feat(qt): the miniplayer window, shell and the two display surfaces
Block B2 of the miniplayer/tray contract, and the block that settles the premise the whole port rests on: a second top-level Window in the same QQmlApplicationEngine reads the SAME bridge singletons as the shell. Proven by driving it — a probe window with one Text bound to QbzPlayer.npTitle tracked the main window across a track change with no mirror code. Slint needs ~155 lines of mirroring for this; Qt needs none. qml/miniplayer/ (new, six files) — MiniWindow (frameless, transparent, transientParent null, its own key host and its own onClosing), MiniShell (the card, the artwork backdrop, the surface router), MiniCoverArt and MiniExplicitBadge (the two components MiniBits.slint exports, which cannot share one .qml file), and the compact and artwork surfaces. The card is the window minus a 6 px gutter, its radius is 9 for the condensed surfaces and 10 otherwise, and switching the surface RESIZES THE WINDOW — 540 to 178 and back, driven and measured, not inferred. The backdrop lives inside a masked container. `clip: true` on a rounded Rectangle does NOT round its children on this Qt build — theme/RoundedImage.qml records that as measured fact — so without the mask the scrim and the atmosphere's own opaque root would paint square corners over the card the moment the backdrop is on. That is reachable before its toggle exists, because the pref is co-owned with the shipping Slint app. src/mini_bridge.rs — enter/exit, the mini's own key dispatcher, and toggle(). Re-entering an open mini re-raises it rather than doing nothing, which is what the reference does and what present() will want. src/hotkeys_qt.rs — action_for_mini_key, a SIBLING of action_for_key with the context arm inverted. The main window still refuses Context::Mini and the test that pins it is untouched; a new test pins the mirror. src/hotkeys_bridge.rs — the ui.miniPlayer arm stops logging and toggles. qml/shell/ViewModeMenu.qml — the Miniplayer row goes live with its own dispatch arm, and it is hidden under the kiosk profile, 1:1 with PlayerBarSmall.slint:819. The kiosk port landed first, so that gate was owed here. Three comments claiming the row is inert are corrected. Surfaces 0, 3 and 4 are clamped to the artwork surface until their content exists (B3 and B4), because mini_surface and mini_default_view live in the prefs file shared with the Slint app: a user whose Slint mini was last on Queue would otherwise open onto a blank card with no visible way out. Each block deletes its own entry from that clamp. Enter does not hide the main window yet — window.hideToTray() is B6's, and open-coding a bare hide() here is what the one-visibility-owner rule forbids. So the main window stays visible behind the mini in this commit, by design. cc
This commit is contained in:
13 files changed
+1025
-29
No files matched your search
@@ -0,0 +1,220 @@
|
||||
// MiniShell — the miniplayer CARD (2026-08-03 miniplayer/tray contract A-28,
|
||||
// §4.3.1), port of `crates/qbz-ui/ui/miniplayer/MiniShell.slint:15-65`.
|
||||
//
|
||||
// The card is the window minus the 6 px gutter, so every number here is
|
||||
// relative to it (§15 trap 3). It owns three things: the card chrome, the
|
||||
// optional artwork backdrop, and the surface router.
|
||||
//
|
||||
// The mini INHERITS the user's theme. The reference cannot — its only
|
||||
// SlintTheme writer takes &AppWindow (crates/qbz/src/theme.rs:96-103), so the
|
||||
// Slint miniplayer always renders the compiled-in Dark palette even for a user
|
||||
// on a light theme. Here QbzShell.themeJson is process-global and every
|
||||
// QbzTheme instance binds it, so reproducing that defect would take extra code
|
||||
// (§13-D16).
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import com.blitzfc.qbz
|
||||
import "../immersive"
|
||||
import "../theme"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
// §8 rule 3: the window, handed down explicitly by MiniWindow. Consumed by
|
||||
// the footer's drag handle and the hover capsule (B3), which call
|
||||
// startSystemMove() on it rather than walking a parent chain.
|
||||
property var hostWindow: null
|
||||
|
||||
// --- Cached per-mode values (§7-M2) ------------------------------------
|
||||
// The reference computes each of these ONCE into a named property
|
||||
// (MiniShell.slint:18, :23, :62). An always-visible surface pays a repeated
|
||||
// inline ternary on every frame, which is exactly what the perf doctrine
|
||||
// refuses.
|
||||
readonly property int surfaceId: QbzMini.surface
|
||||
|
||||
// The software-renderer arm, same detection as theme/RoundedImage.qml:223.
|
||||
// Offscreen forces software, so the masked backdrop below degrades to an
|
||||
// unmasked one there — which is exactly the environment the gate runs in
|
||||
// and never a user's.
|
||||
readonly property bool _noShaders: GraphicsInfo.api === GraphicsInfo.Software
|
||||
|
||||
// THE INVERSION (§15 trap 2). The footer's `mode` is numbered the OPPOSITE
|
||||
// way from the surface enum — 0 full · 1 compact · 2 micro
|
||||
// (MiniFooter.slint:212) against 0 micro · 1 compact · 2 artwork — so
|
||||
// surface 0 -> mode 2, 1 -> 1, 2/3/4 -> 0 (MiniShell.slint:17-18). Computed
|
||||
// here, once; MiniFooter (B3) mounts against it.
|
||||
readonly property int footerMode: root.surfaceId === 0
|
||||
? 2 : (root.surfaceId === 1 ? 1 : 0)
|
||||
|
||||
// MiniShell.slint:62, with ONE ruling applied: micro's 50 px binding inside
|
||||
// a 45 px clipped card becomes 45 (§13-D10). The micro content is 38 px
|
||||
// tall, so nothing is lost, and a 50 px child of a 45 px clip:true card is
|
||||
// not a shape worth reproducing.
|
||||
readonly property int footerHeight: root.surfaceId === 1
|
||||
? 64 : (root.surfaceId === 0 ? 45 : 80)
|
||||
|
||||
// EXPLICIT SOURCE — the one datum the mini needs that QbzPlayer does not
|
||||
// publish. Slint reads NowPlayingState.explicit; there is no np_explicit
|
||||
// (src/player_bridge.rs:31-122). The queue document's `current` row carries
|
||||
// the SAME datum (QueueTrack::parental_warning -> src/queue_qt.rs:47), so
|
||||
// this is the guarded try/catch + track-id guard of
|
||||
// qml/immersive/ImmersiveSongCard.qml:45-53 — the id guard is what keeps a
|
||||
// stale queue document from lending the PREVIOUS track's badge to this one.
|
||||
//
|
||||
// Derived ONCE here and passed DOWN to the surfaces as an explicit
|
||||
// property: both of them need it, and a second JSON.parse per queue publish
|
||||
// is precisely the per-frame work §7 exists to refuse. It is also §8's
|
||||
// rule 1 — the surfaces take a property, they do not read `parent`.
|
||||
readonly property bool npExplicit: {
|
||||
try {
|
||||
var d = JSON.parse(QbzQueue.queueJson)
|
||||
return !!(d && d.current && d.current.id === QbzPlayer.npTrackId
|
||||
&& d.current.explicit)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// --- Card chrome (MiniShell.slint:20-24) -------------------------------
|
||||
// #050506 stays a literal here because it is a literal there (§4.11): it is
|
||||
// the near-black the artwork backdrop is composed against, not a theme
|
||||
// surface.
|
||||
color: QbzMini.backgroundBlur ? "#050506" : theme.surfaceMain
|
||||
border.width: 1
|
||||
border.color: theme.alphaTier(10)
|
||||
// 9 px for micro + compact, 10 px otherwise (§15 trap 6).
|
||||
radius: root.surfaceId <= 1 ? 9 : 10
|
||||
antialiasing: true
|
||||
clip: true
|
||||
|
||||
// --- The backdrop, and why it needs a MASK ----------------------------
|
||||
// Both backdrop layers live inside ONE masked container.
|
||||
//
|
||||
// The card above sets `radius` + `clip: true`, and that is NOT enough:
|
||||
// **QML's clip is RECTANGULAR.** `qml/theme/RoundedImage.qml:3-6` states it
|
||||
// as measured fact on this exact Qt build — *"a Rectangle with radius +
|
||||
// clip: true does NOT clip children to the rounded shape (proven with an
|
||||
// isolated scene on this Qt build: the child paints square over the rounded
|
||||
// fill)"*. So without a mask the scrim, and the atmosphere's own opaque
|
||||
// `#0a0a0b` root (ImmersiveAtmosphere.qml:57-60), would both paint into the
|
||||
// four corner regions the card fill leaves transparent: the moment the
|
||||
// backdrop is switched on, the floating card stops being a rounded card and
|
||||
// becomes a hard-cornered rectangle with a rounded hairline inside it.
|
||||
//
|
||||
// This is reachable WITHOUT B3's toggle: `mini_background_blur` lives in
|
||||
// the ui_prefs.json that is CO-OWNED with the shipping Slint app
|
||||
// (mini_qt.rs's key table), so a user who enabled the backdrop over there
|
||||
// gets it on their first Qt mini open.
|
||||
//
|
||||
// ONE layer + ONE mask for the whole group, never one per child — the
|
||||
// tree's own idiom at `qml/shell/Sidebar.qml:1002-1013`. The 0.5/1.0 mask
|
||||
// pair is MEASURED, not defaulted; RoundedImage.qml:495-521 has the table
|
||||
// and the reason 0.0/0.0 collapses Qt's smoothstep to `step()`.
|
||||
Item {
|
||||
id: backdrop
|
||||
anchors.fill: parent
|
||||
visible: QbzMini.backgroundBlur
|
||||
clip: true
|
||||
layer.enabled: QbzMini.backgroundBlur && !root._noShaders
|
||||
layer.smooth: true
|
||||
layer.effect: MultiEffect {
|
||||
maskEnabled: true
|
||||
maskSource: backdropMask
|
||||
maskThresholdMin: 0.5
|
||||
maskSpreadAtMin: 1.0
|
||||
}
|
||||
|
||||
// Layer 1: the ambient field (MiniShell.slint:26-37). A conditional
|
||||
// MOUNT, not a `visible` flip: with the backdrop off there is no
|
||||
// ambient item at all, which is the point of §7-M11 — handing a 380 px
|
||||
// always-on-top window a continuously repainting shader surface is the
|
||||
// failure mode. A Loader with an INLINE sourceComponent keeps the type
|
||||
// (and therefore every property name below) checkable; nothing ever
|
||||
// reads `Loader.item`, which §8 rule 4 forbids.
|
||||
//
|
||||
// All four tuning values are passed EXPLICITLY. ImmersiveAtmosphere's
|
||||
// own defaults are animated:true / dim 0.15 / baseOpacity 0.95 /
|
||||
// warpOpacity 0.48 (ImmersiveAtmosphere.qml:36-41) and every one of
|
||||
// them is wrong for the mini.
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
active: QbzMini.backgroundBlur && QbzPlayer.npHasTrack
|
||||
sourceComponent: Component {
|
||||
ImmersiveAtmosphere {
|
||||
source: QbzImmersive.atmosphereUrl
|
||||
fallbackSource: QbzPlayer.npArtworkPath
|
||||
animated: false
|
||||
dim: 0.54
|
||||
baseOpacity: 0.72
|
||||
warpOpacity: 0.20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Layer 2: the scrim (MiniShell.slint:39-41). Gated on background-blur
|
||||
// ALONE — NOT on has-track, unlike the layer above it. That asymmetry
|
||||
// is the reference's and it is deliberate: with the backdrop on and no
|
||||
// track, the card is the flat scrim over #050506.
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#050506bf"
|
||||
}
|
||||
}
|
||||
|
||||
// The mask's own item. A layer renders even when its item is invisible —
|
||||
// that IS the mask idiom — so the gate is `backgroundBlur`, not `visible`,
|
||||
// and an ungated pair of layers would cost two FBOs on a card that usually
|
||||
// has the backdrop OFF.
|
||||
Item {
|
||||
id: backdropMask
|
||||
anchors.fill: parent
|
||||
visible: false
|
||||
layer.enabled: QbzMini.backgroundBlur && !root._noShaders
|
||||
layer.smooth: true
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: root.radius
|
||||
color: "#ffffff"
|
||||
}
|
||||
}
|
||||
|
||||
// --- The surface area (MiniShell.slint:43-55) --------------------------
|
||||
// Absent in micro, where the footer IS the card. Its height is the card
|
||||
// minus the footer, which is how §4.2's "surface-area H" column is
|
||||
// reproduced: 102 at compact, 448 at the 540-tall expanded default.
|
||||
//
|
||||
// MiniFooter mounts under it and arrives with B3; the space it will occupy
|
||||
// is reserved here, by footerHeight, because that reservation is what makes
|
||||
// the surface geometry above it correct in the first place.
|
||||
Item {
|
||||
id: surfaceArea
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
height: root.height - root.footerHeight
|
||||
visible: root.surfaceId !== 0
|
||||
clip: true
|
||||
|
||||
// The router: one gated Loader per surface, each with its own INLINE
|
||||
// component (§8 rule 4 — not one Loader with a `source` string, whose
|
||||
// item is an untyped QObject). MiniQueueSurface (3) and
|
||||
// MiniLyricsSurface (4) join it in B4.
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
active: root.surfaceId === 1
|
||||
sourceComponent: Component {
|
||||
MiniCompactSurface { npExplicit: root.npExplicit }
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
active: root.surfaceId === 2
|
||||
sourceComponent: Component {
|
||||
MiniArtworkSurface { npExplicit: root.npExplicit }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user