diff --git a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po index 1f1a0530f..e66ca8196 100644 --- a/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/de/LC_MESSAGES/qbz-ui.po @@ -4523,3 +4523,7 @@ msgstr "Cache konnte nicht geleert werden" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Meistgespielte Alben" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} Wiedergaben" diff --git a/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po index 467300ae7..75208ee5d 100644 --- a/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/en/LC_MESSAGES/qbz-ui.po @@ -295,3 +295,7 @@ msgstr "Couldn't clear the cache" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Most Played Albums" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} plays" diff --git a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po index 6c5750b6b..5ea0cd049 100644 --- a/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/es/LC_MESSAGES/qbz-ui.po @@ -4553,3 +4553,7 @@ msgstr "No se pudo limpiar el caché" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Álbumes más escuchados" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} reproducciones" diff --git a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po index 5c736b585..5435f6288 100644 --- a/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/fr/LC_MESSAGES/qbz-ui.po @@ -4523,3 +4523,7 @@ msgstr "Impossible de vider le cache" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Albums les plus écoutés" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} lectures" diff --git a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po index 808e11e39..991fb35a2 100644 --- a/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ja/LC_MESSAGES/qbz-ui.po @@ -4512,3 +4512,7 @@ msgstr "キャッシュを削除できませんでした" # Most Played Albums rail title msgid "Most Played Albums" msgstr "最も再生したアルバム" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} 回再生" diff --git a/crates/qbz-ui/translations/nl/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/nl/LC_MESSAGES/qbz-ui.po index c937f078b..ab4f37b0d 100644 --- a/crates/qbz-ui/translations/nl/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/nl/LC_MESSAGES/qbz-ui.po @@ -4535,3 +4535,7 @@ msgstr "Kan de cache niet wissen" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Meest afgespeelde albums" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} keer afgespeeld" diff --git a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po index 0fdfcdbec..4130f15ed 100644 --- a/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/pt/LC_MESSAGES/qbz-ui.po @@ -4523,3 +4523,7 @@ msgstr "Não foi possível limpar o cache" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Álbuns mais tocados" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} reproduções" diff --git a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po index 5eda4d041..d632ed94b 100644 --- a/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po +++ b/crates/qbz-ui/translations/ru/LC_MESSAGES/qbz-ui.po @@ -4536,3 +4536,7 @@ msgstr "Не удалось очистить кэш" # Most Played Albums rail title msgid "Most Played Albums" msgstr "Самые прослушиваемые альбомы" + +# Most Played Albums View-all — per-card play count +msgid "{} plays" +msgstr "{} воспроизведений" diff --git a/crates/qbz-ui/ui/discover/AlbumCard.slint b/crates/qbz-ui/ui/discover/AlbumCard.slint index b3f2b85f3..ceb882615 100644 --- a/crates/qbz-ui/ui/discover/AlbumCard.slint +++ b/crates/qbz-ui/ui/discover/AlbumCard.slint @@ -455,6 +455,15 @@ export component AlbumCard inherits Rectangle { overflow: elide; } } + // Play count — shown ONLY in the Most Played Albums View-all + // (plays is 0 everywhere else, so nothing draws here). + if root.album.plays > 0: Text { + text: @tr("{} plays", root.album.plays); + color: Theme.text-muted; + font-size: Typography.legal; + vertical-alignment: center; + overflow: elide; + } } // Icon-only quality badge with an exact-quality hover tooltip. diff --git a/crates/qbz-ui/ui/discover/ForYouView.slint b/crates/qbz-ui/ui/discover/ForYouView.slint index f1350863e..6f15fa3a6 100644 --- a/crates/qbz-ui/ui/discover/ForYouView.slint +++ b/crates/qbz-ui/ui/discover/ForYouView.slint @@ -17,7 +17,7 @@ import { Theme } from "../foundation/semantic-colors.slint"; import { Typography } from "../foundation/typography.slint"; -import { ForYouState, RadioStationItem, DiscoverState } from "../state.slint"; +import { ForYouState, RadioStationItem, DiscoverState, HomeActions } from "../state.slint"; import { Carousel } from "Carousel.slint"; import { SlimCarousel } from "SlimCarousel.slint"; import { ArtistCarousel } from "ArtistCarousel.slint"; @@ -132,6 +132,10 @@ export component ForYouView inherits VerticalLayout { // mostPlayedAlbums — album carousel ranked by local play count. if desc.id == "mostPlayedAlbums" && ForYouState.most-played-albums.albums.length > 0: Carousel { section: ForYouState.most-played-albums; + show-view-all: true; + view-all-clicked => { + HomeActions.open-most-played-albums(); + } album-clicked(id) => { root.open-album(id); } diff --git a/crates/qbz-ui/ui/discover/HomeView.slint b/crates/qbz-ui/ui/discover/HomeView.slint index c0ea3a5ea..9d4649367 100644 --- a/crates/qbz-ui/ui/discover/HomeView.slint +++ b/crates/qbz-ui/ui/discover/HomeView.slint @@ -487,6 +487,10 @@ export component HomeView inherits Rectangle { if desc.id == "mostPlayedAlbums" && HomeState.most-played-albums.albums.length > 0: Carousel { section: HomeState.most-played-albums; + show-view-all: true; + view-all-clicked => { + HomeActions.open-most-played-albums(); + } album-clicked(id) => { root.album-clicked(id); } diff --git a/crates/qbz-ui/ui/discover/MostPlayedAlbumsView.slint b/crates/qbz-ui/ui/discover/MostPlayedAlbumsView.slint new file mode 100644 index 000000000..bd346b127 --- /dev/null +++ b/crates/qbz-ui/ui/discover/MostPlayedAlbumsView.slint @@ -0,0 +1,198 @@ +// Most Played Albums — the full-page listing opened from the rail's "View +// all". Renders the local play-count store (album_play_history), ranked by +// plays desc, as a flat grid. Each card shows its play count (AlbumCardItem +// carries `plays`, non-zero only here). Structure mirrors RecentAlbumsView +// (fixed header + AlbumCollectionView in a Flickable + the shared +// ListScrollbar); the search box is the one addition. + +import { Theme } from "../foundation/semantic-colors.slint"; +import { Typography } from "../foundation/typography.slint"; +import { MostPlayedAlbumsState, MostPlayedAlbumsActions, NavState, ShellState } from "../state.slint"; +import { AlbumCollectionView } from "AlbumCollectionView.slint"; +import { LoadingSpinner } from "../primitives/LoadingSpinner.slint"; +import { ListScrollbar } from "../primitives/ListScrollbar.slint"; +import { NavButtons } from "../shell/NavButtons.slint"; +import { QbzIcon } from "../primitives/QbzIcon.slint"; + +export component MostPlayedAlbumsView inherits Rectangle { + callback open-album(string); + callback open-artist(string); + callback media-action(string, string, string); + + property album-w: 200px; + property album-h: 286px; + property gap: 24px; + + background: Theme.surface-main; + + VerticalLayout { + spacing: 0px; + + // --- Fixed header: NavButtons + title (left), search (right) ------- + Rectangle { + height: 56px; + background: Theme.surface-main; + + HorizontalLayout { + x: 32px; + y: 25px - self.height / 2; + width: self.preferred-width; + height: self.preferred-height; + spacing: 16px; + VerticalLayout { + alignment: center; + NavButtons { } + } + VerticalLayout { + alignment: center; + Text { + text: @tr("Most Played Albums"); + color: Theme.text-primary; + font-size: Typography.section; + font-weight: Typography.bold; + vertical-alignment: center; + } + } + } + + // Search box, anchored right (filters the grid by title/artist). + search-box := Rectangle { + x: parent.width - self.width - 32px; + y: 25px - self.height / 2; + width: 240px; + 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: 8px; + VerticalLayout { + alignment: center; + QbzIcon { + source: @image-url("../assets/icons/search.svg"); + width: 14px; + height: 14px; + tint: Theme.text-muted; + } + } + Rectangle { + horizontal-stretch: 1; + input := TextInput { + width: 100%; + height: 100%; + color: Theme.text-primary; + font-size: Typography.body; + vertical-alignment: center; + single-line: true; + text <=> MostPlayedAlbumsState.search; + // Client filter runs in Rust (re-set model + re-fire + // artwork for the matches, like the playlists filter). + changed text => { MostPlayedAlbumsActions.filter(self.text); } + } + Text { + visible: input.text == ""; + text: @tr("Search…"); + color: Theme.text-muted; + font-size: Typography.body; + vertical-alignment: center; + } + } + } + } + } + + // --- Scrolling grid ---------------------------------------------- + flick := Flickable { + vertical-stretch: 1; + viewport-width: self.width; + viewport-height: page.preferred-height; + property sr-armed: NavState.restore-scope; + function sr-restore() { + if (NavState.restore-scope == "most-played-albums" && self.viewport-height > self.height) { + self.viewport-y = NavState.scroll-restore; + NavState.restore-scope = ""; + } + } + init => { self.sr-restore(); } + changed sr-armed => { self.sr-restore(); } + changed viewport-height => { self.sr-restore(); } + changed viewport-y => { NavState.report-scroll(self.viewport-y); } + + page := VerticalLayout { + width: parent.width; + padding-left: 32px; + padding-right: 32px; + padding-top: 8px; + padding-bottom: 100px; + spacing: 0px; + alignment: start; + + if MostPlayedAlbumsState.loading: HorizontalLayout { + alignment: center; + VerticalLayout { + alignment: center; + spacing: 12px; + HorizontalLayout { + alignment: center; + LoadingSpinner { size: 36px; } + } + Text { + text: @tr("Loading…"); + color: Theme.text-muted; + font-size: 14px; + horizontal-alignment: center; + } + } + } + + if !MostPlayedAlbumsState.loading + && MostPlayedAlbumsState.albums.length == 0: HorizontalLayout { + alignment: center; + Text { + text: @tr("Albums you play will appear here."); + color: Theme.text-muted; + font-size: 14px; + } + } + + if !MostPlayedAlbumsState.loading: AlbumCollectionView { + albums: MostPlayedAlbumsState.albums; + view-mode: "grid"; + is-grouped: false; + show-source: false; + card-width: root.album-w; + card-height: root.album-h; + card-gap: root.gap; + windowed: true; + visible-top: -flick.viewport-y; + visible-height: flick.height; + content-offset: 8px; + open-album(id) => { root.open-album(id); } + open-artist(id) => { root.open-artist(id); } + media-action(kind, id, action) => { + root.media-action(kind, id, action); + } + } + } + } + } + + ListScrollbar { + x: parent.width - self.width - 4px; + y: 56px; + width: 14px; + height: parent.height - 56px; + viewport-height: flick.viewport-height; + visible-height: flick.height; + viewport-y <=> flick.viewport-y; + auto-hide: true; + hover-active: ShellState.pointer-in-window + && ShellState.pointer-x >= flick.absolute-position.x + && ShellState.pointer-x <= flick.absolute-position.x + flick.width + && ShellState.pointer-y >= flick.absolute-position.y + && ShellState.pointer-y <= flick.absolute-position.y + flick.height; + } +} diff --git a/crates/qbz-ui/ui/shell/AppShell.slint b/crates/qbz-ui/ui/shell/AppShell.slint index 5b09a4a31..db7497745 100644 --- a/crates/qbz-ui/ui/shell/AppShell.slint +++ b/crates/qbz-ui/ui/shell/AppShell.slint @@ -55,6 +55,7 @@ import { LyricsSidebar } from "LyricsSidebar.slint"; import { HomeView } from "../discover/HomeView.slint"; import { DiscoverBrowseView } from "../discover/DiscoverBrowseView.slint"; import { RecentAlbumsView } from "../discover/RecentAlbumsView.slint"; +import { MostPlayedAlbumsView } from "../discover/MostPlayedAlbumsView.slint"; import { AlbumPageView } from "../album/AlbumPageView.slint"; import { LocalAlbumView } from "../album/LocalAlbumView.slint"; import { ArtistPageView } from "../artist/ArtistPageView.slint"; @@ -327,6 +328,17 @@ export component AppShell inherits Rectangle { root.media-action(kind, id, action); } } + if NavState.view == ContentView.most-played-albums: MostPlayedAlbumsView { + open-album(id) => { + root.open-album(id); + } + open-artist(id) => { + root.open-artist(id); + } + media-action(kind, id, action) => { + root.media-action(kind, id, action); + } + } if NavState.view == ContentView.album && !OfflineState.offline: AlbumPageView { open-artist(id) => { root.open-artist(id); diff --git a/crates/qbz-ui/ui/state.slint b/crates/qbz-ui/ui/state.slint index 0e7261136..b227a636f 100644 --- a/crates/qbz-ui/ui/state.slint +++ b/crates/qbz-ui/ui/state.slint @@ -34,6 +34,8 @@ export struct AlbumCardItem { quality-detail: string,// "24-bit / 96 kHz" — bare detail for QualityBadgeFull track-count: string, // "12" — TRACKS column plain-year: string, // "1973" — bare year for the list-row YEAR column + plays: int, // play count — shown ONLY in the Most Played Albums + // View-all (0 elsewhere, so no count is drawn). } // One entry in an A-Z jump strip (favorites tracks name-group / albums @@ -211,6 +213,9 @@ export global HomeActions { // "View all" on the Recently Played Albums rail -> the full-page listing // (RecentAlbumsView), fed from the local play-history store. callback open-recent-albums(); + // Opens the full "Most Played Albums" page (MostPlayedAlbumsView), fed + // from the local play-count store. + callback open-most-played-albums(); // Fired by HomeView's init on every (re)mount. Rust re-reads the LOCAL // recently-played store into the two rails IF a play was recorded while // Home was off-screen (dirty-flag gated in Rust — a no-op otherwise, so @@ -233,6 +238,21 @@ export global RecentAlbumsState { in property loading: false; } +// MostPlayedAlbumsView — the full "Most Played Albums" page opened from the +// rail's "View all". Ranked by local play count; each item carries its +// `plays`. `search` filters title/artist client-side (visibility only). +export global MostPlayedAlbumsState { + in property <[AlbumCardItem]> albums: []; + in property loading: false; + in-out property search: ""; +} + +export global MostPlayedAlbumsActions { + // Filter the loaded page by title/artist. Rust re-sets `albums` to the + // matches and re-fires their artwork (mirrors the Qobuz-playlists filter). + callback filter(string); +} + // --------------------------------------------------------------------------- // Discover section configurator (Slice 5) — prefs-driven render loop + modal. // --------------------------------------------------------------------------- @@ -1000,7 +1020,7 @@ export global DragActions { } // Which content view the shell shows. -export enum ContentView { home, album, artist, artist-releases, settings, search, musician, label, label-releases, award, award-albums, location, favorites, mix, playlist, discover-browse, recent-albums, playlist-manager, offline-manager, blacklist-manager, local-library, local-album, mixtapes, collections, mixtape-detail, discography-builder, purchases, purchase-album, now-playing } +export enum ContentView { home, album, artist, artist-releases, settings, search, musician, label, label-releases, award, award-albums, location, favorites, mix, playlist, discover-browse, recent-albums, most-played-albums, playlist-manager, offline-manager, blacklist-manager, local-library, local-album, mixtapes, collections, mixtape-detail, discography-builder, purchases, purchase-album, now-playing } // In-app toast (transient notification). Mirrors Tauri's toastStore: // a single toast at a time (a new one replaces the current), auto-hidden diff --git a/crates/qbz/src/artwork.rs b/crates/qbz/src/artwork.rs index ee3a392de..5352747f3 100644 --- a/crates/qbz/src/artwork.rs +++ b/crates/qbz/src/artwork.rs @@ -70,6 +70,9 @@ pub enum ArtworkTarget { /// model has its own lifecycle, separate from the rail's (same split as /// HomeFavoriteAlbum vs ForYouFavoriteAlbum). RecentAlbumsPage { idx: usize }, + /// A card in `MostPlayedAlbumsState.albums[idx]` — the "Most Played Albums" + /// View-all page. + MostPlayedAlbumsPage { idx: usize }, /// A card in `HomeState.favorite-albums.albums[idx]` — the Home tab's /// "Library Albums" rail (#566). Separate from `ForYouFavoriteAlbum`: /// the two rails share the data pipeline but not the model lifecycle. @@ -938,6 +941,14 @@ fn apply_artwork( item.artwork = image; albums.set_row_data(idx, item); } + ArtworkTarget::MostPlayedAlbumsPage { idx } => { + let albums = window.global::().get_albums(); + let Some(mut item) = albums.row_data(idx) else { + return; + }; + item.artwork = image; + albums.set_row_data(idx, item); + } ArtworkTarget::RecentAlbumsPage { idx } => { let albums = window.global::().get_albums(); let Some(mut item) = albums.row_data(idx) else { diff --git a/crates/qbz/src/main.rs b/crates/qbz/src/main.rs index 7f9b59b72..d94c84ee8 100644 --- a/crates/qbz/src/main.rs +++ b/crates/qbz/src/main.rs @@ -2345,6 +2345,7 @@ fn scope_for(entry: &nav::NavEntry) -> String { nav::NavEntry::LocalLibrary { tab } => format!("ll:{tab}"), nav::NavEntry::DiscoverBrowse { .. } => "discover-browse".into(), nav::NavEntry::RecentAlbums => "recent-albums".into(), + nav::NavEntry::MostPlayedAlbums => "most-played-albums".into(), nav::NavEntry::Mix { .. } => "mix".into(), nav::NavEntry::Playlist(_) => "playlist".into(), nav::NavEntry::PlaylistManager => "playlist-manager".into(), @@ -2529,6 +2530,9 @@ fn apply_entry( nav::NavEntry::RecentAlbums => { navigate_recent_albums(weak.clone(), handle, image_cache.clone()); } + nav::NavEntry::MostPlayedAlbums => { + navigate_most_played_albums(weak.clone(), handle, image_cache.clone()); + } nav::NavEntry::Mix { kind } => { navigate_mix(runtime.clone(), weak.clone(), handle, image_cache.clone(), kind); } @@ -2945,6 +2949,125 @@ fn navigate_recent_albums( }); } +/// Full ranked list for the Most Played Albums View-all, cached so the search +/// box re-filters without re-querying SQLite (mirrors the Qobuz-playlists +/// filter). Written by the navigation, read by the filter. +static MOST_PLAYED_ROWS: std::sync::Mutex< + Vec, +> = std::sync::Mutex::new(Vec::new()); + +/// Map a ranked row to a grid card, carrying its play count (drawn only here; +/// `plays` is 0 on every other AlbumCardItem). +fn most_played_item(row: &qbz_app::settings::album_play_history::AlbumPlayRow) -> AlbumCardItem { + let mut item = home::card_to_item(crate::home::CardData { + id: row.album_id.clone(), + title: row.title.clone(), + artist: row.artist.clone(), + artist_id: row.artist_id.clone(), + year: row.year.clone(), + quality_tier: row.quality_tier.clone(), + quality_label: row.quality_label.clone(), + artwork_url: row.artwork_url.clone(), + source: row.source.clone(), + ..Default::default() + }); + item.plays = row.plays as i32; + item +} + +/// Push ranked rows onto the Most Played Albums page + fire their artwork +/// (Qobuz plain loader vs Plex/local source-aware funnel, like the recent +/// page). Shared by the initial load and the search filter. +fn apply_most_played_page( + weak: &slint::Weak, + image_cache: artwork::ImageCache, + rows: Vec, +) { + let mut jobs: Vec = Vec::new(); + let mut plex_jobs: Vec = Vec::new(); + for (idx, row) in rows.iter().enumerate() { + if row.artwork_url.is_empty() { + continue; + } + let job = artwork::ArtworkJob { + target: artwork::ArtworkTarget::MostPlayedAlbumsPage { idx }, + url: row.artwork_url.clone(), + }; + if row.source == "plex" || row.source == "local" { + plex_jobs.push(job); + } else { + jobs.push(job); + } + } + let weak_for_plex = weak.clone(); + let image_cache_plex = image_cache.clone(); + let _ = weak.clone().upgrade_in_event_loop(move |w| { + let items: Vec = rows.iter().map(most_played_item).collect(); + let s = w.global::(); + s.set_albums(slint::ModelRc::new(slint::VecModel::from(items))); + s.set_loading(false); + }); + artwork::spawn_loads(jobs, weak.clone(), image_cache); + if !plex_jobs.is_empty() { + let plex = crate::plex_settings::get(); + artwork::spawn_local_or_plex_loads( + plex_jobs, + plex.base_url, + plex.token, + weak_for_plex, + image_cache_plex, + ); + } +} + +/// Open the full "Most Played Albums" page: load the ranked list, cache it, +/// render it. Local SQLite read, so no runtime + no error branch. +fn navigate_most_played_albums( + weak: slint::Weak, + handle: &tokio::runtime::Handle, + image_cache: artwork::ImageCache, +) { + handle.spawn(async move { + let _ = weak.upgrade_in_event_loop(|w| { + let s = w.global::(); + s.set_loading(true); + s.set_search("".into()); + s.set_albums(slint::ModelRc::new(slint::VecModel::from( + Vec::::new(), + ))); + w.global::() + .set_view(ContentView::MostPlayedAlbums); + }); + let rows = qbz_app::settings::album_play_history::all_albums(); + *MOST_PLAYED_ROWS.lock().unwrap() = rows.clone(); + apply_most_played_page(&weak, image_cache, rows); + }); +} + +/// Re-filter the cached Most Played list by title/artist and re-render. +fn filter_most_played( + weak: slint::Weak, + image_cache: artwork::ImageCache, + query: String, +) { + let q = query.trim().to_lowercase(); + let rows: Vec<_> = MOST_PLAYED_ROWS + .lock() + .map(|guard| { + guard + .iter() + .filter(|r| { + q.is_empty() + || r.title.to_lowercase().contains(&q) + || r.artist.to_lowercase().contains(&q) + }) + .cloned() + .collect() + }) + .unwrap_or_default(); + apply_most_played_page(&weak, image_cache, rows); +} + /// Set when a play lands in the recently-played store while the Home view is /// not showing, so the next Home mount (`HomeActions.home-mounted`) re-reads /// the LOCAL store into the rails. Cleared by `refresh_recent_rails`. @@ -15253,6 +15376,29 @@ fn main() -> Result<(), Box> { } }); } + { + let weak = window.as_weak(); + let handle = tokio_rt.handle().clone(); + let image_cache = image_cache.clone(); + window + .global::() + .on_open_most_played_albums(move || { + nav::record(nav::NavEntry::MostPlayedAlbums); + navigate_most_played_albums(weak.clone(), &handle, image_cache.clone()); + if let Some(w) = weak.upgrade() { + update_nav_flags(&w); + } + }); + } + { + let weak = window.as_weak(); + let image_cache = image_cache.clone(); + window + .global::() + .on_filter(move |q| { + filter_most_played(weak.clone(), image_cache.clone(), q.to_string()); + }); + } // Recently-played rails refresh. `home-mounted` fires on every HomeView // (re)mount: re-read the LOCAL store into the rails IF a play was recorded diff --git a/crates/qbz/src/nav.rs b/crates/qbz/src/nav.rs index 9c77423d8..e789011a0 100644 --- a/crates/qbz/src/nav.rs +++ b/crates/qbz/src/nav.rs @@ -55,6 +55,9 @@ pub enum NavEntry { /// store (crate::recently), reloaded on every navigation, so the entry /// carries no payload. RecentAlbums, + /// MostPlayedAlbumsView — the full "Most Played Albums" listing, ranked by + /// local play count (album_play_history), reloaded on every navigation. + MostPlayedAlbums, /// A Qobuz mix detail page ("daily" | "weekly" | "fav" | "top"). Mix { kind: String,