feat(slint): NowPlayingBar Mode C "Small" + mode shell + floating album-art preview

- New mode shell ui/shell/NowPlayingBar.slint switches on ShellState.npb-mode
  (0/1 -> existing PlayerBar untouched except a mode-aware height, 2 -> new
  PlayerBarSmall). AppShell mounts it; npb_mode "small" persists in ui_prefs.
- PlayerBarSmall: one 42px row (the album art defines the height, no bump) — a
  3px full-width top seekbar (SeekBar gains a show-times prop) + a symmetric
  3-column controls row that mirrors PlayerBar's responsive side-frac so the
  transport is window-centred. Compact SongCard (art border + flush-left +
  text-center + smaller fonts), a tabular 2-row time column (monospace), an
  inline 2-row AudioStamp (no format icon), and the right cluster
  (ViewMode/Connect/Cast/Lyrics/Settings-flyout/Volume/Queue). Responsive
  volume: inline QbzSlider when wide, an upward QbzVerticalSlider flyout when
  narrow.
- New ui/primitives/QbzVerticalSlider.slint.
- Floating album-art hover preview (1:1 Tauri): NowPlayingState.artwork-large
  (300px, loaded via the same source-aware artwork funnel) + a global
  ArtPreviewState rendered by the new ArtPreviewOverlay (an overlay, NOT a
  PopupWindow, so it never steals hover -> no flicker). New/Classic/Small.
- Fix: settings.rs handle_bool now refreshes SettingsState on the non-cascade
  path so the bar's Normalization/Gapless toggles reflect their real state
  (shared path, also helps New/Classic). Protected audio backend untouched.
- Context icon turntable -> layers (Tauri parity, all now-playing modes).

cc
This commit is contained in:
vicrodh committed 2026-06-12 13:18:54 -06:00
1 parent 3689a5fda8
commit 8fa03a8c03
13 files changed
+1606 -30

No files matched your search

