feat(slint): add-to-playlist duplicate modal + playlist importer port

Add-to-playlist (Slices 0-3):
- qbz-core: check_playlist_duplicates + pure compute_playlist_duplicates
  (reuses qbz_models::PlaylistDuplicateResult) + unit tests.
- PlaylistDuplicateConfirmModal (Add all / Add new only / Cancel); the
  duplicate check runs on the Qobuz->Qobuz picker branch only (local/Plex
  add directly, mirroring Tauri); the track-id Vec lives Rust-side in a
  stash, never in Slint.
- Inline create-and-add in the picker (online create_playlist, offline ->
  local playlist per D8) + client-side filter (Slint 1.16 has no string
  contains, routed through a Rust callback) + success toasts.

Playlist importer (1:1 Tauri port):
- New headless crate qbz-playlist-import (Spotify/Apple/Tidal/Deezer
  scrapers, Qobuz matcher, importer, progress sink, shared http client;
  copy-not-move from src-tauri, zero tauri deps; 40 unit tests green).
- PlaylistImportModal (two-step fetch-preview -> import with live progress
  bar / log / summary) + controller + sidebar PLAYLISTS menu entry point.

Reco logging staged behind TODO(reco-v1) markers (golden rule: playlist
recommendations ship in Slint v1 once the reco engine is extracted to a
shared crate).

cc
This commit is contained in:
vicrodh committed 2026-06-11 22:03:46 -06:00
1 parent 999ded11ff
commit 3689a5fda8
33 files changed
+5664 -129

No files matched your search

