feat(slint): persist sidebar state, volume and nav placement

Restore across restarts: the three-state sidebar (open/mini/closed) and
the section-nav placement (sidebar vs header) seed from ui_prefs before
the shell renders and persist via new ShellState callbacks; the player
volume persists on slider release only (a new QbzSlider `released`
callback + NowPlayingState.persist-volume — no ui_prefs write per drag
tick) and is reapplied to the player on session entry.

cc
This commit is contained in:
vicrodh committed 2026-06-22 23:57:08 -06:00
1 parent be8c90bb80
commit 2c9104e1e3
6 files changed
+74 -1

No files matched your search

@@ -11,6 +11,9 @@ export component QbzSlider inherits Rectangle {
in property <int> maximum: 10;
in property <int> value: 0;
callback changed(int);
// Fired once on pointer release (drag end) — for callers that want to
// commit/persist only the final value, not every intermediate `changed`.
callback released(int);
width: 200px;
height: 22px;
@@ -72,6 +75,9 @@ export component QbzSlider inherits Rectangle {
&& root.value-from-x(self.mouse-x) != root.value) {
root.changed(root.value-from-x(self.mouse-x));
}
if (e.kind == PointerEventKind.up) {
root.released(root.value);
}
}
// Continuous drag while held.
moved => {
@@ -322,6 +322,7 @@ export component AppearanceSettings inherits VerticalLayout {
checked: ShellState.nav-in-sidebar;
toggled(v) => {
ShellState.nav-in-sidebar = v;
ShellState.persist-nav(v);
}
}
}
@@ -847,6 +847,13 @@ export component PlayerBar inherits Rectangle {
NowPlayingState.set-volume(v / 100.0);
}
}
// Persist only the final value on drag-end (avoids a
// ui_prefs write per drag tick).
released(v) => {
if (!root.vol-locked) {
NowPlayingState.persist-volume(v / 100.0);
}
}
}
}
if AppearanceState.show-volume-steppers: VerticalLayout {
+6 -1
View File
@@ -3403,11 +3403,15 @@ export global ShellState {
// reverts LIVE to New (0). The persisted ui_prefs key stays "large", so a
// later relaunch (sidebar defaults open) restores Large — the revert is a
// compatibility fallback, not a preference change.
// Persist the sidebar state / nav placement (wired to ui_prefs in Rust).
callback persist-sidebar-state(int);
callback persist-nav(bool);
public function cycle-sidebar() {
root.sidebar-state = Math.mod(root.sidebar-state + 1, 3);
if (root.sidebar-state != 0 && root.npb-mode == 3) {
root.npb-mode = 0;
}
root.persist-sidebar-state(root.sidebar-state);
}
// Right-side panels — independent now: Queue and Lyrics can BOTH be open
// at once, stacked vertically in a shared right column (Feishin-style). Each
@@ -3708,7 +3712,8 @@ export global NowPlayingState {
callback next();
callback previous();
callback seek(float); // 0..1
callback set-volume(float); // 0..1
callback set-volume(float); // 0..1 — live (fires on every drag tick)
callback persist-volume(float); // 0..1 — drag-end only, persists to ui_prefs
callback toggle-mute();
callback toggle-shuffle();
callback cycle-repeat();