From 4ada6a9de4c04757ae2d8855458cfc14425c7e32 Mon Sep 17 00:00:00 2001 From: shun_iwasawa Date: Nov 14 2016 06:56:58 +0000 Subject: dialog position fix --- diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cpp index 02fb1b2..b9d46c3 100644 --- a/toonz/sources/toonz/penciltestpopup.cpp +++ b/toonz/sources/toonz/penciltestpopup.cpp @@ -569,17 +569,16 @@ void LevelNameLineEdit::onEditingFinished() { //============================================================================= PencilTestPopup::PencilTestPopup() - : Dialog(TApp::instance()->getMainWindow(), false, false, "PencilTest") - , m_currentCamera(NULL) - , m_cameraImageCapture(NULL) - , m_captureWhiteBGCue(false) - , m_captureCue(false) { + // set the parent 0 in order to enable the popup behind the main window + : Dialog(0, false, false, "PencilTest"), + m_currentCamera(NULL), + m_cameraImageCapture(NULL), + m_captureWhiteBGCue(false), + m_captureCue(false) { setWindowTitle(tr("Camera Capture")); // add maximize button to the dialog - Qt::WindowFlags flags = windowFlags(); - flags |= Qt::WindowMaximizeButtonHint; - setWindowFlags(flags); + setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); layout()->setSizeConstraint(QLayout::SetNoConstraint); @@ -1241,6 +1240,7 @@ void PencilTestPopup::hideEvent(QHideEvent* event) { if (m_currentCamera->state() == QCamera::LoadedState) m_currentCamera->unload(); } + Dialog::hideEvent(event); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonzqt/dvdialog.cpp b/toonz/sources/toonzqt/dvdialog.cpp index 59cfbd8..ee19d27 100644 --- a/toonz/sources/toonzqt/dvdialog.cpp +++ b/toonz/sources/toonzqt/dvdialog.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // boost includes #include @@ -286,8 +287,16 @@ Dialog::Dialog(QWidget *parent, bool hasButton, bool hasFixedSize, if (geo != QString()) { QStringList values = geo.split(" "); assert(values.size() == 4); - setGeometry(values.at(0).toInt(), std::max(30, values.at(1).toInt()), - values.at(2).toInt(), values.at(3).toInt()); + // Ensure that the dialog is visible in the screen. + // The dialog opens with some offset to bottom-right direction + // if a flag Qt::WindowMaximizeButtonHint is set. (e.g. PencilTestPopup) + // Therefore, if the dialog is moved to the bottom-end of the screen, + // it will be got out of the screen on the next launch. + // The following position adjustment will also prevent such behavior. + QRect screen = QApplication::desktop()->screenGeometry(); + int x = std::min(values.at(0).toInt(), screen.width() - 50); + int y = std::min(std::max(30, values.at(1).toInt()), screen.height() - 90); + setGeometry(x, y, values.at(2).toInt(), values.at(3).toInt()); } }