mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Ref T560, reset move position
This commit is contained in:
committed by
Mat Sutcliffe
parent
0d0e093330
commit
66cbe1662e
@@ -29,6 +29,8 @@
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -127,6 +129,8 @@ namespace BlackGui
|
||||
if (m_isMainApplicationWindow && CGuiUtility::isTopLevelWindow(m_widget))
|
||||
{
|
||||
m_widget->setAttribute(Qt::WA_NativeWindow);
|
||||
|
||||
// causeing a BLACK background
|
||||
m_widget->setAttribute(Qt::WA_NoSystemBackground, frameless);
|
||||
m_widget->setAttribute(Qt::WA_TranslucentBackground, frameless); // causing QTBUG-52206
|
||||
}
|
||||
@@ -181,7 +185,7 @@ namespace BlackGui
|
||||
bool CEnableForFramelessWindow::handleMouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_ASSERT(m_widget);
|
||||
if (m_windowMode == WindowFrameless && event->buttons() & Qt::LeftButton)
|
||||
if (m_windowMode == WindowFrameless && event->buttons() & Qt::LeftButton && !m_framelessDragPosition.isNull())
|
||||
{
|
||||
m_widget->move(event->globalPos() - m_framelessDragPosition);
|
||||
event->accept();
|
||||
@@ -194,16 +198,21 @@ namespace BlackGui
|
||||
{
|
||||
if (event->type() != QEvent::WindowStateChange) { return false; }
|
||||
if (m_windowMode != WindowTool) { return false; }
|
||||
if (!m_widget) { return false; }
|
||||
|
||||
// make sure a tool window is changed to Normal window so it is show in taskbar
|
||||
// here we are already in transition state, so isMinimized means will be minimize right now
|
||||
// this check here is needed if minimized is called from somewhere else than ps_showMinimized
|
||||
|
||||
QPointer<QWidget> widgetSelf(m_widget); // almost as good as myself
|
||||
if (m_widget->isMinimized())
|
||||
{
|
||||
// still tool, force normal window
|
||||
// decouple, otherwise we end up in infinite loop as it triggers a new changeEvent
|
||||
BlackMisc::singleShot(0, QThread::currentThread(), [ = ]()
|
||||
|
||||
QTimer::singleShot(0, m_widget, [ = ]
|
||||
{
|
||||
if (!widgetSelf) { return; }
|
||||
this->showMinimizedModeChecked();
|
||||
});
|
||||
}
|
||||
@@ -211,8 +220,9 @@ namespace BlackGui
|
||||
{
|
||||
// not tool, force tool window
|
||||
// decouple, otherwise we end up in infinite loop as it triggers a new changeEvent
|
||||
BlackMisc::singleShot(0, QThread::currentThread(), [ = ]()
|
||||
QTimer::singleShot(0, m_widget, [ = ]
|
||||
{
|
||||
if (!widgetSelf) { return; }
|
||||
this->showNormalModeChecked();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace BlackGui
|
||||
static const QString &windowModeToString(WindowMode m);
|
||||
|
||||
protected:
|
||||
QPoint m_framelessDragPosition; //!< position, if moving is handled with frameless window */
|
||||
QPoint m_framelessDragPosition; //!< position, if moving is handled with frameless window
|
||||
QPushButton *m_framelessCloseButton = nullptr; //!< close button
|
||||
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
||||
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
||||
|
||||
@@ -94,6 +94,12 @@ void SwiftGuiStd::mousePressEvent(QMouseEvent *event)
|
||||
if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); }
|
||||
}
|
||||
|
||||
void SwiftGuiStd::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_framelessDragPosition = QPoint();
|
||||
QMainWindow::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void SwiftGuiStd::performGracefulShutdown()
|
||||
{
|
||||
if (!m_init) { return; }
|
||||
|
||||
@@ -85,6 +85,7 @@ protected:
|
||||
//! @{
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual void changeEvent(QEvent *event) override;
|
||||
//! @}
|
||||
|
||||
@@ -124,11 +124,22 @@ CoreModes::CoreMode CSwiftLauncher::getCoreMode() const
|
||||
return CoreModes::CoreInGuiProcess;
|
||||
}
|
||||
|
||||
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||
}
|
||||
|
||||
void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
|
||||
}
|
||||
|
||||
void CSwiftLauncher::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_framelessDragPosition = QPoint();
|
||||
QDialog::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void CSwiftLauncher::displayLatestNews(QNetworkReply *reply)
|
||||
{
|
||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(reply);
|
||||
@@ -157,11 +168,6 @@ void CSwiftLauncher::updateInfoAvailable()
|
||||
this->loadLatestNews();
|
||||
}
|
||||
|
||||
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||
}
|
||||
|
||||
void CSwiftLauncher::init()
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||
|
||||
@@ -73,11 +73,11 @@ public:
|
||||
bool startDetached();
|
||||
|
||||
protected:
|
||||
//! \copydoc QDialog::mousePressEvent
|
||||
//! Mouse events for frameless window @{
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
//! \copydoc QDialog::mouseMoveEvent
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Show the log page
|
||||
|
||||
Reference in New Issue
Block a user