From c56540a03ad759eaa30404420142873fdc023132 Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Sat, 20 Apr 2024 20:56:40 +0800 Subject: [PATCH] the popup dialog able to move --- DSView/pv/dialogs/dsdialog.cpp | 4 ++++ DSView/pv/dialogs/dsmessagebox.cpp | 4 ++++ DSView/pv/toolbars/titlebar.cpp | 29 ++++++++++++++++++++++++----- DSView/pv/toolbars/titlebar.h | 12 +++++++++++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/DSView/pv/dialogs/dsdialog.cpp b/DSView/pv/dialogs/dsdialog.cpp index ec770bc6..55541011 100644 --- a/DSView/pv/dialogs/dsdialog.cpp +++ b/DSView/pv/dialogs/dsdialog.cpp @@ -52,7 +52,11 @@ DSDialog::DSDialog(QWidget *parent, bool hasClose): } DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) : +#ifdef Q_OS_LINUX + QDialog(NULL), //enable the popup dialog draged. +#else QDialog(parent), +#endif m_bBaseButton(bBaseButton) { (void)parent; diff --git a/DSView/pv/dialogs/dsmessagebox.cpp b/DSView/pv/dialogs/dsmessagebox.cpp index 09bf4384..c8cf41f0 100644 --- a/DSView/pv/dialogs/dsmessagebox.cpp +++ b/DSView/pv/dialogs/dsmessagebox.cpp @@ -38,7 +38,11 @@ namespace pv { namespace dialogs { DSMessageBox::DSMessageBox(QWidget *parent,const QString title) : +#ifdef Q_OS_LINUX + QDialog(NULL) //enable the popup dialog draged. +#else QDialog(parent) +#endif { (void)parent; _layout = NULL; diff --git a/DSView/pv/toolbars/titlebar.cpp b/DSView/pv/toolbars/titlebar.cpp index 006d1db1..d755df22 100644 --- a/DSView/pv/toolbars/titlebar.cpp +++ b/DSView/pv/toolbars/titlebar.cpp @@ -35,14 +35,11 @@ #include "../appcontrol.h" #include "../dsvdef.h" #include "../ui/fn.h" +#include "../log.h" namespace pv { namespace toolbars { -namespace{ - static bool _is_able_drag = true; -} - TitleBar::TitleBar(bool top, QWidget *parent, ITitleParent *titleParent, bool hasClose) : QWidget(parent) { @@ -58,9 +55,14 @@ TitleBar::TitleBar(bool top, QWidget *parent, ITitleParent *titleParent, bool ha _is_native = false; _titleParent = titleParent; _is_done_moved = false; + _is_able_drag = true; assert(parent); +#ifdef _WIN32 + _hMonitor = NULL; +#endif + setObjectName("TitleBar"); setContentsMargins(0,0,0,0); setFixedHeight(32); @@ -262,6 +264,12 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event) if (!_moving){ if (ABS_VAL(datX) >= 2 || ABS_VAL(datY) >= 2){ _moving = true; + +#ifdef _WIN32 + POINT cursorPos; + GetCursorPos(&cursorPos); + _hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); +#endif } else{ return; @@ -278,7 +286,18 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event) _titleParent->MoveWindow(x, y); } else{ - _parent->move(x, y); + +#ifdef _WIN32 + POINT cursorPos; + GetCursorPos(&cursorPos); + HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + if (hMonitor != _hMonitor){ + event->ignore(); + return; + } +#endif + + _parent->move(x, y); } event->accept(); diff --git a/DSView/pv/toolbars/titlebar.h b/DSView/pv/toolbars/titlebar.h index 7af3ed5d..91842a1e 100644 --- a/DSView/pv/toolbars/titlebar.h +++ b/DSView/pv/toolbars/titlebar.h @@ -23,6 +23,11 @@ #define DSVIEW_PV_TOOLBARS_TITLEBAR_H #include + +#ifdef _WIN32 +#include +#endif + #include "../interface/icallbacks.h" #include "../ui/xtoolbutton.h" #include "../ui/uimanager.h" @@ -107,7 +112,12 @@ protected: QWidget *_parent; bool _is_native; ITitleParent *_titleParent; - bool _is_done_moved; + bool _is_done_moved; + bool _is_able_drag; + +#ifdef _WIN32 +HMONITOR _hMonitor; +#endif }; } // namespace toolbars