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
@@ -313,6 +313,17 @@ fn main() {
|
||||
"qml/views/playlistmanager/PmToolbar.qml",
|
||||
"qml/views/playlistmanager/PmTreeFolderRow.qml",
|
||||
"qml/views/playlistmanager/PmTreePlaylistRow.qml",
|
||||
// Miniplayer (2026-08-03 miniplayer/tray-port contract §3.4) —
|
||||
// its own module directory, like immersive/ and kiosk/. B2
|
||||
// ships the window, the card shell and the two DISPLAY
|
||||
// surfaces; B3 adds the footer + capsule, B4 the queue and
|
||||
// lyrics surfaces.
|
||||
"qml/miniplayer/MiniWindow.qml",
|
||||
"qml/miniplayer/MiniShell.qml",
|
||||
"qml/miniplayer/MiniExplicitBadge.qml",
|
||||
"qml/miniplayer/MiniCoverArt.qml",
|
||||
"qml/miniplayer/MiniCompactSurface.qml",
|
||||
"qml/miniplayer/MiniArtworkSurface.qml",
|
||||
],
|
||||
qrc_files: &qrc_refs,
|
||||
..Default::default()
|
||||
|
||||
@@ -11,6 +11,7 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Window
|
||||
import com.blitzfc.qbz
|
||||
import "miniplayer"
|
||||
import "theme"
|
||||
|
||||
ApplicationWindow {
|
||||
@@ -461,6 +462,58 @@ ApplicationWindow {
|
||||
|
||||
|
||||
|
||||
// --- The miniplayer window (2026-08-03 miniplayer/tray contract, B2) ---
|
||||
//
|
||||
// LAZY, with a STRONG reference. Declaring the mini inline would build its
|
||||
// whole subtree at startup; a Component + createObject(null) is the Qt
|
||||
// shape of the reference's ensure_window() (crates/qbz/src/miniplayer.rs:
|
||||
// 121-151), and `miniWindow` is its MINI_STRONG thread-local (:40 "Strong
|
||||
// handle keeps the window alive", set :149, NEVER cleared — exit() and
|
||||
// close_app() only hide()). A null-parent createObject with no strong
|
||||
// reference is JS-GC eligible (contract §16 U-3), and this property is what
|
||||
// makes it not.
|
||||
//
|
||||
// Created on first ENTER, never on boot: the QML tree of a window that has
|
||||
// never been opened costs nothing.
|
||||
property var miniWindow: null
|
||||
Component {
|
||||
id: miniWindowComponent
|
||||
MiniWindow {}
|
||||
}
|
||||
function ensureMiniWindow() {
|
||||
if (window.miniWindow === null)
|
||||
window.miniWindow = miniWindowComponent.createObject(null)
|
||||
return window.miniWindow
|
||||
}
|
||||
|
||||
// `QbzMini.open` is the ONE mini lifecycle flag (contract A-2): Rust's
|
||||
// enter/exit funnel writes it, stores the AtomicBool mirror the hotkeys
|
||||
// pipeline reads, and THEN notifies — so this handler is the QML half of
|
||||
// §4.6's step ordering and the only place either window is shown or hidden
|
||||
// for the miniplayer.
|
||||
//
|
||||
// Step 7 of enter() ("m.hide() LAST, avoid a blank flash") and its exit
|
||||
// twin are window.hideToTray() / window.showFromTray() (A-25), which land
|
||||
// with block B6 — so on this commit the mini opens with the main window
|
||||
// still visible behind it. That is §14.2's stated ordering constraint, not
|
||||
// a defect: a bare window.hide() here would be a second visibility owner
|
||||
// and §5.8.1's invariant (stage-0 S0-4) forbids it.
|
||||
Connections {
|
||||
target: QbzMini
|
||||
function onOpenChanged() {
|
||||
if (QbzMini.open) {
|
||||
var mini = window.ensureMiniWindow()
|
||||
if (mini !== null) {
|
||||
mini.show()
|
||||
mini.raise()
|
||||
mini.requestActivate()
|
||||
}
|
||||
} else if (window.miniWindow !== null) {
|
||||
window.miniWindow.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The immersive toggle Shortcut is GONE (2026-08-03 hotkeys-port §1.3):
|
||||
// Shift+I now fires as the REBINDABLE ui.focusMode action through the
|
||||
// AppShell dispatcher (QbzHotkeys.keyPressed), whose central text-input
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// MiniArtworkSurface — surface 2, THE DEFAULT (2026-08-03 miniplayer/tray
|
||||
// contract §4.2.2), port of
|
||||
// `crates/qbz-ui/ui/miniplayer/MiniArtworkSurface.slint` (73 L, read whole).
|
||||
//
|
||||
// A large centred cover over centred metadata, in the resizable expanded
|
||||
// window. DISPLAY ONLY.
|
||||
//
|
||||
// DEFERRED POLISH, REPRODUCED 1:1: the Tauri build ran a hover-triggered
|
||||
// marquee per overflowing text line; this elides, exactly as the reference does
|
||||
// and for the reason its own header records (:4-6). Do not add the marquee here
|
||||
// before it lands there.
|
||||
//
|
||||
// Where compact falls back to a "—" string, this surface uses CONDITIONAL
|
||||
// MOUNTS: an empty artist or album makes the row disappear and the Column's
|
||||
// 2 px spacing collapse with it. In a QML Column an invisible child is skipped
|
||||
// along with its spacing, so `visible:` is the exact equivalent of Slint's
|
||||
// `if artist != "":`.
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
/// Handed down by MiniShell (see MiniCompactSurface for why it is a
|
||||
/// property and not a `parent` read).
|
||||
property bool npExplicit: false
|
||||
|
||||
// Max 320, 1:1, shrinking with the resizable window: the card is 40 px
|
||||
// wider than the cover at the padding, so this is 320 at the 368 px card
|
||||
// and 288 at the 340 px minimum width (:14). Cached, per §7-M2.
|
||||
readonly property int coverSize: Math.min(root.width - 40, 320)
|
||||
|
||||
// VerticalLayout { padding-left/right 20; padding-top 16;
|
||||
// padding-bottom 12; spacing 12; alignment: center }
|
||||
// (:16-24). `alignment: center` centres the content inside the PADDED box,
|
||||
// and that box is asymmetric (16 above, 12 below), so the stack sits 2 px
|
||||
// below the item's own centre. Written out rather than anchored to
|
||||
// verticalCenter so the asymmetry is visible instead of accidental.
|
||||
Column {
|
||||
id: stack
|
||||
x: 20
|
||||
width: root.width - 40
|
||||
y: 16 + Math.max(0, (root.height - 28 - stack.height) / 2)
|
||||
spacing: 12
|
||||
|
||||
// HorizontalLayout { alignment: center } (:26-27).
|
||||
Item {
|
||||
width: stack.width
|
||||
height: root.coverSize
|
||||
MiniCoverArt {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: root.coverSize
|
||||
height: root.coverSize
|
||||
// Overrides the 7 px default (:30).
|
||||
radius: 10
|
||||
source: QbzPlayer.npArtworkPath
|
||||
}
|
||||
}
|
||||
|
||||
// The meta block: VerticalLayout { spacing: 2px } — note it carries NO
|
||||
// `alignment`, unlike compact's (:37-38). Each row centres itself.
|
||||
Column {
|
||||
width: stack.width
|
||||
spacing: 2
|
||||
|
||||
// Title + badge row, spacing 5, title at stretch 1 (:40-53). The
|
||||
// title is centred WITHIN its stretched box while the badge sits at
|
||||
// the row's right edge — that is what the reference's layout does,
|
||||
// not an approximation of it.
|
||||
Item {
|
||||
width: parent.width
|
||||
height: title.implicitHeight
|
||||
|
||||
Text {
|
||||
id: title
|
||||
anchors.left: parent.left
|
||||
width: parent.width - (badge.visible ? badge.width + 5 : 0)
|
||||
text: QbzPlayer.npHasTrack
|
||||
? QbzPlayer.npTitle
|
||||
: QbzSession.tr("No track playing", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: 13
|
||||
font.weight: Font.DemiBold
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
MiniExplicitBadge {
|
||||
id: badge
|
||||
visible: root.npExplicit
|
||||
anchors.left: title.right
|
||||
anchors.leftMargin: 5
|
||||
anchors.verticalCenter: title.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
// CONDITIONAL (:56-62) — the row disappears when empty, and there
|
||||
// is no fallback string anywhere on this surface.
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: QbzPlayer.npArtist !== ""
|
||||
text: QbzPlayer.npArtist
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 12
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
// CONDITIONAL (:64-70), and it exists ONLY on this surface —
|
||||
// compact has no album line at all. alphaTier(55), NOT textMuted.
|
||||
Text {
|
||||
width: parent.width
|
||||
visible: QbzPlayer.npAlbum !== ""
|
||||
text: QbzPlayer.npAlbum
|
||||
color: theme.alphaTier(55)
|
||||
font.pixelSize: 12
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
// MiniCompactSurface — surface 1 (2026-08-03 miniplayer/tray contract §4.2.1),
|
||||
// port of `crates/qbz-ui/ui/miniplayer/MiniCompactSurface.slint` (57 L, read
|
||||
// whole).
|
||||
//
|
||||
// A horizontal metadata strip in the 380x178 window. DISPLAY ONLY: no
|
||||
// controls, no IPC, no marquee — long text ellipsis-truncates
|
||||
// (MiniCompactSurface.slint:1-3). No album line, no hover, no click target, no
|
||||
// context menu. Everything interactive lives in the footer.
|
||||
//
|
||||
// The one divergence from its artwork twin, and it is the reference's: the
|
||||
// artist line here is ALWAYS mounted with a "—" fallback, where
|
||||
// MiniArtworkSurface drops the row entirely. Reproduced exactly (§4.2.2).
|
||||
|
||||
import QtQuick
|
||||
import com.blitzfc.qbz
|
||||
import "../theme"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
/// Handed down by MiniShell, which derives it once from the queue
|
||||
/// document — QbzPlayer publishes no np_explicit (§8 rule 1: an explicit
|
||||
/// property, never a `parent` read).
|
||||
property bool npExplicit: false
|
||||
|
||||
// The cover is square: the surface height minus the 12 px padding on both
|
||||
// sides, floored at 40 (MiniCompactSurface.slint:11) -> 78 px at the 102 px
|
||||
// surface. Cached, per §7-M2.
|
||||
readonly property int art: Math.max(40, root.height - 24)
|
||||
|
||||
// HorizontalLayout { padding: 12px; spacing: 12px; alignment: start }
|
||||
// (:13-18), expressed as anchors: `alignment: start` means the cover leads
|
||||
// and the text block takes the rest, which is what the anchor chain below
|
||||
// does without a layout item in between.
|
||||
MiniCoverArt {
|
||||
id: cover
|
||||
x: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: root.art
|
||||
height: root.art
|
||||
// Overrides the 7 px default (:23).
|
||||
radius: 8
|
||||
source: QbzPlayer.npArtworkPath
|
||||
}
|
||||
|
||||
Column {
|
||||
id: meta
|
||||
anchors.left: cover.right
|
||||
anchors.leftMargin: 12
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
// VerticalLayout { alignment: center; spacing: 2px } (:29-31).
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
|
||||
// Title + badge row: HorizontalLayout { spacing: 5px } with the title
|
||||
// at stretch 1 and the badge at stretch 0 (:33-46) — so the badge sits
|
||||
// 5 px after the title's BOX, at the right edge, not flush against the
|
||||
// glyphs.
|
||||
Item {
|
||||
id: titleRow
|
||||
width: meta.width
|
||||
height: title.implicitHeight
|
||||
|
||||
Text {
|
||||
id: title
|
||||
anchors.left: parent.left
|
||||
// badge.width is the constant 13, so this is not a loop.
|
||||
width: parent.width - (badge.visible ? badge.width + 5 : 0)
|
||||
text: QbzPlayer.npHasTrack
|
||||
? QbzPlayer.npTitle
|
||||
: QbzSession.tr("No track playing", QbzSession.trRev)
|
||||
color: theme.textPrimary
|
||||
font.pixelSize: 13
|
||||
font.weight: Font.DemiBold
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
MiniExplicitBadge {
|
||||
id: badge
|
||||
visible: root.npExplicit
|
||||
anchors.left: title.right
|
||||
anchors.leftMargin: 5
|
||||
anchors.verticalCenter: title.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
// ALWAYS mounted, with a literal em-dash fallback (:49-54) — NOT
|
||||
// translated, and NOT the conditional mount the artwork surface uses.
|
||||
Text {
|
||||
width: meta.width
|
||||
text: QbzPlayer.npArtist !== "" ? QbzPlayer.npArtist : "—"
|
||||
color: theme.textMuted
|
||||
font.pixelSize: 11
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// MiniCoverArt — the mini's cover tile (2026-08-03 miniplayer/tray contract
|
||||
// A-28, §4.2.3), port of `CoverArt` at
|
||||
// `crates/qbz-ui/ui/miniplayer/MiniBits.slint:28-44`. The other half of the
|
||||
// MiniBits split; see MiniExplicitBadge.qml.
|
||||
//
|
||||
// THE PLACEHOLDER IS THE BACKGROUND SHOWING THROUGH AN EMPTY IMAGE — no icon,
|
||||
// no glyph, no skeleton (MiniBits.slint:25-27). RoundedImage renders nothing
|
||||
// while `source` is empty, so the tinted fill and its 1 px border are the
|
||||
// empty state, exactly as the reference's bordered empty-art box is.
|
||||
//
|
||||
// `radius` is Rectangle's OWN property, defaulted to 7 here rather than
|
||||
// redeclared: Slint's `in property <length> radius: 7px` and a QML
|
||||
// `property real radius` on a Rectangle root are the same knob, and shadowing
|
||||
// it would be a property-override. The default is never actually used — the
|
||||
// two call sites pass 8 (compact) and 10 (artwork).
|
||||
//
|
||||
// RoundedImage's DEFAULT arm is the one that matters here (§7-M3): Image +
|
||||
// layer + a MultiEffect masked by a rounded Rectangle, whose FBOs are pure
|
||||
// functions of (width, height, radius), so a static cover costs zero CPU raster
|
||||
// and zero texture upload per frame. The mini's cover does not change between
|
||||
// frames — it is the clearest "static content, cache it" case in the app. Do
|
||||
// not reach for the Canvas arm.
|
||||
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
/// A file:// path from the artwork pipeline (QbzPlayer.npArtworkPath), not
|
||||
/// an image object — the Qt component takes URL strings where the Slint one
|
||||
/// takes `image`.
|
||||
property string source: ""
|
||||
|
||||
radius: 7
|
||||
antialiasing: true
|
||||
color: theme.alphaTier(8)
|
||||
border.width: 1
|
||||
border.color: theme.alphaTier(12)
|
||||
clip: true
|
||||
|
||||
RoundedImage {
|
||||
anchors.fill: parent
|
||||
source: root.source
|
||||
radius: root.radius
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// MiniExplicitBadge — the mini's parental-advisory chip (2026-08-03
|
||||
// miniplayer/tray contract A-28, §4.2.3), port of `ExplicitBadge` at
|
||||
// `crates/qbz-ui/ui/miniplayer/MiniBits.slint:9-23`.
|
||||
//
|
||||
// `MiniBits.slint` exports TWO components (ExplicitBadge :9, CoverArt :28) and
|
||||
// a QML file declares exactly one root type, so the pair is split — this file
|
||||
// and MiniCoverArt.qml (§15 trap 32).
|
||||
//
|
||||
// The glyph is a STYLED LETTER, not the official explicit.svg mask the Tauri
|
||||
// build rendered at 13x13 / opacity 0.45. That is a deliberate divergence the
|
||||
// reference records at MiniBits.slint:5-8 for app consistency, and it is
|
||||
// REPRODUCED here rather than "fixed" back to the SVG.
|
||||
//
|
||||
// Takes NO properties — every call site mounts it bare.
|
||||
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
QbzTheme { id: theme }
|
||||
|
||||
width: 13
|
||||
height: 13
|
||||
radius: 3
|
||||
antialiasing: true
|
||||
color: theme.alphaTier(12)
|
||||
|
||||
Text {
|
||||
anchors.fill: parent
|
||||
// Literal, never translated (MiniBits.slint:16).
|
||||
text: "E"
|
||||
color: theme.alphaTier(55)
|
||||
font.pixelSize: 8
|
||||
font.weight: Font.DemiBold
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// MiniWindow — the miniplayer's top-level window (2026-08-03 miniplayer/tray
|
||||
// contract A-27, §4.1), port of `crates/qbz-ui/ui/app.slint:282-305`.
|
||||
//
|
||||
// A SECOND top-level Window in the SAME QQmlApplicationEngine, created lazily
|
||||
// by Main.qml. That route is what deletes the reference's whole mirror layer:
|
||||
// Slint globals are per-component-tree, so `crates/qbz/src/miniplayer.rs`
|
||||
// copies 39 NowPlayingState scalars on every 450 ms tick; a Qt #[qml_singleton]
|
||||
// is one object per engine, so this window reads the SAME QbzPlayer / QbzQueue /
|
||||
// QbzLyrics / QbzShell the shell reads. MEASURED, not assumed (contract §16
|
||||
// U-1): the probe build showed one Text bound to QbzPlayer.npTitle following
|
||||
// the main window across a track change with no mirror code at all.
|
||||
//
|
||||
// The window is TRANSPARENT and the visible card is inset by a 6 px gutter, so
|
||||
// every geometry number in §4.2-§4.5 is relative to the CARD, not to the
|
||||
// window (§15 trap 3).
|
||||
//
|
||||
// NOT ported: the reference's CREATING_MINI double-latch
|
||||
// (miniplayer.rs:128-130, :166-169). It exists because a winit surface may be
|
||||
// created lazily on set_size/show() and a global attributes hook has to see the
|
||||
// flag; in Qt `flags` is declarative and applies at creation (§4.1).
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Window
|
||||
import com.blitzfc.qbz
|
||||
|
||||
Window {
|
||||
id: root
|
||||
|
||||
// §15 trap 1, and it is the one that would bite hardest: a Window declared
|
||||
// inside another Window is auto-parented (QQuickWindowQmlImpl carries
|
||||
// `updateTransientParent`), and a transient child is tied to its parent's
|
||||
// mapping by compositor policy — while hiding the main window is the LAST
|
||||
// step of enter() (§4.6). Explicitly null, never inherited.
|
||||
transientParent: null
|
||||
|
||||
// Borderless, 1:1 with `no-frame: true` (app.slint:293).
|
||||
//
|
||||
// Always-on-top is owner ruling K1 and defaults ON, but its property
|
||||
// (QbzMini.alwaysOnTop, A-5) and the pin button that toggles it are block
|
||||
// B3's; B3 adds the `| (QbzMini.alwaysOnTop ? Qt.WindowStaysOnTopHint : 0)`
|
||||
// term to this expression. Naming a property that does not exist would be
|
||||
// the L1 failure this contract's symbol rule exists to prevent.
|
||||
flags: Qt.Window | Qt.FramelessWindowHint
|
||||
|
||||
// Literal, never translated (app.slint:283 uses a plain string, not @tr).
|
||||
title: "QBZ Mini Player"
|
||||
|
||||
// Per-window alpha buffer: QQuickWindow::setColor requests it natively
|
||||
// (§3.1). The Slint side needs a vendored femtovg fork for the same effect.
|
||||
color: "transparent"
|
||||
|
||||
// --- Geometry (§4.2). Every per-mode value is CACHED into a named
|
||||
// readonly property, never a ternary repeated per binding (§7-M2): this is
|
||||
// a permanently-visible surface and cost per frame scales with the number
|
||||
// of live bindings, not with area.
|
||||
//
|
||||
// Switching the surface RESIZES THE WINDOW and moves its min-height floor
|
||||
// with it (§15 trap 5) — these are plain bindings on QbzMini.surface, so
|
||||
// that happens by construction. A WM-driven resize writes width/height from
|
||||
// C++, which does not disturb a binding (the same property Main.qml:32-35
|
||||
// relies on).
|
||||
//
|
||||
// ⚠ OPEN, and it is an OWNER-SMOKE item, not a known-good: `height` and
|
||||
// `minimumHeight` are sibling bindings re-evaluated off the same
|
||||
// `surfaceId` change, and QML gives no guaranteed delivery ORDER between
|
||||
// them. On a SHRINK — artwork (540, floor 420) to compact (178, floor 170)
|
||||
// — a `height` that lands while the OLD floor is still in force is a
|
||||
// request qtwayland clamps to the current minimum, and Qt's later min/max
|
||||
// update only ever expands the current size. The card would stay stuck at
|
||||
// 420 px showing a 178 px layout.
|
||||
//
|
||||
// **It is left declarative on purpose.** The obvious fix — lower the floor
|
||||
// imperatively, then assign the size — was written and MEASURED to break
|
||||
// the resize outright on this platform: breaking the two bindings left the
|
||||
// window at its old height with the new surface's layout inside it. The
|
||||
// declarative form is what RFB shows working (540 -> 178 -> 540, measured).
|
||||
// RFB cannot settle the Wayland question either way: the VNC platform
|
||||
// enforces no size constraints at all, which is exactly why the shrink
|
||||
// measures clean there. If the owner's smoke shows the compact card
|
||||
// refusing to shrink, THAT is this note, and the fix needs a real
|
||||
// compositor to develop against.
|
||||
readonly property int surfaceId: QbzMini.surface
|
||||
readonly property bool expanded: root.surfaceId >= 2
|
||||
// The expanded size is the PERSISTED one, exposed by the bridge because
|
||||
// Rust cannot reach a QQuickWindow (A-6b). The reference reads the same two
|
||||
// prefs on every geometry apply (miniplayer.rs:404).
|
||||
readonly property int winWidth: root.expanded ? Math.max(QbzMini.miniWidth, 340) : 380
|
||||
readonly property int winHeight: root.expanded
|
||||
? Math.max(QbzMini.miniHeight, 420)
|
||||
: (root.surfaceId === 0 ? 57 : 178)
|
||||
// The ONLY floor that moves. Min WIDTH is 340 in every surface
|
||||
// (miniplayer.rs:408-411).
|
||||
readonly property int winMinHeight: root.expanded ? 420 : (root.surfaceId === 0 ? 57 : 170)
|
||||
|
||||
width: root.winWidth
|
||||
height: root.winHeight
|
||||
minimumWidth: 340
|
||||
minimumHeight: root.winMinHeight
|
||||
|
||||
// A compositor close (Alt+F4, a panel's close entry) behaves EXACTLY like
|
||||
// the capsule's expand button — §13-D13, and it closes a hole the reference
|
||||
// has: Slint has no on_close_requested on the mini, so its default
|
||||
// HideWindow leaves OPEN true, the main window hidden and the app alive but
|
||||
// invisible. Accepting the event is also what would arm Qt's quit check
|
||||
// (§3.1), so `accepted = false` is load-bearing twice.
|
||||
onClosing: function (close) {
|
||||
close.accepted = false
|
||||
QbzMini.exit()
|
||||
}
|
||||
|
||||
// --- The key host (§4.9, A-15) ----------------------------------------
|
||||
// BOTH halves are required. Qt delivers key events only to activeFocusItem
|
||||
// and propagates up its parent chain, so a tree with no focus item receives
|
||||
// nothing; and `focus: true` ALONE did not survive in a WM-less (VNC)
|
||||
// session — measured on AppShell (qml/shell/AppShell.qml:75-81), where the
|
||||
// dispatcher got nothing until the first click. The idiom is that file's
|
||||
// :72 / :81 / :91-97.
|
||||
//
|
||||
// NOTHING is handled locally: the ordered table lives in Rust behind
|
||||
// QbzMini.keyPressed, which resolves through hotkeys_qt::action_for_mini_key
|
||||
// (A-16) over the user's ACTIVE bindings. No text-input gate is computed
|
||||
// here because the mini has no text fields, exactly as the reference's
|
||||
// dispatch_mini has no such guard (crates/qbz/src/keybindings.rs:623-648).
|
||||
Item {
|
||||
id: keyHost
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
Component.onCompleted: keyHost.forceActiveFocus()
|
||||
Keys.onPressed: function (event) {
|
||||
event.accepted = QbzMini.keyPressed(event.key, event.modifiers, event.text)
|
||||
}
|
||||
|
||||
// The card: window MINUS 12 px in both axes, a 6 px transparent gutter
|
||||
// (app.slint:299-304). §15 trap 3.
|
||||
MiniShell {
|
||||
id: card
|
||||
x: 6
|
||||
y: 6
|
||||
width: root.width - 12
|
||||
height: root.height - 12
|
||||
// §8 rule 3: children reach the window through THIS explicit
|
||||
// reference, never through parent.parent — a chain qmllint cannot
|
||||
// verify. Same seam as Main.qml -> AppShell.hostWindow. The footer's
|
||||
// drag handle and the capsule (B3) are its consumers.
|
||||
hostWindow: root
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
// Now-Playing-view mode menu (PlayerBar.slint layout-menu, phase 18) —
|
||||
// one QbzContextMenu shared by the full PlayerBar and the Small bar:
|
||||
// New / Classic / Small / Large (with the current mode checked), then the
|
||||
// window-mode rows. Immersive is LIVE (2026-08-02 immersive-port §7, B2);
|
||||
// Miniplayer / Kiosk stay inert (kiosk goes live in the kiosk contract §8).
|
||||
// window-mode rows. All three window-mode rows are LIVE: Immersive since the
|
||||
// 2026-08-02 immersive-port §7 B2, Kiosk since the 2026-08-02 kiosk-port §8.1,
|
||||
// Miniplayer since the 2026-08-03 miniplayer/tray-port §4.10 B2.
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
@@ -81,8 +82,8 @@ QbzContextMenu {
|
||||
}
|
||||
}
|
||||
|
||||
// Divider + the window-mode rows (Miniplayer / Immersive / Kiosk).
|
||||
// Immersive is live (below); the other two stay inert.
|
||||
// Divider + the window-mode rows (Miniplayer / Immersive / Kiosk), all
|
||||
// three live.
|
||||
Item {
|
||||
width: parent ? parent.width : 0
|
||||
height: 7
|
||||
@@ -97,8 +98,8 @@ QbzContextMenu {
|
||||
Repeater {
|
||||
// Window-mode rows. `live` flips per-row inside the shared delegate
|
||||
// (2026-08-02 immersive-port §7); Immersive went live in that
|
||||
// contract's B2, Kiosk in the 2026-08-02-kiosk-port §8.1. Miniplayer
|
||||
// remains the one inert row (sanctioned, kiosk contract §9.2).
|
||||
// contract's B2, Kiosk in the 2026-08-02-kiosk-port §8.1, Miniplayer
|
||||
// in the 2026-08-03 miniplayer/tray-port §4.10 B2.
|
||||
//
|
||||
// Each row carries its own `action` because the delegate's MouseArea
|
||||
// used to call QbzImmersive.openFromMenu() unconditionally: flipping
|
||||
@@ -107,14 +108,30 @@ QbzContextMenu {
|
||||
// The Kiosk label mirrors the profile, 1:1 with the reference
|
||||
// (`shell/PlayerBar.slint:797`): in kiosk it reads "Desktop mode",
|
||||
// because the row is the way back out.
|
||||
model: [
|
||||
{ "label": QbzSession.tr("Miniplayer", QbzSession.trRev), "icon": "picture-in-picture-2", "live": false, "action": "miniplayer" },
|
||||
{ "label": QbzSession.tr("Immersive", QbzSession.trRev), "icon": "maximize-2", "live": true, "action": "immersive" },
|
||||
{ "label": QbzShell.kioskProfile
|
||||
? QbzSession.tr("Desktop mode", QbzSession.trRev)
|
||||
: QbzSession.tr("Kiosk mode", QbzSession.trRev),
|
||||
"icon": "hard-drive", "live": true, "action": "kiosk" },
|
||||
]
|
||||
//
|
||||
// THE MINIPLAYER ROW IS ABSENT UNDER THE KIOSK PROFILE, not dimmed —
|
||||
// 1:1 with `crates/qbz-ui/ui/shell/PlayerBarSmall.slint:819`, which
|
||||
// wraps its ContextMenuItem in `if !ShellState.kiosk-profile`. The
|
||||
// reference's reason is the appliance shell: a second floating,
|
||||
// draggable, always-on-top window has no way back on a touch-only
|
||||
// kiosk. Building the model in JS (not a ternary inside one row) is
|
||||
// what makes the row genuinely absent; the binding re-runs when
|
||||
// QbzShell.kioskProfile changes, which the live desktop/kiosk toggle
|
||||
// does. This closes ticket T-13 (contract §4.10.2): the kiosk contract
|
||||
// landed first, so this diff owes the gate and pays it here.
|
||||
model: {
|
||||
var rows = []
|
||||
if (!QbzShell.kioskProfile)
|
||||
rows.push({ "label": QbzSession.tr("Miniplayer", QbzSession.trRev),
|
||||
"icon": "picture-in-picture-2", "live": true, "action": "miniplayer" })
|
||||
rows.push({ "label": QbzSession.tr("Immersive", QbzSession.trRev),
|
||||
"icon": "maximize-2", "live": true, "action": "immersive" })
|
||||
rows.push({ "label": QbzShell.kioskProfile
|
||||
? QbzSession.tr("Desktop mode", QbzSession.trRev)
|
||||
: QbzSession.tr("Kiosk mode", QbzSession.trRev),
|
||||
"icon": "hard-drive", "live": true, "action": "kiosk" })
|
||||
return rows
|
||||
}
|
||||
delegate: Rectangle {
|
||||
required property var modelData
|
||||
width: parent ? parent.width : 0
|
||||
@@ -148,8 +165,10 @@ QbzContextMenu {
|
||||
QbzImmersive.openFromMenu()
|
||||
else if (modelData.action === "kiosk")
|
||||
QbzSession.toggleProfile()
|
||||
// "miniplayer" has live: false, so `enabled` above keeps
|
||||
// this handler unreachable for it.
|
||||
else if (modelData.action === "miniplayer")
|
||||
// Suppressed under gamescope INSIDE enter() — one
|
||||
// predicate for this row and for Shift+M (§4.10.1).
|
||||
QbzMini.enter()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,11 +322,13 @@ impl qbz_hotkeys::QbzHotkeys {
|
||||
}
|
||||
|
||||
/// The §2 dispatch table (keybindings.rs:502-531 `run_action`). true =
|
||||
/// consumed. The no-op seams are CONTRACTUAL (K3, trap 10): ui.openLink
|
||||
/// (LinkResolver not ported, HeaderBar.qml:23 — activates when it lands),
|
||||
/// ui.miniPlayer (no Qt miniplayer, §6 multi-window-ready), and the
|
||||
/// mini.* rows (no-op on the main window — kept in the table for
|
||||
/// binding-file compat + the cheatsheet).
|
||||
/// consumed. ONE no-op seam is left and it is CONTRACTUAL (K3, trap 10):
|
||||
/// ui.openLink (LinkResolver not ported, HeaderBar.qml:23 — activates when
|
||||
/// it lands). The mini.* rows still no-op here — they belong to the mini
|
||||
/// window's own dispatcher (mini_bridge::key_pressed) and are kept in this
|
||||
/// table for binding-file compat + the cheatsheet. **ui.miniPlayer is no
|
||||
/// longer a seam**: it toggles the Qt miniplayer (2026-08-03
|
||||
/// miniplayer/tray contract §4.9 seam 2).
|
||||
fn run_action(mut self: Pin<&mut Self>, id: &str) -> bool {
|
||||
match id {
|
||||
"playback.toggle" => crate::transport_toggle_play(),
|
||||
@@ -349,9 +351,11 @@ impl qbz_hotkeys::QbzHotkeys {
|
||||
"ui.openLink" => {
|
||||
log::debug!("[qbz-qt] hotkeys: ui.openLink — no-op seam, LinkResolver not ported (K3)");
|
||||
}
|
||||
"ui.miniPlayer" => {
|
||||
log::debug!("[qbz-qt] hotkeys: ui.miniPlayer — no-op seam, no Qt miniplayer (K3/§6)");
|
||||
}
|
||||
// Shift+M — the reference's `toggle_miniplayer()`
|
||||
// (keybindings.rs:547-558). Its gamescope guard is NOT repeated
|
||||
// here: it lives in `QbzMini::enter`, so this hotkey and the view
|
||||
// menu's row share ONE predicate (contract §4.10.1).
|
||||
"ui.miniPlayer" => crate::mini_bridge::toggle(),
|
||||
"focus.seekForward" => seek_relative(5),
|
||||
"focus.seekBack" => seek_relative(-5),
|
||||
"focus.seekForwardLong" => seek_relative(10),
|
||||
|
||||
@@ -115,9 +115,11 @@ pub enum Context {
|
||||
None,
|
||||
/// Only while the immersive overlay is open (seek shortcuts).
|
||||
Immersive,
|
||||
/// Only while the miniplayer window is active (surface 1-5). Dispatched on
|
||||
/// the mini window's own hook, never on the main window (§6 — multi-window
|
||||
/// readiness, documented seam, NOT implemented).
|
||||
/// Only while the miniplayer window is active (surfaces 0-4). Dispatched
|
||||
/// on the mini window's own hook — `QbzMini.keyPressed` through
|
||||
/// `action_for_mini_key` below — and NEVER on the main window, whose
|
||||
/// `action_for_key` still answers `Context::Mini => None` (there is a test
|
||||
/// on that arm). The two functions are siblings, not one widened gate.
|
||||
Mini,
|
||||
}
|
||||
|
||||
@@ -574,6 +576,37 @@ pub fn action_for_key(
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve a key event over the MINI window's context — a SIBLING of
|
||||
/// `action_for_key`, never a widening of it (2026-08-03 miniplayer/tray
|
||||
/// contract A-16, §4.9).
|
||||
///
|
||||
/// `Context::Mini` and `Context::None` fire here; `Context::Immersive` does
|
||||
/// not, because the immersive overlay lives on the main window, which is hidden
|
||||
/// while the mini is up. This mirrors the reference's split: `dispatch_mini`
|
||||
/// (`crates/qbz/src/keybindings.rs:623-648`) resolves over the same ACTIVE
|
||||
/// bindings — user overrides respected — and its table is exactly the mini + the
|
||||
/// three global playback rows.
|
||||
///
|
||||
/// **`action_for_key`'s `Context::Mini => None` arm (`:572`) does NOT change.**
|
||||
/// The main window must keep rejecting mini actions and the test at
|
||||
/// `immersive_actions_are_gated_on_the_overlay_and_mini_never_fires` asserts it.
|
||||
pub fn action_for_mini_key(
|
||||
overrides: &BTreeMap<String, String>,
|
||||
key: i32,
|
||||
modifiers: i32,
|
||||
text: &str,
|
||||
) -> Option<&'static ActionDef> {
|
||||
let (ctrl, alt, shift) = mods_from_qt(modifiers);
|
||||
let token = token_from_qt_key(key, modifiers, text)?;
|
||||
let shortcut = shortcut_from_parts(ctrl, alt, shift, &token)?;
|
||||
let bindings = active_bindings_with(overrides);
|
||||
let action = action_for_shortcut(&shortcut, &bindings)?;
|
||||
match action.context {
|
||||
Context::Immersive => None,
|
||||
_ => Some(action),
|
||||
}
|
||||
}
|
||||
|
||||
/// The (C2) Ctrl+A predicate, EXACTLY the Slint one (contract §4.6 / trap 8):
|
||||
/// `ctrl && token.eq_ignore_ascii_case("a")` — other modifiers are NOT
|
||||
/// excluded, so Ctrl+Shift+A and Ctrl+Alt+A also trigger.
|
||||
@@ -936,6 +969,25 @@ mod tests {
|
||||
assert_eq!(a.id, "playback.toggle");
|
||||
}
|
||||
|
||||
/// A-16's sibling gate: the mini window is the mirror image of the main
|
||||
/// one. Written beside its twin above ON PURPOSE — the pair is what proves
|
||||
/// the widening was NOT applied to the shared arm.
|
||||
#[test]
|
||||
fn the_mini_gate_is_the_mirror_of_the_main_one() {
|
||||
let overrides = no_overrides();
|
||||
// "1" is mini.micro — it fires HERE and nowhere else.
|
||||
let a = action_for_mini_key(&overrides, QT_KEY_0 + 1, 0, "1").unwrap();
|
||||
assert_eq!(a.id, "mini.micro");
|
||||
// …and it is still refused on the main window (the arm was not widened).
|
||||
assert!(action_for_key(&overrides, QT_KEY_0 + 1, 0, "1", false).is_none());
|
||||
// A global action resolves on both.
|
||||
let a = action_for_mini_key(&overrides, QT_KEY_SPACE, 0, " ").unwrap();
|
||||
assert_eq!(a.id, "playback.toggle");
|
||||
// Immersive-context actions never fire on the mini: the overlay lives
|
||||
// on the main window, which is hidden while the mini is up.
|
||||
assert!(action_for_mini_key(&overrides, QT_KEY_RIGHT, 0, "").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_a_predicate_matches_the_slint_rule() {
|
||||
let key_a = QT_KEY_A;
|
||||
|
||||
@@ -81,6 +81,32 @@ pub mod qbz_mini {
|
||||
/// bridge never errors, it just never repaints.
|
||||
#[qinvokable]
|
||||
fn boot(self: Pin<&mut QbzMini>);
|
||||
|
||||
/// Enter the miniplayer (contract A-8, §4.6's `enter()`). Suppressed
|
||||
/// under gamescope — the guard lives HERE so the view-menu row and the
|
||||
/// `ui.miniPlayer` hotkey share one predicate (§4.10.1).
|
||||
#[qinvokable]
|
||||
fn enter(self: Pin<&mut QbzMini>);
|
||||
|
||||
/// Leave the miniplayer (contract A-8, §4.6's `exit()`). Also the
|
||||
/// destination of the mini's `Escape` / `Shift+M` and of its
|
||||
/// `onClosing` — a compositor close behaves like the expand button
|
||||
/// (§13-D13).
|
||||
#[qinvokable]
|
||||
fn exit(self: Pin<&mut QbzMini>);
|
||||
|
||||
/// The MINI window's own key dispatcher (contract A-15, §4.9), 1:1 with
|
||||
/// the reference's `dispatch_mini`
|
||||
/// (`crates/qbz/src/keybindings.rs:623-648`). **No
|
||||
/// `text_input_focused` argument** — the mini has no text fields, and
|
||||
/// `dispatch_mini` has no text-input guard either. `true` = consumed.
|
||||
#[qinvokable]
|
||||
fn key_pressed(
|
||||
self: Pin<&mut QbzMini>,
|
||||
key: i32,
|
||||
modifiers: i32,
|
||||
text: QString,
|
||||
) -> bool;
|
||||
}
|
||||
|
||||
// The custom WRITE targets. NOT qinvokables — QML reaches them by writing
|
||||
@@ -202,6 +228,72 @@ fn refresh_queue() {
|
||||
crate::spawn(async move { crate::queue_qt::publish(&runtime).await });
|
||||
}
|
||||
|
||||
/// `enter()`'s body as a free fn, so the invokable and the `ui()`-hopped
|
||||
/// `toggle()` below reach the SAME code instead of two copies that can drift.
|
||||
///
|
||||
/// The reference's `enter()` (`crates/qbz/src/miniplayer.rs:154-188`) is seven
|
||||
/// ordered steps; five of them have no Qt counterpart. Creation + seeding is
|
||||
/// QML's `createObject` plus this bridge's construction-time seeds (steps 1-2),
|
||||
/// `ensure_lyrics_engine` is DROPPED (§3.2 — the mini mounts its own engine),
|
||||
/// `force_full_mirror` and `spawn_queue_refresh` are DROPPED because the
|
||||
/// singletons the mini reads are the ones the shell reads and are already
|
||||
/// current. What remains is the flag — and QML's `onOpenChanged` does the rest.
|
||||
///
|
||||
/// Step 7, `m.hide()` LAST, is `window.hideToTray()` (A-25) and lands with B6;
|
||||
/// until then the main window stays visible behind the mini. Open-coding a bare
|
||||
/// `window.hide()` here would create a second visibility owner, which §5.8.1's
|
||||
/// invariant and stage-0 S0-4 forbid.
|
||||
fn enter_now(mut this: Pin<&mut QbzMini>) {
|
||||
if crate::tray_qt::in_gamescope() {
|
||||
// 1:1 with the reference's two suppressed entry points
|
||||
// (`crates/qbz/src/main.rs:11732-11733`, `keybindings.rs:548-552`): an
|
||||
// extra mapped window can steal gamescope's focused-window pick.
|
||||
log::info!("[qbz-qt] miniplayer: entry suppressed under gamescope");
|
||||
return;
|
||||
}
|
||||
if this.open {
|
||||
// Already up: `apply_open` would early-return on the unchanged value,
|
||||
// no `openChanged` would fire, and QML's handler — the ONLY place the
|
||||
// window is shown or raised — would never run. The reference's
|
||||
// `enter()` re-applies geometry and `show()`s unconditionally
|
||||
// (`miniplayer.rs:154-188`), so re-entering RAISES. Forcing the notify
|
||||
// is how a Rust-side verb reaches a QML-owned window; it is also the
|
||||
// shape `present()` wants.
|
||||
this.as_mut().open_changed();
|
||||
return;
|
||||
}
|
||||
apply_open(this, true);
|
||||
}
|
||||
|
||||
/// `exit()`'s body as a free fn — see `enter_now` for why.
|
||||
///
|
||||
/// The reference sets `OPEN = false` FIRST so any in-flight work bails
|
||||
/// (`miniplayer.rs:191-215`); `apply_open` stores the mirror before it notifies,
|
||||
/// so that ordering is preserved. Restoring the force-opened lyrics panel is
|
||||
/// DROPPED with the hack that needed it (§3.2). `m.show()` is
|
||||
/// `window.showFromTray()` (A-25) and lands with B6, for the same
|
||||
/// one-visibility-owner reason `enter_now` states.
|
||||
fn exit_now(this: Pin<&mut QbzMini>) {
|
||||
apply_open(this, false);
|
||||
}
|
||||
|
||||
/// The `ui.miniPlayer` hotkey's verb — the reference's `toggle_miniplayer()`
|
||||
/// (`crates/qbz/src/keybindings.rs:547-558`) minus its gamescope guard, which
|
||||
/// lives in `enter_now` so both entry points share ONE predicate (§4.10.1).
|
||||
///
|
||||
/// Hopped through `ui()` because the caller is `hotkeys_bridge`'s `run_action`,
|
||||
/// which runs on ANOTHER QObject and cannot reach this one's properties — the
|
||||
/// same reason the `OPEN` mirror exists.
|
||||
pub(crate) fn toggle() {
|
||||
ui(|mini| {
|
||||
if is_open() {
|
||||
exit_now(mini);
|
||||
} else {
|
||||
enter_now(mini);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
impl qbz_mini::QbzMini {
|
||||
pub fn boot(self: Pin<&mut Self>) {
|
||||
if QT_THREAD.set(self.qt_thread()).is_err() {
|
||||
@@ -220,4 +312,62 @@ impl qbz_mini::QbzMini {
|
||||
pub fn set_surface(self: Pin<&mut Self>, surface: i32) {
|
||||
apply_surface(self, surface);
|
||||
}
|
||||
|
||||
/// Contract A-8 — enter.
|
||||
pub fn enter(self: Pin<&mut Self>) {
|
||||
enter_now(self);
|
||||
}
|
||||
|
||||
/// Contract A-8 — exit.
|
||||
pub fn exit(self: Pin<&mut Self>) {
|
||||
exit_now(self);
|
||||
}
|
||||
|
||||
/// Contract A-15 — the mini's key dispatcher, the table at §4.9.
|
||||
///
|
||||
/// Resolution goes through `hotkeys_qt::action_for_mini_key` (A-16), which
|
||||
/// reads the user's ACTIVE bindings, so a rebound `mini.queue` works here
|
||||
/// exactly as the reference's `dispatch_mini` intends (`keybindings.rs:631`).
|
||||
/// A matched action consumes (`:647`); anything else propagates (`:645`).
|
||||
pub fn key_pressed(
|
||||
self: Pin<&mut Self>,
|
||||
key: i32,
|
||||
modifiers: i32,
|
||||
text: QString,
|
||||
) -> bool {
|
||||
let text = text.to_string();
|
||||
let overrides = crate::hotkeys_qt::load_overrides();
|
||||
let Some(action) =
|
||||
crate::hotkeys_qt::action_for_mini_key(&overrides, key, modifiers, &text)
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
// The surface writes go through `apply_surface`, the same funnel
|
||||
// `QbzMini.surface = n` uses, so the keyboard path cannot skip the
|
||||
// persist or the surface-3 queue kick.
|
||||
//
|
||||
// `clamp_to_implemented` is the TEMPORARY guard that keeps `1`, `4` and
|
||||
// `5` from landing the user on a blank card while the micro footer
|
||||
// (B3) and the queue + lyrics surfaces (B4) do not exist yet. It is
|
||||
// deleted by those blocks — see the function's own doc. The keys stay
|
||||
// BOUND rather than being removed from the table, because the table is
|
||||
// the user's rebindable one and the cheatsheet already lists all five.
|
||||
match action.id {
|
||||
"mini.micro" => apply_surface(self, crate::mini_qt::clamp_to_implemented(0)),
|
||||
"mini.compact" => apply_surface(self, 1),
|
||||
"mini.artwork" => apply_surface(self, 2),
|
||||
"mini.queue" => apply_surface(self, crate::mini_qt::clamp_to_implemented(3)),
|
||||
"mini.lyrics" => apply_surface(self, crate::mini_qt::clamp_to_implemented(4)),
|
||||
// Both leave the mini — 1:1 with `keybindings.rs:641`, where the
|
||||
// two ids share one arm.
|
||||
"ui.miniPlayer" | "ui.escape" => exit_now(self),
|
||||
"playback.toggle" => crate::transport_toggle_play(),
|
||||
"playback.next" => crate::transport_next(),
|
||||
"playback.prev" => crate::transport_previous(),
|
||||
// Nothing else is bound on the mini (§4.9): no arrow navigation,
|
||||
// no volume keys, no seek keys.
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -210,10 +210,33 @@ fn surface_for_default_view(default_view: &str, last_surface: i32) -> i32 {
|
||||
}
|
||||
|
||||
pub(crate) fn initial_surface() -> i32 {
|
||||
surface_for_default_view(
|
||||
clamp_to_implemented(surface_for_default_view(
|
||||
&crate::settings_qt::pref_str(KEY_DEFAULT_VIEW, "remember"),
|
||||
crate::settings_qt::pref_i32(KEY_SURFACE, DEFAULT_SURFACE),
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
/// TEMPORARY, and it deletes itself: surfaces 0 (micro), 3 (queue) and 4
|
||||
/// (lyrics) have no content yet — the footer that IS the micro card is block
|
||||
/// B3's, and the queue and lyrics surfaces are B4's.
|
||||
///
|
||||
/// This matters because `mini_surface` and `mini_default_view` live in the
|
||||
/// ui_prefs.json **co-owned with the shipping Slint app**. A user whose Slint
|
||||
/// miniplayer was last on Queue, or whose default view is "micro", would open
|
||||
/// the Qt mini onto a blank rounded box with no footer and no capsule — i.e.
|
||||
/// no visible way out but Escape. Falling back to the artwork surface (the
|
||||
/// reference's own default, `ui_prefs.rs`'s `mini_surface: 2`) is the honest
|
||||
/// behaviour until the surfaces exist.
|
||||
///
|
||||
/// **Removal is part of B3 and B4**, in the same commit that lands each
|
||||
/// surface: B3 drops 0 from the list, B4 drops 3 and 4, and the last one to go
|
||||
/// deletes this function. The keyboard arms in `mini_bridge::key_pressed` are
|
||||
/// clamped by the same rule and lose it the same way.
|
||||
pub(crate) fn clamp_to_implemented(surface: i32) -> i32 {
|
||||
match surface {
|
||||
1 | 2 => surface,
|
||||
_ => DEFAULT_SURFACE,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn initial_background_blur() -> bool {
|
||||
|
||||
Reference in new issue
Block a user