feat(slint): Track Info + Album Info (Credits/Review) modals
1:1 port of the Tauri TrackInfoModal + AlbumCreditsModal to the Slint UI.
The Track Info invocations were already wired (TransportControls info
button, SongCard title, TrackContextMenu item) and only needed the modal
plus the fetch; the backend (core get_track/get_album, qbz-qobuz performers,
models) already carried all the data.
- qbz-qobuz/performers.rs: group_credits_ordered (matches the Tauri
getGroupedCredits ordering: Composer/Lyricist first, MainArtist last, rest
alphabetical, deduped) + format_role_label backed by the 147-entry English
performerRoles map.
- qbz-slint/info_modals.rs: fetch + map + apply controllers (mirror of
navigate_album); track/album quality strings match Tauri exactly.
- state.slint: TrackInfoState / AlbumInfoState + InfoCreditRow / InfoCreditPair
/ AlbumCreditPerformer / AlbumCreditTrack + Actions; re-exported in app.slint.
- TrackInfoModal.slint + AlbumCreditsModal.slint: scrim modals (FocusScope +
Timer for Esc, ListScrollbar), 3-col metadata + 2-col credits grids,
expandable track rows with play-on-hover, Credits/Review tabs gated on a
review. Album modal is content-sized with a capped max height.
- AppShell mounts both; AlbumPageView (i) button wired (Qobuz albums only);
main.rs adds the ("track","track-info") + ("album","info") arms and the
modal action callbacks (close/tab/play/artist/label/musician).
cc
This commit is contained in:
9 files changed
+1876
-5
No files matched your search
@@ -0,0 +1,510 @@
|
||||
//! Track Info + Album Info (Credits/Review) modal controllers.
|
||||
//!
|
||||
//! 1:1 port of Tauri's `TrackInfoModal.svelte` + `AlbumCreditsModal.svelte`.
|
||||
//! Both fetch fresh data through `QbzCore` (`get_track` / `get_album`), map it
|
||||
//! to plain `Send` structs on the worker thread, then apply it to the
|
||||
//! `TrackInfoState` / `AlbumInfoState` globals on the Slint event loop —
|
||||
//! mirroring `crate::album::navigate_album`. Role parsing / grouping /
|
||||
//! localization lives in `qbz_qobuz::performers` (frontend-agnostic, ADR-006).
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
use qbz_app::shell::AppRuntime;
|
||||
use qbz_core::FrontendAdapter;
|
||||
use qbz_models::{Album, Track};
|
||||
use qbz_qobuz::performers::{format_role_label, group_credits_ordered, parse_performers};
|
||||
use slint::{ComponentHandle, ModelRc, SharedString, VecModel};
|
||||
|
||||
use crate::{
|
||||
AlbumCreditPerformer, AlbumCreditTrack, AlbumInfoState, AlbumState, AppWindow, InfoCreditPair,
|
||||
InfoCreditRow, TrackInfoState,
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Plain, `Send` data produced on the worker thread.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
struct CreditRowData {
|
||||
/// Already-localized, UPPER-CASED role label (display).
|
||||
role: String,
|
||||
/// Original role string (for the musician-nav role hint, 1:1 with Tauri
|
||||
/// which passes the raw group role, not the display label).
|
||||
role_raw: String,
|
||||
names: Vec<String>,
|
||||
}
|
||||
|
||||
pub struct TrackInfoData {
|
||||
title: String,
|
||||
album: String,
|
||||
artist: String,
|
||||
/// "" -> render the artist as plain text (no link).
|
||||
artist_id: String,
|
||||
duration: String,
|
||||
quality: String,
|
||||
isrc: String,
|
||||
label: String,
|
||||
label_id: String,
|
||||
copyright: String,
|
||||
credits: Vec<CreditRowData>,
|
||||
}
|
||||
|
||||
struct PerformerData {
|
||||
name: String,
|
||||
/// ", Role1, Role2" suffix (empty when the performer has no roles).
|
||||
roles: String,
|
||||
/// First role (clean), or "Performer" — the musician-nav role hint,
|
||||
/// 1:1 with Tauri `handlePerformerClick` (roles[0] || 'Performer').
|
||||
primary_role: String,
|
||||
}
|
||||
|
||||
struct AlbumTrackData {
|
||||
id: String,
|
||||
number: String,
|
||||
title: String,
|
||||
artist: String,
|
||||
has_credits: bool,
|
||||
performers: Vec<PerformerData>,
|
||||
copyright: String,
|
||||
}
|
||||
|
||||
pub struct AlbumCreditsData {
|
||||
title: String,
|
||||
artist: String,
|
||||
label: String,
|
||||
label_id: String,
|
||||
release_date: String,
|
||||
meta_line: String,
|
||||
quality: String,
|
||||
review: String,
|
||||
has_review: bool,
|
||||
tracks: Vec<AlbumTrackData>,
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Formatting helpers (mirror the Tauri modal helpers).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// "Title (Version)" when a non-empty version exists, else "Title".
|
||||
fn format_title(title: &str, version: Option<&str>) -> String {
|
||||
let title = title.trim();
|
||||
match version.map(str::trim).filter(|v| !v.is_empty()) {
|
||||
Some(v) => format!("{title} ({v})"),
|
||||
None => title.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Track length as "M:SS" (zero-padded seconds), like Tauri `formatDuration`.
|
||||
fn track_duration(secs: u32) -> String {
|
||||
format!("{}:{:02}", secs / 60, secs % 60)
|
||||
}
|
||||
|
||||
/// Album length as "1h 21m" / "45m" (no seconds), like `formatAlbumDuration`.
|
||||
fn album_duration(secs: u32) -> String {
|
||||
let hours = secs / 3600;
|
||||
let minutes = (secs % 3600) / 60;
|
||||
if hours > 0 {
|
||||
format!("{hours}h {minutes}m")
|
||||
} else {
|
||||
format!("{minutes}m")
|
||||
}
|
||||
}
|
||||
|
||||
/// Sample-rate value without a trailing ".0" (96.0 -> "96", 44.1 -> "44.1"),
|
||||
/// matching JS number interpolation in the Tauri modals. NOT normalized
|
||||
/// (Hz vs kHz) — the modals print the raw maximum_sampling_rate as Tauri does.
|
||||
fn fmt_rate(rate: f64) -> String {
|
||||
if rate.fract().abs() < f64::EPSILON {
|
||||
format!("{}", rate as i64)
|
||||
} else {
|
||||
format!("{rate}")
|
||||
}
|
||||
}
|
||||
|
||||
/// Track Info quality — 1:1 with Tauri `formatQuality`: "24-bit / 96kHz" (NO
|
||||
/// space before kHz), each field only when present; when both are absent fall
|
||||
/// back to the Hi-Res / Lossless label (by `hires_streamable`).
|
||||
fn track_quality(bit: Option<u32>, rate: Option<f64>, hires_streamable: bool) -> String {
|
||||
let mut parts: Vec<String> = Vec::new();
|
||||
if let Some(b) = bit {
|
||||
parts.push(format!("{b}-bit"));
|
||||
}
|
||||
if let Some(r) = rate {
|
||||
parts.push(format!("{}kHz", fmt_rate(r)));
|
||||
}
|
||||
if parts.is_empty() {
|
||||
return if hires_streamable { "Hi-Res" } else { "Lossless" }.to_string();
|
||||
}
|
||||
parts.join(" / ")
|
||||
}
|
||||
|
||||
/// Album Info quality — 1:1 with Tauri `formatQuality(bitDepth, samplingRate)`:
|
||||
/// "24-Bit / 96 kHz" (capital Bit, space before kHz); the three present/absent
|
||||
/// branches; empty string when both are absent (no fabricated defaults).
|
||||
fn album_quality(bit: Option<u32>, rate: Option<f64>) -> String {
|
||||
match (bit, rate) {
|
||||
(Some(b), Some(r)) => format!("{b}-Bit / {} kHz", fmt_rate(r)),
|
||||
(Some(b), None) => format!("{b}-Bit"),
|
||||
(None, Some(r)) => format!("{} kHz", fmt_rate(r)),
|
||||
(None, None) => String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Localized "September 2, 2021" (full month). Empty when no/invalid date.
|
||||
fn full_release_date(raw: Option<&str>) -> String {
|
||||
let Some(raw) = raw else {
|
||||
return String::new();
|
||||
};
|
||||
let raw = raw.trim();
|
||||
if raw.is_empty() {
|
||||
return String::new();
|
||||
}
|
||||
let head = raw.get(0..10).unwrap_or(raw);
|
||||
if let Ok(parsed) = NaiveDate::parse_from_str(head, "%Y-%m-%d") {
|
||||
return parsed
|
||||
.format_localized("%B %-d, %Y", crate::dates::current_locale())
|
||||
.to_string();
|
||||
}
|
||||
String::new()
|
||||
}
|
||||
|
||||
/// ", Role1, Role2" suffix for an Album-Credits performer row (raw roles,
|
||||
/// 1:1 with Tauri which does NOT localize these), or "" when role-less.
|
||||
fn roles_suffix(roles: &[String]) -> String {
|
||||
if roles.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(", {}", roles.join(", "))
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Mapping (worker thread).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn map_track_info(track: Track) -> TrackInfoData {
|
||||
let title = format_title(&track.title, track.version.as_deref());
|
||||
|
||||
let (artist, artist_id) = match track.performer.as_ref() {
|
||||
Some(a) if a.id != 0 => (a.name.clone(), a.id.to_string()),
|
||||
Some(a) => (a.name.clone(), String::new()),
|
||||
None => (String::new(), String::new()),
|
||||
};
|
||||
|
||||
let album_title = track
|
||||
.album
|
||||
.as_ref()
|
||||
.map(|a| a.title.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
let (label, label_id) = match track.album.as_ref().and_then(|a| a.label.as_ref()) {
|
||||
Some(l) => (l.name.clone(), l.id.to_string()),
|
||||
None => (String::new(), String::new()),
|
||||
};
|
||||
|
||||
let credits = group_credits_ordered(&parse_performers(
|
||||
track.performers.as_deref().unwrap_or_default(),
|
||||
))
|
||||
.into_iter()
|
||||
.map(|(role, names)| CreditRowData {
|
||||
role: format_role_label(&role).to_uppercase(),
|
||||
role_raw: role,
|
||||
names,
|
||||
})
|
||||
.collect();
|
||||
|
||||
TrackInfoData {
|
||||
title,
|
||||
album: album_title,
|
||||
artist,
|
||||
artist_id,
|
||||
duration: track_duration(track.duration),
|
||||
quality: track_quality(
|
||||
track.maximum_bit_depth,
|
||||
track.maximum_sampling_rate,
|
||||
track.hires_streamable,
|
||||
),
|
||||
isrc: track.isrc.unwrap_or_default(),
|
||||
label,
|
||||
label_id,
|
||||
copyright: track.copyright.unwrap_or_default(),
|
||||
credits,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_album_credits(album: Album) -> AlbumCreditsData {
|
||||
let album_artist = album.artist.name.clone();
|
||||
|
||||
let (label, label_id) = match album.label.as_ref() {
|
||||
Some(l) => (l.name.clone(), l.id.to_string()),
|
||||
None => (String::new(), String::new()),
|
||||
};
|
||||
|
||||
let raw_tracks = album
|
||||
.tracks
|
||||
.as_ref()
|
||||
.map(|c| c.items.clone())
|
||||
.unwrap_or_default();
|
||||
|
||||
let track_count = album
|
||||
.tracks_count
|
||||
.or(album.track_count)
|
||||
.unwrap_or(raw_tracks.len() as u32);
|
||||
|
||||
// "Hard Rock · 10 tracks · 1h 21m" — gated on a genre, 1:1 with Tauri.
|
||||
let meta_line = match album.genre.as_ref().filter(|g| !g.name.is_empty()) {
|
||||
Some(g) => {
|
||||
// Tauri always appends formatAlbumDuration(album.duration || 0),
|
||||
// so an absent duration shows "· 0m" rather than dropping it.
|
||||
let parts = vec![
|
||||
g.name.clone(),
|
||||
format!("{track_count} tracks"),
|
||||
album_duration(album.duration.unwrap_or(0)),
|
||||
];
|
||||
parts.join(" · ")
|
||||
}
|
||||
None => String::new(),
|
||||
};
|
||||
|
||||
let tracks = raw_tracks
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(index, t)| {
|
||||
let performers: Vec<PerformerData> = parse_performers(
|
||||
t.performers.as_deref().unwrap_or_default(),
|
||||
)
|
||||
.into_iter()
|
||||
.map(|p| PerformerData {
|
||||
roles: roles_suffix(&p.roles),
|
||||
primary_role: p
|
||||
.roles
|
||||
.first()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| "Performer".to_string()),
|
||||
name: p.name,
|
||||
})
|
||||
.collect();
|
||||
let copyright = t.copyright.unwrap_or_default();
|
||||
let number = if t.track_number > 0 {
|
||||
t.track_number.to_string()
|
||||
} else {
|
||||
(index + 1).to_string()
|
||||
};
|
||||
let artist = t
|
||||
.performer
|
||||
.as_ref()
|
||||
.map(|a| a.name.clone())
|
||||
.filter(|n| !n.is_empty())
|
||||
.unwrap_or_else(|| {
|
||||
if album_artist.is_empty() {
|
||||
"Unknown Artist".to_string()
|
||||
} else {
|
||||
album_artist.clone()
|
||||
}
|
||||
});
|
||||
AlbumTrackData {
|
||||
id: t.id.to_string(),
|
||||
number,
|
||||
title: format_title(&t.title, t.version.as_deref()),
|
||||
artist,
|
||||
has_credits: !performers.is_empty() || !copyright.is_empty(),
|
||||
performers,
|
||||
copyright,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let review = album
|
||||
.description
|
||||
.as_deref()
|
||||
.map(crate::strip_html::strip_html)
|
||||
.unwrap_or_default();
|
||||
let has_review = !review.trim().is_empty();
|
||||
|
||||
AlbumCreditsData {
|
||||
title: album.title,
|
||||
artist: album_artist,
|
||||
label,
|
||||
label_id,
|
||||
release_date: full_release_date(album.release_date_original.as_deref()),
|
||||
meta_line,
|
||||
quality: album_quality(album.maximum_bit_depth, album.maximum_sampling_rate),
|
||||
review,
|
||||
has_review,
|
||||
tracks,
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Apply (Slint event loop).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
fn apply_track_info(window: &AppWindow, data: TrackInfoData) {
|
||||
let st = window.global::<TrackInfoState>();
|
||||
// Build the ordered cells, then pair them into 2-column rows so the modal
|
||||
// needs no dynamic grid placement.
|
||||
let cells: Vec<InfoCreditRow> = data
|
||||
.credits
|
||||
.into_iter()
|
||||
.map(|c| {
|
||||
let names: Vec<SharedString> = c.names.into_iter().map(SharedString::from).collect();
|
||||
InfoCreditRow {
|
||||
role: c.role.into(),
|
||||
role_raw: c.role_raw.into(),
|
||||
names: ModelRc::new(VecModel::from(names)),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let mut pairs: Vec<InfoCreditPair> = Vec::new();
|
||||
let mut iter = cells.into_iter();
|
||||
while let Some(left) = iter.next() {
|
||||
match iter.next() {
|
||||
Some(right) => pairs.push(InfoCreditPair {
|
||||
left,
|
||||
right,
|
||||
has_right: true,
|
||||
}),
|
||||
None => pairs.push(InfoCreditPair {
|
||||
left,
|
||||
right: InfoCreditRow {
|
||||
role: SharedString::new(),
|
||||
role_raw: SharedString::new(),
|
||||
names: ModelRc::new(VecModel::from(Vec::<SharedString>::new())),
|
||||
},
|
||||
has_right: false,
|
||||
}),
|
||||
}
|
||||
}
|
||||
st.set_title(data.title.into());
|
||||
st.set_album(data.album.into());
|
||||
st.set_artist(data.artist.into());
|
||||
st.set_artist_id(data.artist_id.into());
|
||||
st.set_duration(data.duration.into());
|
||||
st.set_quality(data.quality.into());
|
||||
st.set_isrc(data.isrc.into());
|
||||
st.set_label(data.label.into());
|
||||
st.set_label_id(data.label_id.into());
|
||||
st.set_copyright(data.copyright.into());
|
||||
st.set_credits(ModelRc::new(VecModel::from(pairs)));
|
||||
}
|
||||
|
||||
fn apply_album_credits(window: &AppWindow, data: AlbumCreditsData) {
|
||||
let st = window.global::<AlbumInfoState>();
|
||||
let tracks: Vec<AlbumCreditTrack> = data
|
||||
.tracks
|
||||
.into_iter()
|
||||
.map(|t| {
|
||||
let perfs: Vec<AlbumCreditPerformer> = t
|
||||
.performers
|
||||
.into_iter()
|
||||
.map(|p| AlbumCreditPerformer {
|
||||
name: p.name.into(),
|
||||
roles: p.roles.into(),
|
||||
primary_role: p.primary_role.into(),
|
||||
})
|
||||
.collect();
|
||||
AlbumCreditTrack {
|
||||
id: t.id.into(),
|
||||
number: t.number.into(),
|
||||
title: t.title.into(),
|
||||
artist: t.artist.into(),
|
||||
has_credits: t.has_credits,
|
||||
performers: ModelRc::new(VecModel::from(perfs)),
|
||||
copyright: t.copyright.into(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
// The modal opens from the album header, so the cover already lives in
|
||||
// AlbumState — reuse it instead of re-fetching the artwork.
|
||||
st.set_artwork(window.global::<AlbumState>().get_artwork());
|
||||
st.set_title(data.title.into());
|
||||
st.set_artist(data.artist.into());
|
||||
st.set_label(data.label.into());
|
||||
st.set_label_id(data.label_id.into());
|
||||
st.set_release_date(data.release_date.into());
|
||||
st.set_meta_line(data.meta_line.into());
|
||||
st.set_quality(data.quality.into());
|
||||
st.set_review(data.review.into());
|
||||
st.set_has_review(data.has_review);
|
||||
st.set_active_tab("credits".into());
|
||||
st.set_tracks(ModelRc::new(VecModel::from(tracks)));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Public spawn entry points (called from the media-action handler).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Fetch a track and open the Track Info modal.
|
||||
pub fn open_track_info<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
track_id: u64,
|
||||
) where
|
||||
A: FrontendAdapter + Send + Sync + 'static,
|
||||
{
|
||||
let _ = weak.upgrade_in_event_loop(|w| {
|
||||
let st = w.global::<TrackInfoState>();
|
||||
st.set_error("".into());
|
||||
st.set_loading(true);
|
||||
st.set_open(true);
|
||||
});
|
||||
handle.spawn(async move {
|
||||
match runtime.core().get_track(track_id).await {
|
||||
Ok(track) => {
|
||||
let data = map_track_info(track);
|
||||
let _ = weak.upgrade_in_event_loop(move |w| {
|
||||
apply_track_info(&w, data);
|
||||
w.global::<TrackInfoState>().set_loading(false);
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] track-info load failed: {e}");
|
||||
let msg = e.to_string();
|
||||
let _ = weak.upgrade_in_event_loop(move |w| {
|
||||
let st = w.global::<TrackInfoState>();
|
||||
st.set_error(msg.into());
|
||||
st.set_loading(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Fetch an album and open the Album Info (Credits/Review) modal.
|
||||
pub fn open_album_credits<A>(
|
||||
runtime: Arc<AppRuntime<A>>,
|
||||
weak: slint::Weak<AppWindow>,
|
||||
handle: tokio::runtime::Handle,
|
||||
album_id: String,
|
||||
) where
|
||||
A: FrontendAdapter + Send + Sync + 'static,
|
||||
{
|
||||
let _ = weak.upgrade_in_event_loop(|w| {
|
||||
let st = w.global::<AlbumInfoState>();
|
||||
st.set_error("".into());
|
||||
st.set_active_tab("credits".into());
|
||||
st.set_loading(true);
|
||||
st.set_open(true);
|
||||
});
|
||||
handle.spawn(async move {
|
||||
match runtime.core().get_album(&album_id).await {
|
||||
Ok(album) => {
|
||||
let data = map_album_credits(album);
|
||||
let _ = weak.upgrade_in_event_loop(move |w| {
|
||||
apply_album_credits(&w, data);
|
||||
w.global::<AlbumInfoState>().set_loading(false);
|
||||
});
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-slint] album-info load failed: {e}");
|
||||
let msg = e.to_string();
|
||||
let _ = weak.upgrade_in_event_loop(move |w| {
|
||||
let st = w.global::<AlbumInfoState>();
|
||||
st.set_error(msg.into());
|
||||
st.set_loading(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -31,6 +31,7 @@ mod favorites_prefs;
|
||||
mod foryou;
|
||||
mod genre_filter;
|
||||
mod home;
|
||||
mod info_modals;
|
||||
mod label;
|
||||
mod location_view;
|
||||
mod mix;
|
||||
@@ -4929,6 +4930,31 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
crate::ui_prefs::save(&prefs);
|
||||
}
|
||||
}
|
||||
// Track Info modal — opened from the NPB (i) button, the
|
||||
// song-card title, or a TrackRow context menu. Qobuz tracks
|
||||
// only (the id must be a real catalog u64).
|
||||
("track", "track-info") => {
|
||||
if let Ok(track_id) = id.parse::<u64>() {
|
||||
info_modals::open_track_info(
|
||||
runtime.clone(),
|
||||
weak.clone(),
|
||||
handle.clone(),
|
||||
track_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
// Album Info (Credits/Review) modal — opened from the album
|
||||
// header (i) button. Qobuz albums only (skip local/Plex keys).
|
||||
("album", "info") => {
|
||||
if !is_local_album_key(&id) {
|
||||
info_modals::open_album_credits(
|
||||
runtime.clone(),
|
||||
weak.clone(),
|
||||
handle.clone(),
|
||||
id,
|
||||
);
|
||||
}
|
||||
}
|
||||
("album", "play") => {
|
||||
// A Plex/local id is a metadata group key, not a Qobuz id —
|
||||
// play it from the local/Plex cache (Home "Recently played",
|
||||
@@ -7153,6 +7179,132 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
});
|
||||
}
|
||||
|
||||
// Track Info + Album Info modal actions (close / tab / navigation / play).
|
||||
// Navigation reuses the same handlers the rest of the app uses (open-artist
|
||||
// callback, network-sidebar musician resolve, navigate_label).
|
||||
{
|
||||
let runtime = app_runtime.clone();
|
||||
// -- Track Info --
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<TrackInfoActions>()
|
||||
.on_close(move || {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<TrackInfoState>().set_open(false);
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<TrackInfoActions>()
|
||||
.on_open_artist(move |artist_id| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<TrackInfoState>().set_open(false);
|
||||
w.invoke_open_artist(artist_id);
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
let runtime_l = runtime.clone();
|
||||
let handle_l = tokio_rt.handle().clone();
|
||||
let image_cache_l = image_cache.clone();
|
||||
window
|
||||
.global::<TrackInfoActions>()
|
||||
.on_open_label(move |label_id| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
let name = w.global::<TrackInfoState>().get_label().to_string();
|
||||
w.global::<TrackInfoState>().set_open(false);
|
||||
if let Ok(id) = label_id.parse::<u64>() {
|
||||
navigate_label(
|
||||
runtime_l.clone(),
|
||||
w.as_weak(),
|
||||
&handle_l,
|
||||
image_cache_l.clone(),
|
||||
id,
|
||||
name,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<TrackInfoActions>()
|
||||
.on_open_musician(move |name, role| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<TrackInfoState>().set_open(false);
|
||||
w.global::<NetworkSidebarActions>()
|
||||
.invoke_musician_clicked(name, role);
|
||||
}
|
||||
});
|
||||
|
||||
// -- Album Info --
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<AlbumInfoActions>()
|
||||
.on_close(move || {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<AlbumInfoState>().set_open(false);
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<AlbumInfoActions>()
|
||||
.on_set_tab(move |tab| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<AlbumInfoState>().set_active_tab(tab);
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
let runtime_p = runtime.clone();
|
||||
let handle_p = tokio_rt.handle().clone();
|
||||
window
|
||||
.global::<AlbumInfoActions>()
|
||||
.on_play_track(move |id| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
// Album view is the modal's context, so this plays the
|
||||
// album starting at the chosen track (Tauri keeps the
|
||||
// modal open on play).
|
||||
playback::play_track_in_context(
|
||||
&w,
|
||||
runtime_p.clone(),
|
||||
w.as_weak(),
|
||||
handle_p.clone(),
|
||||
&id,
|
||||
);
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
let runtime_a = runtime.clone();
|
||||
let handle_a = tokio_rt.handle().clone();
|
||||
let image_cache_a = image_cache.clone();
|
||||
window
|
||||
.global::<AlbumInfoActions>()
|
||||
.on_open_label(move |label_id| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
let name = w.global::<AlbumInfoState>().get_label().to_string();
|
||||
w.global::<AlbumInfoState>().set_open(false);
|
||||
if let Ok(id) = label_id.parse::<u64>() {
|
||||
navigate_label(
|
||||
runtime_a.clone(),
|
||||
w.as_weak(),
|
||||
&handle_a,
|
||||
image_cache_a.clone(),
|
||||
id,
|
||||
name,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
let weak = window.as_weak();
|
||||
window
|
||||
.global::<AlbumInfoActions>()
|
||||
.on_open_musician(move |name, role| {
|
||||
if let Some(w) = weak.upgrade() {
|
||||
w.global::<AlbumInfoState>().set_open(false);
|
||||
w.global::<NetworkSidebarActions>()
|
||||
.invoke_musician_clicked(name, role);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Musician appearances pagination — Load more in
|
||||
// MusicianPageView appends the next 20 albums onto the existing
|
||||
// grid.
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
// Album Info (Credits / Review) modal — 1:1 port of Tauri's
|
||||
// AlbumCreditsModal.svelte. Opened from the AlbumPageView header (i) button via
|
||||
// media-action("album", id, "info"). The Rust controller (crate::info_modals)
|
||||
// fetches the album, parses per-track performers, and populates AlbumInfoState.
|
||||
// Rectangle-scrim + centered fixed-height card, mounted in AppShell after the
|
||||
// other modals (ADR-009/010). Left column = album info (fixed). Right column =
|
||||
// Credits (expandable track list) / Review (editorial text), independent scroll.
|
||||
|
||||
import { Theme } from "../foundation/semantic-colors.slint";
|
||||
import { Typography } from "../foundation/typography.slint";
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { AlbumInfoState, AlbumInfoActions, AlbumCreditTrack } from "../state.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
||||
|
||||
// One track row in the Credits tab: number / play-on-hover, title + artist,
|
||||
// expand chevron; an expanded panel with per-performer credit lines + the
|
||||
// copyright. Local `expanded` persists while the modal stays open.
|
||||
component AlbumTrackRow inherits VerticalLayout {
|
||||
in property <AlbumCreditTrack> track;
|
||||
in property <bool> is-last;
|
||||
callback play(string /* track-id */);
|
||||
callback musician(string /* name */, string /* primary-role */);
|
||||
property <bool> expanded: false;
|
||||
|
||||
// ---- Header row -------------------------------------------------------
|
||||
Rectangle {
|
||||
height: 46px;
|
||||
// Declared FIRST so the per-cell play TouchArea sits on top (footgun:
|
||||
// a later full-row TouchArea would eat the cell clicks).
|
||||
rowha := TouchArea {
|
||||
mouse-cursor: root.track.has-credits ? pointer : default;
|
||||
clicked => {
|
||||
if (root.track.has-credits) {
|
||||
root.expanded = !root.expanded;
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 12px;
|
||||
// Whole-row hover dim, 1:1 with Tauri .track-header:hover.
|
||||
opacity: (rowha.has-hover && root.track.has-credits) ? 0.8 : 1.0;
|
||||
// Number / play-on-hover cell.
|
||||
Rectangle {
|
||||
width: 28px;
|
||||
if !(rowha.has-hover || pcell.has-hover): Text {
|
||||
text: root.track.number;
|
||||
color: Theme.text-muted;
|
||||
font-size: 14px;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
pcell := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.play(root.track.id);
|
||||
}
|
||||
if rowha.has-hover || pcell.has-hover: Rectangle {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 14px;
|
||||
background: Theme.accent;
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/play-fill.svg");
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
tint: Theme.accent-text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Title + artist.
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
alignment: center;
|
||||
spacing: 2px;
|
||||
Text {
|
||||
text: root.track.title;
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
font-weight: Typography.medium;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: root.track.artist;
|
||||
color: Theme.text-muted;
|
||||
font-size: 12px;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
// Expand chevron (only when there are credits).
|
||||
if root.track.has-credits: VerticalLayout {
|
||||
alignment: center;
|
||||
QbzIcon {
|
||||
source: root.expanded
|
||||
? @image-url("../assets/icons/chevron-up.svg")
|
||||
: @image-url("../assets/icons/chevron-down.svg");
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
tint: root.expanded ? Theme.text-primary : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Expanded credits -------------------------------------------------
|
||||
if root.expanded && root.track.has-credits: VerticalLayout {
|
||||
padding-left: 40px;
|
||||
padding-bottom: 12px;
|
||||
spacing: 0px;
|
||||
for perf in root.track.performers: HorizontalLayout {
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
alignment: start;
|
||||
pta := TouchArea {
|
||||
width: pname.preferred-width;
|
||||
height: pname.preferred-height;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.musician(perf.name, perf.primary-role);
|
||||
}
|
||||
pname := Text {
|
||||
text: perf.name;
|
||||
color: pta.has-hover ? Theme.accent : Theme.text-primary;
|
||||
font-size: 13px;
|
||||
font-weight: Typography.medium;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: perf.roles;
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
if root.track.copyright != "": Rectangle { height: 8px; }
|
||||
if root.track.copyright != "": Rectangle {
|
||||
height: 1px;
|
||||
background: Theme.border-subtle;
|
||||
}
|
||||
if root.track.copyright != "": Rectangle { height: 8px; }
|
||||
if root.track.copyright != "": Text {
|
||||
text: root.track.copyright;
|
||||
color: Theme.text-muted;
|
||||
font-size: 12px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Divider ----------------------------------------------------------
|
||||
if !root.is-last: Rectangle {
|
||||
height: 1px;
|
||||
background: Theme.border-subtle;
|
||||
}
|
||||
}
|
||||
|
||||
export component AlbumCreditsModal inherits Rectangle {
|
||||
visible: AlbumInfoState.open;
|
||||
|
||||
if AlbumInfoState.open: Rectangle {
|
||||
background: #000000bf;
|
||||
|
||||
TouchArea {
|
||||
mouse-cursor: default;
|
||||
clicked => {
|
||||
AlbumInfoActions.close();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 40px, 850px);
|
||||
// Content-sized with a decent cap: as tall as the header + the
|
||||
// taller of the two columns (left meta vs tabs + the full credit
|
||||
// list), but never beyond the content area (40px margin each side).
|
||||
// When the list exceeds the cap, the right column's Flickable
|
||||
// scrolls. All inputs are width-driven (card width is fixed by
|
||||
// root.width) so the height binding is acyclic. The +42px is the
|
||||
// tab strip when a review exists.
|
||||
height: Math.min(
|
||||
root.height - 80px,
|
||||
hdr.preferred-height
|
||||
+ Math.max(
|
||||
leftcol.preferred-height,
|
||||
(AlbumInfoState.has-review ? 42px : 0px) + content.preferred-height)
|
||||
+ 24px);
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
border-radius: Radius.md;
|
||||
background: Theme.surface-card;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border-subtle;
|
||||
drop-shadow-blur: 32px;
|
||||
drop-shadow-color: Theme.card-shadow;
|
||||
|
||||
TouchArea { }
|
||||
|
||||
fs := FocusScope {
|
||||
Timer {
|
||||
interval: 30ms;
|
||||
running: true;
|
||||
triggered => {
|
||||
self.running = false;
|
||||
fs.focus();
|
||||
}
|
||||
}
|
||||
key-pressed(event) => {
|
||||
if (event.text == Key.Escape) {
|
||||
AlbumInfoActions.close();
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
// ---- Header -------------------------------------------
|
||||
hdr := HorizontalLayout {
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
spacing: 16px;
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
spacing: 4px;
|
||||
Text {
|
||||
text: AlbumInfoState.title;
|
||||
color: Theme.text-primary;
|
||||
font-size: 16px;
|
||||
font-weight: Typography.semibold;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: AlbumInfoState.artist;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
close-x := TouchArea {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
AlbumInfoActions.close();
|
||||
}
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/x.svg");
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
x: (parent.width - self.width) / 2;
|
||||
y: (parent.height - self.height) / 2;
|
||||
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Body (two columns) — always rendered so the card
|
||||
// height can read the real content height (loading/error
|
||||
// are overlays below, since Slint can't reference elements
|
||||
// nested in an `if` from the height binding).
|
||||
HorizontalLayout {
|
||||
vertical-stretch: 1;
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
padding-bottom: 24px;
|
||||
spacing: 24px;
|
||||
|
||||
// LEFT — album info (fixed width). alignment:start so
|
||||
// the meta stacks tightly under the cover instead of
|
||||
// the layout distributing the tall body's slack between
|
||||
// the rows.
|
||||
leftcol := VerticalLayout {
|
||||
width: 260px;
|
||||
spacing: 0px;
|
||||
alignment: start;
|
||||
Rectangle {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border-radius: 8px;
|
||||
clip: true;
|
||||
Image {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
source: AlbumInfoState.artwork;
|
||||
image-fit: cover;
|
||||
}
|
||||
}
|
||||
Rectangle { height: 16px; }
|
||||
// Released by <label> on <date>.
|
||||
if AlbumInfoState.label != "": VerticalLayout {
|
||||
spacing: 0px;
|
||||
Text {
|
||||
text: @tr("Released by");
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
lbl := TouchArea {
|
||||
width: lbltext.preferred-width;
|
||||
height: lbltext.preferred-height;
|
||||
mouse-cursor: AlbumInfoState.label-id != "" ? pointer : default;
|
||||
clicked => {
|
||||
if (AlbumInfoState.label-id != "") {
|
||||
AlbumInfoActions.open-label(AlbumInfoState.label-id);
|
||||
}
|
||||
}
|
||||
lbltext := Text {
|
||||
text: AlbumInfoState.label;
|
||||
color: (lbl.has-hover && AlbumInfoState.label-id != "")
|
||||
? Theme.accent : Theme.text-primary;
|
||||
font-size: 13px;
|
||||
font-weight: Typography.semibold;
|
||||
}
|
||||
}
|
||||
if AlbumInfoState.release-date != "": Text {
|
||||
text: @tr("on") + " " + AlbumInfoState.release-date;
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
if AlbumInfoState.label != "": Rectangle { height: 8px; }
|
||||
if AlbumInfoState.meta-line != "": Text {
|
||||
text: AlbumInfoState.meta-line;
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
if AlbumInfoState.quality != "": Rectangle { height: 12px; }
|
||||
if AlbumInfoState.quality != "": Text {
|
||||
text: AlbumInfoState.quality;
|
||||
color: Theme.text-secondary;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
// RIGHT — tabs + scrollable content.
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
spacing: 0px;
|
||||
|
||||
// Tab switcher (only when a review exists).
|
||||
if AlbumInfoState.has-review: VerticalLayout {
|
||||
spacing: 0px;
|
||||
HorizontalLayout {
|
||||
spacing: 16px;
|
||||
alignment: start;
|
||||
credits-tab := TouchArea {
|
||||
width: ct.preferred-width;
|
||||
height: ct.preferred-height;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
AlbumInfoActions.set-tab("credits");
|
||||
}
|
||||
ct := Text {
|
||||
text: @tr("Credits");
|
||||
color: AlbumInfoState.active-tab == "credits"
|
||||
? Theme.accent : Theme.text-muted;
|
||||
font-size: 13px;
|
||||
font-weight: Typography.medium;
|
||||
}
|
||||
}
|
||||
review-tab := TouchArea {
|
||||
width: rt.preferred-width;
|
||||
height: rt.preferred-height;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
AlbumInfoActions.set-tab("review");
|
||||
}
|
||||
rt := Text {
|
||||
text: @tr("Review");
|
||||
color: AlbumInfoState.active-tab == "review"
|
||||
? Theme.accent : Theme.text-muted;
|
||||
font-size: 13px;
|
||||
font-weight: Typography.medium;
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { height: 12px; }
|
||||
Rectangle {
|
||||
height: 1px;
|
||||
background: Theme.border-subtle;
|
||||
}
|
||||
Rectangle { height: 12px; }
|
||||
}
|
||||
|
||||
// Content (scrollable) + overlaid scrollbar.
|
||||
Rectangle {
|
||||
vertical-stretch: 1;
|
||||
rflick := Flickable {
|
||||
viewport-width: self.width;
|
||||
viewport-height: content.preferred-height;
|
||||
|
||||
content := VerticalLayout {
|
||||
width: parent.width;
|
||||
spacing: 0px;
|
||||
// Reserve the scrollbar gutter so rows
|
||||
// (and the expand chevron at the row's
|
||||
// right edge) never sit under the 14px
|
||||
// ListScrollbar.
|
||||
padding-right: 18px;
|
||||
|
||||
// Credits tab.
|
||||
if AlbumInfoState.active-tab == "credits": VerticalLayout {
|
||||
spacing: 0px;
|
||||
for t[i] in AlbumInfoState.tracks: AlbumTrackRow {
|
||||
track: t;
|
||||
is-last: i == AlbumInfoState.tracks.length - 1;
|
||||
play(id) => {
|
||||
AlbumInfoActions.play-track(id);
|
||||
}
|
||||
musician(n, r) => {
|
||||
AlbumInfoActions.open-musician(n, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Review tab.
|
||||
if AlbumInfoState.active-tab == "review": Text {
|
||||
text: AlbumInfoState.review;
|
||||
color: Theme.text-secondary;
|
||||
font-size: 14px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListScrollbar {
|
||||
x: parent.width - self.width;
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
viewport-height: rflick.viewport-height;
|
||||
visible-height: rflick.height;
|
||||
viewport-y <=> rflick.viewport-y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Loading / error overlay -------------------------------
|
||||
// Covers the (empty) skeleton while fetching or on error.
|
||||
if AlbumInfoState.loading || AlbumInfoState.error != "": Rectangle {
|
||||
background: Theme.surface-card;
|
||||
border-radius: Radius.md;
|
||||
// Swallow clicks so the skeleton behind isn't reachable.
|
||||
TouchArea { }
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: AlbumInfoState.error != ""
|
||||
? @tr("Failed to load album credits")
|
||||
: @tr("Loading credits...");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.body;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
if AlbumInfoState.error != "": Text {
|
||||
text: AlbumInfoState.error;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,11 +445,17 @@ export component AlbumPageView inherits Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Album info (i) — icon only for now; the detail panel
|
||||
// logic lands later.
|
||||
VerticalLayout {
|
||||
// Album info (i) — opens the Album Info (Credits/Review)
|
||||
// modal. Qobuz albums only (local albums have no Qobuz
|
||||
// credits/review), 1:1 with Tauri's album-credits button.
|
||||
if !AlbumState.is-local: VerticalLayout {
|
||||
alignment: center;
|
||||
CircleAction { icon: @image-url("../assets/icons/info.svg"); }
|
||||
CircleAction {
|
||||
icon: @image-url("../assets/icons/info.svg");
|
||||
clicked => {
|
||||
root.media-action("album", AlbumState.id, "info");
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
// Track Info modal — 1:1 port of Tauri's TrackInfoModal.svelte. Opened from
|
||||
// the NPB (i) button / song-card title / TrackRow context menu via
|
||||
// media-action("track", id, "track-info"). The Rust controller
|
||||
// (crate::info_modals) fetches the track, parses + groups + localizes the
|
||||
// credits, and populates TrackInfoState. Rectangle-scrim + centered card
|
||||
// (no PopupWindow), mounted in AppShell after the other modals (ADR-009/010).
|
||||
|
||||
import { Theme } from "../foundation/semantic-colors.slint";
|
||||
import { Typography } from "../foundation/typography.slint";
|
||||
import { Radius } from "../foundation/radius.slint";
|
||||
import { TrackInfoState, TrackInfoActions, InfoCreditRow } from "../state.slint";
|
||||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||||
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
|
||||
|
||||
// One metadata cell: uppercase label (11px) + a value supplied as a child.
|
||||
component MetaCell inherits VerticalLayout {
|
||||
in property <string> label;
|
||||
spacing: 6px;
|
||||
Text {
|
||||
text: root.label;
|
||||
color: Theme.text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: Typography.semibold;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
@children
|
||||
}
|
||||
|
||||
// One credit cell: role label (11px upper) + the performer names, each
|
||||
// clickable -> musician. Clipped so a long name list can't bleed into the
|
||||
// neighbouring column (the common 1-3 name case fits one line).
|
||||
component CreditCell inherits VerticalLayout {
|
||||
in property <InfoCreditRow> cell;
|
||||
callback name-clicked(string /* name */, string /* role-raw */);
|
||||
spacing: 6px;
|
||||
Text {
|
||||
text: root.cell.role;
|
||||
color: Theme.text-muted;
|
||||
font-size: 11px;
|
||||
font-weight: Typography.semibold;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
Rectangle {
|
||||
clip: true;
|
||||
height: names-row.preferred-height;
|
||||
names-row := HorizontalLayout {
|
||||
alignment: start;
|
||||
for name[j] in root.cell.names: HorizontalLayout {
|
||||
nta := TouchArea {
|
||||
width: nm.preferred-width;
|
||||
height: nm.preferred-height;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.name-clicked(name, root.cell.role-raw);
|
||||
}
|
||||
nm := Text {
|
||||
text: name;
|
||||
color: nta.has-hover ? Theme.accent : Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
if j < root.cell.names.length - 1: Text {
|
||||
text: ", ";
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component TrackInfoModal inherits Rectangle {
|
||||
visible: TrackInfoState.open;
|
||||
|
||||
if TrackInfoState.open: Rectangle {
|
||||
background: #000000bf;
|
||||
|
||||
// Scrim — click outside dismisses.
|
||||
TouchArea {
|
||||
mouse-cursor: default;
|
||||
clicked => {
|
||||
TrackInfoActions.close();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 40px, 728px);
|
||||
height: Math.min(root.height * 0.8, card-body.preferred-height);
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
border-radius: Radius.md;
|
||||
background: Theme.surface-card;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border-subtle;
|
||||
drop-shadow-blur: 32px;
|
||||
drop-shadow-color: Theme.card-shadow;
|
||||
|
||||
// Swallow clicks so they don't reach the scrim.
|
||||
TouchArea { }
|
||||
|
||||
fs := FocusScope {
|
||||
// Focus a tick after mount (synchronous focus races layout).
|
||||
Timer {
|
||||
interval: 30ms;
|
||||
running: true;
|
||||
triggered => {
|
||||
self.running = false;
|
||||
fs.focus();
|
||||
}
|
||||
}
|
||||
key-pressed(event) => {
|
||||
if (event.text == Key.Escape) {
|
||||
TrackInfoActions.close();
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
|
||||
flick := Flickable {
|
||||
viewport-width: self.width;
|
||||
viewport-height: card-body.preferred-height;
|
||||
|
||||
card-body := VerticalLayout {
|
||||
width: parent.width;
|
||||
|
||||
// ---- Loading --------------------------------
|
||||
if TrackInfoState.loading && TrackInfoState.error == "": VerticalLayout {
|
||||
alignment: center;
|
||||
padding: 60px;
|
||||
Text {
|
||||
text: @tr("Loading track info...");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.body;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Error ----------------------------------
|
||||
if TrackInfoState.error != "": VerticalLayout {
|
||||
alignment: center;
|
||||
padding: 60px;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: @tr("Failed to load track info");
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.body;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Text {
|
||||
text: TrackInfoState.error;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
horizontal-alignment: center;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Loaded ---------------------------------
|
||||
if !TrackInfoState.loading && TrackInfoState.error == "": VerticalLayout {
|
||||
// Header
|
||||
HorizontalLayout {
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
spacing: 16px;
|
||||
VerticalLayout {
|
||||
horizontal-stretch: 1;
|
||||
spacing: 4px;
|
||||
Text {
|
||||
text: TrackInfoState.title;
|
||||
color: Theme.text-primary;
|
||||
font-size: 16px;
|
||||
font-weight: Typography.semibold;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
if TrackInfoState.album != "": Text {
|
||||
text: TrackInfoState.album;
|
||||
color: Theme.text-muted;
|
||||
font-size: Typography.legal;
|
||||
}
|
||||
if TrackInfoState.artist != "": HorizontalLayout {
|
||||
alignment: start;
|
||||
artist-link := TouchArea {
|
||||
width: artist-text.preferred-width;
|
||||
height: artist-text.preferred-height;
|
||||
mouse-cursor: TrackInfoState.artist-id != "" ? pointer : default;
|
||||
clicked => {
|
||||
if (TrackInfoState.artist-id != "") {
|
||||
TrackInfoActions.open-artist(TrackInfoState.artist-id);
|
||||
}
|
||||
}
|
||||
artist-text := Text {
|
||||
text: TrackInfoState.artist;
|
||||
color: TrackInfoState.artist-id != ""
|
||||
? Theme.accent : Theme.text-primary;
|
||||
font-size: 16px;
|
||||
font-weight: Typography.semibold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Close X
|
||||
close-x := TouchArea {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
TrackInfoActions.close();
|
||||
}
|
||||
QbzIcon {
|
||||
source: @image-url("../assets/icons/x.svg");
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||||
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Content
|
||||
VerticalLayout {
|
||||
padding-left: 24px;
|
||||
padding-right: 24px;
|
||||
padding-bottom: 24px;
|
||||
spacing: 0px;
|
||||
|
||||
// Metadata: fixed 3-column rows.
|
||||
VerticalLayout {
|
||||
spacing: 24px;
|
||||
HorizontalLayout {
|
||||
spacing: 24px;
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Duration");
|
||||
Text {
|
||||
text: TrackInfoState.duration;
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Quality");
|
||||
Text {
|
||||
text: TrackInfoState.quality;
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
if TrackInfoState.isrc != "": MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: "ISRC";
|
||||
Text {
|
||||
text: TrackInfoState.isrc;
|
||||
color: Theme.text-muted;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
if TrackInfoState.isrc == "": Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if TrackInfoState.label != "": HorizontalLayout {
|
||||
spacing: 24px;
|
||||
MetaCell {
|
||||
horizontal-stretch: 1;
|
||||
label: @tr("Label");
|
||||
label-link := TouchArea {
|
||||
width: label-text.preferred-width;
|
||||
height: label-text.preferred-height;
|
||||
mouse-cursor: TrackInfoState.label-id != "" ? pointer : default;
|
||||
clicked => {
|
||||
if (TrackInfoState.label-id != "") {
|
||||
TrackInfoActions.open-label(TrackInfoState.label-id);
|
||||
}
|
||||
}
|
||||
label-text := Text {
|
||||
text: TrackInfoState.label;
|
||||
color: (label-link.has-hover && TrackInfoState.label-id != "")
|
||||
? Theme.accent : Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
// Credits (2 columns), only when present.
|
||||
if TrackInfoState.credits.length > 0: Rectangle { height: 20px; }
|
||||
if TrackInfoState.credits.length > 0: Rectangle {
|
||||
height: 1px;
|
||||
background: Theme.surface-elevated;
|
||||
}
|
||||
if TrackInfoState.credits.length > 0: Rectangle { height: 20px; }
|
||||
if TrackInfoState.credits.length > 0: VerticalLayout {
|
||||
spacing: 16px;
|
||||
for pair in TrackInfoState.credits: HorizontalLayout {
|
||||
spacing: 24px;
|
||||
CreditCell {
|
||||
horizontal-stretch: 1;
|
||||
cell: pair.left;
|
||||
name-clicked(n, r) => {
|
||||
TrackInfoActions.open-musician(n, r);
|
||||
}
|
||||
}
|
||||
if pair.has-right: CreditCell {
|
||||
horizontal-stretch: 1;
|
||||
cell: pair.right;
|
||||
name-clicked(n, r) => {
|
||||
TrackInfoActions.open-musician(n, r);
|
||||
}
|
||||
}
|
||||
if !pair.has-right: Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
// Copyright.
|
||||
if TrackInfoState.copyright != "": Rectangle { height: 20px; }
|
||||
if TrackInfoState.copyright != "": Rectangle {
|
||||
height: 1px;
|
||||
background: Theme.surface-elevated;
|
||||
}
|
||||
if TrackInfoState.copyright != "": Rectangle { height: 20px; }
|
||||
if TrackInfoState.copyright != "": Text {
|
||||
text: TrackInfoState.copyright;
|
||||
color: Theme.text-muted;
|
||||
font-size: 12px;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListScrollbar {
|
||||
x: parent.width - self.width - 4px;
|
||||
width: 14px;
|
||||
height: 100%;
|
||||
viewport-height: flick.viewport-height;
|
||||
visible-height: flick.height;
|
||||
viewport-y <=> flick.viewport-y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import { Toast } from "primitives/Toast.slint";
|
||||
import { ShellState } from "state.slint";
|
||||
|
||||
// Re-export the state globals so the Rust layer can populate them.
|
||||
export { HomeState, HomeActions, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions } from "state.slint";
|
||||
export { HomeState, HomeActions, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions } from "state.slint";
|
||||
|
||||
// Which top-level screen is shown. The app starts on `splash` while it
|
||||
// restores a saved session, then resolves to `shell` or `login`.
|
||||
|
||||
@@ -31,6 +31,8 @@ import { FolderEditModal } from "../primitives/FolderEditModal.slint";
|
||||
import { LibFolderEditModal } from "../settings/LibFolderEditModal.slint";
|
||||
import { TagEditorModal } from "../primitives/TagEditorModal.slint";
|
||||
import { PlaylistImportModal } from "../primitives/PlaylistImportModal.slint";
|
||||
import { TrackInfoModal } from "../album/TrackInfoModal.slint";
|
||||
import { AlbumCreditsModal } from "../album/AlbumCreditsModal.slint";
|
||||
import { QconnectDevModal } from "QconnectDevModal.slint";
|
||||
import { DragGhost } from "../primitives/DragGhost.slint";
|
||||
import { Toast } from "../primitives/Toast.slint";
|
||||
@@ -486,6 +488,18 @@ export component AppShell inherits Rectangle {
|
||||
// `open`), keeping QconnectDevModal topmost.
|
||||
PlaylistImportModal { }
|
||||
|
||||
// Track Info + Album Info (Credits/Review) modals — fed by crate::info_modals
|
||||
// through TrackInfoState / AlbumInfoState. Conditional-mount on their own
|
||||
// `open`; stacked above the feature modals (ADR-009/010).
|
||||
TrackInfoModal {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
AlbumCreditsModal {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
// Qobuz Connect DEV diagnostics modal (opened from the connect flyout).
|
||||
QconnectDevModal {
|
||||
width: 100%;
|
||||
|
||||
@@ -341,6 +341,115 @@ export global AlbumState {
|
||||
in property <string> source;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Track Info + Album Info (Credits/Review) modals — 1:1 port of Tauri's
|
||||
// TrackInfoModal.svelte + AlbumCreditsModal.svelte. Data is fetched fresh by
|
||||
// the Rust controller (crate::info_modals) via core.get_track/get_album and
|
||||
// mapped to these plain structs. Roles are parsed + grouped + localized in
|
||||
// qbz_qobuz::performers (frontend-agnostic).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// One grouped-by-role credit cell in the Track Info grid. `role` is the
|
||||
// already-localized, UPPER-CASED label; each name is clickable -> musician.
|
||||
export struct InfoCreditRow {
|
||||
role: string,
|
||||
// Original (non-localized) role string, passed to the musician-nav hint.
|
||||
role-raw: string,
|
||||
names: [string],
|
||||
}
|
||||
|
||||
// A row in the Track Info 2-column credits grid. The Rust side pairs the
|
||||
// ordered cells (left + optional right) so the modal needs no dynamic grid
|
||||
// placement. `has-right` is false on a trailing odd cell.
|
||||
export struct InfoCreditPair {
|
||||
left: InfoCreditRow,
|
||||
right: InfoCreditRow,
|
||||
has-right: bool,
|
||||
}
|
||||
|
||||
// One performer line inside an expanded Album-Credits track. `roles` is the
|
||||
// raw ", Role1, Role2" suffix (empty when the performer has no roles).
|
||||
export struct AlbumCreditPerformer {
|
||||
name: string,
|
||||
roles: string,
|
||||
// First role (clean) — the musician-nav role hint (Tauri roles[0]).
|
||||
primary-role: string,
|
||||
}
|
||||
|
||||
// One track row in the Album-Credits "Credits" tab.
|
||||
export struct AlbumCreditTrack {
|
||||
id: string,
|
||||
number: string,
|
||||
title: string,
|
||||
artist: string,
|
||||
// True when the row has performers or a copyright line (expandable).
|
||||
has-credits: bool,
|
||||
performers: [AlbumCreditPerformer],
|
||||
copyright: string,
|
||||
}
|
||||
|
||||
// Track Info modal — opened from the NPB (i) button / song-card title /
|
||||
// TrackRow context menu via media-action("track", id, "track-info").
|
||||
export global TrackInfoState {
|
||||
in-out property <bool> open: false;
|
||||
in property <bool> loading: false;
|
||||
in property <string> error: "";
|
||||
in property <string> title;
|
||||
in property <string> album;
|
||||
in property <string> artist;
|
||||
// "" -> artist rendered as plain text (not a link).
|
||||
in property <string> artist-id;
|
||||
in property <string> duration;
|
||||
in property <string> quality;
|
||||
// "" -> the row is hidden.
|
||||
in property <string> isrc;
|
||||
in property <string> label;
|
||||
in property <string> label-id;
|
||||
// Paired (2-column) ordered credit cells.
|
||||
in property <[InfoCreditPair]> credits: [];
|
||||
in property <string> copyright;
|
||||
}
|
||||
|
||||
export global TrackInfoActions {
|
||||
callback close();
|
||||
callback open-artist(string /* artist-id */);
|
||||
callback open-label(string /* label-id */);
|
||||
callback open-musician(string /* name */, string /* role */);
|
||||
}
|
||||
|
||||
// Album Info modal — opened from the AlbumPageView header (i) button via
|
||||
// media-action("album", id, "info").
|
||||
export global AlbumInfoState {
|
||||
in-out property <bool> open: false;
|
||||
in property <bool> loading: false;
|
||||
in property <string> error: "";
|
||||
// "credits" | "review". The Review tab only exists when has-review.
|
||||
in-out property <string> active-tab: "credits";
|
||||
in property <bool> has-review: false;
|
||||
in property <image> artwork;
|
||||
in property <string> title;
|
||||
in property <string> artist;
|
||||
in property <string> label;
|
||||
in property <string> label-id;
|
||||
// Localized "September 2, 2021" ("" hides the date span).
|
||||
in property <string> release-date;
|
||||
// "Hard Rock · 10 tracks · 1h 21m".
|
||||
in property <string> meta-line;
|
||||
// "24-Bit / 96 kHz" ("" hides).
|
||||
in property <string> quality;
|
||||
in property <[AlbumCreditTrack]> tracks: [];
|
||||
// HTML-stripped editorial review ("" -> no Review tab).
|
||||
in property <string> review;
|
||||
}
|
||||
|
||||
export global AlbumInfoActions {
|
||||
callback close();
|
||||
callback set-tab(string /* "credits" | "review" */);
|
||||
callback play-track(string /* track-id */);
|
||||
callback open-label(string /* label-id */);
|
||||
callback open-musician(string /* name */, string /* role */);
|
||||
}
|
||||
|
||||
// Album-view actions wired to Rust callbacks.
|
||||
export global AlbumActions {
|
||||
// Filter the visible track list by a query (client-side).
|
||||
|
||||
Reference in new issue
Block a user