summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2016-12-22 14:02:31 +0100
committerSimon Rettberg2016-12-22 14:02:31 +0100
commit69a87ddf7faee8b26747b3e0c1cc97ab06bc779d (patch)
tree9f835c13c1a367af994e79734989d8f08f385bb2 /src/dialog.cpp
parentDon't lower() window on startup (diff)
downloadvmchooser2-69a87ddf7faee8b26747b3e0c1cc97ab06bc779d.tar.gz
vmchooser2-69a87ddf7faee8b26747b3e0c1cc97ab06bc779d.tar.xz
vmchooser2-69a87ddf7faee8b26747b3e0c1cc97ab06bc779d.zip
Add --autoquit <seconds> that will quit automatically if no action is performed within a given time span
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 6b934e9..105d476 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -55,6 +55,7 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent)
ui->helpBox->hide();
ui->newsBox->hide();
+ ui->lblAutoQuit->hide();
this->addStatusString(STR_LOADING);
@@ -166,6 +167,7 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index)
}
ChooserSettings::setSetting("last-session", (s->shortDescription()));
ChooserSettings::setSetting("last-tab", QString::number(activeTab_));
+ g_autoQuitSeconds = 0; // So we don't kill the session :>
setVisible(false);
} else {
QMessageBox::warning(
@@ -369,13 +371,25 @@ void Dialog::setTheme() {
void Dialog::onCenterTimer() {
// center dialog on primary screen
- QRect desktopRect = QApplication::desktop()->availableGeometry(this);
- QPoint center = desktopRect.center();
- if (center != oldCenter_) {
- if (_fullscreen)
- this->resize(desktopRect.width(), desktopRect.height());
- this->move(center.x() - this->width() / 2, center.y() - this->height() / 2);
- oldCenter_ = center;
+ if (isVisible()) {
+ QRect desktopRect = QApplication::desktop()->availableGeometry(this);
+ QPoint center = desktopRect.center();
+ if (center != oldCenter_) {
+ if (_fullscreen)
+ this->resize(desktopRect.width(), desktopRect.height());
+ this->move(center.x() - this->width() / 2, center.y() - this->height() / 2);
+ oldCenter_ = center;
+ }
+ }
+ // Handle auto-quit timeout
+ if (g_autoQuitSeconds > 0) {
+ g_autoQuitSeconds--;
+ if (g_autoQuitSeconds == 0) {
+ qApp->exit(0);
+ } else if (g_autoQuitSeconds < 60) {
+ ui->lblAutoQuit->setText(this->trUtf8("Auto logout in %1").arg(g_autoQuitSeconds));
+ ui->lblAutoQuit->show();
+ }
}
}