feat(slint/discover): DiscoverState global + prefs controller + load/persist
Add the Slice 5 foundation for the Discover section configurator: a single DiscoverState/DiscoverActions global pair owning both the prefs-driven render descriptor lists and the modal payload, plus a thin frontend controller over the headless qbz_app discover_prefs store. - state.slint: SectionDescriptor + ConfigRow structs and the DiscoverState / DiscoverActions globals (active-tab lives here; render loop + modal read it). - app.slint: re-export the new globals/structs so the Rust layer can bind them. - discover_prefs.rs: per-user store lifecycle (init_for_user/teardown mirror fav_cache), in-memory authoritative prefs, descriptor + config-row push helpers, id->kind/label maps, and toggle/move/reset/open/close handlers (mutate -> persist -> re-push -> re-render, re-firing artwork for the active Home/Editor tab). Labels resolve in Rust (English today) since Slint @tr needs a literal key and the gettext pipeline is unwired. - home.rs: add the SectionData.id key; build the Home/Editor ordered descriptor lists from the cached section data (album ids embed their DiscoverSection, fixed ids carry an empty section); rerender_active_tab + descriptor artwork jobs. Empty album sections are dropped (policy b); placeholder-bearing Home sections are kept and gated in the view. - artwork.rs: DiscoverSectionAlbum target so covers paint on the descriptor list (DiscoverState.home-sections / editor-sections) rather than HomeState. - main.rs/auth.rs: mod + seed at both shell entries + per-user init/teardown at every session-activation point + the 5 DiscoverActions callback registrations. Descriptor lists are pushed but not yet rendered (the views still draw the old way); no behavior change until the render loop lands. cc
This commit is contained in:
7 files changed
+639
-9
No files matched your search
@@ -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, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions, VisualizerState, ImmersiveState } from "state.slint";
|
||||
export { HomeState, HomeActions, DiscoverState, DiscoverActions, SectionDescriptor, ConfigRow, 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, VisualizerState, ImmersiveState } 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`.
|
||||
|
||||
@@ -108,6 +108,67 @@ export global HomeActions {
|
||||
callback select-tab(string);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Discover section configurator (Slice 5) — prefs-driven render loop + modal.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// One Discover section as a render-loop descriptor. Rust emits the ordered
|
||||
// ENABLED list per tab (DiscoverState.home-sections / editor-sections /
|
||||
// foryou-sections); each surface iterates and dispatches on `id`
|
||||
// (DiscoverySectionId::as_str). `kind` is a coarse render family used by the
|
||||
// one tab-dependent arm (mostStreamed renders as a slim grid on Home, an album
|
||||
// carousel on Editor's Picks). `section` carries the album-carousel payload for
|
||||
// Home arms that share the Carousel component but have no dedicated HomeState
|
||||
// field (newReleases / pressAwards / idealDiscography / editorPicks /
|
||||
// qobuzissimes / mostStreamed-album / recentlyPlayedAlbums); For You arms read
|
||||
// the typed ForYouState fields by id and ignore `section`.
|
||||
export struct SectionDescriptor {
|
||||
id: string, // "newReleases" | "qobuzPlaylists" | "qobuzMixes" | ...
|
||||
kind: string, // "albumCarousel" | "slimGrid" | "playlistCarousel" | ...
|
||||
section: DiscoverSection,
|
||||
}
|
||||
|
||||
// One row in the configurator modal: a section in the active tab's FULL ordered
|
||||
// list (enabled AND disabled — reorder applies to disabled rows too). `label`
|
||||
// is resolved in Rust from the id->key map (Slint @tr cannot take a runtime
|
||||
// key), returning the English string until the Slint gettext pipeline lands.
|
||||
export struct ConfigRow {
|
||||
id: string,
|
||||
label: string,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
// Single owner of the configurator render-driver lists AND the modal payload.
|
||||
// `active-tab` lives here once (render loop + modal target read it); the Slice-3
|
||||
// tab pill keeps writing HomeState.active-tab and crate::home::select_tab mirrors
|
||||
// it into here (one extra set, no second tab-switch path).
|
||||
export global DiscoverState {
|
||||
// "home" | "editorPicks" | "forYou". home::select_tab writes this.
|
||||
in-out property <string> active-tab: "home";
|
||||
|
||||
// Ordered ENABLED descriptors per tab (Rust recomputes on every mutation +
|
||||
// on tab switch). Per-tab so a tab flip is a pure binding read. When
|
||||
// active-tab is "forYou" the home/editor lists are pushed empty so the Home
|
||||
// repeater renders nothing for that tab (unconditional-repeater form).
|
||||
in property <[SectionDescriptor]> home-sections: [];
|
||||
in property <[SectionDescriptor]> editor-sections: [];
|
||||
in property <[SectionDescriptor]> foryou-sections: [];
|
||||
|
||||
// Configurator modal payload (for the modal's current target = active-tab).
|
||||
in-out property <bool> configurator-open: false;
|
||||
in property <[ConfigRow]> config-rows: []; // FULL list (enabled+disabled).
|
||||
in property <int> enabled-count: 0;
|
||||
in property <int> total-count: 0;
|
||||
}
|
||||
|
||||
export global DiscoverActions {
|
||||
callback open-configurator(); // gear -> opens for active-tab
|
||||
callback close-configurator();
|
||||
callback toggle-section(/* tab */ string, /* id */ string);
|
||||
callback move-section(/* tab */ string, /* id */ string, /* dir -1|+1 */ int);
|
||||
callback reset-tab(/* tab */ string);
|
||||
}
|
||||
|
||||
// Discover "View all" full-list page — one album module (new releases,
|
||||
// qobuzissimes, ...) opened from a Carousel's See-All link. Paginated.
|
||||
export global DiscoverBrowseState {
|
||||
|
||||
Reference in new issue
Block a user