From b51ec1509e5ba9a7edd47f8b6941af2b5c82bcf5 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 18 May 2026 19:25:33 -0600 Subject: [PATCH] feat(slint): album view detail parity Bring the album view closer to 1:1 with the Tauri original. - Track list: favorite and offline-cache columns, and the context-menu button now always shows in the muted column color (it brightens on hover) instead of being hidden until hover - Toolbar above the track list: a QualityBadgeFull port of the Tauri QualityBadgeStatic (icon + tier + exact bit-depth/sample-rate), plus a track search box - Editorial album description, truncated, with a Read more link that opens the full text in a modal - Label/awards sidebar: drop the resting card background; awards use the Tauri laurels SVG - Control buttons on both album and artist views are ghost circles (translucent fill, faint ring) instead of solid fills cc --- crates/qbz-slint/src/album.rs | 47 ++++ crates/qbz-slint/ui/album/AlbumPageView.slint | 230 ++++++++++++++++-- .../qbz-slint/ui/artist/ArtistPageView.slint | 15 +- .../ui/assets/icons/cloud-download.svg | 5 + crates/qbz-slint/ui/assets/laurels.svg | 2 + crates/qbz-slint/ui/assets/mp3.svg | 2 + .../ui/primitives/QualityBadgeFull.slint | 77 ++++++ 7 files changed, 358 insertions(+), 20 deletions(-) create mode 100644 crates/qbz-slint/ui/assets/icons/cloud-download.svg create mode 100644 crates/qbz-slint/ui/assets/laurels.svg create mode 100644 crates/qbz-slint/ui/assets/mp3.svg create mode 100644 crates/qbz-slint/ui/primitives/QualityBadgeFull.slint diff --git a/crates/qbz-slint/src/album.rs b/crates/qbz-slint/src/album.rs index cf5748665..7970c3940 100644 --- a/crates/qbz-slint/src/album.rs +++ b/crates/qbz-slint/src/album.rs @@ -22,6 +22,10 @@ pub struct AlbumData { /// Pre-formatted "year • label • genre • N tracks • duration". pub info_line: String, pub quality_tier: String, + /// "24-bit / 96 kHz" — the quality-badge detail line. + pub quality_detail: String, + /// Editorial description / review (HTML stripped). May be empty. + pub description: String, pub artwork_url: String, /// Record label name, for the sidebar (empty when unknown). pub label: String, @@ -83,6 +87,12 @@ 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 description = album + .description + .as_deref() + .map(strip_html) + .unwrap_or_default(); let artwork_url = album.image.best().cloned().unwrap_or_default(); let label = album .label @@ -112,6 +122,8 @@ fn map_album(album: Album) -> AlbumData { artist_id, info_line, quality_tier, + quality_detail, + description, artwork_url, label, awards, @@ -119,6 +131,39 @@ fn map_album(album: Album) -> AlbumData { } } +/// "24-bit / 96 kHz" — the quality-badge detail string. +fn quality_detail(bit_depth: Option, sample_rate: Option) -> 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 (tags + a few entities). +fn strip_html(input: &str) -> String { + let mut out = String::new(); + let mut in_tag = false; + for ch in input.chars() { + match ch { + '<' => in_tag = true, + '>' => in_tag = false, + _ if !in_tag => out.push(ch), + _ => {} + } + } + out.replace("&", "&") + .replace("'", "'") + .replace(""", "\"") + .replace(" ", " ") + .trim() + .to_string() +} + fn map_track(track: Track) -> TrackData { let mut title = track.title; if let Some(version) = track.version.as_ref().filter(|v| !v.is_empty()) { @@ -186,6 +231,8 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) { state.set_artist_id(data.artist_id.into()); state.set_info_line(data.info_line.into()); state.set_quality_tier(data.quality_tier.into()); + state.set_quality_detail(data.quality_detail.into()); + state.set_description(data.description.into()); state.set_label(data.label.into()); state.set_awards(ModelRc::new(VecModel::from(awards))); state.set_tracks(ModelRc::new(VecModel::from(tracks))); diff --git a/crates/qbz-slint/ui/album/AlbumPageView.slint b/crates/qbz-slint/ui/album/AlbumPageView.slint index a7c214d2b..82cc04dd1 100644 --- a/crates/qbz-slint/ui/album/AlbumPageView.slint +++ b/crates/qbz-slint/ui/album/AlbumPageView.slint @@ -13,6 +13,7 @@ import { AlbumState, AlbumTrackItem, NavState, ContentView } from "../state.slin import { QbzIcon } from "../primitives/QbzIcon.slint"; import { ContextMenu } from "../primitives/ContextMenu.slint"; import { ContextMenuItem } from "../primitives/ContextMenuItem.slint"; +import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint"; component CircleAction inherits Rectangle { in property icon; @@ -23,17 +24,19 @@ component CircleAction inherits Rectangle { width: root.diameter; height: root.diameter; border-radius: root.diameter / 2; - background: root.primary - ? (ta.has-hover ? Theme.accent-hover : Theme.accent) - : (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated); + // Ghost circle — translucent fill with a faint ring, never a solid + // accent fill (mirrors the Tauri transport controls). + background: ta.has-hover ? Theme.surface-hover : transparent; + border-width: 1px; + border-color: ta.has-hover ? Theme.text-disabled : Theme.border-subtle; QbzIcon { source: root.icon; - width: 17px; - height: 17px; + width: root.primary ? 19px : 17px; + height: root.primary ? 19px : 17px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; - tint: root.primary ? Theme.accent-text : Theme.text-secondary; + tint: ta.has-hover ? Theme.text-primary : Theme.text-secondary; } ta := TouchArea { @@ -134,17 +137,39 @@ component TrackRow inherits Rectangle { vertical-alignment: center; } - // More button — a 32px square hit area, vertically centered. - // Visible while the row OR the button itself is hovered (the - // button steals has-hover from the row, so the states are ORed). + // Favorite column (visual). + Rectangle { + width: 28px; + QbzIcon { + source: @image-url("../assets/icons/heart.svg"); + width: 16px; + height: 16px; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + tint: Theme.text-muted; + } + } + // Offline-cache column (visual). + Rectangle { + width: 28px; + QbzIcon { + source: @image-url("../assets/icons/cloud-download.svg"); + width: 16px; + height: 16px; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + tint: Theme.text-muted; + } + } + + // Context-menu button — always visible in the muted column color, + // a 32px square hit area that brightens on hover. VerticalLayout { alignment: center; Rectangle { width: 32px; height: 32px; border-radius: Radius.sm; - opacity: (ta.has-hover || more-ta.has-hover) ? 1.0 : 0.0; - animate opacity { duration: 120ms; } background: more-ta.has-hover ? Theme.surface-elevated : transparent; QbzIcon { source: @image-url("../assets/icons/ellipsis.svg"); @@ -152,7 +177,7 @@ component TrackRow inherits Rectangle { height: 16px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; - tint: more-ta.has-hover ? Theme.text-primary : Theme.text-secondary; + tint: more-ta.has-hover ? Theme.text-primary : Theme.text-muted; } more-ta := TouchArea { mouse-cursor: pointer; @@ -205,7 +230,7 @@ component SidebarCard inherits Rectangle { height: 56px; border-radius: Radius.sm; - background: ta.has-hover ? Theme.surface-hover : Theme.surface-card; + background: ta.has-hover ? Theme.surface-hover : transparent; HorizontalLayout { padding: 8px; @@ -259,6 +284,9 @@ export component AlbumPageView inherits Rectangle { callback open-artist(string); callback media-action(string, string, string); + // Whether the full-description modal is open. + property show-description: false; + background: Theme.surface-main; Flickable { @@ -273,6 +301,7 @@ export component AlbumPageView inherits Rectangle { height: 340px; background: @linear-gradient(180deg, AlbumState.header-color 0%, + AlbumState.header-color 16%, transparent 100%); } @@ -377,6 +406,37 @@ export component AlbumPageView inherits Rectangle { font-size: Typography.body; overflow: elide; } + + // Editorial description — truncated, with a Read more + // link that opens the full text in a modal. + if AlbumState.description != "": Rectangle { height: 10px; } + if AlbumState.description != "": Text { + text: AlbumState.description; + color: Theme.text-secondary; + font-size: Typography.legal; + wrap: word-wrap; + height: 34px; + overflow: elide; + } + if AlbumState.description != "": read-more := TouchArea { + width: read-more-row.preferred-width; + height: 22px; + mouse-cursor: pointer; + clicked => { + root.show-description = true; + } + read-more-row := HorizontalLayout { + Text { + text: @tr("Read more"); + color: read-more.has-hover + ? Theme.accent-hover + : Theme.accent; + font-size: Typography.legal; + vertical-alignment: center; + } + } + } + Rectangle { height: 20px; } HorizontalLayout { alignment: start; @@ -453,6 +513,52 @@ export component AlbumPageView inherits Rectangle { font-size: Typography.body; } + // Toolbar — album quality badge and track search. + HorizontalLayout { + height: 52px; + spacing: 16px; + VerticalLayout { + alignment: center; + QualityBadgeFull { + tier: AlbumState.quality-tier; + detail: AlbumState.quality-detail; + } + } + Rectangle { horizontal-stretch: 1; } + VerticalLayout { + alignment: center; + Rectangle { + width: 280px; + height: 34px; + border-radius: 6px; + border-width: 1px; + border-color: Theme.border-subtle; + background: Theme.surface-elevated; + HorizontalLayout { + padding-left: 10px; + padding-right: 10px; + spacing: 7px; + VerticalLayout { + alignment: center; + QbzIcon { + source: @image-url("../assets/icons/search.svg"); + width: 14px; + height: 14px; + tint: Theme.text-muted; + } + } + Text { + text: @tr("Search tracks..."); + color: Theme.text-muted; + font-size: 13px; + vertical-alignment: center; + horizontal-stretch: 1; + } + } + } + } + } + // Column header. HorizontalLayout { height: 40px; @@ -493,6 +599,29 @@ export component AlbumPageView inherits Rectangle { horizontal-alignment: center; vertical-alignment: center; } + // Favorite / offline-cache column headers. + Rectangle { + width: 28px; + QbzIcon { + source: @image-url("../assets/icons/heart.svg"); + width: 14px; + height: 14px; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + tint: Theme.text-muted; + } + } + Rectangle { + width: 28px; + QbzIcon { + source: @image-url("../assets/icons/cloud-download.svg"); + width: 14px; + height: 14px; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + tint: Theme.text-muted; + } + } // Aligns with the per-row more-button slot. Rectangle { width: 32px; } } @@ -526,7 +655,7 @@ export component AlbumPageView inherits Rectangle { spacing: 8px; SidebarHeading { text: @tr("AWARDS"); } for award in AlbumState.awards: SidebarCard { - icon: @image-url("../assets/icons/award.svg"); + icon: @image-url("../assets/laurels.svg"); name: award; avatar-bg: @linear-gradient(135deg, #b45309 0%, #eab308 100%); } @@ -535,4 +664,77 @@ export component AlbumPageView inherits Rectangle { } } } + + // --- Full-description modal -------------------------------------------- + if root.show-description: Rectangle { + background: #000000bf; + + // Scrim — a click anywhere outside the panel dismisses. + TouchArea { + mouse-cursor: default; + clicked => { + root.show-description = false; + } + } + + Rectangle { + width: Math.min(root.width - 80px, 560px); + height: Math.min(root.height - 120px, 460px); + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + 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 do not reach the scrim. + TouchArea { } + + VerticalLayout { + padding: 24px; + spacing: 14px; + + HorizontalLayout { + Text { + text: @tr("About this album"); + color: Theme.text-primary; + font-size: Typography.heading; + font-weight: Typography.semibold; + horizontal-stretch: 1; + vertical-alignment: center; + } + close-x := TouchArea { + width: 28px; + height: 28px; + mouse-cursor: pointer; + clicked => { + root.show-description = false; + } + 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; + } + } + } + + Flickable { + viewport-width: self.width; + viewport-height: desc-text.preferred-height; + desc-text := Text { + width: parent.width; + text: AlbumState.description; + color: Theme.text-secondary; + font-size: Typography.body; + wrap: word-wrap; + } + } + } + } + } } diff --git a/crates/qbz-slint/ui/artist/ArtistPageView.slint b/crates/qbz-slint/ui/artist/ArtistPageView.slint index fbae8daee..7635a5631 100644 --- a/crates/qbz-slint/ui/artist/ArtistPageView.slint +++ b/crates/qbz-slint/ui/artist/ArtistPageView.slint @@ -23,17 +23,19 @@ component CircleAction inherits Rectangle { width: root.diameter; height: root.diameter; border-radius: root.diameter / 2; - background: root.primary - ? (ta.has-hover ? Theme.accent-hover : Theme.accent) - : (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated); + // Ghost circle — translucent fill with a faint ring, never a solid + // accent fill (mirrors the Tauri transport controls). + background: ta.has-hover ? Theme.surface-hover : transparent; + border-width: 1px; + border-color: ta.has-hover ? Theme.text-disabled : Theme.border-subtle; QbzIcon { source: root.icon; - width: 17px; - height: 17px; + width: root.primary ? 19px : 17px; + height: root.primary ? 19px : 17px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; - tint: root.primary ? Theme.accent-text : Theme.text-secondary; + tint: ta.has-hover ? Theme.text-primary : Theme.text-secondary; } ta := TouchArea { @@ -184,6 +186,7 @@ export component ArtistPageView inherits Rectangle { height: 340px; background: @linear-gradient(180deg, ArtistState.header-color 0%, + ArtistState.header-color 16%, transparent 100%); } diff --git a/crates/qbz-slint/ui/assets/icons/cloud-download.svg b/crates/qbz-slint/ui/assets/icons/cloud-download.svg new file mode 100644 index 000000000..7504c094f --- /dev/null +++ b/crates/qbz-slint/ui/assets/icons/cloud-download.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/crates/qbz-slint/ui/assets/laurels.svg b/crates/qbz-slint/ui/assets/laurels.svg new file mode 100644 index 000000000..8a6203ce1 --- /dev/null +++ b/crates/qbz-slint/ui/assets/laurels.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/crates/qbz-slint/ui/assets/mp3.svg b/crates/qbz-slint/ui/assets/mp3.svg new file mode 100644 index 000000000..b1efd8ac1 --- /dev/null +++ b/crates/qbz-slint/ui/assets/mp3.svg @@ -0,0 +1,2 @@ + +MP3 \ No newline at end of file diff --git a/crates/qbz-slint/ui/primitives/QualityBadgeFull.slint b/crates/qbz-slint/ui/primitives/QualityBadgeFull.slint new file mode 100644 index 000000000..9a5cc1da8 --- /dev/null +++ b/crates/qbz-slint/ui/primitives/QualityBadgeFull.slint @@ -0,0 +1,77 @@ +// Full quality badge — a faithful port of the Tauri QualityBadgeStatic +// (full mode): a contained pill with the format icon, the tier label, and +// the exact bit-depth / sample-rate line. +// +// Intentionally not a creative reinterpretation — the Tauri layout is the +// contract. Used wherever a track list or detail view advertises its +// stored quality. + +import { Theme } from "../foundation/semantic-colors.slint"; +import { QbzIcon } from "QbzIcon.slint"; + +export component QualityBadgeFull inherits Rectangle { + // "hires" | "cd" | "mp3" | "". + in property tier; + // Exact quality, e.g. "24-bit / 96 kHz". + in property detail; + + property tier-label: root.tier == "hires" + ? "HI-RES" + : (root.tier == "mp3" ? "MP3" : "CD"); + + visible: root.tier != ""; + height: 36px; + width: Math.max(content.preferred-width, 136px); + border-radius: 4px; + background: Theme.surface-hover; + border-width: 1px; + border-color: Theme.border-subtle; + + content := HorizontalLayout { + padding-left: 10px; + padding-right: 10px; + spacing: 6px; + + // Format icon. The Hi-Res brand mark keeps its own colors; the + // CD / MP3 marks render in muted grey. + VerticalLayout { + alignment: center; + if root.tier == "hires": Image { + source: @image-url("../assets/hi-res.svg"); + width: 24px; + height: 24px; + image-fit: contain; + } + if root.tier == "cd": QbzIcon { + source: @image-url("../assets/cd.svg"); + width: 16px; + height: 16px; + tint: #b0b0b0; + } + if root.tier == "mp3": QbzIcon { + source: @image-url("../assets/mp3.svg"); + width: 16px; + height: 16px; + tint: #b0b0b0; + } + } + + VerticalLayout { + alignment: center; + spacing: 1px; + Text { + text: root.tier-label; + color: #b0b0b0; + font-size: 8px; + font-weight: 100; + letter-spacing: 0.5px; + } + Text { + text: root.detail; + color: #999999; + font-size: 9px; + font-weight: 100; + } + } + } +}