+5 -4
View File
@@ -4916,10 +4916,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
match (kind.as_str(), action.as_str()) {
// Now-playing bar layout switch (New / Classic). Persisted to
// ui_prefs so the choice survives restarts. Small/Large/window
// modes are disabled in the menu until those layouts land.
("npb-view", mode @ ("new" | "classic")) => {
// Now-playing bar layout switch (New / Classic / Small).
// Persisted to ui_prefs so the choice survives restarts.
// Large/window modes are disabled in the menu until those
// layouts land.
("npb-view", mode @ ("new" | "classic" | "small")) => {
if let Some(w) = weak.upgrade() {
w.global::<ShellState>()
.set_npb_mode(crate::ui_prefs::npb_mode_index(mode));
+35
View File
@@ -1171,6 +1171,32 @@ fn load_now_playing_artwork(weak: slint::Weak<AppWindow>, art: qbz_models::Artwo
});
}
/// Resolve a HIGHER-res now-playing cover (~300px) and apply it to
/// `NowPlayingState.artwork-large`. Feeds the hover preview that floats above
/// the bar's small art, so the ~220px popup is crisp instead of an upscale of
/// the 160px bar art. Mirrors [`load_now_playing_artwork`] but decodes larger
/// and writes the separate `artwork-large` slot. Source-aware via the SAME
/// `ArtworkRef` funnel (the caller passes a `Some(300)` ref).
fn load_now_playing_artwork_large(weak: slint::Weak<AppWindow>, art: qbz_models::ArtworkRef) {
if art.is_empty() {
return;
}
let Some(cache) = crate::artwork::shared_cache() else {
return;
};
tokio::spawn(async move {
let Some((pixels, w, h)) =
crate::artwork::fetch_and_decode_ref(&art, &cache, 300).await
else {
return;
};
let _ = weak.upgrade_in_event_loop(move |win| {
let img = crate::artwork::pixels_to_image(&pixels, w, h);
win.global::<NowPlayingState>().set_artwork_large(img);
});
});
}
/// Wall-clock now in milliseconds. Used by the poll loop to extrapolate the
/// peer renderer's position (`position_ms + (now - updated_at_ms)`) while
/// QBZ is CONTROLLING a peer (the local player is stopped, so the seek bar
@@ -1280,6 +1306,10 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We
// For non-Plex tracks both collapse to the same `artwork_ref()`.
let artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, None);
let bar_artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, Some(160));
// Higher-res cover for the hover preview that floats above the bar art. Same
// source-aware funnel; a ~300px server-side transcode so the ~220px popup is
// crisp without paying for the full original. One extra fetch per track.
let preview_artwork = track.artwork_ref_with_plex(&plex.base_url, &plex.token, Some(300));
// Quality badge: tier from bit depth (24-bit+ = Hi-Res), exact detail line
// reused from the shared formatter so it matches the track-row badges.
let quality_tier = match track.bit_depth {
@@ -1430,9 +1460,14 @@ pub(crate) async fn refresh_now_playing_meta(runtime: &Runtime, weak: &slint::We
// Clear the previous cover so it does not linger while the new
// one resolves.
np.set_artwork(slint::Image::default());
// Clear the hover-preview cover too, exactly like the bar art, so the
// floating preview never shows the previous track while the new high-res
// cover resolves.
np.set_artwork_large(slint::Image::default());
});
load_now_playing_artwork(weak.clone(), bar_artwork);
load_now_playing_artwork_large(weak.clone(), preview_artwork);
}
/// Record the playback CONTEXT — the source the queue was launched from — on
+27
View File
@@ -599,6 +599,15 @@ pub fn apply_snapshot(window: &AppWindow, snap: SettingsSnapshot) {
st.set_stream_uncached(snap.stream_uncached);
st.set_streaming_only(snap.streaming_only);
st.set_normalization(snap.normalization);
// Mirror the four output LEDs onto NowPlayingState too, so the Mode C
// "Small" now-playing bar has a single source for the song card + the
// DAC/EXC cluster. Cloned because the SettingsState setters below consume
// the snapshot's String fields via `.into()`.
let np = window.global::<NowPlayingState>();
np.set_output_backend_label(snap.output_backend_label.clone().into());
np.set_output_mode_label(snap.output_mode_label.clone().into());
np.set_output_backend_active(snap.output_backend_active);
np.set_output_mode_active(snap.output_mode_active);
st.set_output_backend_label(snap.output_backend_label.into());
st.set_output_mode_label(snap.output_mode_label.into());
st.set_output_backend_active(snap.output_backend_active);
@@ -870,6 +879,24 @@ pub async fn handle_bool(
// triggering toggle alone required.
let apply = if cascaded { Apply::Reinit } else { apply };
apply_audio(&ctx, &runtime, apply);
// Reflect the persisted value back onto SettingsState so toggles
// that are purely driven by `checked: SettingsState.x` (e.g. the
// now-playing bar audio-menu QbzToggles for Normalization/Gapless)
// actually flip. The Settings panel's own toggles already reflect
// their click optimistically, but the bar flyout's do NOT self-flip
// — they need this push. Skipped when cascaded, since the full
// snapshot re-push below already carries the new value.
if !cascaded {
let key = key.to_string();
let _ = weak.upgrade_in_event_loop(move |w| {
let st = w.global::<SettingsState>();
match key.as_str() {
"normalization" => st.set_normalization(value),
"gapless" => st.set_gapless(value),
_ => {}
}
});
}
}
Err(e) => log::error!("[qbz-slint] failed to persist '{key}': {e}"),
}
+4 -3
View File
@@ -44,8 +44,8 @@ pub struct UiPrefs {
/// Streaming-quality key — one of `STREAMING_QUALITIES[*].key`.
#[serde(default = "default_streaming_quality")]
pub streaming_quality: String,
/// Now-playing bar layout: `"new"` | `"classic"`. Maps to
/// `ShellState.npb-mode` (0 / 1).
/// Now-playing bar layout: `"new"` | `"classic"` | `"small"`. Maps to
/// `ShellState.npb-mode` (0 / 1 / 2).
#[serde(default = "default_npb_mode")]
pub npb_mode: String,
}
@@ -68,10 +68,11 @@ impl Default for UiPrefs {
}
/// Map a persisted npb-mode key to the `ShellState.npb-mode` int
/// (New = 0, Classic = 1). Unknown keys fall back to New.
/// (New = 0, Classic = 1, Small = 2). Unknown keys fall back to New.
pub fn npb_mode_index(key: &str) -> i32 {
match key {
"classic" => 1,
"small" => 2,
_ => 0,
}
}