feat(qt): mixed playlists, page fade, category filter, per-context recents
Six parity fronts against the Slint/Tauri references, plus the applied-filters
tooltip the app never had.
MIXED PLAYLISTS — the bug. A mixed playlist is a QOBUZ playlist carrying local
and Plex rows through library.db's playlist_local_tracks / playlist_plex_tracks
sidecar tables. This port could WRITE those rows (the picker) and COUNT them
(the Playlist Manager badge), but playlist_qt::load built its rows exclusively
from the Qobuz API response, so a track added to a playlist never appeared on
the page it was added to. Two comments elsewhere claimed the merge already
happened; they were describing the reference. Ported literally:
read_sidecar_rows_blocking (healing + bulk Plex resolve) and interleave_rows
(absolute-slot claim, same-slot collisions all emit), merged in load, with the
merged queue adopted as the open-detail snapshot.
Routing had to split with it. local_playlist_qt::open_id() was the one
predicate for every action, and a mixed detail adopts that same snapshot — so
it now means "a local:<uuid> detail OR a mixed one", which is right for
play/shuffle/row-play and wrong for the writes. Remove and reorder route on the
new local_detail_open() instead; without that, removing a local row from a
Qobuz playlist wrote into the local-playlist repo, found nothing, and reported
success. Removal by source is a third arm: the Qobuz arm parses the display id
as a u64 playlist_track_id, and a local row's display id is a library.db rowid
in the same numeric space. Reorder is refused on a mixed detail for the same
collision, in Rust and in the view.
PAGE FADE. 300 ms OpacityAnimator on the mounted page, OutCubic, honouring
reduceMotion. Zero added latency: the router's Loader is synchronous, the UI
thread is frozen through the mount and no frame exists in which a fade-OUT
could be shown, so the page snaps transparent in the same turn as the rebuild
and only the reveal is animated. An Animator and not a NumberAnimation because
it runs on the render thread — measured 0.53 vs 0.11 of progress with the GUI
thread blocked — and not on the shared pulse because the pulse arrives on the
very thread the mount blocks.
The first cut faded a veil coloured from the pane, and that was wrong in a way
that only shows in the configuration the app actually runs in: AppShell paints
the pane surface-main@0.22 while the ambient background is on, so a veil at
full opacity covered 22% of the page and the fade read as a flicker. Fading the
page has no such failure mode and keeps the ambient art visible.
SPLASH COPY. The login screen was already 1:1 (18 msgids, verified by diff).
The splash was missing the legal disclaimer the reference pins to the bottom of
the screen, drew "QBZ" / "QOBUZ PLAYER" as bare literals (English in all eight
locales), and hardcoded the dark palette — black on the other 34 themes.
CATEGORY FILTER on the Home playlists rail. Slugs now travel per card and the
offered set comes from the same /discover/index response, so the filter is
client-side over the cached 40 with no extra request. The selection lives in
Rust because HomeView is destroyed on every navigation; the reference keeps its
own for the same reason. New trigger + popup, and a `leading` slot on
QbzSectionHeader to hang it off the title line.
APPLIED-FILTERS TOOLTIP. A third QbzTooltip mode taking [{group, values}],
below the control with an upward caret. Overflow is staged summary and never
scroll — the overlay is enabled:false by construction, so a scrollable tooltip
could not be scrolled. Wired where a filter is INVISIBLE (collapsed to a count
or a glyph): the genre chip in four hosts, the Home tags, the Local Library and
Purchases funnels, the Artist Scene genres.
RECENTS BY CONTEXT. QueueTrack already carried context_kind and exactly one
function threw it away: record_queue_track wrote both album histories on every
track start whatever the user had put on, so one 40-track playlist filled a
24-entry album rail with that playlist's contents. album_play_events gains an
additive context_kind column (the other frontend names its columns on insert,
so it writes '' and '' counts as an album — no history reinterpreted), plus a
new playlist_play_history.db and a "Recently Played Playlists" rail, default on.
A separate file rather than a field in recently_played.json, which is a
destructive round trip between frontends: serde drops what it does not know and
the next write puts the truncated object back.
ITEMS PER CAROUSEL, recovered from Tauri and never ported to Slint. It lives in
a NEW TABLE of discover_prefs.db, not in the prefs blob: to_json rebuilds the
object from the keys the running binary knows and save overwrites the whole
column, so a new key would survive only until the other build's next toggle.
Default is uncapped, i.e. today's behaviour.
Two DiscoverySectionId arms were added to the frozen Slint tree, obliged by the
shared enum's exhaustive matches — same two-line follow MostPlayedAlbums took.
Not verifiable here: compiling that crate pulls qbz-ui.
Also fixes two recommendations_qt tests that had been red since c02e7713d,
which turned the two Weekly rows into ordering slots that deliberately do not
self-hide while the assertions kept the pre-split behaviour. Verified by stash
that they fail without any of this change: the code was right, the tests stale.
Eight locales updated. Release build clean, offscreen smoke gate green,
qbz-qt 421/421 and qbz-app 215/215.
cc
This commit is contained in:
41 files changed
+2896
-96
No files matched your search
@@ -38,6 +38,37 @@ Rectangle {
|
||||
readonly property int count: (genreDoc.counts || {})[root.context] || 0
|
||||
readonly property bool active: root.count > 0
|
||||
|
||||
// APPLIED-FILTERS TOOLTIP. The selected genre NAMES are already on the wire
|
||||
// per context (`genre_filter_qt.rs` publishes `names`, expanded to include
|
||||
// tree descendants), so this surface costs nothing but the wiring — and
|
||||
// wiring it HERE gives it to all four hosts at once: Home/Discover, the two
|
||||
// browse pages and Library.
|
||||
//
|
||||
// `extraGroups` lets a host append the filters this button knows nothing
|
||||
// about (a search term, a sort, the source toggles) so one bubble answers
|
||||
// the whole toolbar instead of one control.
|
||||
property var extraGroups: []
|
||||
readonly property var genreNames: (genreDoc.names || {})[root.context] || []
|
||||
readonly property var summaryGroups: {
|
||||
var out = []
|
||||
if (root.genreNames.length > 0)
|
||||
out.push({
|
||||
group: QbzSession.tr("Genre", QbzSession.trRev),
|
||||
values: root.genreNames
|
||||
})
|
||||
var ex = root.extraGroups || []
|
||||
for (var i = 0; i < ex.length; i++)
|
||||
out.push(ex[i])
|
||||
return out
|
||||
}
|
||||
|
||||
QbzFilterTip {
|
||||
id: genreTip
|
||||
ownerKey: "genre-" + root.context
|
||||
anchor: root
|
||||
groups: root.summaryGroups
|
||||
}
|
||||
|
||||
width: genreRow.width
|
||||
height: btnHeight
|
||||
radius: 6
|
||||
@@ -94,5 +125,9 @@ Rectangle {
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.clicked()
|
||||
onEntered: genreTip.enter()
|
||||
onExited: genreTip.exit()
|
||||
// A click opens the genre popup right over the bubble; drop it first.
|
||||
onPressed: genreTip.exit()
|
||||
}
|
||||
}
|
||||
@@ -176,13 +176,68 @@ Item {
|
||||
font.weight: theme.weightMedium
|
||||
}
|
||||
|
||||
// --- Section list ---------------------------------------------
|
||||
// Explicit, content-derived height capped to what is left of the
|
||||
// panel; the Flickable scrolls past that.
|
||||
// --- Items per carousel ---------------------------------------
|
||||
// Recovered from Tauri (`HomeSettingsModal.svelte`), which let the
|
||||
// user cap how many items each carousel showed. It never reached
|
||||
// Slint — the discovery-v2 modal Slint was ported from only ever
|
||||
// modelled {id, enabled} — so Qt inherited the absence.
|
||||
//
|
||||
// GLOBAL, so it reads its own bridge property rather than the
|
||||
// per-tab document: `root.mine` gates the rows below on the tab
|
||||
// payload having landed, and this control must be usable before
|
||||
// that.
|
||||
Item {
|
||||
visible: root.tab !== "recommendations"
|
||||
width: parent.width
|
||||
height: Math.max(0, Math.min(listCol.height, root.height * 0.78 - 260))
|
||||
height: 34
|
||||
|
||||
Text {
|
||||
id: sizeLabel
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: QbzSession.tr("Items per carousel", QbzSession.trRev)
|
||||
color: theme.textMuted
|
||||
font.pixelSize: theme.fontBody
|
||||
}
|
||||
QbzSelect {
|
||||
anchors.left: sizeLabel.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
sm: true
|
||||
menuWidth: 140
|
||||
// Option ORDER is the contract with RAIL_SIZE_PRESETS in
|
||||
// qbz-app/src/settings/discover_prefs.rs — the bridge
|
||||
// publishes an index, not a count, so reordering these
|
||||
// silently changes what every stored value means. "All" is
|
||||
// the stored 0 and the default: it is what this page did
|
||||
// before the setting existed.
|
||||
options: [
|
||||
"10",
|
||||
"15",
|
||||
"20",
|
||||
"25",
|
||||
QbzSession.tr("All", QbzSession.trRev),
|
||||
]
|
||||
currentIndex: QbzHome.discoverRailSizeIndex
|
||||
onSelected: function (i) { QbzHome.discoverSetRailSize(i) }
|
||||
}
|
||||
}
|
||||
|
||||
// --- Section list ---------------------------------------------
|
||||
// Explicit, content-derived height capped to what is left of the
|
||||
// panel; the Flickable scrolls past that.
|
||||
//
|
||||
// The subtrahend is the FIXED-CHROME BUDGET (title + banner + count
|
||||
// + the size row + footer + margins), and it is load-bearing: the
|
||||
// panel clips (`clip: true` above), so a row added over this list
|
||||
// without raising the number does not overflow visibly — the last
|
||||
// sections and the Reset footer simply stop existing. It went
|
||||
// 260 -> 308 with the size row: 34 of row plus the column's 14 of
|
||||
// spacing.
|
||||
Item {
|
||||
visible: root.tab !== "recommendations"
|
||||
width: parent.width
|
||||
height: Math.max(0, Math.min(listCol.height, root.height * 0.78 - 308))
|
||||
clip: true
|
||||
Flickable {
|
||||
id: listFlick
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
// "Filter by category" trigger for the Home rail of Qobuz Playlists — port of
|
||||
// `crates/qbz-ui/ui/discover/PlaylistTagFilter.slint:66-118`.
|
||||
//
|
||||
// 220x30, radius 6, NO outline: the reference states the size contract
|
||||
// explicitly ("sm variant — matches QbzSelect { sm: true } used by the toolbar
|
||||
// selects: 30px tall, 6px radius, no outline"), so this is the small toolbar
|
||||
// control, not the 34px browse-header one that BrowseGenreButton draws.
|
||||
//
|
||||
// Extracted rather than inlined into HomeView for the reason BrowseGenreButton
|
||||
// states about itself: one control, drawn identically wherever it is mounted.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property int count: 0
|
||||
signal clicked()
|
||||
|
||||
// The selected tag NAMES, for the applied-filters tooltip. The host has
|
||||
// them (it holds the tag catalogue); this control only knows the count.
|
||||
property var selectedNames: []
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
width: 220
|
||||
height: 30
|
||||
radius: 6
|
||||
// Translucent at rest under the dynamic background, like every other chip
|
||||
// in this toolbar band (PlaylistTagFilter.slint:77).
|
||||
color: tagArea.containsMouse
|
||||
? theme.surfaceHover
|
||||
: (theme.ambientOn ? theme.surfaceElevatedA50 : theme.surfaceElevated)
|
||||
|
||||
QbzFilterTip {
|
||||
id: tagTip
|
||||
ownerKey: "home-playlist-tags"
|
||||
anchor: root
|
||||
groups: root.selectedNames.length > 0
|
||||
? [{ group: QbzSession.tr("Category", QbzSession.trRev),
|
||||
values: root.selectedNames }]
|
||||
: []
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 8
|
||||
|
||||
QbzIcon {
|
||||
name: "list-filter"
|
||||
width: 13
|
||||
height: 13
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
tintName: "muted"
|
||||
}
|
||||
Text {
|
||||
width: parent.width - 13 - 14 - 2 * parent.spacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.count > 0
|
||||
? QbzSession.tr("{} selected", QbzSession.trRev)
|
||||
.replace("{}", root.count)
|
||||
: QbzSession.tr("Filter by category", QbzSession.trRev)
|
||||
color: root.count > 0 ? theme.textPrimary : theme.textSecondary
|
||||
font.pixelSize: 13
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
QbzIcon {
|
||||
name: "chevron-down"
|
||||
width: 14
|
||||
height: 14
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
tintName: "muted"
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: tagArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.clicked()
|
||||
onEntered: tagTip.enter()
|
||||
onExited: tagTip.exit()
|
||||
onPressed: tagTip.exit()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
// Qobuz-Playlists category filter — the dropdown of the Home rail's
|
||||
// "Filter by category" trigger. Port of
|
||||
// `crates/qbz-ui/ui/discover/PlaylistTagFilter.slint:120-183`.
|
||||
//
|
||||
// The filter is CLIENT-side over the 40 cards already in hand: the tags ship in
|
||||
// the same /discover/index response as the playlists, so opening this costs no
|
||||
// request. The selection is a UNION (a card passes if it carries ANY selected
|
||||
// slug) and an empty selection shows everything.
|
||||
//
|
||||
// The selection lives in RUST (`home_qt::toggle_playlist_tag`), not in a
|
||||
// property here or on HomeView: this view is destroyed on every navigation, so
|
||||
// a QML-side selection would be forgotten the moment the user opened an album
|
||||
// and came back. Slint keeps it in `TAB_SECTIONS` for the same reason and says
|
||||
// so: "Client-side; survives a tab switch."
|
||||
//
|
||||
// ANCHORING. The trigger sits INSIDE the Home flickable, at a y that depends on
|
||||
// the scroll position and on the rail order the Discover configurator dictates,
|
||||
// so the fixed `anchorTop` of GenreFilterPopup is not available here. The
|
||||
// position is captured by `mapToItem` AT OPEN and stored as NUMBERS — never a
|
||||
// reference to the trigger — so a rebuilt rail cannot dangle under an open
|
||||
// popup. Same rule, same reason, as controls/QbzTooltip.qml:127-133.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// [{ slug, name }] — the offered set, from QbzHome.playlistTagsJson.
|
||||
property var tags: []
|
||||
// Selected slugs, from the same document.
|
||||
property var selected: []
|
||||
|
||||
readonly property bool opened: root._open
|
||||
property bool _open: false
|
||||
property real _x: 0
|
||||
property real _y: 0
|
||||
|
||||
signal toggled(string slug)
|
||||
signal cleared()
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
// 220 = the trigger's width (PlaylistTagFilter.slint:69), so the card lines
|
||||
// up under it exactly.
|
||||
readonly property int cardW: 220
|
||||
readonly property int rowH: 32
|
||||
readonly property int footerH: 32
|
||||
readonly property int listMax: 320
|
||||
readonly property real listH: Math.min(root.tags.length * root.rowH, root.listMax)
|
||||
readonly property real cardH: root.listH + root.footerH + 10
|
||||
|
||||
anchors.fill: parent
|
||||
visible: root._open
|
||||
z: 3000
|
||||
|
||||
function openAt(item) {
|
||||
if (!item)
|
||||
return
|
||||
var p = item.mapToItem(root, 0, 0)
|
||||
// 4px of air under the trigger (PlaylistTagFilter.slint:122), clamped
|
||||
// so the card never leaves the window.
|
||||
root._x = Math.max(8, Math.min(root.width - root.cardW - 8, p.x))
|
||||
root._y = Math.max(8, Math.min(root.height - root.cardH - 8,
|
||||
p.y + item.height + 4))
|
||||
root._open = true
|
||||
}
|
||||
function close() {
|
||||
root._open = false
|
||||
}
|
||||
function toggle(item) {
|
||||
if (root._open)
|
||||
root.close()
|
||||
else
|
||||
root.openAt(item)
|
||||
}
|
||||
|
||||
// Click-out backdrop. Declared FIRST so the card below covers it.
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.close()
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
x: Math.round(root._x)
|
||||
y: Math.round(root._y)
|
||||
width: root.cardW
|
||||
height: root.cardH
|
||||
color: theme.surfaceMain
|
||||
radius: theme.radiusSm
|
||||
border.width: 1
|
||||
border.color: theme.borderMuted
|
||||
clip: true
|
||||
|
||||
// Swallow clicks so the backdrop does not close the card.
|
||||
MouseArea { anchors.fill: parent }
|
||||
|
||||
Flickable {
|
||||
id: listFlick
|
||||
x: 0
|
||||
y: 5
|
||||
width: parent.width
|
||||
height: root.listH
|
||||
contentWidth: width
|
||||
contentHeight: listCol.height
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
clip: true
|
||||
|
||||
Column {
|
||||
id: listCol
|
||||
width: listFlick.width
|
||||
|
||||
Repeater {
|
||||
model: root.tags
|
||||
delegate: Rectangle {
|
||||
id: tagRow
|
||||
width: listCol.width
|
||||
height: root.rowH
|
||||
color: tagArea.containsMouse ? theme.surfaceHover : "transparent"
|
||||
|
||||
readonly property string slug: modelData.slug || ""
|
||||
readonly property bool picked:
|
||||
(root.selected || []).indexOf(tagRow.slug) >= 0
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 10
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 8
|
||||
|
||||
Rectangle {
|
||||
width: 16
|
||||
height: 16
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
radius: 4
|
||||
color: tagRow.picked ? theme.accent : "transparent"
|
||||
border.width: tagRow.picked ? 0 : 1.5
|
||||
border.color: theme.textMuted
|
||||
QbzIcon {
|
||||
anchors.centerIn: parent
|
||||
visible: tagRow.picked
|
||||
name: "check"
|
||||
width: 11
|
||||
height: 11
|
||||
// The reference hardcodes #ffffff
|
||||
// (PlaylistTagFilter.slint:43). This port
|
||||
// does not: white on a pale accent measures
|
||||
// under 2.6:1 on 16 of the 35 palettes, so
|
||||
// every check in this build takes the
|
||||
// measured selector instead.
|
||||
tintName: theme.accentGlyphTint
|
||||
}
|
||||
}
|
||||
Text {
|
||||
width: parent.width - 24 - parent.spacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.name || ""
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: 12
|
||||
font.weight: tagRow.picked ? theme.weightMedium
|
||||
: theme.weightRegular
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: tagArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.toggled(tagRow.slug)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "All categories" — clears the selection. Dimmed and inert when there
|
||||
// is nothing to clear (PlaylistTagFilter.slint:159-180).
|
||||
Item {
|
||||
width: parent.width
|
||||
height: root.footerH
|
||||
y: root.listH + 5
|
||||
opacity: (root.selected || []).length > 0 ? 1.0 : 0.5
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: QbzSession.tr("All categories", QbzSession.trRev)
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: 12
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: (root.selected || []).length > 0
|
||||
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: root.cleared()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Applied-filters tooltip trigger — the two-line wiring a filter control mounts
|
||||
// beside itself so hovering it says WHAT is currently filtered, not just that
|
||||
// something is.
|
||||
//
|
||||
// Non-visual. It writes the shell's `filterTipJson` channel
|
||||
// (`shell_bridge.rs`), which `AppShell.qml` feeds to the one `QbzTooltip`
|
||||
// overlay. That indirection is not ceremony: a funnel lives five levels inside
|
||||
// a view's toolbar and the overlay is a sibling of the whole shell, so a QML
|
||||
// `id` cannot reach it, and the art preview solved the identical problem the
|
||||
// identical way.
|
||||
//
|
||||
// THE HOST BUILDS `groups`, and there is no way around it: of the app's filter
|
||||
// surfaces roughly a third keep their state in QML properties and the rest in
|
||||
// Rust documents, so nothing here could read one source and be right. What this
|
||||
// does own is the CONTRACT — `[{ group: "<label>", values: ["…"] }]`, groups
|
||||
// with no values dropped, and an empty result meaning "show nothing", which
|
||||
// lets a control keep its ordinary one-line tooltip for the unfiltered case.
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// QbzFilterTip {
|
||||
// id: filterTip
|
||||
// ownerKey: "local-albums-filter"
|
||||
// anchor: funnelButton
|
||||
// groups: root.filterSummaryGroups
|
||||
// }
|
||||
// MouseArea {
|
||||
// hoverEnabled: true
|
||||
// onEntered: filterTip.enter()
|
||||
// onExited: filterTip.exit()
|
||||
// }
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
// Unique per surface. It is the race-safe owner id the overlay closes on,
|
||||
// so two funnels on one screen never blank each other's bubble.
|
||||
property string ownerKey: ""
|
||||
// The control the bubble points at.
|
||||
property Item anchor: null
|
||||
// [{ group: "Genre", values: ["Rock", "Jazz"] }, …]
|
||||
property var groups: []
|
||||
|
||||
width: 0
|
||||
height: 0
|
||||
visible: false
|
||||
|
||||
// True when there is actually something to say. Hosts read it to decide
|
||||
// whether to show their plain tooltip instead.
|
||||
readonly property bool hasSummary: {
|
||||
var gs = root.groups || []
|
||||
for (var i = 0; i < gs.length; i++) {
|
||||
var v = (gs[i] || {}).values || []
|
||||
if (v.length > 0)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function enter() {
|
||||
if (!root.anchor || !root.hasSummary)
|
||||
return
|
||||
// Scene coordinates: the overlay fills the window, so its coordinate
|
||||
// space and the scene's are the same. Captured as NUMBERS — the anchor
|
||||
// may be destroyed (a rebuilt view, a recycled delegate) while the
|
||||
// bubble is still up.
|
||||
var p = root.anchor.mapToItem(null, 0, 0)
|
||||
QbzShell.filterTipJson = JSON.stringify({
|
||||
key: root.ownerKey,
|
||||
x: p.x,
|
||||
y: p.y,
|
||||
w: root.anchor.width,
|
||||
h: root.anchor.height,
|
||||
groups: root.groups
|
||||
})
|
||||
}
|
||||
|
||||
function exit() {
|
||||
// Only clear if this control still owns the channel, so sliding from
|
||||
// one funnel straight onto another does not blank the new bubble.
|
||||
var d = {}
|
||||
try {
|
||||
d = JSON.parse(QbzShell.filterTipJson)
|
||||
} catch (e) {
|
||||
d = {}
|
||||
}
|
||||
if (d && d.key === root.ownerKey)
|
||||
QbzShell.filterTipJson = "{}"
|
||||
}
|
||||
|
||||
// A view being torn down under an open bubble must not leave it floating.
|
||||
Component.onDestruction: root.exit()
|
||||
}
|
||||
@@ -102,10 +102,28 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
/// Optional control mounted at the START of the right-hand row, i.e. LEFT
|
||||
/// of "View all" and the page chevrons. Added for the Qobuz-Playlists
|
||||
/// rail's category filter, which the reference puts on this very line
|
||||
/// (HomeView.slint:358-374).
|
||||
///
|
||||
/// A Component, not an Item: it is declared by the HOST, so it keeps the
|
||||
/// host's scope and can see the host's ids — and it is only instantiated
|
||||
/// where it is set. The `visible`/`active` gate keeps the thirteen existing
|
||||
/// instantiations pixel-identical, because `Row` skips invisible children
|
||||
/// and adds no spacing for them.
|
||||
property Component leading: null
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 4
|
||||
Loader {
|
||||
visible: root.leading !== null
|
||||
active: root.leading !== null
|
||||
sourceComponent: root.leading
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
// "View all" link/chip (accent = Search's, secondary = Home's).
|
||||
Rectangle {
|
||||
visible: root.showViewAll
|
||||
|
||||
@@ -43,6 +43,19 @@
|
||||
// 9/9/5/5 padding, 11px/medium text-primary, downward caret,
|
||||
// y = anchor.top - height - 9, centre clamped 8px from the
|
||||
// window edges with the caret still pointing at the control.
|
||||
// showSummary() APPLIED-FILTERS bubble — this port's own, no Slint twin.
|
||||
// Same machine, structured content: a list of {group, values}
|
||||
// instead of one string, laid out UNDER the control (filter
|
||||
// funnels live in toolbars, so the space is below them) with an
|
||||
// upward caret, flipping above when it would leave the window.
|
||||
// 10/10/8/8 padding, 6px between groups — one step up from the
|
||||
// one-line bubble and one step below a flyout's 14/12, which is
|
||||
// a DELIBERATE departure from the control-alignment standard
|
||||
// (that document sizes flyouts, and this is not one).
|
||||
// Group headers are 11px semibold text-muted rather than the
|
||||
// standard GroupHeader (ALL-CAPS 11px, letter-spacing 1.5):
|
||||
// inside an 11px bubble the tracked caps are unreadable.
|
||||
// Values are comma-separated TEXT, never chips — ADR-008.
|
||||
//
|
||||
// DELIBERATE DEVIATIONS FROM SLINT, both stated because they are visible:
|
||||
// - MAX WIDTH + ELISION. Neither Slint bubble caps its width; a 200-character
|
||||
@@ -61,6 +74,7 @@
|
||||
// against Slint's `drop-shadow-blur`, so it is deliberately NOT done here.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
@@ -79,7 +93,9 @@ Item {
|
||||
// never blanks it (Sidebar.slint:199-203).
|
||||
property string ownerKey: ""
|
||||
property string label: ""
|
||||
// 0 = right of the anchor (sidebar rail), 1 = above it (caret bubble).
|
||||
// 0 = right of the anchor (sidebar rail), 1 = above it (caret bubble),
|
||||
// 2 = below it (applied-filters summary, upward caret; flips to 1 when it
|
||||
// would fall off the bottom).
|
||||
property int placement: 0
|
||||
// Anchor rectangle, in THIS overlay's coordinates. Captured as plain
|
||||
// numbers on show — never a reference to the anchoring Item, so a recycled
|
||||
@@ -91,7 +107,52 @@ Item {
|
||||
// 0 disables the cap (Slint's own behaviour).
|
||||
property int maxWidth: 320
|
||||
|
||||
readonly property bool shown: ownerKey !== "" && label !== ""
|
||||
// ---- Summary mode -----------------------------------------------------
|
||||
// [{ group: "Genre", values: ["Rock", "Jazz"] }, …]. Empty = the classic
|
||||
// one-line bubble, so nothing about the sidebar changes.
|
||||
property var groups: []
|
||||
property int summaryMinWidth: 160
|
||||
|
||||
readonly property bool isSummary: root.placement === 2 && root._rows.length > 0
|
||||
readonly property bool shown: ownerKey !== ""
|
||||
&& (label !== "" || root.isSummary)
|
||||
|
||||
// OVERFLOW, and why there is no scrolling.
|
||||
//
|
||||
// A scrollable tooltip cannot be scrolled: this overlay is `enabled: false`
|
||||
// by construction (it must never take the pointer, or it steals the hover
|
||||
// that is keeping it open — see the header). So the rule for "too much
|
||||
// content" has to be SUMMARY, not scroll, and it is staged:
|
||||
// 1. at most 3 values per group, then "+N more";
|
||||
// 2. at most 5 groups, then one final "+N more filters" row;
|
||||
// 3. every row elides inside the fixed width;
|
||||
// 4. a hard width cap of min(maxWidth, 40% of the window), floor 160.
|
||||
// With those, the height cap is never the thing that truncates.
|
||||
readonly property int _maxValues: 3
|
||||
readonly property int _maxGroups: 5
|
||||
readonly property var _rows: {
|
||||
var gs = root.groups || []
|
||||
var out = []
|
||||
var n = Math.min(gs.length, root._maxGroups)
|
||||
for (var i = 0; i < n; i++) {
|
||||
var g = gs[i] || {}
|
||||
var vals = g.values || []
|
||||
if (vals.length === 0)
|
||||
continue
|
||||
var line = vals.slice(0, root._maxValues).join(", ")
|
||||
if (vals.length > root._maxValues)
|
||||
line += " " + QbzSession.tr("+{} more", QbzSession.trRev)
|
||||
.replace("{}", vals.length - root._maxValues)
|
||||
out.push({ head: g.group || "", body: line })
|
||||
}
|
||||
if (gs.length > root._maxGroups)
|
||||
out.push({
|
||||
head: "",
|
||||
body: QbzSession.tr("+{} more filters", QbzSession.trRev)
|
||||
.replace("{}", gs.length - root._maxGroups)
|
||||
})
|
||||
return out
|
||||
}
|
||||
|
||||
// ---- API --------------------------------------------------------------
|
||||
// `item` is any Item; its bounds are mapped into this overlay. `key` is the
|
||||
@@ -112,16 +173,48 @@ Item {
|
||||
root.label = text
|
||||
root.ownerKey = key
|
||||
}
|
||||
// The applied-filters bubble. `groups` is built by the HOST, not read from
|
||||
// a global: of the app's filter surfaces roughly a third keep their state
|
||||
// in QML and the rest in Rust documents, so there is no single source this
|
||||
// could read. Passing an empty (or all-empty) array is a no-op — a surface
|
||||
// with nothing applied shows its ordinary one-line tooltip instead.
|
||||
function showSummary(item, key, groups) {
|
||||
if (!item)
|
||||
return
|
||||
const p = item.mapToItem(root, 0, 0)
|
||||
root.showSummaryAt(key, p.x, p.y, item.width, item.height, groups)
|
||||
}
|
||||
// The same, from plain NUMBERS — the form the bridge channel uses, and the
|
||||
// honest one: this overlay has never wanted an Item, only a rectangle.
|
||||
function showSummaryAt(key, x, y, w, h, groups) {
|
||||
if (!groups || groups.length === 0)
|
||||
return
|
||||
root.groups = groups
|
||||
if (root._rows.length === 0) {
|
||||
root.groups = []
|
||||
return
|
||||
}
|
||||
root.anchorX = x
|
||||
root.anchorY = y
|
||||
root.anchorW = w
|
||||
root.anchorH = h
|
||||
root.label = ""
|
||||
root.placement = 2
|
||||
root.ownerKey = key
|
||||
}
|
||||
// Race-safe close: only the owner may clear the bubble.
|
||||
function hide(key) {
|
||||
if (root.ownerKey === key)
|
||||
if (root.ownerKey === key) {
|
||||
root.ownerKey = ""
|
||||
root.groups = []
|
||||
}
|
||||
}
|
||||
// Unconditional close — for the events that invalidate the anchor itself
|
||||
// (the sidebar leaving the mini state, a flyout taking the same slot, a
|
||||
// view change).
|
||||
function hideAll() {
|
||||
root.ownerKey = ""
|
||||
root.groups = []
|
||||
}
|
||||
|
||||
function _capture(item) {
|
||||
@@ -137,12 +230,22 @@ Item {
|
||||
// reads the Text's natural implicitWidth (NoWrap + ElideRight leaves
|
||||
// implicitWidth at the unelided width, so assigning the Text a narrower
|
||||
// width below is not a binding loop) and the cap only ever shrinks it.
|
||||
readonly property real padH: placement === 0 ? 10 : 9
|
||||
readonly property real padV: 5
|
||||
readonly property real bubbleW: Math.min(
|
||||
tipText.implicitWidth + 2 * padH,
|
||||
maxWidth > 0 ? maxWidth : Number.MAX_VALUE)
|
||||
readonly property real bubbleH: tipText.implicitHeight + 2 * padV
|
||||
readonly property real padH: root.isSummary ? 10 : (placement === 0 ? 10 : 9)
|
||||
readonly property real padV: root.isSummary ? 8 : 5
|
||||
// The width cap for the summary is tighter than the plain bubble's: 40% of
|
||||
// the window, so a wide screen does not get a 320px slab floating over a
|
||||
// toolbar, with a 160px floor so a one-word filter still reads as a bubble.
|
||||
readonly property real summaryCap: Math.max(
|
||||
root.summaryMinWidth,
|
||||
Math.min(maxWidth > 0 ? maxWidth : 320, root.width * 0.4))
|
||||
readonly property real bubbleW: root.isSummary
|
||||
? Math.max(root.summaryMinWidth,
|
||||
Math.min(sumMeasure.implicitWidth + 2 * padH, root.summaryCap))
|
||||
: Math.min(tipText.implicitWidth + 2 * padH,
|
||||
maxWidth > 0 ? maxWidth : Number.MAX_VALUE)
|
||||
readonly property real bubbleH: root.isSummary
|
||||
? sumCol.implicitHeight + 2 * padV
|
||||
: tipText.implicitHeight + 2 * padV
|
||||
|
||||
// Right placement (SidebarTooltip.slint:17-19): +6px off the row's right
|
||||
// edge, vertically centred on the row. Flips to the row's LEFT when the
|
||||
@@ -163,19 +266,32 @@ Item {
|
||||
Math.max(8, root.width - bubbleW - 8), aboveCx - bubbleW / 2))
|
||||
readonly property real aboveY: anchorY - bubbleH - 9
|
||||
|
||||
// Below placement (summary): 9px of air under the control, same horizontal
|
||||
// clamp as `above`. Flips ABOVE when the bubble would leave the bottom of
|
||||
// the window — a filter funnel near the foot of a short window is exactly
|
||||
// where a toolbar ends up on a laptop.
|
||||
readonly property real belowY: anchorY + anchorH + 9
|
||||
readonly property bool flipUp: root.isSummary
|
||||
&& (root.belowY + root.bubbleH > root.height - 8)
|
||||
&& (root.aboveY >= 8)
|
||||
// True when the caret points UP at a control above the bubble.
|
||||
readonly property bool caretUp: root.isSummary && !root.flipUp
|
||||
|
||||
// ---- The bubble -------------------------------------------------------
|
||||
Item {
|
||||
id: bubble
|
||||
visible: root.shown
|
||||
x: Math.round(root.placement === 0 ? root.rightX : root.aboveX)
|
||||
y: Math.round(root.placement === 0 ? root.rightY : root.aboveY)
|
||||
y: Math.round(root.placement === 0 ? root.rightY
|
||||
: root.isSummary ? (root.flipUp ? root.aboveY : root.belowY)
|
||||
: root.aboveY)
|
||||
width: Math.ceil(root.bubbleW)
|
||||
height: Math.ceil(root.bubbleH)
|
||||
|
||||
// Shadow approximation (see the header): one offset rect, same radius.
|
||||
Rectangle {
|
||||
x: 0
|
||||
y: root.placement === 0 ? 4 : 2
|
||||
y: root.placement === 0 ? 4 : (root.isSummary ? 3 : 2)
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
radius: root.placement === 0 ? theme.radiusSm : 4
|
||||
@@ -193,6 +309,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: tipText
|
||||
visible: !root.isSummary
|
||||
x: root.padH
|
||||
y: root.padV
|
||||
width: Math.max(0, parent.width - 2 * root.padH)
|
||||
@@ -204,6 +321,76 @@ Item {
|
||||
wrapMode: Text.NoWrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
// Summary body. Every row is NoWrap + elide, deliberately: with
|
||||
// `Text.Wrap` a Text's implicitWidth depends on the width assigned
|
||||
// to it, and `bubbleW` is computed FROM those implicit widths — a
|
||||
// binding loop. NoWrap keeps implicitWidth at the unelided width,
|
||||
// which is the same reason the one-line bubble above uses it. The
|
||||
// values are already capped to three plus a "+N more", so a row is
|
||||
// short by construction and the cap rarely bites.
|
||||
Column {
|
||||
id: sumCol
|
||||
visible: root.isSummary
|
||||
x: root.padH
|
||||
y: root.padV
|
||||
width: Math.max(0, parent.width - 2 * root.padH)
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: root.isSummary ? root._rows : []
|
||||
delegate: Column {
|
||||
width: sumCol.width
|
||||
spacing: 1
|
||||
Text {
|
||||
visible: (modelData.head || "") !== ""
|
||||
width: parent.width
|
||||
text: modelData.head || ""
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
wrapMode: Text.NoWrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
width: parent.width
|
||||
text: modelData.body || ""
|
||||
color: theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
wrapMode: Text.NoWrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Off-screen measuring pass. A Column's implicitWidth is the widest of
|
||||
// its children, and an UNASSIGNED Text's width is its implicitWidth —
|
||||
// so this reports the natural width of the widest row without any of
|
||||
// the visible rows influencing it. It only ever holds delegates while
|
||||
// the summary is up (`_rows` is empty otherwise), so at rest it costs
|
||||
// nothing.
|
||||
Column {
|
||||
id: sumMeasure
|
||||
visible: false
|
||||
spacing: 6
|
||||
Repeater {
|
||||
model: root.isSummary ? root._rows : []
|
||||
delegate: Column {
|
||||
spacing: 1
|
||||
Text {
|
||||
visible: (modelData.head || "") !== ""
|
||||
text: modelData.head || ""
|
||||
font.pixelSize: 11
|
||||
font.weight: theme.weightSemibold
|
||||
}
|
||||
Text {
|
||||
text: modelData.body || ""
|
||||
font.pixelSize: 11
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Downward caret, above-placement only. Slint draws a Path
|
||||
@@ -214,18 +401,22 @@ Item {
|
||||
// recycling; see theme/RoundedImage.qml).
|
||||
Canvas {
|
||||
id: caret
|
||||
visible: root.placement === 1
|
||||
visible: root.placement === 1 || root.isSummary
|
||||
width: 10
|
||||
height: 6
|
||||
x: Math.round(Math.max(4, Math.min(parent.width - width - 4,
|
||||
root.aboveCx - bubble.x - width / 2)))
|
||||
y: parent.height - 1
|
||||
y: root.caretUp ? -(height - 1) : parent.height - 1
|
||||
renderTarget: Canvas.Image
|
||||
renderStrategy: Canvas.Immediate
|
||||
// The fill has to follow the theme, and a Canvas does not repaint
|
||||
// on a colour binding by itself.
|
||||
property color fill: theme.surfaceElevated
|
||||
// The triangle points DOWN at a control below the bubble, and UP at
|
||||
// one above it. A Canvas repaints on neither of these by itself.
|
||||
property bool up: root.caretUp
|
||||
onFillChanged: caret.requestPaint()
|
||||
onUpChanged: caret.requestPaint()
|
||||
onVisibleChanged: if (visible) caret.requestPaint()
|
||||
onPaint: {
|
||||
var ctx = caret.getContext("2d")
|
||||
@@ -235,9 +426,15 @@ Item {
|
||||
ctx.clearRect(0, 0, caret.width, caret.height)
|
||||
ctx.fillStyle = caret.fill
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(0, 0)
|
||||
ctx.lineTo(caret.width / 2, caret.height)
|
||||
ctx.lineTo(caret.width, 0)
|
||||
if (caret.up) {
|
||||
ctx.moveTo(0, caret.height)
|
||||
ctx.lineTo(caret.width / 2, 0)
|
||||
ctx.lineTo(caret.width, caret.height)
|
||||
} else {
|
||||
ctx.moveTo(0, 0)
|
||||
ctx.lineTo(caret.width / 2, caret.height)
|
||||
ctx.lineTo(caret.width, 0)
|
||||
}
|
||||
ctx.closePath()
|
||||
ctx.fill()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user