diff options
author | Jonathan Bauer | 2019-06-04 11:57:24 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-06-04 11:57:24 +0200 |
commit | f6b59f899f3b2b79d7fe57639e8d7aff73d943a4 (patch) | |
tree | d7fa8af991c2838ace9d32cc6a1d36b8e61b2627 | |
parent | reset to "chooser" page on inactivity (diff) | |
download | slxgreeter-f6b59f899f3b2b79d7fe57639e8d7aff73d943a4.tar.gz slxgreeter-f6b59f899f3b2b79d7fe57639e8d7aff73d943a4.tar.xz slxgreeter-f6b59f899f3b2b79d7fe57639e8d7aff73d943a4.zip |
always reset input form when user idles
still defaults to 30 or configurable with 'reset-timeout'.
-rw-r--r-- | src/loginform.cpp | 19 | ||||
-rw-r--r-- | src/loginform.h | 2 | ||||
-rw-r--r-- | src/settings.h | 2 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/loginform.cpp b/src/loginform.cpp index f41d99e..d4f8abd 100644 --- a/src/loginform.cpp +++ b/src/loginform.cpp @@ -91,13 +91,13 @@ void LoginForm::initialize() this->checkCaps(); }); - resetFormTimer.setInterval(Settings::sessionChooserResetTimer() != 0 ? - Settings::sessionChooserResetTimer() * 1000 : 30000); // default to 30s + // timer to reset the form to its original state + resetFormTimer.setInterval(Settings::resetForm() != 0 ? + Settings::resetForm() * 1000 : 30000); // default to 30s connect(&resetFormTimer, &QTimer::timeout, this, [this]() { long idleTime = static_cast<long>(getIdleTime(QX11Info::display())); - std::cerr << "User idle time: " << idleTime << std::endl; - if (idleTime > Settings::sessionChooserResetTimer() * 1000l) - resetLoginChooser(); + if (idleTime > Settings::resetForm() * 1000l) + resetForm(); }); resetFormTimer.start(); @@ -136,7 +136,7 @@ void LoginForm::initialize() ui->loginChooser->setCurrentWidget(ui->guestPage); }); connect(ui->backButton, &QAbstractButton::released, this, [this]() { - resetLoginChooser(); + resetForm(); }); connect(ui->loginChooser, &QStackedWidget::currentChanged, this, [this]() { if (ui->loginChooser->currentWidget() == ui->welcomePage) { @@ -320,15 +320,16 @@ void LoginForm::keyPressEvent(QKeyEvent *event) } } if (Settings::guestSessionEnabled() && event->key() == Qt::Key_Escape) { - resetLoginChooser(); + resetForm(); } // Fallback: Passthrough QWidget::keyPressEvent(event); } -void LoginForm::resetLoginChooser() +void LoginForm::resetForm() { - ui->loginChooser->setCurrentWidget(ui->welcomePage); + if (Settings::guestSessionEnabled()) + ui->loginChooser->setCurrentWidget(ui->welcomePage); ui->userInput->clear(); ui->passwordInput->clear(); } diff --git a/src/loginform.h b/src/loginform.h index 64edacc..79a862e 100644 --- a/src/loginform.h +++ b/src/loginform.h @@ -55,7 +55,7 @@ private: QString currentSession(); void setCurrentSession(QString session); void showMessage(QString message, bool error); - void resetLoginChooser(); + void resetForm(); Ui::LoginForm *ui; QMap<int, void (QLightDM::PowerInterface::*)()> powerSlots; diff --git a/src/settings.h b/src/settings.h index e61a8a1..c2488b5 100644 --- a/src/settings.h +++ b/src/settings.h @@ -48,7 +48,7 @@ public: static QString guestSessionButtonText() { return s_settings->value("guest-session-button-text").toString(); } static QString guestSessionStartText() { return s_settings->value("guest-session-start-text").toString(); } static QString guestSessionStartButtonText() { return s_settings->value("guest-session-start-button-text").toString(); } - static int sessionChooserResetTimer() { return s_settings->value("session-chooser-reset-timer").toInt(); } + static int resetForm() { return s_settings->value("reset-timeout").toInt(); } }; #endif // SETTINGS_H |