Files
qbz/crates/qbz-slint/ui/primitives/PlaylistDuplicateConfirmModal.slint
T
vicrodh 3689a5fda8 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
2026-06-11 22:03:46 -06:00

130 lines
5.9 KiB
Plaintext

// 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();
}
}
}
}
}
}
}