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

+56 -14
View File
@@ -18,6 +18,7 @@ import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { TrackPlayCell } from "../primitives/TrackPlayCell.slint";
import { TrackContextMenu } from "../primitives/TrackContextMenu.slint";
import { AlbumContextMenu } from "../primitives/AlbumContextMenu.slint";
import { DiscHeaderMenu } from "../primitives/DiscHeaderMenu.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { CircleAction } from "../primitives/CircleAction.slint";
@@ -721,20 +722,61 @@ export component AlbumPageView inherits Rectangle {
Rectangle { width: 32px; }
}
for track[index] in AlbumState.tracks: TrackRow {
track: track;
index: index;
// Number cell (no cover). Qobuz albums carry the
// favorite heart (matching the column header) + the
// offline-cache button; local albums show the source
// indicator instead.
show-artwork: false;
show-favorite: !AlbumState.is-local;
show-download: !AlbumState.is-local;
show-source: AlbumState.is-local;
multi-select-mode: AlbumState.multi-select;
media-action(kind, id, action) => {
root.media-action(kind, id, action);
// Each iteration is a thin column wrapper so a "Disc N"
// divider can precede the row when the model marks it as
// the first track of a disc (multi-disc albums only; on a
// single-disc album disc-header-number is always 0, so the
// header `if` never renders and the list stays flat —
// unchanged from before). Mirrors the Tauri
// PurchaseAlbumDetailView groupByDisc + isMultiDisc markup.
for track[index] in AlbumState.tracks: VerticalLayout {
spacing: 0px;
if track.disc-header-number > 0: Rectangle {
height: 40px;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 16px;
Text {
text: @tr("Disc") + " \{track.disc-header-number}";
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
horizontal-alignment: left;
horizontal-stretch: 1;
}
// Per-disc ⋯ menu — actions scoped to this
// disc's tracks only (the column header reserves
// a 32px more-button slot on the right; this
// aligns with it).
VerticalLayout {
alignment: center;
DiscHeaderMenu {
disc: track.disc-header-number;
disc-action(d, a) => {
AlbumActions.disc-action(d, a);
}
}
}
}
}
TrackRow {
track: track;
index: index;
// Number cell (no cover). Qobuz albums carry the
// favorite heart (matching the column header) + the
// offline-cache button; local albums show the source
// indicator instead.
show-artwork: false;
show-favorite: !AlbumState.is-local;
show-download: !AlbumState.is-local;
show-source: AlbumState.is-local;
multi-select-mode: AlbumState.multi-select;
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
+60 -22
View File
@@ -15,6 +15,7 @@ import { TrackRow } from "../primitives/TrackRow.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { DiscHeaderMenu } from "../primitives/DiscHeaderMenu.slint";
import { ListView } from "std-widgets.slint";
// Source glyph for a version: hard-drive (local), Qobuz logo (offline cache),
@@ -475,28 +476,65 @@ export component LocalAlbumView inherits Rectangle {
Rectangle { width: 32px; }
}
for track[index] in LocalAlbumState.tracks: TrackRow {
track: track;
index: index;
show-artwork: false;
show-album: false;
show-favorite: false;
show-download: false;
// Show the per-row source glyph (local / qobuz-offline / Plex).
show-source: true;
// Library surface: local menu even for qobuz_download
// rows (spec §3.4).
force-local-menu: true;
media-action(kind, id, action) => {
// Local-only: ignore album/artist link clicks. "play"
// (row body / play cell) plays; the context-menu
// actions (play-next / queue / add-to-playlist) route
// to their own handler instead of collapsing to play.
if (kind != "album" && kind != "artist") {
if (action == "play") {
LocalAlbumActions.play-track(id);
} else {
LocalAlbumActions.track-menu-action(id, action);
// Disc divider before the first row of each disc on a
// multi-disc local album (disc-header-number is stamped in
// apply_album_version; 0 for single-disc → flat list, as
// before). Same pattern as the Qobuz AlbumPageView.
for track[index] in LocalAlbumState.tracks: VerticalLayout {
spacing: 0px;
if track.disc-header-number > 0: Rectangle {
height: 40px;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 16px;
Text {
text: @tr("Disc") + " \{track.disc-header-number}";
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: 600;
letter-spacing: 0.5px;
vertical-alignment: center;
horizontal-alignment: left;
horizontal-stretch: 1;
}
// Per-disc ⋯ menu — actions scoped to this disc's
// tracks only (aligns with the column header's 32px
// right-edge more-button slot).
VerticalLayout {
alignment: center;
DiscHeaderMenu {
disc: track.disc-header-number;
disc-action(d, a) => {
LocalAlbumActions.disc-action(d, a);
}
}
}
}
}
TrackRow {
track: track;
index: index;
show-artwork: false;
show-album: false;
show-favorite: false;
show-download: false;
// Show the per-row source glyph (local / qobuz-offline / Plex).
show-source: true;
// Library surface: local menu even for qobuz_download
// rows (spec §3.4).
force-local-menu: true;
media-action(kind, id, action) => {
// Local-only: ignore album/artist link clicks. "play"
// (row body / play cell) plays; the context-menu
// actions (play-next / queue / add-to-playlist) route
// to their own handler instead of collapsing to play.
if (kind != "album" && kind != "artist") {
if (action == "play") {
LocalAlbumActions.play-track(id);
} else {
LocalAlbumActions.track-menu-action(id, action);
}
}
}
}
@@ -0,0 +1,59 @@
// Per-disc "more" (⋯) context menu — opened from a "Disc N" separator in the
// album track list (Qobuz AlbumPageView + LocalAlbumView). NEW feature: Tauri
// has no per-disc menu. Each action is scoped to that disc's tracks only; the
// whole-album header buttons keep their own behavior.
//
// Mirrors AlbumContextMenu's structure (a PopupWindow hosting a ContextMenu +
// ContextMenuItem rows) so it reads like every other ⋯ menu. The `disc`
// property identifies which disc the four actions operate on.
//
// Play all -> disc-action(disc, "play")
// Shuffle -> disc-action(disc, "shuffle")
// --
// Add to queue -> disc-action(disc, "queue")
// Play next -> disc-action(disc, "play-next")
import { Theme } from "../foundation/semantic-colors.slint";
import { ContextMenu } from "ContextMenu.slint";
import { ContextMenuItem } from "ContextMenuItem.slint";
export component DiscContextMenu inherits PopupWindow {
in property <int> disc;
callback disc-action(int, string);
width: 200px;
// 4 rows x 33px + 1 separator x 1px + ContextMenu's 5/5 padding.
height: 4 * 33px + 1 * 1px + 10px;
ContextMenu {
ContextMenuItem {
icon: @image-url("../assets/icons/play-fill.svg");
label: @tr("Play all");
clicked => {
root.disc-action(root.disc, "play");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/shuffle.svg");
label: @tr("Shuffle");
clicked => {
root.disc-action(root.disc, "shuffle");
}
}
Rectangle { height: 1px; background: Theme.border-subtle; }
ContextMenuItem {
icon: @image-url("../assets/icons/list-end.svg");
label: @tr("Add to queue");
clicked => {
root.disc-action(root.disc, "queue");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/list-plus.svg");
label: @tr("Play next");
clicked => {
root.disc-action(root.disc, "play-next");
}
}
}
}
@@ -0,0 +1,46 @@
// Per-disc ⋯ trigger + context menu for the album track-list disc headers.
//
// WHY a component: Slint rejects a `PopupWindow` placed DIRECTLY under a
// `for`/`if` ("PopupWindow cannot be directly repeated or conditional" —
// the popup becomes the conditional/repeated root). Wrapping the trigger +
// `DiscContextMenu` here makes the PopupWindow a NON-root child of this
// component's Rectangle root, so mounting `DiscHeaderMenu` inside the disc
// header's `if` is fine (same shape as TrackRow embedding TrackContextMenu).
import { Theme } from "../foundation/semantic-colors.slint";
import { QbzIcon } from "QbzIcon.slint";
import { DiscContextMenu } from "DiscContextMenu.slint";
export component DiscHeaderMenu inherits Rectangle {
in property <int> disc;
// (disc, action) — action: "play" | "shuffle" | "queue" | "play-next".
callback disc-action(int, string);
width: 32px;
height: 32px;
more-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
menu.show();
}
QbzIcon {
source: @image-url("../assets/icons/ellipsis.svg");
width: 16px;
height: 16px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: more-ta.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
// Opens just below the ⋯, right edges aligned (opens leftward).
menu := DiscContextMenu {
x: 32px - self.width;
y: 36px;
disc: root.disc;
disc-action(d, a) => {
root.disc-action(d, a);
}
}
}
+16
View File
@@ -368,6 +368,14 @@ export struct TrackItem {
// True while this track's offline CMAF bundle is being decrypted for
// playback — drives the padlock glyph (swaps the play/equalizer icon).
unlocking: bool,
// Multi-disc grouping: the disc number whose "Disc N" header should be
// rendered ABOVE this row. Set (> 0) only on the first track of each
// disc, and only when the album spans more than one disc; 0 otherwise
// (single-disc albums and every non-leading track render flat, with no
// header). The "Disc" word is translated in the delegate via @tr so it
// flows through the gettext pipeline, matching the Tauri markup
// `{$t('album.disc')} {discNum}` (groupByDisc + isMultiDisc).
disc-header-number: int,
}
// Album detail screen state.
@@ -552,6 +560,10 @@ export global AlbumActions {
// | "queue" | "add-to-playlist" | "add-to-favorites" | "make-offline" |
// "clear").
callback bulk-action(string);
// Per-disc context-menu action on a multi-disc album's "Disc N" header —
// scoped to that disc's tracks only (action = "play" | "shuffle" | "queue"
// | "play-next"). The whole-album header buttons are unaffected.
callback disc-action(int /* disc number */, string /* action */);
}
// Track drag-and-drop onto sidebar playlists (a star QBZ feature).
@@ -942,6 +954,10 @@ export global LocalAlbumActions {
// Client-side track filter (mirrors AlbumActions.search), applied over the
// current version's tracks.
callback search(string /* query */);
// Per-disc context-menu action on a multi-disc local album's "Disc N"
// header — scoped to that disc's tracks only (action = "play" | "shuffle" |
// "queue" | "play-next"). The whole-album header buttons are unaffected.
callback disc-action(int /* disc number */, string /* action */);
}
// ============================ Local Library management ====================