feat(slint): persist session across restarts (startup page, window geometry, playback)

Three restart-persistence features built and tested together (they share
ui_prefs + the enter_shell restore sequence, so kept as one change):

- Startup page: persist + restore the last SAFE top-level view via the
  canonical apply_entry dispatcher (loads data, not a blank view). Wired to
  Settings > Appearance > "Where you left off"; ui_prefs startup_page/last_view.
- Window geometry: persist logical size + outer position and restore them at
  launch, clamped to the current monitor so a smaller/disconnected display can
  never open an oversized or off-screen window (winit Resized/Moved hook).
- Playback session: new session_persist module wiring qbz-app's SessionStore.
  Saves queue + current track + volume + shuffle/repeat + position on
  track-change / pause / ~5s tick / exit (incl. hide-to-tray and tray Quit);
  restores the queue PAUSED at launch. Position resume on first play threads
  the player's existing start_position_secs (no protected-audio change beyond
  passing that param). Gated on the persist_session / resume_playback_position
  playback prefs; opened per-user on login + boot-restore + offline entry.

Known issue: the seek bar/timer do not visibly show the resume position until
play is pressed (the audio resume itself works); marked in code for follow-up.

cc
This commit is contained in:
vicrodh committed 2026-06-23 12:09:34 -06:00
1 parent 181b85c359
commit dd32f573b4
12 files changed
+672 -14

No files matched your search

+18 -5
View File
@@ -3433,11 +3433,13 @@ impl Player {
client: &QobuzClient,
track_id: u64,
quality: Quality,
start_position_secs: u64,
) -> Result<(), String> {
log::info!(
"Player: Starting playback for track {} with quality {:?}",
"Player: Starting playback for track {} with quality {:?} (start {}s)",
track_id,
quality
quality,
start_position_secs
);
// Cache hit: replay instantly from L1/L2 unless the cached copy is
@@ -3455,7 +3457,14 @@ impl Player {
track_id,
cached.size_bytes
);
return self.play_data(cached.data, track_id);
let r = self.play_data(cached.data, track_id);
// Cached tracks play from in-memory data (no streaming resume
// offset); honor a session-resume position with a best-effort
// seek once playback has been handed to the audio thread.
if r.is_ok() && start_position_secs > 0 {
let _ = self.seek(start_position_secs);
}
return r;
}
}
@@ -3527,7 +3536,7 @@ impl Player {
total_flac_size,
speed_mbps,
duration_secs,
0, // no resume offset
start_position_secs, // session-resume offset (0 = from start)
)?;
// Spawn the background task that fetches + decrypts + pushes
@@ -3604,7 +3613,11 @@ impl Player {
}
// Send to audio thread
self.play_data(audio_data, track_id)
let r = self.play_data(audio_data, track_id);
if r.is_ok() && start_position_secs > 0 {
let _ = self.seek(start_position_secs);
}
r
}
/// Download a track fully into the L1/L2 cache **without** starting