diff options
author | Georg Zotti <Georg.Zotti@univie.ac.at> | 2021-12-27 22:56:39 +0100 |
---|---|---|
committer | Georg Zotti <Georg.Zotti@univie.ac.at> | 2021-12-27 22:56:39 +0100 |
commit | e4f6ff223dbea4e62c0104b59805ca6a35fd076a (patch) | |
tree | 3674f408071909aa340b70608a4e01b8ac137914 | |
parent | 9991aaf00e7871a45aa00990ed07f578d393bc02 (diff) |
Allow moving StelDialogSeparate to a separate screenonlinequeries-secondscreen
-rw-r--r-- | src/gui/Dialog.cpp | 35 | ||||
-rw-r--r-- | src/gui/Dialog.hpp | 4 | ||||
-rw-r--r-- | src/gui/StelDialogSeparate.cpp | 10 |
3 files changed, 22 insertions, 27 deletions
diff --git a/src/gui/Dialog.cpp b/src/gui/Dialog.cpp index 045f2bb2f4..695cfc8766 100644 --- a/src/gui/Dialog.cpp +++ b/src/gui/Dialog.cpp @@ -42,21 +42,26 @@ void BarFrame::mouseMoveEvent(QMouseEvent *event) QWidget* p = dynamic_cast<QWidget*>(QFrame::parent()); QPoint targetPos = p->pos() + dpos; - // Prevent the title bar from being dragged to an unreachable position. - QWidget& mainWindow = StelMainView::getInstance(); - int leftBoundX = 10 - width(); - int rightBoundX = mainWindow.width() - 10; - if (targetPos.x() < leftBoundX) - targetPos.setX(leftBoundX); - else if (targetPos.x() > rightBoundX) - targetPos.setX(rightBoundX); - - int lowerBoundY = mainWindow.height() - height(); - if (targetPos.y() < 0) - targetPos.setY(0); - else if (targetPos.y() > lowerBoundY) - targetPos.setY(lowerBoundY); - + QWidget *parent=parentWidget(); + Q_ASSERT(parent); + + if (!(parent->inherits("CustomDialog"))) + { + // Prevent the title bar from being dragged to an unreachable position. + QWidget& mainWindow = StelMainView::getInstance(); + int leftBoundX = 10 - width(); + int rightBoundX = mainWindow.width() - 10; + if (targetPos.x() < leftBoundX) + targetPos.setX(leftBoundX); + else if (targetPos.x() > rightBoundX) + targetPos.setX(rightBoundX); + + int lowerBoundY = mainWindow.height() - height(); + if (targetPos.y() < 0) + targetPos.setY(0); + else if (targetPos.y() > lowerBoundY) + targetPos.setY(lowerBoundY); + } p->move(targetPos); //emit movedTo(targetPos); } diff --git a/src/gui/Dialog.hpp b/src/gui/Dialog.hpp index d07f15e077..521b3f237b 100644 --- a/src/gui/Dialog.hpp +++ b/src/gui/Dialog.hpp @@ -65,10 +65,10 @@ public: ResizeFrame(QWidget* parent) : QFrame(parent) {} - virtual void mousePressEvent(QMouseEvent *event) { + virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE { mousePos = event->pos(); } - virtual void mouseMoveEvent(QMouseEvent *event); + virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; }; diff --git a/src/gui/StelDialogSeparate.cpp b/src/gui/StelDialogSeparate.cpp index d02a430f85..fc216c00a2 100644 --- a/src/gui/StelDialogSeparate.cpp +++ b/src/gui/StelDialogSeparate.cpp @@ -84,16 +84,6 @@ void StelDialogSeparate::setVisible(bool v) if (gui) dialog->setStyleSheet(gui->getStelStyle().qtStyleSheet); dialog->show(); - // If the main window has been resized, it is possible the dialog - // will be off screen. Check for this and move it to a visible - // position if necessary - QPointF newPos = dialog->pos(); - if (newPos.x()>=screenSize.width()) - newPos.setX(screenSize.width() - dialog->size().width()); - if (newPos.y()>=screenSize.height()) - newPos.setY(screenSize.height() - dialog->size().height()); - if (newPos != dialog->pos()) - dialog->move(newPos.toPoint()); } else { |