feat(slint): keyboard multi-select on the built-out surfaces (Mix, Label, LocalLibrary Albums)

Extend the keyboard multi-select feature to the surfaces that had no
working selection in the Slint port.

- Mix (DailyQ/WeeklyQ/FavQ/TopQ all render through one MixView): mode
  toggle + MultiSelectBar, per-row checkbox via the central toggle arm + a
  ContentView::Mix branch (model + recount), bulk play-next/queue/
  add-to-playlist. Shift-range, Ctrl+A and Escape inherited automatically.
- Label Popular Tracks: was a dead stub (checkboxes with no bar/recount/
  router arms). Converted the local mode flag to LabelState.multi-select,
  added a real MultiSelectBar + label.rs recount/select_all/clear/selected,
  and the missing select-toggle/bulk router arms.
- LocalLibrary Albums grid (a previously-missing surface): AlbumCardItem
  gains a `selected` field; a `select-mode` prop is threaded through the
  shared AlbumCard / AlbumListRow / AlbumGrid / AlbumCollectionView (default
  false, so Discover/Label/Favorites are untouched). Albums toolbar toggle
  + MultiSelectBar; local_library.rs album select fns (flat + grouped,
  id-resilient Shift-range over AlbumCardItem); album->tracks bulk resolve
  via fetch_album_tracks_blocking on spawn_blocking for queue/play-next/
  add-to-playlist/add-to-mixtape; Ctrl+A and Escape routed by active-tab.

cargo check -p qbz green (qbz_ui compiles clean).

cc
This commit is contained in:
vicrodh committed 2026-06-29 14:53:31 -06:00
1 parent 53e1e8cd1c
commit acfd3d928d
13 files changed
+783 -58

No files matched your search

