summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2019-06-12 15:25:58 +0200
committerJonathan Bauer2019-06-12 15:25:58 +0200
commit8670a9b1279738badf449119f015c84e61284a1e (patch)
treee557bba5fac1724c945b9ace6d6d9f1f0826caf1
parentfix missing return and removed unneeded check (diff)
downloadslxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.gz
slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.xz
slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.zip
rework reset timeout stuff
-rw-r--r--src/loginform.cpp22
-rw-r--r--src/settings.h2
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