the popup dialog able to move

This commit is contained in:
dreamsourcelabTAI 2024-04-20 20:56:40 +08:00
parent 8f74bacf3b
commit c56540a03a
4 changed files with 43 additions and 6 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -23,6 +23,11 @@
#define DSVIEW_PV_TOOLBARS_TITLEBAR_H
#include <QWidget>
#ifdef _WIN32
#include <windows.h>
#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