mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-02-02 13:52:55 +08:00
the popup dialog able to move
This commit is contained in:
parent
8f74bacf3b
commit
c56540a03a
@ -52,7 +52,11 @@ DSDialog::DSDialog(QWidget *parent, bool hasClose):
|
|||||||
}
|
}
|
||||||
|
|
||||||
DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) :
|
DSDialog::DSDialog(QWidget *parent, bool hasClose, bool bBaseButton) :
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QDialog(NULL), //enable the popup dialog draged.
|
||||||
|
#else
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
#endif
|
||||||
m_bBaseButton(bBaseButton)
|
m_bBaseButton(bBaseButton)
|
||||||
{
|
{
|
||||||
(void)parent;
|
(void)parent;
|
||||||
|
@ -38,7 +38,11 @@ namespace pv {
|
|||||||
namespace dialogs {
|
namespace dialogs {
|
||||||
|
|
||||||
DSMessageBox::DSMessageBox(QWidget *parent,const QString title) :
|
DSMessageBox::DSMessageBox(QWidget *parent,const QString title) :
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QDialog(NULL) //enable the popup dialog draged.
|
||||||
|
#else
|
||||||
QDialog(parent)
|
QDialog(parent)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
(void)parent;
|
(void)parent;
|
||||||
_layout = NULL;
|
_layout = NULL;
|
||||||
|
@ -35,14 +35,11 @@
|
|||||||
#include "../appcontrol.h"
|
#include "../appcontrol.h"
|
||||||
#include "../dsvdef.h"
|
#include "../dsvdef.h"
|
||||||
#include "../ui/fn.h"
|
#include "../ui/fn.h"
|
||||||
|
#include "../log.h"
|
||||||
|
|
||||||
namespace pv {
|
namespace pv {
|
||||||
namespace toolbars {
|
namespace toolbars {
|
||||||
|
|
||||||
namespace{
|
|
||||||
static bool _is_able_drag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
TitleBar::TitleBar(bool top, QWidget *parent, ITitleParent *titleParent, bool hasClose) :
|
TitleBar::TitleBar(bool top, QWidget *parent, ITitleParent *titleParent, bool hasClose) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
@ -58,9 +55,14 @@ TitleBar::TitleBar(bool top, QWidget *parent, ITitleParent *titleParent, bool ha
|
|||||||
_is_native = false;
|
_is_native = false;
|
||||||
_titleParent = titleParent;
|
_titleParent = titleParent;
|
||||||
_is_done_moved = false;
|
_is_done_moved = false;
|
||||||
|
_is_able_drag = true;
|
||||||
|
|
||||||
assert(parent);
|
assert(parent);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
_hMonitor = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
setObjectName("TitleBar");
|
setObjectName("TitleBar");
|
||||||
setContentsMargins(0,0,0,0);
|
setContentsMargins(0,0,0,0);
|
||||||
setFixedHeight(32);
|
setFixedHeight(32);
|
||||||
@ -262,6 +264,12 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
if (!_moving){
|
if (!_moving){
|
||||||
if (ABS_VAL(datX) >= 2 || ABS_VAL(datY) >= 2){
|
if (ABS_VAL(datX) >= 2 || ABS_VAL(datY) >= 2){
|
||||||
_moving = true;
|
_moving = true;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
POINT cursorPos;
|
||||||
|
GetCursorPos(&cursorPos);
|
||||||
|
_hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return;
|
return;
|
||||||
@ -278,7 +286,18 @@ void TitleBar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
_titleParent->MoveWindow(x, y);
|
_titleParent->MoveWindow(x, y);
|
||||||
}
|
}
|
||||||
else{
|
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();
|
event->accept();
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
#define DSVIEW_PV_TOOLBARS_TITLEBAR_H
|
#define DSVIEW_PV_TOOLBARS_TITLEBAR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../interface/icallbacks.h"
|
#include "../interface/icallbacks.h"
|
||||||
#include "../ui/xtoolbutton.h"
|
#include "../ui/xtoolbutton.h"
|
||||||
#include "../ui/uimanager.h"
|
#include "../ui/uimanager.h"
|
||||||
@ -107,7 +112,12 @@ protected:
|
|||||||
QWidget *_parent;
|
QWidget *_parent;
|
||||||
bool _is_native;
|
bool _is_native;
|
||||||
ITitleParent *_titleParent;
|
ITitleParent *_titleParent;
|
||||||
bool _is_done_moved;
|
bool _is_done_moved;
|
||||||
|
bool _is_able_drag;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
HMONITOR _hMonitor;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace toolbars
|
} // namespace toolbars
|
||||||
|
Loading…
x
Reference in New Issue
Block a user