Commit 2281b5a6 authored by Johan Ouwerkerk's avatar Johan Ouwerkerk

Fix stale UI when the app is resumed from suspend.

In some cases Keysmith may be suspended and animations/timers are no longer updated.
With this change, the application now detects when it is being 'woken' from suspend and refreshes the UI.
parent d9d110ed
......@@ -24,6 +24,30 @@ AccountEntryViewBase {
}
]
/*
* If the application is suspended the displayed state may be out-of-date by the time the application is woken from
* suspend again. Use a property to monitor for this condition and recover when the application wakes: reset timers,
* animations and recompute token in case it has lapsed.
*/
property bool shouldBeActive: Qt.application.state === Qt.ApplicationActive
onShouldBeActiveChanged: {
if (root.alive && root.shouldBeActive) {
timer.stop()
timeoutIndicatorAnimation.stop();
root.account.recompute();
var phase = root.account.millisecondsLeftForToken();
timer.interval = phase;
root.healthIndicator = phase;
timeoutIndicatorAnimation.duration = phase;
timeoutIndicatorAnimation.from = phase;
timer.restart();
timeoutIndicatorAnimation.restart();
}
}
TokenEntryViewLabels {
id: mainLayout
accountName: account.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment