diff options
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/modules/appearance/WallEngineModule.qml | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/desktop/modules/appearance/WallEngineModule.qml b/desktop/modules/appearance/WallEngineModule.qml index 5b8a39c..9eb191c 100644 --- a/desktop/modules/appearance/WallEngineModule.qml +++ b/desktop/modules/appearance/WallEngineModule.qml @@ -37,10 +37,30 @@ Module { Row { spacing: 8 Text { + id: status + // Only ticks while the page is open: the engine + // itself keeps nextAt, not a count. + property double now: Date.now() + Timer { + interval: 1000 + repeat: true + running: WallEngine.on + triggeredOnStart: true + onTriggered: status.now = Date.now() + } + // Floored, as now can be up to a second old: a + // restarted timer reads the full interval, not one + // second over it. Not named left: that is Item's + // anchor line, which a function cannot shadow. + function remaining() { + const s = Math.max(0, Math.floor((WallEngine.nextAt - now) / 1000)); + const two = n => (n < 10 ? "0" : "") + n; + const h = Math.floor(s / 3600); + return (h > 0 ? h + ":" : "") + two(Math.floor(s / 60) % 60) + ":" + two(s % 60); + } anchors.verticalCenter: parent.verticalCenter text: WallEngine.dirty ? "unsaved changes" - : WallEngine.on ? "running, next change at " - + Qt.formatTime(new Date(WallEngine.nextAt), "hh:mm") + : WallEngine.on ? "running, next change in " + remaining() : "stopped" color: WallEngine.dirty ? Theme.yellow : WallEngine.on ? Theme.green : Theme.overlay font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } |
