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:
vicrodh committed 2026-06-12 19:20:55 -06:00
1 parent cf88516cb3
commit 4e8703d660
9 files changed
+1876 -5

No files matched your search

+260
View File
@@ -87,6 +87,117 @@ pub fn group_by_role(performers: &[Performer]) -> std::collections::HashMap<Stri
grouped
}
/// Build the lookup key Qobuz frontends use for role i18n: first char
/// lowercased, the rest with spaces stripped (mirrors Tauri `formatRole`).
fn role_key(role: &str) -> String {
let mut chars = role.chars();
match chars.next() {
Some(first) => {
let lowered: String = first.to_lowercase().collect();
let rest: String = chars.filter(|c| *c != ' ').collect();
format!("{lowered}{rest}")
}
None => String::new(),
}
}
/// Fallback humanizer (mirrors Tauri `formatUnknownRole` minus the final
/// upper-casing, which the caller applies): insert a space before each
/// uppercase letter, then trim. e.g. "CustomRole" -> "Custom Role".
fn humanize_role(role: &str) -> String {
let mut out = String::with_capacity(role.len() + 4);
for (i, c) in role.chars().enumerate() {
if i > 0 && c.is_uppercase() {
out.push(' ');
}
out.push(c);
}
out.trim().to_string()
}
/// Human-readable role label, ported 1:1 from the Tauri `performerRoles` i18n
/// map (English) with the same `formatRole` key + `formatUnknownRole`
/// fallback. NOT upper-cased — the Track Info grid upper-cases at render
/// (Tauri uses CSS `text-transform: uppercase`).
pub fn format_role_label(role: &str) -> String {
let key = role_key(role);
for (k, label) in PERFORMER_ROLE_LABELS {
if *k == key {
return (*label).to_string();
}
}
humanize_role(role)
}
/// Ordered, deduped role grouping — 1:1 with Tauri `getGroupedCredits`:
/// group performer names by role (dedup within a role, first-seen order),
/// then order roles as: Composer, Lyricist first (Composer before Lyricist);
/// MainArtist / "Main Artist" last; everything else alphabetical
/// (case-insensitive). Returns `(role, names)` pairs.
pub fn group_credits_ordered(performers: &[Performer]) -> Vec<(String, Vec<String>)> {
// Preserve first-seen role order while grouping (mirror of JS object key
// insertion order before the explicit sort).
let mut order: Vec<String> = Vec::new();
let mut grouped: std::collections::HashMap<String, Vec<String>> =
std::collections::HashMap::new();
for performer in performers {
for role in &performer.roles {
let entry = grouped.entry(role.clone()).or_insert_with(|| {
order.push(role.clone());
Vec::new()
});
if !entry.contains(&performer.name) {
entry.push(performer.name.clone());
}
}
}
let is_first = |r: &str| {
let r = r.to_lowercase();
r == "composer" || r == "lyricist"
};
let is_last = |r: &str| {
let r = r.to_lowercase();
r == "mainartist" || r == "main artist"
};
order.sort_by(|a, b| {
use std::cmp::Ordering;
let (af, bf) = (is_first(a), is_first(b));
let (al, bl) = (is_last(a), is_last(b));
if af && !bf {
return Ordering::Less;
}
if !af && bf {
return Ordering::Greater;
}
if al && !bl {
return Ordering::Greater;
}
if !al && bl {
return Ordering::Less;
}
if af && bf {
if a.to_lowercase() == "composer" {
return Ordering::Less;
}
if b.to_lowercase() == "composer" {
return Ordering::Greater;
}
}
a.to_lowercase().cmp(&b.to_lowercase())
});
order
.into_iter()
.map(|role| {
let names = grouped.remove(&role).unwrap_or_default();
(role, names)
})
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
@@ -141,3 +252,152 @@ mod tests {
assert_eq!(grouped.get("Vocals").unwrap().len(), 1);
}
}
pub(crate) static PERFORMER_ROLE_LABELS: &[(&str, &str)] = &[
("a&R", "Artists and Repertoire"),
("a&RDirector", "Artists and Repertoire Director"),
("aAndRCoordinator", "A&R Coordinator"),
("accordion", "Accordion"),
("acousticGuitar", "Acoustic Guitar"),
("additionalEngineer", "Additional Engineer"),
("additionalKeyboard", "Additional Keyboard"),
("additionalMusic", "Additional Music"),
("additionalProduction", "Additional Production"),
("additionalProgrammer", "Additional Programmer"),
("additionalStudioProducer", "Additional Studio Producer"),
("additionalVocalist", "Additional Vocalist"),
("additionalVocals", "Additional Vocals"),
("arranger", "Arranger"),
("artDirector", "Art Director"),
("artist", "Artist"),
("assistant", "Assistant"),
("assistantEngineer", "Assistant Engineer"),
("assistantMixer", "Assistant Mixer"),
("assistantMixingEngineer", "Assistant Mixing Engineer"),
("associatedPerformer", "Associated Performer"),
("associatedProducer", "Associated Producer"),
("author", "Author"),
("backingVocals", "Backing Vocals"),
("backgroundVocal", "Background Vocal"),
("backgroundVocalist", "Background Vocalist"),
("backgroundVocals", "Background Vocals"),
("baritoneSaxophone", "Baritone Saxophone"),
("bass", "Bass"),
("bassGuitar", "Bass Guitar"),
("celesta", "Celesta"),
("cello", "Cello"),
("chamberOrchestra", "Chamber Orchestra"),
("choir", "Choir"),
("choirArranger", "Choir Arranger"),
("choirConductor", "Choir Conductor"),
("coachVocals", "Coach Vocals"),
("composer", "Composer"),
("composerLyricist", "Composer Lyricist"),
("conductor", "Conductor"),
("consultant", "Consultant"),
("contractor", "Contractor"),
("coProducer", "Co-Producer"),
("designer", "Designer"),
("digitalEditingEngineer", "Digital Editing Engineer"),
("doubleBass", "Double Bass"),
("drum", "Drum"),
("drumMachine", "Drum Machine"),
("drumProgrammer", "Drum Programmer"),
("drumProgramming", "Drum Programming"),
("drumKit", "Drum Kit"),
("drums", "Drums"),
("editingEngineer", "Editing Engineer"),
("electricBassGuitar", "Electric Bass Guitar"),
("electricGuitar", "Electric Guitar"),
("engineer", "Engineer"),
("executiveProducer", "Executive Producer"),
("featuredArtist", "Featured Artist"),
("fiddle", "Fiddle"),
("frenchHorn", "French Horn"),
("glockenspiel", "Glockenspiel"),
("guitar", "Guitar"),
("hammondOrgan", "Hammond Organ"),
("harp", "Harp"),
("horn", "Horn"),
("horns", "Horns"),
("instrumentation", "Instrumentation"),
("keyboard", "Keyboard"),
("keyboards", "Keyboards"),
("leadGuitar", "Lead Guitar"),
("leadViolin", "Lead Violin"),
("leadVocals", "Lead Vocals"),
("lyricist", "Lyricist"),
("mainArtist", "Main Artist"),
("manager", "Manager"),
("masterer", "Masterer"),
("masteringEngineer", "Mastering Engineer"),
("mixer", "Mixer"),
("mixEngineer", "Mix Engineer"),
("mixingEngineer", "Mixing Engineer"),
("mixingSecondEngineer", "Mixing Second Engineer"),
("music", "Music"),
("musicDirector", "Music Director"),
("musicEditor", "Music Editor"),
("musicPublisher", "Music Publisher"),
("musicSupervisor", "Music Supervisor"),
("nylonStringGuitar", "Nylon String Guitar"),
("orchestra", "Orchestra"),
("orchestralContractor", "Orchestral Contractor"),
("orchestration", "Orchestration"),
("organ", "Organ"),
("other", "Other"),
("oud", "Oud"),
("percussion", "Percussion"),
("performance", "Performance"),
("performer", "Performer"),
("piano", "Piano"),
("producer", "Producer"),
("production", "Production"),
("programmer", "Programmer"),
("programming", "Programming"),
("programmingEngineer", "Programming Engineer"),
("rapVocalist", "Rap Vocalist"),
("recordedby", "Recorded By"),
("recordingArranger", "Recording Arranger"),
("recordingEngineer", "Recording Engineer"),
("recordingProducer", "Recording Producer"),
("recordingSecondEngineer", "Recording Second Engineer"),
("remasteringEngineer", "Remastering Engineer"),
("remixer", "Remixer"),
("remixingSecondEngineer", "Remixing Second Engineer"),
("rhythmGuitar", "rhythmGuitar"),
("samples", "Samples"),
("saxophone", "Saxophone"),
("secondEngineer", "Second Engineer"),
("singer", "Singer"),
("slideguitar&Pad", "Slide Guitar & Pad"),
("songwriter", "Songwriter"),
("stringArranger", "String Arranger"),
("strings", "Strings"),
("studioAssistant", "Studio Assistant"),
("studioPersonnel", "Studio Personnel"),
("synthesizer", "Synthesizer"),
("synthesizerProgrammer", "Synthesizer Programmer"),
("synthesizerProgramming", "Synthesizer Programming"),
("technicalAssistant", "Technical Assistant"),
("technicalEngineer", "Technical Engineer"),
("technician", "Technician"),
("trombone", "Trombone"),
("trumpet", "Trumpet"),
("tuba", "Tuba"),
("ukulele", "Ukulele"),
("unknown", "Unknown"),
("vibraphone", "Vibraphone"),
("viola", "Viola"),
("violin", "Violin"),
("vocal", "Vocal"),
("vocalArranger", "Vocal Arranger"),
("vocalEditingEngineer", "Vocal Editing Engineer"),
("vocalEngineer", "Vocal Engineer"),
("vocalProducer", "Vocal Producer"),
("vocalist", "Vocalist"),
("vocals", "Vocals"),
("vocals&Guitar", "Vocals & Guitar"),
("voice", "Voice"),
("workArranger", "Work Arranger"),
("writer", "Writer"),
];