Files
qbz/crates/qbz-slint/ui/primitives/ContextMenuItem.slint
T
vicrodh 065e6be7f4 feat(slint): playlist detail track menus 1:1 (remove, source routing, bulk parity)
Per-row Remove from playlist lands (danger styling, owner-gated by design
- Tauri renders it un-gated and lets the API reject; we port the intent,
commented) working across qobuz/local/plex rows through the namespace
split. Per-row Play next / Add to queue route by source: local rows
enqueue their snapshot QueueTrack instead of mis-parsing row ids as
catalog ids, and plex rows enqueue too (deliberate deviation from Tauri's
silent no-op - the machinery exists). Hero Play next/later of mixed
playlists merge the sidecar before enqueueing (Tauri T2 fix-forward: their
hero arms drop source and crash plex auto-advance). Bulk bar reaches
parity: select mode on followed playlists, source-aware bulk Play next /
Add to queue / Add to playlist (mixed selections send Qobuz rows to the
catalog picker, all-sidecar selections to the local picker), Remove stays
owner-only. The offline-cache action is now cache-state aware app-wide
(Make available / Refresh / Remove with a sequenced recache arm), and
Track info hides on this surface until the feature exists.

cc
2026-06-10 12:15:25 -06:00

75 lines
2.5 KiB
Plaintext

// One row of a context menu — an icon, a label, and a click callback.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { QbzIcon } from "QbzIcon.slint";
export component ContextMenuItem inherits Rectangle {
in property <image> icon;
in property <string> label;
// When false the row collapses to zero height and stops rendering /
// capturing input — lets a `for` build a filtered list without an
// inner `if` (which Slint does not allow as a direct `for` child).
in property <bool> shown: true;
// When false the row is muted and ignores clicks (a feature that exists
// but is not available yet, e.g. Mini / Immersive window modes).
in property <bool> enabled: true;
// Optional trailing check, for single-choice menus (the selected row).
in property <bool> selected: false;
// Destructive action (Remove from playlist / Remove offline copy) —
// red icon + label, mirroring Tauri's TrackMenu danger rows. Same red
// as the MultiSelectBar danger button.
in property <bool> danger: false;
callback clicked();
height: root.shown ? 33px : 0px;
visible: root.shown;
clip: true;
background: (ta.has-hover && root.enabled) ? Theme.surface-hover : transparent;
opacity: root.enabled ? 1.0 : 0.4;
HorizontalLayout {
padding-left: 11px;
padding-right: 16px;
spacing: 10px;
VerticalLayout {
alignment: center;
QbzIcon {
source: root.icon;
width: 15px;
height: 15px;
tint: root.danger
? #ef4444
: (ta.has-hover ? Theme.text-primary : Theme.text-secondary);
}
}
Text {
text: root.label;
color: root.danger
? #ef4444
: (ta.has-hover ? Theme.text-primary : Theme.text-secondary);
font-size: 13px;
vertical-alignment: center;
horizontal-stretch: 1;
}
if root.selected: VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/check.svg");
width: 14px;
height: 14px;
tint: Theme.accent;
}
}
}
ta := TouchArea {
mouse-cursor: root.enabled ? pointer : default;
clicked => {
if (root.enabled) {
root.clicked();
}
}
}
}