Ports the whole playlist-organisation domain, which had no counterpart in this frontend, plus the Library work the owner asked not to defer. Playlist Manager. New controller (playlist_manager_qt, _rows, _ops) over the already-ported folders_qt repository, which until now had zero consumers. Grid, list and folder-tree modes; sort, filter and search; folder cards and chips; drag reorder and up/down arrows. Reached from the sidebar's "..." menu, whose New folder / Manage playlists / Import rows had been rendering dimmed and inert behind a comment saying the seam did not exist. Folders. QbzFolderEdit plus the create/edit modals and PmFolderIcon: preset or custom-image icons, colour, hidden flag, delete. Deleting a folder nulls its LOCAL members' folder_id explicitly, because the app keeps the foreign_keys pragma off, so the schema's ON DELETE SET NULL never fires for them. QbzPlaylistEdit. One shared rename/description/delete editor replacing the inline popup in PlaylistView. Three corrections the old path had wrong: the description is carried through a rename instead of being written as NULL, a FOLLOWED playlist routes to unsubscribe (playlist/delete returns 200 and silently no-ops on a playlist you do not own), and the post-delete back navigation is conditional on actually being on that playlist's page, so deleting from the manager no longer navigates you off it. Importer. Spotify / Apple Music / Tidal / Deezer, over the shared qbz-playlist-import crate. Picker local mode. The reference's four-case matrix — target local or Qobuz, payload local refs or Qobuz ids. Local playlists list unconditionally and Qobuz ones only when online. Local refs onto a Qobuz playlist write the library.db sidecar at next_playlist_sidecar_position(pid, qobuz_count); the 0-based enumerate the reference used before collided slots and lost rows. The carried payload can no longer be parsed as a catalog id when it is a library row id. Unblocks the local bulk add-to-playlist. Library. A-Z jump strip, Albums list mode, Artists side panel, per-tab persistence and multi-select. Preferences land in the same <data-dir>/qbz/favorites_ui.json the shipping build writes, so switching between the two frontends keeps them. LibraryView is split into views/library/ on the way past 1800 lines. Local library. Group-by now persists; playback queues the order on screen rather than the SQL page order; switching album-identity mode invalidates the Artists tab; artist matching folds diacritics and compares normalized credit parts, so "Air" stops listing "Airbourne" and "Beyonce" stops being two artists. Offline. activate_offline never persisted a last-user marker, so every per-user path resolved to None and all local reads came back empty; a session that started offline saw no local playlists at all. The sidebar's load-once latch was function-local and therefore unreachable from the logout reset, so a second login never rebuilt the tree. Both are session-scoped now, and the sidebar Refresh row runs the local-safe verb instead of being dimmed with no way to recover. Also fixes, found while verifying rather than reported: artwork derivatives were written straight to their final path, so a QML Image resolving one mid-encode opened a truncated png and Qt cached that failure against the URL for the rest of the session; Library's track group separators referenced a Component declared in another delegate's scope and could never render; the genre filter was drawn on Tracks and Albums but applied only on All; an All-feed row called a player method that does not exist; and the sidebar's drop-hot highlight used Slint's #RRGGBBAA literals in Qt's #AARRGGBB slot. 17 new msgids across all 8 locales. cc
193 lines
7.5 KiB
Rust
193 lines
7.5 KiB
Rust
//! QbzPlaylistEdit — the SHARED playlist editor's QML singleton (contract
|
|
//! §3.3, block 3). Port of `primitives/EditPlaylistModal.slint` plus the
|
|
//! `EditPlaylistActions` handlers in the reference's `main.rs`.
|
|
//!
|
|
//! The third of the three singletons the Playlist Manager surface owns (D2):
|
|
//! `QbzPlaylistManager` holds the manager document and the organisation
|
|
//! writes, `QbzFolderEdit` owns the two folder panels, and this one owns the
|
|
//! ONE rename / description / offline-only / delete modal — for BOTH kinds of
|
|
//! playlist (`local:<uuid>` and a Qobuz `u64`) and from every surface that
|
|
//! offers "Edit playlist":
|
|
//!
|
|
//! * the manager's grid card, list row and tree row (block 4),
|
|
//! * the sidebar's row context menu (block 5),
|
|
//! * the playlist DETAIL header's pencil (block 7) — which is why
|
|
//! `qml/views/PlaylistView.qml`'s inline rename+delete popup is deleted:
|
|
//! it could express neither a description nor the offline-only flag, and
|
|
//! a second editor is exactly the fork the port rule forbids.
|
|
//!
|
|
//! It is a SEPARATE singleton from `QbzPlaylist` for the same reason
|
|
//! `QbzPlaylistPicker` is: its callers live outside the detail view, and in
|
|
//! most of those sessions no playlist detail is open at all — so nothing here
|
|
//! may read the open document, and a detail republish can never perturb an
|
|
//! open editor.
|
|
//!
|
|
//! # ONE document, and the id is NOT in QML's hands
|
|
//!
|
|
//! `editJson` (§4.6) carries the seeds plus `descLoaded`, `isLocal` and
|
|
//! `busy`. The id being edited lives in RUST state and is never echoed back
|
|
//! from QML: a republish can then never make the modal save under the wrong
|
|
//! id, which is the same rule `folder_edit_qt` holds the folder id under.
|
|
//!
|
|
//! # `descLoaded` is load-bearing, not cosmetic (§5.2)
|
|
//!
|
|
//! `false` means the real description could not be resolved. The modal then
|
|
//! does NOT render the description field at all and `save` passes `None`,
|
|
//! which `update_playlist` reads as "leave it alone". A field the user never
|
|
//! saw can never overwrite stored data. The reference seeds `""` and always
|
|
//! sends `Some(trimmed)`, so renaming a Qobuz playlist from its manager
|
|
//! DELETES its description; the local branch writes SQL NULL. Neither is
|
|
//! ported.
|
|
//!
|
|
//! # `busy` HOLDS THE MODAL OPEN (D22)
|
|
//!
|
|
//! Save and delete disarm the buttons and keep the panel up; it closes on
|
|
//! success only, and a failure stays open and toasts. `close()` is refused
|
|
//! while busy. Same shape as the folder panels.
|
|
//!
|
|
//! **No `#[qsignal]`** — outcomes are republishes and toasts
|
|
//! (`playlist_picker_bridge.rs:13`).
|
|
//!
|
|
//! `delete` is a C++ keyword, so the member is `delete_playlist` /
|
|
//! `deletePlaylist` (§3.3). The module is `qbz_playlist_edit_bridge` — a
|
|
//! bridge module is never named after a workspace crate (E0659).
|
|
|
|
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_playlist_edit_bridge {
|
|
extern "C++" {
|
|
include!("cxx-qt-lib/qstring.h");
|
|
type QString = cxx_qt_lib::QString;
|
|
}
|
|
|
|
#[auto_cxx_name]
|
|
extern "RustQt" {
|
|
#[qobject]
|
|
#[qml_element]
|
|
#[qml_singleton]
|
|
// The ONE editor document (§4.6): open / id / name / description /
|
|
// descLoaded / isLocal / offlineOnly / busy. Parseable default so a
|
|
// binding reading `doc.open` on the pre-publish frame cannot throw.
|
|
#[qproperty(QString, edit_json)]
|
|
|
|
type QbzPlaylistEdit = super::QbzPlaylistEditRust;
|
|
|
|
/// Registers this object's Qt-thread hop. Without it every `ui()`
|
|
/// publish from Rust is dropped on the floor, silently and forever:
|
|
/// the modal mounts, no document ever arrives, `editJson` stays at
|
|
/// its default and NOTHING is logged on either side.
|
|
#[qinvokable]
|
|
fn boot(self: Pin<&mut QbzPlaylistEdit>);
|
|
|
|
/// Open the editor on `id` — either a Qobuz `u64` spelled as a string
|
|
/// or a `local:<uuid>`. The seeds (name, description, offline-only)
|
|
/// are resolved BEFORE the modal opens, so it never flashes an empty
|
|
/// name field; §5.2 gives the resolution order per kind.
|
|
///
|
|
/// A `local:` id resolves through a pure DB read, so the editor works
|
|
/// offline and for an account-less user — the population local
|
|
/// playlists exist for.
|
|
#[qinvokable]
|
|
fn open(self: Pin<&mut QbzPlaylistEdit>, id: QString);
|
|
|
|
/// Persist. Name / description / offline-only are QML-LOCAL drafts and
|
|
/// arrive as arguments (`MyQbzModals.qml`'s convention); the id and
|
|
/// `descLoaded` are Rust-owned. `offline_only` is ignored for a Qobuz
|
|
/// playlist — the flag is a local-playlist column.
|
|
#[qinvokable]
|
|
fn save(
|
|
self: Pin<&mut QbzPlaylistEdit>,
|
|
name: QString,
|
|
description: QString,
|
|
offline_only: bool,
|
|
);
|
|
|
|
/// Delete the open playlist. `delete` is a C++ keyword, hence the
|
|
/// name. A Qobuz playlist re-derives ownership first and a FOLLOWED
|
|
/// one is unsubscribed instead (§5.1); the back-navigation is
|
|
/// CONDITIONAL on the user actually standing on that playlist's
|
|
/// detail page.
|
|
#[qinvokable]
|
|
fn delete_playlist(self: Pin<&mut QbzPlaylistEdit>);
|
|
|
|
/// Dismiss. Refused while a save or delete is in flight (D22).
|
|
#[qinvokable]
|
|
fn close(self: Pin<&mut QbzPlaylistEdit>);
|
|
}
|
|
|
|
impl cxx_qt::Threading for QbzPlaylistEdit {}
|
|
}
|
|
|
|
use qbz_playlist_edit_bridge::QbzPlaylistEdit;
|
|
|
|
/// Rust side of the playlist-editor bridge (plain storage, phase-1 pattern).
|
|
pub struct QbzPlaylistEditRust {
|
|
edit_json: QString,
|
|
}
|
|
|
|
impl Default for QbzPlaylistEditRust {
|
|
fn default() -> Self {
|
|
Self {
|
|
// Closed and parseable: `doc.open === true` on frame 1 is false,
|
|
// and no binding in the modal throws before the first publish.
|
|
edit_json: QString::from("{\"open\":false}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// The UI hop
|
|
// ---------------------------------------------------------------------------
|
|
|
|
static QT_THREAD: OnceLock<CxxQtThread<QbzPlaylistEdit>> = OnceLock::new();
|
|
|
|
/// Queue an editor mutation onto the Qt event loop (no-op before `boot()`
|
|
/// registers the thread).
|
|
pub(crate) fn ui(f: impl FnOnce(Pin<&mut QbzPlaylistEdit>) + Send + 'static) {
|
|
if let Some(thread) = QT_THREAD.get() {
|
|
let _ = thread.queue(f);
|
|
}
|
|
}
|
|
|
|
impl qbz_playlist_edit_bridge::QbzPlaylistEdit {
|
|
pub fn boot(self: Pin<&mut Self>) {
|
|
if QT_THREAD.set(self.qt_thread()).is_err() {
|
|
log::warn!("[qbz-qt] playlist edit Qt thread already registered");
|
|
}
|
|
// Publish the closed document once, so the modal's parse sees the
|
|
// full shape rather than the terser Default literal.
|
|
crate::playlist_edit_qt::publish();
|
|
}
|
|
|
|
pub fn open(self: Pin<&mut Self>, id: QString) {
|
|
crate::playlist_edit_qt::open(&id.to_string());
|
|
}
|
|
|
|
pub fn save(
|
|
self: Pin<&mut Self>,
|
|
name: QString,
|
|
description: QString,
|
|
offline_only: bool,
|
|
) {
|
|
crate::playlist_edit_qt::save(
|
|
&name.to_string(),
|
|
&description.to_string(),
|
|
offline_only,
|
|
);
|
|
}
|
|
|
|
pub fn delete_playlist(self: Pin<&mut Self>) {
|
|
crate::playlist_edit_qt::delete_playlist();
|
|
}
|
|
|
|
pub fn close(self: Pin<&mut Self>) {
|
|
crate::playlist_edit_qt::close();
|
|
}
|
|
}
|