summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2013-12-19 16:57:29 +0100
committerSimon Rettberg2013-12-19 16:57:29 +0100
commite2c71c3844de35f20b9c7af8c513c993cf06cebb (patch)
treec4e81bf3483a1458766cbd915187d303218998d8 /src/dialog.cpp
parentAdd support for a session start script that gets run right before the session... (diff)
downloadvmchooser-e2c71c3844de35f20b9c7af8c513c993cf06cebb.tar.gz
vmchooser-e2c71c3844de35f20b9c7af8c513c993cf06cebb.tar.xz
vmchooser-e2c71c3844de35f20b9c7af8c513c993cf06cebb.zip
Check if the window is still centered once a second and move it if neccessary.
This is needed to account for resolution changes while the vmChooser is being displayed.
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 21c5620..8ff215e 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -5,6 +5,8 @@
#include <QRegExp>
#include <QFile>
#include <QProcess>
+#include <QTimer>
+#include <QDesktopWidget>
#include "ui_dialog.h"
#include "save_restore_session.h"
@@ -18,6 +20,13 @@ Dialog::Dialog(QWidget *parent)
pvsSettings_ = NULL;
ui->PVSOptionsGroupBox->hide();
+
+ // Re-center dialog every second to account for resolution changes
+ QRect desktopRect = QApplication::desktop()->availableGeometry(this);
+ oldCenter_ = desktopRect.center();
+ centerTimer_ = new QTimer(this);
+ connect(centerTimer_, SIGNAL(timeout()), this, SLOT(on_centerTimer()));
+ centerTimer_->start(1000);
}
Dialog::~Dialog() {
@@ -212,3 +221,14 @@ void Dialog::setTheme() {
ui->label_l->setStyleSheet(label_l_style);
ui->label_r->setStyleSheet(label_r_style);
}
+
+void Dialog::on_centerTimer() {
+ // center dialog on primary screen
+ QRect desktopRect = QApplication::desktop()->availableGeometry(this);
+ QPoint center = desktopRect.center();
+ if (center != oldCenter_) {
+ this->move(center.x() - this->width() / 2, center.y() - this->height() / 2);
+ oldCenter_ = center;
+ }
+}
+