diff options
author | Jonathan Bauer | 2019-06-12 15:25:58 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-06-12 15:25:58 +0200 |
commit | 8670a9b1279738badf449119f015c84e61284a1e (patch) | |
tree | e557bba5fac1724c945b9ace6d6d9f1f0826caf1 | |
parent | fix missing return and removed unneeded check (diff) | |
download | slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.gz slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.xz slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.zip |
rework reset timeout stuff
-rw-r--r-- | src/loginform.cpp | 22 | ||||
-rw-r--r-- | src/settings.h | 2 |
2 files changed, 15 insertions, 9 deletions
diff --git a/src/loginform.cpp b/src/loginform.cpp index d4f8abd..8badf4e 100644 --- a/src/loginform.cpp +++ b/src/loginform.cpp @@ -92,14 +92,20 @@ void LoginForm::initialize() }); // 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())); - if (idleTime > Settings::resetForm() * 1000l) - resetForm(); - }); - resetFormTimer.start(); + if (Settings::resetForm() != 0) { + resetFormTimer.setInterval(Settings::resetForm()); + connect(&resetFormTimer, &QTimer::timeout, this, [this]() { + int idleTime = static_cast<int>(getIdleTime(QX11Info::display())); + int remaining = Settings::resetForm() * 1000 - idleTime; + if (remaining <= 0) { + resetForm(); + remaining = Settings::resetForm() * 1000; + } + resetFormTimer.start(remaining + 100); + + }); + resetFormTimer.start(); + } if (!Global::testMode()) { ui->hostnameLabel->setText(Global::greeter()->hostname()); diff --git a/src/settings.h b/src/settings.h index c2488b5..8a0cf81 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 resetForm() { return s_settings->value("reset-timeout").toInt(); } + static int resetForm() { return s_settings->value("reset-timeout", "30").toInt(); } }; #endif // SETTINGS_H |