feat(album): multi-disc "Disc N" headers with per-disc context menu

Album and local-album track lists render a "Disc N" header above the
first track of each disc when the album spans more than one disc
(media_number-driven; single-disc albums render flat), matching Tauri.
Each header carries a context menu (new — Tauri has none) with Play all /
Shuffle / Add to queue / Play next scoped to that disc's tracks only; the
whole-album header buttons are unchanged.

The menu lives in a DiscHeaderMenu wrapper because Slint rejects a
PopupWindow placed directly under a for/if delegate — wrapping it makes
the popup a non-root child (same pattern as TrackRow + TrackContextMenu).
Every TrackItem constructor gains disc-header-number: 0; artist
top-tracks (a flat cross-album list) default the disc to 1.

cc
This commit is contained in:
vicrodh committed 2026-06-15 19:19:21 -06:00
1 parent 2e337f6039
commit 30bd959bf7
16 files changed
+506 -40

No files matched your search

+125
View File
@@ -6916,6 +6916,79 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});
}
// Per-disc "Disc N" header ⋯ menu (Qobuz album) — each action is scoped to
// that disc's tracks only, resolved from the album's stashed raw catalog
// tracks. Reuses the SAME queue ops as the album-header buttons (play_tracks
// / play_album_shuffled's xorshift / enqueue_tracks), just over the disc
// subset rather than the whole album.
{
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<AlbumActions>()
.on_disc_action(move |disc, action| {
let mut tracks = album::disc_play_tracks(disc);
if tracks.is_empty() {
return;
}
match action.as_str() {
"play" => {
playback::play_tracks(
runtime.clone(),
weak.clone(),
handle.clone(),
tracks,
0,
);
}
"shuffle" => {
// Same SystemTime-seeded xorshift Fisher-Yates as the
// album-header Shuffle (playback::play_album_shuffled),
// applied to the disc subset before play_tracks.
let mut seed = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|d| d.as_nanos() as u64)
.unwrap_or(1)
| 1;
for i in (1..tracks.len()).rev() {
seed ^= seed << 13;
seed ^= seed >> 7;
seed ^= seed << 17;
let j = (seed % (i as u64 + 1)) as usize;
tracks.swap(i, j);
}
playback::play_tracks(
runtime.clone(),
weak.clone(),
handle.clone(),
tracks,
0,
);
}
"queue" => {
playback::enqueue_tracks(
runtime.clone(),
handle.clone(),
tracks,
false,
);
}
"play-next" => {
playback::enqueue_tracks(
runtime.clone(),
handle.clone(),
tracks,
true,
);
}
other => {
log::warn!("[qbz-slint] album disc-action: unknown action {other}");
}
}
});
}
// Artist in-page search — client-side filter over Popular Tracks
// and every release-section album.
{
@@ -8885,6 +8958,58 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
local_library::search_album(weak.clone(), q.to_string());
});
}
{
// Per-disc "Disc N" header ⋯ menu (local album) — scoped to that disc's
// tracks only, resolved from the open version's track cache. Reuses the
// SAME local queue ops as the header play-all / shuffle buttons
// (play_local_tracks, shuffle flag) and the per-row menu's
// enqueue_local_tracks, just over the disc subset.
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<LocalAlbumActions>()
.on_disc_action(move |disc, action| {
let Some(w) = weak.upgrade() else { return };
let tracks = local_library::current_album_disc_tracks(&w, disc);
if tracks.is_empty() {
return;
}
match action.as_str() {
"play" => playback::play_local_tracks(
runtime.clone(),
weak.clone(),
handle.clone(),
tracks,
0,
false,
),
"shuffle" => playback::play_local_tracks(
runtime.clone(),
weak.clone(),
handle.clone(),
tracks,
0,
true,
),
"queue" => playback::enqueue_local_tracks(
runtime.clone(),
handle.clone(),
tracks,
false,
),
"play-next" => playback::enqueue_local_tracks(
runtime.clone(),
handle.clone(),
tracks,
true,
),
other => {
log::warn!("[qbz-slint] local disc-action: unknown action {other}");
}
}
});
}
// Local Library — Albums tab controls (search / sort re-query page 1;
// load-more pages on scroll; retry) + the shared AlbumCollectionView's