From b5fd478b7b3146355524972a7443302a45998779 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sat, 27 Jun 2026 23:15:45 -0600 Subject: [PATCH] fix(foryou): radio excludes local/Plex, Plex/local artwork, radio nav buttons - Radio Stations seed only Qobuz-sourced recent albums; local/Plex albums carry ids the Qobuz /radio/album endpoint can't resolve, so they no longer generate radio tiles (they still appear in Recently Played Albums). - Recently Played albums/tracks route artwork by scheme (spawn_search_loads): http -> Qobuz CDN, /library/ or /photo/ -> Plex thumb, else local file. The plain HTTP loader left Plex/local covers blank. - Radio Stations carousel extracted to a RadioCarousel component with prev/next nav buttons (drag preserved), mirroring SlimCarousel. cc --- crates/qbz-ui/ui/discover/ForYouView.slint | 42 ++----- crates/qbz-ui/ui/discover/RadioCarousel.slint | 117 ++++++++++++++++++ crates/qbz/src/foryou.rs | 15 ++- 3 files changed, 138 insertions(+), 36 deletions(-) create mode 100644 crates/qbz-ui/ui/discover/RadioCarousel.slint diff --git a/crates/qbz-ui/ui/discover/ForYouView.slint b/crates/qbz-ui/ui/discover/ForYouView.slint index df0a967e6..e94692533 100644 --- a/crates/qbz-ui/ui/discover/ForYouView.slint +++ b/crates/qbz-ui/ui/discover/ForYouView.slint @@ -23,7 +23,7 @@ import { SlimCarousel } from "SlimCarousel.slint"; import { ArtistCarousel } from "ArtistCarousel.slint"; import { Spotlight } from "Spotlight.slint"; import { QobuzMixesRow } from "QobuzMixesRow.slint"; -import { RadioCard } from "RadioCard.slint"; +import { RadioCarousel } from "RadioCarousel.slint"; import { HomeSkeleton } from "HomeSkeleton.slint"; export component ForYouView inherits VerticalLayout { @@ -77,40 +77,12 @@ export component ForYouView inherits VerticalLayout { } } - // radioStations — album-seeded radio tiles (bespoke Flickable body). - if desc.id == "radioStations" && ForYouState.radio-stations.length > 0: VerticalLayout { - spacing: 12px; - Text { - text: @tr("Radio Stations"); - color: Theme.text-primary; - font-size: 18px; - font-weight: Typography.semibold; - } - Rectangle { - height: 234px; - clip: true; - radio-flick := Flickable { - width: 100%; - height: parent.height; - viewport-width: ForYouState.radio-stations.length * (200px + 32px); - viewport-height: self.height; - HorizontalLayout { - spacing: 32px; - alignment: start; - for st in ForYouState.radio-stations: RadioCard { - seed-title: st.title; - seed-subtitle: st.artist; - label: @tr("RADIO"); - artwork: st.artwork; - clicked => { - root.start-radio-album(st.album-id); - } - play => { - root.start-radio-album(st.album-id); - } - } - } - } + // radioStations — album-seeded radio tiles (paged carousel w/ nav buttons). + if desc.id == "radioStations" && ForYouState.radio-stations.length > 0: RadioCarousel { + title: @tr("Radio Stations"); + stations: ForYouState.radio-stations; + start-radio-album(id) => { + root.start-radio-album(id); } } diff --git a/crates/qbz-ui/ui/discover/RadioCarousel.slint b/crates/qbz-ui/ui/discover/RadioCarousel.slint new file mode 100644 index 000000000..6570d0fd5 --- /dev/null +++ b/crates/qbz-ui/ui/discover/RadioCarousel.slint @@ -0,0 +1,117 @@ +// Radio Stations carousel for Discover > For You — album-seeded radio tiles in a +// paged horizontal Flickable with prev/next nav buttons (drag still works). The +// nav buttons mirror SlimCarousel; the body uses RadioCard (the bespoke radio +// tile) instead of slim/album cards. Replaces the previous bespoke Flickable +// block in ForYouView, which had no navigation buttons. + +import { Theme } from "../foundation/semantic-colors.slint"; +import { Typography } from "../foundation/typography.slint"; +import { RadioStationItem } from "../state.slint"; +import { RadioCard } from "RadioCard.slint"; +import { QbzIcon } from "../primitives/QbzIcon.slint"; + +component NavButton inherits Rectangle { + in property icon; + in property enabled: true; + callback clicked(); + + width: 28px; + height: 28px; + border-radius: 14px; + opacity: root.enabled ? 1.0 : 0.4; + background: ta.has-hover && root.enabled + ? Theme.surface-hover + : Theme.surface-elevated; + + QbzIcon { + source: root.icon; + width: 15px; + height: 15px; + x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; + y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; + tint: root.enabled ? Theme.text-primary : Theme.text-muted; + } + + ta := TouchArea { + enabled: root.enabled; + mouse-cursor: root.enabled ? pointer : default; + clicked => { + root.clicked(); + } + } +} + +export component RadioCarousel inherits VerticalLayout { + in property title; + in property <[RadioStationItem]> stations; + callback start-radio-album(string); + + // 200px card + 32px inter-card spacing (matches the HorizontalLayout below). + property card-pitch: 232px; + property total-width: root.stations.length * root.card-pitch; + property max-scroll: Math.max(0px, root.total-width - flick.width); + + spacing: 12px; + + // Header: title + (conditional) page controls — only when the row overflows. + HorizontalLayout { + Text { + text: root.title; + color: Theme.text-primary; + font-size: 18px; + font-weight: Typography.semibold; + vertical-alignment: center; + horizontal-stretch: 1; + } + if root.max-scroll > 0px: HorizontalLayout { + spacing: 4px; + VerticalLayout { + alignment: center; + NavButton { + icon: @image-url("../assets/icons/chevron-left.svg"); + enabled: flick.viewport-x < -1px; + clicked => { + flick.viewport-x = Math.min(0px, flick.viewport-x + flick.width); + } + } + } + VerticalLayout { + alignment: center; + NavButton { + icon: @image-url("../assets/icons/chevron-right.svg"); + enabled: flick.viewport-x > -root.max-scroll + 1px; + clicked => { + flick.viewport-x = Math.max(-root.max-scroll, flick.viewport-x - flick.width); + } + } + } + } + } + + Rectangle { + height: 234px; + clip: true; + flick := Flickable { + width: 100%; + height: parent.height; + viewport-width: root.total-width; + viewport-height: self.height; + HorizontalLayout { + spacing: 32px; + alignment: start; + for st in root.stations: RadioCard { + seed-title: st.title; + seed-subtitle: st.artist; + label: @tr("RADIO"); + artwork: st.artwork; + clicked => { + root.start-radio-album(st.album-id); + } + play => { + root.start-radio-album(st.album-id); + } + } + } + } + } +} diff --git a/crates/qbz/src/foryou.rs b/crates/qbz/src/foryou.rs index 09e396db6..7413513f1 100644 --- a/crates/qbz/src/foryou.rs +++ b/crates/qbz/src/foryou.rs @@ -470,6 +470,14 @@ fn build_radio( let mut radio_seen: HashSet = HashSet::new(); let mut radio_stations: Vec = Vec::new(); for a in recent_album_list { + // Radio Stations seed a Qobuz album radio (/radio/album), so only + // Qobuz-sourced albums are eligible. Locally-played / Plex albums carry + // ids the Qobuz radio endpoint can't resolve, so they must NOT appear + // here (they still show in "Recently Played Albums"). Empty source = + // legacy pre-source entry, treated as Qobuz. + if !(a.source.is_empty() || a.source.eq_ignore_ascii_case("qobuz")) { + continue; + } if radio_seen.insert(a.id.clone()) { radio_stations.push(RadioSeed { album_id: a.id.clone(), @@ -651,7 +659,12 @@ fn apply_recent( .collect(); state.set_recent_tracks(ModelRc::new(VecModel::from(slim))); }); - crate::artwork::spawn_loads(jobs, weak.clone(), cache.clone()); + // Recently-played albums/tracks mix sources (Qobuz / Plex / local), so the + // artwork must be routed by scheme: http -> Qobuz CDN, /library/ or /photo/ + // -> Plex thumb (tokenized LAN fetch), else a local file read. The plain + // HTTP loader (spawn_loads) left Plex and local covers blank. + let plex = crate::plex_settings::get(); + crate::artwork::spawn_search_loads(jobs, plex.base_url, plex.token, weak.clone(), cache.clone()); } fn apply_release_watch(weak: &slint::Weak, cache: &ImageCache, cards: Vec) {