feat(qt): port the My QBZ domain — mixtapes, collections and the discography builder

The Slint reference is 3,885 lines of .slint across ten files plus 5,514 lines
of Rust glue over the shared qbz-mixtape crate. None of it existed in the Qt
port; the nav flyout carried a "GAP:" comment and two disabled entries.

Rust (flat in src/, per QTBUG-93443): three bridges rather than one God-object
— QbzMyQbz (grids + detail + edit + cover + mix), QbzMyQbzAdd (the app-wide
picker, kept apart so TrackRow, PlayerBar and the Local Library bulk bars
cannot couple to detail state) and QbzDisco (artist-scoped, reached from the
artist page, never coexisting with the MyQBZ views). Twelve controllers behind
them, ported function by function from myqbz{,_detail,_play,_edit,_cover,_mix,
_add,_prefs,_view_prefs,_builder}.rs. src/toast_qt.rs finally gives the port a
toast host.

QML in qml/views/myqbz/ plus four global overlays. Reused rather than forked:
TrackRow, TrackListHeader, QualityBadgeFull, QbzContextMenu, CardMenu,
QbzCheckbox, QbzSkeleton, QbzScrollBar, RoundedImage. LocalSegToggle and
LocalMultiSelectBar are PROMOTED to controls/QbzSegToggle and
controls/QbzMultiSelectBar (they were ports of shared Slint primitives that
MyQBZ needs too) — a move plus an import fix, with the Local metrics kept as
the defaults so the four Local Library toggles are byte-unchanged and the MyQBZ
call sites pass ViewToggle's own numbers.

Every list is windowed at write time: GridView/ListView with reuseItems and a
cacheBuffer, and expanded mode is an outer recycled ListView whose delegate is
a Column + Repeater, because a nested ListView inside a recycled delegate
cannot size itself. Single-row updates patch in place; replacing the array
resets contentY and throws the user to the top.

Shared controls gained the arms the new views need, with the numbers taken from
the .slint and not guessed: SettingsButton (btnHeight / minWidth /
trailingIconName), QbzEmptyState's four metrics, QbzSelect's `sm` variant
(30px, r6, no outline, 12px label, 14px chevron, 40px narrower —
QbzSelect.slint:74-148), QbzContextMenu.openBelowLeft, and QbzLineEdit gains a
distinct `accepted` signal fired on ENTER ONLY: a modal that submits on
`committed` submits TWICE, because closing it removes focus and fires
`committed` again — a rename would have run twice and a create made two
collections. clearSearch() no longer assigns root.text either; that JS write
destroyed the call site's binding permanently, so Rust could never re-seed the
field after one click on the X.

SourceIcon gained the plain "qobuz" arm it was missing, which had every Qobuz
row in a collection drawing itself as a local file.

Two icons (turntable, image) are baked from the Slint masters into the seven
full tint dirs and registered in MASTERS; three more (circle-check-big,
circle-alert, triangle-alert) back the toast. A missing tint dir or glyph
renders nothing and logs nothing, so this class never surfaces in a build.

cc
This commit is contained in:
vicrodh committed 2026-07-29 21:23:45 -06:00
1 parent d4667f5ea9
commit acf23abc9b
107 files changed
+14608 -226

No files matched your search