+1
View File
@@ -56,6 +56,7 @@ qbz-plex = { path = "../qbz-plex" }
qbz-offline-cache = { path = "../qbz-offline-cache" }
qbz-models = { path = "../qbz-models" }
qbz-mixtape = { path = "../qbz-mixtape" }
qbz-playlist-import = { path = "../qbz-playlist-import" }
qbz-qobuz = { path = "../qbz-qobuz" }
qbz-lyrics = { path = "../qbz-lyrics" }
qbz-integrations = { path = "../qbz-integrations" }
File diff suppressed because it is too large. Load diff
+486
View File
@@ -0,0 +1,486 @@
//! Playlist Importer controller — the Rust side of the "Import Playlist"
//! modal (PlaylistImportModal.slint), a 1:1 port of Tauri's
//! PlaylistImportModal.svelte driven by the headless `qbz-playlist-import`
//! crate. Every interpolated string (log lines, status line, summary
//! block) is formatted HERE and pushed into PlaylistImportState
//! pre-formatted; provider detection lives here too (Slint 1.16 strings
//! have no `.contains`, so every URL keystroke round-trips through
//! `url-edited`).
//!
//! Close-mid-import semantics (spec §1.8): closing the modal never cancels
//! the tokio import task. On completion the toast + sidebar refresh still
//! fire (main.rs arm); navigation happens only while the modal is still
//! open AND the run's generation is current. [`GENERATION`] is bumped on
//! every open() and execute(), so a stale run's sink events / completion
//! can never touch a reopened modal's fresh state.
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::{LazyLock, Mutex};
use slint::{ComponentHandle, Model, ModelRc, VecModel};
use qbz_playlist_import::{
detect_provider_key, ImportEvent, ImportPhase, ImportPlaylist, ImportProgressSink,
ImportProvider, ImportSummary, ProviderKey,
};
use crate::{AppWindow, ImportLogEntry, PlaylistImportState, SidebarState};
/// Rust-side mirror of the Svelte component state that never reaches the
/// UI (sidebar.rs module-state pattern). Reset wholesale on every open.
#[derive(Default)]
struct Session {
preview: Option<ImportPlaylist>,
/// Trimmed URL the preview was fetched for (Svelte `previewUrl`).
preview_url: String,
/// Provider locked at fetch time; survives URL edits until the reset
/// paths clear it (Svelte `lockedProvider`).
locked_provider: Option<ProviderKey>,
/// Trimmed URL of the last completed import (Svelte `lastImportedUrl`).
last_imported_url: String,
/// 5%-milestone tracker for the matching log lines (-1 = none yet).
last_logged_percent: i32,
/// Mirror of the modal's rename field, kept fresh by `name-edited`
/// and read at execute time (Svelte `customName`).
custom_name: String,
}
static SESSION: LazyLock<Mutex<Session>> = LazyLock::new(|| Mutex::new(Session::default()));
/// Import generation (§1.8): bumped on every open() and execute(). Sink
/// events and task completions carry the generation they were spawned
/// with; a mismatch means the modal was reset for a fresh run, so the
/// stale run may only fire toast + sidebar refresh, never modal writes.
static GENERATION: AtomicU64 = AtomicU64::new(0);
pub fn current_generation() -> u64 {
GENERATION.load(Ordering::SeqCst)
}
fn bump_generation() -> u64 {
GENERATION.fetch_add(1, Ordering::SeqCst) + 1
}
/// Open the modal fully reset — Tauri remounts the Svelte component on
/// every open, so nothing persists. Event-loop thread.
pub fn open(window: &AppWindow) {
// Invalidate any in-flight run's modal writes before resetting.
bump_generation();
*SESSION.lock().unwrap() = Session::default();
let state = window.global::<PlaylistImportState>();
state.set_url("".into());
state.set_custom_name("".into());
state.set_loading(false);
state.set_error("".into());
state.set_active_provider("".into());
state.set_can_fetch(false);
state.set_show_preview(false);
state.set_import_completed(false);
state.set_progress_visible(false);
state.set_has_progress(false);
state.set_progress(0.0);
state.set_status_line("".into());
state.set_current_track("".into());
state.set_log(ModelRc::new(VecModel::from(Vec::<ImportLogEntry>::new())));
clear_summary(window);
// Folder dropdown from the sidebar's folder list — the exact
// create-playlist builder pattern: index 0 = "No folder" (id "").
let folders = window.global::<SidebarState>().get_folders();
let mut opts: Vec<slint::SharedString> = vec!["No folder".into()];
let mut ids: Vec<slint::SharedString> = vec!["".into()];
for i in 0..folders.row_count() {
if let Some(f) = folders.row_data(i) {
opts.push(f.name);
ids.push(f.id);
}
}
state.set_folder_options(ModelRc::new(VecModel::from(opts)));
state.set_folder_ids(ModelRc::new(VecModel::from(ids)));
state.set_folder_index(0);
state.set_open(true);
}
/// Recompute the URL-derived properties on every keystroke (Svelte's
/// derived detectedProvider / activeProvider / isValid / showPreview),
/// plus the post-completion fresh-import reset path. Event-loop thread.
pub fn on_url_edited(window: &AppWindow, text: &str) {
let state = window.global::<PlaylistImportState>();
let trimmed = text.trim();
let detected = detect_provider_key(text);
let mut s = SESSION.lock().unwrap();
// After a completed import, editing the URL away from the imported
// one rearms the modal for a fresh import without reopening.
if state.get_import_completed() && trimmed != s.last_imported_url {
s.locked_provider = None;
state.set_import_completed(false);
state.set_error("".into());
state.set_log(ModelRc::new(VecModel::from(Vec::<ImportLogEntry>::new())));
state.set_progress_visible(false);
state.set_has_progress(false);
state.set_progress(0.0);
state.set_status_line("".into());
state.set_current_track("".into());
clear_summary(window);
}
let active = s.locked_provider.or(detected);
state.set_active_provider(active.map(|p| p.as_str()).unwrap_or("").into());
state.set_can_fetch(detected.is_some() && !crate::offline_mode::engine().is_offline());
state.set_show_preview(s.preview.is_some() && trimmed == s.preview_url);
}
/// Keep the session's rename mirror fresh (read back by
/// [`begin_execute`]). Fired on every name-LineEdit keystroke.
pub fn on_name_edited(text: &str) {
SESSION.lock().unwrap().custom_name = text.to_string();
}
/// Step A gate + reset (Svelte handlePreview's pre-invoke block). Returns
/// the URL to fetch, or None when the gate fails. Event-loop thread.
pub fn begin_fetch(window: &AppWindow) -> Option<String> {
let state = window.global::<PlaylistImportState>();
if state.get_loading() || !state.get_can_fetch() {
return None;
}
let url = state.get_url().to_string();
let detected = detect_provider_key(&url)?;
{
let mut s = SESSION.lock().unwrap();
s.preview = None;
s.preview_url.clear();
s.locked_provider = Some(detected);
}
state.set_loading(true);
state.set_error("".into());
state.set_show_preview(false);
state.set_import_completed(false);
state.set_active_provider(detected.as_str().into());
state.set_has_progress(false);
state.set_progress(0.0);
state.set_status_line("".into());
state.set_current_track("".into());
clear_summary(window);
state.set_log(ModelRc::new(VecModel::from(Vec::<ImportLogEntry>::new())));
push_log(window, "Checking playlist link...".to_string(), "info");
state.set_progress_visible(true);
Some(url)
}
/// Preview fetch succeeded (Svelte handlePreview's try arm). Event-loop.
pub fn apply_preview_ok(window: &AppWindow, url: &str, preview: ImportPlaylist) {
let state = window.global::<PlaylistImportState>();
let count = preview.tracks.len();
let provider = provider_display_name(&preview.provider);
state.set_custom_name(preview.name.as_str().into());
{
let mut s = SESSION.lock().unwrap();
s.custom_name = preview.name.clone();
s.preview_url = url.trim().to_string();
s.preview = Some(preview);
}
push_log(
window,
format!("Found {} tracks from {}.", count, provider),
"success",
);
state.set_loading(false);
// The URL input is disabled during the fetch, so it still equals the
// fetched URL — step B (rename + Import) becomes visible.
state.set_show_preview(
state.get_url().trim() == SESSION.lock().unwrap().preview_url.as_str(),
);
}
/// Preview fetch failed (Svelte handlePreview's catch arm). Event-loop.
pub fn apply_preview_err(window: &AppWindow, err: &str) {
let state = window.global::<PlaylistImportState>();
state.set_error(err.into());
push_log(window, format!("Import failed: {}", err), "error");
state.set_loading(false);
}
/// Everything the execute task needs, snapshotted on the event loop.
pub struct ExecuteArgs {
pub url: String,
pub name_override: Option<String>,
/// Local folder id chosen in the dropdown ("" = no folder).
pub folder_id: String,
/// The run's generation (§1.8), carried by the sink and the
/// completion arms.
pub generation: u64,
}
/// Step B gate + reset (Svelte handleExecute's pre-invoke block).
/// Event-loop thread.
pub fn begin_execute(window: &AppWindow) -> Option<ExecuteArgs> {
let state = window.global::<PlaylistImportState>();
if state.get_loading() || state.get_import_completed() {
return None;
}
let (url, name_override) = {
let mut s = SESSION.lock().unwrap();
let source_name = s.preview.as_ref()?.name.clone();
// Rename goes out only when it differs from the source name; an
// empty rename falls back to the source name (Appendix A).
let custom = s.custom_name.trim().to_string();
let name_override = if custom != source_name && !custom.is_empty() {
Some(custom)
} else {
None
};
s.last_logged_percent = -1;
(s.preview_url.clone(), name_override)
};
let folder_id = {
let ids = state.get_folder_ids();
ids.row_data(state.get_folder_index() as usize)
.map(|s| s.to_string())
.unwrap_or_default()
};
state.set_loading(true);
state.set_error("".into());
state.set_progress_visible(true);
Some(ExecuteArgs {
url,
name_override,
folder_id,
generation: bump_generation(),
})
}
/// One sink event onto the modal — the two Svelte event listeners. The
/// generation is checked by the caller (SlintSink). Event-loop thread.
pub fn apply_event(window: &AppWindow, event: ImportEvent) {
let state = window.global::<PlaylistImportState>();
match event {
ImportEvent::Phase(phase) => match phase {
ImportPhase::Matching => {
push_log(window, "Searching Qobuz catalog...".to_string(), "info");
}
// Creating / Adding re-fire once per created part — log each,
// as Tauri does.
ImportPhase::Creating => {
push_log(window, "Creating playlist...".to_string(), "success");
}
ImportPhase::Adding => {
push_log(window, "Adding tracks to playlist...".to_string(), "info");
}
},
ImportEvent::Progress(p) => {
// Bar + status update on EVERY event (Tauri parity, no
// coalescing).
state.set_has_progress(p.total > 0);
if p.total > 0 {
state.set_progress(p.current as f32 / p.total as f32);
}
if p.phase == "adding" {
// Status line per phase — deliberate owner deviation from
// the Tauri modal, which reused the "Matching tracks…"
// string here (see qbz_playlist_import::sink::ImportPhase).
let line = format!("Adding tracks: {} / {}", p.current, p.total);
state.set_status_line(line.as_str().into());
// One log line per 50-track chunk event (chunk counts,
// not tracks) — Tauri logs every adding event.
push_log(window, line, "info");
} else if p.total > 0 {
let line = format!(
"Matching tracks: {} / {} ({} found)",
group_thousands(p.current),
group_thousands(p.total),
group_thousands(p.matched_so_far)
);
state.set_status_line(line.as_str().into());
// Matching is high-frequency (one event per track): log
// only at 5% milestones, exactly like the Svelte listener.
let pct = (p.current as u64 * 100 / p.total as u64) as i32;
let should_log = {
let mut s = SESSION.lock().unwrap();
if pct >= s.last_logged_percent + 5 {
s.last_logged_percent = pct;
true
} else {
false
}
};
if should_log {
push_log(window, line, "info");
}
}
state.set_current_track(p.current_track.unwrap_or_default().into());
}
}
}
/// Import finished (Svelte handleExecute's success arm): completion logs
/// + summary block + import-completed. Toast / sidebar refresh /
/// navigation live in the main.rs arm (§1.8: those fire even after
/// close; this fn is generation-guarded by the caller). Event-loop.
pub fn apply_execute_ok(window: &AppWindow, summary: &ImportSummary) {
let state = window.global::<PlaylistImportState>();
{
let mut s = SESSION.lock().unwrap();
s.last_imported_url = s.preview_url.clone();
}
state.set_import_completed(true);
push_log(
window,
format!(
"Imported {} of {} tracks into QBZ.",
summary.matched_tracks, summary.total_tracks
),
"success",
);
if !summary.qobuz_playlist_ids.is_empty() {
if summary.parts_created > 1 {
push_log(window, parts_line(summary.parts_created), "success");
} else {
push_log(window, "Playlist created in Qobuz™.".to_string(), "success");
}
} else {
push_log(window, "No matching tracks found.".to_string(), "error");
}
// Summary block (pre-formatted; "" = hidden). `playlist_name` is the
// name the playlist was created under — rename included (deliberate
// owner fix vs the Tauri original, see qbz_playlist_import::importer).
state.set_summary_playlist(format!("Playlist: {}", summary.playlist_name).into());
state.set_summary_matched(
format!(
"Tracks matched: {} / {}",
summary.matched_tracks, summary.total_tracks
)
.into(),
);
state.set_summary_skipped(format!("Skipped: {}", summary.skipped_tracks).into());
state.set_summary_parts(if summary.parts_created > 1 {
parts_line(summary.parts_created).into()
} else {
"".into()
});
// The bar/status hide with loading, as in Tauri (`loading` gates the
// bar there).
state.set_has_progress(false);
state.set_status_line("".into());
state.set_current_track("".into());
state.set_loading(false);
}
/// Import failed (Svelte handleExecute's catch arm). The error toast
/// lives in the main.rs arm. Event-loop thread.
pub fn apply_execute_err(window: &AppWindow, err: &str) {
let state = window.global::<PlaylistImportState>();
state.set_error(err.into());
push_log(window, format!("Import failed: {}", err), "error");
state.set_has_progress(false);
state.set_status_line("".into());
state.set_current_track("".into());
state.set_loading(false);
}
/// Streams crate events onto the modal via the established
/// `upgrade_in_event_loop` cross-thread hop — one hop per event, the same
/// frequency profile as the artwork/scan pipelines (Tauri also updated
/// the bar per event, no coalescing).
pub struct SlintSink {
weak: slint::Weak<AppWindow>,
generation: u64,
}
impl SlintSink {
pub fn new(weak: slint::Weak<AppWindow>, generation: u64) -> Self {
Self { weak, generation }
}
}
impl ImportProgressSink for SlintSink {
fn emit(&self, event: ImportEvent) {
let generation = self.generation;
let _ = self.weak.upgrade_in_event_loop(move |w| {
// Stale generation = the modal was reset (reopened) while
// this run was in flight — its events must never touch the
// fresh modal state (§1.8).
if generation == current_generation() {
apply_event(&w, event);
}
});
}
}
/// Append one pre-formatted line to the conversion log (append-only
/// VecModel). Event-loop thread.
fn push_log(window: &AppWindow, message: String, status: &str) {
let state = window.global::<PlaylistImportState>();
let log = state.get_log();
let entry = ImportLogEntry {
message: message.into(),
status: status.into(),
};
if let Some(vec) = log.as_any().downcast_ref::<VecModel<ImportLogEntry>>() {
vec.push(entry);
} else {
// First write after the .slint default literal — swap in a
// VecModel (open()/begin_fetch() normally install one already).
let mut entries: Vec<ImportLogEntry> = log.iter().collect();
entries.push(entry);
state.set_log(ModelRc::new(VecModel::from(entries)));
}
}
fn clear_summary(window: &AppWindow) {
let state = window.global::<PlaylistImportState>();
state.set_summary_playlist("".into());
state.set_summary_matched("".into());
state.set_summary_skipped("".into());
state.set_summary_parts("".into());
}
/// "Split into {count} playlists (Qobuz 2000-track limit)" — used as both
/// a log line and the summary parts line, as in Tauri.
fn parts_line(count: u32) -> String {
format!("Split into {} playlists (Qobuz 2000-track limit)", count)
}
/// Display names for the "Found N tracks from {provider}." log (Svelte
/// formatProvider). The enum is exhaustive, so Svelte's "Unknown" arm is
/// unreachable here.
fn provider_display_name(provider: &ImportProvider) -> &'static str {
match provider {
ImportProvider::Spotify => "Spotify",
ImportProvider::AppleMusic => "Apple Music",
ImportProvider::Tidal => "Tidal",
ImportProvider::Deezer => "Deezer",
}
}
/// `toLocaleString()` twin for the matching log/status numbers
/// ("12,345"). Tauri rendered these with the user's locale; fixed en-US
/// grouping is the deliberate choice here.
fn group_thousands(n: u32) -> String {
let digits = n.to_string();
let mut out = String::with_capacity(digits.len() + digits.len() / 3);
for (i, ch) in digits.chars().enumerate() {
if i > 0 && (digits.len() - i) % 3 == 0 {
out.push(',');
}
out.push(ch);
}
out
}
#[cfg(test)]
mod tests {
use super::group_thousands;
#[test]
fn group_thousands_matches_to_locale_string() {
assert_eq!(group_thousands(0), "0");
assert_eq!(group_thousands(999), "999");
assert_eq!(group_thousands(1000), "1,000");
assert_eq!(group_thousands(12345), "12,345");
assert_eq!(group_thousands(1234567), "1,234,567");
}
}
+10 -1
View File
@@ -23,6 +23,7 @@ pub fn open(window: &AppWindow, track_id: &str) {
state.set_track_id(track_id.into());
state.set_track_ids(ModelRc::new(VecModel::from(Vec::<slint::SharedString>::new())));
state.set_playlists(ModelRc::new(VecModel::from(Vec::<PlaylistPickItem>::new())));
state.set_filter_matches(0);
state.set_local_mode(false);
state.set_loading(true);
state.set_open(true);
@@ -39,6 +40,7 @@ pub fn open_multi(window: &AppWindow, ids: &[String], local: bool) {
let model: Vec<slint::SharedString> = ids.iter().map(|s| s.clone().into()).collect();
state.set_track_ids(ModelRc::new(VecModel::from(model)));
state.set_playlists(ModelRc::new(VecModel::from(Vec::<PlaylistPickItem>::new())));
state.set_filter_matches(0);
state.set_local_mode(local);
state.set_loading(true);
state.set_open(true);
@@ -88,7 +90,8 @@ where
pub fn apply(window: &AppWindow, playlists: Vec<PickPlaylist>) {
let items: Vec<PlaylistPickItem> = playlists
.into_iter()
.map(|p| PlaylistPickItem {
.enumerate()
.map(|(i, p)| PlaylistPickItem {
id: p.id.into(),
name: p.name.into(),
tracks_line: if p.tracks > 0 {
@@ -97,9 +100,15 @@ pub fn apply(window: &AppWindow, playlists: Vec<PickPlaylist>) {
"".into()
},
is_local: p.is_local,
// No filter yet on (re)load — every row matches, ranked in
// list order.
filter_rank: i as i32,
})
.collect();
let state = window.global::<PlaylistPickerState>();
state.set_filter_matches(items.len() as i32);
state.set_playlists(ModelRc::new(VecModel::from(items)));
// Reset the filter affordance whenever the list is repopulated.
state.set_filter("".into());
state.set_loading(false);
}
+11 -1
View File
@@ -16,9 +16,10 @@ import { SplashScreen } from "splash/SplashScreen.slint";
import { LoginScreen } from "login/LoginScreen.slint";
import { AppShell } from "shell/AppShell.slint";
import { Toast } from "primitives/Toast.slint";
import { ShellState } from "state.slint";
// Re-export the state globals so the Rust layer can populate them.
export { HomeState, HomeActions, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions } from "state.slint";
export { HomeState, HomeActions, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions } from "state.slint";
// Which top-level screen is shown. The app starts on `splash` while it
// restores a saved session, then resolves to `shell` or `login`.
@@ -37,6 +38,15 @@ export component AppWindow inherits Window {
in property <string> system-font: "";
default-font-family: root.system-font;
// Publish the live window width so content-area views can make
// responsiveness decisions (see ShellState.content-constrained).
init => {
ShellState.window-width = self.width;
}
changed width => {
ShellState.window-width = self.width;
}
in-out property <AppScreen> screen: AppScreen.splash;
// Forwarded to the Rust layer.
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Apple Music" role="img"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%" fill="url(#g)"/><linearGradient id="g" x1=".5" y1=".99" x2=".5" y2=".02"><stop offset="0" stop-color="#FA233B"/><stop offset="1" stop-color="#FB5C74"/></linearGradient><path fill="#ffffff" d="M199 359V199q0-9 10-11l138-28q11-2 12 10v122q0 15-45 20c-57 9-48 105 30 79 30-11 35-40 35-69V88s0-20-17-15l-170 35s-13 2-13 18v203q0 15-45 20c-57 9-48 105 30 79 30-11 35-40 35-69"/></svg>

After

Width:  |  Height:  |  Size: 636 B

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Deezer" role="img"
fill="none" stroke-width="20"
viewBox="0 0 512 512"><rect
width="512" height="512"
rx="15%"
fill="#231f20"/><path stroke="#f1796e" d="M78 241h64m-64 26h64"/><path stroke="#ec2529" d="M78 293h64m-64 26h64m-64 26h64"/><path stroke="#f6dd05" d="M148 293h64m-64 26h64m-64 26h64"/><path stroke="#e78dcc" d="M218 241h64m-64 26h64m-64-52h64m-64-26h64"/><path stroke="#d81996" d="M218 293h64m-64 26h64m-64 26h64"/><path stroke="#d6e465" d="M288 241h64m-64 26h64"/><path stroke="#adda1a" d="M288 293h64m-64 26h64m-64 26h64"/><path stroke="#b0d8e6" d="M358 241h64m-64 26h64m-64-52h64m-64-26h64m-64-26h64"/><path stroke="#56bbe9" d="M358 293h64m-64 26h64m-64 26h64"/></svg>

After

Width:  |  Height:  |  Size: 852 B

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 3v12" />
<path d="m8 11 4 4 4-4" />
<path d="M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4" />
</svg>

After

Width:  |  Height:  |  Size: 326 B

@@ -0,0 +1,2 @@
<?xml version="1.0" standalone="no"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 192 192" fill="none"><path stroke="#000000" stroke-linecap="round" stroke-width="8" d="M140.672 157.486a76.004 76.004 0 0 1-102.464-12.128 76.001 76.001 0 0 1 107.15-107.15 76.004 76.004 0 0 1 12.128 102.464"/><path stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="15" stroke-width="8" d="M124.807 142.105a54.364 54.364 0 1 1 17.296-17.296"/><path stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="15" stroke-width="8" d="M95.997 117.193c11.705 0 21.193-9.488 21.193-21.193 0-11.704-9.488-21.193-21.193-21.193-11.704 0-21.193 9.489-21.193 21.193 0 11.705 9.489 21.193 21.193 21.193Z"/><path fill="#000000" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="15" stroke-width="3.799" d="M95.997 98.103a2.103 2.103 0 1 0 0-4.205 2.103 2.103 0 0 0 0 4.205Z"/><path fill="#000000" d="m121.193 121.196 41.871 41.625Z"/><path stroke="#000000" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="15" stroke-width="12" d="m121.193 121.196 41.871 41.625"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg xmlns="http://www.w3.org/2000/svg"
aria-label="Spotify" role="img"
viewBox="0 0 512 512">
␍<rect
width="512" height="512"
rx="15%"
fill="#3bd75f"/>
␍<circle cx="256" cy="256" fill="#ffffff" r="192"/>
␍<g fill="none" stroke="#3bd75f" stroke-linecap="round">
␍<path d="m141 195c75-20 164-15 238 24" stroke-width="36"/>
␍<path d="m152 257c61-17 144-13 203 24" stroke-width="31"/>
␍<path d="m156 315c54-12 116-17 178 20" stroke-width="24"/>
␍</g>
␍</svg>

After

Width:  |  Height:  |  Size: 576 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
<path d="M16.016 5.323l-5.339 5.339-5.339-5.339-5.339 5.339 5.339 5.339 5.339-5.339 5.339 5.339-5.339 5.339 5.339 5.339 5.339-5.339-5.339-5.339 5.339-5.339zM21.391 10.661l5.302-5.307 5.307 5.307-5.307 5.307z"/>
</svg>

After

Width:  |  Height:  |  Size: 443 B

@@ -0,0 +1,129 @@
// Duplicate-tracks confirm sub-modal — 1:1 with Tauri's
// PlaylistDuplicateConfirmModal.svelte. Shown when a Qobuz-tracks →
// Qobuz-playlist add finds tracks already in the target playlist. Offers
// "Add all tracks" (re-add the duplicates too) or "Add only new tracks"
// (skip duplicates); dismissal is the X / scrim / Escape (Tauri has no
// footer Cancel). The track-id Vec<u64> + duplicate id set live Rust-side
// in a stash cell; this modal only renders the counts and routes the choice.
//
// Mounted in AppShell AFTER PlaylistPickerModal so it stacks above it
// (Slint stacking = declaration order; ADR-009 >= 3000 satisfied by being
// declared last). Conditional mount via `if DuplicateConfirmState.open`
// (ADR-010). Matches the Rectangle-scrim + centered-card pattern of
// PlaylistPickerModal (no PopupWindow, no shared Modal wrapper).
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { DuplicateConfirmState, DuplicateConfirmActions } from "../state.slint";
import { QbzIcon } from "QbzIcon.slint";
import { QbzPrimaryButton } from "QbzPrimaryButton.slint";
import { SecondaryButton } from "SecondaryButton.slint";
export component PlaylistDuplicateConfirmModal inherits Rectangle {
visible: DuplicateConfirmState.open;
if DuplicateConfirmState.open: Rectangle {
background: #000000bf;
// Scrim — click outside to dismiss (gated by busy so a click can't
// cancel mid-add).
TouchArea {
mouse-cursor: default;
clicked => {
if (!DuplicateConfirmState.busy) {
DuplicateConfirmActions.cancel();
}
}
}
Rectangle {
width: Math.min(root.width - 80px, 480px);
height: panel.preferred-height;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.md;
// Tauri's ModalLite card is --bg-primary (#0f0f0f), darker
// than the picker card.
background: Theme.surface-main;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// Swallow clicks so they don't reach the scrim.
TouchArea { }
panel := VerticalLayout {
padding: 20px;
spacing: 16px;
// Title + close.
HorizontalLayout {
Text {
text: @tr("Some of these tracks were already added");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: DuplicateConfirmState.busy ? default : pointer;
enabled: !DuplicateConfirmState.busy;
clicked => {
DuplicateConfirmActions.cancel();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
// Body: how many duplicates, and what each choice does.
Text {
text: @tr("This playlist already contains {} of the {} tracks you're adding. Add only the new ones, or add everything including duplicates.",
DuplicateConfirmState.duplicate-count,
DuplicateConfirmState.total-count);
color: Theme.text-secondary;
font-size: Typography.body;
wrap: word-wrap;
}
// Footer: Add all tracks / Add only new tracks. No Cancel —
// dismissal is the header X / scrim / Escape (Tauri parity).
HorizontalLayout {
alignment: end;
spacing: 10px;
// Add all tracks — re-adds the duplicates too
// (executeAddTracks(false)).
SecondaryButton {
label: DuplicateConfirmState.busy ? @tr("Adding...") : @tr("Add all tracks");
enabled: !DuplicateConfirmState.busy;
clicked => {
DuplicateConfirmActions.add-all();
}
}
// Add only new tracks — skips the duplicates
// (executeAddTracks(true)). Disabled when there is
// nothing left to add (all dupes).
QbzPrimaryButton {
label: DuplicateConfirmState.busy ? @tr("Adding...") : @tr("Add only new tracks");
height: 34px;
enabled: !DuplicateConfirmState.busy
&& DuplicateConfirmState.duplicate-count
< DuplicateConfirmState.total-count;
clicked => {
DuplicateConfirmActions.add-new-only();
}
}
}
}
}
}
}
@@ -0,0 +1,560 @@
// "Import Playlist" modal — 1:1 port of Tauri's PlaylistImportModal.svelte.
// Two-step flow: URL entry → provider auto-detect (Rust-side; Slint 1.16
// has no string `.contains`) → fetch preview → rename + optional folder →
// import with a live progress bar, status line and append-only log, then
// an in-panel Summary block. All interpolated strings arrive pre-formatted
// from the Rust controller; the modal renders them verbatim.
//
// Documented visual deviation (port spec §1.5): Slint/femtovg has no
// grayscale/drop-shadow image filters, so the provider logos homologate to
// opacity 0.45 idle / 1.0 active (no glow/translate/scale), and Tidal's
// black SVG renders through QbzIcon tinted white so it reads on dark
// surfaces in both states.
//
// Close semantics (port spec §1.8): footer Close disables while loading
// (Tauri-verbatim); the header X and the scrim stay clickable mid-import —
// closing only hides the UI, the import task runs to completion.
//
// CJK/femtovg: playlist names, the current-track line and log lines can
// hold Korean/CJK, which femtovg measures at ~0 in both axes — every such
// Text gets BOTH width and height assigned from layout (stretch + fixed
// row heights, overflow: elide), never intrinsic sizing.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { PlaylistImportState, PlaylistImportActions, OfflineState } from "../state.slint";
import { QbzIcon } from "QbzIcon.slint";
import { QbzSelect } from "QbzSelect.slint";
import { LoadingSpinner } from "LoadingSpinner.slint";
import { QbzPrimaryButton } from "QbzPrimaryButton.slint";
import { SecondaryButton } from "SecondaryButton.slint";
export component PlaylistImportModal inherits Rectangle {
visible: PlaylistImportState.open;
if PlaylistImportState.open: Rectangle {
background: #000000bf;
// Scrim — click outside dismisses, even mid-import (§1.8: closing
// only hides the UI, the tokio task keeps running).
TouchArea {
mouse-cursor: default;
clicked => {
PlaylistImportActions.close();
}
}
card := Rectangle {
// Tauri: 560px max, min-height 420px, max-height 90vh.
width: Math.min(root.width - 80px, 560px);
// 140px = header 68 + 2 hairlines + footer 70 (16/34/20); the
// body scrolls inside a Flickable past the 90% clamp.
height: Math.min(Math.max(420px, body.preferred-height + 140px), root.height * 0.9);
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.lg;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// Swallow clicks so they never reach the scrim.
TouchArea { }
panel := VerticalLayout {
padding: 0px;
spacing: 0px;
// Header: Qobuz logo + title + close-x.
header := HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 20px;
padding-bottom: 20px;
spacing: 10px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/qobuz-logo.svg");
width: 26px;
height: 26px;
tint: #ffffff;
opacity: 0.9;
}
}
Text {
text: @tr("Import Playlist");
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
}
// X close — allowed mid-import (§1.8).
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
PlaylistImportActions.close();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
// Body — scrolls when the progress panel outgrows the card.
body-flick := Flickable {
vertical-stretch: 1;
viewport-width: self.width;
viewport-height: body.preferred-height;
body := VerticalLayout {
padding: 24px;
spacing: 16px;
alignment: start;
// Offline banner — fetch is gated (can-fetch goes
// false), the URL input stays enabled.
if OfflineState.offline: Rectangle {
height: offline-row.preferred-height;
border-radius: 8px;
background: #eab3081a;
border-width: 1px;
border-color: #eab3084d;
offline-row := HorizontalLayout {
padding: 12px;
spacing: 10px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/cloud-off.svg");
width: 16px;
height: 16px;
tint: #eab308;
}
}
Text {
text: @tr("This feature requires internet connection");
color: #eab308;
font-size: Typography.legal;
vertical-alignment: center;
horizontal-stretch: 1;
}
}
}
// Error banner (preview or execute failure).
if PlaylistImportState.error != "": Rectangle {
height: error-row.preferred-height;
border-radius: 8px;
background: #ef44441a;
border-width: 1px;
border-color: #ef44444d;
error-row := HorizontalLayout {
padding: 12px;
Text {
text: PlaylistImportState.error;
color: #ef4444;
font-size: Typography.legal;
wrap: word-wrap;
min-height: 20px;
horizontal-stretch: 1;
}
}
}
// URL input — every keystroke routes the detection
// through Rust (url-edited); Enter fetches (step A).
VerticalLayout {
spacing: 8px;
Text {
text: @tr("Playlist URL");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
// The standard 43px input box (PlaylistPicker
// recipe).
url-box := Rectangle {
height: 43px;
border-radius: Radius.sm;
background: Theme.surface-card;
border-width: 1px;
border-color: url-input.has-focus ? Theme.accent : Theme.border-subtle;
opacity: PlaylistImportState.loading ? 0.5 : 1.0;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
Rectangle {
horizontal-stretch: 1;
clip: true;
url-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.link;
vertical-alignment: center;
single-line: true;
enabled: !PlaylistImportState.loading;
text <=> PlaylistImportState.url;
edited => {
PlaylistImportActions.url-edited(self.text);
}
accepted => {
if (!PlaylistImportState.show-preview
&& PlaylistImportState.can-fetch
&& !PlaylistImportState.loading) {
PlaylistImportActions.fetch();
}
}
}
Text {
// Placeholder — Slint TextInput has
// no placeholder property; a sibling
// Text gated on empty text. Plain
// string: not localized in Tauri
// either.
visible: url-input.text == "";
width: 100%;
height: 100%;
text: "https://open.spotify.com/playlist/...";
color: Theme.text-muted;
font-size: Typography.link;
vertical-alignment: center;
overflow: elide;
}
}
}
}
}
// Allowed sources — the detected provider's logo at
// full opacity, the rest dimmed (§1.5 homologation).
VerticalLayout {
spacing: 8px;
Text {
text: @tr("ALLOWED SOURCES");
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
letter-spacing: 0.5px;
}
HorizontalLayout {
spacing: 10px;
alignment: start;
Image {
source: @image-url("../assets/icons/spotify-logo.svg");
width: 70px;
height: 24px;
image-fit: contain;
opacity: PlaylistImportState.active-provider == "spotify" ? 1.0 : 0.45;
}
Image {
source: @image-url("../assets/icons/apple-music-logo.svg");
width: 70px;
height: 24px;
image-fit: contain;
opacity: PlaylistImportState.active-provider == "apple" ? 1.0 : 0.45;
}
// Tidal's SVG is black — tint white so it
// reads on dark surfaces in both states.
QbzIcon {
source: @image-url("../assets/icons/tidal-tidal.svg");
width: 70px;
height: 24px;
tint: #ffffff;
opacity: PlaylistImportState.active-provider == "tidal" ? 1.0 : 0.45;
}
Image {
source: @image-url("../assets/icons/deezer-logo.svg");
width: 70px;
height: 24px;
image-fit: contain;
opacity: PlaylistImportState.active-provider == "deezer" ? 1.0 : 0.45;
}
}
}
// Customization panel (step B): rename + optional
// folder. Editing the URL reverts to step A
// (show-preview recomputes Rust-side).
if PlaylistImportState.show-preview: Rectangle {
height: custom-col.preferred-height;
border-radius: Radius.md;
background: Theme.surface-elevated;
border-width: 1px;
border-color: Theme.border-subtle;
custom-col := VerticalLayout {
padding: 16px;
spacing: 12px;
VerticalLayout {
spacing: 8px;
Text {
text: @tr("Playlist name");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
name-box := Rectangle {
height: 43px;
border-radius: Radius.sm;
background: Theme.surface-card;
border-width: 1px;
border-color: name-input.has-focus ? Theme.accent : Theme.border-subtle;
opacity: name-input.enabled ? 1.0 : 0.5;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
Rectangle {
horizontal-stretch: 1;
clip: true;
name-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.link;
vertical-alignment: center;
single-line: true;
enabled: !PlaylistImportState.loading
&& !PlaylistImportState.import-completed;
text <=> PlaylistImportState.custom-name;
edited => {
PlaylistImportActions.name-edited(self.text);
}
accepted => {
// Enter here executes (step B).
if (!PlaylistImportState.loading
&& !PlaylistImportState.import-completed) {
PlaylistImportActions.execute();
}
}
}
}
}
}
}
// Folder dropdown — only when the user has
// folders (mirrors Tauri; index 0 = "No
// folder").
if PlaylistImportState.folder-options.length > 1: VerticalLayout {
spacing: 8px;
Text {
text: @tr("Folder");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
QbzSelect {
options: PlaylistImportState.folder-options;
current-index: PlaylistImportState.folder-index;
menu-width: 380px;
selected(i) => {
PlaylistImportState.folder-index = i;
}
}
}
}
}
// Progress panel: spinner header, determinate bar,
// status + current-track lines, the log, and the
// Summary block on completion.
if PlaylistImportState.progress-visible: Rectangle {
height: progress-col.preferred-height;
border-radius: Radius.md;
background: Theme.surface-elevated;
border-width: 1px;
border-color: Theme.border-subtle;
progress-col := VerticalLayout {
padding: 16px;
spacing: 10px;
HorizontalLayout {
spacing: 8px;
Text {
text: @tr("Conversion progress");
color: Theme.text-primary;
font-size: Typography.body;
font-weight: Typography.medium;
vertical-alignment: center;
horizontal-stretch: 1;
}
// Tauri: 14px accent ring while loading.
if PlaylistImportState.loading: VerticalLayout {
alignment: center;
LoadingSpinner {
size: 14px;
}
}
}
if PlaylistImportState.has-progress: VerticalLayout {
spacing: 6px;
// Determinate 6px bar (LocalLibrarySettings
// recipe); track in the 8%-alpha tone — the
// panel bg already uses surface-elevated.
Rectangle {
height: 6px;
border-radius: 3px;
background: Theme.border-subtle;
clip: true;
Rectangle {
x: 0;
width: parent.width * Math.min(1.0, PlaylistImportState.progress);
height: parent.height;
border-radius: 3px;
background: Theme.accent;
}
}
// Status line — 12px Tauri metric; fixed
// height (CJK floor) + elide.
Text {
text: PlaylistImportState.status-line;
color: Theme.text-secondary;
font-size: 12px;
height: 18px;
vertical-alignment: center;
overflow: elide;
}
// Current-track line — "Artist - Title"
// while matching, "Part i/n" while adding.
if PlaylistImportState.current-track != "": Text {
text: PlaylistImportState.current-track;
color: Theme.text-muted;
font-size: 11px;
height: 16px;
vertical-alignment: center;
overflow: elide;
}
}
// Append-only log. Height capped via static
// arithmetic over the MODEL LENGTH — never row
// geometry (Recursion-detected footgun). No
// autoscroll (Tauri parity). Render-only rows:
// no TouchAreas here.
if PlaylistImportState.log.length > 0: Flickable {
height: Math.min(PlaylistImportState.log.length * 20px, 160px);
viewport-width: self.width;
viewport-height: PlaylistImportState.log.length * 20px;
VerticalLayout {
spacing: 0px;
for entry in PlaylistImportState.log: Rectangle {
height: 20px;
Text {
width: 100%;
height: 100%;
text: entry.message;
// Hex literals kept — Tauri
// hardcodes them.
color: entry.status == "success" ? #34d399
: (entry.status == "error" ? #f87171 : Theme.text-muted);
font-size: Typography.legal;
vertical-alignment: center;
overflow: elide;
}
}
}
}
// Summary block — pre-formatted lines, hairline
// separated, "" = hidden.
if PlaylistImportState.summary-playlist != "": VerticalLayout {
spacing: 6px;
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
Text {
text: @tr("Summary");
color: Theme.text-primary;
font-size: Typography.body;
font-weight: Typography.semibold;
}
Text {
text: PlaylistImportState.summary-playlist;
color: Theme.text-secondary;
font-size: Typography.legal;
height: 18px;
vertical-alignment: center;
overflow: elide;
}
Text {
text: PlaylistImportState.summary-matched;
color: Theme.text-secondary;
font-size: Typography.legal;
height: 18px;
vertical-alignment: center;
overflow: elide;
}
Text {
text: PlaylistImportState.summary-skipped;
color: Theme.text-secondary;
font-size: Typography.legal;
height: 18px;
vertical-alignment: center;
overflow: elide;
}
if PlaylistImportState.summary-parts != "": Text {
text: PlaylistImportState.summary-parts;
color: Theme.text-secondary;
font-size: Typography.legal;
height: 18px;
vertical-alignment: center;
overflow: elide;
}
}
}
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
footer := HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 16px;
padding-bottom: 20px;
alignment: end;
spacing: 12px;
SecondaryButton {
label: @tr("Close");
enabled: !PlaylistImportState.loading;
clicked => {
PlaylistImportActions.close();
}
}
// The single accent confirm (ADR-008). Step A fetches,
// step B imports; stays visible-but-disabled after
// completion (Tauri parity).
QbzPrimaryButton {
height: 34px;
label: PlaylistImportState.show-preview
? (PlaylistImportState.loading ? @tr("Importing...") : @tr("Import"))
: (PlaylistImportState.loading ? @tr("Fetching...") : @tr("Fetch playlist"));
enabled: PlaylistImportState.show-preview
? (!PlaylistImportState.loading && !PlaylistImportState.import-completed)
: (PlaylistImportState.can-fetch && !PlaylistImportState.loading);
clicked => {
if (PlaylistImportState.show-preview) {
PlaylistImportActions.execute();
} else {
PlaylistImportActions.fetch();
}
}
}
}
}
}
}
}
@@ -1,6 +1,15 @@
// "Add to playlist" picker — a global modal overlay. Lists the user's
// playlists; clicking one adds the pending track to it. Opened from
// the track context menu (PlaylistPickerState.open).
// "Add to Playlist" picker — a global modal overlay, 1:1 with Tauri's
// PlaylistModal.svelte (addTrack mode). A focus-opened dropdown lists
// the user's playlists; clicking a row only SELECTS it (the selection
// becomes the input's placeholder); the footer Add button fires the
// actual pick. "+ Create new playlist" (first dropdown row) reveals an
// inline name field confirmed by the same footer button ("Create & Add").
// Opened from the track context menu (PlaylistPickerState.open).
//
// Filter matching runs Rust-side (Slint 1.16 has no string `.contains`):
// every keystroke recomputes each row's `filter-rank` (match ordinal,
// -1 = filtered out) plus `filter-matches`; ranks >= 8 hide behind the
// "{} more playlist(s)..." overflow row.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
@@ -8,62 +17,71 @@ import { Radius } from "../foundation/radius.slint";
import { PlaylistPickerState, PlaylistPickerActions, PlaylistPickItem } from "../state.slint";
import { QbzIcon } from "QbzIcon.slint";
import { LoadingSpinner } from "LoadingSpinner.slint";
import { QbzPrimaryButton } from "QbzPrimaryButton.slint";
import { SecondaryButton } from "SecondaryButton.slint";
component PickRow inherits Rectangle {
// One flat dropdown row (Tauri parity: single 41px line, name + count,
// hover fill only — no icon tile, no zebra). Rows filtered out
// (filter-rank == -1) or ranked past the 8-row window collapse to zero
// height; the list layout's spacing is 0 so nothing leaks. The height
// binding reads only model data — never layout-managed geometry.
component DropRow inherits Rectangle {
in property <PlaylistPickItem> item;
in property <int> index;
callback clicked(string);
height: 52px;
border-radius: 8px;
background: ta.has-hover
? #ffffff16
: (Math.mod(root.index, 2) == 1 ? #ffffff07 : transparent);
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 12px;
VerticalLayout {
alignment: center;
Rectangle {
width: 34px;
height: 34px;
border-radius: 6px;
background: Theme.surface-elevated;
QbzIcon {
// LOCAL playlists (library.db) get the hard-drive glyph
// — adds write the local repo and work offline.
source: root.item.is-local
? @image-url("../assets/icons/hard-drive.svg")
: @image-url("../assets/icons/list-music.svg");
width: 18px;
height: 18px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: Theme.text-muted;
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: root.item.name;
color: Theme.text-primary;
font-size: Typography.body;
font-weight: Typography.medium;
overflow: elide;
}
if root.item.tracks-line != "": Text {
text: root.item.tracks-line;
color: Theme.text-muted;
font-size: Typography.legal;
}
// Keyboard highlight (arrow nav) — painted like hover.
in property <bool> highlighted;
// Enter-to-select dispatch: when `select-seq` bumps, the row whose
// filter-rank equals `select-rank` fires `select()`.
in property <int> select-seq;
in property <int> select-rank: -1;
callback select();
visible: root.item.filter-rank >= 0 && root.item.filter-rank < 8;
height: (root.item.filter-rank >= 0 && root.item.filter-rank < 8) ? 41px : 0px;
background: (ta.has-hover || root.highlighted) ? Theme.surface-hover : transparent;
changed select-seq => {
if (root.item.filter-rank >= 0 && root.item.filter-rank == root.select-rank) {
root.select();
}
}
// Row-level TouchArea declared FIRST, cell content after.
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked(root.item.id);
root.select();
}
}
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
padding-top: 10px;
padding-bottom: 10px;
spacing: 8px;
// LOCAL playlists (library.db) keep a small hard-drive glyph —
// deliberate Slint extra; locals don't exist in Tauri's picker.
if root.item.is-local: VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/hard-drive.svg");
width: 14px;
height: 14px;
tint: Theme.text-muted;
}
}
Text {
text: root.item.name;
color: Theme.text-primary;
font-size: Typography.link;
vertical-alignment: center;
overflow: elide;
horizontal-stretch: 1;
}
Text {
text: root.item.tracks-line;
color: Theme.text-muted;
font-size: Typography.legal;
vertical-alignment: center;
}
}
}
@@ -80,73 +98,523 @@ export component PlaylistPickerModal inherits Rectangle {
PlaylistPickerActions.close();
}
}
Rectangle {
width: Math.min(root.width - 80px, 460px);
height: Math.min(root.height - 120px, 520px);
// Card-sized FocusScope: keyboard nav + the picker's local state.
// The locals live on the `if open:` subtree so every conditional
// remount resets them — no state.slint props, no Rust resets.
keys := FocusScope {
// Dropdown visibility + the select-then-Add selection.
property <bool> dropdown-open: false;
property <string> selected-id: ""; // "" = nothing selected
property <string> selected-label: ""; // "{name} ({tracks-line})" placeholder
// Keyboard highlight over shown + 1 virtual rows; -1 = none,
// 0 = the create-new row, 1.. = visible playlist rows.
property <int> highlight: -1;
// Bumped by Enter; the rank-matching DropRow selects itself.
property <int> select-seq: 0;
property <int> nav-count: Math.min(PlaylistPickerState.filter-matches, 8) + 1;
property <int> adding-count: Math.max(1, PlaylistPickerState.track-ids.length);
width: Math.min(root.width - 80px, 490px);
// Tauri: min-height 400px / max-height 90vh — the body
// stretches so the footer pins to the bottom and blank space
// sits under the picker group.
height: Math.min(Math.max(400px, panel.preferred-height), root.height - 80px);
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.md;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// Swallow clicks so they don't reach the scrim.
TouchArea { }
forward-focus: search-input;
VerticalLayout {
padding: 20px;
spacing: 14px;
HorizontalLayout {
Text {
text: @tr("Add to playlist");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
// Enter semantics: dropdown open → select the highlighted row
// (select only, never submit); dropdown closed → act as the
// footer Add button.
function on-enter() {
if (self.dropdown-open) {
if (self.highlight >= 0) {
self.commit-highlight();
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
PlaylistPickerActions.close();
} else if (!PlaylistPickerState.creating) {
if (PlaylistPickerState.creating-open) {
if (PlaylistPickerState.create-name != "") {
PlaylistPickerActions.create-and-add();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
} else if (self.selected-id != "") {
PlaylistPickerActions.pick(self.selected-id);
}
}
}
function commit-highlight() {
if (self.highlight == 0) {
// Virtual row 0 = "+ Create new playlist".
self.selected-id = "";
self.selected-label = "";
PlaylistPickerState.creating-open = true;
PlaylistPickerState.filter = "";
PlaylistPickerActions.filter-changed("");
self.dropdown-open = false;
self.highlight = -1;
} else if (self.highlight > 0) {
self.select-seq += 1;
}
}
key-pressed(event) => {
if (event.text == Key.DownArrow) {
if (!self.dropdown-open) {
self.dropdown-open = true;
self.highlight = 0;
} else {
self.highlight = Math.mod(self.highlight + 1, self.nav-count);
}
return accept;
}
if (event.text == Key.UpArrow) {
if (!self.dropdown-open) {
self.dropdown-open = true;
self.highlight = 0;
} else if (self.highlight <= 0) {
self.highlight = self.nav-count - 1;
} else {
self.highlight -= 1;
}
return accept;
}
if (event.text == Key.Escape) {
// First Escape closes the dropdown, second the modal.
if (self.dropdown-open) {
self.dropdown-open = false;
self.highlight = -1;
} else {
PlaylistPickerActions.close();
}
return accept;
}
if (event.text == Key.Return) {
self.on-enter();
return accept;
}
return reject;
}
// Deferred mount focus — synchronous focus during the remount
// races layout (see ExpandableSearch); a one-shot timer grabs
// it a tick later. forward-focus routes it into the input.
focus-timer := Timer {
interval: 30ms;
running: true;
triggered => {
self.running = false;
keys.focus();
}
}
card := Rectangle {
border-radius: Radius.lg;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
// NO clip — the dropdown may overflow the card bottom,
// like Tauri's overflow: visible.
// Swallow clicks so they don't reach the scrim; doubles as
// "click inside the card closes the list" (Tauri parity).
TouchArea {
clicked => {
keys.dropdown-open = false;
keys.highlight = -1;
}
}
panel := VerticalLayout {
padding: 0px;
spacing: 0px;
// Header: title + close-x.
header := HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 20px;
padding-bottom: 20px;
Text {
text: @tr("Add to Playlist");
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
PlaylistPickerActions.close();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
body := VerticalLayout {
padding: 24px;
spacing: 16px;
vertical-stretch: 1;
alignment: start;
if PlaylistPickerState.loading: HorizontalLayout {
alignment: center;
LoadingSpinner { size: 30px; }
}
picker-group := VerticalLayout {
spacing: 8px;
label-row := HorizontalLayout {
height: 20px;
Text {
text: @tr("Choose playlist");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
horizontal-stretch: 1;
vertical-alignment: center;
}
counter := Text {
// max(1, …): single-track opens carry
// track-id with track-ids empty.
text: PlaylistPickerState.local-mode
? @tr("Adding {} local track(s)", keys.adding-count)
: @tr("Adding {} track(s)", keys.adding-count);
color: Theme.text-muted;
font-size: Typography.link;
vertical-alignment: center;
}
}
// The search/selection input — explicit 43px
// (Tauri metric; also keeps the card layout
// from dumping surplus height into it).
input-box := Rectangle {
height: 43px;
border-radius: Radius.sm;
background: Theme.surface-card;
border-width: 1px;
border-color: search-input.has-focus ? Theme.accent : Theme.border-subtle;
HorizontalLayout {
padding-left: 12px;
padding-right: 36px; // room for the clear chip
Rectangle {
horizontal-stretch: 1;
clip: true;
search-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.link;
vertical-alignment: center;
single-line: true;
enabled: !PlaylistPickerState.loading;
text <=> PlaylistPickerState.filter;
edited => {
keys.dropdown-open = true; // typing re-opens
keys.highlight = -1;
PlaylistPickerActions.filter-changed(self.text);
}
accepted => {
keys.on-enter();
}
changed has-focus => {
// Tauri: list opens on focus.
if (self.has-focus) {
keys.dropdown-open = true;
}
}
}
Text {
// Placeholder — Slint TextInput has no
// placeholder property; a sibling Text
// gated on empty text. Doubles as the
// selection label (the filter is cleared
// on select, so text is empty then).
visible: search-input.text == "";
width: 100%;
height: 100%;
text: PlaylistPickerState.creating-open
? @tr("+ Create new playlist")
: (keys.selected-label != ""
? keys.selected-label
: @tr("Search playlists..."));
color: Theme.text-muted;
font-size: Typography.link;
vertical-alignment: center;
overflow: elide;
}
}
}
// Clear-selection chip — only when a selection
// (or the inline-create state) exists and the
// list is closed.
if (keys.selected-id != "" || PlaylistPickerState.creating-open)
&& !keys.dropdown-open: clear-chip := Rectangle {
width: 20px;
height: 20px;
x: parent.width - self.width - 10px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.pill;
background: chip-ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 12px;
height: 12px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: chip-ta.has-hover ? Theme.text-primary : Theme.text-muted;
}
chip-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
keys.selected-id = "";
keys.selected-label = "";
PlaylistPickerState.creating-open = false;
PlaylistPickerState.create-name = "";
}
}
}
}
}
// Inline create — a second form group ADDED below the
// picker (Tauri §1.4.6); the footer button confirms.
if PlaylistPickerState.creating-open: create-group := VerticalLayout {
spacing: 8px;
Text {
text: @tr("Playlist Name");
color: Theme.text-secondary;
font-size: Typography.legal;
font-weight: Typography.medium;
}
name-box := Rectangle {
height: 43px;
border-radius: Radius.sm;
background: Theme.surface-card;
border-width: 1px;
border-color: name-input.has-focus ? Theme.accent : Theme.border-subtle;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
Rectangle {
horizontal-stretch: 1;
clip: true;
name-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: Typography.link;
vertical-alignment: center;
single-line: true;
enabled: !PlaylistPickerState.creating;
text <=> PlaylistPickerState.create-name;
accepted => {
if (PlaylistPickerState.create-name != ""
&& !PlaylistPickerState.creating) {
PlaylistPickerActions.create-and-add();
}
}
}
Text {
visible: name-input.text == "";
width: 100%;
height: 100%;
text: @tr("My Playlist");
color: Theme.text-muted;
font-size: Typography.link;
vertical-alignment: center;
overflow: elide;
}
}
}
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
footer := HorizontalLayout {
padding-left: 24px;
padding-right: 24px;
padding-top: 16px;
padding-bottom: 16px;
alignment: end;
spacing: 12px;
SecondaryButton {
label: @tr("Cancel");
clicked => {
PlaylistPickerActions.close();
}
}
// The single accent confirm (ADR-008). Disabled until
// valid — replaces Tauri's in-body error box.
QbzPrimaryButton {
height: 34px;
label: PlaylistPickerState.creating
? @tr("Saving...")
: (PlaylistPickerState.creating-open ? @tr("Create & Add") : @tr("Add"));
enabled: !PlaylistPickerState.creating
&& (PlaylistPickerState.creating-open
? PlaylistPickerState.create-name != ""
: keys.selected-id != "");
clicked => {
if (PlaylistPickerState.creating-open) {
PlaylistPickerActions.create-and-add();
} else {
PlaylistPickerActions.pick(keys.selected-id);
}
}
}
}
}
if PlaylistPickerState.loading: HorizontalLayout {
alignment: center;
LoadingSpinner { size: 30px; }
}
if !PlaylistPickerState.loading
&& PlaylistPickerState.playlists.length == 0: Text {
text: @tr("No playlists yet.");
color: Theme.text-muted;
font-size: Typography.body;
}
// Dropdown overlay — declared LAST inside the card so it
// paints above the body/footer (ADR-009 declaration-order z)
// and legitimately overflows the unclipped card bottom.
if keys.dropdown-open: dropdown := Rectangle {
property <int> shown: Math.min(PlaylistPickerState.filter-matches, 8);
// create-new row 41 + 1 divider, 41px per shown row,
// 41px no-results row, 1 + 34 overflow row.
property <length> drop-content: 42px
+ self.shown * 41px
+ (PlaylistPickerState.filter-matches == 0
&& PlaylistPickerState.filter != "" ? 41px : 0px)
+ (PlaylistPickerState.filter-matches > 8 ? 35px : 0px);
Flickable {
vertical-stretch: 1;
viewport-width: self.width;
viewport-height: list.preferred-height;
list := VerticalLayout {
spacing: 2px;
for pl[i] in PlaylistPickerState.playlists: PickRow {
item: pl;
index: i;
clicked(id) => {
PlaylistPickerActions.pick(id);
x: 24px;
// Anchor below the input — static arithmetic over fixed
// metrics (never an absolute-position binding): header 68
// (20 pad + 28 close-x + 20 pad) + 1 divider + 24 body pad
// + 20 label row + 8 spacing + 43 input + 4 gap.
y: 68px + 1px + 24px + 20px + 8px + 43px + 4px;
width: parent.width - 48px;
height: Math.min(self.drop-content + 2px, 322px); // Tauri max-height 320 + border
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
border-radius: Radius.sm;
drop-shadow-blur: 24px;
drop-shadow-offset-y: 8px;
drop-shadow-color: Theme.card-shadow;
clip: true;
// Keep clicks on the list chrome from reaching the card
// swallower (which would close the list).
TouchArea { }
Flickable {
viewport-width: self.width;
viewport-height: inner.preferred-height;
inner := VerticalLayout {
spacing: 0px;
// "+ Create new playlist" — ALWAYS first, never
// filtered out (Tauri parity).
create-row := Rectangle {
height: 41px;
background: (create-ta.has-hover || keys.highlight == 0)
? Theme.surface-hover : transparent;
create-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
keys.selected-id = "";
keys.selected-label = "";
PlaylistPickerState.creating-open = true;
PlaylistPickerState.filter = "";
PlaylistPickerActions.filter-changed("");
keys.dropdown-open = false;
keys.highlight = -1;
}
}
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
padding-top: 10px;
padding-bottom: 10px;
Text {
text: @tr("+ Create new playlist");
color: Theme.accent;
font-size: Typography.link;
font-weight: Typography.medium;
vertical-alignment: center;
overflow: elide;
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
for pl[i] in PlaylistPickerState.playlists: DropRow {
item: pl;
highlighted: pl.filter-rank >= 0
&& pl.filter-rank + 1 == keys.highlight;
select-seq: keys.select-seq;
select-rank: keys.highlight - 1;
select => {
keys.selected-id = self.item.id;
keys.selected-label = self.item.tracks-line == ""
? self.item.name
: self.item.name + " (" + self.item.tracks-line + ")";
PlaylistPickerState.creating-open = false;
// Tauri clears the query on selection (§2.4).
PlaylistPickerState.filter = "";
PlaylistPickerActions.filter-changed("");
keys.dropdown-open = false;
keys.highlight = -1;
}
}
if PlaylistPickerState.filter != ""
&& PlaylistPickerState.filter-matches == 0: Rectangle {
height: 41px;
Text {
width: 100%;
height: 100%;
text: @tr("No playlists found");
color: Theme.text-muted;
font-size: Typography.legal;
horizontal-alignment: center;
vertical-alignment: center;
}
}
// Overflow row — ranks past the 8-row window.
if PlaylistPickerState.filter-matches > 8: Rectangle {
height: 1px;
background: Theme.border-subtle;
}
if PlaylistPickerState.filter-matches > 8: Rectangle {
height: 34px;
Text {
width: 100%;
height: 100%;
text: @tr("{} more playlist(s)...",
PlaylistPickerState.filter-matches - 8);
color: Theme.text-muted;
font-size: Typography.legal;
font-italic: true;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
}
+17 -1
View File
@@ -17,6 +17,7 @@ import { SidebarFolderPopup } from "SidebarFolderPopup.slint";
import { SidebarTooltip } from "SidebarTooltip.slint";
import { SidebarPlaylistsPopup } from "SidebarPlaylistsPopup.slint";
import { PlaylistPickerModal } from "../primitives/PlaylistPickerModal.slint";
import { PlaylistDuplicateConfirmModal } from "../primitives/PlaylistDuplicateConfirmModal.slint";
import { CreatePlaylistModal } from "../primitives/CreatePlaylistModal.slint";
import { EditPlaylistModal } from "../primitives/EditPlaylistModal.slint";
import { CreateFolderModal } from "../primitives/CreateFolderModal.slint";
@@ -28,6 +29,7 @@ import { EphemeralPlayChoiceModal } from "../primitives/EphemeralPlayChoiceModal
import { FolderEditModal } from "../primitives/FolderEditModal.slint";
import { LibFolderEditModal } from "../settings/LibFolderEditModal.slint";
import { TagEditorModal } from "../primitives/TagEditorModal.slint";
import { PlaylistImportModal } from "../primitives/PlaylistImportModal.slint";
import { QconnectDevModal } from "QconnectDevModal.slint";
import { DragGhost } from "../primitives/DragGhost.slint";
import { Toast } from "../primitives/Toast.slint";
@@ -369,7 +371,11 @@ export component AppShell inherits Rectangle {
// When both are open each section vertical-stretches to half; when
// only one is open it fills.
Rectangle {
width: (ShellState.queue-open || ShellState.lyrics-open) ? 280px : 0px;
// 300px so the lines/queue gain +20px of CONTENT width
// (padding/margins unchanged inside the panels). Both share
// the column (stacked mode), so both widen together — keeping
// Queue and Lyrics aligned when stacked.
width: (ShellState.queue-open || ShellState.lyrics-open) ? 300px : 0px;
clip: true;
animate width { duration: 160ms; easing: ease-in-out; }
background: Theme.surface-card;
@@ -428,6 +434,10 @@ export component AppShell inherits Rectangle {
// context menu.
PlaylistPickerModal { }
// "Duplicate tracks" confirm sub-modal — mounted AFTER the picker so it
// stacks above it (Slint stacking = declaration order; ADR-009/010).
PlaylistDuplicateConfirmModal { }
// Global "Create playlist" modal, opened from the sidebar "+".
CreatePlaylistModal { }
@@ -462,6 +472,12 @@ export component AppShell inherits Rectangle {
// Global "Tag editor" modal (local album metadata).
TagEditorModal { }
// Global "Import Playlist" modal (public-playlist importer). Mounted
// LAST among the feature modals so it stacks above them (ADR-009
// declaration-order z; ADR-010 conditional mount via the global's
// `open`), keeping QconnectDevModal topmost.
PlaylistImportModal { }
// Qobuz Connect DEV diagnostics modal (opened from the connect flyout).
QconnectDevModal {
width: 100%;
+19 -3
View File
@@ -25,10 +25,14 @@ component MenuItem inherits Rectangle {
in property <bool> selected: false;
in property <image> icon;
in property <bool> has-icon: false;
// When false the row is muted and ignores clicks (Import while
// offline). Same pattern as ContextMenuItem's enabled.
in property <bool> enabled: true;
callback activated();
height: 30px;
border-radius: 5px;
background: mi-ta.has-hover ? Theme.surface-hover : transparent;
background: (mi-ta.has-hover && root.enabled) ? Theme.surface-hover : transparent;
opacity: root.enabled ? 1.0 : 0.4;
HorizontalLayout {
padding-left: 8px;
padding-right: 8px;
@@ -63,9 +67,11 @@ component MenuItem inherits Rectangle {
}
}
mi-ta := TouchArea {
mouse-cursor: pointer;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.activated();
if (root.enabled) {
root.activated();
}
}
}
}
@@ -849,6 +855,16 @@ export component Sidebar inherits Rectangle {
icon: @image-url("../assets/icons/library-big.svg");
activated => { SidebarActions.manage-playlists(); }
}
// Import playlist — open the importer modal. Dimmed
// + inert while offline; the modal's own offline
// banner is the second layer, exactly like Tauri.
MenuItem {
label: @tr("Import");
has-icon: true;
icon: @image-url("../assets/icons/import.svg");
enabled: !OfflineState.offline;
activated => { SidebarActions.import-playlist(); }
}
// Refresh — re-fetch the playlist list.
MenuItem {
label: @tr("Refresh");
+173 -1
View File
@@ -40,7 +40,8 @@ export struct AlphaJump {
// One button in the shared multi-select bulk bar (MultiSelectBar).
export struct BulkAction {
id: string, // emitted verbatim via MultiSelectBar.action(id)
label: string, // already-translated button label
label: string, // already-translated text — now the hover tooltip
icon: image, // the button glyph (the bar is icon-only)
danger: bool, // red-bordered destructive button (e.g. Remove)
needs-selection: bool, // dimmed + disabled while nothing is selected
}
@@ -288,6 +289,11 @@ export global AlbumState {
in property <string> artwork-url;
in property <bool> has-custom-cover: false;
in property <string> info-line;
// Meta-line split around the label so the header can render the label
// as a clickable link: meta-pre (year) + [label] + meta-post
// (genre • N tracks • duration). info-line stays the fallback.
in property <string> meta-pre;
in property <string> meta-post;
in property <string> quality-tier;
// "24-bit / 96 kHz" — quality-badge detail line.
in property <string> quality-detail;
@@ -295,6 +301,10 @@ export global AlbumState {
in property <string> description;
// Truncated description for the header; full text lives in the modal.
in property <string> description-short;
// Half-length truncation used when the content area is space-constrained
// (ShellState.content-constrained) so the header stays compact and the
// tracks keep priority. Falls back to the full short text when there's room.
in property <string> description-shorter;
in property <image> artwork;
// Artwork-derived tint for the header gradient.
in property <color> header-color: #181820;
@@ -302,6 +312,25 @@ export global AlbumState {
// Label id for the sidebar label card → label page navigation ("" = none).
in property <string> label-id;
in property <[string]> awards: [];
// True when the album ships a downloadable booklet/liner-notes PDF
// (Qobuz goodies). Gates the booklet button in the header — not every
// album has one.
in property <bool> has-booklet: false;
// True when EVERY track of the album is cached offline (cache-status 3).
// Swaps the header menu's "Make available offline" for "Refresh offline
// copy" (Tauri's isAlbumFullyDownloaded). Kept live as downloads land.
in property <bool> album-fully-cached: false;
// Whether the album is in the user's favorites (library). Drives the
// header heart (filled accent when on). Seeded from fav_cache on open,
// flipped optimistically on toggle.
in property <bool> is-favorite: false;
// True while a favorite toggle is in flight (spinner on the heart).
in property <bool> favorite-loading: false;
// Multi-select (track selection) mode for the track list. in-out: the
// toolbar toggle flips it from the UI; Rust resets it on album change.
in-out property <bool> multi-select: false;
// Number of selected rows (drives the bulk bar count + select-all label).
in property <int> selected-count: 0;
in property <[TrackItem]> tracks: [];
in property <bool> loading: false;
// True when this is a Local Library album (local files / offline copies).
@@ -316,6 +345,12 @@ export global AlbumState {
export global AlbumActions {
// Filter the visible track list by a query (client-side).
callback search(string);
// Toggle multi-select (track selection) mode on the album track list.
callback toggle-multi-select();
// Bulk-bar action over the selected rows (id = "select-all" | "play-next"
// | "queue" | "add-to-playlist" | "add-to-favorites" | "make-offline" |
// "clear").
callback bulk-action(string);
}
// Track drag-and-drop onto sidebar playlists (a star QBZ feature).
@@ -1128,6 +1163,8 @@ export global SidebarActions {
callback refresh-playlists();
// Open the full Playlist Manager view.
callback manage-playlists();
// Open the playlist importer modal (sidebar "..." menu).
callback import-playlist();
}
// "Create playlist" modal state. Mirrors Tauri's PlaylistModal (create
@@ -2413,6 +2450,11 @@ export global ArtistState {
// Artwork-derived tint for the header gradient.
in property <color> header-color: #181820;
in property <[TrackItem]> top-tracks: [];
// Popular Tracks multi-select (track selection) mode + selected count —
// mirrors AlbumState. in-out: the section toggle flips it from the UI;
// Rust resets it on artist change.
in-out property <bool> top-tracks-multi-select: false;
in property <int> top-tracks-selected-count: 0;
// Releases grouped into titled sections (Albums, EPs & Singles, ...).
in property <[DiscoverSection]> release-sections: [];
// Labels collected from the artist's own album releases (deduped by
@@ -2449,6 +2491,15 @@ export global ArtistActions {
// a query string (client-side substring match, mirrors the album
// track search in AlbumActions).
callback search(string);
// Toggle Popular Tracks multi-select mode.
callback toggle-top-tracks-select();
// Bulk-bar action over the selected Popular Tracks (id = "select-all" |
// "play-next" | "queue" | "add-to-playlist" | "add-to-favorites" |
// "clear").
callback top-tracks-bulk-action(string);
// Popular Tracks section "more" menu (id = "next-all" | "queue-all" |
// "shuffle-all" | "playlist-all").
callback top-tracks-menu-action(string);
}
// Artist network sidebar — Origin / Labels / Similar / Relationships /
@@ -2746,6 +2797,16 @@ export global ShellState {
// where lyrics closed queue and vice-versa.)
in-out property <bool> queue-open: false;
in-out property <bool> lyrics-open: false;
// Live WINDOW width (set from the AppWindow root). Views read it to make
// content-area responsiveness decisions independent of their own
// (sidebar-shrunk) width — e.g. the album Label/Awards sidebar collapses
// to an icon rail at the now-playing-bar breakpoint (1366px) WHEN a right
// panel is open. Defaults to the preferred window width.
in-out property <length> window-width: 1180px;
// True when the content area is space-constrained: window at/under the
// NPB responsive breakpoint AND a right panel (Queue/Lyrics) is open.
out property <bool> content-constrained:
root.window-width < 1366px && (root.queue-open || root.lyrics-open);
// Section navigation placement: the sections (Discover/Library/Local
// Library/My QBZ) now live in the sidebar and open right-flyout menus.
in-out property <bool> nav-in-sidebar: true;
@@ -3067,6 +3128,11 @@ export struct PlaylistPickItem {
// LOCAL playlist (library.db entity, id "local:<uuid>") — the row
// shows a hard-drive glyph; adds write the local repo (works offline).
is-local: bool,
// Client-side filter result — recomputed Rust-side on every filter
// keystroke (Slint 1.16 has no string `.contains`, so the substring
// match lives in Rust). Match ordinal among the filtered rows;
// -1 = filtered out. Rows ranked >= 8 hide behind the overflow row.
filter-rank: int,
}
// "Add to playlist" picker — a global overlay opened from the track
@@ -3081,11 +3147,49 @@ export global PlaylistPickerState {
// True when track-ids are LocalLibrary row ids (i64) -> route to
// add_local_track_to_playlist instead of the Qobuz endpoint.
in property <bool> local-mode: false;
// Client-side filter: case-insensitive substring over playlist names.
// Pure frontend, no backend call. The list filters live as the user types.
in-out property <string> filter: "";
// Total rows matching the current filter — drives the dropdown's
// no-results/overflow rows and its explicit height.
in property <int> filter-matches: 0;
// Inline "Create new playlist" affordance (mirrors Tauri's
// CREATE_NEW_PLAYLIST inline name field). When `creating-open` is true the
// name input is revealed; `create-name` holds the typed name; `creating`
// gates the confirm while the create-and-add runs.
in-out property <bool> creating-open: false;
in-out property <string> create-name: "";
in-out property <bool> creating: false;
}
export global PlaylistPickerActions {
callback pick(string /* playlist id */);
callback close();
// Inline create-and-add: creates a new playlist (Qobuz online / local
// offline per D8) and adds the carried tracks to it.
callback create-and-add();
// Client-side filter changed — Rust recomputes each row's filter-rank
// plus filter-matches (case-insensitive substring) since Slint 1.16
// lacks string `.contains`.
callback filter-changed(string);
}
// "Duplicate tracks" confirm sub-modal — shown when a Qobuz-tracks → Qobuz-
// playlist add finds tracks already in the target. The track-id Vec<u64> and
// the duplicate id set live Rust-side in a stash cell (Slint never holds
// them); this global only carries the counts + busy flag for rendering.
export global DuplicateConfirmState {
in-out property <bool> open: false;
in property <int> duplicate-count: 0;
in property <int> total-count: 0;
in property <bool> busy: false;
in property <string> playlist-name;
}
export global DuplicateConfirmActions {
callback add-all();
callback add-new-only();
callback cancel();
}
// One artist tile in the Favorites > Artists grid.
@@ -3354,3 +3458,71 @@ export global OfflineFavoritesActions {
// queue path; the cached copies play through the offline tier).
callback play(string);
}
// ================= Playlist Importer (public playlists) ==================
// "Import Playlist" modal state — 1:1 port of Tauri's
// PlaylistImportModal.svelte. All interpolated strings (log lines, status
// line, summary block) arrive pre-formatted from the Rust controller
// (crate::playlist_import); the UI renders them verbatim. Provider
// detection lives Rust-side too (Slint 1.16 has no string `.contains`) —
// every URL keystroke round-trips through `url-edited`.
// One append-only line in the conversion log.
export struct ImportLogEntry {
// Final display string (pre-formatted Rust-side).
message: string,
// "info" | "success" | "error" — drives the row color.
status: string,
}
export global PlaylistImportState {
in-out property <bool> open: false;
in-out property <string> url;
// Rename field — prefilled with the fetched playlist name.
in-out property <string> custom-name;
// True during preview fetch AND import execute.
in property <bool> loading: false;
// "" = none; shown as the red banner at the top of the body.
in property <string> error: "";
// "" | "spotify" | "apple" | "tidal" | "deezer" — the locked-or-
// detected provider; its source logo renders full-opacity.
in property <string> active-provider: "";
// Rust-computed: provider detected && !offline.
in property <bool> can-fetch: false;
// Rust-computed: a preview exists AND the URL hasn't been edited
// since the fetch — flips the modal into step B (rename + Import).
in property <bool> show-preview: false;
in property <bool> import-completed: false;
// The "Conversion progress" panel (any log lines, or loading).
in property <bool> progress-visible: false;
// Bar + status/current-track lines visible.
in property <bool> has-progress: false;
in property <float> progress: 0.0; // 0..1
in property <string> status-line: "";
in property <string> current-track: "";
in property <[ImportLogEntry]> log: [];
// Folder dropdown options — exact CreatePlaylistState pattern: index
// 0 is always "No folder" (id ""), the rest are the user's folder
// names parallel to `folder-ids`.
in property <[string]> folder-options: ["No folder"];
in property <[string]> folder-ids: [""];
in-out property <int> folder-index: 0;
// Summary block, pre-formatted lines ("" = hidden).
in property <string> summary-playlist: "";
in property <string> summary-matched: "";
in property <string> summary-skipped: "";
in property <string> summary-parts: "";
}
export global PlaylistImportActions {
callback close();
// Fired on every URL keystroke — Rust recomputes active-provider /
// can-fetch / show-preview (and the post-completion reset path).
callback url-edited(string);
// Keeps Rust's custom_name mirror fresh.
callback name-edited(string);
// Step A: preview_public_playlist(url).
callback fetch();
// Step B: import_public_playlist(...) with rename + folder choice.
callback execute();
}