diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-07 11:59:41 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-07 11:59:41 +0100 |
| commit | 0811ff78e1716a7984aaa315bac0b2b4a8de248d (patch) | |
| tree | 251a38d0aa4c2b5b3f3ced63ae29a4a8d3e5206e /desktop | |
| parent | 4a5f1197ec26518f22925dd0b56bc8a1b0dc6729 (diff) | |
| download | quickshell-0811ff78e1716a7984aaa315bac0b2b4a8de248d.tar.gz quickshell-0811ff78e1716a7984aaa315bac0b2b4a8de248d.zip | |
island: keep the Sonix heart and volume until the player agrees
Diffstat (limited to 'desktop')
| -rw-r--r-- | desktop/island/SonixPanel.qml | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/desktop/island/SonixPanel.qml b/desktop/island/SonixPanel.qml index c884c93..73618d3 100644 --- a/desktop/island/SonixPanel.qml +++ b/desktop/island/SonixPanel.qml @@ -34,11 +34,21 @@ Column { // Position runs locally between polls; each poll resets it. property real pos: 0 - // The heart flips at once; the next poll confirms or reverts it. + // The heart and volume show the local value until a poll agrees, the + // command fails, or overrideExpiry fires. property var favOverride: null Connections { target: Sonix - function onPlayerChanged() { panel.pos = Sonix.player.position || 0; panel.favOverride = null; } + function onPlayerChanged() { + panel.pos = Sonix.player.position || 0; + if (panel.favOverride !== null && !!Sonix.player.favourite === panel.favOverride) panel.favOverride = null; + if (panel.pendingVol >= 0 && !volSend.running && Sonix.player.volume === panel.pendingVol) panel.pendingVol = -1; + } + } + Timer { + id: overrideExpiry + interval: 3000 + onTriggered: { panel.favOverride = null; if (!volSend.running) panel.pendingVol = -1; } } Timer { interval: 1000; repeat: true @@ -54,8 +64,10 @@ Column { interval: 400 onTriggered: { const v = panel.pendingVol; - panel.pendingVol = -1; - if (v >= 0) Sonix.command({ do: "volume", value: v }, null, panel.report); + if (v < 0) return; + Sonix.command({ do: "volume", value: v }, null, + (ok, d, err) => { panel.report(ok, d, err); if (!ok) panel.pendingVol = -1; }); + overrideExpiry.restart(); } } @@ -68,7 +80,7 @@ Column { readonly property string artUrl: p.path ? `${Sonix.base}/api/art?${S.query({ path: p.path, max: 256 })}&t=${artTry}` : "" readonly property string artPath: p.path || "" - onArtPathChanged: { artTry = 0; artRetry.stop(); } + onArtPathChanged: { artTry = 0; artRetry.stop(); favOverride = null; } Timer { id: artRetry; interval: 1000; onTriggered: panel.artTry++ } spacing: 14 @@ -181,7 +193,9 @@ Column { onClicked: { const want = !heart.fav; panel.favOverride = want; - Sonix.command({ do: "favourite", path: panel.p.path, value: want ? 1 : 0 }, null, panel.report); + overrideExpiry.restart(); + Sonix.command({ do: "favourite", path: panel.p.path, value: want ? 1 : 0 }, null, + (ok, d, err) => { panel.report(ok, d, err); if (!ok) panel.favOverride = null; }); } } } |
