From d029ce3e3d3ab1acafdc78f2fd4dfde03419c3fd Mon Sep 17 00:00:00 2001 From: Steffen Ritter Date: Thu, 24 Aug 2017 16:42:36 +0200 Subject: Reset 'autoquit' on user interaction --- src/dialog.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/dialog.cpp') diff --git a/src/dialog.cpp b/src/dialog.cpp index f93a8bd..efe659d 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -31,6 +31,7 @@ Dialog::Dialog(int defaultTab, bool examMode, QWidget *parent) userInteracted_ = false; genericExpandedOnce_ = false; examMode_ = examMode; + autoQuit_ = g_autoQuitSeconds; ui->setupUi(this); @@ -183,7 +184,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 :> + autoQuit_ = 0; // So we don't kill the session :> setVisible(false); } else { QMessageBox::warning( @@ -398,13 +399,15 @@ void Dialog::onCenterTimer() { } } // Handle auto-quit timeout - if (g_autoQuitSeconds > 0) { - g_autoQuitSeconds--; - if (g_autoQuitSeconds == 0) { + if (autoQuit_ > 0) { + autoQuit_--; + if (autoQuit_ == 0) { qApp->exit(0); - } else if (g_autoQuitSeconds < 60) { - ui->lblAutoQuit->setText(this->trUtf8("Auto logout in %1").arg(g_autoQuitSeconds)); + } else if (autoQuit_ < 60) { + ui->lblAutoQuit->setText(this->trUtf8("Auto logout in %1").arg(autoQuit_)); ui->lblAutoQuit->show(); + } else if (ui->lblAutoQuit->isVisible()) { + ui->lblAutoQuit->hide(); } } } @@ -822,6 +825,7 @@ void Dialog::selectFirstElement() { /* install this filter to the filterEdit to listen for arrow keys */ bool Dialog::eventFilter(QObject*, QEvent *event) { if (event->type() == QEvent::KeyPress) { + autoQuit_ = g_autoQuitSeconds; QKeyEvent *keyEvent = static_cast(event); bool fortv = false; if (keyEvent->key() == Qt::Key_Right) { @@ -844,6 +848,8 @@ bool Dialog::eventFilter(QObject*, QEvent *event) { ui->treeView->setFocus(); return true; } + } else if (event->type() == QEvent::MouseMove) { + autoQuit_ = g_autoQuitSeconds; } return false; } -- cgit v1.2.3-55-g7522