summaryrefslogtreecommitdiffstats
path: root/src/loginform.cpp
diff options
context:
space:
mode:
authorJonathan Bauer2019-06-12 15:25:58 +0200
committerJonathan Bauer2019-06-12 15:25:58 +0200
commit8670a9b1279738badf449119f015c84e61284a1e (patch)
treee557bba5fac1724c945b9ace6d6d9f1f0826caf1 /src/loginform.cpp
parentfix missing return and removed unneeded check (diff)
downloadslxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.gz
slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.tar.xz
slxgreeter-8670a9b1279738badf449119f015c84e61284a1e.zip
rework reset timeout stuff
Diffstat (limited to 'src/loginform.cpp')
-rw-r--r--src/loginform.cpp22
1 files changed, 14 insertions, 8 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());