// Discography Builder — the full-page flow that assembles an artist's // complete discography into a saved `kind='artist_collection'` collection // (spec 13). A 1:1 port of the Tauri DiscographyBuilderView.svelte. // // Two-part layout: `.builder-scroll` holds everything that scrolls; the // footer is a fixed-height flex sibling pinned at the bottom (NOT // sticky-inside-scroll) so last rows never peek past the footer. // // HOMOLOGATED: all chrome colors go through the app's `Theme.*` tokens (so the // accent matches every sibling view); the only hardcoded palette left is the // per-release-type label tints (`DiscoTint`), which the spec intends as fixed // non-token colors. The old per-view back button was removed (the shell owns // the global < > nav; the footer Cancel covers exit). import { Theme } from "../foundation/semantic-colors.slint"; import { Typography } from "../foundation/typography.slint"; import { DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate } from "../state.slint"; import { QbzIcon } from "../primitives/QbzIcon.slint"; import { QualityBadgeFull } from "../primitives/QualityBadgeFull.slint"; import { QbzPrimaryButton } from "../primitives/QbzPrimaryButton.slint"; import { SecondaryButton } from "../primitives/SecondaryButton.slint"; import { SourceGlyph } from "../primitives/SourceGlyph.slint"; import { SelectionCheckbox } from "../primitives/SelectionCheckbox.slint"; // ── Release-type label tints (spec §0) ──────────────────────────────────── // The ONE legitimately-hardcoded palette in this view: the per-release-type // accent colors. Everything else now goes through the app's `Theme.*` tokens // (the old `global D` — which hardcoded the dark-theme literals AND a non-app // `#4285F4` accent — was deleted; that blue mismatched every sibling view). global DiscoTint { out property compilation: #f59e0b; // amber out property live: #e91e63; // pink out property ep: #60a5fa; // blue out property single: #a78bfa; // violet } // Resolve a release-type to its tint (plain "album" = muted, no tint). component TypeColor { in property kind; out property color: root.kind == "compilation" ? DiscoTint.compilation : root.kind == "live" ? DiscoTint.live : root.kind == "ep" ? DiscoTint.ep : root.kind == "single" ? DiscoTint.single : Theme.text-muted; } // ── Source indicator — the shared SourceGlyph (full-color logos untinted; // monochrome local hard-drive tinted muted), centered in a 28px cell. ─────── component SourceIndicator inherits Rectangle { in property source; width: 28px; height: 28px; SourceGlyph { kind: root.source; x: Math.round((parent.width - self.width) / 2 / 1px) * 1px; y: Math.round((parent.height - self.height) / 2 / 1px) * 1px; } } // ── Per-row release-type override button + popover (spec §7.1) ───────────── component TypeOverride inherits Rectangle { in property candidate; // 11px primary / 10px alternate. in property font-size: 11px; property menu-key: root.candidate.source + "|" + root.candidate.source-item-id; property menu-open: DiscoBuilderState.open-type-menu-key == root.menu-key; // The wrapper anchors the absolute popover; it sizes to the button. width: type-btn.preferred-width; height: type-btn.preferred-height; type-btn := Rectangle { // .type-btn negative margin (0 -4px) is replicated by a -4px touch // bleed; the visual glyph stays put. background: btn-ta.has-hover ? Theme.surface-hover : transparent; border-radius: 4px; HorizontalLayout { padding-left: 4px; padding-right: 4px; padding-top: 2px; padding-bottom: 2px; label := Text { text: root.candidate.release-type; color: type-color.color; font-size: root.font-size; font-weight: 600; letter-spacing: 0.4px; vertical-alignment: center; } } type-color := TypeColor { kind: root.candidate.release-type; } // Dotted-underline marker for an active override (Slint has no // text-decoration; draw a 1px dotted rule under the label). if root.candidate.is-overridden: Rectangle { x: label.x; y: parent.height - 3px; width: label.width; height: 1px; background: type-color.color; opacity: 0.6; } btn-ta := TouchArea { mouse-cursor: pointer; clicked => { DiscoBuilderState.open-type-menu-key = root.menu-open ? "" : root.menu-key; } } } // Backdrop + menu (rendered above siblings; z-order is paint order). if root.menu-open: Rectangle { // Backdrop click-catcher — full-row local catch; closes the menu. // (A true full-viewport backdrop isn't expressible here without a // global overlay; the menu's close-on-outside is handled by the // backdrop TouchArea plus re-clicking the button.) TouchArea { x: -2000px; y: -2000px; width: 4000px; height: 4000px; clicked => { DiscoBuilderState.open-type-menu-key = ""; } } menu := Rectangle { x: 0; y: parent.height + 4px; width: 160px; background: Theme.surface-card; border-width: 1px; border-color: Theme.surface-elevated; border-radius: 6px; drop-shadow-blur: 12px; drop-shadow-color: #00000059; // rgba(0,0,0,0.35) drop-shadow-offset-y: 4px; VerticalLayout { padding: 4px; // Album, EP, Single, Live, Compilation (spec order). for choice in [ { id: "album", lbl: "Album" }, { id: "ep", lbl: "EP" }, { id: "single", lbl: "Single" }, { id: "live", lbl: "Live" }, { id: "compilation", lbl: "Compilation" }, ]: Rectangle { height: 28px; border-radius: 4px; background: item-ta.has-hover ? Theme.surface-hover : transparent; HorizontalLayout { padding-left: 8px; padding-right: 8px; spacing: 8px; alignment: start; VerticalLayout { alignment: center; // Check glyph if this is the selected type; else a // 12px placeholder so labels stay aligned. if root.candidate.release-type == choice.id: QbzIcon { source: @image-url("../assets/icons/check.svg"); width: 12px; height: 12px; tint: Theme.accent; } if root.candidate.release-type != choice.id: Rectangle { width: 12px; height: 12px; } } Text { text: choice.lbl; color: root.candidate.release-type == choice.id ? Theme.accent : Theme.text-primary; font-size: 12px; vertical-alignment: center; horizontal-stretch: 1; } } item-ta := TouchArea { mouse-cursor: pointer; clicked => { DiscoBuilderActions.set-type-override( root.candidate.source, root.candidate.source-item-id, choice.id); DiscoBuilderState.open-type-menu-key = ""; } } } // Reset row — only when an override is active. if root.candidate.is-overridden: Rectangle { height: 9px; Rectangle { y: 4px; height: 1px; background: Theme.surface-elevated; } } if root.candidate.is-overridden: Rectangle { height: 28px; border-radius: 4px; background: reset-ta.has-hover ? Theme.surface-hover : transparent; HorizontalLayout { padding-left: 8px; padding-right: 8px; spacing: 8px; alignment: start; VerticalLayout { alignment: center; QbzIcon { source: @image-url("../assets/icons/rotate-ccw.svg"); width: 12px; height: 12px; tint: Theme.text-muted; } } Text { text: @tr("Use auto-detected"); color: Theme.text-muted; font-size: 12px; vertical-alignment: center; horizontal-stretch: 1; } } reset-ta := TouchArea { mouse-cursor: pointer; clicked => { DiscoBuilderActions.reset-type-override( root.candidate.source, root.candidate.source-item-id); DiscoBuilderState.open-type-menu-key = ""; } } } } } } } // 7-column row grid — the alignment backbone (spec §2.9): // grid-template-columns: 28px 56px 72px minmax(0,1fr) 72px 60px 156px, gap 10px. // Each row below inlines this template (header/primary/alternate share it). // // One candidate row (primary or alternate). `alt` dims it + swaps the col[0] // checkbox for a connector + checkbox and shrinks/mutes the text. component CandidateRow inherits Rectangle { in property candidate; in property group-key; in property alt: false; // Whether the OWNING group is a compilation — drives the primary row's // "compilation" tag (spec §2.10: tag is `{#if grp.is_compilation}`, the // group flag, not the candidate's effective type). in property group-is-compilation: false; // Persistent dim (compilation primary 0.65 / alternate 0.72); lifts to 1 // on hover. The parent passes the resting opacity. in property rest-opacity: 1.0; height: 44px; border-radius: 6px; background: row-ta.has-hover ? Theme.surface-hover : transparent; opacity: row-ta.has-hover ? 1.0 : root.rest-opacity; row-ta := TouchArea { mouse-cursor: default; } // Subtle bottom hairline so adjacent rows (and their quality badges) read // as separated instead of stuck together. Rectangle { y: parent.height - 1px; height: 1px; background: Theme.border-subtle; } HorizontalLayout { padding-left: 8px; padding-right: 8px; spacing: 10px; // [0] 28px — checkbox cell (alt: connector + checkbox). Rectangle { width: 28px; HorizontalLayout { alignment: start; spacing: 3px; if root.alt: Text { text: "↳"; color: Theme.text-muted; font-size: 12px; vertical-alignment: center; } VerticalLayout { alignment: center; SelectionCheckbox { checked: root.candidate.checked; toggled => { DiscoBuilderActions.toggle-checked( root.group-key, root.candidate.key); } } } } } // [1] 56px — year. Rectangle { width: 56px; Text { text: root.candidate.year; color: root.alt ? Theme.text-muted : Theme.text-secondary; font-size: root.alt ? 12px : 13px; vertical-alignment: center; horizontal-alignment: left; width: 100%; } } // [2] 72px — type override button + popover. Rectangle { width: 72px; HorizontalLayout { alignment: start; VerticalLayout { alignment: center; TypeOverride { candidate: root.candidate; font-size: root.alt ? 10px : 11px; } } } } // [3] 1fr — title (flexes) + tag. Rectangle { horizontal-stretch: 1; HorizontalLayout { alignment: start; spacing: 8px; title-ta := TouchArea { mouse-cursor: pointer; horizontal-stretch: 1; clicked => { DiscoBuilderActions.open-album( root.candidate.source, root.candidate.source-item-id); } title := Text { text: root.candidate.title; color: title-ta.has-hover ? Theme.accent : (root.alt ? Theme.text-muted : Theme.text-primary); font-size: root.alt ? 13px : 14px; overflow: elide; vertical-alignment: center; width: 100%; } } // alternates always show the "alternate" tag; primaries show // "compilation" only when the group is a compilation (passed // by the parent baking it into the candidate's title? No — // the parent sets `tag` separately). Here we infer from the // row kind + the candidate's own type. if root.alt: Text { text: @tr("alternate"); color: Theme.text-muted; font-size: 10px; font-weight: 500; font-italic: true; letter-spacing: 0.8px; vertical-alignment: center; } if !root.alt && root.group-is-compilation: Text { text: @tr("compilation"); color: Theme.text-muted; font-size: 10px; font-weight: 500; font-italic: true; letter-spacing: 0.8px; vertical-alignment: center; } } } // [4] 72px — tracks (centered, tabular). Rectangle { width: 72px; Text { text: root.candidate.tracks; color: root.alt ? Theme.text-muted : Theme.text-secondary; font-size: root.alt ? 12px : 13px; horizontal-alignment: center; vertical-alignment: center; width: 100%; } } // [5] 60px — source indicator. Rectangle { width: 60px; HorizontalLayout { alignment: center; VerticalLayout { alignment: center; SourceIndicator { source: root.candidate.source; } } } } // [6] 156px — quality badge. Rectangle { width: 156px; HorizontalLayout { alignment: center; VerticalLayout { alignment: center; QualityBadgeFull { tier: root.candidate.quality-tier; detail: root.candidate.quality-detail; } } } } } } export component DiscographyBuilderView inherits Rectangle { background: transparent; // ── .builder-view (flex column, full size) ── VerticalLayout { // ── .builder-scroll (scrolls everything) ── scroll := Flickable { vertical-stretch: 1; viewport-width: self.width; viewport-height: content.preferred-height; content := VerticalLayout { width: scroll.width; padding-left: 32px; padding-right: 32px; padding-top: 24px; padding-bottom: 24px; spacing: 0px; alignment: start; // NO per-view back button — the shell owns the global < > nav // (the footer Cancel covers exit). Vertical space reclaimed. // ── header.builder-header ── HorizontalLayout { spacing: 20px; alignment: start; // Avatar (img or placeholder) — 72px circle. Rectangle { width: 72px; height: 72px; border-radius: 36px; background: Theme.surface-elevated; clip: true; if DiscoBuilderState.artist-avatar-url != "": Image { width: 100%; height: 100%; source: DiscoBuilderState.artist-avatar; image-fit: cover; } } // Header text — eyebrow + title. VerticalLayout { alignment: center; spacing: 4px; horizontal-stretch: 1; Text { // Eyebrow is uppercased (spec 13 §0: eyebrow/field- // label/col-label use text-transform:uppercase). Slint // has no text-transform, so the literal is written in // caps (same idiom as the other MyQBZ eyebrows — // AddToMixtapeModal "ADD TO MIXTAPE/COLLECTION", the // grid card label from Rust kind_label). text: @tr("BUILD ARTIST COLLECTION"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.5px; } Text { text: DiscoBuilderState.artist-name == "" ? "—" : DiscoBuilderState.artist-name; color: Theme.text-primary; font-size: 28px; font-weight: 700; overflow: elide; } } } Rectangle { height: 24px; } // ── label.field (collection-name input) ── VerticalLayout { spacing: 8px; alignment: start; Text { text: @tr("NAME"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.5px; } Rectangle { width: 540px; height: 40px; background: Theme.surface-card; border-radius: 8px; border-width: 1px; border-color: name-input.has-focus ? Theme.accent : Theme.surface-elevated; HorizontalLayout { padding-left: 12px; padding-right: 12px; name-input := TextInput { color: Theme.text-primary; font-size: 14px; vertical-alignment: center; single-line: true; text: DiscoBuilderState.collection-name; edited => { DiscoBuilderActions.name-changed(self.text); } } } } } Rectangle { height: 16px; } // ── .order-row (segmented control) ── HorizontalLayout { spacing: 12px; alignment: start; VerticalLayout { alignment: center; Text { // .field-label is uppercased (spec §2.6 — same // text-transform:uppercase as the eyebrow / NAME label). text: @tr("ORDER BY"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.5px; } } // .segmented — 8px corners, NO pills. Rectangle { width: seg.preferred-width; height: 32px; border-radius: 8px; border-width: 1px; border-color: Theme.surface-elevated; clip: true; seg := HorizontalLayout { spacing: 0px; for s[i] in [ { id: "release_date", lbl: "Release date" }, { id: "title", lbl: "Title" }, { id: "manual", lbl: "Manual" }, ]: seg-rect := Rectangle { property active: DiscoBuilderState.order-by == s.id; // Non-accent active (the app's ToggleButton idiom): a surface // highlight, not a blue fill. Active distinguished from hover by // tone + bolder text below. background: seg-rect.active ? Theme.surface-hover : (seg-ta.has-hover ? Theme.surface-elevated : transparent); // Divider between segments. if i > 0: Rectangle { x: 0; width: 1px; height: 100%; background: Theme.surface-elevated; } HorizontalLayout { padding-left: 14px; padding-right: 14px; padding-top: 7px; padding-bottom: 7px; Text { text: s.lbl; color: seg-rect.active ? Theme.text-primary : (seg-ta.has-hover ? Theme.text-primary : Theme.text-secondary); font-size: 12px; font-weight: seg-rect.active ? 600 : 500; vertical-alignment: center; } } seg-ta := TouchArea { mouse-cursor: pointer; clicked => { DiscoBuilderActions.set-order(s.id); } } } } } } Rectangle { height: 20px; } // ── {state branch} ── // loading if DiscoBuilderState.loading: Rectangle { height: 96px; Text { text: @tr("Loading..."); color: Theme.text-muted; font-size: 14px; horizontal-alignment: center; vertical-alignment: center; } } // error if !DiscoBuilderState.loading && DiscoBuilderState.load-error != "": Rectangle { height: 96px; Text { text: DiscoBuilderState.load-error; color: Theme.favorite; font-size: 14px; horizontal-alignment: center; vertical-alignment: center; } } // empty if !DiscoBuilderState.loading && DiscoBuilderState.load-error == "" && DiscoBuilderState.groups.length == 0: Rectangle { height: 96px; Text { text: @tr("No results found"); color: Theme.text-muted; font-size: 14px; horizontal-alignment: center; vertical-alignment: center; } } // populated — .groups table if !DiscoBuilderState.loading && DiscoBuilderState.load-error == "" && DiscoBuilderState.groups.length > 0: VerticalLayout { spacing: 0px; // border-top + 4px pad-top. Rectangle { height: 1px; background: Theme.surface-elevated; } Rectangle { height: 4px; } // ── header row (.row.header-row) ── Rectangle { height: 36px; Rectangle { y: parent.height - 1px; height: 1px; background: Theme.surface-elevated; } HorizontalLayout { padding-left: 8px; padding-right: 8px; spacing: 10px; // [0] 28px — select-all checkbox (tri-state). The // indeterminate state renders minus.svg inside the // same circular accent box (the TreeRow idiom), NOT a // hand-drawn dash. Rectangle { width: 28px; HorizontalLayout { alignment: start; VerticalLayout { alignment: center; SelectionCheckbox { checked: DiscoBuilderState.all-checked; partial: !DiscoBuilderState.all-checked && DiscoBuilderState.some-checked; toggled => { DiscoBuilderActions.toggle-all(); } } } } } // [1..6] column labels — uppercased (spec §2.9 // header-row text-transform:uppercase; literal caps). Rectangle { width: 56px; Text { text: @tr("YEAR"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; width: 100%; horizontal-alignment: left; } } Rectangle { width: 72px; Text { text: @tr("TYPE"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; width: 100%; horizontal-alignment: left; } } Rectangle { horizontal-stretch: 1; Text { text: @tr("ALBUM"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; horizontal-alignment: left; } } Rectangle { width: 72px; Text { text: @tr("TRACKS"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; width: 100%; horizontal-alignment: center; } } Rectangle { width: 60px; Text { text: @tr("SOURCE"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; width: 100%; horizontal-alignment: center; } } Rectangle { width: 156px; Text { text: @tr("QUALITY"); color: Theme.text-muted; font-size: 10px; font-weight: 600; letter-spacing: 1.2px; vertical-alignment: center; width: 100%; horizontal-alignment: center; } } } } // ── per group ── for grp in DiscoBuilderState.groups: VerticalLayout { spacing: 0px; // primary row (dimmed when the group is a compilation). CandidateRow { candidate: grp.primary; group-key: grp.key; alt: false; group-is-compilation: grp.is-compilation; rest-opacity: grp.is-compilation ? 0.65 : 1.0; } // alternate rows. for alt in grp.alternates: CandidateRow { candidate: alt; group-key: grp.key; alt: true; rest-opacity: 0.72; } } } } } // ── footer.builder-footer (fixed-height flex sibling) ── Rectangle { vertical-stretch: 0; height: 60px; background: Theme.surface-main; Rectangle { y: 0; height: 1px; background: Theme.surface-elevated; } HorizontalLayout { padding-left: 32px; padding-right: 88px; // asymmetric — clears the back-to-top FAB. padding-top: 12px; padding-bottom: 12px; spacing: 16px; // .footer-count. VerticalLayout { alignment: center; horizontal-stretch: 1; Text { text: DiscoBuilderState.selected-count + " of " + DiscoBuilderState.group-count + " albums selected"; color: Theme.text-secondary; font-size: 13px; } } // .footer-actions — the app's shared labeled primitives. HorizontalLayout { spacing: 8px; alignment: end; // disabled = creating || selectedCount===0 || // !collectionName.trim() (spec §2.13 / §10.19). The trim is // computed in the controller (Slint can't trim) and exposed // as `name-trimmed-empty`, so a whitespace-only name disables. property create-disabled: DiscoBuilderState.creating || DiscoBuilderState.selected-count == 0 || DiscoBuilderState.name-trimmed-empty; // Cancel (secondary). SecondaryButton { label: @tr("Cancel"); height: 36px; clicked => { DiscoBuilderActions.back(); } } // Create (primary). QbzPrimaryButton { label: DiscoBuilderState.creating ? @tr("Loading...") : @tr("Create Collection"); height: 36px; enabled: !parent.create-disabled; clicked => { DiscoBuilderActions.create(); } } } } } } }