+35 -2
View File
@@ -77,6 +77,10 @@ export component AlbumCard inherits Rectangle {
// Always-visible source badge on the artwork (Local Library: local |
// qobuz-offline | plex). Off elsewhere (single-source catalogs).
in property <bool> show-source-badge: false;
// Multi-select mode (Local Library albums): a checkbox overlay replaces the
// hover action buttons, and the card click toggles selection instead of
// opening. Default false → every other AlbumCard consumer is untouched.
in property <bool> select-mode: false;
// Fade out when the card is being removed (favorites un-favorite).
opacity: root.album.removing ? 0.0 : 1.0;
animate opacity { duration: 250ms; }
@@ -161,12 +165,41 @@ export component AlbumCard inherits Rectangle {
height: 100%;
mouse-cursor: pointer;
clicked => {
root.clicked(root.album.id);
if (root.select-mode) {
root.media-action("album", root.album.id, "toggle-select");
} else {
root.clicked(root.album.id);
}
}
}
// Hover action buttons — favorite / play / more.
// Multi-select checkbox — top-right of the art, shown only in
// select-mode (the card click toggles; this is the indicator).
if root.select-mode: Rectangle {
x: parent.width - self.width - 8px;
y: 8px;
width: 24px;
height: 24px;
border-radius: 12px;
background: root.album.selected ? Theme.accent : #00000099;
border-width: 1.5px;
border-color: root.album.selected ? Theme.accent : #ffffffcc;
animate background { duration: 120ms; }
QbzIcon {
source: @image-url("../assets/icons/check.svg");
visible: root.album.selected;
width: 14px;
height: 14px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #ffffff;
}
}
// Hover action buttons — favorite / play / more. Hidden in
// select-mode (the click toggles selection instead).
HorizontalLayout {
visible: !root.select-mode;
x: 0px;
y: 120px;
width: 200px;
@@ -20,6 +20,7 @@ component AlbumGrid inherits Rectangle {
in property <length> card-gap: 24px;
in property <bool> show-favorite: true;
in property <bool> show-source-badge: false;
in property <bool> select-mode: false;
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
@@ -40,6 +41,7 @@ component AlbumGrid inherits Rectangle {
album: album;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
select-mode: root.select-mode;
clicked(id) => {
root.open-album(id);
}
@@ -65,6 +67,9 @@ export component AlbumCollectionView inherits VerticalLayout {
// Forwarded to AlbumCard — show the always-visible source badge on the
// grid card art (Local Library: local | qobuz-offline | plex).
in property <bool> show-source-badge: false;
// Forwarded to AlbumCard / AlbumListRow — checkbox + toggle-on-click
// (Local Library albums multi-select). Default false everywhere else.
in property <bool> select-mode: false;
in property <length> card-width: 200px;
in property <length> card-height: 246px;
in property <length> card-gap: 24px;
@@ -98,6 +103,7 @@ export component AlbumCollectionView inherits VerticalLayout {
album: album;
index: i;
show-source: root.show-source;
select-mode: root.select-mode;
clicked(id) => {
root.open-album(id);
}
@@ -115,6 +121,7 @@ export component AlbumCollectionView inherits VerticalLayout {
albums: section.albums;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
select-mode: root.select-mode;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;
@@ -136,6 +143,7 @@ export component AlbumCollectionView inherits VerticalLayout {
albums: root.albums;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
select-mode: root.select-mode;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;
@@ -160,6 +168,7 @@ export component AlbumCollectionView inherits VerticalLayout {
album: album;
index: i;
show-source: root.show-source;
select-mode: root.select-mode;
clicked(id) => {
root.open-album(id);
}
+20 -45
View File
@@ -12,12 +12,13 @@
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { LabelState, LabelActions, TrackItem, DragState, NavState } from "../state.slint";
import { LabelState, LabelActions, TrackItem, DragState, NavState, BulkAction } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { TrackRow } from "../primitives/TrackRow.slint";
import { CircleAction } from "../primitives/CircleAction.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { MultiSelectBar } from "../primitives/MultiSelectBar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
import { JumpNavBar } from "../primitives/JumpNavBar.slint";
import { Carousel } from "../discover/Carousel.slint";
@@ -42,7 +43,6 @@ export component LabelPageView inherits Rectangle {
property <string> active-jump-tab: "about";
// Popular Tracks progressive reveal: 5 -> 20 -> 50 (Tauri's steps).
property <int> preview-count: 5;
property <bool> multi-select-mode: false;
background: Theme.surface-main;
@@ -227,9 +227,9 @@ export component LabelPageView inherits Rectangle {
}
CircleAction {
icon: @image-url("../assets/icons/square-check-big.svg");
active: root.multi-select-mode;
active: LabelState.multi-select;
clicked => {
root.multi-select-mode = !root.multi-select-mode;
root.media-action("label", "", "select-toggle");
}
}
CircleAction {
@@ -242,48 +242,23 @@ export component LabelPageView inherits Rectangle {
}
if LabelState.top-tracks.length > 0: Rectangle { height: 10px; }
// Select-all row (multi-select mode).
if root.multi-select-mode && LabelState.top-tracks.length > 0: HorizontalLayout {
height: 36px;
padding-left: 12px;
padding-right: 12px;
spacing: 16px;
VerticalLayout {
alignment: center;
Rectangle {
width: 28px;
height: 28px;
Rectangle {
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
width: 22px;
height: 22px;
border-radius: 11px;
background: transparent;
border-width: 1.5px;
border-color: check-all-ta.has-hover
? Theme.text-primary
: Theme.text-muted;
check-all-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.media-action("label", "", "select-all-top-tracks");
}
}
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: @tr("Select all");
color: Theme.text-secondary;
font-size: Typography.body;
font-weight: Typography.medium;
}
// Bulk action bar — visible in multi-select mode. Actions bubble
// via media-action("label",...). Replaces the old dead Select-all
// row (the checkbox now lives on each TrackRow + this bar).
if LabelState.multi-select && LabelState.top-tracks.length > 0: MultiSelectBar {
selected-count: LabelState.selected-count;
actions: [
{ id: "select-all", label: @tr("Select all"), icon: @image-url("../assets/icons/square-check-big.svg"), danger: false, needs-selection: false },
{ id: "play-next", label: @tr("Play next"), icon: @image-url("../assets/icons/list-plus.svg"), danger: false, needs-selection: true },
{ id: "queue", label: @tr("Add to queue"), icon: @image-url("../assets/icons/list-end.svg"), danger: false, needs-selection: true },
{ id: "add-to-playlist", label: @tr("Add to playlist"), icon: @image-url("../assets/icons/list-music.svg"), danger: false, needs-selection: true },
{ id: "clear", label: @tr("Clear"), icon: @image-url("../assets/icons/x.svg"), danger: false, needs-selection: true },
];
action(id) => {
root.media-action("label", "", id);
}
}
if LabelState.multi-select && LabelState.top-tracks.length > 0: Rectangle { height: 8px; }
for track[index] in LabelState.top-tracks: TrackRow {
visible: index < root.preview-count;
@@ -292,7 +267,7 @@ export component LabelPageView inherits Rectangle {
index: index;
// Label tracks carry the album thumbnail (Tauri shows it).
show-artwork: true;
multi-select-mode: root.multi-select-mode;
multi-select-mode: LabelState.multi-select;
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
@@ -852,6 +852,16 @@ export component LocalLibraryView inherits Rectangle {
}
}
}
// Multi-select toggle.
VerticalLayout {
alignment: center;
CircleIconBtn {
icon: @image-url("../assets/icons/square-check-big.svg");
clicked => {
LocalLibraryActions.albums-toggle-multi-select();
}
}
}
}
// Tracks toolbar — multi-select toggle + search + group-by.
@@ -1131,11 +1141,28 @@ export component LocalLibraryView inherits Rectangle {
padding-bottom: 100px;
spacing: 0px;
alignment: start;
// Bulk action bar — visible in albums multi-select.
if LocalLibraryState.albums-multi-select: MultiSelectBar {
selected-count: LocalLibraryState.albums-selected-count;
actions: [
{ id: "select-all", label: @tr("Select all"), icon: @image-url("../assets/icons/square-check-big.svg"), danger: false, needs-selection: false },
{ id: "queue", label: @tr("Add to queue"), icon: @image-url("../assets/icons/list-end.svg"), danger: false, needs-selection: true },
{ id: "play-next", label: @tr("Play next"), icon: @image-url("../assets/icons/list-plus.svg"), danger: false, needs-selection: true },
{ id: "add-to-playlist", label: @tr("Add to playlist"), icon: @image-url("../assets/icons/list-music.svg"), danger: false, needs-selection: true },
{ id: "add-to-mixtape", label: @tr("Add to Mixtape/Collection"), icon: @image-url("../assets/icons/cassette-tape.svg"), danger: false, needs-selection: true },
{ id: "clear", label: @tr("Clear"), icon: @image-url("../assets/icons/x.svg"), danger: false, needs-selection: true },
];
action(id) => {
LocalLibraryActions.albums-bulk-action(id);
}
}
if LocalLibraryState.albums-multi-select: Rectangle { height: 8px; }
AlbumCollectionView {
albums: LocalLibraryState.albums-visible;
grouped: LocalLibraryState.albums-grouped;
is-grouped: LocalLibraryState.albums-group != "off";
view-mode: LocalLibraryState.albums-view-mode;
select-mode: LocalLibraryState.albums-multi-select;
// List view shows the SOURCE column (local/offline/plex).
show-source: true;
// Local albums aren't Qobuz-favoritable — hide the heart.
+36 -2
View File
@@ -8,17 +8,19 @@
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { MixState, DragState, NavState } from "../state.slint";
import { MixState, DragState, NavState, BulkAction } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { TrackRow } from "../primitives/TrackRow.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { MultiSelectBar } from "../primitives/MultiSelectBar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
// Circular header action button (Play / Shuffle / Save / Refresh).
component CircleAction inherits Rectangle {
in property <image> icon;
in property <bool> primary: false;
in property <bool> active: false;
in property <length> diameter: 38px;
in property <bool> enabled: true;
callback clicked();
@@ -36,7 +38,9 @@ component CircleAction inherits Rectangle {
height: root.primary ? 18px : 16px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.primary ? #ffffff : Theme.text-secondary;
tint: root.primary
? #ffffff
: (root.active ? Theme.accent : Theme.text-secondary);
}
ta := TouchArea {
mouse-cursor: root.enabled ? pointer : default;
@@ -182,6 +186,18 @@ export component MixView inherits Rectangle {
enabled: MixState.tracks.length > 0;
}
}
// Multi-select toggle (accent-tinted when active).
VerticalLayout {
alignment: center;
CircleAction {
icon: @image-url("../assets/icons/square-check-big.svg");
active: MixState.multi-select;
enabled: MixState.tracks.length > 0;
clicked => {
root.media-action("mix", "", "select-toggle");
}
}
}
VerticalLayout {
alignment: center;
CircleAction {
@@ -197,6 +213,23 @@ export component MixView inherits Rectangle {
Rectangle { height: 28px; }
// Bulk action bar — visible in multi-select mode. Scrolls with the
// page (same as AlbumView). Actions bubble via media-action("mix").
if MixState.multi-select: MultiSelectBar {
selected-count: MixState.selected-count;
actions: [
{ id: "select-all", label: @tr("Select all"), icon: @image-url("../assets/icons/square-check-big.svg"), danger: false, needs-selection: false },
{ id: "play-next", label: @tr("Play next"), icon: @image-url("../assets/icons/list-plus.svg"), danger: false, needs-selection: true },
{ id: "queue", label: @tr("Add to queue"), icon: @image-url("../assets/icons/list-end.svg"), danger: false, needs-selection: true },
{ id: "add-to-playlist", label: @tr("Add to playlist"), icon: @image-url("../assets/icons/list-music.svg"), danger: false, needs-selection: true },
{ id: "clear", label: @tr("Clear"), icon: @image-url("../assets/icons/x.svg"), danger: false, needs-selection: true },
];
action(id) => {
root.media-action("mix", "", id);
}
}
if MixState.multi-select: Rectangle { height: 8px; }
if MixState.loading: HorizontalLayout {
alignment: center;
LoadingSpinner { size: 36px; }
@@ -261,6 +294,7 @@ export component MixView inherits Rectangle {
for track[i] in MixState.tracks: TrackRow {
track: track;
index: i;
multi-select-mode: MixState.multi-select;
show-artwork: true;
show-album: true;
show-favorite: true;
+37 -2
View File
@@ -143,6 +143,10 @@ export component AlbumListRow inherits Rectangle {
in property <string> rank;
// The SOURCE column is hidden in single-source contexts (Discover).
in property <bool> show-source: true;
// Multi-select mode (Local Library albums): a leading checkbox + row click
// toggles selection instead of opening. Default false → other consumers
// (Discover/Label/Favorites lists) are untouched.
in property <bool> select-mode: false;
callback clicked(string);
// kind ("album" | "artist"), id, action ("play" | "queue" |
@@ -164,7 +168,11 @@ export component AlbumListRow inherits Rectangle {
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked(root.album.id);
if (root.select-mode) {
root.media-action("album", root.album.id, "toggle-select");
} else {
root.clicked(root.album.id);
}
}
}
@@ -173,6 +181,29 @@ export component AlbumListRow inherits Rectangle {
padding-right: 12px;
spacing: AlbumListCols.gap;
// --- Multi-select checkbox (leading) --------------------------
if root.select-mode: VerticalLayout {
alignment: center;
Rectangle {
width: 18px;
height: 18px;
border-radius: 9px;
background: root.album.selected ? Theme.accent : transparent;
border-width: root.album.selected ? 0px : 1.5px;
border-color: Theme.text-muted;
animate background { duration: 120ms; }
QbzIcon {
source: @image-url("../assets/icons/check.svg");
visible: root.album.selected;
width: 11px;
height: 11px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #ffffff;
}
}
}
// --- # ---------------------------------------------------------
if root.show-rank: Text {
width: AlbumListCols.rank;
@@ -216,7 +247,11 @@ export component AlbumListRow inherits Rectangle {
art-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.media-action("album", root.album.id, "play");
if (root.select-mode) {
root.media-action("album", root.album.id, "toggle-select");
} else {
root.media-action("album", root.album.id, "play");
}
}
}
}
+18 -2
View File
@@ -27,6 +27,7 @@ export struct AlbumCardItem {
artwork: image, // empty until the artwork pipeline resolves it
is-favorite: bool, // filled accent heart on the card when favorited
removing: bool, // fading out (un-favorited in the favorites view)
selected: bool, // checkbox state in a multi-select grid (LocalLibrary)
// --- List-row extras (AlbumListRow; ignored by the grid AlbumCard) ----
release-type: string, // "Album" | "EP" | "Single" | "Live" | "Compilation"
source: string, // "qobuz" | "local" | "plex" | "" — hideable column
@@ -1026,6 +1027,8 @@ export global LocalLibraryState {
in-out property <string> albums-group: "off"; // off | alpha | artist
in property <[AlphaJump]> albums-alpha: []; // A-Z jumps (alpha group)
in property <int> albums-shown: 0; // count after filter
in-out property <bool> albums-multi-select: false; // album checkboxes on
in property <int> albums-selected-count: 0; // bar count + select-all
// --- Tracks tab (server-paginated flat list — the 16K-freeze fix) ---
// Group-by / multi-select / per-row play land with the playback slice.
@@ -1150,9 +1153,14 @@ export global LocalLibraryActions {
callback open-album(string /* album id */);
// Open an artist (lands with the Artists slice).
callback open-artist(string /* artist id */);
// Per-card action (play / queue / play-next) — lands with the playback
// slice. Wired now so the shared AlbumCollectionView contract is honored.
// Per-card action (play / queue / play-next / toggle-select). The Albums
// grid honors the shared AlbumCollectionView contract.
callback album-action(string /* album id */, string /* action */);
// Toggle the Albums-grid multi-select mode.
callback albums-toggle-multi-select();
// Albums bulk bar action: select-all | clear | queue | play-next |
// add-to-playlist | add-to-mixtape.
callback albums-bulk-action(string /* action */);
// --- Tracks tab ---
callback tracks-search(string /* query */);
@@ -3370,6 +3378,10 @@ export global LabelState {
in property <bool> is-following: false;
// Popular tracks (album-thumbnail rows, multi-select capable).
in property <[TrackItem]> top-tracks: [];
// Multi-select (mirrors AlbumState): mode flag + count. Per-row toggle
// routes through the shared media-action("track",...) arm.
in-out property <bool> multi-select: false;
in property <int> selected-count: 0;
// Releases + Critics' Picks carousels (reuse Carousel).
in property <DiscoverSection> releases-section;
in property <DiscoverSection> critics-section;
@@ -4798,6 +4810,10 @@ export global MixState {
in property <int> track-count: 0;
in property <string> total-duration;
in property <bool> loading: false;
// Keyboard/checkbox multi-select (mirrors AlbumState): mode flag + count.
// Per-row toggle routes through the shared media-action("track",...) arm.
in-out property <bool> multi-select: false;
in property <int> selected-count: 0;
}
// Search results screen state. The Rust search controller populates the