mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 17:55:45 +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 <QWidget>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
|
||||||
@@ -127,6 +129,8 @@ namespace BlackGui
|
|||||||
if (m_isMainApplicationWindow && CGuiUtility::isTopLevelWindow(m_widget))
|
if (m_isMainApplicationWindow && CGuiUtility::isTopLevelWindow(m_widget))
|
||||||
{
|
{
|
||||||
m_widget->setAttribute(Qt::WA_NativeWindow);
|
m_widget->setAttribute(Qt::WA_NativeWindow);
|
||||||
|
|
||||||
|
// causeing a BLACK background
|
||||||
m_widget->setAttribute(Qt::WA_NoSystemBackground, frameless);
|
m_widget->setAttribute(Qt::WA_NoSystemBackground, frameless);
|
||||||
m_widget->setAttribute(Qt::WA_TranslucentBackground, frameless); // causing QTBUG-52206
|
m_widget->setAttribute(Qt::WA_TranslucentBackground, frameless); // causing QTBUG-52206
|
||||||
}
|
}
|
||||||
@@ -181,7 +185,7 @@ namespace BlackGui
|
|||||||
bool CEnableForFramelessWindow::handleMouseMoveEvent(QMouseEvent *event)
|
bool CEnableForFramelessWindow::handleMouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_widget);
|
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);
|
m_widget->move(event->globalPos() - m_framelessDragPosition);
|
||||||
event->accept();
|
event->accept();
|
||||||
@@ -194,16 +198,21 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (event->type() != QEvent::WindowStateChange) { return false; }
|
if (event->type() != QEvent::WindowStateChange) { return false; }
|
||||||
if (m_windowMode != WindowTool) { 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
|
// 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
|
// 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
|
// 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())
|
if (m_widget->isMinimized())
|
||||||
{
|
{
|
||||||
// still tool, force normal window
|
// still tool, force normal window
|
||||||
// decouple, otherwise we end up in infinite loop as it triggers a new changeEvent
|
// 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();
|
this->showMinimizedModeChecked();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -211,8 +220,9 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
// not tool, force tool window
|
// not tool, force tool window
|
||||||
// decouple, otherwise we end up in infinite loop as it triggers a new changeEvent
|
// 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();
|
this->showNormalModeChecked();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace BlackGui
|
|||||||
static const QString &windowModeToString(WindowMode m);
|
static const QString &windowModeToString(WindowMode m);
|
||||||
|
|
||||||
protected:
|
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
|
QPushButton *m_framelessCloseButton = nullptr; //!< close button
|
||||||
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
WindowMode m_windowMode = WindowNormal; //!< Window mode, \sa WindowMode
|
||||||
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
WindowMode m_originalWindowMode = WindowNormal; //!< mode when initialized
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ void SwiftGuiStd::mousePressEvent(QMouseEvent *event)
|
|||||||
if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); }
|
if (!handleMousePressEvent(event)) { QMainWindow::mousePressEvent(event); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwiftGuiStd::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_framelessDragPosition = QPoint();
|
||||||
|
QMainWindow::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void SwiftGuiStd::performGracefulShutdown()
|
void SwiftGuiStd::performGracefulShutdown()
|
||||||
{
|
{
|
||||||
if (!m_init) { return; }
|
if (!m_init) { return; }
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
//! @{
|
//! @{
|
||||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual void changeEvent(QEvent *event) override;
|
virtual void changeEvent(QEvent *event) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|||||||
@@ -124,11 +124,22 @@ CoreModes::CoreMode CSwiftLauncher::getCoreMode() const
|
|||||||
return CoreModes::CoreInGuiProcess;
|
return CoreModes::CoreInGuiProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
||||||
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
|
void CSwiftLauncher::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
|
if (!handleMouseMoveEvent(event)) { QDialog::mouseMoveEvent(event); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSwiftLauncher::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
m_framelessDragPosition = QPoint();
|
||||||
|
QDialog::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::displayLatestNews(QNetworkReply *reply)
|
void CSwiftLauncher::displayLatestNews(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(reply);
|
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(reply);
|
||||||
@@ -157,11 +168,6 @@ void CSwiftLauncher::updateInfoAvailable()
|
|||||||
this->loadLatestNews();
|
this->loadLatestNews();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSwiftLauncher::mousePressEvent(QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (!handleMousePressEvent(event)) { QDialog::mousePressEvent(event); }
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSwiftLauncher::init()
|
void CSwiftLauncher::init()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ public:
|
|||||||
bool startDetached();
|
bool startDetached();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc QDialog::mousePressEvent
|
//! Mouse events for frameless window @{
|
||||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
//! \copydoc QDialog::mouseMoveEvent
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
//! @}
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Show the log page
|
//! Show the log page
|
||||||
|
|||||||
Reference in New Issue
Block a user