aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-06 18:03:44 +0100
committerDanilo M. <danix@danix.xyz>2026-11-06 18:03:44 +0100
commit9d4d35d2044131dcb8d0db19d2b2fa5585afd5c6 (patch)
treeaae20f0fcaae812839fac4655ec835c75bc7d037 /desktop/modules/appearance
parent157d6070847d4e1ce76c5d7cf6d118f25ffa13de (diff)
downloadquickshell-9d4d35d2044131dcb8d0db19d2b2fa5585afd5c6.tar.gz
quickshell-9d4d35d2044131dcb8d0db19d2b2fa5585afd5c6.zip
wallpaper engine: count down to the next change
The header gave the clock time of the next change, which left the sum to the reader. It now counts down, from a one second timer that lives on the page, so nothing ticks while the page is closed. The engine still keeps only nextAt. The function is remaining(), not left(): left is Item's anchor line, so the call threw a TypeError and the status text went blank, which a clean hot reload does not show until the page is opened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'desktop/modules/appearance')
-rw-r--r--desktop/modules/appearance/WallEngineModule.qml24
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 }