refactor(qbz-qt): phase 23 part 1 — QML module layout + first five domain bridges
Two fronts of the modularization, both gated green before this commit. QML leaves the flat qml/ directory for seven modules: cards, controls, rows, settings, shell, theme, views. Only Main.qml and LoginScreen.qml stay at the root. build.rs matches the tree exactly (55 files), relative imports and asset paths were re-anchored for the new depth. The QbzBridge God-object starts breaking up: QbzSession, QbzShell, QbzPlayer, QbzQueue and QbzHome are now their own #[cxx_qt::bridge] singletons, each with its own OnceLock<CxxQtThread> and ui() hop, booted in order from Main.qml. Bridge files stay directly under src/ because cxx-qt-build only accepts rust_files from one directory (QTBUG-93443). bridge.rs keeps 5.5 domains (library, album/artist, settings, integrations, search, playlist) and dies once they are split out. cc
This commit is contained in:
72 files changed
+2152
-1690
No files matched your search
@@ -272,7 +272,7 @@ pub fn update_for_artwork(artwork_url: &str) {
|
||||
.flatten();
|
||||
if let Some((primary, secondary, accent)) = triad {
|
||||
log::info!("[qbz-qt] ambient palette: {primary} / {secondary} / {accent}");
|
||||
crate::ui(move |mut b| {
|
||||
crate::shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_ambient_primary(QString::from(primary.as_str()));
|
||||
b.as_mut()
|
||||
.set_ambient_secondary(QString::from(secondary.as_str()));
|
||||
|
||||
+4
-784
@@ -17,12 +17,6 @@ pub mod qbz_bridge {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
|
||||
include!("cxx-qt-lib/qvariant.h");
|
||||
type QVariant = cxx_qt_lib::QVariant;
|
||||
|
||||
include!("cxx-qt-lib/qlist.h");
|
||||
type QList_QVariant = cxx_qt_lib::QList<cxx_qt_lib::QVariant>;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
@@ -30,83 +24,6 @@ pub mod qbz_bridge {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// "splash" | "login" | "shell"
|
||||
#[qproperty(QString, screen)]
|
||||
// Login narration: 0 idle / 1 waiting-for-browser / 2 authenticating.
|
||||
#[qproperty(i32, login_phase)]
|
||||
// Last SIGN-IN failure message ("" = none). Mirrors Slint
|
||||
// `LoginState.error`.
|
||||
#[qproperty(QString, login_error)]
|
||||
// Session-RESTORE failure message ("" = none). Mirrors Slint
|
||||
// `OfflineState.login-error`. (The Slint app has two separate fields;
|
||||
// keeping both here so the two login-screen boxes stay distinct.)
|
||||
#[qproperty(QString, restore_error)]
|
||||
// Offline-MODE engine snapshot (Slint `OfflineState`):
|
||||
#[qproperty(bool, offline)]
|
||||
// 0 online / 1 real offline / 2 induced offline.
|
||||
#[qproperty(i32, offline_mode)]
|
||||
// 0 unknown / 1 up / 2 down.
|
||||
#[qproperty(i32, connectivity)]
|
||||
#[qproperty(bool, captive_portal)]
|
||||
#[qproperty(bool, has_previous_session)]
|
||||
#[qproperty(bool, show_recovery_banner)]
|
||||
#[qproperty(bool, offline_session)]
|
||||
// Shell session header:
|
||||
#[qproperty(QString, session_user_name)]
|
||||
#[qproperty(QString, session_subscription)]
|
||||
|
||||
// --- Shell chrome (Slint ShellState) ----------------------------
|
||||
// Three-state sidebar: 0 = open (240px), 1 = mini (64px), 2 = closed.
|
||||
#[qproperty(i32, sidebar_state)]
|
||||
#[qproperty(bool, queue_open)]
|
||||
// Content view id — only "home" exists (phase 3 adds the rest).
|
||||
#[qproperty(QString, current_view)]
|
||||
// Nav history (src/nav_qt.rs):
|
||||
#[qproperty(bool, can_back)]
|
||||
#[qproperty(bool, can_forward)]
|
||||
|
||||
// --- Now playing (Slint NowPlayingState; np_ prefix) ------------
|
||||
// POC: fed by a static NowPlayingModel (src/now_playing.rs) with
|
||||
// empty-state defaults; phase 4 swaps the data source for the real
|
||||
// player poll.
|
||||
#[qproperty(bool, np_has_track)]
|
||||
#[qproperty(QString, np_title)]
|
||||
#[qproperty(QString, np_artist)]
|
||||
#[qproperty(QString, np_artwork_path)]
|
||||
#[qproperty(i32, np_elapsed_secs)]
|
||||
#[qproperty(i32, np_duration_secs)]
|
||||
#[qproperty(f32, np_progress)]
|
||||
#[qproperty(f32, np_cache_progress)]
|
||||
#[qproperty(bool, np_playing)]
|
||||
#[qproperty(bool, np_loading)]
|
||||
#[qproperty(f32, np_volume)]
|
||||
#[qproperty(bool, np_muted)]
|
||||
#[qproperty(bool, np_shuffle)]
|
||||
// 0 off / 1 all / 2 one.
|
||||
#[qproperty(i32, np_repeat_mode)]
|
||||
// "hires" | "mp3" | "lossless" | "cd" (AudioStamp tier mapping).
|
||||
#[qproperty(QString, np_quality_tier)]
|
||||
// e.g. "24-bit / 96 kHz" (AudioStamp detail line).
|
||||
#[qproperty(QString, np_quality_label)]
|
||||
|
||||
// --- Queue panel -------------------------------------------------
|
||||
// POC: empty until phase 4 (QML shows the empty states).
|
||||
#[qproperty(QList_QVariant, queue_model)]
|
||||
|
||||
// --- Discover > Home ---------------------------------------------
|
||||
#[qproperty(bool, home_loading)]
|
||||
#[qproperty(QString, home_error)]
|
||||
// POC-NOTE: the brief's QVariantList-of-QVariantMap shape is not
|
||||
// expressible in cxx-qt-lib 0.7.3 (no QVariantValue impls for
|
||||
// QMap/QList — a QVariant can't hold a nested map/list), so the
|
||||
// sections travel as ONE JSON document; QML JSON.parse()s it into
|
||||
// the exact same {id, title, kind, items:[{...}]} object graph.
|
||||
#[qproperty(QString, home_sections_json)]
|
||||
// Editor's Picks / For You tab section lists (phase 13; same
|
||||
// HomeSection shape, ordered by each tab's discover prefs).
|
||||
#[qproperty(QString, editor_sections_json)]
|
||||
#[qproperty(QString, for_you_sections_json)]
|
||||
|
||||
// --- Library view --------------------------------------------------
|
||||
#[qproperty(bool, library_loading)]
|
||||
#[qproperty(QString, library_error)]
|
||||
@@ -124,83 +41,12 @@ pub mod qbz_bridge {
|
||||
#[qproperty(QString, artist_json)]
|
||||
// The id backing the current "album"/"artist" view ("" = none).
|
||||
#[qproperty(QString, view_param_id)]
|
||||
// Now-playing track id (playing-row indicator in track lists).
|
||||
#[qproperty(QString, np_track_id)]
|
||||
#[qproperty(QString, np_album)]
|
||||
#[qproperty(QString, np_album_id)]
|
||||
#[qproperty(QString, np_artist_id)]
|
||||
// Now-playing bar mode (phase 18): 0 New / 1 Classic / 2 Small /
|
||||
// 3 Large — the ui_prefs npb_mode key, live-switchable.
|
||||
#[qproperty(i32, npb_mode)]
|
||||
// "Show track playing context" pref (Playback settings) — feeds the
|
||||
// SongCard layers icon.
|
||||
#[qproperty(bool, show_context_icon)]
|
||||
|
||||
// --- Theme (phase 19) --------------------------------------------
|
||||
// ONE JSON token document (theme_qt.rs ThemeTokens: 30 colors + 24
|
||||
// alpha tiers + ambient derivations + isDark) — QbzTheme.qml binds
|
||||
// to it, so a theme switch repaints the whole app live (the Slint
|
||||
// theme::push_colors equivalent).
|
||||
#[qproperty(QString, theme_json)]
|
||||
// The persisted ui_prefs theme slug ("oled", "auto", "custom", ...).
|
||||
#[qproperty(QString, theme_slug)]
|
||||
// The dropdown catalog (36 registry themes + Auto/Custom rows).
|
||||
#[qproperty(QString, theme_list_json)]
|
||||
// Dropdown filter: 0 All / 1 Dark / 2 Light (ui_prefs theme_filter).
|
||||
#[qproperty(i32, theme_filter)]
|
||||
// --- i18n (phase 20) ----------------------------------------------
|
||||
// Translation revision: bumped on every live language switch. Every
|
||||
// QML `QbzBridge.tr(msgid, QbzBridge.trRev)` binding depends on it,
|
||||
// so all ~380 call sites re-evaluate through the new catalog.
|
||||
#[qproperty(i32, tr_rev)]
|
||||
|
||||
// --- Lyrics panel (phase 9) ----------------------------------------
|
||||
#[qproperty(bool, lyrics_open)]
|
||||
// One JSON document (lyrics_qt.rs LyricsDoc: status/lines/synced/
|
||||
// provider/error).
|
||||
#[qproperty(QString, lyrics_json)]
|
||||
|
||||
// --- Queue panel (phase 9) -----------------------------------------
|
||||
// One JSON document (queue_qt.rs QueueDoc: current/upcoming/history
|
||||
// + pagination + #442 section markers). Supersedes `queueModel`.
|
||||
#[qproperty(QString, queue_json)]
|
||||
|
||||
// --- Sidebar playlist tree ---------------------------------------
|
||||
// One JSON document: the flattened entries (folders + playlists,
|
||||
// expand/sort/search applied Rust-side — sidebar_qt.rs).
|
||||
#[qproperty(QString, sidebar_json)]
|
||||
#[qproperty(QString, sidebar_sort_by)]
|
||||
#[qproperty(bool, sidebar_sort_asc)]
|
||||
|
||||
// --- Settings (phase 10) -----------------------------------------
|
||||
// One JSON document (settings_qt.rs SettingsDoc: audio + playback
|
||||
// row states, select option lists, output-device groups).
|
||||
#[qproperty(QString, settings_json)]
|
||||
|
||||
// --- Window chrome (phase 12) --------------------------------------
|
||||
// The APPLIED titlebar mode (the ui_prefs `use_system_title_bar`
|
||||
// value read at startup — drives the window flags; never mutated at
|
||||
// runtime, matching the Slint restart semantics).
|
||||
#[qproperty(bool, system_title_bar)]
|
||||
// The PERSISTED pref as it stands NOW (the app-menu check state;
|
||||
// flips live when the user toggles, applies on the next launch).
|
||||
#[qproperty(bool, system_title_bar_pref)]
|
||||
|
||||
// --- Ambient background (phase 14) --------------------------------
|
||||
// 0 = off, 1 = on (the ambient look; the owner's store carries
|
||||
// "ambient"). Live — toggling applies immediately (pure QML
|
||||
// layering). Combined in QML with npHasTrack for the D4 no-track
|
||||
// rule.
|
||||
#[qproperty(i32, ambient_mode)]
|
||||
// Album-art triad (ambient_qt.rs), pushed on track change.
|
||||
#[qproperty(QString, ambient_primary)]
|
||||
#[qproperty(QString, ambient_secondary)]
|
||||
#[qproperty(QString, ambient_accent)]
|
||||
// Look knobs (Slint AppearanceState defaults; QBZ_BG_* env seed).
|
||||
#[qproperty(f32, ambient_dim)]
|
||||
#[qproperty(f32, ambient_surface_alpha)]
|
||||
#[qproperty(f32, ambient_bar_alpha)]
|
||||
|
||||
// --- Search (phase 15) ---------------------------------------------
|
||||
// Cortinilla (live dropdown): open/loading flags, ONE JSON payload
|
||||
// (search_qt.rs CortinillaData: query/top/sections with controller
|
||||
@@ -221,159 +67,14 @@ pub mod qbz_bridge {
|
||||
// rows + ownership/follow/pin/sort/search state).
|
||||
#[qproperty(QString, playlist_json)]
|
||||
|
||||
// --- Drag & drop (phase 17) ----------------------------------------
|
||||
// The shared drag state (DragState in state.slint): the ghost reads
|
||||
// count/title/subtitle + the window-coord pointer; sidebar playlist
|
||||
// rows self-detect the drop via dragX/dragY + over-playlist-id.
|
||||
#[qproperty(bool, drag_active)]
|
||||
#[qproperty(i32, drag_count)]
|
||||
#[qproperty(QString, drag_title)]
|
||||
#[qproperty(QString, drag_subtitle)]
|
||||
#[qproperty(f32, drag_x)]
|
||||
#[qproperty(f32, drag_y)]
|
||||
#[qproperty(QString, drag_over_playlist_id)]
|
||||
|
||||
type QbzBridge = super::QbzBridgeRust;
|
||||
|
||||
/// Called once from Main.qml's Component.onCompleted: registers the
|
||||
/// Qt thread handle and kicks off the boot sequence (offline engine
|
||||
/// start + silent session restore).
|
||||
/// TEMP (phase 23 split): registers the QbzBridge Qt-thread
|
||||
/// hop while the remaining domains still live here. Removed
|
||||
/// when the last domain moves out.
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Login screen primary button: system-browser OAuth (no webview).
|
||||
#[qinvokable]
|
||||
fn sign_in_via_browser(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Cancel link (phase 1): aborts the in-flight OAuth task.
|
||||
#[qinvokable]
|
||||
fn cancel_login(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// "Start offline" link: unauthenticated offline session.
|
||||
#[qinvokable]
|
||||
fn start_offline(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Recovery badge "Sign in": same browser flow.
|
||||
#[qinvokable]
|
||||
fn recovery_login(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Terms-of-Service link: opens the system browser.
|
||||
#[qinvokable]
|
||||
fn open_tos(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Shell logout: back to the login screen.
|
||||
#[qinvokable]
|
||||
fn logout(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// i18n lookup against the shared gettext catalog (qbz-i18n), so the
|
||||
/// QML texts reuse the EXISTING .po translations via the same msgids
|
||||
/// the Slint `@tr()` calls use. `rev` is the trRev binding
|
||||
/// dependency (phase 20) — unused in Rust, it only forces QML
|
||||
/// re-evaluation when the language changes live.
|
||||
#[qinvokable]
|
||||
fn tr(self: &QbzBridge, msgid: QString, rev: i32) -> QString;
|
||||
|
||||
// --- Shell chrome -------------------------------------------------
|
||||
/// Header panel-left button: cycle the sidebar open -> mini ->
|
||||
/// closed -> open (Slint `ShellState.cycle-sidebar()`).
|
||||
#[qinvokable]
|
||||
fn cycle_sidebar(self: Pin<&mut QbzBridge>);
|
||||
/// NPB queue button / queue panel close.
|
||||
#[qinvokable]
|
||||
fn toggle_queue(self: Pin<&mut QbzBridge>);
|
||||
/// Header history buttons.
|
||||
#[qinvokable]
|
||||
fn navigate_back(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn navigate_forward(self: Pin<&mut QbzBridge>);
|
||||
|
||||
// --- Transport (phase 4 wires the player; POC log-and-noop, except
|
||||
// the pure-UI toggles which mutate the NowPlayingModel) -----------
|
||||
#[qinvokable]
|
||||
fn toggle_play(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn next(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn previous(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn seek(self: Pin<&mut QbzBridge>, frac: f32);
|
||||
#[qinvokable]
|
||||
fn set_volume(self: Pin<&mut QbzBridge>, volume: f32);
|
||||
#[qinvokable]
|
||||
fn toggle_mute(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn toggle_shuffle(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn cycle_repeat(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Home view retry button / manual refresh: refetch the discover
|
||||
/// index + rails and republish `homeSectionsJson`.
|
||||
#[qinvokable]
|
||||
fn reload_home(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Album-card click on Home: resolve the album's tracks, enqueue,
|
||||
/// and play through the core's resolved path.
|
||||
#[qinvokable]
|
||||
fn play_album(self: Pin<&mut QbzBridge>, album_id: QString);
|
||||
|
||||
/// AlbumView header Shuffle.
|
||||
#[qinvokable]
|
||||
fn play_album_shuffled(self: Pin<&mut QbzBridge>, album_id: QString);
|
||||
/// AlbumView row play: the album starting AT this track.
|
||||
#[qinvokable]
|
||||
fn play_album_from(self: Pin<&mut QbzBridge>, album_id: QString, track_id: QString);
|
||||
/// AlbumView row "Play next" ("next") / "Add to queue" ("later").
|
||||
#[qinvokable]
|
||||
fn enqueue_album_track(self: Pin<&mut QbzBridge>, album_id: QString, track_id: QString, mode: QString);
|
||||
/// ArtistView Popular Tracks row play (whole list as the queue).
|
||||
#[qinvokable]
|
||||
fn play_artist_track(self: Pin<&mut QbzBridge>, track_id: QString);
|
||||
/// ArtistView "Play all" (shuffle=false) / "Shuffle all" (true).
|
||||
#[qinvokable]
|
||||
fn play_artist_top(self: Pin<&mut QbzBridge>, shuffle: bool);
|
||||
/// ArtistView ⋯ "Add all to queue" — appends the top-tracks queue.
|
||||
#[qinvokable]
|
||||
fn enqueue_artist_top(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// NPB lyrics button / lyrics panel close X.
|
||||
#[qinvokable]
|
||||
fn toggle_lyrics(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Queue panel: tabs/pagination/search.
|
||||
#[qinvokable]
|
||||
fn queue_set_page(self: Pin<&mut QbzBridge>, page: i32);
|
||||
#[qinvokable]
|
||||
fn queue_set_search(self: Pin<&mut QbzBridge>, query: QString);
|
||||
/// Row actions.
|
||||
#[qinvokable]
|
||||
fn queue_play_upcoming(self: Pin<&mut QbzBridge>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_remove_upcoming(self: Pin<&mut QbzBridge>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_remove_all_after(self: Pin<&mut QbzBridge>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_move_track(self: Pin<&mut QbzBridge>, from: i32, to: i32);
|
||||
#[qinvokable]
|
||||
fn queue_play_history(self: Pin<&mut QbzBridge>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_toggle_favorite(self: Pin<&mut QbzBridge>, kind: QString, id: QString);
|
||||
/// Footer: Clear queue.
|
||||
#[qinvokable]
|
||||
fn queue_clear(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Sidebar navigation: record a content view ("home" | "library")
|
||||
/// and lazy-load its data on first visit.
|
||||
#[qinvokable]
|
||||
fn navigate_to(self: Pin<&mut QbzBridge>, view: QString);
|
||||
|
||||
/// Track-row click (Library): play the track as a 1-element queue.
|
||||
#[qinvokable]
|
||||
fn play_track(self: Pin<&mut QbzBridge>, track_id: QString);
|
||||
/// Library track context menus: Play next ("next") / Play later
|
||||
/// ("later") / Add to queue ("queue") on a single feed track.
|
||||
#[qinvokable]
|
||||
fn enqueue_track(self: Pin<&mut QbzBridge>, track_id: QString, mode: QString);
|
||||
|
||||
/// Library retry button / manual refresh.
|
||||
#[qinvokable]
|
||||
fn reload_library(self: Pin<&mut QbzBridge>);
|
||||
@@ -400,10 +101,6 @@ pub mod qbz_bridge {
|
||||
#[qsignal]
|
||||
fn library_favorite_changed(self: Pin<&mut QbzBridge>, key: QString, value: bool);
|
||||
|
||||
/// AlbumCard ⋯ menu: Play next ("next") / Add to queue ("later").
|
||||
#[qinvokable]
|
||||
fn enqueue_album(self: Pin<&mut QbzBridge>, album_id: QString, mode: QString);
|
||||
|
||||
/// AlbumCard pin badge: toggle pin (album/artist/playlist).
|
||||
#[qinvokable]
|
||||
fn toggle_pin(self: Pin<&mut QbzBridge>, kind: QString, id: QString, title: QString, subtitle: QString, artwork_url: QString);
|
||||
@@ -411,25 +108,6 @@ pub mod qbz_bridge {
|
||||
#[qsignal]
|
||||
fn pin_changed(self: Pin<&mut QbzBridge>, key: QString, value: bool);
|
||||
|
||||
/// Sidebar tree: rebuild + republish after load / sort / search /
|
||||
/// folder toggle.
|
||||
#[qinvokable]
|
||||
fn reload_sidebar(self: Pin<&mut QbzBridge>);
|
||||
#[qinvokable]
|
||||
fn sidebar_set_sort(self: Pin<&mut QbzBridge>, option: QString);
|
||||
#[qinvokable]
|
||||
fn sidebar_search(self: Pin<&mut QbzBridge>, query: QString);
|
||||
#[qinvokable]
|
||||
fn sidebar_toggle_folder(self: Pin<&mut QbzBridge>, id: QString);
|
||||
/// Sidebar "+" — create an empty playlist (single core call), then
|
||||
/// reload the tree.
|
||||
#[qinvokable]
|
||||
fn create_playlist(self: Pin<&mut QbzBridge>);
|
||||
/// Sidebar cover dispatch: JSON array of cover URLS (the tree's
|
||||
/// collage is url-keyed, unlike the feed's artKey).
|
||||
#[qinvokable]
|
||||
fn sidebar_artwork_window(self: Pin<&mut QbzBridge>, urls_json: QString);
|
||||
|
||||
/// Open the album detail view (pushes "album" on the nav stack).
|
||||
#[qinvokable]
|
||||
fn open_album(self: Pin<&mut QbzBridge>, album_id: QString);
|
||||
@@ -439,15 +117,6 @@ pub mod qbz_bridge {
|
||||
/// ArtistView per-section "Load more" — the next releases page.
|
||||
#[qinvokable]
|
||||
fn load_release_section(self: Pin<&mut QbzBridge>, artist_id: QString, release_type: QString, offset: i32);
|
||||
/// Artist-card overlay play (ArtistGridCard): Popular tracks,
|
||||
/// falling back to the studio discography (playback.rs play_artist).
|
||||
#[qinvokable]
|
||||
fn play_artist_card(self: Pin<&mut QbzBridge>, artist_id: QString);
|
||||
/// Now-Playing-view flyout: switch the bar mode (0 New / 1 Classic /
|
||||
/// 2 Small / 3 Large) — persists ui_prefs.npb_mode; Large forces the
|
||||
/// sidebar open (the Slint "large" arm).
|
||||
#[qinvokable]
|
||||
fn npb_set_mode(self: Pin<&mut QbzBridge>, mode: i32);
|
||||
/// Emitted with the next page of a releases bucket.
|
||||
#[qsignal]
|
||||
fn release_section_ready(self: Pin<&mut QbzBridge>, release_type: QString, cards_json: QString, has_more: bool);
|
||||
@@ -473,33 +142,12 @@ pub mod qbz_bridge {
|
||||
#[qinvokable]
|
||||
fn refresh_devices(self: Pin<&mut QbzBridge>);
|
||||
|
||||
// --- Theme (phase 19) ---------------------------------------------
|
||||
/// Appearance > Theme row: persist the picked slug + republish
|
||||
/// `themeJson` (live switch).
|
||||
#[qinvokable]
|
||||
fn theme_set(self: Pin<&mut QbzBridge>, slug: QString);
|
||||
/// Appearance > theme filter cycle button (0 All / 1 Dark / 2 Light).
|
||||
#[qinvokable]
|
||||
fn theme_set_filter(self: Pin<&mut QbzBridge>, index: i32);
|
||||
|
||||
// --- Integrations (phase 19) ---------------------------------------
|
||||
/// Non-toggle integration actions (integrations_qt.rs): Last.fm
|
||||
/// connect/open-auth-url/finish/disconnect, ListenBrainz disconnect.
|
||||
#[qinvokable]
|
||||
fn integrations_action(self: Pin<&mut QbzBridge>, action: QString);
|
||||
|
||||
/// App-menu chrome toggle: flip the persisted `use_system_title_bar`
|
||||
/// pref (applies on the next launch — the window flags are fixed at
|
||||
/// creation, 1:1 Slint). Updates `systemTitleBarPref` only.
|
||||
#[qinvokable]
|
||||
fn toggle_system_title_bar(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// App-menu ambient toggle: flip the persisted `app_background` pref
|
||||
/// off <-> "ambient" and apply LIVE (pure QML layering — no restart,
|
||||
/// unlike the titlebar).
|
||||
#[qinvokable]
|
||||
fn toggle_ambient_background(self: Pin<&mut QbzBridge>);
|
||||
|
||||
// --- Search (phase 15) ---------------------------------------------
|
||||
/// Header field keystrokes (QML-debounced 220ms, >= 2 chars): drive
|
||||
/// the cortinilla live query.
|
||||
@@ -572,25 +220,8 @@ pub mod qbz_bridge {
|
||||
#[qinvokable]
|
||||
fn playlist_reorder(self: Pin<&mut QbzBridge>, from: i32, slot: i32);
|
||||
|
||||
// --- Drag & drop (phase 17) ----------------------------------------
|
||||
/// Track-row press-drag start (row id, ghost texts, window coords).
|
||||
#[qinvokable]
|
||||
fn drag_start(self: Pin<&mut QbzBridge>, track_id: QString, title: QString, subtitle: QString, x: f32, y: f32);
|
||||
#[qinvokable]
|
||||
fn drag_move(self: Pin<&mut QbzBridge>, x: f32, y: f32);
|
||||
/// A sidebar playlist row claims / releases the drop target.
|
||||
#[qinvokable]
|
||||
fn drag_set_over(self: Pin<&mut QbzBridge>, playlist_id: QString);
|
||||
/// Release: add the dragged track(s) to the over-playlist target.
|
||||
#[qinvokable]
|
||||
fn drag_end(self: Pin<&mut QbzBridge>);
|
||||
|
||||
/// Card-level playlist actions (LibPlaylistCard overlay + menu).
|
||||
#[qinvokable]
|
||||
fn play_playlist_by_id(self: Pin<&mut QbzBridge>, playlist_id: QString);
|
||||
#[qinvokable]
|
||||
fn enqueue_playlist_by_id(self: Pin<&mut QbzBridge>, playlist_id: QString, mode: QString);
|
||||
#[qinvokable]
|
||||
fn playlist_set_follow_by_id(self: Pin<&mut QbzBridge>, playlist_id: QString, follow: bool);
|
||||
}
|
||||
|
||||
@@ -600,90 +231,22 @@ pub mod qbz_bridge {
|
||||
use core::pin::Pin;
|
||||
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::{QList, QString, QVariant};
|
||||
|
||||
type QListQVariant = QList<QVariant>;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
/// Rust side of the bridge. All fields are driven exclusively through the
|
||||
/// generated `set_*` methods on the Qt thread; the struct itself is plain
|
||||
/// storage (as required by cxx-qt's Default-constructed qobjects).
|
||||
pub struct QbzBridgeRust {
|
||||
screen: QString,
|
||||
login_phase: i32,
|
||||
login_error: QString,
|
||||
restore_error: QString,
|
||||
offline: bool,
|
||||
offline_mode: i32,
|
||||
connectivity: i32,
|
||||
captive_portal: bool,
|
||||
has_previous_session: bool,
|
||||
show_recovery_banner: bool,
|
||||
offline_session: bool,
|
||||
session_user_name: QString,
|
||||
session_subscription: QString,
|
||||
sidebar_state: i32,
|
||||
queue_open: bool,
|
||||
current_view: QString,
|
||||
can_back: bool,
|
||||
can_forward: bool,
|
||||
np_has_track: bool,
|
||||
np_title: QString,
|
||||
np_artist: QString,
|
||||
np_artwork_path: QString,
|
||||
np_elapsed_secs: i32,
|
||||
np_duration_secs: i32,
|
||||
np_progress: f32,
|
||||
np_cache_progress: f32,
|
||||
np_playing: bool,
|
||||
np_loading: bool,
|
||||
np_volume: f32,
|
||||
np_muted: bool,
|
||||
np_shuffle: bool,
|
||||
np_repeat_mode: i32,
|
||||
np_quality_tier: QString,
|
||||
np_quality_label: QString,
|
||||
queue_model: QListQVariant,
|
||||
home_loading: bool,
|
||||
home_error: QString,
|
||||
home_sections_json: QString,
|
||||
editor_sections_json: QString,
|
||||
for_you_sections_json: QString,
|
||||
library_loading: bool,
|
||||
library_error: QString,
|
||||
library_json: QString,
|
||||
library_counts_json: QString,
|
||||
sidebar_json: QString,
|
||||
sidebar_sort_by: QString,
|
||||
sidebar_sort_asc: bool,
|
||||
album_loading: bool,
|
||||
album_json: QString,
|
||||
artist_loading: bool,
|
||||
artist_json: QString,
|
||||
view_param_id: QString,
|
||||
np_track_id: QString,
|
||||
np_album: QString,
|
||||
np_album_id: QString,
|
||||
np_artist_id: QString,
|
||||
npb_mode: i32,
|
||||
show_context_icon: bool,
|
||||
theme_json: QString,
|
||||
theme_slug: QString,
|
||||
theme_list_json: QString,
|
||||
theme_filter: i32,
|
||||
tr_rev: i32,
|
||||
queue_json: QString,
|
||||
lyrics_open: bool,
|
||||
lyrics_json: QString,
|
||||
settings_json: QString,
|
||||
system_title_bar: bool,
|
||||
system_title_bar_pref: bool,
|
||||
ambient_mode: i32,
|
||||
ambient_primary: QString,
|
||||
ambient_secondary: QString,
|
||||
ambient_accent: QString,
|
||||
ambient_dim: f32,
|
||||
ambient_surface_alpha: f32,
|
||||
ambient_bar_alpha: f32,
|
||||
cortinilla_open: bool,
|
||||
cortinilla_loading: bool,
|
||||
cortinilla_json: QString,
|
||||
@@ -692,96 +255,21 @@ pub struct QbzBridgeRust {
|
||||
search_json: QString,
|
||||
intelligent_search: bool,
|
||||
playlist_json: QString,
|
||||
drag_active: bool,
|
||||
drag_count: i32,
|
||||
drag_title: QString,
|
||||
drag_subtitle: QString,
|
||||
drag_x: f32,
|
||||
drag_y: f32,
|
||||
drag_over_playlist_id: QString,
|
||||
}
|
||||
|
||||
impl Default for QbzBridgeRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
screen: QString::from("splash"),
|
||||
current_view: QString::from("home"),
|
||||
// A derive would zero these — the model's sane defaults instead.
|
||||
np_volume: 1.0,
|
||||
np_quality_tier: QString::from("cd"),
|
||||
login_phase: 0,
|
||||
login_error: QString::default(),
|
||||
restore_error: QString::default(),
|
||||
offline: false,
|
||||
offline_mode: 0,
|
||||
connectivity: 0,
|
||||
captive_portal: false,
|
||||
has_previous_session: false,
|
||||
show_recovery_banner: false,
|
||||
offline_session: false,
|
||||
session_user_name: QString::default(),
|
||||
session_subscription: QString::default(),
|
||||
sidebar_state: 0,
|
||||
queue_open: false,
|
||||
can_back: false,
|
||||
can_forward: false,
|
||||
np_has_track: false,
|
||||
np_title: QString::default(),
|
||||
np_artist: QString::default(),
|
||||
np_artwork_path: QString::default(),
|
||||
np_elapsed_secs: 0,
|
||||
np_duration_secs: 0,
|
||||
np_progress: 0.0,
|
||||
np_cache_progress: 0.0,
|
||||
np_playing: false,
|
||||
np_loading: false,
|
||||
np_muted: false,
|
||||
np_shuffle: false,
|
||||
np_repeat_mode: 0,
|
||||
np_quality_label: QString::default(),
|
||||
queue_model: QListQVariant::default(),
|
||||
home_loading: false,
|
||||
home_error: QString::default(),
|
||||
home_sections_json: QString::from("[]"),
|
||||
editor_sections_json: QString::from("[]"),
|
||||
for_you_sections_json: QString::from("[]"),
|
||||
library_loading: false,
|
||||
library_error: QString::default(),
|
||||
library_json: QString::from("[]"),
|
||||
library_counts_json: QString::from("{}"),
|
||||
sidebar_json: QString::from("[]"),
|
||||
sidebar_sort_by: QString::from("name"),
|
||||
sidebar_sort_asc: true,
|
||||
album_loading: false,
|
||||
album_json: QString::from("{}"),
|
||||
artist_loading: false,
|
||||
artist_json: QString::from("{}"),
|
||||
view_param_id: QString::default(),
|
||||
np_track_id: QString::default(),
|
||||
np_album: QString::default(),
|
||||
np_album_id: QString::default(),
|
||||
np_artist_id: QString::default(),
|
||||
npb_mode: crate::settings_qt::npb_mode_index(),
|
||||
show_context_icon: crate::settings_qt::show_context_icon(),
|
||||
theme_json: QString::from(crate::theme_qt::theme_json().as_str()),
|
||||
theme_slug: QString::from(crate::theme_qt::current_slug().as_str()),
|
||||
theme_list_json: QString::from(crate::theme_qt::theme_list_json().as_str()),
|
||||
theme_filter: crate::theme_qt::theme_filter(),
|
||||
tr_rev: 0,
|
||||
queue_json: QString::from("{}"),
|
||||
lyrics_open: false,
|
||||
lyrics_json: QString::from("{}"),
|
||||
settings_json: QString::from("{}"),
|
||||
system_title_bar: crate::settings_qt::use_system_title_bar(),
|
||||
system_title_bar_pref: crate::settings_qt::use_system_title_bar(),
|
||||
ambient_mode: crate::settings_qt::app_background_mode(),
|
||||
// The Slint ImmersiveState default triad (pre-artwork colors).
|
||||
ambient_primary: QString::from("#00dcc8"),
|
||||
ambient_secondary: QString::from("#9632ff"),
|
||||
ambient_accent: QString::from("#3fd9c8"),
|
||||
ambient_dim: crate::settings_qt::ambient_dim(),
|
||||
ambient_surface_alpha: crate::settings_qt::ambient_surface_alpha(),
|
||||
ambient_bar_alpha: crate::settings_qt::ambient_bar_alpha(),
|
||||
cortinilla_open: false,
|
||||
cortinilla_loading: false,
|
||||
cortinilla_json: QString::from("{}"),
|
||||
@@ -790,201 +278,13 @@ impl Default for QbzBridgeRust {
|
||||
search_json: QString::from("{}"),
|
||||
intelligent_search: crate::search_qt::intelligent_search_pref(),
|
||||
playlist_json: QString::from("{}"),
|
||||
drag_active: false,
|
||||
drag_count: 0,
|
||||
drag_title: QString::default(),
|
||||
drag_subtitle: QString::default(),
|
||||
drag_x: 0.0,
|
||||
drag_y: 0.0,
|
||||
drag_over_playlist_id: QString::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_bridge::QbzBridge {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
// The very first invokable: hand the Qt-thread handle to the process
|
||||
// global so tokio tasks can queue property updates back here.
|
||||
crate::register_qt_thread(self.qt_thread());
|
||||
crate::on_boot();
|
||||
}
|
||||
|
||||
pub fn sign_in_via_browser(self: Pin<&mut Self>) {
|
||||
crate::start_login();
|
||||
}
|
||||
|
||||
pub fn cancel_login(self: Pin<&mut Self>) {
|
||||
crate::cancel_login();
|
||||
}
|
||||
|
||||
pub fn start_offline(self: Pin<&mut Self>) {
|
||||
crate::start_offline();
|
||||
}
|
||||
|
||||
pub fn recovery_login(self: Pin<&mut Self>) {
|
||||
crate::start_login();
|
||||
}
|
||||
|
||||
pub fn open_tos(self: Pin<&mut Self>) {
|
||||
// Same URL the Slint shell opens (crates/qbz/src/main.rs
|
||||
// QOBUZ_TOS_URL). `open` spawns xdg-open detached, so this is safe to
|
||||
// run on the Qt thread.
|
||||
if let Err(e) = open::that(crate::QOBUZ_TOS_URL) {
|
||||
log::error!("[qbz-qt] failed to open Terms of Service: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn logout(self: Pin<&mut Self>) {
|
||||
crate::do_logout();
|
||||
}
|
||||
|
||||
pub fn tr(&self, msgid: QString, rev: i32) -> QString {
|
||||
let _ = rev; // binding dependency only (see the bridge declaration)
|
||||
QString::from(&qbz_i18n::t(&msgid.to_string()))
|
||||
}
|
||||
|
||||
pub fn cycle_sidebar(mut self: Pin<&mut Self>) {
|
||||
let next = (self.sidebar_state() + 1) % 3;
|
||||
self.as_mut().set_sidebar_state(next);
|
||||
}
|
||||
|
||||
pub fn toggle_queue(mut self: Pin<&mut Self>) {
|
||||
let next = !self.queue_open();
|
||||
self.as_mut().set_queue_open(next);
|
||||
}
|
||||
|
||||
pub fn navigate_back(self: Pin<&mut Self>) {
|
||||
crate::nav_qt::back();
|
||||
}
|
||||
|
||||
pub fn navigate_forward(self: Pin<&mut Self>) {
|
||||
crate::nav_qt::forward();
|
||||
}
|
||||
|
||||
pub fn toggle_play(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_play();
|
||||
}
|
||||
|
||||
pub fn next(self: Pin<&mut Self>) {
|
||||
crate::transport_next();
|
||||
}
|
||||
|
||||
pub fn previous(self: Pin<&mut Self>) {
|
||||
crate::transport_previous();
|
||||
}
|
||||
|
||||
pub fn seek(self: Pin<&mut Self>, frac: f32) {
|
||||
crate::transport_seek(frac);
|
||||
}
|
||||
|
||||
pub fn set_volume(self: Pin<&mut Self>, volume: f32) {
|
||||
crate::transport_set_volume(volume);
|
||||
}
|
||||
|
||||
pub fn toggle_mute(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_mute();
|
||||
}
|
||||
|
||||
pub fn toggle_shuffle(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_shuffle();
|
||||
}
|
||||
|
||||
pub fn cycle_repeat(self: Pin<&mut Self>) {
|
||||
crate::transport_cycle_repeat();
|
||||
}
|
||||
|
||||
pub fn reload_home(self: Pin<&mut Self>) {
|
||||
crate::reload_home();
|
||||
}
|
||||
|
||||
pub fn play_album(self: Pin<&mut Self>, album_id: QString) {
|
||||
crate::play_album(album_id.to_string());
|
||||
}
|
||||
|
||||
pub fn queue_set_page(self: Pin<&mut Self>, page: i32) {
|
||||
crate::queue_set_page(page);
|
||||
}
|
||||
|
||||
pub fn queue_set_search(self: Pin<&mut Self>, query: QString) {
|
||||
crate::queue_set_search(query.to_string());
|
||||
}
|
||||
|
||||
pub fn queue_play_upcoming(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_play_upcoming(index);
|
||||
}
|
||||
|
||||
pub fn queue_remove_upcoming(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_remove_upcoming(index);
|
||||
}
|
||||
|
||||
pub fn queue_remove_all_after(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_remove_all_after(index);
|
||||
}
|
||||
|
||||
pub fn queue_move_track(self: Pin<&mut Self>, from: i32, to: i32) {
|
||||
crate::queue_move_track(from, to);
|
||||
}
|
||||
|
||||
pub fn queue_play_history(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_play_history(index);
|
||||
}
|
||||
|
||||
pub fn queue_toggle_favorite(self: Pin<&mut Self>, kind: QString, id: QString) {
|
||||
crate::queue_toggle_favorite(kind.to_string(), id.to_string());
|
||||
}
|
||||
|
||||
pub fn queue_clear(self: Pin<&mut Self>) {
|
||||
crate::queue_clear();
|
||||
}
|
||||
|
||||
pub fn toggle_lyrics(self: Pin<&mut Self>) {
|
||||
crate::toggle_lyrics();
|
||||
}
|
||||
|
||||
pub fn play_album_shuffled(self: Pin<&mut Self>, album_id: QString) {
|
||||
crate::play_album_shuffled(album_id.to_string());
|
||||
}
|
||||
|
||||
pub fn play_album_from(self: Pin<&mut Self>, album_id: QString, track_id: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_album_from_track(album_id.to_string(), tid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_album_track(self: Pin<&mut Self>, album_id: QString, track_id: QString, mode: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_album_track(album_id.to_string(), tid, mode.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_artist_track(self: Pin<&mut Self>, track_id: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_artist_track(tid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_artist_top(self: Pin<&mut Self>, shuffle: bool) {
|
||||
crate::play_artist_top(shuffle);
|
||||
}
|
||||
|
||||
pub fn enqueue_artist_top(self: Pin<&mut Self>) {
|
||||
crate::enqueue_artist_top();
|
||||
}
|
||||
|
||||
pub fn navigate_to(self: Pin<&mut Self>, view: QString) {
|
||||
crate::navigate_to(&view.to_string());
|
||||
}
|
||||
|
||||
pub fn play_track(self: Pin<&mut Self>, track_id: QString) {
|
||||
if let Ok(id) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_track(id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_track(self: Pin<&mut Self>, track_id: QString, mode: QString) {
|
||||
if let Ok(id) = track_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_track(id, mode.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reload_library(self: Pin<&mut Self>) {
|
||||
@@ -999,10 +299,6 @@ impl qbz_bridge::QbzBridge {
|
||||
crate::library_toggle_favorite(kind.to_string(), id.to_string());
|
||||
}
|
||||
|
||||
pub fn enqueue_album(self: Pin<&mut Self>, album_id: QString, mode: QString) {
|
||||
crate::enqueue_album(album_id.to_string(), mode.to_string());
|
||||
}
|
||||
|
||||
pub fn toggle_pin(self: Pin<&mut Self>, kind: QString, id: QString, title: QString, subtitle: QString, artwork_url: QString) {
|
||||
crate::toggle_pin(
|
||||
kind.to_string(),
|
||||
@@ -1013,30 +309,6 @@ impl qbz_bridge::QbzBridge {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn reload_sidebar(self: Pin<&mut Self>) {
|
||||
crate::reload_sidebar();
|
||||
}
|
||||
|
||||
pub fn sidebar_set_sort(self: Pin<&mut Self>, option: QString) {
|
||||
crate::sidebar_set_sort(&option.to_string());
|
||||
}
|
||||
|
||||
pub fn sidebar_search(self: Pin<&mut Self>, query: QString) {
|
||||
crate::sidebar_set_search(&query.to_string());
|
||||
}
|
||||
|
||||
pub fn sidebar_toggle_folder(self: Pin<&mut Self>, id: QString) {
|
||||
crate::sidebar_toggle_folder(&id.to_string());
|
||||
}
|
||||
|
||||
pub fn create_playlist(self: Pin<&mut Self>) {
|
||||
crate::create_playlist();
|
||||
}
|
||||
|
||||
pub fn sidebar_artwork_window(self: Pin<&mut Self>, urls_json: QString) {
|
||||
crate::sidebar_artwork_window(urls_json.to_string());
|
||||
}
|
||||
|
||||
pub fn open_album(self: Pin<&mut Self>, album_id: QString) {
|
||||
crate::open_album(album_id.to_string());
|
||||
}
|
||||
@@ -1049,22 +321,6 @@ impl qbz_bridge::QbzBridge {
|
||||
crate::load_release_section(artist_id.to_string(), release_type.to_string(), offset);
|
||||
}
|
||||
|
||||
pub fn play_artist_card(self: Pin<&mut Self>, artist_id: QString) {
|
||||
crate::play_artist_card(artist_id.to_string());
|
||||
}
|
||||
|
||||
pub fn npb_set_mode(self: Pin<&mut Self>, mode: i32) {
|
||||
crate::npb_set_mode(mode);
|
||||
}
|
||||
|
||||
pub fn theme_set(self: Pin<&mut Self>, slug: QString) {
|
||||
crate::theme_set(slug.to_string());
|
||||
}
|
||||
|
||||
pub fn theme_set_filter(self: Pin<&mut Self>, index: i32) {
|
||||
crate::theme_set_filter(index);
|
||||
}
|
||||
|
||||
pub fn integrations_action(self: Pin<&mut Self>, action: QString) {
|
||||
crate::integrations_action(action.to_string());
|
||||
}
|
||||
@@ -1093,14 +349,6 @@ impl qbz_bridge::QbzBridge {
|
||||
crate::refresh_devices();
|
||||
}
|
||||
|
||||
pub fn toggle_system_title_bar(self: Pin<&mut Self>) {
|
||||
crate::toggle_system_title_bar();
|
||||
}
|
||||
|
||||
pub fn toggle_ambient_background(self: Pin<&mut Self>) {
|
||||
crate::toggle_ambient_background();
|
||||
}
|
||||
|
||||
pub fn search_live(self: Pin<&mut Self>, query: QString) {
|
||||
crate::search_live(query.to_string());
|
||||
}
|
||||
@@ -1205,34 +453,6 @@ impl qbz_bridge::QbzBridge {
|
||||
crate::playlist_qt::reorder_track(from.max(0) as usize, slot.max(0) as usize);
|
||||
}
|
||||
|
||||
pub fn drag_start(self: Pin<&mut Self>, track_id: QString, title: QString, subtitle: QString, x: f32, y: f32) {
|
||||
crate::drag_start(track_id.to_string(), title.to_string(), subtitle.to_string(), x, y);
|
||||
}
|
||||
|
||||
pub fn drag_move(self: Pin<&mut Self>, x: f32, y: f32) {
|
||||
crate::drag_move(x, y);
|
||||
}
|
||||
|
||||
pub fn drag_set_over(self: Pin<&mut Self>, playlist_id: QString) {
|
||||
crate::drag_set_over(playlist_id.to_string());
|
||||
}
|
||||
|
||||
pub fn drag_end(self: Pin<&mut Self>) {
|
||||
crate::drag_end();
|
||||
}
|
||||
|
||||
pub fn play_playlist_by_id(self: Pin<&mut Self>, playlist_id: QString) {
|
||||
if let Ok(pid) = playlist_id.to_string().parse::<u64>() {
|
||||
crate::play_playlist_by_id(pid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_playlist_by_id(self: Pin<&mut Self>, playlist_id: QString, mode: QString) {
|
||||
if let Ok(pid) = playlist_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_playlist_by_id(pid, mode.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn playlist_set_follow_by_id(self: Pin<&mut Self>, playlist_id: QString, follow: bool) {
|
||||
if let Ok(pid) = playlist_id.to_string().parse::<u64>() {
|
||||
crate::playlist_set_follow_by_id(pid, follow);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
//! QbzHome — Discover > Home domain bridge (phase 23 split of the QbzBridge
|
||||
//! God-object; the pattern is documented in main.rs). Props: the three tab
|
||||
//! section documents + loading/error. Invokable: reloadHome (the retry
|
||||
//! button / manual refresh).
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use cxx_qt::CxxQtThread;
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qbz_home {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// --- Discover > Home ---------------------------------------------
|
||||
#[qproperty(bool, home_loading)]
|
||||
#[qproperty(QString, home_error)]
|
||||
// POC-NOTE: the brief's QVariantList-of-QVariantMap shape is not
|
||||
// expressible in cxx-qt-lib 0.7.3 (no QVariantValue impls for
|
||||
// QMap/QList — a QVariant can't hold a nested map/list), so the
|
||||
// sections travel as ONE JSON document; QML JSON.parse()s it into
|
||||
// the exact same {id, title, kind, items:[{...}]} object graph.
|
||||
#[qproperty(QString, home_sections_json)]
|
||||
// Editor's Picks / For You tab section lists (phase 13; same
|
||||
// HomeSection shape, ordered by each tab's discover prefs).
|
||||
#[qproperty(QString, editor_sections_json)]
|
||||
#[qproperty(QString, for_you_sections_json)]
|
||||
|
||||
type QbzHome = super::QbzHomeRust;
|
||||
|
||||
/// Registers this object's Qt-thread hop (Main.qml boots EVERY
|
||||
/// domain singleton; only QbzSession.boot also fires crate::on_boot).
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzHome>);
|
||||
|
||||
/// Home view retry button / manual refresh: refetch the discover
|
||||
/// index + rails and republish `homeSectionsJson`.
|
||||
#[qinvokable]
|
||||
fn reload_home(self: Pin<&mut QbzHome>);
|
||||
}
|
||||
|
||||
impl cxx_qt::Threading for QbzHome {}
|
||||
}
|
||||
|
||||
use qbz_home::QbzHome;
|
||||
|
||||
/// Rust side of the home bridge (plain storage, phase-1 pattern).
|
||||
pub struct QbzHomeRust {
|
||||
home_loading: bool,
|
||||
home_error: QString,
|
||||
home_sections_json: QString,
|
||||
editor_sections_json: QString,
|
||||
for_you_sections_json: QString,
|
||||
}
|
||||
|
||||
impl Default for QbzHomeRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
home_loading: false,
|
||||
home_error: QString::default(),
|
||||
home_sections_json: QString::from("[]"),
|
||||
editor_sections_json: QString::from("[]"),
|
||||
for_you_sections_json: QString::from("[]"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The UI hop (bridges/mod.rs pattern)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QT_THREAD: OnceLock<CxxQtThread<QbzHome>> = OnceLock::new();
|
||||
|
||||
/// Queue a home-bridge mutation onto the Qt event loop (no-op before
|
||||
/// boot registers the thread).
|
||||
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzHome>) + Send + 'static) {
|
||||
if let Some(thread) = QT_THREAD.get() {
|
||||
let _ = thread.queue(f);
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_home::QbzHome {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
log::warn!("[qbz-qt] home Qt thread already registered");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reload_home(self: Pin<&mut Self>) {
|
||||
crate::reload_home();
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ async fn service(runtime: &Arc<AppRuntime<LoggingAdapter>>) -> Option<Arc<Lyrics
|
||||
|
||||
fn publish(doc: LyricsDoc) {
|
||||
let json = serde_json::to_string(&doc).unwrap_or_else(|_| "{}".into());
|
||||
crate::ui(move |mut b| {
|
||||
crate::shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_lyrics_json(QString::from(json.as_str()));
|
||||
});
|
||||
}
|
||||
|
||||
+50
-26
@@ -7,6 +7,24 @@
|
||||
//! async work; results hop back to Qt through the bridge's `CxxQtThread`.
|
||||
|
||||
mod auth_qt;
|
||||
// Per-domain QML bridge singletons (phase 23 — the QbzBridge God-object
|
||||
// split). THE PATTERN (phase-1, replicated per domain file):
|
||||
// 1. one #[cxx_qt::bridge] mod per file (crate root — cxx-qt-build
|
||||
// accepts rust_files from ONE directory only, QTBUG-93443) with a
|
||||
// single #[qml_element] #[qml_singleton] QObject + its *Rust storage;
|
||||
// 2. `static QT_THREAD: OnceLock<CxxQtThread<QbzDomain>>` per file;
|
||||
// 3. the singleton's `boot()` invokable registers `self.qt_thread()` —
|
||||
// Main.qml boots EVERY singleton (they instantiate lazily); only
|
||||
// QbzSession.boot also fires crate::on_boot();
|
||||
// 4. `pub(crate) fn ui(f)` queues a property mutation onto that
|
||||
// object's Qt event loop (no-op pre-registration).
|
||||
// All singletons live in the SAME QML module (com.blitzfc.qbz); the
|
||||
// invokables stay one-line forwards into the domain controllers below.
|
||||
mod session_bridge;
|
||||
mod shell_bridge;
|
||||
mod player_bridge;
|
||||
mod queue_bridge;
|
||||
mod home_bridge;
|
||||
mod artwork_qt;
|
||||
mod bridge;
|
||||
mod home_qt;
|
||||
@@ -112,8 +130,8 @@ pub(crate) fn on_boot() {
|
||||
}
|
||||
match auth_qt::restore_saved_session(&runtime).await {
|
||||
Ok(Some(session)) => enter_shell(session),
|
||||
Ok(None) => ui(|mut b| b.as_mut().set_screen(QString::from("login"))),
|
||||
Err(e) => ui(move |mut b| {
|
||||
Ok(None) => session_bridge::ui(|mut b| b.as_mut().set_screen(QString::from("login"))),
|
||||
Err(e) => session_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_restore_error(QString::from(e.as_str()));
|
||||
b.as_mut().set_screen(QString::from("login"));
|
||||
}),
|
||||
@@ -139,7 +157,7 @@ fn enter_shell(session: auth_qt::SessionInfo) {
|
||||
// Phase 10: seed the playback request tier from the persisted
|
||||
// streaming-quality pref (Settings > Audio writes it live after this).
|
||||
playback_qt::set_streaming_quality(&settings_qt::streaming_quality());
|
||||
ui(move |mut b| {
|
||||
session_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_session_user_name(QString::from(session.display_name.as_str()));
|
||||
b.as_mut().set_session_subscription(QString::from(session.subscription.as_str()));
|
||||
b.as_mut().set_has_previous_session(true);
|
||||
@@ -160,7 +178,7 @@ pub(crate) fn start_login() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ui(|mut b| {
|
||||
session_bridge::ui(|mut b| {
|
||||
b.as_mut().set_login_error(QString::from(""));
|
||||
b.as_mut().set_login_phase(1);
|
||||
});
|
||||
@@ -172,13 +190,13 @@ pub(crate) fn start_login() {
|
||||
auth_qt::LoginPhase::WaitingForBrowser => 1,
|
||||
auth_qt::LoginPhase::Authenticating => 2,
|
||||
};
|
||||
ui(move |mut b| b.as_mut().set_login_phase(value));
|
||||
session_bridge::ui(move |mut b| b.as_mut().set_login_phase(value));
|
||||
})
|
||||
.await;
|
||||
LOGIN_TASK.lock().unwrap().take();
|
||||
match result {
|
||||
Ok(session) => enter_shell(session),
|
||||
Err(e) => ui(move |mut b| {
|
||||
Err(e) => session_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_login_phase(0);
|
||||
b.as_mut().set_login_error(QString::from(e.as_str()));
|
||||
}),
|
||||
@@ -192,7 +210,7 @@ pub(crate) fn cancel_login() {
|
||||
if let Some(task) = LOGIN_TASK.lock().unwrap().take() {
|
||||
task.abort();
|
||||
}
|
||||
ui(|mut b| b.as_mut().set_login_phase(0));
|
||||
session_bridge::ui(|mut b| b.as_mut().set_login_phase(0));
|
||||
}
|
||||
|
||||
/// "Start offline": unauthenticated offline session -> shell placeholder.
|
||||
@@ -206,7 +224,7 @@ pub(crate) fn start_offline() {
|
||||
} else {
|
||||
format!("Offline (user {user_id})")
|
||||
};
|
||||
ui(move |mut b| {
|
||||
session_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_session_user_name(QString::from(name.as_str()));
|
||||
b.as_mut().set_session_subscription(QString::from(""));
|
||||
b.as_mut().set_login_error(QString::from(""));
|
||||
@@ -219,7 +237,7 @@ pub(crate) fn start_offline() {
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("[qbz-qt] failed to enter offline mode: {e}");
|
||||
ui(move |mut b| {
|
||||
session_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_login_error(QString::from(e.as_str()));
|
||||
});
|
||||
}
|
||||
@@ -237,21 +255,27 @@ pub(crate) fn do_logout() {
|
||||
// A later login must re-fetch Home + Library (new user, fresh data).
|
||||
*HOME_LOADED.lock().unwrap() = false;
|
||||
*LIBRARY_LOADED.lock().unwrap() = false;
|
||||
ui(|mut b| {
|
||||
session_bridge::ui(|mut b| {
|
||||
b.as_mut().set_session_user_name(QString::from(""));
|
||||
b.as_mut().set_session_subscription(QString::from(""));
|
||||
b.as_mut().set_login_error(QString::from(""));
|
||||
b.as_mut().set_restore_error(QString::from(""));
|
||||
b.as_mut().set_login_phase(0);
|
||||
b.as_mut().set_screen(QString::from("login"));
|
||||
});
|
||||
home_bridge::ui(|mut b| {
|
||||
b.as_mut().set_home_sections_json(QString::from("[]"));
|
||||
b.as_mut().set_home_error(QString::from(""));
|
||||
b.as_mut().set_home_loading(false);
|
||||
});
|
||||
ui(|mut b| {
|
||||
b.as_mut().set_library_json(QString::from("[]"));
|
||||
b.as_mut().set_library_counts_json(QString::from("{}"));
|
||||
b.as_mut().set_library_error(QString::from(""));
|
||||
b.as_mut().set_library_loading(false);
|
||||
});
|
||||
shell_bridge::ui(|mut b| {
|
||||
b.as_mut().set_sidebar_json(QString::from("[]"));
|
||||
b.as_mut().set_screen(QString::from("login"));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -308,7 +332,7 @@ fn publish_sidebar() {
|
||||
let json = serde_json::to_string(&entries).unwrap_or_else(|_| "[]".into());
|
||||
log::debug!("[qbz-qt] sidebar published: {} entries ({} bytes)", entries.len(), json.len());
|
||||
let (sort_by, sort_asc) = sidebar_qt::sort_state();
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_sidebar_json(QString::from(json.as_str()));
|
||||
b.as_mut().set_sidebar_sort_by(QString::from(sort_by.as_str()));
|
||||
b.as_mut().set_sidebar_sort_asc(sort_asc);
|
||||
@@ -494,7 +518,7 @@ static LYRICS_OPEN: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBoo
|
||||
|
||||
pub(crate) fn toggle_lyrics() {
|
||||
let open = !LYRICS_OPEN.swap(!LYRICS_OPEN.load(std::sync::atomic::Ordering::SeqCst), std::sync::atomic::Ordering::SeqCst);
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_lyrics_open(open);
|
||||
});
|
||||
if open {
|
||||
@@ -734,7 +758,7 @@ pub(crate) fn drag_start(track_id: String, title: String, subtitle: String, x: f
|
||||
let id = track_id.parse::<u64>().unwrap_or(0);
|
||||
*DRAGGED.lock().unwrap() = if id > 0 { vec![id] } else { Vec::new() };
|
||||
log::info!("[qbz-qt][drag] start {track_id} ({title})");
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_drag_count(if id > 0 { 1 } else { 0 });
|
||||
b.as_mut().set_drag_title(QString::from(title.as_str()));
|
||||
b.as_mut().set_drag_subtitle(QString::from(subtitle.as_str()));
|
||||
@@ -746,7 +770,7 @@ pub(crate) fn drag_start(track_id: String, title: String, subtitle: String, x: f
|
||||
}
|
||||
|
||||
pub(crate) fn drag_move(x: f32, y: f32) {
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_drag_x(x);
|
||||
b.as_mut().set_drag_y(y);
|
||||
});
|
||||
@@ -754,7 +778,7 @@ pub(crate) fn drag_move(x: f32, y: f32) {
|
||||
|
||||
pub(crate) fn drag_set_over(playlist_id: String) {
|
||||
*DRAG_OVER.lock().unwrap() = playlist_id.clone();
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
b.as_mut()
|
||||
.set_drag_over_playlist_id(QString::from(playlist_id.as_str()));
|
||||
});
|
||||
@@ -762,7 +786,7 @@ pub(crate) fn drag_set_over(playlist_id: String) {
|
||||
|
||||
pub(crate) fn drag_end() {
|
||||
let pid = std::mem::take(&mut *DRAG_OVER.lock().unwrap());
|
||||
ui(|mut b| {
|
||||
shell_bridge::ui(|mut b| {
|
||||
b.as_mut().set_drag_active(false);
|
||||
b.as_mut().set_drag_over_playlist_id(QString::default());
|
||||
});
|
||||
@@ -810,7 +834,7 @@ pub(crate) fn playlist_set_follow_by_id(playlist_id: u64, follow: bool) {
|
||||
pub(crate) fn npb_set_mode(mode: i32) {
|
||||
let mode = settings_qt::set_npb_mode(mode);
|
||||
log::info!("[qbz-qt] npb_mode -> {mode}");
|
||||
ui(move |mut b| {
|
||||
shell_bridge::ui(move |mut b| {
|
||||
if mode == 3 {
|
||||
b.as_mut().set_sidebar_state(0);
|
||||
}
|
||||
@@ -930,7 +954,7 @@ pub(crate) fn apply_language(code: String) {
|
||||
};
|
||||
qbz_i18n::set_language(&resolved);
|
||||
log::info!("[qbz-qt] language -> {code} (resolved: {resolved})");
|
||||
ui(move |mut b| {
|
||||
session_bridge::ui(move |mut b| {
|
||||
let next = b.as_ref().tr_rev() + 1;
|
||||
b.as_mut().set_tr_rev(next);
|
||||
});
|
||||
@@ -1072,7 +1096,7 @@ pub(crate) fn theme_set(slug: String) {
|
||||
pub(crate) fn theme_set_filter(index: i32) {
|
||||
let index = index.clamp(0, 2);
|
||||
theme_qt::set_theme_filter(index);
|
||||
ui(move |mut b| b.as_mut().set_theme_filter(index));
|
||||
shell_bridge::ui(move |mut b| b.as_mut().set_theme_filter(index));
|
||||
}
|
||||
|
||||
/// Integrations panel non-toggle actions (Last.fm connect flow, LB/LFM
|
||||
@@ -1089,7 +1113,7 @@ pub(crate) fn integrations_action(action: String) {
|
||||
pub(crate) fn toggle_system_title_bar() {
|
||||
let next = settings_qt::toggle_system_title_bar();
|
||||
log::info!("[qbz-qt] use_system_title_bar -> {next} (applies on next launch)");
|
||||
ui(move |mut b| b.as_mut().set_system_title_bar_pref(next));
|
||||
shell_bridge::ui(move |mut b| b.as_mut().set_system_title_bar_pref(next));
|
||||
}
|
||||
|
||||
/// App-menu ambient toggle: persist the flipped pref and apply LIVE (the
|
||||
@@ -1097,7 +1121,7 @@ pub(crate) fn toggle_system_title_bar() {
|
||||
pub(crate) fn toggle_ambient_background() {
|
||||
let mode = settings_qt::toggle_ambient_background();
|
||||
log::info!("[qbz-qt] app_background -> {}", if mode == 1 { "ambient" } else { "off" });
|
||||
ui(move |mut b| b.as_mut().set_ambient_mode(mode));
|
||||
shell_bridge::ui(move |mut b| b.as_mut().set_ambient_mode(mode));
|
||||
}
|
||||
|
||||
fn load_library_once() {
|
||||
@@ -1247,7 +1271,7 @@ pub(crate) fn reload_home() {
|
||||
if offline_fwd::engine().status().is_offline() {
|
||||
return;
|
||||
}
|
||||
ui(|mut b| {
|
||||
home_bridge::ui(|mut b| {
|
||||
b.as_mut().set_home_loading(true);
|
||||
b.as_mut().set_home_error(QString::from(""));
|
||||
});
|
||||
@@ -1287,11 +1311,11 @@ pub(crate) fn reload_home() {
|
||||
});
|
||||
}
|
||||
|
||||
ui(|mut b| b.as_mut().set_home_loading(false));
|
||||
home_bridge::ui(|mut b| b.as_mut().set_home_loading(false));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("[qbz-qt] home load failed: {e}");
|
||||
ui(move |mut b| {
|
||||
home_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_home_error(QString::from(e.as_str()));
|
||||
b.as_mut().set_home_loading(false);
|
||||
});
|
||||
@@ -1304,7 +1328,7 @@ fn publish_home_sections(sections: &home_qt::DiscoverSections) {
|
||||
let home_json = serde_json::to_string(§ions.home).unwrap_or_else(|_| "[]".to_string());
|
||||
let editor_json = serde_json::to_string(§ions.editor).unwrap_or_else(|_| "[]".to_string());
|
||||
let for_you_json = serde_json::to_string(§ions.for_you).unwrap_or_else(|_| "[]".to_string());
|
||||
ui(move |mut b| {
|
||||
home_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_home_sections_json(QString::from(home_json.as_str()));
|
||||
b.as_mut()
|
||||
.set_editor_sections_json(QString::from(editor_json.as_str()));
|
||||
|
||||
@@ -72,7 +72,7 @@ fn snapshot(h: &NavHistory) -> (bool, bool, String) {
|
||||
}
|
||||
|
||||
fn publish(can_back: bool, can_forward: bool, current: String) {
|
||||
crate::ui(move |mut b| {
|
||||
crate::shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_can_back(can_back);
|
||||
b.as_mut().set_can_forward(can_forward);
|
||||
b.as_mut().set_current_view(QString::from(current.as_str()));
|
||||
|
||||
@@ -92,7 +92,7 @@ fn mutate(f: impl FnOnce(&mut NowPlayingModel)) {
|
||||
/// Push the full model onto the bridge (Qt thread hop).
|
||||
fn publish(m: &NowPlayingModel) {
|
||||
let m = m.clone();
|
||||
crate::ui(move |mut b| {
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
let progress = if m.duration_secs > 0 {
|
||||
(m.elapsed_secs as f32 / m.duration_secs as f32).clamp(0.0, 1.0)
|
||||
} else {
|
||||
@@ -253,7 +253,7 @@ pub fn set_position(elapsed_secs: i32, duration_secs: i32, playing: bool, cache:
|
||||
/// mirroring progress.
|
||||
fn publish_with_cache(m: &NowPlayingModel) {
|
||||
let m = m.clone();
|
||||
crate::ui(move |mut b| {
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
let progress = if m.duration_secs > 0 {
|
||||
(m.elapsed_secs as f32 / m.duration_secs as f32).clamp(0.0, 1.0)
|
||||
} else {
|
||||
|
||||
@@ -63,13 +63,13 @@ pub fn start() {
|
||||
/// login. Spawned once from the boot sequence.
|
||||
pub fn start_ui_forwarder() {
|
||||
let has_previous = UserDataPaths::load_last_user_id().is_some();
|
||||
crate::ui(move |mut b| b.as_mut().set_has_previous_session(has_previous));
|
||||
crate::session_bridge::ui(move |mut b| b.as_mut().set_has_previous_session(has_previous));
|
||||
|
||||
crate::spawn(async move {
|
||||
let mut rx = engine().subscribe();
|
||||
loop {
|
||||
let status = *rx.borrow_and_update();
|
||||
crate::ui(move |b| apply_status(b, status));
|
||||
crate::session_bridge::ui(move |b| apply_status(b, status));
|
||||
if rx.changed().await.is_err() {
|
||||
break;
|
||||
}
|
||||
@@ -79,7 +79,10 @@ pub fn start_ui_forwarder() {
|
||||
|
||||
/// Push one engine status snapshot into the bridge (queued on the Qt
|
||||
/// thread via [`crate::ui`]).
|
||||
fn apply_status(mut b: core::pin::Pin<&mut crate::bridge::qbz_bridge::QbzBridge>, status: OfflineStatus) {
|
||||
fn apply_status(
|
||||
mut b: core::pin::Pin<&mut crate::session_bridge::qbz_session::QbzSession>,
|
||||
status: OfflineStatus,
|
||||
) {
|
||||
b.as_mut().set_offline(status.is_offline());
|
||||
b.as_mut().set_offline_mode(match status.mode {
|
||||
OfflineMode::Online => 0,
|
||||
|
||||
@@ -590,7 +590,7 @@ pub(crate) async fn refresh_now_playing(runtime: &Arc<AppRuntime<LoggingAdapter>
|
||||
let state = runtime.core().get_queue_state().await;
|
||||
let Some(track) = state.current_track else {
|
||||
crate::now_playing::clear_track();
|
||||
crate::ui(move |mut b| {
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_np_track_id(QString::from(""));
|
||||
});
|
||||
crate::lyrics_qt::publish_idle();
|
||||
@@ -601,7 +601,7 @@ pub(crate) async fn refresh_now_playing(runtime: &Arc<AppRuntime<LoggingAdapter>
|
||||
None => track.title.clone(),
|
||||
};
|
||||
let track_id_str = track.id.to_string();
|
||||
crate::ui(move |mut b| {
|
||||
crate::player_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_np_track_id(QString::from(track_id_str.as_str()));
|
||||
});
|
||||
log::info!(
|
||||
|
||||
@@ -0,0 +1,308 @@
|
||||
//! QbzPlayer — now-playing/transport domain bridge (phase 23 split of the
|
||||
//! QbzBridge God-object; the pattern is documented in main.rs). Props: the
|
||||
//! NowPlayingState mirror (np_ prefix) + the playing-row indicator ids +
|
||||
//! show-context-icon. Invokables: transport + the play/enqueue entry points
|
||||
//! (album / artist / track / playlist) — one-line forwards into the crate
|
||||
//! handlers.
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use cxx_qt::CxxQtThread;
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qbz_player {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// --- Now playing (Slint NowPlayingState; np_ prefix) ------------
|
||||
// POC: fed by a static NowPlayingModel (src/now_playing.rs) with
|
||||
// empty-state defaults; phase 4 swaps the data source for the real
|
||||
// player poll.
|
||||
#[qproperty(bool, np_has_track)]
|
||||
#[qproperty(QString, np_title)]
|
||||
#[qproperty(QString, np_artist)]
|
||||
#[qproperty(QString, np_artwork_path)]
|
||||
#[qproperty(i32, np_elapsed_secs)]
|
||||
#[qproperty(i32, np_duration_secs)]
|
||||
#[qproperty(f32, np_progress)]
|
||||
#[qproperty(f32, np_cache_progress)]
|
||||
#[qproperty(bool, np_playing)]
|
||||
#[qproperty(bool, np_loading)]
|
||||
#[qproperty(f32, np_volume)]
|
||||
#[qproperty(bool, np_muted)]
|
||||
#[qproperty(bool, np_shuffle)]
|
||||
// 0 off / 1 all / 2 one.
|
||||
#[qproperty(i32, np_repeat_mode)]
|
||||
// "hires" | "mp3" | "lossless" | "cd" (AudioStamp tier mapping).
|
||||
#[qproperty(QString, np_quality_tier)]
|
||||
// e.g. "24-bit / 96 kHz" (AudioStamp detail line).
|
||||
#[qproperty(QString, np_quality_label)]
|
||||
// Now-playing track id (playing-row indicator in track lists).
|
||||
#[qproperty(QString, np_track_id)]
|
||||
#[qproperty(QString, np_album)]
|
||||
#[qproperty(QString, np_album_id)]
|
||||
#[qproperty(QString, np_artist_id)]
|
||||
// "Show track playing context" pref (Playback settings) — feeds the
|
||||
// SongCard layers icon.
|
||||
#[qproperty(bool, show_context_icon)]
|
||||
|
||||
type QbzPlayer = super::QbzPlayerRust;
|
||||
|
||||
/// Registers this object's Qt-thread hop (Main.qml boots EVERY
|
||||
/// domain singleton; only QbzSession.boot also fires crate::on_boot).
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzPlayer>);
|
||||
|
||||
// --- Transport (phase 4 wires the player; POC log-and-noop, except
|
||||
// the pure-UI toggles which mutate the NowPlayingModel) -----------
|
||||
#[qinvokable]
|
||||
fn toggle_play(self: Pin<&mut QbzPlayer>);
|
||||
#[qinvokable]
|
||||
fn next(self: Pin<&mut QbzPlayer>);
|
||||
#[qinvokable]
|
||||
fn previous(self: Pin<&mut QbzPlayer>);
|
||||
#[qinvokable]
|
||||
fn seek(self: Pin<&mut QbzPlayer>, frac: f32);
|
||||
#[qinvokable]
|
||||
fn set_volume(self: Pin<&mut QbzPlayer>, volume: f32);
|
||||
#[qinvokable]
|
||||
fn toggle_mute(self: Pin<&mut QbzPlayer>);
|
||||
#[qinvokable]
|
||||
fn toggle_shuffle(self: Pin<&mut QbzPlayer>);
|
||||
#[qinvokable]
|
||||
fn cycle_repeat(self: Pin<&mut QbzPlayer>);
|
||||
|
||||
/// Album-card click on Home: resolve the album's tracks, enqueue,
|
||||
/// and play through the core's resolved path.
|
||||
#[qinvokable]
|
||||
fn play_album(self: Pin<&mut QbzPlayer>, album_id: QString);
|
||||
|
||||
/// AlbumView header Shuffle.
|
||||
#[qinvokable]
|
||||
fn play_album_shuffled(self: Pin<&mut QbzPlayer>, album_id: QString);
|
||||
/// AlbumView row play: the album starting AT this track.
|
||||
#[qinvokable]
|
||||
fn play_album_from(self: Pin<&mut QbzPlayer>, album_id: QString, track_id: QString);
|
||||
/// AlbumView row "Play next" ("next") / "Add to queue" ("later").
|
||||
#[qinvokable]
|
||||
fn enqueue_album_track(self: Pin<&mut QbzPlayer>, album_id: QString, track_id: QString, mode: QString);
|
||||
/// AlbumCard ⋯ menu: Play next ("next") / Add to queue ("later").
|
||||
#[qinvokable]
|
||||
fn enqueue_album(self: Pin<&mut QbzPlayer>, album_id: QString, mode: QString);
|
||||
/// ArtistView Popular Tracks row play (whole list as the queue).
|
||||
#[qinvokable]
|
||||
fn play_artist_track(self: Pin<&mut QbzPlayer>, track_id: QString);
|
||||
/// ArtistView "Play all" (shuffle=false) / "Shuffle all" (true).
|
||||
#[qinvokable]
|
||||
fn play_artist_top(self: Pin<&mut QbzPlayer>, shuffle: bool);
|
||||
/// ArtistView ⋯ "Add all to queue" — appends the top-tracks queue.
|
||||
#[qinvokable]
|
||||
fn enqueue_artist_top(self: Pin<&mut QbzPlayer>);
|
||||
/// Artist-card overlay play (ArtistGridCard): Popular tracks,
|
||||
/// falling back to the studio discography (playback.rs play_artist).
|
||||
#[qinvokable]
|
||||
fn play_artist_card(self: Pin<&mut QbzPlayer>, artist_id: QString);
|
||||
|
||||
/// Track-row click (Library): play the track as a 1-element queue.
|
||||
#[qinvokable]
|
||||
fn play_track(self: Pin<&mut QbzPlayer>, track_id: QString);
|
||||
/// Library track context menus: Play next ("next") / Play later
|
||||
/// ("later") / Add to queue ("queue") on a single feed track.
|
||||
#[qinvokable]
|
||||
fn enqueue_track(self: Pin<&mut QbzPlayer>, track_id: QString, mode: QString);
|
||||
|
||||
/// Card-level playlist actions (LibPlaylistCard overlay + menu).
|
||||
#[qinvokable]
|
||||
fn play_playlist_by_id(self: Pin<&mut QbzPlayer>, playlist_id: QString);
|
||||
#[qinvokable]
|
||||
fn enqueue_playlist_by_id(self: Pin<&mut QbzPlayer>, playlist_id: QString, mode: QString);
|
||||
}
|
||||
|
||||
impl cxx_qt::Threading for QbzPlayer {}
|
||||
}
|
||||
|
||||
use qbz_player::QbzPlayer;
|
||||
|
||||
/// Rust side of the player bridge (plain storage, phase-1 pattern).
|
||||
pub struct QbzPlayerRust {
|
||||
np_has_track: bool,
|
||||
np_title: QString,
|
||||
np_artist: QString,
|
||||
np_artwork_path: QString,
|
||||
np_elapsed_secs: i32,
|
||||
np_duration_secs: i32,
|
||||
np_progress: f32,
|
||||
np_cache_progress: f32,
|
||||
np_playing: bool,
|
||||
np_loading: bool,
|
||||
np_volume: f32,
|
||||
np_muted: bool,
|
||||
np_shuffle: bool,
|
||||
np_repeat_mode: i32,
|
||||
np_quality_tier: QString,
|
||||
np_quality_label: QString,
|
||||
np_track_id: QString,
|
||||
np_album: QString,
|
||||
np_album_id: QString,
|
||||
np_artist_id: QString,
|
||||
show_context_icon: bool,
|
||||
}
|
||||
|
||||
impl Default for QbzPlayerRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
// A derive would zero these — the model's sane defaults instead.
|
||||
np_volume: 1.0,
|
||||
np_quality_tier: QString::from("cd"),
|
||||
np_has_track: false,
|
||||
np_title: QString::default(),
|
||||
np_artist: QString::default(),
|
||||
np_artwork_path: QString::default(),
|
||||
np_elapsed_secs: 0,
|
||||
np_duration_secs: 0,
|
||||
np_progress: 0.0,
|
||||
np_cache_progress: 0.0,
|
||||
np_playing: false,
|
||||
np_loading: false,
|
||||
np_muted: false,
|
||||
np_shuffle: false,
|
||||
np_repeat_mode: 0,
|
||||
np_quality_label: QString::default(),
|
||||
np_track_id: QString::default(),
|
||||
np_album: QString::default(),
|
||||
np_album_id: QString::default(),
|
||||
np_artist_id: QString::default(),
|
||||
show_context_icon: crate::settings_qt::show_context_icon(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The UI hop (bridges/mod.rs pattern)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QT_THREAD: OnceLock<CxxQtThread<QbzPlayer>> = OnceLock::new();
|
||||
|
||||
/// Queue a player-bridge mutation onto the Qt event loop (no-op before
|
||||
/// boot registers the thread).
|
||||
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzPlayer>) + Send + 'static) {
|
||||
if let Some(thread) = QT_THREAD.get() {
|
||||
let _ = thread.queue(f);
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_player::QbzPlayer {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
log::warn!("[qbz-qt] player Qt thread already registered");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_play(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_play();
|
||||
}
|
||||
|
||||
pub fn next(self: Pin<&mut Self>) {
|
||||
crate::transport_next();
|
||||
}
|
||||
|
||||
pub fn previous(self: Pin<&mut Self>) {
|
||||
crate::transport_previous();
|
||||
}
|
||||
|
||||
pub fn seek(self: Pin<&mut Self>, frac: f32) {
|
||||
crate::transport_seek(frac);
|
||||
}
|
||||
|
||||
pub fn set_volume(self: Pin<&mut Self>, volume: f32) {
|
||||
crate::transport_set_volume(volume);
|
||||
}
|
||||
|
||||
pub fn toggle_mute(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_mute();
|
||||
}
|
||||
|
||||
pub fn toggle_shuffle(self: Pin<&mut Self>) {
|
||||
crate::transport_toggle_shuffle();
|
||||
}
|
||||
|
||||
pub fn cycle_repeat(self: Pin<&mut Self>) {
|
||||
crate::transport_cycle_repeat();
|
||||
}
|
||||
|
||||
pub fn play_album(self: Pin<&mut Self>, album_id: QString) {
|
||||
crate::play_album(album_id.to_string());
|
||||
}
|
||||
|
||||
pub fn play_album_shuffled(self: Pin<&mut Self>, album_id: QString) {
|
||||
crate::play_album_shuffled(album_id.to_string());
|
||||
}
|
||||
|
||||
pub fn play_album_from(self: Pin<&mut Self>, album_id: QString, track_id: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_album_from_track(album_id.to_string(), tid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_album_track(self: Pin<&mut Self>, album_id: QString, track_id: QString, mode: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_album_track(album_id.to_string(), tid, mode.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_album(self: Pin<&mut Self>, album_id: QString, mode: QString) {
|
||||
crate::enqueue_album(album_id.to_string(), mode.to_string());
|
||||
}
|
||||
|
||||
pub fn play_artist_track(self: Pin<&mut Self>, track_id: QString) {
|
||||
if let Ok(tid) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_artist_track(tid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_artist_top(self: Pin<&mut Self>, shuffle: bool) {
|
||||
crate::play_artist_top(shuffle);
|
||||
}
|
||||
|
||||
pub fn enqueue_artist_top(self: Pin<&mut Self>) {
|
||||
crate::enqueue_artist_top();
|
||||
}
|
||||
|
||||
pub fn play_artist_card(self: Pin<&mut Self>, artist_id: QString) {
|
||||
crate::play_artist_card(artist_id.to_string());
|
||||
}
|
||||
|
||||
pub fn play_track(self: Pin<&mut Self>, track_id: QString) {
|
||||
if let Ok(id) = track_id.to_string().parse::<u64>() {
|
||||
crate::play_track(id);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_track(self: Pin<&mut Self>, track_id: QString, mode: QString) {
|
||||
if let Ok(id) = track_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_track(id, mode.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_playlist_by_id(self: Pin<&mut Self>, playlist_id: QString) {
|
||||
if let Ok(pid) = playlist_id.to_string().parse::<u64>() {
|
||||
crate::play_playlist_by_id(pid);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enqueue_playlist_by_id(self: Pin<&mut Self>, playlist_id: QString, mode: QString) {
|
||||
if let Ok(pid) = playlist_id.to_string().parse::<u64>() {
|
||||
crate::enqueue_playlist_by_id(pid, mode.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
//! QbzQueue — queue-panel domain bridge (phase 23 split of the QbzBridge
|
||||
//! God-object; the pattern is documented in main.rs). Props: the legacy
|
||||
//! queueModel list + the queueJson document. Invokables: the panel's
|
||||
//! tabs/pagination/search and row actions — one-line forwards into the
|
||||
//! crate handlers.
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use cxx_qt::CxxQtThread;
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qbz_queue {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
|
||||
include!("cxx-qt-lib/qvariant.h");
|
||||
type QVariant = cxx_qt_lib::QVariant;
|
||||
|
||||
include!("cxx-qt-lib/qlist.h");
|
||||
type QList_QVariant = cxx_qt_lib::QList<cxx_qt_lib::QVariant>;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// --- Queue panel -------------------------------------------------
|
||||
// POC: empty until phase 4 (QML shows the empty states).
|
||||
#[qproperty(QList_QVariant, queue_model)]
|
||||
|
||||
// --- Queue panel (phase 9) -----------------------------------------
|
||||
// One JSON document (queue_qt.rs QueueDoc: current/upcoming/history
|
||||
// + pagination + #442 section markers). Supersedes `queueModel`.
|
||||
#[qproperty(QString, queue_json)]
|
||||
|
||||
type QbzQueue = super::QbzQueueRust;
|
||||
|
||||
/// Registers this object's Qt-thread hop (Main.qml boots EVERY
|
||||
/// domain singleton; only QbzSession.boot also fires crate::on_boot).
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzQueue>);
|
||||
|
||||
/// Queue panel: tabs/pagination/search.
|
||||
#[qinvokable]
|
||||
fn queue_set_page(self: Pin<&mut QbzQueue>, page: i32);
|
||||
#[qinvokable]
|
||||
fn queue_set_search(self: Pin<&mut QbzQueue>, query: QString);
|
||||
/// Row actions.
|
||||
#[qinvokable]
|
||||
fn queue_play_upcoming(self: Pin<&mut QbzQueue>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_remove_upcoming(self: Pin<&mut QbzQueue>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_remove_all_after(self: Pin<&mut QbzQueue>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_move_track(self: Pin<&mut QbzQueue>, from: i32, to: i32);
|
||||
#[qinvokable]
|
||||
fn queue_play_history(self: Pin<&mut QbzQueue>, index: i32);
|
||||
#[qinvokable]
|
||||
fn queue_toggle_favorite(self: Pin<&mut QbzQueue>, kind: QString, id: QString);
|
||||
/// Footer: Clear queue.
|
||||
#[qinvokable]
|
||||
fn queue_clear(self: Pin<&mut QbzQueue>);
|
||||
}
|
||||
|
||||
impl cxx_qt::Threading for QbzQueue {}
|
||||
}
|
||||
|
||||
use cxx_qt_lib::{QList, QVariant};
|
||||
use qbz_queue::QbzQueue;
|
||||
|
||||
type QListQVariant = QList<QVariant>;
|
||||
|
||||
/// Rust side of the queue bridge (plain storage, phase-1 pattern).
|
||||
pub struct QbzQueueRust {
|
||||
queue_model: QListQVariant,
|
||||
queue_json: QString,
|
||||
}
|
||||
|
||||
impl Default for QbzQueueRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
queue_model: QListQVariant::default(),
|
||||
queue_json: QString::from("{}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The UI hop (bridges/mod.rs pattern)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QT_THREAD: OnceLock<CxxQtThread<QbzQueue>> = OnceLock::new();
|
||||
|
||||
/// Queue a queue-bridge mutation onto the Qt event loop (no-op before
|
||||
/// boot registers the thread).
|
||||
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzQueue>) + Send + 'static) {
|
||||
if let Some(thread) = QT_THREAD.get() {
|
||||
let _ = thread.queue(f);
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_queue::QbzQueue {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
log::warn!("[qbz-qt] queue Qt thread already registered");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn queue_set_page(self: Pin<&mut Self>, page: i32) {
|
||||
crate::queue_set_page(page);
|
||||
}
|
||||
|
||||
pub fn queue_set_search(self: Pin<&mut Self>, query: QString) {
|
||||
crate::queue_set_search(query.to_string());
|
||||
}
|
||||
|
||||
pub fn queue_play_upcoming(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_play_upcoming(index);
|
||||
}
|
||||
|
||||
pub fn queue_remove_upcoming(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_remove_upcoming(index);
|
||||
}
|
||||
|
||||
pub fn queue_remove_all_after(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_remove_all_after(index);
|
||||
}
|
||||
|
||||
pub fn queue_move_track(self: Pin<&mut Self>, from: i32, to: i32) {
|
||||
crate::queue_move_track(from, to);
|
||||
}
|
||||
|
||||
pub fn queue_play_history(self: Pin<&mut Self>, index: i32) {
|
||||
crate::queue_play_history(index);
|
||||
}
|
||||
|
||||
pub fn queue_toggle_favorite(self: Pin<&mut Self>, kind: QString, id: QString) {
|
||||
crate::queue_toggle_favorite(kind.to_string(), id.to_string());
|
||||
}
|
||||
|
||||
pub fn queue_clear(self: Pin<&mut Self>) {
|
||||
crate::queue_clear();
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ pub async fn publish(runtime: &Arc<AppRuntime<LoggingAdapter>>) {
|
||||
},
|
||||
};
|
||||
let json = serde_json::to_string(&doc).unwrap_or_else(|_| "{}".into());
|
||||
crate::ui(move |mut b| {
|
||||
crate::queue_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_queue_json(QString::from(json.as_str()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
//! QbzSession — session/auth/offline/i18n domain bridge (phase 23 split of
|
||||
//! the QbzBridge God-object; the pattern is documented in main.rs). Props:
|
||||
//! screen/login/offline/connectivity/recovery/session-user + trRev.
|
||||
//! Invokables: boot (THE app boot — registers this object's thread hop AND
|
||||
//! fires crate::on_boot once), the login/logout flow, and `tr` (the one
|
||||
//! i18n lookup every QML string binds to, with the trRev dependency arg).
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use cxx_qt::CxxQtThread;
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qbz_session {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// "splash" | "login" | "shell"
|
||||
#[qproperty(QString, screen)]
|
||||
// Login narration: 0 idle / 1 waiting-for-browser / 2 authenticating.
|
||||
#[qproperty(i32, login_phase)]
|
||||
// Last SIGN-IN failure message ("" = none). Mirrors Slint
|
||||
// `LoginState.error`.
|
||||
#[qproperty(QString, login_error)]
|
||||
// Session-RESTORE failure message ("" = none). Mirrors Slint
|
||||
// `OfflineState.login-error`.
|
||||
#[qproperty(QString, restore_error)]
|
||||
// Offline-MODE engine snapshot (Slint `OfflineState`):
|
||||
#[qproperty(bool, offline)]
|
||||
// 0 online / 1 real offline / 2 induced offline.
|
||||
#[qproperty(i32, offline_mode)]
|
||||
// 0 unknown / 1 up / 2 down.
|
||||
#[qproperty(i32, connectivity)]
|
||||
#[qproperty(bool, captive_portal)]
|
||||
#[qproperty(bool, has_previous_session)]
|
||||
#[qproperty(bool, show_recovery_banner)]
|
||||
#[qproperty(bool, offline_session)]
|
||||
// Shell session header:
|
||||
#[qproperty(QString, session_user_name)]
|
||||
#[qproperty(QString, session_subscription)]
|
||||
// Translation revision (phase 20): bumped on every live language
|
||||
// switch; every `QbzSession.tr(msgid, QbzSession.trRev)` binding
|
||||
// depends on it.
|
||||
#[qproperty(i32, tr_rev)]
|
||||
|
||||
type QbzSession = super::QbzSessionRust;
|
||||
|
||||
/// The first invokable (Main.qml Component.onCompleted): register
|
||||
/// this object's Qt-thread hop, then run the app boot sequence.
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzSession>);
|
||||
/// Start the Qobuz browser-OAuth login flow.
|
||||
#[qinvokable]
|
||||
fn sign_in_via_browser(self: Pin<&mut QbzSession>);
|
||||
/// Abort the in-flight login (back to idle).
|
||||
#[qinvokable]
|
||||
fn cancel_login(self: Pin<&mut QbzSession>);
|
||||
/// Continue in induced-offline mode (no Qobuz services).
|
||||
#[qinvokable]
|
||||
fn start_offline(self: Pin<&mut QbzSession>);
|
||||
/// Retry session restore after a failure.
|
||||
#[qinvokable]
|
||||
fn recovery_login(self: Pin<&mut QbzSession>);
|
||||
/// Open the Qobuz Terms of Service in the browser.
|
||||
#[qinvokable]
|
||||
fn open_tos(self: Pin<&mut QbzSession>);
|
||||
/// Shell logout: back to the login screen.
|
||||
#[qinvokable]
|
||||
fn logout(self: Pin<&mut QbzSession>);
|
||||
|
||||
/// i18n lookup against the shared gettext catalog (qbz-i18n), so the
|
||||
/// QML texts reuse the EXISTING .po translations via the same msgids
|
||||
/// the Slint `@tr()` calls use. `rev` is the trRev binding
|
||||
/// dependency — unused in Rust, it only forces QML re-evaluation
|
||||
/// when the language changes live.
|
||||
#[qinvokable]
|
||||
fn tr(self: &QbzSession, msgid: QString, rev: i32) -> QString;
|
||||
}
|
||||
|
||||
impl cxx_qt::Threading for QbzSession {}
|
||||
}
|
||||
|
||||
use qbz_session::QbzSession;
|
||||
|
||||
/// Rust side of the session bridge (plain storage, phase-1 pattern).
|
||||
pub struct QbzSessionRust {
|
||||
screen: QString,
|
||||
login_phase: i32,
|
||||
login_error: QString,
|
||||
restore_error: QString,
|
||||
offline: bool,
|
||||
offline_mode: i32,
|
||||
connectivity: i32,
|
||||
captive_portal: bool,
|
||||
has_previous_session: bool,
|
||||
show_recovery_banner: bool,
|
||||
offline_session: bool,
|
||||
session_user_name: QString,
|
||||
session_subscription: QString,
|
||||
tr_rev: i32,
|
||||
}
|
||||
|
||||
impl Default for QbzSessionRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
screen: QString::from("splash"),
|
||||
login_phase: 0,
|
||||
login_error: QString::default(),
|
||||
restore_error: QString::default(),
|
||||
offline: false,
|
||||
offline_mode: 0,
|
||||
connectivity: 0,
|
||||
captive_portal: false,
|
||||
has_previous_session: false,
|
||||
show_recovery_banner: false,
|
||||
offline_session: false,
|
||||
session_user_name: QString::default(),
|
||||
session_subscription: QString::default(),
|
||||
tr_rev: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The UI hop (bridges/mod.rs pattern)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QT_THREAD: OnceLock<CxxQtThread<QbzSession>> = OnceLock::new();
|
||||
|
||||
/// Queue a session-bridge mutation onto the Qt event loop (no-op before
|
||||
/// boot registers the thread).
|
||||
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzSession>) + Send + 'static) {
|
||||
if let Some(thread) = QT_THREAD.get() {
|
||||
let _ = thread.queue(f);
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_session::QbzSession {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
log::warn!("[qbz-qt] session Qt thread already registered");
|
||||
}
|
||||
crate::on_boot();
|
||||
}
|
||||
|
||||
pub fn sign_in_via_browser(self: Pin<&mut Self>) {
|
||||
crate::start_login();
|
||||
}
|
||||
|
||||
pub fn cancel_login(self: Pin<&mut Self>) {
|
||||
crate::cancel_login();
|
||||
}
|
||||
|
||||
pub fn start_offline(self: Pin<&mut Self>) {
|
||||
crate::start_offline();
|
||||
}
|
||||
|
||||
pub fn recovery_login(self: Pin<&mut Self>) {
|
||||
crate::start_login();
|
||||
}
|
||||
|
||||
pub fn open_tos(self: Pin<&mut Self>) {
|
||||
// Same URL the Slint shell opens (crates/qbz/src/main.rs
|
||||
// QOBUZ_TOS_URL). `open` spawns xdg-open detached, so this is safe
|
||||
// to run on the Qt thread.
|
||||
if let Err(e) = open::that(crate::QOBUZ_TOS_URL) {
|
||||
log::error!("[qbz-qt] failed to open Terms of Service: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn logout(self: Pin<&mut Self>) {
|
||||
crate::do_logout();
|
||||
}
|
||||
|
||||
pub fn tr(&self, msgid: QString, rev: i32) -> QString {
|
||||
let _ = rev; // binding dependency only (see the bridge declaration)
|
||||
QString::from(&qbz_i18n::t(&msgid.to_string()))
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1141,7 @@ pub async fn settings_bool(runtime: &Arc<AppRuntime<LoggingAdapter>>, key: &str,
|
||||
// Restart semantics (1:1 Slint): the APPLIED mode is untouched;
|
||||
// only the menu/row state flips live.
|
||||
log::info!("[qbz-qt] use_system_title_bar -> {value} (applies on next launch)");
|
||||
crate::ui(move |mut b| b.as_mut().set_system_title_bar_pref(value));
|
||||
crate::shell_bridge::ui(move |mut b| b.as_mut().set_system_title_bar_pref(value));
|
||||
Ok(Apply::None)
|
||||
}
|
||||
"hide-title-bar" => {
|
||||
@@ -1323,7 +1323,7 @@ pub async fn settings_select(runtime: &Arc<AppRuntime<LoggingAdapter>>, key: &st
|
||||
save_pref("app_background", serde_json::json!(mode));
|
||||
// Live (pure QML layering; blurred renders AS ambient in the POC).
|
||||
let ambient = if *mode == "off" { 0 } else { 1 };
|
||||
crate::ui(move |mut b| b.as_mut().set_ambient_mode(ambient));
|
||||
crate::shell_bridge::ui(move |mut b| b.as_mut().set_ambient_mode(ambient));
|
||||
}
|
||||
"language" => {
|
||||
let Some(lang) = LANGUAGE_VALUES.get(index) else {
|
||||
|
||||
@@ -0,0 +1,378 @@
|
||||
//! QbzShell — shell-chrome domain bridge (phase 23 split of the QbzBridge
|
||||
//! God-object; the pattern is documented in main.rs). Props: sidebar / queue
|
||||
//! / nav-history / now-playing-bar mode / lyrics panel / window chrome /
|
||||
//! ambient background / theme / sidebar playlist tree / drag & drop.
|
||||
//! Invokables: the shell actions (sidebar cycle, nav, npb mode, theme,
|
||||
//! sidebar tree, drag & drop) — one-line forwards into the crate handlers.
|
||||
|
||||
use std::pin::Pin;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use cxx_qt::CxxQtThread;
|
||||
use cxx_qt::Threading as _;
|
||||
use cxx_qt_lib::QString;
|
||||
|
||||
#[cxx_qt::bridge]
|
||||
pub mod qbz_shell {
|
||||
extern "C++" {
|
||||
include!("cxx-qt-lib/qstring.h");
|
||||
type QString = cxx_qt_lib::QString;
|
||||
}
|
||||
|
||||
#[auto_cxx_name]
|
||||
extern "RustQt" {
|
||||
#[qobject]
|
||||
#[qml_element]
|
||||
#[qml_singleton]
|
||||
// --- Shell chrome (Slint ShellState) ----------------------------
|
||||
// Three-state sidebar: 0 = open (240px), 1 = mini (64px), 2 = closed.
|
||||
#[qproperty(i32, sidebar_state)]
|
||||
#[qproperty(bool, queue_open)]
|
||||
// Content view id — only "home" exists (phase 3 adds the rest).
|
||||
#[qproperty(QString, current_view)]
|
||||
// Nav history (src/nav_qt.rs):
|
||||
#[qproperty(bool, can_back)]
|
||||
#[qproperty(bool, can_forward)]
|
||||
|
||||
// Now-playing bar mode (phase 18): 0 New / 1 Classic / 2 Small /
|
||||
// 3 Large — the ui_prefs npb_mode key, live-switchable.
|
||||
#[qproperty(i32, npb_mode)]
|
||||
|
||||
// --- Theme (phase 19) --------------------------------------------
|
||||
// ONE JSON token document (theme_qt.rs ThemeTokens: 30 colors + 24
|
||||
// alpha tiers + ambient derivations + isDark) — QbzTheme.qml binds
|
||||
// to it, so a theme switch repaints the whole app live (the Slint
|
||||
// theme::push_colors equivalent).
|
||||
#[qproperty(QString, theme_json)]
|
||||
// The persisted ui_prefs theme slug ("oled", "auto", "custom", ...).
|
||||
#[qproperty(QString, theme_slug)]
|
||||
// The dropdown catalog (36 registry themes + Auto/Custom rows).
|
||||
#[qproperty(QString, theme_list_json)]
|
||||
// Dropdown filter: 0 All / 1 Dark / 2 Light (ui_prefs theme_filter).
|
||||
#[qproperty(i32, theme_filter)]
|
||||
|
||||
// --- Lyrics panel (phase 9) ----------------------------------------
|
||||
#[qproperty(bool, lyrics_open)]
|
||||
// One JSON document (lyrics_qt.rs LyricsDoc: status/lines/synced/
|
||||
// provider/error).
|
||||
#[qproperty(QString, lyrics_json)]
|
||||
|
||||
// --- Sidebar playlist tree ---------------------------------------
|
||||
// One JSON document: the flattened entries (folders + playlists,
|
||||
// expand/sort/search applied Rust-side — sidebar_qt.rs).
|
||||
#[qproperty(QString, sidebar_json)]
|
||||
#[qproperty(QString, sidebar_sort_by)]
|
||||
#[qproperty(bool, sidebar_sort_asc)]
|
||||
|
||||
// --- Window chrome (phase 12) --------------------------------------
|
||||
// The APPLIED titlebar mode (the ui_prefs `use_system_title_bar`
|
||||
// value read at startup — drives the window flags; never mutated at
|
||||
// runtime, matching the Slint restart semantics).
|
||||
#[qproperty(bool, system_title_bar)]
|
||||
// The PERSISTED pref as it stands NOW (the app-menu check state;
|
||||
// flips live when the user toggles, applies on the next launch).
|
||||
#[qproperty(bool, system_title_bar_pref)]
|
||||
|
||||
// --- Ambient background (phase 14) --------------------------------
|
||||
// 0 = off, 1 = on (the ambient look; the owner's store carries
|
||||
// "ambient"). Live — toggling applies immediately (pure QML
|
||||
// layering). Combined in QML with npHasTrack for the D4 no-track
|
||||
// rule.
|
||||
#[qproperty(i32, ambient_mode)]
|
||||
// Album-art triad (ambient_qt.rs), pushed on track change.
|
||||
#[qproperty(QString, ambient_primary)]
|
||||
#[qproperty(QString, ambient_secondary)]
|
||||
#[qproperty(QString, ambient_accent)]
|
||||
// Look knobs (Slint AppearanceState defaults; QBZ_BG_* env seed).
|
||||
#[qproperty(f32, ambient_dim)]
|
||||
#[qproperty(f32, ambient_surface_alpha)]
|
||||
#[qproperty(f32, ambient_bar_alpha)]
|
||||
|
||||
// --- Drag & drop (phase 17) ----------------------------------------
|
||||
// The shared drag state (DragState in state.slint): the ghost reads
|
||||
// count/title/subtitle + the window-coord pointer; sidebar playlist
|
||||
// rows self-detect the drop via dragX/dragY + over-playlist-id.
|
||||
#[qproperty(bool, drag_active)]
|
||||
#[qproperty(i32, drag_count)]
|
||||
#[qproperty(QString, drag_title)]
|
||||
#[qproperty(QString, drag_subtitle)]
|
||||
#[qproperty(f32, drag_x)]
|
||||
#[qproperty(f32, drag_y)]
|
||||
#[qproperty(QString, drag_over_playlist_id)]
|
||||
|
||||
type QbzShell = super::QbzShellRust;
|
||||
|
||||
/// Registers this object's Qt-thread hop (Main.qml boots EVERY
|
||||
/// domain singleton; only QbzSession.boot also fires crate::on_boot).
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzShell>);
|
||||
|
||||
// --- Shell chrome -------------------------------------------------
|
||||
/// Header panel-left button: cycle the sidebar open -> mini ->
|
||||
/// closed -> open (Slint `ShellState.cycle-sidebar()`).
|
||||
#[qinvokable]
|
||||
fn cycle_sidebar(self: Pin<&mut QbzShell>);
|
||||
/// NPB queue button / queue panel close.
|
||||
#[qinvokable]
|
||||
fn toggle_queue(self: Pin<&mut QbzShell>);
|
||||
/// Header history buttons.
|
||||
#[qinvokable]
|
||||
fn navigate_back(self: Pin<&mut QbzShell>);
|
||||
#[qinvokable]
|
||||
fn navigate_forward(self: Pin<&mut QbzShell>);
|
||||
|
||||
/// NPB lyrics button / lyrics panel close X.
|
||||
#[qinvokable]
|
||||
fn toggle_lyrics(self: Pin<&mut QbzShell>);
|
||||
|
||||
/// Sidebar navigation: record a content view ("home" | "library")
|
||||
/// and lazy-load its data on first visit.
|
||||
#[qinvokable]
|
||||
fn navigate_to(self: Pin<&mut QbzShell>, view: QString);
|
||||
|
||||
/// Now-Playing-view flyout: switch the bar mode (0 New / 1 Classic /
|
||||
/// 2 Small / 3 Large) — persists ui_prefs.npb_mode; Large forces the
|
||||
/// sidebar open (the Slint "large" arm).
|
||||
#[qinvokable]
|
||||
fn npb_set_mode(self: Pin<&mut QbzShell>, mode: i32);
|
||||
|
||||
// --- Theme (phase 19) ---------------------------------------------
|
||||
/// Appearance > Theme row: persist the picked slug + republish
|
||||
/// `themeJson` (live switch).
|
||||
#[qinvokable]
|
||||
fn theme_set(self: Pin<&mut QbzShell>, slug: QString);
|
||||
/// Appearance > theme filter cycle button (0 All / 1 Dark / 2 Light).
|
||||
#[qinvokable]
|
||||
fn theme_set_filter(self: Pin<&mut QbzShell>, index: i32);
|
||||
|
||||
/// App-menu chrome toggle: flip the persisted `use_system_title_bar`
|
||||
/// pref (applies on the next launch — the window flags are fixed at
|
||||
/// creation, 1:1 Slint). Updates `systemTitleBarPref` only.
|
||||
#[qinvokable]
|
||||
fn toggle_system_title_bar(self: Pin<&mut QbzShell>);
|
||||
|
||||
/// App-menu ambient toggle: flip the persisted `app_background` pref
|
||||
/// off <-> "ambient" and apply LIVE (pure QML layering — no restart,
|
||||
/// unlike the titlebar).
|
||||
#[qinvokable]
|
||||
fn toggle_ambient_background(self: Pin<&mut QbzShell>);
|
||||
|
||||
/// Sidebar tree: rebuild + republish after load / sort / search /
|
||||
/// folder toggle.
|
||||
#[qinvokable]
|
||||
fn reload_sidebar(self: Pin<&mut QbzShell>);
|
||||
#[qinvokable]
|
||||
fn sidebar_set_sort(self: Pin<&mut QbzShell>, option: QString);
|
||||
#[qinvokable]
|
||||
fn sidebar_search(self: Pin<&mut QbzShell>, query: QString);
|
||||
#[qinvokable]
|
||||
fn sidebar_toggle_folder(self: Pin<&mut QbzShell>, id: QString);
|
||||
/// Sidebar "+" — create an empty playlist (single core call), then
|
||||
/// reload the tree.
|
||||
#[qinvokable]
|
||||
fn create_playlist(self: Pin<&mut QbzShell>);
|
||||
/// Sidebar cover dispatch: JSON array of cover URLS (the tree's
|
||||
/// collage is url-keyed, unlike the feed's artKey).
|
||||
#[qinvokable]
|
||||
fn sidebar_artwork_window(self: Pin<&mut QbzShell>, urls_json: QString);
|
||||
|
||||
// --- Drag & drop (phase 17) ----------------------------------------
|
||||
/// Track-row press-drag start (row id, ghost texts, window coords).
|
||||
#[qinvokable]
|
||||
fn drag_start(self: Pin<&mut QbzShell>, track_id: QString, title: QString, subtitle: QString, x: f32, y: f32);
|
||||
#[qinvokable]
|
||||
fn drag_move(self: Pin<&mut QbzShell>, x: f32, y: f32);
|
||||
/// A sidebar playlist row claims / releases the drop target.
|
||||
#[qinvokable]
|
||||
fn drag_set_over(self: Pin<&mut QbzShell>, playlist_id: QString);
|
||||
/// Release: add the dragged track(s) to the over-playlist target.
|
||||
#[qinvokable]
|
||||
fn drag_end(self: Pin<&mut QbzShell>);
|
||||
}
|
||||
|
||||
impl cxx_qt::Threading for QbzShell {}
|
||||
}
|
||||
|
||||
use qbz_shell::QbzShell;
|
||||
|
||||
/// Rust side of the shell bridge (plain storage, phase-1 pattern).
|
||||
pub struct QbzShellRust {
|
||||
sidebar_state: i32,
|
||||
queue_open: bool,
|
||||
current_view: QString,
|
||||
can_back: bool,
|
||||
can_forward: bool,
|
||||
npb_mode: i32,
|
||||
theme_json: QString,
|
||||
theme_slug: QString,
|
||||
theme_list_json: QString,
|
||||
theme_filter: i32,
|
||||
lyrics_open: bool,
|
||||
lyrics_json: QString,
|
||||
sidebar_json: QString,
|
||||
sidebar_sort_by: QString,
|
||||
sidebar_sort_asc: bool,
|
||||
system_title_bar: bool,
|
||||
system_title_bar_pref: bool,
|
||||
ambient_mode: i32,
|
||||
ambient_primary: QString,
|
||||
ambient_secondary: QString,
|
||||
ambient_accent: QString,
|
||||
ambient_dim: f32,
|
||||
ambient_surface_alpha: f32,
|
||||
ambient_bar_alpha: f32,
|
||||
drag_active: bool,
|
||||
drag_count: i32,
|
||||
drag_title: QString,
|
||||
drag_subtitle: QString,
|
||||
drag_x: f32,
|
||||
drag_y: f32,
|
||||
drag_over_playlist_id: QString,
|
||||
}
|
||||
|
||||
impl Default for QbzShellRust {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
sidebar_state: 0,
|
||||
queue_open: false,
|
||||
current_view: QString::from("home"),
|
||||
can_back: false,
|
||||
can_forward: false,
|
||||
npb_mode: crate::settings_qt::npb_mode_index(),
|
||||
theme_json: QString::from(crate::theme_qt::theme_json().as_str()),
|
||||
theme_slug: QString::from(crate::theme_qt::current_slug().as_str()),
|
||||
theme_list_json: QString::from(crate::theme_qt::theme_list_json().as_str()),
|
||||
theme_filter: crate::theme_qt::theme_filter(),
|
||||
lyrics_open: false,
|
||||
lyrics_json: QString::from("{}"),
|
||||
sidebar_json: QString::from("[]"),
|
||||
sidebar_sort_by: QString::from("name"),
|
||||
sidebar_sort_asc: true,
|
||||
system_title_bar: crate::settings_qt::use_system_title_bar(),
|
||||
system_title_bar_pref: crate::settings_qt::use_system_title_bar(),
|
||||
ambient_mode: crate::settings_qt::app_background_mode(),
|
||||
// The Slint ImmersiveState default triad (pre-artwork colors).
|
||||
ambient_primary: QString::from("#00dcc8"),
|
||||
ambient_secondary: QString::from("#9632ff"),
|
||||
ambient_accent: QString::from("#3fd9c8"),
|
||||
ambient_dim: crate::settings_qt::ambient_dim(),
|
||||
ambient_surface_alpha: crate::settings_qt::ambient_surface_alpha(),
|
||||
ambient_bar_alpha: crate::settings_qt::ambient_bar_alpha(),
|
||||
drag_active: false,
|
||||
drag_count: 0,
|
||||
drag_title: QString::default(),
|
||||
drag_subtitle: QString::default(),
|
||||
drag_x: 0.0,
|
||||
drag_y: 0.0,
|
||||
drag_over_playlist_id: QString::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// The UI hop (bridges/mod.rs pattern)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
static QT_THREAD: OnceLock<CxxQtThread<QbzShell>> = OnceLock::new();
|
||||
|
||||
/// Queue a shell-bridge mutation onto the Qt event loop (no-op before
|
||||
/// boot registers the thread).
|
||||
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzShell>) + Send + 'static) {
|
||||
if let Some(thread) = QT_THREAD.get() {
|
||||
let _ = thread.queue(f);
|
||||
}
|
||||
}
|
||||
|
||||
impl qbz_shell::QbzShell {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
log::warn!("[qbz-qt] shell Qt thread already registered");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cycle_sidebar(mut self: Pin<&mut Self>) {
|
||||
let next = (self.sidebar_state() + 1) % 3;
|
||||
self.as_mut().set_sidebar_state(next);
|
||||
}
|
||||
|
||||
pub fn toggle_queue(mut self: Pin<&mut Self>) {
|
||||
let next = !self.queue_open();
|
||||
self.as_mut().set_queue_open(next);
|
||||
}
|
||||
|
||||
pub fn navigate_back(self: Pin<&mut Self>) {
|
||||
crate::nav_qt::back();
|
||||
}
|
||||
|
||||
pub fn navigate_forward(self: Pin<&mut Self>) {
|
||||
crate::nav_qt::forward();
|
||||
}
|
||||
|
||||
pub fn toggle_lyrics(self: Pin<&mut Self>) {
|
||||
crate::toggle_lyrics();
|
||||
}
|
||||
|
||||
pub fn navigate_to(self: Pin<&mut Self>, view: QString) {
|
||||
crate::navigate_to(&view.to_string());
|
||||
}
|
||||
|
||||
pub fn npb_set_mode(self: Pin<&mut Self>, mode: i32) {
|
||||
crate::npb_set_mode(mode);
|
||||
}
|
||||
|
||||
pub fn theme_set(self: Pin<&mut Self>, slug: QString) {
|
||||
crate::theme_set(slug.to_string());
|
||||
}
|
||||
|
||||
pub fn theme_set_filter(self: Pin<&mut Self>, index: i32) {
|
||||
crate::theme_set_filter(index);
|
||||
}
|
||||
|
||||
pub fn toggle_system_title_bar(self: Pin<&mut Self>) {
|
||||
crate::toggle_system_title_bar();
|
||||
}
|
||||
|
||||
pub fn toggle_ambient_background(self: Pin<&mut Self>) {
|
||||
crate::toggle_ambient_background();
|
||||
}
|
||||
|
||||
pub fn reload_sidebar(self: Pin<&mut Self>) {
|
||||
crate::reload_sidebar();
|
||||
}
|
||||
|
||||
pub fn sidebar_set_sort(self: Pin<&mut Self>, option: QString) {
|
||||
crate::sidebar_set_sort(&option.to_string());
|
||||
}
|
||||
|
||||
pub fn sidebar_search(self: Pin<&mut Self>, query: QString) {
|
||||
crate::sidebar_set_search(&query.to_string());
|
||||
}
|
||||
|
||||
pub fn sidebar_toggle_folder(self: Pin<&mut Self>, id: QString) {
|
||||
crate::sidebar_toggle_folder(&id.to_string());
|
||||
}
|
||||
|
||||
pub fn create_playlist(self: Pin<&mut Self>) {
|
||||
crate::create_playlist();
|
||||
}
|
||||
|
||||
pub fn sidebar_artwork_window(self: Pin<&mut Self>, urls_json: QString) {
|
||||
crate::sidebar_artwork_window(urls_json.to_string());
|
||||
}
|
||||
|
||||
pub fn drag_start(self: Pin<&mut Self>, track_id: QString, title: QString, subtitle: QString, x: f32, y: f32) {
|
||||
crate::drag_start(track_id.to_string(), title.to_string(), subtitle.to_string(), x, y);
|
||||
}
|
||||
|
||||
pub fn drag_move(self: Pin<&mut Self>, x: f32, y: f32) {
|
||||
crate::drag_move(x, y);
|
||||
}
|
||||
|
||||
pub fn drag_set_over(self: Pin<&mut Self>, playlist_id: QString) {
|
||||
crate::drag_set_over(playlist_id.to_string());
|
||||
}
|
||||
|
||||
pub fn drag_end(self: Pin<&mut Self>) {
|
||||
crate::drag_end();
|
||||
}
|
||||
}
|
||||
@@ -270,7 +270,7 @@ pub fn theme_json() -> String {
|
||||
pub fn publish_theme() {
|
||||
let json = theme_json();
|
||||
let slug = current_slug();
|
||||
crate::ui(move |mut b| {
|
||||
crate::shell_bridge::ui(move |mut b| {
|
||||
b.as_mut().set_theme_json(QString::from(json.as_str()));
|
||||
b.as_mut().set_theme_slug(QString::from(slug.as_str()));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user