feat(qt): playlist manager, folders, importer and the Library parity round
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
This commit is contained in:
115 files changed
+20778
-1637
No files matched your search
@@ -0,0 +1,391 @@
|
||||
// FolderEditPanel — the BODY of the folder editor
|
||||
// (primitives/FolderEditModal.slint:66-266): name field, the seven icon-preset
|
||||
// tiles plus the custom-image tile, the eleven colour swatches, the "Hide from
|
||||
// sidebar" row and the Delete / Save footer.
|
||||
//
|
||||
// The chrome around it — scrim, card, title, close X, Escape scope and the
|
||||
// delete confirm — belongs to FolderModals.qml, which mounts this. The split
|
||||
// is declared up front (rule 2): 04 §5.2's single ~380-line FolderModals is
|
||||
// rejected because the two panels plus the confirm plus the drafts land nearer
|
||||
// 600, and the port's precedents for "one file, several panels" are
|
||||
// MyQbzModals.qml at 523 lines for three SIMPLER panels and
|
||||
// PlaylistPickerModal.qml at 685.
|
||||
//
|
||||
// ── THE DRAFTS LIVE HERE ───────────────────────────────────────────────────
|
||||
// Name, preset, colour and the hidden switch are QML-LOCAL and reach Rust only
|
||||
// as arguments to `editSave(name, preset, color, hidden)`. That is the port's
|
||||
// standing rule (MyQbzModals.qml's header: "TEXT STATE IS QML-LOCAL ... every
|
||||
// submit invokable takes the value as an argument") and it is why the bridge
|
||||
// has no `selectPreset` / `selectColor` / `toggleHidden` invokables: a colour
|
||||
// click has no business making a round trip.
|
||||
//
|
||||
// Preset selection is the ONE draft write with a Rust side effect — it also
|
||||
// calls `QbzFolderEdit.clearImage()`, because picking a preset means dropping
|
||||
// the custom image, and the image is Rust-owned (the file dialog is native).
|
||||
// That call is also what makes the reference's declared-but-never-called
|
||||
// `clear-image` callback (main.rs:5611-5619) live.
|
||||
//
|
||||
// ── SEEDING ────────────────────────────────────────────────────────────────
|
||||
// `doc.name` / `iconPreset` / `iconColor` / `isHidden` are SEEDS, consumed
|
||||
// once on the open transition. They are NOT bound: Rust republishes editJson
|
||||
// on every `busy` flip and on every image pick, and a bound field would throw
|
||||
// away whatever the user had typed each time. `hasCustomImage` /
|
||||
// `customImagePath` / `busy` ARE read live, because Rust owns them.
|
||||
//
|
||||
// ── REUSED, NOT REDRAWN ────────────────────────────────────────────────────
|
||||
// QbzLineEdit the name field (its width MUST be set — the plain arm is
|
||||
// a fixed 240, where the Slint LineEdit stretches).
|
||||
// QbzToggle the hidden row. The reference uses QbzToggle too
|
||||
// (FolderEditModal.slint:214). A second switch is exactly
|
||||
// the fork rule 5 forbids.
|
||||
// QbzPrimaryButton the Save button. The reference's `#ffffffd6` hover on an
|
||||
// accent fill and its hardcoded `#ffffff` label are NOT
|
||||
// copied — that white-wash is the white-button-on-artwork
|
||||
// treatment and it washes out on an accent fill (illegible
|
||||
// on the 11 light themes). The sibling
|
||||
// LibFolderEditModal.slint:376 already uses accent-hover.
|
||||
// Contract §10 Q5 records the exact literals if parity is
|
||||
// ever wanted.
|
||||
// PmFolderIcon NOT reused for the preset tiles: a tile is a
|
||||
// surface-elevated square with a theme-tinted 17px glyph,
|
||||
// where PmFolderIcon is a saturated colour tile with a
|
||||
// fixed-white glyph at half its own size. Only the id ->
|
||||
// glyph chain is common, and it is seven ternary arms; a
|
||||
// shared .js would need its own build.rs entry for that.
|
||||
// Keep the two in step — PmFolderIcon.qml carries the
|
||||
// same chain.
|
||||
// Delete button hand-drawn, because it is a GHOST danger button and the
|
||||
// port's filled danger control (QbzPrimaryButton
|
||||
// `destructive`) is a different affordance. SettingsButton
|
||||
// has `danger`, but it is a settings-row control with its
|
||||
// own leading-glyph geometry.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
/// The parsed QbzFolderEdit.editJson (§4.5). The HOST parses it once; a
|
||||
/// second `JSON.parse` in here would double the work on every republish.
|
||||
property var doc: ({})
|
||||
/// The panel never raises the confirm itself — FolderModals owns it, so
|
||||
/// the confirm can stack over this panel with its own z (D21).
|
||||
signal deleteRequested()
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
function t(s) { return QbzSession.tr(s, QbzSession.trRev) }
|
||||
|
||||
// --- Drafts -----------------------------------------------------------
|
||||
property string draftName: ""
|
||||
property string draftPreset: "folder"
|
||||
property string draftColor: ""
|
||||
property bool draftHidden: false
|
||||
|
||||
readonly property bool busy: root.doc.busy === true
|
||||
readonly property bool isCreate: (root.doc.id || "") === ""
|
||||
readonly property bool canSave: root.draftName.trim() !== "" && !root.busy
|
||||
|
||||
/// Consume the seeds. Called by the host on the open transition — never on
|
||||
/// a plain republish.
|
||||
function seed() {
|
||||
root.draftName = root.doc.name || ""
|
||||
root.draftPreset = root.doc.iconPreset || "folder"
|
||||
root.draftColor = root.doc.iconColor || ""
|
||||
root.draftHidden = root.doc.isHidden === true
|
||||
}
|
||||
|
||||
/// Focus the name field. Split out so the host can call it AFTER the panel
|
||||
/// is actually visible — an invisible item cannot take active focus.
|
||||
function focusName() { nameField.focusField() }
|
||||
|
||||
/// The id -> glyph chain, shared with PmFolderIcon.qml. "folder" is not a
|
||||
/// case in the reference's chain at all and falls through to the default
|
||||
/// arm, which is also the unknown-id arm; "headphones" draws audio-lines.
|
||||
/// Both are upstream intent (§4.5) — do not "fix" either.
|
||||
function presetGlyph(id) {
|
||||
return id === "heart" ? "heart"
|
||||
: id === "star" ? "star"
|
||||
: id === "music" ? "music"
|
||||
: id === "disc" ? "disc"
|
||||
: id === "library" ? "library"
|
||||
: id === "headphones" ? "audio-lines"
|
||||
: "folder"
|
||||
}
|
||||
|
||||
implicitHeight: col.implicitHeight
|
||||
|
||||
Column {
|
||||
id: col
|
||||
width: parent.width
|
||||
spacing: 16
|
||||
|
||||
// ================= Name =========================================
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 6
|
||||
Text {
|
||||
text: root.t("Folder name")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
}
|
||||
QbzLineEdit {
|
||||
id: nameField
|
||||
// MUST be explicit: the plain arm is a fixed `width: 240`
|
||||
// (QbzLineEdit.qml:62), where the Slint LineEdit stretches to
|
||||
// the panel.
|
||||
width: parent.width
|
||||
text: root.draftName
|
||||
placeholder: root.t("Enter folder name")
|
||||
onEdited: function (value) { root.draftName = value }
|
||||
// `accepted`, NEVER `committed`: committed also fires on blur,
|
||||
// and closing the modal blurs the field, which would submit a
|
||||
// second time (MyQbzModals.qml:34-36 documents the incident).
|
||||
onAccepted: function (value) {
|
||||
root.draftName = value
|
||||
if (root.draftName.trim() !== "" && !root.busy)
|
||||
QbzFolderEdit.editSave(root.draftName, root.draftPreset,
|
||||
root.draftColor, root.draftHidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Icon =========================================
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 6
|
||||
Text {
|
||||
text: root.t("Icon")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
}
|
||||
Row {
|
||||
spacing: 8
|
||||
|
||||
Repeater {
|
||||
model: root.doc.presets || []
|
||||
delegate: Rectangle {
|
||||
id: presetTile
|
||||
required property var modelData
|
||||
// A preset is only "the" selection while there is no
|
||||
// custom image — the image wins, exactly as in the
|
||||
// reference (`custom-image-path == "" && ...`).
|
||||
readonly property bool active:
|
||||
root.doc.hasCustomImage !== true
|
||||
&& root.draftPreset === presetTile.modelData
|
||||
width: 40
|
||||
height: 40
|
||||
radius: 8
|
||||
color: presetTile.active
|
||||
? theme.accent
|
||||
: (presetArea.containsMouse ? theme.surfaceHover
|
||||
: theme.surfaceElevated)
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
width: 17
|
||||
height: 17
|
||||
name: root.presetGlyph(presetTile.modelData)
|
||||
// On an accent fill the port goes through the
|
||||
// measured on-accent selector, not a hardcoded
|
||||
// #ffffff (QbzTheme.qml "ON AN ACCENT FILL").
|
||||
tintName: presetTile.active ? theme.accentGlyphTint : "secondary"
|
||||
}
|
||||
MouseArea {
|
||||
id: presetArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.draftPreset = presetTile.modelData
|
||||
// The image is RUST-owned (native dialog), so
|
||||
// dropping it is the one draft write that has
|
||||
// to make a round trip.
|
||||
QbzFolderEdit.clearImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- The custom-image tile.
|
||||
Rectangle {
|
||||
id: imageTile
|
||||
readonly property bool active: root.doc.hasCustomImage === true
|
||||
width: 40
|
||||
height: 40
|
||||
radius: 8
|
||||
color: imageTile.active
|
||||
? theme.accent
|
||||
: (imageArea.containsMouse ? theme.surfaceHover
|
||||
: theme.surfaceElevated)
|
||||
// No `clip: true` — it is a rectangular scissor and does
|
||||
// not follow `radius`. RoundedImage masks its own corners.
|
||||
RoundedImage {
|
||||
anchors.fill: parent
|
||||
visible: imageTile.active
|
||||
source: imageTile.active ? (root.doc.customImagePath || "") : ""
|
||||
radius: 8
|
||||
fit: "crop"
|
||||
}
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
visible: !imageTile.active
|
||||
width: 17
|
||||
height: 17
|
||||
name: "image-plus"
|
||||
tintName: "secondary"
|
||||
}
|
||||
MouseArea {
|
||||
id: imageArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: QbzFolderEdit.pickImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Colour =======================================
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 6
|
||||
Text {
|
||||
text: root.t("Color")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
}
|
||||
// ELEVEN swatches, ONE row — 11 * 28 + 10 * 8 = 388 px. The
|
||||
// .slint comment at :167 saying "Two rows" is wrong about its own
|
||||
// grid. The wrap arithmetic is kept anyway, so a longer constant
|
||||
// list wraps instead of overflowing the card.
|
||||
Item {
|
||||
id: swatchGrid
|
||||
readonly property int columns: 11
|
||||
readonly property int sw: 28
|
||||
readonly property int gap: 8
|
||||
readonly property int count: (root.doc.swatches || []).length
|
||||
readonly property int rows: Math.ceil(swatchGrid.count / swatchGrid.columns)
|
||||
width: parent.width
|
||||
height: swatchGrid.rows * swatchGrid.sw
|
||||
+ Math.max(0, swatchGrid.rows - 1) * swatchGrid.gap
|
||||
|
||||
Repeater {
|
||||
model: root.doc.swatches || []
|
||||
delegate: Rectangle {
|
||||
id: swatch
|
||||
required property int index
|
||||
required property var modelData
|
||||
readonly property string value: swatch.modelData.value || ""
|
||||
readonly property bool active: root.draftColor === swatch.value
|
||||
x: (swatch.index % swatchGrid.columns) * (swatchGrid.sw + swatchGrid.gap)
|
||||
y: Math.floor(swatch.index / swatchGrid.columns)
|
||||
* (swatchGrid.sw + swatchGrid.gap)
|
||||
width: swatchGrid.sw
|
||||
height: swatchGrid.sw
|
||||
radius: swatchGrid.sw / 2
|
||||
color: swatch.modelData.isAccent === true ? theme.accent : swatch.value
|
||||
// A fixed white ring: the host is a saturated swatch
|
||||
// under every theme, so a theme-following border would
|
||||
// vanish on half of them.
|
||||
border.width: swatch.active ? 2 : 0
|
||||
border.color: "#ffffff"
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
visible: swatch.active
|
||||
width: 14
|
||||
height: 14
|
||||
name: "check"
|
||||
tintName: "white"
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
// "" IS a value ("use the theme accent") and it
|
||||
// reaches the DB as "" — see contract D24.
|
||||
onClicked: root.draftColor = swatch.value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Hidden =======================================
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 22
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.max(0, parent.width - 50)
|
||||
text: root.t("Hide from sidebar")
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontBody
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
QbzToggle {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: root.draftHidden
|
||||
enabled: !root.busy
|
||||
// QbzToggle never self-flips; the owner of the state does.
|
||||
onToggled: function (value) { root.draftHidden = value }
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Footer =======================================
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
// Delete — edit mode only. A ghost danger button: fill on hover
|
||||
// only, 1px danger border, danger label. theme.danger /
|
||||
// theme.dangerHover ARE the reference's #ef4444 / #ef444433 under
|
||||
// the default theme (the engine defaults danger to rgb(ef,44,44)
|
||||
// and derives danger_hover as a 0.2 tint, i.e. alpha 0x33) and the
|
||||
// correct colours under the other 35.
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: !root.isCreate
|
||||
width: delLabel.implicitWidth + 28
|
||||
height: 36
|
||||
radius: 8
|
||||
color: (delArea.containsMouse && !root.busy) ? theme.dangerHover : "transparent"
|
||||
border.width: 1
|
||||
border.color: theme.danger
|
||||
opacity: root.busy ? 0.5 : 1.0
|
||||
Text {
|
||||
id: delLabel
|
||||
anchors.centerIn: parent
|
||||
text: root.t("Delete")
|
||||
color: theme.danger
|
||||
font.pixelSize: 15
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
MouseArea {
|
||||
id: delArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: root.busy ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||
onClicked: if (!root.busy) root.deleteRequested()
|
||||
}
|
||||
}
|
||||
|
||||
// Save. The label stays "Save" in create mode too — that is the
|
||||
// reference (FolderEditModal.slint:246); the small sidebar create
|
||||
// panel is the one that says "Create".
|
||||
QbzPrimaryButton {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: root.t("Save")
|
||||
btnHeight: 36
|
||||
labelSize: 15
|
||||
btnEnabled: root.canSave
|
||||
onClicked: QbzFolderEdit.editSave(root.draftName, root.draftPreset,
|
||||
root.draftColor, root.draftHidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
// FolderModals — the TWO folder panels and their delete confirm, in one file,
|
||||
// as sibling self-gating overlays (the MyQbzModals.qml shape):
|
||||
//
|
||||
// CREATE primitives/CreateFolderModal.slint (109 lines) — a name field and
|
||||
// a Create button, opened from the sidebar's "..." -> New folder.
|
||||
// Panel width min(host - 80, 400).
|
||||
// EDITOR primitives/FolderEditModal.slint (277) — the full editor, opened
|
||||
// from every folder card / chip / tree row (D7) and from the
|
||||
// sidebar row menu, and by the manager toolbar's own "New folder"
|
||||
// in CREATE mode (`id == ""`). Panel width min(host - 80, 480). Its
|
||||
// body is FolderEditPanel.qml; this file owns the chrome.
|
||||
// CONFIRM QbzConfirmModal, declared LAST so it stacks over the editor, with
|
||||
// its own z: 3100.
|
||||
//
|
||||
// Mounted ONCE in qml/shell/AppShell.qml as a direct child of the root, after
|
||||
// MyQbzModals and before QbzToast, with no `z` — that file's convention is
|
||||
// declaration order, and ADR-009's ">= 3000" is satisfied structurally
|
||||
// (AppShell.qml:533-563). 05 §5.4's "mount the create modal inside Sidebar.qml"
|
||||
// is rejected: the sidebar animates to width 0 with clip: true and already
|
||||
// force-closes its own flyout on a state change, so a modal parented into it
|
||||
// disappears with the sidebar.
|
||||
//
|
||||
// ── TWO DRAFTS, NOT ONE ────────────────────────────────────────────────────
|
||||
// `draftCreateName` belongs to the CREATE panel and is reset on its OWN open
|
||||
// transition; the editor's four drafts live inside FolderEditPanel. Sharing
|
||||
// one draft set between them (04 §5.6) makes "New folder" reopen holding
|
||||
// whatever was last typed in the editor.
|
||||
//
|
||||
// ── `busy` HOLDS THE PANEL OPEN ────────────────────────────────────────────
|
||||
// Neither panel closes itself. Rust closes them, and only after the write
|
||||
// landed (contract D22) — a failed create keeps the name on screen and toasts,
|
||||
// where the reference closes first and loses both the name and the error.
|
||||
//
|
||||
// ── ESCAPE IS A WRAPPING FocusScope, NOT A SIBLING ONE ─────────────────────
|
||||
// QbzConfirmModal gets away with a sibling FocusScope because it has no text
|
||||
// field. Here the name input takes active focus, and QML propagates an
|
||||
// unhandled key up the focused item's PARENT chain — a sibling scope is never
|
||||
// on that chain, so Escape would be dead the moment the field is focused.
|
||||
// Each panel is therefore wrapped in its scope. QbzLineEdit's TextInput leaves
|
||||
// Escape unaccepted on the plain arm (QbzLineEdit.qml:177-184), so it reaches
|
||||
// us. Escape closes the innermost open thing: while the confirm is up it holds
|
||||
// focus and handles its own.
|
||||
//
|
||||
// ── ENTER ──────────────────────────────────────────────────────────────────
|
||||
// Through QbzLineEdit's `accepted`, NEVER `committed`: committed also fires on
|
||||
// focus-out, and closing the modal blurs the field, which would submit the
|
||||
// same value twice (MyQbzModals.qml:34-36).
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
function t(s) { return QbzSession.tr(s, QbzSession.trRev) }
|
||||
|
||||
// --- Documents. Guarded parses: a raw JSON.parse in a binding throws on
|
||||
// the pre-publish frame (PlaylistView.qml:55-61).
|
||||
readonly property var createDoc: {
|
||||
try { return JSON.parse(QbzFolderEdit.createJson) } catch (e) { return ({}) }
|
||||
}
|
||||
readonly property var editDoc: {
|
||||
try { return JSON.parse(QbzFolderEdit.editJson) } catch (e) { return ({}) }
|
||||
}
|
||||
|
||||
readonly property bool createOpen: root.createDoc.open === true
|
||||
readonly property bool creating: root.createDoc.creating === true
|
||||
readonly property bool editOpen: root.editDoc.open === true
|
||||
/// Rust REFUSES `createClose()` / `editClose()` while a write is in flight
|
||||
/// (D22 — `busy` holds the panel open). The close X must therefore SHOW
|
||||
/// that it is inert for that window, or it is a control that renders and
|
||||
/// no-ops. Same treatment the panel's own Delete button already carries.
|
||||
readonly property bool editBusy: root.editDoc.busy === true
|
||||
|
||||
visible: root.createOpen || root.editOpen
|
||||
enabled: root.visible
|
||||
|
||||
// ==================================================================
|
||||
// PANEL 1 — Create folder (CreateFolderModal.slint)
|
||||
// ==================================================================
|
||||
property string draftCreateName: ""
|
||||
readonly property bool canCreate: root.draftCreateName.trim() !== "" && !root.creating
|
||||
|
||||
onCreateOpenChanged: {
|
||||
if (root.createOpen) {
|
||||
// Its OWN draft, reset on its OWN open transition.
|
||||
root.draftCreateName = ""
|
||||
createScope.forceActiveFocus()
|
||||
createField.focusField()
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: createScope
|
||||
anchors.fill: parent
|
||||
visible: root.createOpen
|
||||
enabled: root.createOpen
|
||||
|
||||
// Taken HERE rather than in the open handler: an invisible item cannot
|
||||
// hold active focus, and a handler on the document property is not
|
||||
// ordered against the `visible` binding it shares a frame with.
|
||||
onVisibleChanged: if (createScope.visible) createScope.forceActiveFocus()
|
||||
|
||||
Keys.onEscapePressed: function (event) {
|
||||
QbzFolderEdit.createClose()
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
// `radius` is load-bearing: this Item fills AppShell's ROUNDED content
|
||||
// frame and Qt Quick's clip is a rectangular scissor, so an opaque
|
||||
// full-bleed child paints into the frame's four bezel corners
|
||||
// (AppShell.qml:246-310). #bf000000 is Slint's #000000bf CONVERTED —
|
||||
// Slint is #RRGGBBAA, Qt is #AARRGGBB.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: theme.radiusMd
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzFolderEdit.createClose()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 80, 400)
|
||||
height: createCol.implicitHeight + 40
|
||||
x: Math.round((root.width - width) / 2)
|
||||
y: Math.round((root.height - height) / 2)
|
||||
radius: theme.radiusMd
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
|
||||
// FIRST child: swallows clicks so they never reach the scrim.
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Column {
|
||||
id: createCol
|
||||
x: 20
|
||||
y: 20
|
||||
width: parent.width - 40
|
||||
spacing: 16
|
||||
|
||||
// --- Title + close X.
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 28
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.max(0, parent.width - 28)
|
||||
text: root.t("New folder")
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontHeading
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Item {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
opacity: root.creating ? 0.5 : 1.0
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
width: 17
|
||||
height: 17
|
||||
name: "x"
|
||||
tintName: createCloseArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: createCloseArea
|
||||
anchors.fill: parent
|
||||
// `createClose()` is refused mid-create, so the
|
||||
// affordance goes with it rather than lying.
|
||||
enabled: !root.creating
|
||||
hoverEnabled: !root.creating
|
||||
cursorShape: root.creating ? Qt.ArrowCursor
|
||||
: Qt.PointingHandCursor
|
||||
onClicked: QbzFolderEdit.createClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Name. No label above it — the reference has none here.
|
||||
QbzLineEdit {
|
||||
id: createField
|
||||
width: parent.width
|
||||
text: root.draftCreateName
|
||||
placeholder: root.t("Folder name")
|
||||
onEdited: function (value) { root.draftCreateName = value }
|
||||
onAccepted: function (value) {
|
||||
root.draftCreateName = value
|
||||
if (root.canCreate)
|
||||
QbzFolderEdit.createSubmit(root.draftCreateName)
|
||||
}
|
||||
}
|
||||
|
||||
// --- Footer.
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
QbzPrimaryButton {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: root.creating ? root.t("Creating...") : root.t("Create")
|
||||
btnHeight: 36
|
||||
labelSize: 15
|
||||
btnEnabled: root.canCreate
|
||||
onClicked: QbzFolderEdit.createSubmit(root.draftCreateName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// PANEL 2 — The folder editor (FolderEditModal.slint)
|
||||
// ==================================================================
|
||||
// Seeds are consumed ONCE per open, and again when the editor is pointed
|
||||
// at a different folder without closing. A plain republish (a busy flip, a
|
||||
// picked image) must NOT reseed — it would throw away what the user typed.
|
||||
readonly property string editSeedKey:
|
||||
(root.editOpen ? "1" : "0") + "|" + (root.editDoc.id || "")
|
||||
|
||||
onEditSeedKeyChanged: {
|
||||
if (root.editOpen) {
|
||||
editPanel.seed()
|
||||
editScope.forceActiveFocus()
|
||||
editPanel.focusName()
|
||||
}
|
||||
}
|
||||
onEditOpenChanged: {
|
||||
// A sub-modal must never outlive its host panel.
|
||||
if (!root.editOpen)
|
||||
deleteConfirm.close()
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: editScope
|
||||
anchors.fill: parent
|
||||
visible: root.editOpen
|
||||
enabled: root.editOpen
|
||||
|
||||
onVisibleChanged: if (editScope.visible) editScope.forceActiveFocus()
|
||||
|
||||
Keys.onEscapePressed: function (event) {
|
||||
// The confirm holds focus while it is up and handles its own Esc,
|
||||
// so reaching here means the panel is the innermost open thing.
|
||||
QbzFolderEdit.editClose()
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: theme.radiusMd
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzFolderEdit.editClose()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 80, 480)
|
||||
height: editCol.implicitHeight + 40
|
||||
x: Math.round((root.width - width) / 2)
|
||||
y: Math.round((root.height - height) / 2)
|
||||
radius: theme.radiusMd
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Column {
|
||||
id: editCol
|
||||
x: 20
|
||||
y: 20
|
||||
width: parent.width - 40
|
||||
spacing: 16
|
||||
|
||||
// --- Title + close X.
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 28
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.max(0, parent.width - 28)
|
||||
// "" is CREATE mode — the manager toolbar's New folder
|
||||
// opens this same editor with no id.
|
||||
text: (root.editDoc.id || "") === "" ? root.t("New folder")
|
||||
: root.t("Edit folder")
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontHeading
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Item {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
opacity: root.editBusy ? 0.5 : 1.0
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
width: 17
|
||||
height: 17
|
||||
name: "x"
|
||||
tintName: editCloseArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: editCloseArea
|
||||
anchors.fill: parent
|
||||
// `editClose()` is refused while a save or delete
|
||||
// is in flight — see `editBusy`.
|
||||
enabled: !root.editBusy
|
||||
hoverEnabled: !root.editBusy
|
||||
cursorShape: root.editBusy ? Qt.ArrowCursor
|
||||
: Qt.PointingHandCursor
|
||||
onClicked: QbzFolderEdit.editClose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FolderEditPanel {
|
||||
id: editPanel
|
||||
width: parent.width
|
||||
doc: root.editDoc
|
||||
onDeleteRequested: deleteConfirm.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ==================================================================
|
||||
// The delete confirm — LAST, so it stacks over the editor (D21).
|
||||
// ==================================================================
|
||||
// The reference raises a NATIVE rfd message box with untranslated &str
|
||||
// (main.rs:5724); this is the in-app surface the port already has, and its
|
||||
// two strings are new msgids. The body interpolates the LIVE draft name,
|
||||
// matching the reference's `get_name()` — rename the folder, then delete
|
||||
// it without saving, and the prompt still names what is on screen.
|
||||
QbzConfirmModal {
|
||||
id: deleteConfirm
|
||||
anchors.fill: parent
|
||||
danger: true
|
||||
title: root.t("Delete folder")
|
||||
body: root.t("Delete the folder “{}”? Its playlists move back to the root.")
|
||||
.replace("{}", editPanel.draftName)
|
||||
confirmLabel: root.t("Delete")
|
||||
onConfirmed: {
|
||||
QbzFolderEdit.editDeleteConfirmed()
|
||||
// Hand focus back so Esc keeps working on the panel that is still
|
||||
// up while the delete is in flight.
|
||||
if (root.editOpen)
|
||||
editScope.forceActiveFocus()
|
||||
}
|
||||
onCancelled: {
|
||||
if (root.editOpen)
|
||||
editScope.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
// PlaylistEditModal — THE playlist editor (primitives/EditPlaylistModal.slint):
|
||||
// rename, description, the offline-only flag and delete, for BOTH kinds of
|
||||
// playlist (`local:<uuid>` and a Qobuz u64) and for every surface that offers
|
||||
// "Edit playlist":
|
||||
//
|
||||
// * the manager's PmGridCard / PmListRow / PmTreePlaylistRow pencils,
|
||||
// * qml/shell/SidebarRowMenu.qml's "Edit playlist" row,
|
||||
// * qml/views/PlaylistView.qml's header pencil (contract block 7) — whose
|
||||
// inline rename+delete Popup this file REPLACES. That popup could express
|
||||
// neither a description nor the offline-only flag, and it carried a delete
|
||||
// arm, so the replacement has to cover both verbs or deleting it removes
|
||||
// working functionality (D20).
|
||||
//
|
||||
// Mounted ONCE in qml/shell/AppShell.qml as a direct child of the root, after
|
||||
// FolderModals and before QbzToast, with no `z` — that file's convention is
|
||||
// DECLARATION ORDER, and ADR-009's ">= 3000" is satisfied structurally.
|
||||
//
|
||||
// ── NO INPUTS ──────────────────────────────────────────────────────────────
|
||||
// It reads QbzPlaylistEdit.editJson (§4.6) and owns its own drafts. QML has no
|
||||
// lexical scope across files, so everything it reads is declared on its own
|
||||
// root or comes from a singleton.
|
||||
//
|
||||
// ── THE DRAFTS LIVE HERE, THE ID DOES NOT ──────────────────────────────────
|
||||
// Name, description and the offline-only checkbox are QML-LOCAL and reach Rust
|
||||
// only as arguments to `save(name, description, offlineOnly)` (MyQbzModals.qml's
|
||||
// standing rule). The id being edited is RUST state and is never echoed back,
|
||||
// so a republish can never make this modal save under the wrong playlist.
|
||||
//
|
||||
// ── `descLoaded` IS NOT COSMETIC ───────────────────────────────────────────
|
||||
// When Rust could not resolve the real description, the field is NOT RENDERED
|
||||
// and `save` sends `None`, i.e. "leave the stored description alone". A field
|
||||
// the user never saw can never overwrite stored data. The reference seeds ""
|
||||
// and always writes it back, which deletes the description on every rename
|
||||
// (§5.2). Do not "simplify" this into an always-visible empty field.
|
||||
//
|
||||
// ── `busy` HOLDS THE MODAL OPEN ────────────────────────────────────────────
|
||||
// The modal never closes itself. Rust closes it, and only after the write
|
||||
// landed (D22) — a failed rename keeps what the user typed on screen and
|
||||
// toasts. `close()` is REFUSED while busy, so the close X and the scrim go
|
||||
// inert for that window rather than rendering and no-opping.
|
||||
//
|
||||
// ── NO DELETE CONFIRM, ON PURPOSE ──────────────────────────────────────────
|
||||
// The reference's danger button calls `EditPlaylistActions.delete()` straight
|
||||
// (EditPlaylistModal.slint:150-155), unlike the FOLDER editor, whose reference
|
||||
// raises a native rfd message box that this port replaced with
|
||||
// QbzConfirmModal. Adding one here would be a redesign, not a port.
|
||||
//
|
||||
// ── ESCAPE IS A WRAPPING FocusScope, NOT A SIBLING ONE ─────────────────────
|
||||
// The name field takes active focus and QML propagates an unhandled key up the
|
||||
// focused item's PARENT chain, so a sibling scope would be dead the moment the
|
||||
// field is focused (the FolderModals.qml note). QbzLineEdit's TextInput leaves
|
||||
// Escape unaccepted on the plain arm, so it reaches us.
|
||||
//
|
||||
// ── ENTER ──────────────────────────────────────────────────────────────────
|
||||
// Through QbzLineEdit's `accepted`, NEVER `committed`: committed also fires on
|
||||
// focus-out, and closing the modal blurs the field, which would rename twice
|
||||
// (MyQbzModals.qml:34-36).
|
||||
//
|
||||
// ── REUSED, NOT REDRAWN ────────────────────────────────────────────────────
|
||||
// QbzLineEdit the name field. Its width MUST be set — the plain arm is
|
||||
// a fixed `width: 240` (QbzLineEdit.qml:62) where the Slint
|
||||
// LineEdit stretches to the panel.
|
||||
// QbzTextArea the description body, the port's multiline input (its one
|
||||
// prior call site is MyQBZ's edit modal, the same job).
|
||||
// QbzCheckbox the offline-only row. Already 18x18 r4, accent when
|
||||
// checked, 2px muted ring when not, and it never self-flips
|
||||
// — exactly what a QML-local draft needs (§5.21).
|
||||
// QbzPrimaryButton Save. The reference's `#ffffffd6` hover on an accent fill
|
||||
// and its hardcoded `#ffffff` label are NOT copied; both
|
||||
// wash out on the light palettes.
|
||||
// Delete button hand-drawn, byte-for-byte the ghost danger button
|
||||
// FolderEditPanel.qml uses, for the same reason: the port's
|
||||
// filled danger control is a different affordance.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
function t(s) { return QbzSession.tr(s, QbzSession.trRev) }
|
||||
|
||||
// Guarded parse: a raw JSON.parse in a binding throws on the pre-publish
|
||||
// frame (PlaylistView.qml:55-61).
|
||||
readonly property var doc: {
|
||||
try { return JSON.parse(QbzPlaylistEdit.editJson) } catch (e) { return ({}) }
|
||||
}
|
||||
|
||||
readonly property bool editOpen: root.doc.open === true
|
||||
readonly property bool busy: root.doc.busy === true
|
||||
readonly property bool isLocal: root.doc.isLocal === true
|
||||
readonly property bool descLoaded: root.doc.descLoaded === true
|
||||
|
||||
// --- Drafts -----------------------------------------------------------
|
||||
property string draftName: ""
|
||||
property string draftDescription: ""
|
||||
property bool draftOfflineOnly: false
|
||||
|
||||
readonly property bool canSave: root.draftName.trim() !== "" && !root.busy
|
||||
|
||||
visible: root.editOpen
|
||||
enabled: root.visible
|
||||
|
||||
// Seeds are consumed ONCE per open, and again when the editor is pointed
|
||||
// at a different playlist without closing. A plain republish (the `busy`
|
||||
// flip on save) must NOT reseed — it would throw away what the user typed.
|
||||
readonly property string seedKey:
|
||||
(root.editOpen ? "1" : "0") + "|" + (root.doc.id || "")
|
||||
|
||||
onSeedKeyChanged: {
|
||||
if (root.editOpen) {
|
||||
root.draftName = root.doc.name || ""
|
||||
root.draftDescription = root.doc.description || ""
|
||||
root.draftOfflineOnly = root.doc.offlineOnly === true
|
||||
scope.forceActiveFocus()
|
||||
nameField.focusField()
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (root.canSave)
|
||||
QbzPlaylistEdit.save(root.draftName, root.draftDescription,
|
||||
root.draftOfflineOnly)
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: scope
|
||||
anchors.fill: parent
|
||||
visible: root.editOpen
|
||||
enabled: root.editOpen
|
||||
|
||||
// Taken HERE rather than only in the open handler: an invisible item
|
||||
// cannot hold active focus, and a handler on the document property is
|
||||
// not ordered against the `visible` binding it shares a frame with.
|
||||
onVisibleChanged: if (scope.visible) scope.forceActiveFocus()
|
||||
|
||||
Keys.onEscapePressed: function (event) {
|
||||
QbzPlaylistEdit.close()
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
// `radius` is load-bearing: this Item fills AppShell's ROUNDED content
|
||||
// frame and Qt Quick's clip is a rectangular scissor, so an opaque
|
||||
// full-bleed child paints into the frame's four bezel corners
|
||||
// (AppShell.qml:246-310). #bf000000 is Slint's #000000bf CONVERTED —
|
||||
// Slint is #RRGGBBAA, Qt is #AARRGGBB.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: theme.radiusMd
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzPlaylistEdit.close()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: Math.min(root.width - 80, 420)
|
||||
height: col.implicitHeight + 40
|
||||
x: Math.round((root.width - width) / 2)
|
||||
y: Math.round((root.height - height) / 2)
|
||||
radius: theme.radiusMd
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
|
||||
// FIRST child: swallows clicks so they never reach the scrim.
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Column {
|
||||
id: col
|
||||
x: 20
|
||||
y: 20
|
||||
width: parent.width - 40
|
||||
spacing: 16
|
||||
|
||||
// ================= Title + close X ======================
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 28
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.max(0, parent.width - 28)
|
||||
text: root.t("Edit playlist")
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontHeading
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Item {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
opacity: root.busy ? 0.5 : 1.0
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
width: 17
|
||||
height: 17
|
||||
name: "x"
|
||||
tintName: closeArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: closeArea
|
||||
anchors.fill: parent
|
||||
// `close()` is refused while a write is in flight,
|
||||
// so the affordance goes with it rather than lying.
|
||||
enabled: !root.busy
|
||||
hoverEnabled: !root.busy
|
||||
cursorShape: root.busy ? Qt.ArrowCursor
|
||||
: Qt.PointingHandCursor
|
||||
onClicked: QbzPlaylistEdit.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Name =================================
|
||||
// No label above it — the reference has none here, only the
|
||||
// placeholder (EditPlaylistModal.slint:66).
|
||||
QbzLineEdit {
|
||||
id: nameField
|
||||
width: parent.width
|
||||
text: root.draftName
|
||||
placeholder: root.t("Playlist name")
|
||||
enabled: !root.busy
|
||||
onEdited: function (value) { root.draftName = value }
|
||||
onAccepted: function (value) {
|
||||
root.draftName = value
|
||||
root.submit()
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Description ==========================
|
||||
// Rendered ONLY when Rust resolved the real one. A Column
|
||||
// skips invisible children, so this leaves no gap.
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: 6
|
||||
visible: root.descLoaded
|
||||
Text {
|
||||
text: root.t("Description")
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
}
|
||||
QbzTextArea {
|
||||
width: parent.width
|
||||
height: 90
|
||||
text: root.draftDescription
|
||||
enabled: !root.busy
|
||||
onEdited: function (value) { root.draftDescription = value }
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Offline-only =========================
|
||||
// LOCAL playlists only — the flag is a `local_playlists`
|
||||
// column with no Qobuz analogue. Unmark it to make "Upload to
|
||||
// Qobuz" available (D8).
|
||||
// An Item with a FIXED height, not a Row: a Row's height comes
|
||||
// from its tallest child, so anchoring a child to
|
||||
// `parent.verticalCenter` inside one is a binding loop. Same
|
||||
// shape FolderEditPanel.qml's hidden row uses.
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 20
|
||||
visible: root.isLocal
|
||||
// 20x20 wrapper: the larger hit target the reference's
|
||||
// TouchArea gives the 18px box (§5.21).
|
||||
Item {
|
||||
id: offlineHit
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 20
|
||||
height: 20
|
||||
QbzCheckbox {
|
||||
anchors.centerIn: parent
|
||||
checked: root.draftOfflineOnly
|
||||
enabled: !root.busy
|
||||
// QbzCheckbox never self-flips; the owner of the
|
||||
// state does.
|
||||
onToggled: root.draftOfflineOnly = !root.draftOfflineOnly
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.left: offlineHit.right
|
||||
anchors.leftMargin: 10
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.t("Offline-only playlist")
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: 15
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
// ================= Footer ===============================
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 36
|
||||
|
||||
// Delete — a ghost danger button: fill on hover only, 1px
|
||||
// danger border, danger label. theme.danger /
|
||||
// theme.dangerHover ARE the reference's #ef4444 /
|
||||
// #ef444433 under the default theme (the engine defaults
|
||||
// danger to rgb(ef,44,44) and derives danger_hover as a
|
||||
// 0.2 tint, i.e. alpha 0x33) and the correct colours under
|
||||
// the other 35.
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: delLabel.implicitWidth + 28
|
||||
height: 36
|
||||
radius: 8
|
||||
color: (delArea.containsMouse && !root.busy) ? theme.dangerHover
|
||||
: "transparent"
|
||||
border.width: 1
|
||||
border.color: theme.danger
|
||||
opacity: root.busy ? 0.5 : 1.0
|
||||
Text {
|
||||
id: delLabel
|
||||
anchors.centerIn: parent
|
||||
text: root.t("Delete")
|
||||
color: theme.danger
|
||||
font.pixelSize: 15
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
MouseArea {
|
||||
id: delArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: root.busy ? Qt.ArrowCursor
|
||||
: Qt.PointingHandCursor
|
||||
onClicked: if (!root.busy) QbzPlaylistEdit.deletePlaylist()
|
||||
}
|
||||
}
|
||||
|
||||
QbzPrimaryButton {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
label: root.t("Save")
|
||||
btnHeight: 36
|
||||
labelSize: 15
|
||||
btnEnabled: root.canSave
|
||||
onClicked: root.submit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,688 @@
|
||||
// "Import Playlist" — QML port of
|
||||
// crates/qbz-ui/ui/primitives/PlaylistImportModal.slint (itself a 1:1 port of
|
||||
// Tauri's PlaylistImportModal.svelte).
|
||||
//
|
||||
// Two-step flow: URL entry -> provider auto-detect (RUST-side, one round trip
|
||||
// per keystroke, exactly as the reference does) -> fetch preview -> rename +
|
||||
// optional folder -> import with a live progress bar, a status line and an
|
||||
// append-only log, then an in-panel Summary block. Every interpolated string
|
||||
// arrives PRE-FORMATTED in the document (playlist_import_qt.rs); this file
|
||||
// renders them verbatim and never pluralises or interpolates a count itself.
|
||||
//
|
||||
// Mounted ONCE in AppShell next to PlaylistPickerModal, NOT inside the sidebar
|
||||
// (05 §5.8.5): the two surfaces that open it — the sidebar `...` menu and the
|
||||
// closed-sidebar flyout — have no lifetime guarantee across a navigation, and
|
||||
// closing the modal must never cancel an in-flight import.
|
||||
//
|
||||
// CLOSE SEMANTICS (reference §1.8): the footer Close disables while loading
|
||||
// (Tauri-verbatim); the header X and the scrim stay clickable mid-import —
|
||||
// closing only hides the UI, the tokio task runs to completion and still
|
||||
// toasts, assigns the folder and refreshes the sidebar.
|
||||
//
|
||||
// OFFLINE is gated in TWO layers (05 §5.8.7), both required: the sidebar row is
|
||||
// inert while `QbzSession.offline`, AND this modal carries its own banner and a
|
||||
// `canFetch` that Rust computes as `provider detected && !offline`. The URL
|
||||
// field stays enabled — only the fetch is refused.
|
||||
//
|
||||
// PROVIDER MARKS. Spotify / Apple Music / Deezer are self-coloured marks and
|
||||
// render UNTINTED out of qml/assets/brand/, the rule SourceIcon.qml calls
|
||||
// load-bearing. Tidal's upstream asset is a black `fill` with no colour to
|
||||
// lose, so it goes through QbzIcon at `textPrimary` instead: the reference
|
||||
// hardcodes it to white (PlaylistImportModal.slint:271-279) which is
|
||||
// illegible on the 11 light themes, and a monochrome glyph is exactly what the
|
||||
// tint table is for. The header's Qobuz mark is the port's existing
|
||||
// `qobuz-logo-filled.svg` brand asset for the same reason — the reference tints
|
||||
// its outline logo white, which disappears on a light `surface-card`.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
// An unopened overlay is an invisible, non-interactive Item and costs
|
||||
// nothing (the AppShell mount comment states the contract).
|
||||
visible: doc.open === true
|
||||
|
||||
readonly property var doc: JSON.parse(QbzPlaylistImport.importJson)
|
||||
readonly property var logRows: doc.log || []
|
||||
readonly property bool loading: doc.loading === true
|
||||
readonly property bool showPreview: doc.showPreview === true
|
||||
readonly property bool importCompleted: doc.importCompleted === true
|
||||
readonly property var folderOptions: doc.folderOptions || []
|
||||
|
||||
// Bumped by every QbzPlaylistImport.open(). The reference remounts the
|
||||
// whole Svelte component per open and Slint reproduces it by clearing 14
|
||||
// properties; here Rust resets its document and this counter tells the two
|
||||
// QML-local text mirrors to drop what the user last typed (05 §5.8.3).
|
||||
readonly property int resetSeq: doc.resetSeq || 0
|
||||
onResetSeqChanged: {
|
||||
urlInput.text = ""
|
||||
nameInput.text = ""
|
||||
}
|
||||
|
||||
// Absolute qrc prefix for the brand SVGs — same rule as QbzIcon: a relative
|
||||
// URL resolves against the CONSUMER's document depth.
|
||||
readonly property string brandDir: "qrc:/qt/qml/com/blitzfc/qbz/qml/assets/brand/"
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
// Scrim — click outside dismisses, EVEN MID-IMPORT (§1.8: closing only
|
||||
// hides the UI, the task keeps running).
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzPlaylistImport.close()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: card
|
||||
anchors.centerIn: parent
|
||||
// Tauri: 560px max, min-height 420px, max-height 90vh.
|
||||
width: Math.min(parent.width - 80, 560)
|
||||
// 140 = header 68 + 2 hairlines + footer 70 (16/34/20); the body
|
||||
// scrolls inside the Flickable past the 90 % clamp.
|
||||
height: Math.min(Math.max(420, bodyCol.implicitHeight + 140), parent.height * 0.9)
|
||||
radius: theme.radiusLg
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
// Swallow clicks so they never reach the scrim.
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
readonly property int contentWidth: card.width - 48
|
||||
|
||||
// ---------------------------- header ----------------------------
|
||||
Item {
|
||||
id: header
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 68
|
||||
|
||||
Image {
|
||||
id: qobuzMark
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 26
|
||||
height: 26
|
||||
source: root.brandDir + "qobuz-logo-filled.svg"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
sourceSize.width: 52
|
||||
sourceSize.height: 52
|
||||
smooth: true
|
||||
opacity: 0.9
|
||||
}
|
||||
Text {
|
||||
anchors.left: qobuzMark.right
|
||||
anchors.leftMargin: 10
|
||||
anchors.right: closeX.left
|
||||
anchors.rightMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Import Playlist", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
// X close — allowed mid-import (§1.8).
|
||||
Item {
|
||||
id: closeX
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "x"
|
||||
width: 17
|
||||
height: 17
|
||||
tintName: closeXArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: closeXArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: QbzPlaylistImport.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: headerDiv
|
||||
anchors.top: header.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 1
|
||||
color: theme.borderSubtle
|
||||
}
|
||||
|
||||
// ---------------------------- footer ----------------------------
|
||||
// Declared before the body so the body can anchor to the divider; the
|
||||
// footer is pinned to the card bottom either way.
|
||||
Item {
|
||||
id: footerBar
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 70
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 24
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 20
|
||||
spacing: 12
|
||||
|
||||
SettingsButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Close", QbzSession.trRev)
|
||||
btnHeight: 34
|
||||
minWidth: 0
|
||||
// Tauri-verbatim: the FOOTER close disables while loading;
|
||||
// the header X and the scrim do not.
|
||||
enabled: !root.loading
|
||||
onClicked: QbzPlaylistImport.close()
|
||||
}
|
||||
// The single accent confirm (ADR-008). Step A fetches, step B
|
||||
// imports; it stays visible-but-disabled after completion.
|
||||
QbzPrimaryButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
btnHeight: 34
|
||||
label: root.showPreview
|
||||
? (root.loading ? QbzSession.tr("Importing...", QbzSession.trRev)
|
||||
: QbzSession.tr("Import", QbzSession.trRev))
|
||||
: (root.loading ? QbzSession.tr("Fetching...", QbzSession.trRev)
|
||||
: QbzSession.tr("Fetch playlist", QbzSession.trRev))
|
||||
btnEnabled: root.showPreview
|
||||
? (!root.loading && !root.importCompleted)
|
||||
: (root.doc.canFetch === true && !root.loading)
|
||||
onClicked: {
|
||||
if (root.showPreview)
|
||||
QbzPlaylistImport.execute()
|
||||
else
|
||||
QbzPlaylistImport.fetch()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: footerDiv
|
||||
anchors.bottom: footerBar.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 1
|
||||
color: theme.borderSubtle
|
||||
}
|
||||
|
||||
// ----------------------------- body -----------------------------
|
||||
// Scrolls when the progress panel outgrows the card.
|
||||
Flickable {
|
||||
id: bodyFlick
|
||||
anchors.top: headerDiv.bottom
|
||||
anchors.bottom: footerDiv.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
clip: true
|
||||
contentWidth: width
|
||||
contentHeight: bodyCol.implicitHeight
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
Column {
|
||||
id: bodyCol
|
||||
width: card.width
|
||||
padding: 24
|
||||
spacing: 16
|
||||
|
||||
// --- Offline banner ---------------------------------------
|
||||
// The fetch is gated (Rust drives `canFetch` false); the URL
|
||||
// input stays enabled, exactly as the reference does.
|
||||
//
|
||||
// The shared control, with the deltas BlacklistManagerView.qml
|
||||
// already records for it: the copy goes in `title` because that
|
||||
// is the TONE-coloured line, the glyph is `info` rather than
|
||||
// `cloud-off`, and the tone alphas are 10 %/30 % against the
|
||||
// reference's #eab3081a / #eab3084d (identical arithmetic, the
|
||||
// theme's warning token instead of a literal).
|
||||
WarningBanner {
|
||||
width: card.contentWidth
|
||||
visible: QbzSession.offline
|
||||
variant: "warning"
|
||||
title: QbzSession.tr("This feature requires internet connection", QbzSession.trRev)
|
||||
}
|
||||
|
||||
// --- Error banner (preview or execute failure) -------------
|
||||
WarningBanner {
|
||||
width: card.contentWidth
|
||||
visible: (root.doc.error || "") !== ""
|
||||
variant: "error"
|
||||
title: root.doc.error || ""
|
||||
}
|
||||
|
||||
// --- URL input --------------------------------------------
|
||||
// Every keystroke routes the provider detection through Rust
|
||||
// (the reference does the same because Slint 1.16 strings have
|
||||
// no `.contains`; here it is what keeps ONE detector — the
|
||||
// crate's `detect_provider_key` — as the source of truth
|
||||
// instead of a second JS copy that would drift).
|
||||
Column {
|
||||
width: card.contentWidth
|
||||
spacing: 8
|
||||
Text {
|
||||
text: QbzSession.tr("Playlist URL", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
// The standard 43px input box (the PlaylistPickerModal
|
||||
// recipe — QbzLineEdit is 34px, commits only on Enter/blur
|
||||
// in its plain arm and has no `enabled` gate, so it cannot
|
||||
// serve a per-keystroke field that must disable mid-fetch).
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 43
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: urlInput.activeFocus ? theme.accent : theme.borderSubtle
|
||||
opacity: root.loading ? 0.5 : 1.0
|
||||
|
||||
TextInput {
|
||||
id: urlInput
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontLink
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
clip: true
|
||||
selectByMouse: true
|
||||
enabled: !root.loading
|
||||
onTextEdited: QbzPlaylistImport.urlEdited(text)
|
||||
onAccepted: {
|
||||
if (!root.showPreview && root.doc.canFetch === true && !root.loading)
|
||||
QbzPlaylistImport.fetch()
|
||||
}
|
||||
// Re-seed from the document while the field is NOT
|
||||
// being edited (the PlaylistPickerModal shape): user
|
||||
// typing breaks a plain `text:` binding for good, so
|
||||
// a reset would never reach the field.
|
||||
Binding {
|
||||
target: urlInput
|
||||
property: "text"
|
||||
value: root.doc.url || ""
|
||||
when: !urlInput.activeFocus
|
||||
}
|
||||
}
|
||||
Text {
|
||||
// Placeholder. Plain string: not localized in the
|
||||
// reference either (it is a URL shape, not copy).
|
||||
visible: urlInput.text === ""
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: "https://open.spotify.com/playlist/..."
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLink
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Allowed sources --------------------------------------
|
||||
// The detected provider's mark at full opacity, the rest dimmed
|
||||
// (the reference's §1.5 homologation: no glow / translate /
|
||||
// scale, opacity 0.45 idle / 1.0 active).
|
||||
Column {
|
||||
width: card.contentWidth
|
||||
spacing: 8
|
||||
Text {
|
||||
text: QbzSession.tr("ALLOWED SOURCES", QbzSession.trRev)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightSemibold
|
||||
font.letterSpacing: 0.5
|
||||
}
|
||||
Row {
|
||||
spacing: 10
|
||||
Image {
|
||||
width: 70
|
||||
height: 24
|
||||
source: root.brandDir + "spotify-logo.svg"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
sourceSize.width: 140
|
||||
sourceSize.height: 48
|
||||
smooth: true
|
||||
opacity: root.doc.activeProvider === "spotify" ? 1.0 : 0.45
|
||||
}
|
||||
Image {
|
||||
width: 70
|
||||
height: 24
|
||||
source: root.brandDir + "apple-music-logo.svg"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
sourceSize.width: 140
|
||||
sourceSize.height: 48
|
||||
smooth: true
|
||||
opacity: root.doc.activeProvider === "apple" ? 1.0 : 0.45
|
||||
}
|
||||
// Monochrome mark -> the tint table, so it reads on the
|
||||
// dark AND the light themes (see the file header).
|
||||
QbzIcon {
|
||||
width: 70
|
||||
height: 24
|
||||
name: "tidal-tidal"
|
||||
tintName: "textPrimary"
|
||||
opacity: root.doc.activeProvider === "tidal" ? 1.0 : 0.45
|
||||
}
|
||||
Image {
|
||||
width: 70
|
||||
height: 24
|
||||
source: root.brandDir + "deezer-logo.svg"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
sourceSize.width: 140
|
||||
sourceSize.height: 48
|
||||
smooth: true
|
||||
opacity: root.doc.activeProvider === "deezer" ? 1.0 : 0.45
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Customization panel (step B) -------------------------
|
||||
// Rename + optional folder. Editing the URL reverts to step A
|
||||
// (`showPreview` recomputes Rust-side on every keystroke).
|
||||
Rectangle {
|
||||
width: card.contentWidth
|
||||
visible: root.showPreview
|
||||
height: customCol.implicitHeight
|
||||
radius: theme.radiusMd
|
||||
color: theme.surfaceElevated
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
|
||||
Column {
|
||||
id: customCol
|
||||
width: parent.width
|
||||
padding: 16
|
||||
spacing: 12
|
||||
|
||||
Column {
|
||||
width: parent.width - 32
|
||||
spacing: 8
|
||||
Text {
|
||||
text: QbzSession.tr("Playlist name", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 43
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: nameInput.activeFocus ? theme.accent : theme.borderSubtle
|
||||
opacity: nameInput.enabled ? 1.0 : 0.5
|
||||
|
||||
TextInput {
|
||||
id: nameInput
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontLink
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
clip: true
|
||||
selectByMouse: true
|
||||
enabled: !root.loading && !root.importCompleted
|
||||
onTextEdited: QbzPlaylistImport.nameEdited(text)
|
||||
onAccepted: {
|
||||
// Enter here executes (step B).
|
||||
if (!root.loading && !root.importCompleted)
|
||||
QbzPlaylistImport.execute()
|
||||
}
|
||||
// Rust prefills this with the fetched
|
||||
// playlist name, so the re-seed is not just
|
||||
// a reset path here — it is how the name
|
||||
// arrives at all.
|
||||
Binding {
|
||||
target: nameInput
|
||||
property: "text"
|
||||
value: root.doc.customName || ""
|
||||
when: !nameInput.activeFocus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Folder dropdown — only when the user HAS folders
|
||||
// (index 0 is always "No folder", so length > 1).
|
||||
Column {
|
||||
width: parent.width - 32
|
||||
spacing: 8
|
||||
visible: root.folderOptions.length > 1
|
||||
Text {
|
||||
text: QbzSession.tr("Folder", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
QbzSelect {
|
||||
options: root.folderOptions
|
||||
currentIndex: root.doc.folderIndex || 0
|
||||
menuWidth: parent.width
|
||||
// The reference caps its menu at 380px; here the
|
||||
// control is full-width, so the popup matches it.
|
||||
popupWidth: parent.width
|
||||
searchable: root.folderOptions.length > 8
|
||||
onSelected: function (i) { QbzPlaylistImport.setFolderIndex(i) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Progress panel ---------------------------------------
|
||||
// Spinner header, determinate bar, status + current-track
|
||||
// lines, the append-only log, and the Summary block.
|
||||
Rectangle {
|
||||
width: card.contentWidth
|
||||
visible: root.doc.progressVisible === true
|
||||
height: progressCol.implicitHeight
|
||||
radius: theme.radiusMd
|
||||
color: theme.surfaceElevated
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
|
||||
Column {
|
||||
id: progressCol
|
||||
width: parent.width
|
||||
padding: 16
|
||||
spacing: 10
|
||||
|
||||
Item {
|
||||
width: parent.width - 32
|
||||
height: 20
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.right: spinnerSlot.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Conversion progress", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontBody
|
||||
font.weight: theme.weightMedium
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
// Tauri: a 14px accent ring while loading.
|
||||
Item {
|
||||
id: spinnerSlot
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 14
|
||||
height: 14
|
||||
QbzSpinner {
|
||||
anchors.centerIn: parent
|
||||
size: 14
|
||||
visible: root.loading
|
||||
spinning: root.loading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - 32
|
||||
spacing: 6
|
||||
visible: root.doc.hasProgress === true
|
||||
|
||||
// Determinate 6px bar (the LocalLibrarySettings
|
||||
// recipe); the track uses the subtle border tone
|
||||
// because the panel is already surface-elevated.
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 6
|
||||
radius: 3
|
||||
color: theme.borderSubtle
|
||||
clip: true
|
||||
Rectangle {
|
||||
width: parent.width * Math.max(0, Math.min(1, root.doc.progress || 0))
|
||||
height: parent.height
|
||||
radius: 3
|
||||
color: theme.accent
|
||||
}
|
||||
}
|
||||
// Status line — the 12px Tauri metric, fixed height
|
||||
// (the CJK floor femtovg needed; harmless here and
|
||||
// it keeps the panel from reflowing per event).
|
||||
Text {
|
||||
width: parent.width
|
||||
height: 18
|
||||
text: root.doc.statusLine || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
// Current-track line — "Artist - Title" while
|
||||
// matching, "Part i/n" while adding.
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: (root.doc.currentTrack || "") !== ""
|
||||
height: visible ? 16 : 0
|
||||
text: root.doc.currentTrack || ""
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
// Append-only log. The height is static arithmetic over
|
||||
// the ROW COUNT, never row geometry (the reference calls
|
||||
// that out as a recursion footgun). No autoscroll —
|
||||
// Tauri parity. Render-only rows: no MouseAreas here.
|
||||
Flickable {
|
||||
width: parent.width - 32
|
||||
visible: root.logRows.length > 0
|
||||
height: visible ? Math.min(root.logRows.length * 20, 160) : 0
|
||||
contentWidth: width
|
||||
contentHeight: root.logRows.length * 20
|
||||
clip: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
Repeater {
|
||||
model: root.logRows
|
||||
delegate: Text {
|
||||
required property var modelData
|
||||
width: parent ? parent.width : 0
|
||||
height: 20
|
||||
text: modelData.message || ""
|
||||
// Hex literals kept — the reference
|
||||
// hardcodes them (Tauri did too), and
|
||||
// the port has no success/danger glyph
|
||||
// ramp for a 13px log row.
|
||||
color: modelData.status === "success" ? "#34d399"
|
||||
: (modelData.status === "error" ? "#f87171" : theme.textMuted)
|
||||
font.pixelSize: theme.fontLegal
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Summary block — pre-formatted lines, hairline
|
||||
// separated, "" = hidden.
|
||||
Column {
|
||||
width: parent.width - 32
|
||||
spacing: 6
|
||||
visible: (root.doc.summaryPlaylist || "") !== ""
|
||||
|
||||
Rectangle { width: parent.width; height: 1; color: theme.borderSubtle }
|
||||
Text {
|
||||
text: QbzSession.tr("Summary", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontBody
|
||||
font.weight: theme.weightSemibold
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
height: 18
|
||||
text: root.doc.summaryPlaylist || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
height: 18
|
||||
text: root.doc.summaryMatched || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
height: 18
|
||||
text: root.doc.summarySkipped || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: (root.doc.summaryParts || "") !== ""
|
||||
height: visible ? 18 : 0
|
||||
text: root.doc.summaryParts || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The 14px gutter scrollbar, inset 4px from the right — the port's
|
||||
// shared control, attached as a SIBLING of the Flickable (it is an
|
||||
// Item with a `target`, not a QtQuick.Controls ScrollBar).
|
||||
QbzScrollBar {
|
||||
target: bodyFlick
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 4
|
||||
anchors.top: bodyFlick.top
|
||||
anchors.bottom: bodyFlick.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,685 @@
|
||||
// "Add to playlist" picker — QML port of
|
||||
// crates/qbz-ui/ui/primitives/PlaylistPickerModal.slint (+ its
|
||||
// PlaylistDuplicateConfirmModal sibling, folded in here because the two
|
||||
// share one document and one carried track set).
|
||||
//
|
||||
// A focus-opened dropdown lists the user's playlists; clicking a row only
|
||||
// SELECTS it (the selection becomes the input's placeholder); the footer
|
||||
// button fires the actual add. "+ Create new playlist" is always the first
|
||||
// dropdown row and reveals an inline name field confirmed by the same
|
||||
// footer button ("Create & Add").
|
||||
//
|
||||
// Mounted ONCE in AppShell next to AddToMixtapeModal: every host that opens
|
||||
// it (the queue footer and row menu today) can be unmounted by the time the
|
||||
// user picks a target, so the modal must outlive them.
|
||||
//
|
||||
// Data: QbzPlaylistPicker.pickerJson (playlist_picker_qt.rs PickerDoc). The
|
||||
// name filter runs in RUST (the QbzMyQbzAdd.search convention), so the row
|
||||
// list arrives already filtered; the 8-row window and the overflow line are
|
||||
// applied here against `total`/`playlists.length`.
|
||||
//
|
||||
// LOCAL playlists are listed alongside the Qobuz ones (a hard-drive glyph
|
||||
// leads the row, `isLocal` in the document) and are the ONLY rows while
|
||||
// offline — a Qobuz playlist cannot be written to without a session, so
|
||||
// offering one would be a dead target (D3/D11). The carried payload is
|
||||
// likewise either Qobuz catalog ids or LocalLibrary refs; `localMode` only
|
||||
// changes the counter's wording ("Adding {} local track(s)"), never the row
|
||||
// list — a local selection can legitimately target a Qobuz playlist, which
|
||||
// Rust routes through the library.db sidecar.
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
// An unopened overlay is an invisible, non-interactive Item and costs
|
||||
// nothing (the AppShell mount comment states the contract).
|
||||
visible: doc.open === true || dup.open === true
|
||||
|
||||
readonly property var doc: JSON.parse(QbzPlaylistPicker.pickerJson)
|
||||
readonly property var rows: doc.playlists || []
|
||||
readonly property var dup: doc.dup || ({})
|
||||
readonly property int trackCount: doc.trackCount || 0
|
||||
// The carried payload is LocalLibrary refs (counter wording only).
|
||||
readonly property bool localMode: doc.localMode === true
|
||||
readonly property bool creatingOpen: doc.creatingOpen === true
|
||||
readonly property bool creating: doc.creating === true
|
||||
|
||||
// Rows past the 8-row window collapse into the "{} more playlist(s)..."
|
||||
// line, exactly as the .slint's filter-rank window does.
|
||||
readonly property int windowSize: 8
|
||||
readonly property int shown: Math.min(rows.length, windowSize)
|
||||
readonly property int overflow: Math.max(0, rows.length - windowSize)
|
||||
|
||||
// --- Local selection state (the .slint keeps these on the `if open:`
|
||||
// subtree so a remount resets them; here they are reset when `open`
|
||||
// flips, which is the same lifetime without a conditional Loader). ---
|
||||
property bool dropdownOpen: false
|
||||
property string selectedId: ""
|
||||
property string selectedLabel: ""
|
||||
property string filterText: ""
|
||||
property string createName: ""
|
||||
|
||||
onVisibleChanged: if (!visible) resetLocals()
|
||||
function resetLocals() {
|
||||
dropdownOpen = false
|
||||
selectedId = ""
|
||||
selectedLabel = ""
|
||||
filterText = ""
|
||||
createName = ""
|
||||
}
|
||||
|
||||
function selectRow(row) {
|
||||
selectedId = row.id
|
||||
selectedLabel = (row.tracksLine || "") === ""
|
||||
? row.name : row.name + " (" + row.tracksLine + ")"
|
||||
// The reference clears the query on selection (Tauri §2.4).
|
||||
filterText = ""
|
||||
QbzPlaylistPicker.search("")
|
||||
QbzPlaylistPicker.showCreate(false)
|
||||
dropdownOpen = false
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
if (root.creating)
|
||||
return
|
||||
if (root.creatingOpen) {
|
||||
if (createName.trim() !== "")
|
||||
QbzPlaylistPicker.createAndAdd(createName)
|
||||
} else if (selectedId !== "") {
|
||||
QbzPlaylistPicker.pick(selectedId)
|
||||
}
|
||||
}
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
// ======================= The picker ==================================
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
visible: root.doc.open === true && root.dup.open !== true
|
||||
|
||||
// Scrim — click outside dismisses.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzPlaylistPicker.close()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: card
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width - 80, 490)
|
||||
// Tauri: min-height 400 / max-height 90vh. The body stretches so
|
||||
// the footer pins to the bottom.
|
||||
height: Math.min(Math.max(400, panel.implicitHeight), parent.height * 0.9)
|
||||
radius: theme.radiusLg
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
// NO clip: the dropdown legitimately overflows the card bottom.
|
||||
|
||||
// Swallow clicks so they never reach the scrim; doubles as
|
||||
// "a click inside the card closes the list" (Tauri parity).
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.dropdownOpen = false
|
||||
}
|
||||
|
||||
Column {
|
||||
id: panel
|
||||
width: parent.width
|
||||
|
||||
// --- Header -------------------------------------------
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 68
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.right: closeX.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Add to Playlist", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Item {
|
||||
id: closeX
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "x"
|
||||
width: 17
|
||||
height: 17
|
||||
tintName: closeArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: closeArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: QbzPlaylistPicker.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { width: parent.width; height: 1; color: theme.borderSubtle }
|
||||
|
||||
// --- Body ---------------------------------------------
|
||||
Column {
|
||||
id: body
|
||||
width: parent.width
|
||||
padding: 24
|
||||
spacing: 16
|
||||
|
||||
// Loading — the playlists are still on the wire.
|
||||
Item {
|
||||
width: parent.width - 48
|
||||
height: visible ? 30 : 0
|
||||
visible: root.doc.loading === true
|
||||
QbzSpinner {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
size: 30
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - 48
|
||||
spacing: 8
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: 20
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Choose playlist", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
// Two msgids, not one with an inserted word: the
|
||||
// .slint counter switches the whole string on
|
||||
// `local-mode` so every locale can order it its
|
||||
// own way.
|
||||
Text {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: (root.localMode
|
||||
? QbzSession.tr("Adding {} local track(s)", QbzSession.trRev)
|
||||
: QbzSession.tr("Adding {} track(s)", QbzSession.trRev))
|
||||
.replace("{}", root.trackCount)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLink
|
||||
}
|
||||
}
|
||||
|
||||
// The search / selection input (43px, the Tauri metric).
|
||||
Rectangle {
|
||||
id: inputBox
|
||||
width: parent.width
|
||||
height: 43
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: searchInput.activeFocus ? theme.accent : theme.borderSubtle
|
||||
|
||||
TextInput {
|
||||
id: searchInput
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 36 // room for the clear chip
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontLink
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
clip: true
|
||||
selectByMouse: true
|
||||
enabled: root.doc.loading !== true
|
||||
text: root.filterText
|
||||
onTextEdited: {
|
||||
root.filterText = text
|
||||
root.dropdownOpen = true // typing re-opens
|
||||
QbzPlaylistPicker.search(text)
|
||||
}
|
||||
onAccepted: root.confirm()
|
||||
// Tauri: the list opens on focus.
|
||||
onActiveFocusChanged: if (activeFocus) root.dropdownOpen = true
|
||||
// Re-seed while not being edited (the
|
||||
// AddToMixtapeModal Binding shape).
|
||||
Binding {
|
||||
target: searchInput
|
||||
property: "text"
|
||||
value: root.filterText
|
||||
when: !searchInput.activeFocus
|
||||
}
|
||||
}
|
||||
// Placeholder, doubling as the SELECTION label —
|
||||
// the filter is cleared on select, so the field is
|
||||
// empty exactly when the label should show.
|
||||
Text {
|
||||
visible: searchInput.text === ""
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 36
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: root.creatingOpen
|
||||
? QbzSession.tr("+ Create new playlist", QbzSession.trRev)
|
||||
: (root.selectedLabel !== ""
|
||||
? root.selectedLabel
|
||||
: QbzSession.tr("Search playlists...", QbzSession.trRev))
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLink
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
// Clear-selection chip — only with a selection (or
|
||||
// the inline-create state) and the list closed.
|
||||
Rectangle {
|
||||
visible: (root.selectedId !== "" || root.creatingOpen)
|
||||
&& !root.dropdownOpen
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 20
|
||||
height: 20
|
||||
radius: 10
|
||||
color: chipArea.containsMouse ? theme.surfaceHover : theme.surfaceElevated
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "x"
|
||||
width: 12
|
||||
height: 12
|
||||
tintName: chipArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: chipArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.selectedId = ""
|
||||
root.selectedLabel = ""
|
||||
root.createName = ""
|
||||
QbzPlaylistPicker.showCreate(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inline create — a second form group BELOW the picker
|
||||
// (Tauri §1.4.6); the footer button confirms it.
|
||||
Column {
|
||||
width: parent.width - 48
|
||||
spacing: 8
|
||||
visible: root.creatingOpen
|
||||
Text {
|
||||
text: QbzSession.tr("Playlist Name", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 43
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: nameInput.activeFocus ? theme.accent : theme.borderSubtle
|
||||
TextInput {
|
||||
id: nameInput
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontLink
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
clip: true
|
||||
selectByMouse: true
|
||||
enabled: !root.creating
|
||||
text: root.createName
|
||||
onTextEdited: root.createName = text
|
||||
onAccepted: root.confirm()
|
||||
Binding {
|
||||
target: nameInput
|
||||
property: "text"
|
||||
value: root.createName
|
||||
when: !nameInput.activeFocus
|
||||
}
|
||||
}
|
||||
Text {
|
||||
visible: nameInput.text === ""
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: QbzSession.tr("My Playlist", QbzSession.trRev)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLink
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Footer, pinned to the card bottom --------------------
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: footerRow.top
|
||||
height: 1
|
||||
color: theme.borderSubtle
|
||||
}
|
||||
Row {
|
||||
id: footerRow
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 24
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 16
|
||||
spacing: 12
|
||||
|
||||
SettingsButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Cancel", QbzSession.trRev)
|
||||
btnHeight: 34
|
||||
minWidth: 0
|
||||
onClicked: QbzPlaylistPicker.close()
|
||||
}
|
||||
// The single accent confirm (ADR-008). Disabled until valid —
|
||||
// this is what replaces Tauri's in-body error box.
|
||||
QbzPrimaryButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
btnHeight: 34
|
||||
label: root.creating
|
||||
? QbzSession.tr("Saving...", QbzSession.trRev)
|
||||
: (root.creatingOpen
|
||||
? QbzSession.tr("Create & Add", QbzSession.trRev)
|
||||
: QbzSession.tr("Add", QbzSession.trRev))
|
||||
btnEnabled: !root.creating
|
||||
&& (root.creatingOpen
|
||||
? root.createName.trim() !== ""
|
||||
: root.selectedId !== "")
|
||||
onClicked: root.confirm()
|
||||
}
|
||||
}
|
||||
|
||||
// --- Dropdown overlay -------------------------------------
|
||||
// Declared LAST inside the card so it paints above the body and
|
||||
// the footer (declaration order IS z-order in QML), and it
|
||||
// legitimately overflows the unclipped card bottom.
|
||||
Rectangle {
|
||||
id: dropdown
|
||||
visible: root.dropdownOpen && root.doc.loading !== true
|
||||
x: 24
|
||||
// Anchored below the input by static arithmetic over fixed
|
||||
// metrics — never an absolute-position binding: header 68 +
|
||||
// 1 divider + 24 body pad + 20 label row + 8 spacing +
|
||||
// 43 input + 4 gap.
|
||||
y: 68 + 1 + 24 + 20 + 8 + 43 + 4
|
||||
width: parent.width - 48
|
||||
// create row 41 + 1 divider, 41 per shown row, 41 no-results,
|
||||
// 1 + 34 overflow. Tauri max-height 320 + border.
|
||||
height: Math.min(2 + 42 + root.shown * 41
|
||||
+ ((root.rows.length === 0 && root.filterText !== "") ? 41 : 0)
|
||||
+ (root.overflow > 0 ? 35 : 0), 322)
|
||||
radius: theme.radiusSm
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
clip: true
|
||||
|
||||
// Keep clicks on the list chrome from reaching the card
|
||||
// swallower, which would close the list under the pointer.
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 1
|
||||
contentWidth: width
|
||||
contentHeight: dropInner.implicitHeight
|
||||
clip: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
Column {
|
||||
id: dropInner
|
||||
width: parent.width
|
||||
|
||||
// "+ Create new playlist" — ALWAYS first, never
|
||||
// filtered out (Tauri parity).
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 41
|
||||
color: createArea.containsMouse ? theme.surfaceHover : "transparent"
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 12
|
||||
anchors.rightMargin: 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: QbzSession.tr("+ Create new playlist", QbzSession.trRev)
|
||||
color: theme.accent
|
||||
font.pixelSize: theme.fontLink
|
||||
font.weight: theme.weightMedium
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
MouseArea {
|
||||
id: createArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.selectedId = ""
|
||||
root.selectedLabel = ""
|
||||
root.filterText = ""
|
||||
QbzPlaylistPicker.search("")
|
||||
QbzPlaylistPicker.showCreate(true)
|
||||
root.dropdownOpen = false
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { width: parent.width; height: 1; color: theme.borderSubtle }
|
||||
|
||||
Repeater {
|
||||
model: root.rows.slice(0, root.windowSize)
|
||||
delegate: Rectangle {
|
||||
required property var modelData
|
||||
width: parent ? parent.width : 0
|
||||
height: 41
|
||||
color: rowArea.containsMouse ? theme.surfaceHover : "transparent"
|
||||
// LOCAL playlists (library.db) keep a small
|
||||
// hard-drive glyph LEADING the name, muted —
|
||||
// PlaylistPickerModal.slint:62-69. It is what
|
||||
// tells a local target apart from a Qobuz one
|
||||
// in a list that mixes both.
|
||||
QbzIcon {
|
||||
id: localGlyph
|
||||
visible: modelData.isLocal === true
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
name: "hard-drive"
|
||||
width: 14
|
||||
height: 14
|
||||
tintName: "muted"
|
||||
}
|
||||
Text {
|
||||
anchors.left: localGlyph.visible ? localGlyph.right : parent.left
|
||||
anchors.leftMargin: localGlyph.visible ? 8 : 12
|
||||
anchors.right: countText.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.name
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontLink
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
id: countText
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.tracksLine || ""
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
}
|
||||
MouseArea {
|
||||
id: rowArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.selectRow(modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: root.rows.length === 0 && root.filterText !== ""
|
||||
width: parent.width
|
||||
height: visible ? 41 : 0
|
||||
text: QbzSession.tr("No playlists found", QbzSession.trRev)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
// Overflow line — the rows past the 8-row window.
|
||||
Rectangle {
|
||||
visible: root.overflow > 0
|
||||
width: parent.width
|
||||
height: visible ? 1 : 0
|
||||
color: theme.borderSubtle
|
||||
}
|
||||
Text {
|
||||
visible: root.overflow > 0
|
||||
width: parent.width
|
||||
height: visible ? 34 : 0
|
||||
text: QbzSession.tr("{} more playlist(s)...", QbzSession.trRev)
|
||||
.replace("{}", root.overflow)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontLegal
|
||||
font.italic: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============= Duplicate-confirm sub-modal ===========================
|
||||
// Opens INSTEAD of adding when the chosen playlist already holds some of
|
||||
// the carried tracks. It replaces the picker rather than stacking on it
|
||||
// (the picker's own state is already parked in Rust).
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
visible: root.dup.open === true
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#bf000000"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: QbzPlaylistPicker.cancelDuplicates()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.centerIn: parent
|
||||
width: Math.min(parent.width - 80, 460)
|
||||
height: dupPanel.implicitHeight
|
||||
radius: theme.radiusLg
|
||||
color: theme.surfaceCard
|
||||
border.width: 1
|
||||
border.color: theme.borderSubtle
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Column {
|
||||
id: dupPanel
|
||||
width: parent.width
|
||||
padding: 24
|
||||
spacing: 16
|
||||
|
||||
Item {
|
||||
width: parent.width - 48
|
||||
height: 28
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.right: dupClose.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Some of these tracks were already added", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightSemibold
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Item {
|
||||
id: dupClose
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 28
|
||||
height: 28
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "x"
|
||||
width: 17
|
||||
height: 17
|
||||
tintName: dupCloseArea.containsMouse ? "textPrimary" : "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: dupCloseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: QbzPlaylistPicker.cancelDuplicates()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width - 48
|
||||
text: QbzSession.tr("This playlist already contains {} of the {} tracks you're adding. Add only the new ones, or add everything including duplicates.", QbzSession.trRev)
|
||||
.replace("{}", root.dup.duplicateCount || 0)
|
||||
.replace("{}", root.trackCount)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: theme.fontLink
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 24
|
||||
spacing: 12
|
||||
SettingsButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.dup.busy === true
|
||||
? QbzSession.tr("Adding...", QbzSession.trRev)
|
||||
: QbzSession.tr("Add all tracks", QbzSession.trRev)
|
||||
btnHeight: 34
|
||||
minWidth: 0
|
||||
enabled: root.dup.busy !== true
|
||||
onClicked: QbzPlaylistPicker.confirmDuplicates(true)
|
||||
}
|
||||
QbzPrimaryButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
btnHeight: 34
|
||||
label: root.dup.busy === true
|
||||
? QbzSession.tr("Adding...", QbzSession.trRev)
|
||||
: QbzSession.tr("Add only new tracks", QbzSession.trRev)
|
||||
btnEnabled: root.dup.busy !== true
|
||||
onClicked: QbzPlaylistPicker.confirmDuplicates(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// PmFolderIcon — the folder icon tile (primitives/PmFolderIcon.slint, 48
|
||||
// lines): a rounded colour square carrying either one of the seven lucide
|
||||
// preset glyphs or a user-picked custom image.
|
||||
//
|
||||
// It lives in qml/controls/, not in qml/views/playlistmanager/, because it is
|
||||
// shared chrome rather than a view part: the three manager consumers today are
|
||||
// the folder card, the folder chip and the tree folder row, and the folder
|
||||
// EDITOR (controls/FolderEditPanel.qml) is the fourth the moment it grows a
|
||||
// live preview tile — the reference's FolderEditModal.slint has none, so the
|
||||
// port draws none either (rule 5: no control the reference does not have). A
|
||||
// view-part directory would make a control import a view (contract D12).
|
||||
//
|
||||
// ── FLAT FIELDS, NOT A FOLDER OBJECT ───────────────────────────────────────
|
||||
// The reference takes one `PmFolderItem` struct. Here the publishers carry
|
||||
// DIFFERENT shapes — `QbzPlaylistManager.foldersJson` entries (§4.1) and
|
||||
// `QbzFolderEdit.editJson` (§4.5, which additionally carries the swatch and
|
||||
// preset constants and the editor's busy flag, and whose `iconColor` is NOT
|
||||
// validity-gated because it is a swatch SEED, not a paint) — so passing "the
|
||||
// folder object" would mean one of them silently handing over the wrong keys.
|
||||
// QML does not report that: a property the target type does not declare is an
|
||||
// ignored line, and a key the object does not carry is `undefined`. The
|
||||
// interface is therefore the six flat fields of contract §2.5 and nothing
|
||||
// else.
|
||||
//
|
||||
// ── THE GLYPH SITS UNDER THE IMAGE, NOT OPPOSITE IT ────────────────────────
|
||||
// The reference pairs `if has-custom-image: Image` with
|
||||
// `if !has-custom-image: QbzIcon`, so a tile whose image fails to decode — or
|
||||
// has not decoded yet — is a bare coloured square. Here the glyph is always
|
||||
// drawn and the image is layered over it: identical once the image loads,
|
||||
// degrades to the preset glyph when it does not (§5.20).
|
||||
//
|
||||
// ── TINT IS "white", DELIBERATELY ──────────────────────────────────────────
|
||||
// A fixed #ffffff, matching the reference's hardcoded tint — NOT
|
||||
// "textPrimary". The host is a saturated, user-chosen colour tile under every
|
||||
// theme, and a theme-following tint would paint a dark glyph on it on the 11
|
||||
// light themes. ("primary" is the legacy alias of "white"; QbzIcon.qml:55-65
|
||||
// says do not add new call sites for it.)
|
||||
//
|
||||
// ── NO `clip: true` ────────────────────────────────────────────────────────
|
||||
// `Rectangle { radius; clip: true }` does NOT round in Qt Quick — `clip` is a
|
||||
// rectangular scissor. The fill Rectangle rounds itself and RoundedImage does
|
||||
// the image's corners with a mask.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
/// Edge length. The root binds BOTH dimensions off it — the reference's
|
||||
/// component does the same, and a sketch that omits it renders 0x0.
|
||||
property int size: 40
|
||||
/// One of the seven ids in §4.5. ANY unknown value renders "folder", which
|
||||
/// is also where the id "folder" itself lands: it is not a case in the
|
||||
/// reference's id -> glyph chain at all and falls through to the default
|
||||
/// arm. Both are upstream intent; both are kept.
|
||||
property string iconPreset: "folder"
|
||||
/// "" means "use the theme accent"; only read when `hasColor` is true.
|
||||
property string iconColor: ""
|
||||
/// False when the stored value was empty, a gradient or a CSS var — the
|
||||
/// validity gate lives in RUST (§5.20), so a stored gradient string can
|
||||
/// never reach `Qt.color()` here.
|
||||
property bool hasColor: false
|
||||
/// `icon_type == "custom" && custom_image_path.is_some()` — BOTH, decided
|
||||
/// in Rust. A stale path is reachable, so this is never derived from the
|
||||
/// path alone.
|
||||
property bool hasCustomImage: false
|
||||
/// A percent-encoded `file://…` URL, "" when there is none. A bare
|
||||
/// `/home/...` string would be resolved against this component's `qrc:`
|
||||
/// base and fail silently (D25).
|
||||
property string customImagePath: ""
|
||||
|
||||
/// Glyph size and corner radius are DERIVED, because §2.5 gives this
|
||||
/// control `size` as its only geometry input. The three reference call
|
||||
/// sites pass 64/32/12 (grid card, PlaylistManagerView.slint:314),
|
||||
/// 36/20/8 (list chip, :397) and 28/15/6 (tree row, :903); the bands below
|
||||
/// reproduce all three exactly and interpolate sanely in between. Both are
|
||||
/// plain properties rather than readonly ones, so a call site that wants
|
||||
/// to pin the reference numbers can just assign them.
|
||||
property int glyphSize: root.size >= 56 ? Math.round(root.size * 0.5)
|
||||
: root.size >= 32 ? Math.round(root.size * 0.556)
|
||||
: Math.round(root.size * 0.536)
|
||||
property int tileRadius: root.size >= 56 ? 12 : root.size >= 32 ? 8 : 6
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
width: root.size
|
||||
height: root.size
|
||||
radius: root.tileRadius
|
||||
color: root.hasColor && root.iconColor !== "" ? root.iconColor : theme.accent
|
||||
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
width: root.glyphSize
|
||||
height: root.glyphSize
|
||||
tintName: "white"
|
||||
name: root.iconPreset === "heart" ? "heart"
|
||||
: root.iconPreset === "star" ? "star"
|
||||
: root.iconPreset === "music" ? "music"
|
||||
: root.iconPreset === "disc" ? "disc"
|
||||
: root.iconPreset === "library" ? "library"
|
||||
// The id/glyph mismatch is upstream intent, not a typo: the preset
|
||||
// persisted as "headphones" has always drawn audio-lines.
|
||||
: root.iconPreset === "headphones" ? "audio-lines"
|
||||
: "folder"
|
||||
}
|
||||
|
||||
RoundedImage {
|
||||
anchors.fill: parent
|
||||
visible: root.hasCustomImage && root.customImagePath !== ""
|
||||
source: (root.hasCustomImage && root.customImagePath !== "")
|
||||
? root.customImagePath : ""
|
||||
radius: root.tileRadius
|
||||
fit: "crop"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// Vertical A-Z jump strip (favorites/FavoritesView.slint:398 `AlphaStrip`;
|
||||
// LocalLibraryView.slint:577 is a 1:1 lift of the same component). 18px
|
||||
// gutter, 15px rows, 9px semibold muted letters that go accent on hover.
|
||||
// Emits jump(ordinal, index); the host scrolls its own view — exactly like
|
||||
// the Slint, which scrolls proportionally on the grouped grids (:1996) and by
|
||||
// row index on the uniform track list (:1687).
|
||||
//
|
||||
// PROMOTED from views/local/AlphaStrip.qml, unchanged except for the import
|
||||
// depth — same move QbzMultiSelectBar made and for the same reason: the Slint
|
||||
// component was always shared (Local Library albums/artists/tracks AND the
|
||||
// Library favorites tabs), so the "local" folder was a naming accident. The
|
||||
// old views/local/AlphaStrip.qml is GONE; this file is the only copy.
|
||||
// Call sites: views/local/{LocalAlbumsTab,LocalArtistsTab,LocalTracksTab}.qml,
|
||||
// views/library/{LibraryAlbumsList}.qml and views/LibraryView.qml.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
/// [{ letter, index }] — index = the row ordinal in the flat model.
|
||||
property var jumps: []
|
||||
signal jump(int ordinal, int index)
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
width: 18
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: 0
|
||||
Repeater {
|
||||
model: root.jumps
|
||||
delegate: Item {
|
||||
id: cell
|
||||
required property var modelData
|
||||
required property int index
|
||||
width: 18
|
||||
height: 15
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
text: cell.modelData.letter
|
||||
color: cellArea.containsMouse ? theme.accent : theme.textMuted
|
||||
font.pixelSize: 9
|
||||
font.weight: theme.weightSemibold
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
MouseArea {
|
||||
id: cellArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.jump(cell.index, cell.modelData.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,15 @@ Popup {
|
||||
|
||||
property int menuWidth: 196
|
||||
default property alias menuContent: col.data
|
||||
/// Row gap inside the panel. Defaults to the Column's own 0 — every
|
||||
/// existing call site is unaffected — and exists because a call site CANNOT
|
||||
/// reach `col`: QML gives a component no access to another file's ids, so
|
||||
/// `col.spacing: 1` inside a `QbzContextMenu { … }` block is a grouped
|
||||
/// assignment against a property the type does not have and fails the WHOLE
|
||||
/// consuming file at load. The Playlist Manager's three menus set 1, which
|
||||
/// is the reference's `spacing: 1px`
|
||||
/// (playlist/PlaylistManagerView.slint:1153, :1197, :816).
|
||||
property alias contentSpacing: col.spacing
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
|
||||
@@ -96,6 +96,19 @@ Rectangle {
|
||||
input.focus = false
|
||||
}
|
||||
|
||||
/// Focus the field from OUTSIDE the control — what a modal needs on open.
|
||||
///
|
||||
/// The deferred Timer below already existed, but it was driven only by
|
||||
/// `onOpenChanged`, and `open` is the EXPANDABLE-SEARCH arm's property;
|
||||
/// the control exposes no alias to its inner TextInput either, so a modal
|
||||
/// had no way in. Setting `open: true` on a plain field happens to work
|
||||
/// (with `expandable: false`, `box.width` is `root.width` regardless of
|
||||
/// `open`, :139) but it repurposes a search-arm property and reads as a
|
||||
/// bug. This is the seam instead. It is deferred for the same reason the
|
||||
/// expandable arm defers: focusing synchronously inside the caller's own
|
||||
/// open transition races it.
|
||||
function focusField() { focusDefer.restart() }
|
||||
|
||||
// Deferred focus — see the header note.
|
||||
onOpenChanged: if (open) focusDefer.restart()
|
||||
Timer {
|
||||
|
||||
@@ -42,6 +42,11 @@ Rectangle {
|
||||
property bool btnEnabled: true
|
||||
property bool destructive: false
|
||||
property int btnHeight: 48
|
||||
/// Label size. The control draws Typography.button (17px), which is right
|
||||
/// for the footer chips it was written for; the folder / playlist modals
|
||||
/// are 15px (Typography.body) in the reference, and hardcoding 17 there
|
||||
/// would be a visible parity break on every one of them.
|
||||
property int labelSize: theme.fontButton
|
||||
signal clicked()
|
||||
|
||||
QbzTheme { id: theme }
|
||||
@@ -67,7 +72,7 @@ Rectangle {
|
||||
width: Math.min(implicitWidth, root.width - 40)
|
||||
text: root.label
|
||||
color: theme.accentGlyphColor
|
||||
font.pixelSize: theme.fontButton
|
||||
font.pixelSize: root.labelSize
|
||||
font.weight: theme.weightSemibold
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
@@ -8,16 +8,35 @@
|
||||
// Arms: `title` (fontSection semibold); `showViewAll` + `viewAllLabel` +
|
||||
// `viewAllAccent` (Search's accent chip vs Home's secondary link) +
|
||||
// viewAllClicked(); `showChevrons` + `leftEnabled`/`rightEnabled` +
|
||||
// pageLeft()/pageRight() (the host owns the page-step math).
|
||||
// pageLeft()/pageRight() (the host owns the page-step math); and, since the
|
||||
// Playlist Manager landed, `collapsible` + `collapsed` + toggled() and
|
||||
// `titleSecondary`.
|
||||
// Deliberately NOT absorbed: ArtistView.ReleaseSection's header (adds a
|
||||
// sort dropdown + "See discography" — distinct arms, still stubs) and the
|
||||
// uppercase 10-11px eyebrow mini-headers (different type scale).
|
||||
//
|
||||
// ── THE `id: root` REFACTOR CAME FIRST, AND IT WAS NOT COSMETIC ───────────
|
||||
// This file used to have no root id: its Text read `text: parent.title` and
|
||||
// three deeper bindings walked `parent.parent…`. Wrapping that Text in the
|
||||
// Row the collapse chevron needs would have changed its `parent` and silently
|
||||
// BLANKED the title on all thirteen existing instantiations
|
||||
// (HomeView.qml:346,537,612,773,1096,1150 · SearchView.qml:526,555,584,690,790
|
||||
// · SectionRail.qml:28 · LabelView.qml:139). Every property read now goes
|
||||
// through `root`, so the tree can be restructured again without that trap.
|
||||
//
|
||||
// The collapse chevron sits IMMEDIATELY RIGHT OF THE TITLE (the Playlist
|
||||
// Manager's `PmSectionHeader`, playlist/PlaylistManagerView.slint:1034-1058),
|
||||
// not in the right-hand Row. `Row` skips invisible children, so with
|
||||
// `collapsible: false` — the default — the thirteen existing sites are
|
||||
// pixel-identical: no width, no spacing, nothing.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property string title: ""
|
||||
property bool showViewAll: false
|
||||
property string viewAllLabel: ""
|
||||
@@ -25,30 +44,69 @@ Item {
|
||||
property bool showChevrons: true
|
||||
property bool leftEnabled: false
|
||||
property bool rightEnabled: false
|
||||
/// Paint the title `text-secondary` instead of `text-primary` — the
|
||||
/// Playlist Manager's two section headers do
|
||||
/// (playlist/PlaylistManagerView.slint:1029).
|
||||
property bool titleSecondary: false
|
||||
/// Render the 22 × 22 collapse chevron right of the title.
|
||||
property bool collapsible: false
|
||||
property bool collapsed: false
|
||||
signal viewAllClicked()
|
||||
signal pageLeft()
|
||||
signal pageRight()
|
||||
signal toggled()
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
width: parent ? parent.width : 0
|
||||
height: 28
|
||||
|
||||
Text {
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: parent.title
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightSemibold
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.title
|
||||
color: root.titleSecondary ? theme.textSecondary : theme.textPrimary
|
||||
font.pixelSize: theme.fontSection
|
||||
font.weight: theme.weightSemibold
|
||||
}
|
||||
// The chevron's 22 × 22 PLATE lights on hover; the glyph itself stays
|
||||
// `text-muted` in every state (`:1040-1049`).
|
||||
Rectangle {
|
||||
visible: root.collapsible
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 22
|
||||
height: 22
|
||||
radius: 4
|
||||
color: chevArea.containsMouse ? theme.surfaceHover : "transparent"
|
||||
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
name: root.collapsed ? "chevron-right" : "chevron-down"
|
||||
width: 14
|
||||
height: 14
|
||||
tintName: "muted"
|
||||
}
|
||||
MouseArea {
|
||||
id: chevArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.toggled()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 4
|
||||
// "View all" link/chip (accent = Search's, secondary = Home's).
|
||||
Rectangle {
|
||||
visible: parent.parent.showViewAll
|
||||
visible: root.showViewAll
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: vaText.implicitWidth + 16
|
||||
height: 26
|
||||
@@ -57,10 +115,10 @@ Item {
|
||||
Text {
|
||||
id: vaText
|
||||
anchors.centerIn: parent
|
||||
text: parent.parent.parent.viewAllLabel !== ""
|
||||
? parent.parent.parent.viewAllLabel
|
||||
text: root.viewAllLabel !== ""
|
||||
? root.viewAllLabel
|
||||
: QbzSession.tr("View all →", QbzSession.trRev)
|
||||
color: parent.parent.parent.viewAllAccent ? theme.accent
|
||||
color: root.viewAllAccent ? theme.accent
|
||||
: vaArea.containsMouse ? theme.textPrimary : theme.textSecondary
|
||||
font.pixelSize: 14
|
||||
font.weight: theme.weightMedium
|
||||
@@ -70,7 +128,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: parent.parent.parent.viewAllClicked()
|
||||
onClicked: root.viewAllClicked()
|
||||
}
|
||||
}
|
||||
// `ambient: true` on BOTH: these two are the carousel page chevrons,
|
||||
@@ -89,19 +147,22 @@ Item {
|
||||
// section header on OPAQUE chrome would need the arm off — there is
|
||||
// no such host today, and adding one means adding the property then,
|
||||
// not carrying a dead knob now.
|
||||
//
|
||||
// The Playlist Manager's two headers are the first consumers that are
|
||||
// NOT carousels, and they say so with `showChevrons: false`.
|
||||
QbzNavButton {
|
||||
visible: parent.parent.showChevrons
|
||||
visible: root.showChevrons
|
||||
name: "chevron-left"
|
||||
ambient: true
|
||||
btnEnabled: parent.parent.leftEnabled
|
||||
onClicked: parent.parent.pageLeft()
|
||||
btnEnabled: root.leftEnabled
|
||||
onClicked: root.pageLeft()
|
||||
}
|
||||
QbzNavButton {
|
||||
visible: parent.parent.showChevrons
|
||||
visible: root.showChevrons
|
||||
name: "chevron-right"
|
||||
ambient: true
|
||||
btnEnabled: parent.parent.rightEnabled
|
||||
onClicked: parent.parent.pageRight()
|
||||
btnEnabled: root.rightEnabled
|
||||
onClicked: root.pageRight()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,33 +37,54 @@ Rectangle {
|
||||
property bool active: false
|
||||
/// Active = accent FILL (labelled buttons) vs accent BORDER (icon-only).
|
||||
property bool fillActive: false
|
||||
/// THE SECOND SCALE — the Playlist Manager toolbar's `PmToolButton` /
|
||||
/// `PmIconButton` (playlist/PlaylistManagerView.slint:162-230), which is the
|
||||
/// same control 4 px taller with more air. The port's established idiom for
|
||||
/// a second size on one control (`QbzLineEdit.sm`, `QbzSelect.sm`,
|
||||
/// `QbzToggleButton.sm`), rather than a 90 %-identical fork.
|
||||
///
|
||||
/// Under `large`: height 34, padH 11 (the reference's `row { x: 11 }` and
|
||||
/// `width: row.preferred-width + 22`), row spacing 7, label 13, NO border
|
||||
/// (except the accent-border arm, which the PM never uses), and an
|
||||
/// icon-only button is a 34 × 34 square with a 16 px glyph — the 15 → 16
|
||||
/// delta between the labelled and icon-only forms IS the reference
|
||||
/// (`:180-184` vs `:216-222`); do not unify it.
|
||||
///
|
||||
/// The idle GLYPH tint also changes, and it is the largest of the deltas:
|
||||
/// this control tints idle glyphs `muted` (#888888) where the reference
|
||||
/// paints `Theme.text-secondary` (#cccccc) on five of its six toolbar
|
||||
/// controls. Defaults are untouched, so the MyQBZ toolbars cannot regress.
|
||||
property bool large: false
|
||||
signal clicked()
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
readonly property bool filled: root.active && root.fillActive
|
||||
readonly property int padH: root.label === "" ? 8 : 10
|
||||
readonly property bool iconOnly: root.label === ""
|
||||
readonly property int padH: root.large ? 11 : (root.iconOnly ? 8 : 10)
|
||||
|
||||
height: 30
|
||||
implicitWidth: 2 * root.padH + row.implicitWidth
|
||||
height: root.large ? 34 : 30
|
||||
implicitWidth: (root.large && root.iconOnly)
|
||||
? 34
|
||||
: 2 * root.padH + row.implicitWidth
|
||||
radius: 6
|
||||
color: root.filled ? theme.accent
|
||||
: (toolArea.containsMouse ? theme.surfaceHover : theme.surfaceElevated)
|
||||
border.width: 1
|
||||
border.width: (root.large && !(root.active && !root.fillActive)) ? 0 : 1
|
||||
border.color: (root.active && !root.fillActive) ? theme.accent : theme.borderSubtle
|
||||
|
||||
Row {
|
||||
id: row
|
||||
anchors.centerIn: parent
|
||||
spacing: 6
|
||||
spacing: root.large ? 7 : 6
|
||||
|
||||
QbzIcon {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
name: root.name
|
||||
width: 15
|
||||
height: 15
|
||||
width: (root.large && root.iconOnly) ? 16 : 15
|
||||
height: (root.large && root.iconOnly) ? 16 : 15
|
||||
tintName: root.filled ? theme.accentGlyphTint
|
||||
: (root.active ? "textPrimary" : "muted")
|
||||
: (root.active ? "textPrimary" : (root.large ? "secondary" : "muted"))
|
||||
}
|
||||
Text {
|
||||
visible: root.label !== ""
|
||||
@@ -71,7 +92,7 @@ Rectangle {
|
||||
text: root.label
|
||||
color: root.filled ? theme.accentGlyphColor
|
||||
: (root.active ? theme.textPrimary : theme.textSecondary)
|
||||
font.pixelSize: 12
|
||||
font.pixelSize: root.large ? 13 : 12
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
Rectangle {
|
||||
|
||||
Reference in new issue
Block a user