refactor(slint): one shared TrackRow + TrackItem across all surfaces
Collapses the three near-identical track rows (AlbumView's inline
TrackRow, ArtistPage's inline TrackRow with multi-select, and the
shared SearchTrackRow) into a single primitives/TrackRow driven by
flags, backed by one TrackItem (superset). Foundation for the
upcoming playlist module, which renders the artwork variant heavily.
- New primitives/TrackRow.slint with: show-artwork (cover+number vs
number cell), show-album, show-favorite, show-download,
multi-select-mode (selection checkbox). One media-action wires
play / play-next / queue / favorite / download / toggle-select +
the TrackContextMenu.
- TrackItem is the unified model (superset of the old AlbumTrackItem
+ SearchTrackItem: number, album, selected, artwork all present;
unused fields stay empty per surface).
- Migrated AlbumView (show-artwork:false, show-download:true),
ArtistPage Popular (show-artwork:false, multi-select-mode),
Search, Favorites, Mix (show-artwork:true, +album/+favorite).
Deleted SearchTrackRow.slint and both inline TrackRows.
- Rust: AlbumTrackItem + SearchTrackItem -> TrackItem across
album/artist/search/favorites/mix/main; search's internal row
struct renamed TrackRow -> TrackRowData to free the TrackRow name
for the Slint component. 46 tests pass.
cc
This commit is contained in:
14 files changed
+207
-464
No files matched your search
@@ -20,7 +20,7 @@ use qbz_models::Track;
|
||||
use slint::{ComponentHandle, ModelRc, VecModel};
|
||||
|
||||
use crate::artwork::{ArtworkJob, ArtworkTarget};
|
||||
use crate::{AppWindow, MixState, SearchTrackItem};
|
||||
use crate::{AppWindow, MixState, TrackItem};
|
||||
|
||||
/// The currently-loaded mix track list, kept so play-all / per-track
|
||||
/// play can build the queue without re-fetching.
|
||||
@@ -124,13 +124,14 @@ fn mmss(secs: u32) -> String {
|
||||
format!("{}:{:02}", secs / 60, secs % 60)
|
||||
}
|
||||
|
||||
fn to_item(track: &Track) -> SearchTrackItem {
|
||||
fn to_item(track: &Track) -> TrackItem {
|
||||
let mut title = track.title.clone();
|
||||
if let Some(v) = track.version.as_ref().filter(|v| !v.is_empty()) {
|
||||
title = format!("{title} ({v})");
|
||||
}
|
||||
SearchTrackItem {
|
||||
TrackItem {
|
||||
id: track.id.to_string().into(),
|
||||
number: "".into(),
|
||||
title: title.into(),
|
||||
artist: track
|
||||
.performer
|
||||
@@ -152,6 +153,7 @@ fn to_item(track: &Track) -> SearchTrackItem {
|
||||
}
|
||||
.into(),
|
||||
explicit: track.parental_warning,
|
||||
selected: false,
|
||||
artwork_url: track
|
||||
.album
|
||||
.as_ref()
|
||||
@@ -175,7 +177,7 @@ fn total_duration(tracks: &[Track]) -> String {
|
||||
|
||||
pub fn apply_mix(window: &AppWindow, kind: &str, tracks: Vec<Track>) {
|
||||
let (title, subtitle) = mix_meta(kind);
|
||||
let items: Vec<SearchTrackItem> = tracks.iter().map(to_item).collect();
|
||||
let items: Vec<TrackItem> = tracks.iter().map(to_item).collect();
|
||||
let count = tracks.len() as i32;
|
||||
let duration = total_duration(&tracks);
|
||||
if let Ok(mut cur) = CURRENT_MIX.lock() {
|
||||
@@ -197,7 +199,7 @@ pub fn reset_mix(window: &AppWindow, kind: &str) {
|
||||
state.set_kind(kind.into());
|
||||
state.set_title(title.into());
|
||||
state.set_subtitle(subtitle.into());
|
||||
state.set_tracks(ModelRc::new(VecModel::from(Vec::<SearchTrackItem>::new())));
|
||||
state.set_tracks(ModelRc::new(VecModel::from(Vec::<TrackItem>::new())));
|
||||
state.set_track_count(0);
|
||||
state.set_total_duration("".into());
|
||||
state.set_loading(true);
|
||||
|
||||
Reference in new issue
Block a user