@@ -0,0 +1,620 @@
// AddToMixtapeModal — the app-wide "Add to Mixtape/Collection" picker
// (myqbz/AddToMixtapeModal.slint, 553 lines). A GLOBAL singleton mounted ONCE
// in AppShell.qml (Slint mounts it the same way at AppShell.slint:824) and
// self-gated on its own document's `open` flag, so every caller only has to
// invoke `QbzMyQbzAdd.open(itemsJson)`.
//
// It carries its OWN backdrop and card — NOT the shared modal chrome (:5) —
// and TWO mutually exclusive body panels: the PICKER (search row + collection
// list + the two create chips) and the CREATE-NEW panel (name + kind +
// footer).
//
// Chrome (:209-231): scrim `#00000099` that closes on click, card
// `min(width - 80, 480) x min(height - 120, 560)` centred, r12 surface-card,
// 1px border-subtle, and a click-swallowing area over the card so a press
// inside it never reaches the scrim. The scrim carries `radius:
// theme.radiusMd` for the reason controls/DiscoverConfigModal.qml:59-75 spells
// out: QML `clip` is a rectangular scissor, so an opaque full-bleed child
// paints into the shell frame's four bezel corners and the panel reads square.
// The .slint's `drop-shadow-blur: 32px` is dropped — shadows render nothing on
// this port's software path; the 1px border carries the separation.
//
// The header's title/subtitle are PRECOMPUTED IN RUST (single item ->
// title+subtitle; bulk -> "{count} items" + "{first} + N more"), so this file
// never inspects the pending items.
//
// The name typed into the create panel is QML-LOCAL: the bridge takes it as an
// argument (`createAndAdd(kind, name)`) and has no name property. Same for the
// create KIND, which the two radios flip locally over the doc's value — there
// is no `setCreateKind` invokable, and re-calling `showCreate` for a radio tap
// would be a round trip for a value the submit call already carries.
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 and takes the whole overlay down (PlaylistView.qml:55-61).
readonly property var doc: {
try {
return JSON.parse(QbzMyQbzAdd.addJson)
} catch (e) {
return ({})
}
}
readonly property bool opened: root.doc.open === true
readonly property bool loading: root.doc.loading === true
readonly property bool creating: root.doc.creating === true
readonly property bool createBusy: root.doc.createBusy === true
readonly property bool restrictToMixtape: root.doc.restrictToMixtape === true
readonly property string busyId: root.doc.busyId || ""
readonly property string search: root.doc.search || ""
readonly property var rows: root.doc.rows || []
// Local create-panel state (see the header).
property string createName: ""
property string createKindOverride: ""
readonly property string docCreateKind: root.doc.createKind || "mixtape"
readonly property string createKind: root.createKindOverride !== ""
? root.createKindOverride : root.docCreateKind
readonly property bool createMixtape: root.createKind === "mixtape"
// :207 — the raw non-empty check, exactly as Slint gates it (Rust trims).
readonly property bool canCreate: root.createName !== "" && !root.createBusy
// A fresh panel starts empty and follows the kind Rust was asked for; a
// closed modal must not keep a half-typed name for the next caller.
onDocCreateKindChanged: root.createKindOverride = ""
onCreatingChanged: if (root.creating) root.createName = ""
onOpenedChanged: if (!root.opened) { root.createName = ""; root.createKindOverride = "" }
visible: root.opened
enabled: root.opened
// --- Scrim. Declared FIRST so the card (later in source order, hence
// above it) keeps its own presses.
Rectangle {
anchors.fill: parent
radius: theme.radiusMd
color: "#99000000"
MouseArea {
anchors.fill: parent
onClicked: QbzMyQbzAdd.close()
}
}
Rectangle {
id: card
width: Math.min(root.width - 80, 480)
height: Math.min(root.height - 120, 560)
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
clip: true
// Swallow clicks so they never reach the scrim.
MouseArea { anchors.fill: parent }
// ======================= HEADER (always) ======================
Item {
id: header
width: parent.width
// :235 — the row's own height plus 20 top + 16 bottom.
height: Math.max(hdrText.implicitHeight, 28) + 36
Column {
id: hdrText
x: 20
y: 20
width: Math.max(0, card.width - 40 - 28)
spacing: 2
Text {
text: root.t("ADD TO MIXTAPE/COLLECTION")
color: theme.textMuted
font.pixelSize: 10
font.weight: theme.weightSemibold
font.letterSpacing: 1.5
}
Text {
width: parent.width
text: root.doc.headerTitle || ""
color: theme.textPrimary
font.pixelSize: theme.fontSection
font.weight: theme.weightBold
elide: Text.ElideRight
}
Text {
visible: (root.doc.headerSubtitle || "") !== ""
width: parent.width
text: root.doc.headerSubtitle || ""
color: theme.textMuted
font.pixelSize: theme.fontLegal
elide: Text.ElideRight
}
}
Item {
x: card.width - 20 - 28
y: 20
width: 28
height: 28
QbzIcon {
anchors.centerIn: parent
name: "x"
width: 17
height: 17
tintName: hdrCloseArea.containsMouse ? "textPrimary" : "muted"
}
MouseArea {
id: hdrCloseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: QbzMyQbzAdd.close()
}
}
// Bottom border on the block's LAST pixel (:285-289).
Rectangle {
y: parent.height - 1
width: parent.width
height: 1
color: theme.borderSubtle
}
}
// ======================== PICKER PANEL ========================
Item {
id: picker
visible: !root.creating
anchors.top: header.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
// --- Search row (:295-361). The leading glyph sits OUTSIDE the
// box, which is unique to this modal — QbzLineEdit puts its
// magnifier inside — so the box is inlined here rather than
// forking the shared control.
Item {
id: searchRow
width: parent.width
height: 46
QbzIcon {
x: 20
anchors.verticalCenter: searchBox.verticalCenter
name: "search"
width: 14
height: 14
tintName: "muted"
}
Rectangle {
id: searchBox
x: 20 + 14 + 8
width: Math.max(0, parent.width - x - 20)
height: 43
y: Math.round((parent.height - height) / 2)
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: 12
color: theme.textPrimary
font.pixelSize: theme.fontLink
verticalAlignment: Text.AlignVCenter
clip: true
selectByMouse: true
text: root.search
onTextEdited: QbzMyQbzAdd.search(text)
// A republish re-seeds the field while it is not being
// edited (QbzLineEdit.qml:167-172).
Binding {
target: searchInput
property: "text"
value: root.search
when: !searchInput.activeFocus
}
}
Text {
visible: searchInput.text === ""
anchors.fill: searchInput
text: root.t("Search…")
color: theme.textMuted
font.pixelSize: theme.fontLink
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
Rectangle {
y: parent.height - 1
width: parent.width
height: 1
color: theme.borderSubtle
}
}
// --- Footer: the two create chips (:403-432). 60px, elevated, a
// 1px rule at its TOP (:406-409 puts it at y=0), padding 12.
Rectangle {
id: pickerFooter
anchors.bottom: parent.bottom
width: parent.width
height: 60
color: theme.surfaceElevated
Rectangle {
width: parent.width
height: 1
color: theme.borderSubtle
}
Row {
anchors.fill: parent
anchors.margins: 12
spacing: 8
// Both chips carry `horizontal-stretch: 1`, so one fills
// the row and two split it.
readonly property int chips: root.restrictToMixtape ? 1 : 2
readonly property real chipW: (width - (chips - 1) * 8) / chips
FooterIconButton {
anchors.verticalCenter: parent.verticalCenter
width: parent.chipW
label: root.t("Mixtapes")
onClicked: QbzMyQbzAdd.showCreate("mixtape")
}
FooterIconButton {
// Hidden for track/playlist payloads: collections hold
// whole albums only (:423).
anchors.verticalCenter: parent.verticalCenter
visible: !root.restrictToMixtape
width: visible ? parent.chipW : 0
label: root.t("Collections")
onClicked: QbzMyQbzAdd.showCreate("collection")
}
}
}
// --- Between the two: spinner / empty band / the list.
Item {
anchors.top: searchRow.bottom
anchors.bottom: pickerFooter.top
width: parent.width
// Loading (:364-368): centred, 24px padding, 30px spinner.
QbzSpinner {
visible: root.loading
anchors.horizontalCenter: parent.horizontalCenter
y: 24
size: 30
}
// Empty (:370-381).
Text {
visible: !root.loading && root.rows.length === 0
width: parent.width
height: 80
text: root.search !== "" ? root.t("No matches.")
: root.t("No mixtapes or collections yet.")
color: theme.textMuted
font.pixelSize: theme.fontBody
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
// List (:384-400).
ListView {
id: pickList
visible: !root.loading && root.rows.length > 0
anchors.fill: parent
// The .slint's `padding: 8` on the list layout. The
// horizontal half is on the DELEGATE, not as a Flickable
// margin: a vertical ListView's leftMargin moves the
// content origin, it does not inset the rows.
topMargin: 8
bottomMargin: 8
spacing: 2
cacheBuffer: 200
reuseItems: true
clip: true
boundsBehavior: Flickable.StopAtBounds
model: root.rows
delegate: AddPickRow {
required property var modelData
required property int index
x: 8
width: Math.max(0, pickList.width - 16)
rowData: modelData
rowIndex: index
}
}
}
}
// ====================== CREATE-NEW PANEL ======================
Item {
visible: root.creating
anchors.top: header.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Column {
id: createTop
x: 20
y: 20
width: Math.max(0, parent.width - 40)
spacing: 16
// --- NAME
Column {
width: parent.width
spacing: 8
Text {
text: root.t("NAME")
color: theme.textMuted
font.pixelSize: theme.fontLegal
font.weight: theme.weightSemibold
font.letterSpacing: 1.5
}
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
enabled: !root.createBusy
color: theme.textPrimary
font.pixelSize: theme.fontLink
verticalAlignment: Text.AlignVCenter
clip: true
selectByMouse: true
onTextEdited: root.createName = text
onAccepted: {
if (root.canCreate)
QbzMyQbzAdd.createAndAdd(root.createKind, root.createName)
}
Binding {
target: nameInput
property: "text"
value: root.createName
when: !nameInput.activeFocus
}
}
Text {
visible: nameInput.text === ""
anchors.fill: nameInput
// NOT translated — verbatim literals in the .slint
// (:482).
text: root.createMixtape ? "90s Cassettes" : "Jazz Library"
color: theme.textMuted
font.pixelSize: theme.fontLink
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
// --- KIND (16px between the radios here; the Create modal
// uses 12 — CreateMyQbzModal.slint:150).
Column {
width: parent.width
spacing: 8
Text {
text: root.t("KIND")
color: theme.textMuted
font.pixelSize: theme.fontLegal
font.weight: theme.weightSemibold
font.letterSpacing: 1.5
}
Row {
spacing: 16
QbzRadioOption {
label: root.t("Mixtapes")
selected: root.createMixtape
onClicked: if (!root.createBusy) root.createKindOverride = "mixtape"
}
QbzRadioOption {
label: root.t("Collections")
selected: !root.createMixtape
onClicked: if (!root.createBusy) root.createKindOverride = "collection"
}
}
}
}
// Footer, pushed to the bottom by the .slint's vertical stretch
// spacer (:526).
Row {
anchors.right: parent.right
anchors.rightMargin: 20
anchors.bottom: parent.bottom
anchors.bottomMargin: 20
spacing: 8
SettingsButton {
anchors.verticalCenter: parent.verticalCenter
text: root.t("Back")
btnHeight: 38
minWidth: 0
enabled: !root.createBusy
onClicked: QbzMyQbzAdd.createBack()
}
QbzPrimaryButton {
anchors.verticalCenter: parent.verticalCenter
label: root.t("Create & Add")
btnHeight: 38
btnEnabled: root.canCreate
onClicked: QbzMyQbzAdd.createAndAdd(root.createKind, root.createName)
}
}
}
}
// One collection row in the picker list (:63-158). 52px, r8, zebra on ODD
// indices, dimmed and inert while ANOTHER row is being written to.
component AddPickRow: Rectangle {
id: pickRow
// NOT `data`: Item already owns a `data` default property.
property var rowData: ({})
property int rowIndex: 0
readonly property bool busy: root.busyId !== ""
height: 52
radius: 8
opacity: pickRow.busy ? 0.5 : 1.0
// TrackRow.qml:200-206's exact pair: the hover is the polarity-baked
// alpha ramp (so it is visible on light themes too) with the
// pre-publish fallback, and the zebra stays the dark literal.
color: (pickHover.containsMouse && !pickRow.busy)
? (theme.alphaTiers.length > 0 ? theme.alphaTier(8)
: (theme.isDark ? "#14ffffff" : "#14000000"))
: (pickRow.rowIndex % 2 === 1 ? "#07ffffff" : "transparent")
MouseArea {
id: pickHover
anchors.fill: parent
hoverEnabled: true
cursorShape: pickRow.busy ? Qt.ArrowCursor : Qt.PointingHandCursor
onClicked: if (!pickRow.busy) QbzMyQbzAdd.pick(pickRow.rowData.id)
}
Row {
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 12
spacing: 12
Item {
anchors.verticalCenter: parent.verticalCenter
width: 32
height: 32
QbzIcon {
anchors.centerIn: parent
// Rust resolves the name (myqbz_add.rs:203-209).
name: pickRow.rowData.icon === "user" ? "user"
: pickRow.rowData.icon === "library-big" ? "library-big"
: "cassette-tape"
width: 18
height: 18
tintName: "muted"
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
width: Math.max(0, parent.width - 32 - 12 - kindTag.width - 12)
Text {
width: parent.width
text: pickRow.rowData.name || ""
color: theme.textPrimary
font.pixelSize: theme.fontBody
font.weight: theme.weightSemibold
elide: Text.ElideRight
}
Row {
spacing: 6
Text {
anchors.verticalCenter: parent.verticalCenter
text: pickRow.rowData.meta || ""
color: theme.textMuted
font.pixelSize: theme.fontLegal
verticalAlignment: Text.AlignVCenter
}
// "Already added" — the collection already holds EVERY
// pending item (Rust's item_exists pass).
Row {
visible: pickRow.rowData.alreadyHas === true
anchors.verticalCenter: parent.verticalCenter
spacing: 3
QbzIcon {
anchors.verticalCenter: parent.verticalCenter
name: "circle-check-big"
width: 12
height: 12
tintName: "accent"
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.t("Already added")
color: theme.accent
font.pixelSize: theme.fontLegal
verticalAlignment: Text.AlignVCenter
}
}
}
}
Text {
id: kindTag
anchors.verticalCenter: parent.verticalCenter
text: pickRow.rowData.kindLabel || ""
color: theme.textMuted
font.pixelSize: 11
font.weight: theme.weightSemibold
font.letterSpacing: 1.2
}
}
}
// The "+ Mixtapes" / "+ Collections" footer chips (:164-201): a 38px
// labelled icon button with a CENTRED [glyph · gap · label] group. Neither
// SettingsButton (34px, 160 min width) nor QbzToolButton (30px) is this
// shape, and both call sites are in this file, so it stays local.
component FooterIconButton: Rectangle {
id: chip
property string label: ""
signal clicked()
height: 38
radius: theme.radiusSm
color: chipArea.containsMouse ? theme.surfaceHover : theme.surfaceElevated
border.width: 1
border.color: theme.borderSubtle
Row {
anchors.centerIn: parent
spacing: 6
QbzIcon {
anchors.verticalCenter: parent.verticalCenter
name: "plus"
width: 14
height: 14
tintName: "textPrimary"
}
Text {
anchors.verticalCenter: parent.verticalCenter
// The leading `+` is the GLYPH above, not part of the msgid.
text: chip.label
color: theme.textPrimary
font.pixelSize: theme.fontBody
font.weight: theme.weightSemibold
verticalAlignment: Text.AlignVCenter
}
}
MouseArea {
id: chipArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: chip.clicked()
}
}
}
+516
View File
@@ -0,0 +1,516 @@
// MyQbzModals — the THREE small MyQBZ modals in one file, as three sibling
// panels: Create (myqbz/CreateMyQbzModal.slint, 199 lines), Edit
// (MyQbzEditModal.slint, 147) and Mix (MyQbzMixModal.slint, 184). Slint keeps
// them apart only because each has its own global; they share the chrome
// byte-for-byte (`#bf000000` backdrop that closes on click, a centred
// surface-card panel with a 1px border-subtle border and 24px padding, a
// right-aligned footer of one secondary + one primary button) and they are
// mutually exclusive in practice.
//
// A GLOBAL overlay: AppShell.qml mounts it once and each panel self-gates on
// its OWN document's `open` flag (`QbzMyQbz.createJson` / `editJson` /
// `mixJson`) — the same shape as Slint's four bare instantiations at
// AppShell.slint:814-824.
//
// Per-panel numbers that are NOT shared, and every one of them is deliberate:
// * width 420 / 420 / 440 (Create / Edit / Mix);
// * spacing 16 / 16 / 18;
// * title `Typography.heading` = 19 in Create, but a LITERAL 18 in Edit
// (MyQbzEditModal.slint:70) and Mix (MyQbzMixModal.slint:80);
// * a 28x28 close X in Create — Edit and Mix have NONE;
// * footer spacing 8 / 8 / 12 (MyQbzMixModal.slint:159).
//
// Drop shadows (`drop-shadow-blur: 32px` on all three) are dropped: shadows
// render nothing on this port's software path. The scrims carry `radius:
// theme.radiusMd` so an opaque full-bleed child cannot paint into the shell
// frame's bezel corners (controls/DiscoverConfigModal.qml:59-75).
//
// TEXT STATE IS QML-LOCAL. `MyQbzCreateState.name` and
// `MyQbzEditState.draft-name` / `draft-description` are NOT bridge members:
// every submit invokable takes the value as an argument (`createSubmit(name)`,
// `editSubmitRename(name)`, `editSubmitDescription(description)`). The drafts
// are seeded from the document when a panel opens and cleared when it closes.
//
// ENTER submits through `QbzLineEdit`'s `accepted` signal, NEVER `committed`:
// `committed` also fires on focus-out (QbzLineEdit.qml:155), and a blur must
// not create or rename anything.
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(QbzMyQbz.createJson) } catch (e) { return ({}) }
}
readonly property var editDoc: {
try { return JSON.parse(QbzMyQbz.editJson) } catch (e) { return ({}) }
}
readonly property var mixDoc: {
try { return JSON.parse(QbzMyQbz.mixJson) } catch (e) { return ({}) }
}
readonly property bool createOpen: root.createDoc.open === true
readonly property bool editOpen: root.editDoc.open === true
readonly property bool mixOpen: root.mixDoc.open === true
visible: root.createOpen || root.editOpen || root.mixOpen
enabled: root.visible
// ================================================================
// PANEL 1 — Create Mixtape / Collection (CreateMyQbzModal.slint)
// ================================================================
Item {
id: createPanel
anchors.fill: parent
visible: root.createOpen
readonly property string kind: root.createDoc.kind || "mixtape"
readonly property bool isMixtape: createPanel.kind === "mixtape"
readonly property bool creating: root.createDoc.creating === true
property string name: ""
readonly property bool canCreate: createPanel.name !== "" && !createPanel.creating
// A fresh open starts with an empty field.
Connections {
target: root
function onCreateOpenChanged() { createPanel.name = "" }
}
Rectangle {
anchors.fill: parent
radius: theme.radiusMd
color: "#bf000000"
MouseArea {
anchors.fill: parent
onClicked: QbzMyQbz.createClose()
}
}
Rectangle {
width: Math.min(root.width - 80, 420)
height: createCol.implicitHeight + 48
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: createCol
x: 24
y: 24
width: parent.width - 48
spacing: 16
// --- Title + close
Item {
width: parent.width
height: 28
Text {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: Math.max(0, parent.width - 28)
text: createPanel.isMixtape ? root.t("Create Mixtape")
: root.t("Create Collection")
color: theme.textPrimary
font.pixelSize: theme.fontHeading
font.weight: theme.weightBold
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Item {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
width: 28
height: 28
QbzIcon {
anchors.centerIn: parent
name: "x"
width: 17
height: 17
tintName: createCloseArea.containsMouse ? "textPrimary" : "muted"
}
MouseArea {
id: createCloseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: QbzMyQbz.createClose()
}
}
}
// --- NAME
Column {
width: parent.width
spacing: 8
Text {
text: root.t("NAME")
color: theme.textMuted
font.pixelSize: theme.fontLegal
font.weight: theme.weightSemibold
font.letterSpacing: 1.5
}
QbzLineEdit {
width: parent.width
height: 34
text: createPanel.name
onEdited: function (v) { createPanel.name = v }
onAccepted: function (v) {
if (createPanel.canCreate) QbzMyQbz.createSubmit(createPanel.name)
}
}
}
// --- KIND (12px between the radios here; the Add modal uses
// 16 — AddToMixtapeModal.slint:503).
Column {
width: parent.width
spacing: 8
Text {
text: root.t("KIND")
color: theme.textMuted
font.pixelSize: theme.fontLegal
font.weight: theme.weightSemibold
font.letterSpacing: 1.5
}
Row {
spacing: 12
QbzRadioOption {
label: root.t("Mixtapes")
selected: createPanel.isMixtape
onClicked: if (!createPanel.creating) QbzMyQbz.createSetKind("mixtape")
}
QbzRadioOption {
label: root.t("Collections")
selected: !createPanel.isMixtape
onClicked: if (!createPanel.creating) QbzMyQbz.createSetKind("collection")
}
}
}
// --- Footer
Row {
anchors.right: parent.right
spacing: 8
SettingsButton {
text: root.t("Cancel")
btnHeight: 38
minWidth: 0
onClicked: QbzMyQbz.createClose()
}
QbzPrimaryButton {
label: createPanel.isMixtape ? root.t("+ New Mixtape")
: root.t("+ New Collection")
btnHeight: 38
btnEnabled: createPanel.canCreate
onClicked: QbzMyQbz.createSubmit(createPanel.name)
}
}
}
}
}
// ================================================================
// PANEL 2 — Rename / Edit description / Delete (MyQbzEditModal.slint)
// ================================================================
Item {
id: editPanel
anchors.fill: parent
visible: root.editOpen
readonly property string mode: root.editDoc.mode || ""
readonly property bool isRename: editPanel.mode === "rename"
readonly property bool isDescription: editPanel.mode === "description"
readonly property bool isDelete: editPanel.mode === "delete"
readonly property bool busy: root.editDoc.busy === true
property string draftName: ""
property string draftDescription: ""
// :33-35 — busy blocks everything; rename additionally needs a
// non-empty name (Rust trims again).
readonly property bool canSubmit: editPanel.busy
? false : (editPanel.isRename ? editPanel.draftName !== "" : true)
// Prefill from the document (Rust fills `name` for the rename + the
// delete-confirm interpolation, `description` for the description
// body — myqbz_edit sets the drafts when it opens, which is what this
// reproduces).
//
// Keyed on mode+name, NOT on `open`: Rust may publish a second open
// document for a DIFFERENT collection without an intervening closed
// frame, and then `open` never changes and the prefill would be stale.
// Keying it on the whole document instead would clobber what the user
// is typing every time an unrelated field (`busy`) flips.
readonly property string editKey: editPanel.mode + "|" + (root.editDoc.name || "")
onEditKeyChanged: {
editPanel.draftName = root.editDoc.name || ""
editPanel.draftDescription = root.editDoc.description || ""
}
Rectangle {
anchors.fill: parent
radius: theme.radiusMd
color: "#bf000000"
MouseArea {
anchors.fill: parent
onClicked: QbzMyQbz.editClose()
}
}
Rectangle {
width: Math.min(root.width - 80, 420)
height: editCol.implicitHeight + 48
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: 24
y: 24
width: parent.width - 48
spacing: 16
// --- Title. A LITERAL 18px (:70), NOT fontHeading, and there
// is deliberately no close X in this modal.
Text {
width: parent.width
text: editPanel.isRename ? root.t("Rename")
: editPanel.isDescription ? root.t("Edit description")
: root.t("Delete")
color: theme.textPrimary
font.pixelSize: 18
font.weight: theme.weightBold
elide: Text.ElideRight
}
// --- Body: rename
QbzLineEdit {
visible: editPanel.isRename
width: parent.width
height: visible ? 34 : 0
text: editPanel.draftName
onEdited: function (v) { editPanel.draftName = v }
onAccepted: function (v) {
if (editPanel.canSubmit) QbzMyQbz.editSubmitRename(editPanel.draftName)
}
}
// --- Body: description
QbzTextArea {
visible: editPanel.isDescription
width: parent.width
height: visible ? 96 : 0
wrapMode: TextEdit.WordWrap
text: editPanel.draftDescription
onEdited: function (v) { editPanel.draftDescription = v }
}
// --- Body: delete confirm (:105, DOUBLE quotes around the
// name, interpolated into the msgid's `{}`).
Text {
visible: editPanel.isDelete
width: parent.width
text: root.t("Delete \"{}\"? This cannot be undone.")
.replace("{}", root.editDoc.name || "")
color: theme.textSecondary
font.pixelSize: 14
wrapMode: Text.WordWrap
}
// --- Footer
Row {
anchors.right: parent.right
spacing: 8
SettingsButton {
text: root.t("Cancel")
btnHeight: 38
minWidth: 0
enabled: !editPanel.busy
onClicked: QbzMyQbz.editClose()
}
QbzPrimaryButton {
label: editPanel.isDelete ? root.t("Delete") : root.t("Save")
btnHeight: 38
destructive: editPanel.isDelete
btnEnabled: editPanel.canSubmit
onClicked: {
if (editPanel.isRename)
QbzMyQbz.editSubmitRename(editPanel.draftName)
else if (editPanel.isDescription)
QbzMyQbz.editSubmitDescription(editPanel.draftDescription)
else
QbzMyQbz.editConfirmDelete()
}
}
}
}
}
}
// ================================================================
// PANEL 3 — DJ-mix "Random queue" (MyQbzMixModal.slint)
// ================================================================
Item {
id: mixPanel
anchors.fill: parent
visible: root.mixOpen
readonly property bool loading: root.mixDoc.loading === true
readonly property bool busy: root.mixDoc.busy === true
readonly property var sizeOptions: root.mixDoc.sizeOptions || []
readonly property int selectedIndex: root.mixDoc.selectedIndex || 0
readonly property int selectedSize: root.mixDoc.selectedSize || 0
readonly property bool selectedIsAll: root.mixDoc.selectedIsAll === true
readonly property int uniqueCount: root.mixDoc.uniqueCount || 0
// :35-39
readonly property bool canShuffle: !mixPanel.loading && !mixPanel.busy
&& mixPanel.sizeOptions.length > 0 && mixPanel.selectedSize > 0
// The slider travels over option INDICES, not song counts; a single
// option (only "All (N)") renders a degenerate 0..0 track (:42).
readonly property int sliderMax: Math.max(0, mixPanel.sizeOptions.length - 1)
readonly property string sizeLabel: mixPanel.selectedIsAll
? root.t("All ({})").replace("{}", mixPanel.selectedSize)
: String(mixPanel.selectedSize)
Rectangle {
anchors.fill: parent
radius: theme.radiusMd
color: "#bf000000"
MouseArea {
anchors.fill: parent
onClicked: QbzMyQbz.mixClose()
}
}
Rectangle {
width: Math.min(root.width - 80, 440)
height: mixCol.implicitHeight + 48
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: mixCol
x: 24
y: 24
width: parent.width - 48
spacing: 18
Text {
width: parent.width
text: root.t("Random queue")
color: theme.textPrimary
font.pixelSize: 18
font.weight: theme.weightBold
elide: Text.ElideRight
}
Text {
width: parent.width
text: root.t("Create a random queue with songs from this collection. How many songs do you want?")
color: theme.textSecondary
font.pixelSize: 14
wrapMode: Text.WordWrap
}
// --- Loading (:93-106): left-aligned, 8px spacing.
Row {
visible: mixPanel.loading
height: visible ? 18 : 0
spacing: 8
QbzSpinner {
anchors.verticalCenter: parent.verticalCenter
size: 18
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.t("Loading…")
color: theme.textSecondary
font.pixelSize: 14
verticalAlignment: Text.AlignVCenter
}
}
// --- Size field (:109-154)
Column {
visible: !mixPanel.loading && mixPanel.sizeOptions.length > 0
width: parent.width
spacing: 8
Text {
text: root.t("Number of songs")
color: theme.textPrimary
font.pixelSize: 13
font.weight: theme.weightMedium
}
Row {
width: parent.width
spacing: 12
Text {
id: sizeValue
anchors.verticalCenter: parent.verticalCenter
width: Math.max(64, implicitWidth)
text: mixPanel.sizeLabel
color: theme.accent
font.pixelSize: 15
font.weight: theme.weightSemibold
verticalAlignment: Text.AlignVCenter
}
QbzSlider {
anchors.verticalCenter: parent.verticalCenter
width: Math.max(0, parent.width - sizeValue.width - 12)
minimum: 0
maximum: mixPanel.sliderMax
value: mixPanel.selectedIndex
onChanged: function (v) { QbzMyQbz.mixSetIndex(v) }
}
}
Text {
width: parent.width
text: root.t("{} songs available").replace("{}", mixPanel.uniqueCount)
color: theme.textMuted
font.pixelSize: 12
}
}
// --- Footer: spacing 12 here, NOT 8 (:159).
Row {
anchors.right: parent.right
spacing: 12
SettingsButton {
text: root.t("Cancel")
btnHeight: 38
minWidth: 0
enabled: !mixPanel.busy
onClicked: QbzMyQbz.mixClose()
}
QbzPrimaryButton {
label: root.t("Add to queue")
btnHeight: 38
btnEnabled: mixPanel.canShuffle
onClicked: QbzMyQbz.mixShuffle()
}
}
}
}
}
}
@@ -73,4 +73,14 @@ Popup {
var g = sourceItem.mapToItem(null, sourceItem.width - width, sourceItem.height + 4)
_place(g.x, g.y, sourceItem.Window.window)
}
/// Button menu: below the trigger, LEFT edges aligned. The mirror of
/// openBelowRight, for triggers that sit at the LEFT end of their row (the
/// MyQBZ hero overflow and the Disco builder's per-row type override), where
/// a right-aligned panel would hang off the trigger to the left and, on a
/// narrow window, get clamped by _place into visibly the wrong place.
function openBelowLeft(sourceItem) {
var g = sourceItem.mapToItem(null, 0, sourceItem.height + 4)
_place(g.x, g.y, sourceItem.Window.window)
}
}
+36 -4
View File
@@ -29,7 +29,14 @@ Rectangle {
property string text: ""
property string placeholder: ""
property bool isPassword: false
/// Fired on focus-loss AND on Enter — the "the value settled" signal.
signal committed(string value)
/// Fired on ENTER ONLY. A modal that submits on Enter must NOT listen to
/// `committed`: closing the modal removes focus, which fires `committed`
/// again and submits the same value a second time (a rename would run
/// twice, a create would make two collections). Emitted BEFORE `committed`
/// so a handler that closes the modal wins the race.
signal accepted(string value)
// --- search arm -------------------------------------------------------
/// Leading magnifier + live `edited` + trailing X.
@@ -56,9 +63,31 @@ Rectangle {
height: (searchMode || expandable) ? collapsedSize : 34
color: "transparent"
/// Set by `clearSearch()`, released the moment the CALLER publishes anything
/// into `text`. While it is set, the focus-loss re-seed Binding below is
/// suppressed.
///
/// This is what replaces the `root.text = ""` this function used to do. That
/// assignment was a JS write to a property the call site normally holds a
/// BINDING on (`text: root.doc.search`, `text: root.query`, …), so the first
/// click on the × destroyed the binding PERMANENTLY: Rust could never
/// re-seed the field again, and the re-seed Binding below then wrote the
/// now-frozen "" back into the input on every later focus loss. The X in
/// MyQBZ's grid + detail toolbars, DiscoverBrowse and PlaylistBrowse all
/// rode that. Clearing is now purely local — the input goes empty and
/// `edited("")` tells the owner, which republishes "" through the binding
/// that is still intact.
///
/// The latch is needed because the republish is not synchronous: between the
/// click and Rust's answer `root.text` still holds the OLD query, and a
/// focus loss in that window (expandable's `closeSearch()` drops focus by
/// design) would put it straight back.
property bool _cleared: false
onTextChanged: root._cleared = false
function clearSearch() {
input.text = ""
root.text = ""
root._cleared = true
root.edited("")
}
function closeSearch() {
@@ -151,7 +180,7 @@ Rectangle {
selectByMouse: true
echoMode: root.isPassword ? TextInput.Password : TextInput.Normal
text: root.text
onAccepted: root.committed(text)
onAccepted: { root.accepted(text); root.committed(text) }
onActiveFocusChanged: if (!activeFocus) root.committed(text)
onTextEdited: root.edited(text)
Keys.onEscapePressed: function (event) {
@@ -163,12 +192,15 @@ Rectangle {
}
}
// External republish (e.g. Reset) re-seeds the field while
// it is not being edited.
// it is not being edited. `!_cleared` holds it off for the
// frames between the × and the owner's republish, when
// `root.text` is still the query the user just cleared —
// see `_cleared`.
Binding {
target: input
property: "text"
value: root.text
when: !input.activeFocus
when: !input.activeFocus && !root._cleared
}
}
Text {
@@ -0,0 +1,53 @@
// QbzLoadingDots — the three-dot "still resolving" indicator
// (primitives/LoadingDots.slint). Mounted in the MyQBZ detail row's 160px
// quality cell while the badge has not resolved yet.
//
// A CHEAPER APPROXIMATION, on purpose. Slint runs a per-dot triangle wave off
// `animation-tick()` — phase offsets 0 / 0.18 / 0.36 over 900ms,
// `opacity: 0.25 + 0.55 * tri` (so 0.25 … 0.80, LoadingDots.slint:15-20).
// That is a per-DELEGATE animation, and in a windowed list of hundreds of rows
// it is exactly what the port's perf rule forbids. So the phase comes IN as an
// int 0..2 and the HOST owns one `Timer { interval: 300; repeat: true }` for
// the whole view, gated `<any row resolving> && visible && windowShowing`
// (PlaylistView.qml:156-159 + :173-179 — freeze on not-visible or minimized,
// NEVER on lost focus: a tiling desktop keeps windows visible and unfocused).
//
// The dot row CENTRES itself in whatever host it is given, because the .slint
// component inherits Rectangle and therefore fills its cell and centres its
// layout (:26-35) — it is not left-aligned at x=0.
//
// Slint's optional `label` arm (:36-41) is unused by MyQBZ and not ported.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Item {
id: root
/// 0..2 — which dot is lit. Cycled by ONE Timer in the host view.
property int phase: 0
QbzTheme { id: theme }
implicitWidth: 3 * 8 + 2 * 8
implicitHeight: 8
Row {
anchors.centerIn: parent
spacing: 8
Repeater {
// A STATIC model (3), so the delegates are built once and only
// their opacity binding re-evaluates.
model: 3
delegate: Rectangle {
required property int index
width: 8
height: 8
radius: 4
color: theme.textSecondary
opacity: root.phase === index ? 0.8 : 0.25
}
}
}
}
@@ -0,0 +1,110 @@
// Bulk action bar — the floating "N selected" strip with one icon button per
// bulk action (primitives/MultiSelectBar.slint).
//
// PROMOTED from views/local/LocalMultiSelectBar.qml, unchanged except for the
// import depth. The Slint component it ports was already shared — Local Library
// mounts it for Albums (LocalLibraryView.slint:1239) and Tracks (:1406), and
// the MyQBZ detail page mounts the same primitive (:1253) — so the "Local"
// prefix was a naming accident, not a scoping one. The old
// views/local/LocalMultiSelectBar.qml is GONE — this file is the only copy.
// Call sites: views/local/LocalAlbumsTab.qml, views/local/LocalTracksTab.qml,
// views/myqbz/MyQbzDetailView.qml.
//
// 44px tall, radius 8, surface-elevated: "N selected" on the left, then one
// 34x30 icon button per action — dimmed to 0.4 and disarmed while the action
// needs a selection and there is none, red-bordered when it is a danger
// action. ADR-008: bordered/hover buttons, not pills.
//
// `width` has NO default: every call site anchors or sizes it (the MyQBZ detail
// page uses the .slint's deliberately asymmetric `x: 18` / `width: parent.width
// - 40`). The label Text sizes itself from `parent.width - actionRow.width`, so
// a zero width silently collapses the label rather than the buttons.
//
// The Slint puts the action label in the shared tooltip bubble; the Qt port
// has no tooltip channel into this component, so the label rides Qt's own
// ToolTip. (controls/QbzTooltip.qml is the shell's single hover-tooltip
// overlay, but it is reached by calling showRight()/showAbove() on the
// AppShell instance, which a recycled delegate deep inside a view cannot name.)
import QtQuick
import QtQuick.Controls
import com.blitzfc.qbz
import "../theme"
Rectangle {
id: root
/// [{ id, label, icon, danger, needsSelection }] — `id` is what `action`
/// publishes; `label` is the tooltip text and must arrive ALREADY
/// translated (this component calls no `tr`); `icon` must exist in the
/// "warning", "textPrimary" and "secondary" tint dirs.
property var actions: []
property int selectedCount: 0
signal action(string id)
QbzTheme { id: theme }
height: 44
radius: 8
color: theme.surfaceElevated
Row {
anchors.fill: parent
anchors.leftMargin: 14
anchors.rightMargin: 10
spacing: 6
Text {
width: parent.width - actionRow.width - 6
height: parent.height
text: root.selectedCount + " "
+ QbzSession.tr("selected", QbzSession.trRev)
color: theme.textSecondary
font.pixelSize: theme.fontBody
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Row {
id: actionRow
height: parent.height
spacing: 6
Repeater {
model: root.actions
delegate: Rectangle {
id: btn
required property var modelData
readonly property bool armed: !modelData.needsSelection
|| root.selectedCount > 0
width: 34
height: 30
anchors.verticalCenter: parent.verticalCenter
radius: theme.radiusSm
opacity: armed ? 1.0 : 0.4
color: modelData.danger
? (btnArea.containsMouse ? theme.dangerHover : "transparent")
: (btnArea.containsMouse ? theme.surfaceHover : "transparent")
border.width: modelData.danger ? 1 : 0
border.color: theme.dangerBorder
QbzIcon {
name: btn.modelData.icon
width: 16
height: 16
anchors.centerIn: parent
tintName: btn.modelData.danger ? "warning"
: btnArea.containsMouse ? "textPrimary" : "secondary"
}
MouseArea {
id: btnArea
anchors.fill: parent
hoverEnabled: true
cursorShape: btn.armed ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: if (btn.armed) root.action(btn.modelData.id)
ToolTip.visible: containsMouse
ToolTip.text: btn.modelData.label
ToolTip.delay: 400
}
}
}
}
}
}
@@ -0,0 +1,85 @@
// QbzPrimaryButton — the accent-filled labelled button
// (primitives/QbzPrimaryButton.slint). The port had no such control outside
// LoginScreen.qml's inline copy; MyQBZ has five call sites (the Add modal's
// "Create & Add", Create's "+ New Mixtape/Collection", Edit's Save/Delete,
// Mix's "Add to queue", the builder footer's "Create Collection").
// Promoting LoginScreen's copy onto this file is follow-up debt, not part of
// this migration.
//
// THE API IS `btnEnabled` / `btnHeight`, NOT `enabled` / `height`:
// `enabled` shadows Item.enabled (which also disarms child MouseAreas
// through a different mechanism) and the call sites all pass an explicit
// height — 36 in the builder footer, 38 in all four modals, 48 default
// (QbzPrimaryButton.slint:15).
//
// Numbers, off the .slint: r8 (:16), opacity 0.5 when disabled (:17 — NOT
// the 0.4 SettingsButton uses), accent / accent-hover fill (:24) with a
// 150ms transition (:26), destructive = SOLID danger darkened 15% on hover
// (:22-23) — `Theme.danger-hover` is a translucent tint for danger-BG
// surfaces and would render the button pale (the rationale is spelled out at
// :18-21). Padding 20 per side so `implicitWidth = label + 40` (:31-34);
// label Typography.button (17px) semibold (:36-41).
//
// The label colour is `theme.accentGlyphColor`, not a hardcoded
// `Theme.accent-text`: the owner-approved measured on-accent selector
// (theme/QbzTheme.qml, "ON AN ACCENT FILL"). Do not "restore" #ffffff here.
//
// NOT ported (deliberate, both are port-wide gaps rather than MyQBZ ones):
// the .slint's FocusScope Enter/Space activation and its keyboard focus ring
// (:62-86). This port has no keyboard/shortcut layer at all — the whole tree
// carries two key handlers (QbzLineEdit.qml:157, HeaderBar.qml:551) — so
// wiring one here would be the only focusable button in the app.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Rectangle {
id: root
property string label: ""
/// NOT `enabled` — see the header.
property bool btnEnabled: true
property bool destructive: false
property int btnHeight: 48
signal clicked()
QbzTheme { id: theme }
// Height is pinned; the width follows the label so the button auto-sizes
// as a footer chip, and a call site that wants a full-width button
// assigns `width` (Item.width defaults to implicitWidth).
height: root.btnHeight
implicitWidth: lbl.implicitWidth + 40
radius: theme.radiusSm
opacity: root.btnEnabled ? 1.0 : 0.5
color: root.destructive
? ((btnArea.containsMouse && root.btnEnabled)
? Qt.darker(theme.danger, 1.15) : theme.danger)
: ((btnArea.containsMouse && root.btnEnabled)
? theme.accentHover : theme.accent)
Behavior on color { NumberAnimation { duration: 150 } }
Text {
id: lbl
anchors.centerIn: parent
width: Math.min(implicitWidth, root.width - 40)
text: root.label
color: theme.accentGlyphColor
font.pixelSize: theme.fontButton
font.weight: theme.weightSemibold
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
MouseArea {
id: btnArea
anchors.fill: parent
enabled: root.btnEnabled
hoverEnabled: root.btnEnabled
cursorShape: root.btnEnabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: root.clicked()
}
}
@@ -0,0 +1,70 @@
// QbzRadioOption — one labelled radio row (the `KindRadio` component that
// AddToMixtapeModal.slint:28-60 and CreateMyQbzModal.slint:22-55 declare
// BYTE-IDENTICALLY, once each). The port has no radio control at all, so this
// is the first one; both MyQBZ modals use it and nothing else does yet.
//
// Geometry off the .slint: an 18x18 circle (r9) whose ring is 1.5px
// `text-muted` when unselected and vanishes when selected (the fill takes
// over), holding a 7x7 r3.5 dot; 6px to a `Typography.body` label. The whole
// row is the hit target and shows the pointer cursor (the .slint's root IS a
// TouchArea).
//
// The dot is `theme.accentGlyphColor`, not the .slint's literal `#ffffff`
// (:49 / :44) — the measured on-accent selector (theme/QbzTheme.qml, "ON AN
// ACCENT FILL"), the same divergence views/local/SelectCheck.qml already
// takes for its check glyph.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Item {
id: root
property string label: ""
property bool selected: false
signal clicked()
QbzTheme { id: theme }
implicitWidth: row.implicitWidth
implicitHeight: Math.max(18, lbl.implicitHeight)
Row {
id: row
anchors.verticalCenter: parent.verticalCenter
spacing: 6
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 18
height: 18
radius: 9
border.width: root.selected ? 0 : 1.5
border.color: theme.textMuted
color: root.selected ? theme.accent : "transparent"
Rectangle {
visible: root.selected
anchors.centerIn: parent
width: 7
height: 7
radius: 3.5
color: theme.accentGlyphColor
}
}
Text {
id: lbl
anchors.verticalCenter: parent.verticalCenter
text: root.label
color: theme.textPrimary
font.pixelSize: theme.fontBody
verticalAlignment: Text.AlignVCenter
}
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: root.clicked()
}
}
+132
View File
@@ -0,0 +1,132 @@
// Segmented icon toggle — an N-way "pick one" rendered as icon-only segments
// inside a small rounded well.
//
// PROMOTED from views/local/LocalSegToggle.qml. Its Local geometry survives
// UNCHANGED as the defaults; the cell metrics and the active/hover look are
// now properties so the MyQBZ well can be the reference's other set (see TWO
// METRIC SETS below).
// It was never local-library-specific: Slint has the same widget
// three times over (ViewToggle grid/list at LocalLibraryView.slint:358,
// ModeToggle flat/tree at :384, and MyQbzShared.slint:57-70's list/grid), as
// three separate components only because its ToggleButton cannot take a model.
// Here one `segments` model covers all of them.
//
// Call sites: views/myqbz/MyQbzGridView.qml (2 segments, list/grid),
// views/myqbz/MyQbzDetailView.qml (3 segments, list/grid/expanded, `width: 90`
// — see the sizing note below), views/local/LocalToolbar.qml (3 instances:
// albums grid/list, folders grid/list, folders flat/tree) and
// views/local/LocalFolderDetail.qml (grid/list). The old
// views/local/LocalSegToggle.qml is GONE — this file is the only copy.
//
// SIZING. `width` is a plain assignment, not a binding on the content, so a
// call site with more than two segments MUST widen it: with the DEFAULT metrics
// the segments are a centred Row of 26px cells with 2px gaps, so N segments
// need 28N - 2 px (2 -> 54, fits the 60 default; 3 -> 82, hence the detail
// view's 90). Too narrow does not wrap or elide — `clip: true` silently cuts
// the last segment off, and a segment you cannot see is a segment you cannot
// click.
//
// ── TWO METRIC SETS, AND WHY THE CELL LOOK IS PARAMETERISED ────────────────
// The DEFAULTS below are the Local Library set, unchanged: 26x24 r4 cells with
// 2px gaps (so 3px of dead well on each side), a 14px glyph, active fill
// surface-main and active tint `accent`, hover surface-hover. All four Local
// call sites (LocalToolbar.qml x3, LocalFolderDetail.qml) set NOTHING but
// `segments` / `mode` / `onSetMode`, so they keep exactly that.
//
// MyQBZ's toggle is a DIFFERENT widget in the reference and always was —
// `MyQbzShared.slint:49-71` (2 segments, 60x30) and
// `MixtapeDetailView.slint:1058-1084` (3 segments, 90x30) fill the well
// EDGE TO EDGE with `ToggleButton { sm: true }`, i.e. 30x30 cells, no gaps, a
// 15px glyph, and — the load-bearing part, spelled out at MyQbzShared.slint:47-48
// — active = `surface-hover`, NEVER accent (`ToggleButton.slint:19-20,24-28,32-33,38`:
// 30x30 at `sm`, active background surface-hover, hover surface-elevated, idle
// transparent, tint text-primary active / text-muted idle). So the two MyQBZ
// call sites pass that set explicitly. Nine properties at two call sites, in
// preference to a second near-identical component (TRACK-RULES §5).
//
// `segRadius` is the one number that is NOT the reference's: Slint's
// ToggleButton has border-radius 0 and relies on the WELL's `clip: true` to
// round the outer corners. A QML clip is a rectangular scissor and does not
// follow `radius`, so an edge-to-edge square cell would paint its own square
// corner over the well's curve. The curve therefore has to come from the cell,
// which also rounds the two INNER corners Slint leaves square — invisible at
// this contrast, since the active fill is `surfaceHover` = #10ffffff, a 6%
// white wash over the well's own surface-elevated.
//
// ADR-008: small-radius rectangle, never a pill.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Rectangle {
id: root
/// [{ id, icon }] — `id` is the value published through `setMode`, `icon`
/// is a QbzIcon name that must exist in BOTH the `activeTint` and the
/// `idleTint` directories. A missing tint variant renders nothing at all,
/// with nothing logged.
property var segments: []
property string mode: ""
signal setMode(string value)
// --- cell metrics. DEFAULTS = the Local Library set (see the header). ---
property int segWidth: 26
property int segHeight: 24
property int segRadius: 4
property int segSpacing: 2
property int glyphSize: 14
/// Fill of the SELECTED cell. Local: surface-main. MyQBZ/ToggleButton:
/// surface-hover — "active = surface-hover, NEVER accent"
/// (MyQbzShared.slint:47-48).
property color activeFill: theme.surfaceMain
/// Fill of a hovered, unselected cell. `ToggleButton.slint:28` uses
/// surface-elevated, which equals the WELL's own fill, i.e. the reference's
/// hover is deliberately a no-op inside a well — pass `theme.surfaceElevated`
/// to reproduce that, not a visible highlight.
property color hoverFill: theme.surfaceHover
/// QbzIcon tint names (theme/QbzIcon.qml's vocabulary). Local: accent /
/// secondary. ToggleButton.slint:38: text-primary / text-muted.
property string activeTint: "accent"
property string idleTint: "secondary"
QbzTheme { id: theme }
width: 60
height: 30
radius: 6
color: theme.surfaceElevated
clip: true
Row {
anchors.centerIn: parent
spacing: root.segSpacing
Repeater {
model: root.segments
delegate: Rectangle {
id: seg
required property var modelData
readonly property bool active: modelData.id === root.mode
width: root.segWidth
height: root.segHeight
radius: root.segRadius
color: active ? root.activeFill
: segArea.containsMouse ? root.hoverFill : "transparent"
QbzIcon {
name: seg.modelData.icon
width: root.glyphSize
height: root.glyphSize
anchors.centerIn: parent
tintName: seg.active ? root.activeTint : root.idleTint
}
MouseArea {
id: segArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.setMode(seg.modelData.id)
}
}
}
}
}
+26 -11
View File
@@ -20,20 +20,35 @@ Rectangle {
property int popupWidth: 0
property bool enabled: true
property bool searchable: false
// Bootstrap-style small variant (QbzSelect.slint:74-76). The default is the
// standard Settings size; TOOLBARS opt in with `sm: true` — 30px tall, r6,
// NO outline (it matches the favorites toolbar buttons), 12px label and a
// 14px chevron, and 40px narrower because toolbar selects were needlessly
// wide (QbzSelect.slint:86-88,102-105,118-119,126,147-148,299).
property bool sm: false
signal selected(int index)
QbzTheme { id: theme }
id: selectRoot
width: menuWidth
height: 34
radius: theme.radiusSm
border.width: 1
width: sm ? Math.max(0, menuWidth - 40) : menuWidth
height: sm ? 30 : 34
radius: sm ? 6 : theme.radiusSm
border.width: sm ? 0 : 1
border.color: theme.borderSubtle
color: selArea.containsMouse && enabled ? theme.surfaceHover : theme.surfaceElevated
opacity: enabled ? 1.0 : 0.4
readonly property int listWidth: Math.max(popupWidth, menuWidth)
// `width`, NOT `menuWidth`: QbzSelect.slint:89-91 resolves the open list as
// `max(popup-width, EFF-WIDTH)`, and eff-width is `menu-width - 40px` at
// `sm` (:88) — the same value it uses for the collapsed control. Reading the
// RAW menuWidth here made every toolbar dropdown's PANEL 40px wider than the
// reference's (MyQBZ sort 180 vs 140, kind filter 200 vs 160, detail sort
// 170 vs 130, and the Local Library toolbar / LabelReleases selects with it).
// The three `popupWidth` callers (AudioSettings 480, CastPicker 260,
// LyricsControlsFlyout 178) are all non-`sm`, where width === menuWidth and
// popupWidth wins anyway, so none of them moves.
readonly property int listWidth: Math.max(popupWidth, selectRoot.width)
readonly property int rowHeight: 32
readonly property int headerHeight: 24
readonly property int searchHeight: searchable ? 42 : 0
@@ -58,8 +73,8 @@ Rectangle {
Row {
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 10
anchors.leftMargin: selectRoot.sm ? 10 : 12
anchors.rightMargin: selectRoot.sm ? 8 : 10
spacing: 8
Text {
width: parent.width - 16 - 8 - badgeSlot.width - (badgeSlot.visible ? 8 : 0)
@@ -67,7 +82,7 @@ Rectangle {
text: selectRoot.currentIndex >= 0 && selectRoot.currentIndex < selectRoot.options.length
? selectRoot.optLabel(selectRoot.currentIndex) : ""
color: theme.textPrimary
font.pixelSize: theme.fontBody
font.pixelSize: selectRoot.sm ? 12 : theme.fontBody
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
@@ -99,8 +114,8 @@ Rectangle {
}
QbzIcon {
name: "chevron-down"
width: 16
height: 16
width: selectRoot.sm ? 14 : 16
height: selectRoot.sm ? 14 : 16
anchors.verticalCenter: parent.verticalCenter
tintName: "muted"
}
@@ -247,7 +262,7 @@ Rectangle {
text: optRow.label
color: optRow.index === selectRoot.currentIndex
? theme.accent : theme.textSecondary
font.pixelSize: theme.fontBody
font.pixelSize: selectRoot.sm ? 12 : theme.fontBody
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
@@ -0,0 +1,81 @@
// QbzTextArea — the port's first MULTILINE input. Slint uses std-widgets
// `TextEdit` (MyQbzEditModal.slint:90-99, 96px tall, word-wrap); QML's
// QtQuick.Controls TextArea would bring its own styled background, so this is
// the same Rectangle-plus-input recipe controls/QbzLineEdit.qml uses for the
// single-line case: r8 surface-elevated box, 1px border that turns accent on
// focus, 12/8 padding, a Flickable so a description longer than the box
// scrolls instead of clipping silently.
//
// One call site today (the Edit modal's "Edit description" body). The API is
// deliberately the same shape as QbzLineEdit's: `text` in, `edited(value)`
// out, and the external re-seed goes through a `Binding { when: !activeFocus }`
// so a republish while the user is typing cannot fight the caret.
//
// No Enter-submit: a newline is legitimate content here (MyQbzEditModal has
// no `accepted` handler on this body either).
import QtQuick
import com.blitzfc.qbz
import "../theme"
Rectangle {
id: root
property string text: ""
property string placeholder: ""
/// Exposed so a call site can pass TextEdit.WordWrap / .NoWrap explicitly;
/// the .slint body is `wrap: word-wrap`.
property int wrapMode: TextEdit.WordWrap
signal edited(string value)
QbzTheme { id: theme }
width: 240
height: 96
radius: theme.radiusSm
color: theme.surfaceElevated
border.width: 1
border.color: input.activeFocus ? theme.accent : theme.borderSubtle
Flickable {
id: flick
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 12
anchors.topMargin: 8
anchors.bottomMargin: 8
clip: true
contentWidth: width
contentHeight: input.implicitHeight
boundsBehavior: Flickable.StopAtBounds
TextEdit {
id: input
width: flick.width
text: root.text
color: theme.textPrimary
font.pixelSize: theme.fontBody
wrapMode: root.wrapMode
selectByMouse: true
onTextChanged: if (activeFocus) root.edited(text)
// External republish re-seeds the field while it is not being
// edited (the QbzLineEdit.qml:167-172 idiom).
Binding {
target: input
property: "text"
value: root.text
when: !input.activeFocus
}
Text {
visible: input.text === "" && root.placeholder !== ""
width: parent.width
text: root.placeholder
color: theme.textMuted
font.pixelSize: theme.fontBody
wrapMode: Text.WordWrap
}
}
}
}
+167
View File
@@ -0,0 +1,167 @@
// QbzToast — the app's in-app toast host (primitives/Toast.slint), mounted
// ONCE in AppShell.qml as a sibling of the content frame. Until this file the
// port had NO toast seam at all: TrackRow.qml:597-600, LabelView.qml:25,
// LyricsPanel.qml:16, PlayerBar.qml:515-517, NowPlayingBarSmall.qml:461-463
// and local_bulk.rs:190-193 each document the same gap and fall back to
// silence. Silence is not 1:1 — "Already in {name}" is the ONLY signal that a
// duplicate add did nothing, and MyQBZ alone routes 26 distinct messages
// through crate::toast.
//
// CONTRACT. Rust publishes `QbzShell.toastJson`
// (`{ seq, kind, message, persistent }`, ToastDoc): ONE toast at a time, a new
// one replaces the current, and Rust has ALREADY applied the `in_app_toasts`
// settings gate (errors always pass) — this file must not re-read the setting.
// The auto-hide timer lives HERE, keyed off `seq`, so Rust never owns a timer
// nor needs a hide round-trip: success/info 3000ms, warning 4000, error 5000,
// buffering persistent (qbz-slint-common/src/toast.rs:31-40).
//
// The component is ALWAYS in the tree (never `if`-gated) so the entry
// animation runs; the close button's MouseArea is live only while a toast is
// showing, so the transparent overlay never eats a click meant for the content
// underneath. The root itself carries no MouseArea at all.
//
// Geometry (Toast.slint): bubble 44px tall, width = content capped at
// `parent.width - 80`, horizontally centred, `y = parent.height - height -
// (showing ? 100 : 84)` so it slides up the last 16px, 200ms ease-out on both
// y and opacity, r8 surface-elevated, padding 16 left / 8 right, row spacing
// 12, 20px kind icon, 14px message elided to one line, 24x24 r4 close with a
// 16px glyph.
//
// The .slint's `drop-shadow-blur: 16px / #00000066` (:55-56) is DROPPED: Qt's
// shadow effects render nothing on this port's software path (the same reason
// NavFlyout.qml:30-33 and every modal drop it). The 44px elevated fill on a
// dark scene carries the separation.
//
// ASSET + TINT PREREQUISITE (wiring items W21/W22): `circle-check-big`,
// `circle-alert` and `triangle-alert` are NOT in qml/assets/icons/* yet, and
// icon_tint_qt.rs's TOKENS has no `success` / `danger` tint. QbzIcon takes a
// tint NAME, never a colour, so both halves must land or the success/error
// glyphs render NOTHING with nothing logged.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Item {
id: root
QbzTheme { id: theme }
// Guarded parse — a raw JSON.parse inside a binding throws on the
// pre-publish frame and takes the host down with it
// (PlaylistView.qml:55-61).
readonly property var doc: {
try {
return JSON.parse(QbzShell.toastJson)
} catch (e) {
return ({})
}
}
readonly property int seq: root.doc.seq || 0
readonly property string kind: root.doc.kind || "info"
readonly property string message: root.doc.message || ""
readonly property bool persistent: root.doc.persistent === true
property bool showing: false
readonly property int autoHideMs: root.kind === "error" ? 5000
: root.kind === "warning" ? 4000 : 3000
readonly property string iconName: root.kind === "success" ? "circle-check-big"
: root.kind === "error" ? "circle-alert"
: root.kind === "warning" ? "triangle-alert"
: root.kind === "buffering" ? "loader-circle"
: "info"
readonly property string iconTint: root.kind === "success" ? "success"
: root.kind === "error" ? "danger"
: root.kind === "warning" ? "warning"
: "accent"
// A new sequence number IS the show event (a repeated message with the
// same text must still re-show, so the trigger cannot be the text).
onSeqChanged: {
if (root.seq <= 0 || root.message === "")
return
root.showing = true
hideTimer.stop()
if (!root.persistent)
hideTimer.restart()
}
Timer {
id: hideTimer
interval: root.autoHideMs
repeat: false
onTriggered: root.showing = false
}
Rectangle {
id: bubble
// 16 pad + 20 icon + 12 gap + message + 12 gap + 24 close + 8 pad.
readonly property real chromeWidth: 16 + 20 + 12 + 12 + 24 + 8
width: Math.min(bubble.chromeWidth + Math.ceil(msg.implicitWidth),
Math.max(0, root.width - 80))
height: 44
x: Math.round((root.width - width) / 2)
y: root.height - height - (root.showing ? 100 : 84)
opacity: root.showing ? 1.0 : 0.0
Behavior on y { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuad } }
radius: 8
color: theme.surfaceElevated
Row {
anchors.fill: parent
anchors.leftMargin: 16
anchors.rightMargin: 8
spacing: 12
QbzIcon {
anchors.verticalCenter: parent.verticalCenter
name: root.iconName
width: 20
height: 20
tintName: root.iconTint
}
Text {
id: msg
anchors.verticalCenter: parent.verticalCenter
width: Math.max(0, bubble.width - bubble.chromeWidth)
text: root.message
color: theme.textPrimary
font.pixelSize: 14
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 24
height: 24
radius: 4
color: closeArea.containsMouse ? theme.surfaceHover : "transparent"
QbzIcon {
anchors.centerIn: parent
name: "x"
width: 16
height: 16
tintName: closeArea.containsMouse ? "textPrimary" : "muted"
}
MouseArea {
id: closeArea
anchors.fill: parent
// Live ONLY while a toast is showing — the hidden overlay
// must not capture clicks (Toast.slint:106-108).
enabled: root.showing
hoverEnabled: root.showing
cursorShape: Qt.PointingHandCursor
onClicked: {
hideTimer.stop()
root.showing = false
}
}
}
}
}
}
@@ -0,0 +1,103 @@
// QbzToolButton — the MyQBZ detail toolbar's `ToolBtn`
// (myqbz/MixtapeDetailView.slint:85-151): a 30px bordered chip that is
// icon-only, icon+label, or icon+label+badge, with TWO distinct active looks.
//
// Why not controls/BrowseGenreButton.qml: that one is hard-bound to
// `QbzBridge.genreFilterJson` and builds its own label out of it, so a generic
// label/badge/active-mode contract cannot be a parameter of it.
//
// THE TWO ACTIVE MODES are the whole point, and they are not interchangeable:
// * `fillActive: true` — active paints an ACCENT FILL (the Filter button,
// which is labelled and carries the filter count).
// * `fillActive: false` — active paints an accent BORDER on the normal
// elevated fill (the icon-only Select / Reset buttons). Never a fill.
//
// Numbers: height 30, r6, width = the row's own padded width (:97-99, so the
// padding centres the content rather than an absolute x offset), 1px border;
// padding 8/side icon-only and 10/side labelled (:108-109); row spacing 6;
// glyph 15x15; label 12px; badge 16x16 r8 with 10px semibold text.
//
// Where the .slint hardcodes `#ffffff` on the accent fill (:120, :127, :137)
// this uses `theme.accentGlyphTint` / `theme.accentGlyphColor` — the measured
// on-accent selector (theme/QbzTheme.qml, "ON AN ACCENT FILL"). The badge's
// non-filled text stays `accentText` because there it sits on the accent disc,
// which is what that token is for.
import QtQuick
import com.blitzfc.qbz
import "../theme"
Rectangle {
id: root
property string name: ""
property string label: ""
/// > 0 renders the trailing count disc.
property int badge: 0
property bool active: false
/// Active = accent FILL (labelled buttons) vs accent BORDER (icon-only).
property bool fillActive: false
signal clicked()
QbzTheme { id: theme }
readonly property bool filled: root.active && root.fillActive
readonly property int padH: root.label === "" ? 8 : 10
height: 30
implicitWidth: 2 * root.padH + row.implicitWidth
radius: 6
color: root.filled ? theme.accent
: (toolArea.containsMouse ? theme.surfaceHover : theme.surfaceElevated)
border.width: 1
border.color: (root.active && !root.fillActive) ? theme.accent : theme.borderSubtle
Row {
id: row
anchors.centerIn: parent
spacing: 6
QbzIcon {
anchors.verticalCenter: parent.verticalCenter
name: root.name
width: 15
height: 15
tintName: root.filled ? theme.accentGlyphTint
: (root.active ? "textPrimary" : "muted")
}
Text {
visible: root.label !== ""
anchors.verticalCenter: parent.verticalCenter
text: root.label
color: root.filled ? theme.accentGlyphColor
: (root.active ? theme.textPrimary : theme.textSecondary)
font.pixelSize: 12
verticalAlignment: Text.AlignVCenter
}
Rectangle {
visible: root.badge > 0
anchors.verticalCenter: parent.verticalCenter
width: root.badge > 0 ? 16 : 0
height: 16
radius: 8
color: root.filled ? theme.accentGlyphColor : theme.accent
Text {
anchors.centerIn: parent
text: root.badge
color: root.filled ? theme.accent : theme.accentText
font.pixelSize: 10
font.weight: theme.weightSemibold
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
}
}
MouseArea {
id: toolArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.clicked()
}
}
+19 -2
View File
@@ -10,15 +10,24 @@ import "../theme"
Rectangle {
property string text: ""
property string iconName: ""
// Trailing chevron/glyph AFTER the label (the Slint settings rows that open
// a sub-view: ContentFilteringSettings.slint's Manage affordance). "" = none.
property string trailingIconName: ""
property bool danger: false
property bool busy: false
property bool enabled: true
// The two metrics the MyQBZ modal footers and the Disco builder need. The
// Slint's SecondaryButton is 34px/min-160 in Settings and 38px/hug in a
// modal footer, which is one control with two call-site numbers — not two
// components (TRACK-RULES §5). minWidth: 0 = hug the content.
property int btnHeight: 34
property int minWidth: 160
signal clicked()
QbzTheme { id: theme }
width: Math.max(iconName !== "" && text === "" ? 34 : 160, row.implicitWidth + 24)
height: 34
width: Math.max(iconName !== "" && text === "" ? 34 : minWidth, row.implicitWidth + 24)
height: btnHeight
radius: theme.radiusSm
border.width: 1
border.color: danger ? theme.danger : theme.borderSubtle
@@ -45,6 +54,14 @@ Rectangle {
font.weight: theme.weightMedium
verticalAlignment: Text.AlignVCenter
}
QbzIcon {
visible: parent.parent.trailingIconName !== ""
name: parent.parent.trailingIconName
width: 15
height: 15
anchors.verticalCenter: parent.verticalCenter
tintName: parent.parent.danger ? "favorite" : "secondary"
}
}
MouseArea {
id: btnArea