feat(slint): play-from-clicked-track, track-row quality badge, album link, playlist layout
Committed together because these changes share main.rs, playlist.rs and
PlaylistView.slint, and the new quality field is atomic across every
TrackItem builder, so they cannot compile as separate whole-file commits.
- Universal play-from-here: a single play_track_in_context dispatcher builds
the queue from the current view's VISIBLE list and starts at the clicked
track (playlist, album, artist, favorites, label, mix, search). Cached
views order by the visible model; re-fetch views (album / artist top
tracks) reorder to the in-page filter; the search "most popular" hero
prepends to the results queue. Drops the playlist-track / mix-track arms
that always started at track 1 (the clicked id was read from the wrong
media-action slot).
- Album-name links in track rows open the album page (the ("album","open")
media-action arm was missing and fell through to a no-op).
- Unified track-row quality badge: a new quality-detail field on TrackItem,
populated from bit-depth / sample-rate in every builder through a shared
crate::quality::detail, rendered with a bare (no chip background/border,
centered text) QualityBadgeFull. Restores the exact bit-depth / sample-rate
line that had regressed to a plain CD / Hi-Res tier.
- Playlist track list: reserve the favorite / download / context-menu columns
in the column header, match the row's 36px cover cell, and anchor the
scrollbar to the view edge (matches Local Library > Tracks).
cc
This commit is contained in:
17 files changed
+603
-187
No files matched your search
@@ -61,6 +61,7 @@ pub struct TrackData {
|
||||
pub album_id: String,
|
||||
pub duration: String,
|
||||
pub quality_tier: String,
|
||||
pub quality_detail: String,
|
||||
pub explicit: bool,
|
||||
}
|
||||
|
||||
@@ -107,7 +108,7 @@ fn map_album(album: Album) -> AlbumData {
|
||||
let info_line = parts.join(" • ");
|
||||
|
||||
let quality_tier = tier(album.maximum_bit_depth).to_string();
|
||||
let quality_detail = quality_detail(album.maximum_bit_depth, album.maximum_sampling_rate);
|
||||
let quality_detail = crate::quality::detail(album.maximum_bit_depth, album.maximum_sampling_rate);
|
||||
let description = album
|
||||
.description
|
||||
.as_deref()
|
||||
@@ -175,18 +176,6 @@ fn truncate_words(text: &str, max: usize) -> String {
|
||||
}
|
||||
|
||||
/// "24-bit / 96 kHz" — the quality-badge detail string.
|
||||
fn quality_detail(bit_depth: Option<u32>, sample_rate: Option<f64>) -> String {
|
||||
let hi_res = matches!(bit_depth, Some(depth) if depth >= 24);
|
||||
let depth = bit_depth.unwrap_or(if hi_res { 24 } else { 16 });
|
||||
let rate = sample_rate.unwrap_or(if hi_res { 96.0 } else { 44.1 });
|
||||
let rate = if rate.fract().abs() < f64::EPSILON {
|
||||
format!("{}", rate as i64)
|
||||
} else {
|
||||
format!("{rate}")
|
||||
};
|
||||
format!("{depth}-bit / {rate} kHz")
|
||||
}
|
||||
|
||||
/// Crude HTML strip for Qobuz album descriptions. Break and paragraph
|
||||
// The previous local strip_html lived here; moved to
|
||||
// `crate::strip_html` so artist and album views share the same
|
||||
@@ -212,6 +201,10 @@ fn map_track(track: Track) -> TrackData {
|
||||
album_id: String::new(),
|
||||
duration: mmss(track.duration),
|
||||
quality_tier: tier(track.maximum_bit_depth).to_string(),
|
||||
quality_detail: crate::quality::detail(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
),
|
||||
explicit: track.parental_warning,
|
||||
}
|
||||
}
|
||||
@@ -258,6 +251,7 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) {
|
||||
album: "".into(),
|
||||
duration: track.duration.into(),
|
||||
quality_tier: track.quality_tier.into(),
|
||||
quality_detail: track.quality_detail.into(),
|
||||
explicit: track.explicit,
|
||||
selected: false,
|
||||
artwork_url: "".into(),
|
||||
|
||||
@@ -363,6 +363,8 @@ fn map_track(index: usize, track: PageArtistTrack) -> TrackData {
|
||||
.map(|a| (a.name.display, a.id.to_string()))
|
||||
.unwrap_or_default();
|
||||
let album_id = track.album.map(|a| a.id).unwrap_or_default();
|
||||
let bit_depth = track.audio_info.as_ref().and_then(|a| a.maximum_bit_depth);
|
||||
let sample_rate = track.audio_info.as_ref().and_then(|a| a.maximum_sampling_rate);
|
||||
TrackData {
|
||||
id: track.id.to_string(),
|
||||
number: (index + 1).to_string(),
|
||||
@@ -371,7 +373,8 @@ fn map_track(index: usize, track: PageArtistTrack) -> TrackData {
|
||||
artist_id,
|
||||
album_id,
|
||||
duration: mmss(track.duration.unwrap_or(0)),
|
||||
quality_tier: tier(track.audio_info.and_then(|a| a.maximum_bit_depth)).to_string(),
|
||||
quality_tier: tier(bit_depth).to_string(),
|
||||
quality_detail: crate::quality::detail(bit_depth, sample_rate),
|
||||
explicit: track.parental_warning.unwrap_or(false),
|
||||
}
|
||||
}
|
||||
@@ -495,6 +498,7 @@ pub fn apply_artist(window: &AppWindow, data: ArtistData) {
|
||||
album: "".into(),
|
||||
duration: track.duration.into(),
|
||||
quality_tier: track.quality_tier.into(),
|
||||
quality_detail: track.quality_detail.into(),
|
||||
explicit: track.explicit,
|
||||
selected: false,
|
||||
artwork_url: "".into(),
|
||||
|
||||
@@ -121,6 +121,7 @@ pub struct TrackCard {
|
||||
pub genre: String,
|
||||
pub duration: String,
|
||||
pub quality_tier: String,
|
||||
pub quality_detail: String,
|
||||
pub explicit: bool,
|
||||
pub artwork_url: String,
|
||||
}
|
||||
@@ -356,6 +357,10 @@ fn map_track(track: Track) -> TrackCard {
|
||||
genre,
|
||||
duration: mmss(track.duration),
|
||||
quality_tier: album_map::tier(track.maximum_bit_depth).to_string(),
|
||||
quality_detail: crate::quality::detail(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
),
|
||||
explicit: track.parental_warning,
|
||||
artwork_url,
|
||||
}
|
||||
@@ -409,6 +414,7 @@ pub fn apply_favorites(window: &AppWindow, data: FavData) {
|
||||
album: t.album.into(),
|
||||
duration: t.duration.into(),
|
||||
quality_tier: t.quality_tier.into(),
|
||||
quality_detail: t.quality_detail.into(),
|
||||
explicit: t.explicit,
|
||||
selected: false,
|
||||
artwork_url: t.artwork_url.into(),
|
||||
|
||||
@@ -322,6 +322,7 @@ pub struct TopTrack {
|
||||
pub artwork_url: String,
|
||||
pub duration: String,
|
||||
pub quality_tier: String,
|
||||
pub quality_detail: String,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -540,6 +541,12 @@ fn parse_top_track(raw: &Value) -> TopTrack {
|
||||
.and_then(|a| a.get("maximum_bit_depth"))
|
||||
.and_then(|v| v.as_u64())
|
||||
.or_else(|| raw.get("maximum_bit_depth").and_then(|v| v.as_u64()));
|
||||
let sample_rate = raw
|
||||
.get("audio_info")
|
||||
.and_then(|a| a.get("maximum_sampling_rate"))
|
||||
.and_then(|v| v.as_f64())
|
||||
.or_else(|| raw.get("maximum_sampling_rate").and_then(|v| v.as_f64()));
|
||||
let bit_depth = bit_depth.map(|b| b as u32);
|
||||
TopTrack {
|
||||
id,
|
||||
title,
|
||||
@@ -548,7 +555,8 @@ fn parse_top_track(raw: &Value) -> TopTrack {
|
||||
album_id,
|
||||
artwork_url,
|
||||
duration: mmss(duration as u32),
|
||||
quality_tier: tier(bit_depth.map(|b| b as u32)).to_string(),
|
||||
quality_tier: tier(bit_depth).to_string(),
|
||||
quality_detail: crate::quality::detail(bit_depth, sample_rate),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,6 +763,7 @@ fn top_track_to_item(t: &TopTrack) -> TrackItem {
|
||||
album: "".into(),
|
||||
duration: t.duration.clone().into(),
|
||||
quality_tier: t.quality_tier.clone().into(),
|
||||
quality_detail: t.quality_detail.clone().into(),
|
||||
explicit: false,
|
||||
selected: false,
|
||||
artwork_url: t.artwork_url.clone().into(),
|
||||
|
||||
@@ -636,6 +636,12 @@ fn map_local_track(t: qbz_library::LocalTrack) -> TrackItem {
|
||||
album: t.album.into(),
|
||||
duration: fmt_duration(t.duration_secs).into(),
|
||||
quality_tier: tier.into(),
|
||||
quality_detail: if tier == "mp3" {
|
||||
String::new()
|
||||
} else {
|
||||
crate::quality::detail(t.bit_depth, Some(t.sample_rate))
|
||||
}
|
||||
.into(),
|
||||
explicit: false,
|
||||
selected: false,
|
||||
artwork_url: t.artwork_path.unwrap_or_default().into(),
|
||||
|
||||
@@ -53,6 +53,7 @@ mod offline_manager;
|
||||
mod playlist;
|
||||
mod playlist_manager;
|
||||
mod playlist_picker;
|
||||
mod quality;
|
||||
mod recently;
|
||||
mod search;
|
||||
mod settings;
|
||||
@@ -2263,12 +2264,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
0,
|
||||
),
|
||||
("track", "play") => {
|
||||
if let Ok(track_id) = id.parse::<u64>() {
|
||||
playback::play_track_now(
|
||||
// Universal per-row play: queue the current view's VISIBLE
|
||||
// tracklist starting at the clicked track (see
|
||||
// playback::play_track_in_context). Every tracklist surface
|
||||
// routes here — album, playlist, favorites, label, mix,
|
||||
// artist, search.
|
||||
if let Some(w) = weak.upgrade() {
|
||||
playback::play_track_in_context(
|
||||
&w,
|
||||
runtime.clone(),
|
||||
weak.clone(),
|
||||
handle.clone(),
|
||||
track_id,
|
||||
&id,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2483,6 +2490,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
w.invoke_open_artist(id.clone().into());
|
||||
}
|
||||
}
|
||||
// Clickable album name (track rows) -> album page.
|
||||
("album", "open") => {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.invoke_open_album(id.clone().into());
|
||||
}
|
||||
}
|
||||
("artist", "play-top") => playback::play_artist_top_tracks(
|
||||
runtime.clone(),
|
||||
weak.clone(),
|
||||
@@ -2680,16 +2693,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
("mix-track", track_id) => {
|
||||
let idx = mix::index_of(track_id);
|
||||
let runtime = runtime.clone();
|
||||
let weak = weak.clone();
|
||||
let handle = handle.clone();
|
||||
handle.clone().spawn(async move {
|
||||
let tracks = mix::current_tracks();
|
||||
playback::play_tracks(runtime, weak, handle, tracks, idx);
|
||||
});
|
||||
}
|
||||
("playlist", "cache") => {
|
||||
if let Ok(pid) = id.parse::<u64>() {
|
||||
offline_cache::cache_playlist(
|
||||
@@ -2886,20 +2889,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
("playlist-track", track_id) => {
|
||||
// Queue the VISIBLE order starting at the clicked track, so
|
||||
// the tracks that follow it (not track 1) play next.
|
||||
if let Some(w) = weak.upgrade() {
|
||||
let (tracks, idx) = playlist::visible_play_context(&w, track_id);
|
||||
playback::play_tracks(
|
||||
runtime.clone(),
|
||||
weak.clone(),
|
||||
handle.clone(),
|
||||
tracks,
|
||||
idx,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -152,6 +152,11 @@ fn to_item(track: &Track) -> TrackItem {
|
||||
None => "",
|
||||
}
|
||||
.into(),
|
||||
quality_detail: crate::quality::detail(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
)
|
||||
.into(),
|
||||
explicit: track.parental_warning,
|
||||
selected: false,
|
||||
artwork_url: track
|
||||
|
||||
@@ -14,12 +14,15 @@
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use qbz_app::shell::AppRuntime;
|
||||
use qbz_models::{Quality, QueueTrack, RepeatMode};
|
||||
use slint::ComponentHandle;
|
||||
use qbz_models::{Quality, QueueTrack, RepeatMode, Track};
|
||||
use slint::{ComponentHandle, Model, ModelRc};
|
||||
|
||||
use crate::adapter::SlintAdapter;
|
||||
use crate::queue::QueueController;
|
||||
use crate::{AppWindow, NowPlayingState};
|
||||
use crate::{
|
||||
AlbumState, AppWindow, ArtistState, ContentView, FavoritesState, LabelState, NavState,
|
||||
NowPlayingState, PlaylistState, SearchState, TrackItem,
|
||||
};
|
||||
|
||||
/// The Queue sidebar controller, published once the shell is up so the
|
||||
/// playback paths (album/track play, skip, auto-advance) can refresh the
|
||||
@@ -671,6 +674,56 @@ async fn record_recent(runtime: &Runtime) {
|
||||
|
||||
/// Play `album_id` from `start_index`: fetch the album, build the queue,
|
||||
/// hand it to the core, and start audio on the start track.
|
||||
/// Fetch an album and build its play queue (genre/quality meta cached for
|
||||
/// the Recently Played card). Shared by `play_album` (start at a positional
|
||||
/// index) and `play_album_from` (start at a clicked track id). Returns None
|
||||
/// and toasts on failure / an empty album.
|
||||
async fn fetch_album_for_play(
|
||||
runtime: &Runtime,
|
||||
weak: &slint::Weak<AppWindow>,
|
||||
album_id: &str,
|
||||
) -> Option<Vec<QueueTrack>> {
|
||||
let album = match runtime.core().get_album(album_id).await {
|
||||
Ok(album) => album,
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] playback: get_album {album_id} failed: {e}");
|
||||
crate::toast::error_weak(weak, "Couldn't load this album");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let album_title = album.title.clone();
|
||||
let album_artist = album.artist.name.clone();
|
||||
let album_artwork = album.image.best().cloned().unwrap_or_default();
|
||||
// Cache the album's genre / release date / quality so the Recently
|
||||
// Played card the play records carries them (no extra fetch).
|
||||
crate::recently::remember_album_meta(&album.id, album_card_meta(&album));
|
||||
|
||||
let tracks: Vec<QueueTrack> = album
|
||||
.tracks
|
||||
.as_ref()
|
||||
.map(|container| container.items.as_slice())
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|track| {
|
||||
make_queue_track(
|
||||
track,
|
||||
&album.id,
|
||||
&album_title,
|
||||
&album_artist,
|
||||
&album_artwork,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if tracks.is_empty() {
|
||||
log::warn!("[qbz-slint] playback: album {album_id} has no tracks");
|
||||
crate::toast::error_weak(weak, "This album has no playable tracks");
|
||||
return None;
|
||||
}
|
||||
Some(tracks)
|
||||
}
|
||||
|
||||
pub fn play_album(
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
@@ -679,48 +732,39 @@ pub fn play_album(
|
||||
start_index: usize,
|
||||
) {
|
||||
handle.spawn(async move {
|
||||
let album = match runtime.core().get_album(&album_id).await {
|
||||
Ok(album) => album,
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] playback: get_album {album_id} failed: {e}");
|
||||
crate::toast::error_weak(&weak, "Couldn't load this album");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let album_title = album.title.clone();
|
||||
let album_artist = album.artist.name.clone();
|
||||
let album_artwork = album.image.best().cloned().unwrap_or_default();
|
||||
// Cache the album's genre / release date / quality so the Recently
|
||||
// Played card the play records below carries them (no extra fetch).
|
||||
crate::recently::remember_album_meta(&album.id, album_card_meta(&album));
|
||||
|
||||
let tracks: Vec<QueueTrack> = album
|
||||
.tracks
|
||||
.as_ref()
|
||||
.map(|container| container.items.as_slice())
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
.map(|track| {
|
||||
make_queue_track(
|
||||
track,
|
||||
&album.id,
|
||||
&album_title,
|
||||
&album_artist,
|
||||
&album_artwork,
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
if tracks.is_empty() {
|
||||
log::warn!("[qbz-slint] playback: album {album_id} has no tracks");
|
||||
crate::toast::error_weak(&weak, "This album has no playable tracks");
|
||||
let Some(tracks) = fetch_album_for_play(&runtime, &weak, &album_id).await else {
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
let start = start_index.min(tracks.len() - 1);
|
||||
let start_track_id = tracks[start].id;
|
||||
runtime.core().set_queue(tracks, Some(start)).await;
|
||||
after_track_change(&runtime, &weak, start_track_id).await;
|
||||
refresh_sidebar(true);
|
||||
});
|
||||
}
|
||||
|
||||
/// Play an album starting at the clicked track id (queues the tracks that
|
||||
/// follow). `visible_ids` is the album view's VISIBLE row order — the queue
|
||||
/// is reordered/filtered to match it, so the album track-search filter is
|
||||
/// respected. Anchoring on the id keeps the start correct regardless.
|
||||
pub fn play_album_from(
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
album_id: String,
|
||||
visible_ids: Vec<String>,
|
||||
clicked_id: String,
|
||||
) {
|
||||
handle.spawn(async move {
|
||||
let Some(tracks) = fetch_album_for_play(&runtime, &weak, &album_id).await else {
|
||||
return;
|
||||
};
|
||||
let tracks = reorder_queue_by_visible(tracks, &visible_ids);
|
||||
let start = tracks
|
||||
.iter()
|
||||
.position(|t| t.id.to_string() == clicked_id)
|
||||
.unwrap_or(0);
|
||||
let start_track_id = tracks[start].id;
|
||||
runtime.core().set_queue(tracks, Some(start)).await;
|
||||
after_track_change(&runtime, &weak, start_track_id).await;
|
||||
refresh_sidebar(true);
|
||||
@@ -731,6 +775,44 @@ pub fn play_album(
|
||||
/// first track. Wired to the Popular Tracks "play all" CircleAction
|
||||
/// in ArtistPageView. Re-fetches the artist page so the queue
|
||||
/// carries the same audio metadata the page row uses.
|
||||
/// Fetch the artist page and build the Popular-tracks play queue. Shared by
|
||||
/// `play_artist_top_tracks` (start at 0) and `play_artist_top_from` (start at
|
||||
/// a clicked track id). Returns None and toasts on failure / no top tracks.
|
||||
async fn fetch_artist_top_for_play(
|
||||
runtime: &Runtime,
|
||||
weak: &slint::Weak<AppWindow>,
|
||||
artist_id: &str,
|
||||
) -> Option<Vec<QueueTrack>> {
|
||||
let id: u64 = match artist_id.parse() {
|
||||
Ok(id) => id,
|
||||
Err(_) => {
|
||||
log::warn!("[qbz-slint] play-top: invalid artist id {artist_id}");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let page = match runtime.core().get_artist_page(id, None).await {
|
||||
Ok(page) => page,
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] play-top: get_artist_page failed: {e}");
|
||||
crate::toast::error_weak(weak, "Couldn't load this artist");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let artist_name = page.name.display.clone();
|
||||
let tracks: Vec<QueueTrack> = page
|
||||
.top_tracks
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|track| make_top_track_queue(track, &artist_name))
|
||||
.collect();
|
||||
if tracks.is_empty() {
|
||||
log::warn!("[qbz-slint] play-top: artist {artist_id} has no top tracks");
|
||||
crate::toast::error_weak(weak, "No top tracks available for this artist");
|
||||
return None;
|
||||
}
|
||||
Some(tracks)
|
||||
}
|
||||
|
||||
pub fn play_artist_top_tracks(
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
@@ -738,33 +820,9 @@ pub fn play_artist_top_tracks(
|
||||
artist_id: String,
|
||||
) {
|
||||
handle.spawn(async move {
|
||||
let id: u64 = match artist_id.parse() {
|
||||
Ok(id) => id,
|
||||
Err(_) => {
|
||||
log::warn!("[qbz-slint] play-top: invalid artist id {artist_id}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let page = match runtime.core().get_artist_page(id, None).await {
|
||||
Ok(page) => page,
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] play-top: get_artist_page failed: {e}");
|
||||
crate::toast::error_weak(&weak, "Couldn't load this artist");
|
||||
return;
|
||||
}
|
||||
};
|
||||
let artist_name = page.name.display.clone();
|
||||
let tracks: Vec<QueueTrack> = page
|
||||
.top_tracks
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|track| make_top_track_queue(track, &artist_name))
|
||||
.collect();
|
||||
if tracks.is_empty() {
|
||||
log::warn!("[qbz-slint] play-top: artist {artist_id} has no top tracks");
|
||||
crate::toast::error_weak(&weak, "No top tracks available for this artist");
|
||||
let Some(tracks) = fetch_artist_top_for_play(&runtime, &weak, &artist_id).await else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let start_track_id = tracks[0].id;
|
||||
runtime.core().set_queue(tracks, Some(0)).await;
|
||||
after_track_change(&runtime, &weak, start_track_id).await;
|
||||
@@ -772,6 +830,34 @@ pub fn play_artist_top_tracks(
|
||||
});
|
||||
}
|
||||
|
||||
/// Play the artist's Popular tracks starting at the clicked track id (queues
|
||||
/// the tracks that follow it). `visible_ids` is the Popular-tracks VISIBLE row
|
||||
/// order — the queue is reordered/filtered to match, so the in-page search
|
||||
/// filter is respected. Re-fetches the page like `play_artist_top_tracks`.
|
||||
pub fn play_artist_top_from(
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
artist_id: String,
|
||||
visible_ids: Vec<String>,
|
||||
clicked_id: String,
|
||||
) {
|
||||
handle.spawn(async move {
|
||||
let Some(tracks) = fetch_artist_top_for_play(&runtime, &weak, &artist_id).await else {
|
||||
return;
|
||||
};
|
||||
let tracks = reorder_queue_by_visible(tracks, &visible_ids);
|
||||
let start = tracks
|
||||
.iter()
|
||||
.position(|t| t.id.to_string() == clicked_id)
|
||||
.unwrap_or(0);
|
||||
let start_track_id = tracks[start].id;
|
||||
runtime.core().set_queue(tracks, Some(start)).await;
|
||||
after_track_change(&runtime, &weak, start_track_id).await;
|
||||
refresh_sidebar(true);
|
||||
});
|
||||
}
|
||||
|
||||
/// Build a QueueTrack from a /artist/page top_tracks entry. The page
|
||||
/// response carries a thinner audio_info than /album/get tracks; fall
|
||||
/// back to sensible defaults when fields are absent.
|
||||
@@ -871,6 +957,292 @@ pub fn play_track_now(
|
||||
});
|
||||
}
|
||||
|
||||
/// "m:ss" / "h:mm:ss" -> seconds (for a queue row built off a display string).
|
||||
fn mmss_to_secs(s: &str) -> u64 {
|
||||
s.split(':')
|
||||
.filter_map(|p| p.trim().parse::<u64>().ok())
|
||||
.fold(0u64, |acc, v| acc * 60 + v)
|
||||
}
|
||||
|
||||
/// Build a `QueueTrack` from a visible Slint `TrackItem` row. Used for views
|
||||
/// that render Qobuz tracks but keep no full-`Track` cache (search): the
|
||||
/// audio is resolved by id at play time, so the row's display fields suffice
|
||||
/// to seed the queue. Returns None for rows whose id is not numeric.
|
||||
fn track_item_to_queue(it: &TrackItem) -> Option<QueueTrack> {
|
||||
let id = it.id.as_str().parse::<u64>().ok()?;
|
||||
let album_id = {
|
||||
let a = it.album_id.to_string();
|
||||
if a.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(a)
|
||||
}
|
||||
};
|
||||
Some(QueueTrack {
|
||||
id,
|
||||
title: it.title.to_string(),
|
||||
version: None,
|
||||
artist: it.artist.to_string(),
|
||||
album: it.album.to_string(),
|
||||
duration_secs: mmss_to_secs(it.duration.as_str()),
|
||||
artwork_url: {
|
||||
let u = it.artwork_url.to_string();
|
||||
if u.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(u)
|
||||
}
|
||||
},
|
||||
hires: it.quality_tier.as_str() == "hires",
|
||||
bit_depth: None,
|
||||
sample_rate: None,
|
||||
is_local: it.source.as_str() == "local",
|
||||
album_id: album_id.clone(),
|
||||
artist_id: it.artist_id.as_str().parse::<u64>().ok(),
|
||||
streamable: true,
|
||||
source: {
|
||||
let s = it.source.to_string();
|
||||
Some(if s.is_empty() {
|
||||
"qobuz".to_string()
|
||||
} else {
|
||||
s
|
||||
})
|
||||
},
|
||||
parental_warning: it.explicit,
|
||||
source_item_id_hint: album_id,
|
||||
})
|
||||
}
|
||||
|
||||
/// The ids of a view's VISIBLE `TrackItem` model rows, in order.
|
||||
fn model_ids(model: &ModelRc<TrackItem>) -> Vec<String> {
|
||||
(0..model.row_count())
|
||||
.filter_map(|i| model.row_data(i).map(|it| it.id.to_string()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Re-order (and filter) a freshly-built queue to match a view's VISIBLE
|
||||
/// order: keep only the tracks the user can see, in the order they see them.
|
||||
/// Used by the re-fetch views (album / artist top tracks) so an active
|
||||
/// in-page search filter is respected. Empty `visible_ids` (or no overlap)
|
||||
/// leaves the canonical order untouched.
|
||||
fn reorder_queue_by_visible(queue: Vec<QueueTrack>, visible_ids: &[String]) -> Vec<QueueTrack> {
|
||||
if visible_ids.is_empty() {
|
||||
return queue;
|
||||
}
|
||||
let pos: std::collections::HashMap<String, usize> = queue
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, q)| (q.id.to_string(), i))
|
||||
.collect();
|
||||
let order: Vec<usize> = visible_ids
|
||||
.iter()
|
||||
.filter_map(|id| pos.get(id).copied())
|
||||
.collect();
|
||||
if order.is_empty() {
|
||||
return queue;
|
||||
}
|
||||
let mut slots: Vec<Option<QueueTrack>> = queue.into_iter().map(Some).collect();
|
||||
order.iter().filter_map(|&i| slots[i].take()).collect()
|
||||
}
|
||||
|
||||
/// Build a play queue (+ start index) from a view's VISIBLE `TrackItem`
|
||||
/// model, starting at `clicked_id`. The model IS the visible order, so this
|
||||
/// never goes out of sync with what the user sees. Used by views with no
|
||||
/// full-`Track` cache (search).
|
||||
fn queue_from_model(
|
||||
model: &ModelRc<TrackItem>,
|
||||
clicked_id: &str,
|
||||
) -> (Vec<QueueTrack>, Option<usize>) {
|
||||
let mut queue: Vec<QueueTrack> = Vec::with_capacity(model.row_count());
|
||||
let mut found: Option<usize> = None;
|
||||
for i in 0..model.row_count() {
|
||||
if let Some(it) = model.row_data(i) {
|
||||
if let Some(qt) = track_item_to_queue(&it) {
|
||||
if it.id.as_str() == clicked_id {
|
||||
found = Some(queue.len());
|
||||
}
|
||||
queue.push(qt);
|
||||
}
|
||||
}
|
||||
}
|
||||
// `found` is None when the clicked track is not a list row (e.g. the
|
||||
// search "most popular" hero card) — the caller decides what to do.
|
||||
(queue, found)
|
||||
}
|
||||
|
||||
/// Build a play queue (+ start index) from a view's VISIBLE `TrackItem`
|
||||
/// model and its authoritative `Vec<Track>` cache: the queue follows the
|
||||
/// visible order (so custom sort / search filter are respected) and starts
|
||||
/// at `clicked_id`. Falls back to the cache order if the visible/cache
|
||||
/// mapping comes up empty.
|
||||
fn order_by_visible(
|
||||
model: &ModelRc<TrackItem>,
|
||||
cache: Vec<Track>,
|
||||
clicked_id: &str,
|
||||
) -> Option<(Vec<Track>, usize)> {
|
||||
let visible_ids: Vec<String> = (0..model.row_count())
|
||||
.filter_map(|i| model.row_data(i).map(|it| it.id.to_string()))
|
||||
.collect();
|
||||
let by_id: std::collections::HashMap<String, Track> =
|
||||
cache.iter().map(|t| (t.id.to_string(), t.clone())).collect();
|
||||
let ordered: Vec<Track> = visible_ids
|
||||
.iter()
|
||||
.filter_map(|id| by_id.get(id).cloned())
|
||||
.collect();
|
||||
// The clicked track must resolve inside the visible list; if it does not
|
||||
// (orphan/hero row, or a cache miss), return None so the caller plays just
|
||||
// that track rather than starting the queue at the wrong row.
|
||||
let idx = ordered
|
||||
.iter()
|
||||
.position(|t| t.id.to_string() == clicked_id)?;
|
||||
Some((ordered, idx))
|
||||
}
|
||||
|
||||
/// Hand a prebuilt `QueueTrack` queue to the core and start at `start`.
|
||||
/// Callers guard against an empty queue.
|
||||
fn play_queue(
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
queue: Vec<QueueTrack>,
|
||||
start: usize,
|
||||
) {
|
||||
let start = start.min(queue.len() - 1);
|
||||
let first_id = queue[start].id;
|
||||
handle.spawn(async move {
|
||||
runtime.core().set_queue(queue, Some(start)).await;
|
||||
after_track_change(&runtime, &weak, first_id).await;
|
||||
refresh_sidebar(true);
|
||||
});
|
||||
}
|
||||
|
||||
/// Per-row "play this track" for EVERY tracklist surface. Builds the queue
|
||||
/// from the CURRENT view's VISIBLE list and starts at the clicked track, so
|
||||
/// the tracks that visually follow it play next — regardless of context
|
||||
/// (playlist custom sort, album, favorites filter, artist top tracks, ...).
|
||||
///
|
||||
/// This is the single entry point for clicking/double-clicking a track row.
|
||||
/// It replaces a scatter of per-view paths that each got it wrong: the album
|
||||
/// row played a lone track (no queue), and the playlist/mix rows always
|
||||
/// started at track 1 (the clicked id was read from the wrong media-action
|
||||
/// slot). Do NOT reintroduce per-view play arms — route everything here.
|
||||
pub fn play_track_in_context(
|
||||
window: &AppWindow,
|
||||
runtime: Runtime,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
clicked_id: &str,
|
||||
) {
|
||||
let view = window.global::<NavState>().get_view();
|
||||
match view {
|
||||
// Views with an authoritative Vec<Track> cache: order it by the
|
||||
// visible model so sort/filter are respected.
|
||||
ContentView::Playlist => {
|
||||
if let Some((tracks, idx)) = order_by_visible(
|
||||
&window.global::<PlaylistState>().get_tracks(),
|
||||
crate::playlist::current_tracks(),
|
||||
clicked_id,
|
||||
) {
|
||||
play_tracks(runtime, weak, handle, tracks, idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ContentView::Favorites => {
|
||||
if let Some((tracks, idx)) = order_by_visible(
|
||||
&window.global::<FavoritesState>().get_tracks_visible(),
|
||||
crate::favorites::play_tracks(),
|
||||
clicked_id,
|
||||
) {
|
||||
play_tracks(runtime, weak, handle, tracks, idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ContentView::Label => {
|
||||
if let Some((tracks, idx)) = order_by_visible(
|
||||
&window.global::<LabelState>().get_top_tracks(),
|
||||
crate::label::top_tracks_for_play(),
|
||||
clicked_id,
|
||||
) {
|
||||
play_tracks(runtime, weak, handle, tracks, idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ContentView::Mix => {
|
||||
// Mix has no custom sort/filter, so the cache order is the
|
||||
// visible order; anchor on the clicked id.
|
||||
let tracks = crate::mix::current_tracks();
|
||||
if tracks.iter().any(|t| t.id.to_string() == clicked_id) {
|
||||
let idx = crate::mix::index_of(clicked_id);
|
||||
play_tracks(runtime, weak, handle, tracks, idx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Search keeps no full-Track cache — build the queue straight off
|
||||
// the visible model (Qobuz tracks resolve by id at play time).
|
||||
ContentView::Search => {
|
||||
let model = window.global::<SearchState>().get_tracks();
|
||||
let (queue, found) = queue_from_model(&model, clicked_id);
|
||||
if let Some(idx) = found {
|
||||
play_queue(runtime, weak, handle, queue, idx);
|
||||
return;
|
||||
}
|
||||
// The "most popular" hero is a top-track card, not a results row.
|
||||
// Play it as the queue head, then the visible results, so it acts
|
||||
// like a first-class track (clicking it queues what follows).
|
||||
let ss = window.global::<SearchState>();
|
||||
if ss.get_most_popular_kind().as_str() == "track" {
|
||||
let hero = ss.get_most_popular_track();
|
||||
if hero.id.as_str() == clicked_id {
|
||||
if let Some(hq) = track_item_to_queue(&hero) {
|
||||
let mut q = queue;
|
||||
q.insert(0, hq);
|
||||
play_queue(runtime, weak, handle, q, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Re-fetch views: build the queue from the catalog, reorder it to the
|
||||
// VISIBLE row order (so an in-page search filter is respected), and
|
||||
// start at the clicked id. (Local albums are routed earlier.)
|
||||
ContentView::Album => {
|
||||
let album_id = window.global::<AlbumState>().get_id().to_string();
|
||||
if !album_id.is_empty() {
|
||||
let visible_ids = model_ids(&window.global::<AlbumState>().get_tracks());
|
||||
play_album_from(
|
||||
runtime,
|
||||
weak,
|
||||
handle,
|
||||
album_id,
|
||||
visible_ids,
|
||||
clicked_id.to_string(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ContentView::Artist => {
|
||||
let artist_id = window.global::<ArtistState>().get_id().to_string();
|
||||
if !artist_id.is_empty() {
|
||||
let visible_ids = model_ids(&window.global::<ArtistState>().get_top_tracks());
|
||||
play_artist_top_from(
|
||||
runtime,
|
||||
weak,
|
||||
handle,
|
||||
artist_id,
|
||||
visible_ids,
|
||||
clicked_id.to_string(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// No resolvable list context (Home, Discover, ...): play just the track.
|
||||
if let Ok(tid) = clicked_id.parse::<u64>() {
|
||||
play_track_now(runtime, weak, handle, tid);
|
||||
}
|
||||
}
|
||||
|
||||
/// Build a queue from a list of catalog tracks (each carrying its own
|
||||
/// album) and start playback at `start_index`. Shared by radio
|
||||
/// (start 0) and the mix views (start at the clicked track).
|
||||
|
||||
@@ -357,6 +357,11 @@ fn to_item(track: &Track) -> TrackItem {
|
||||
None => "",
|
||||
}
|
||||
.into(),
|
||||
quality_detail: crate::quality::detail(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
)
|
||||
.into(),
|
||||
explicit: track.parental_warning,
|
||||
selected: false,
|
||||
// Smallest variant — these are 40px row thumbnails; best()
|
||||
@@ -489,44 +494,9 @@ pub fn shuffled_tracks() -> Vec<Track> {
|
||||
tracks
|
||||
}
|
||||
|
||||
pub fn index_of(track_id: &str) -> usize {
|
||||
CURRENT
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|c| c.iter().position(|t| t.id.to_string() == track_id))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
/// Build the play queue + start index from the CURRENTLY VISIBLE order
|
||||
/// (search/sort applied — read straight off `PlaylistState.tracks`), starting
|
||||
/// at `track_id`. This makes clicking a row begin playback there and queue the
|
||||
/// tracks that VISUALLY follow it — the general app behaviour. Falls back to
|
||||
/// the cached order if the visible/cache mapping comes up empty.
|
||||
pub fn visible_play_context(window: &AppWindow, track_id: &str) -> (Vec<Track>, usize) {
|
||||
use slint::Model;
|
||||
let visible_ids: Vec<String> = {
|
||||
let m = window.global::<PlaylistState>().get_tracks();
|
||||
(0..m.row_count())
|
||||
.filter_map(|i| m.row_data(i).map(|it| it.id.to_string()))
|
||||
.collect()
|
||||
};
|
||||
let cur = CURRENT.lock().map(|c| c.clone()).unwrap_or_default();
|
||||
let by_id: std::collections::HashMap<String, Track> =
|
||||
cur.iter().map(|t| (t.id.to_string(), t.clone())).collect();
|
||||
let ordered: Vec<Track> = visible_ids
|
||||
.iter()
|
||||
.filter_map(|id| by_id.get(id).cloned())
|
||||
.collect();
|
||||
if ordered.is_empty() {
|
||||
// Cache/visible mismatch — fall back to the cached order.
|
||||
return (cur, index_of(track_id));
|
||||
}
|
||||
let idx = visible_ids
|
||||
.iter()
|
||||
.position(|id| id == track_id)
|
||||
.unwrap_or(0);
|
||||
(ordered, idx)
|
||||
}
|
||||
// Per-row "play from here" (visible order + clicked index) is handled
|
||||
// centrally in `playback::play_track_in_context` / `order_by_visible`, which
|
||||
// covers every tracklist view uniformly — see that function.
|
||||
|
||||
// ==================== Custom artwork ====================
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
//! Shared quality-label formatting for the track / album quality badges.
|
||||
//!
|
||||
//! `detail` is the exact bit-depth / sample-rate line shown under the tier
|
||||
//! label, e.g. `"24-bit / 96 kHz"` — no `Hi-Res` / `CD` prefix (the badge
|
||||
//! renders the tier separately). It matches the AlbumView header badge so a
|
||||
//! track row and an album header advertise quality identically.
|
||||
|
||||
/// Format the quality detail string from a track's max bit depth and sample
|
||||
/// rate. Defaults to CD (16-bit / 44.1 kHz) / Hi-Res (24-bit / 96 kHz) values
|
||||
/// when a field is missing, mirroring the AlbumView badge. The badge itself is
|
||||
/// hidden when the tier is empty, so the value is irrelevant for unknown-quality
|
||||
/// rows.
|
||||
pub fn detail(bit_depth: Option<u32>, sample_rate: Option<f64>) -> String {
|
||||
let hi_res = matches!(bit_depth, Some(depth) if depth >= 24);
|
||||
let depth = bit_depth.unwrap_or(if hi_res { 24 } else { 16 });
|
||||
let rate = sample_rate.unwrap_or(if hi_res { 96.0 } else { 44.1 });
|
||||
let rate = if rate.fract().abs() < f64::EPSILON {
|
||||
format!("{}", rate as i64)
|
||||
} else {
|
||||
format!("{rate}")
|
||||
};
|
||||
format!("{depth}-bit / {rate} kHz")
|
||||
}
|
||||
@@ -68,6 +68,9 @@ pub struct TrackRowData {
|
||||
/// Detailed quality label, e.g. "Hi-Res 24-bit / 192 kHz". Used by the
|
||||
/// most-popular track hero (shown as text instead of an icon badge).
|
||||
pub quality_label: String,
|
||||
/// Exact bit-depth / sample-rate line, e.g. "24-bit / 192 kHz" — feeds the
|
||||
/// track-row quality badge (no tier prefix, unlike `quality_label`).
|
||||
pub quality_detail: String,
|
||||
pub explicit: bool,
|
||||
pub artwork_url: String,
|
||||
}
|
||||
@@ -226,6 +229,10 @@ pub fn map_track(track: Track) -> TrackRowData {
|
||||
duration: mmss(track.duration),
|
||||
quality_tier: tier(track.maximum_bit_depth).to_string(),
|
||||
quality_label: quality_label(track.maximum_bit_depth, track.maximum_sampling_rate),
|
||||
quality_detail: crate::quality::detail(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
),
|
||||
explicit: track.parental_warning,
|
||||
artwork_url,
|
||||
}
|
||||
@@ -365,6 +372,7 @@ fn track_item(row: TrackRowData) -> TrackItem {
|
||||
album: "".into(),
|
||||
duration: row.duration.into(),
|
||||
quality_tier: row.quality_tier.into(),
|
||||
quality_detail: row.quality_detail.into(),
|
||||
explicit: row.explicit,
|
||||
selected: false,
|
||||
artwork_url: row.artwork_url.into(),
|
||||
|
||||
@@ -229,7 +229,7 @@ export component MixView inherits Rectangle {
|
||||
}
|
||||
Text {
|
||||
text: @tr("Quality");
|
||||
width: 64px;
|
||||
width: 92px;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
|
||||
@@ -555,7 +555,8 @@ export component PlaylistView inherits Rectangle {
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Rectangle { width: 40px; }
|
||||
// Play/cover cell — matches the row's 36px artwork cell.
|
||||
Rectangle { width: 36px; }
|
||||
Text {
|
||||
text: @tr("Title");
|
||||
color: Theme.text-muted;
|
||||
@@ -577,11 +578,14 @@ export component PlaylistView inherits Rectangle {
|
||||
}
|
||||
Text {
|
||||
text: @tr("Quality");
|
||||
width: 70px;
|
||||
width: 92px;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
// Reserve the row's three trailing columns: favorite (28),
|
||||
// offline/download (28), context-menu (32).
|
||||
Rectangle { width: 28px; }
|
||||
Rectangle { width: 28px; }
|
||||
Rectangle { width: 32px; }
|
||||
}
|
||||
@@ -612,29 +616,38 @@ export component PlaylistView inherits Rectangle {
|
||||
// without shrinking the list).
|
||||
Rectangle {
|
||||
vertical-stretch: 1;
|
||||
track-list := ListView {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
vertical-scrollbar-policy: ScrollBarPolicy.always-off;
|
||||
for track[i] in PlaylistState.tracks: TrackRow {
|
||||
track: track;
|
||||
index: i;
|
||||
show-artwork: true;
|
||||
show-album: true;
|
||||
show-favorite: true;
|
||||
show-reorder: PlaylistState.sort-field == "custom";
|
||||
multi-select-mode: PlaylistState.multi-select-mode;
|
||||
media-action(kind, id, action) => {
|
||||
if (action == "play") {
|
||||
root.play-track(id);
|
||||
} else {
|
||||
root.media-action(kind, id, action);
|
||||
// The list sits in a right-padded layout so the custom
|
||||
// scrollbar lands in the gutter instead of overlapping the
|
||||
// rows, and the rows' right edge lines up with the column
|
||||
// header (mirrors LocalLibrary > Tracks).
|
||||
VerticalLayout {
|
||||
padding-right: 14px;
|
||||
track-list := ListView {
|
||||
vertical-stretch: 1;
|
||||
vertical-scrollbar-policy: ScrollBarPolicy.always-off;
|
||||
for track[i] in PlaylistState.tracks: TrackRow {
|
||||
track: track;
|
||||
index: i;
|
||||
show-artwork: true;
|
||||
show-album: true;
|
||||
show-favorite: true;
|
||||
show-reorder: PlaylistState.sort-field == "custom";
|
||||
multi-select-mode: PlaylistState.multi-select-mode;
|
||||
media-action(kind, id, action) => {
|
||||
if (action == "play") {
|
||||
root.play-track(id);
|
||||
} else {
|
||||
root.media-action(kind, id, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ListScrollbar {
|
||||
x: parent.width - self.width - 4px;
|
||||
// Anchor to the VIEW's right edge like LocalLibrary > Tracks:
|
||||
// the +16px cancels `page`'s right padding so the scrollbar
|
||||
// sits 4px from the edge (not 4px from the padded content).
|
||||
x: parent.width - self.width - 4px + 16px;
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
viewport-height: track-list.viewport-height;
|
||||
|
||||
@@ -14,6 +14,12 @@ export component QualityBadgeFull inherits Rectangle {
|
||||
in property <string> tier;
|
||||
// Exact quality, e.g. "24-bit / 96 kHz".
|
||||
in property <string> detail;
|
||||
// Whether to show the format icon (Hi-Res / CD / MP3 mark). The track-row
|
||||
// variant turns it off.
|
||||
in property <bool> show-icon: true;
|
||||
// "bare" = no chip background or border, text centered — blends into a
|
||||
// track row instead of looking like a contained badge.
|
||||
in property <bool> bare: false;
|
||||
|
||||
property <string> tier-label: root.tier == "hires"
|
||||
? "HI-RES"
|
||||
@@ -21,20 +27,21 @@ export component QualityBadgeFull inherits Rectangle {
|
||||
|
||||
visible: root.tier != "";
|
||||
height: 36px;
|
||||
width: Math.max(content.preferred-width, 136px);
|
||||
width: root.bare ? content.preferred-width : Math.max(content.preferred-width, 136px);
|
||||
border-radius: 4px;
|
||||
background: Theme.surface-hover;
|
||||
border-width: 1px;
|
||||
background: root.bare ? transparent : Theme.surface-hover;
|
||||
border-width: root.bare ? 0px : 1px;
|
||||
border-color: Theme.border-subtle;
|
||||
|
||||
content := HorizontalLayout {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
spacing: 6px;
|
||||
padding-left: root.bare ? 0px : 10px;
|
||||
padding-right: root.bare ? 0px : 10px;
|
||||
spacing: root.bare ? 0px : 6px;
|
||||
alignment: root.bare ? center : start;
|
||||
|
||||
// Format icon. The Hi-Res brand mark keeps its own colors; the
|
||||
// CD / MP3 marks render in muted grey.
|
||||
VerticalLayout {
|
||||
if root.show-icon: VerticalLayout {
|
||||
alignment: center;
|
||||
if root.tier == "hires": Image {
|
||||
source: @image-url("../assets/hi-res.svg");
|
||||
@@ -65,12 +72,14 @@ export component QualityBadgeFull inherits Rectangle {
|
||||
font-size: 8px;
|
||||
font-weight: 100;
|
||||
letter-spacing: 0.5px;
|
||||
horizontal-alignment: root.bare ? center : left;
|
||||
}
|
||||
Text {
|
||||
text: root.detail;
|
||||
color: #999999;
|
||||
font-size: 9px;
|
||||
font-weight: 100;
|
||||
horizontal-alignment: root.bare ? center : left;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import { TrackItem, DragActions, NowPlayingState, NavState } from "../state.slin
|
||||
import { QbzIcon } from "QbzIcon.slint";
|
||||
import { TrackPlayCell } from "TrackPlayCell.slint";
|
||||
import { TrackContextMenu } from "TrackContextMenu.slint";
|
||||
import { QualityBadgeFull } from "QualityBadgeFull.slint";
|
||||
|
||||
export component TrackRow inherits Rectangle {
|
||||
in property <TrackItem> track;
|
||||
@@ -382,16 +383,20 @@ export component TrackRow inherits Rectangle {
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
// Quality.
|
||||
Text {
|
||||
text: root.track.quality-tier == "hires"
|
||||
? "Hi-Res"
|
||||
: (root.track.quality-tier == "cd" ? "CD" : "");
|
||||
width: 70px;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
// Quality — bare badge (tier label + exact bit-depth / sample-rate),
|
||||
// no chip background so it blends into the row.
|
||||
HorizontalLayout {
|
||||
width: 92px;
|
||||
alignment: center;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
QualityBadgeFull {
|
||||
tier: root.track.quality-tier;
|
||||
detail: root.track.quality-detail;
|
||||
show-icon: false;
|
||||
bare: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Favorite — filled accent heart when favorited, outline heart
|
||||
|
||||
@@ -208,7 +208,7 @@ export component AppShell inherits Rectangle {
|
||||
if NavState.view == ContentView.local-library: LocalLibraryView { }
|
||||
if NavState.view == ContentView.mix: MixView {
|
||||
play-track(id) => {
|
||||
root.media-action("mix-track", id, "play");
|
||||
root.media-action("track", id, "play");
|
||||
}
|
||||
play-all => {
|
||||
root.media-action("mix", "", "play-all");
|
||||
@@ -225,7 +225,7 @@ export component AppShell inherits Rectangle {
|
||||
}
|
||||
if NavState.view == ContentView.playlist: PlaylistView {
|
||||
play-track(id) => {
|
||||
root.media-action("playlist-track", id, "play");
|
||||
root.media-action("track", id, "play");
|
||||
}
|
||||
play-all => {
|
||||
root.media-action("playlist", "", "play-all");
|
||||
|
||||
@@ -247,6 +247,9 @@ export struct TrackItem {
|
||||
album: string,
|
||||
duration: string,
|
||||
quality-tier: string,
|
||||
// Exact bit-depth / sample-rate line, e.g. "24-bit / 96 kHz" — feeds the
|
||||
// track-row quality badge (empty for unknown / where only the tier shows).
|
||||
quality-detail: string,
|
||||
explicit: bool,
|
||||
selected: bool,
|
||||
artwork-url: string,
|
||||
|
||||
Reference in new issue
Block a user