Files
qbz/crates/qbz-ui/ui/shell/PlayerBarSmall.slint
T
vicrodh f1d965b04e feat(kiosk): live Kiosk<->Desktop toggle in the NPB layout menu
Add a "Kiosk mode" / "Desktop mode" item to both PlayerBarSmall and
PlayerBar view menus (label from the new ShellState.kiosk-profile flag).
It fires media-action("npb-view","","toggle-profile"); Rust flips the
persisted ui_prefs.profile and swaps the shell in place via set_screen
(KioskShell/AppShell share state, so no restart). The toggle keys off the
current screen, not kiosk_profile_active(), so a QBZ_PROFILE env override
doesnt pin it. ShellState.kiosk-profile is seeded at window setup.

cc
2026-07-10 21:17:12 -06:00

967 lines
55 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Bottom now-playing / transport bar — Mode C "Small" (redesigned).
//
// One bar, header-height tall (42px). A THIN top seekbar strip (3px) sits over
// the controls row which fills the rest (~39px) — NO band bump. The large
// album art (37px, flush to the left edge with a 2px border) is the dominant
// element that defines the visual height.
//
// ┌──────────────────────────────────────────────────────────────────┐
// │ ▰▰▰▰▰▰▰▰▰▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱▱ ← top seekbar │ (3px, full width)
// ├──────────────────────────────────────────────────────────────────┤
// │[art] title 00:02 (i)⏮ ⏪ ▶ ⏩ ⏭ + STAMP view cast lyr ⚙ vol q │ (~39px)
// │ artist 04:32 │
// └──────────────────────────────────────────────────────────────────┘
//
// A. TOP seekbar — full-width (no side padding), 3-color (bg + cache +
// progress), NO time labels (show-times:false). It is the visual border
// between the content area and the bar.
//
// B. CONTROLS ROW — a SYMMETRIC 3-column layout that mirrors PlayerBar's
// New/Classic mechanism (PlayerBar.slint:138-179): the LEFT and RIGHT
// columns share ONE responsive `side-frac` of the row width, so the CENTER
// transport column is window-centred and PLAY lands on the window centre
// (aligned with the header search) at every width.
// LEFT — album art (42px, 3px left inset) · 2-line title/artist (smaller
// font) · a fixed 2-row time column (elapsed / duration).
// CENTER — the transport cluster (info · shuffle · prev · PLAY · next ·
// repeat · +), reused, symmetric, centred.
// RIGHT — the right control SET, right-aligned, the AudioStamp now PART
// of it: AudioStamp · ViewMode · Connect · Cast · Lyrics ·
// Settings · Volume · Queue.
//
// Mounted by NowPlayingBar.slint when ShellState.npb-mode == 2. Reads
// NowPlayingState directly; bubbles album/artist/media actions up to the shell.
import { Theme } from "../foundation/semantic-colors.slint";
import { Layout } from "../foundation/layout.slint";
import { Radius } from "../foundation/radius.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QbzSlider } from "../primitives/QbzSlider.slint";
import { QbzVerticalSlider } from "../primitives/QbzVerticalSlider.slint";
import { QbzToggle } from "../primitives/QbzToggle.slint";
import { IconButton } from "../primitives/BarControls.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ContextMenu } from "../primitives/ContextMenu.slint";
import { ContextMenuItem } from "../primitives/ContextMenuItem.slint";
import { SeekBar } from "SeekBar.slint";
import { SongCard } from "SongCard.slint";
import { TransportControls } from "TransportControls.slint";
import { AudioStamp } from "AudioStamp.slint";
import { NowPlayingState, ShellState, SettingsState, QconnectDevState, CastState, CastActions } from "../state.slint";
// Qobuz Connect button — monitor-speaker glyph; golden over a soft golden tint
// when a Qobuz Connect session owns playback. A local copy of PlayerBar's
// ConnectButton (it is a file-private component there, so it can't be imported)
// — kept byte-for-byte equivalent so Small and New look identical.
component ConnectButton inherits Rectangle {
in property <bool> active: false;
callback clicked();
property <color> gold: #e0b341;
width: 32px;
height: 32px;
border-radius: Radius.sm;
background: root.active
? root.gold.with-alpha(0.16)
: (ta.has-hover ? Theme.surface-hover : transparent);
border-width: root.active ? 1px : 0px;
border-color: root.gold.with-alpha(0.45);
QbzIcon {
source: @image-url("../assets/icons/monitor-speaker.svg");
width: 16px;
height: 16px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.active
? root.gold
: (ta.has-hover ? Theme.text-primary : Theme.text-secondary);
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
// Thin vertical separator reused inside the controls row (left zone: song-card
// vs time column; right zone: AudioStamp vs the icon cluster). A 1px line,
// border-subtle, ~60% of the row height, vertically centred. The horizontal
// spacing on each side is the caller's responsibility (gap property) so #6 can
// breathe more than #5.
component Sep inherits HorizontalLayout {
in property <length> gap: 6px;
// Per-side overrides (default to `gap`) so a separator can sit a bit closer
// to one neighbour than the other.
in property <length> gap-left: root.gap;
in property <length> gap-right: root.gap;
// A NESTED layout defaults to horizontal-stretch:1 (greedy) in Slint —
// without this the Sep ATE the row's spare width, centring its 1px line in
// a huge box ("un chingo de espacio") and starving the song card so its
// text elided early with lots of empty space to the right. Pin it to 0 so
// the Sep is exactly `gap-left + 1px + gap-right` and the card keeps the rest.
horizontal-stretch: 0;
alignment: center;
padding-left: root.gap-left;
padding-right: root.gap-right;
VerticalLayout {
alignment: center;
Rectangle {
width: 1px;
// ~60% of the ~39px controls row.
height: 24px;
background: Theme.border-subtle;
}
}
}
export component PlayerBarSmall inherits Rectangle {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
callback settings-bool(string, bool);
// One bar, header-height tall: a 3px top seekbar strip + the controls row
// that fills the rest (no band bump — the large album art defines the height).
height: Layout.header-height;
background: Theme.surface-card;
// Responsive side fraction — IDENTICAL to PlayerBar's New mechanism
// (PlayerBar.slint:138-140). LEFT and RIGHT columns share this fraction so
// they are symmetric, which puts the CENTER transport column dead-centre
// and lands PLAY on the window centre (aligned with the header search).
// width < 1366 -> 39% | 22% | 39%
// 1366..<1920 -> 30% | 40% | 30%
// width >= 1920 -> 25% | 50% | 25%
property <float> side-frac: root.width >= 1920px
? 0.25
: (root.width >= 1366px ? 0.30 : 0.39);
property <float> col-centre: 1.0 - 2.0 * root.side-frac;
// WIDE = inline horizontal volume slider; NARROW = a button opening a
// vertical slider flyout. Same 1366px breakpoint family as the side-frac.
property <bool> volume-wide: root.width >= 1366px;
// Volume lock, mirroring PlayerBar's vol-locked: the local ALSA-Direct
// (bit-perfect) lock is LIFTED while controlling a peer, plus the
// sink-pushed remote lock. When locked, the volume control dims + no-ops.
property <bool> vol-locked: (SettingsState.backend-is-alsa && SettingsState.alsa-plugin-is-hw && !NowPlayingState.is-remote)
|| NowPlayingState.volume-locked;
// Qobuz Connect: true while a Connect click is discovering renderers (the
// flyout stays open and shows a spinner until devices arrive or the
// discovery timer bounds it). UI-only — there is no `discovering` flag in
// QconnectDevState, so the spinner is gated on this + an 8s Slint timeout.
property <bool> qc-connecting: false;
VerticalLayout {
spacing: 0px;
// === A. TOP full-width seekbar (the content/bar divider) ===========
// No side padding so it spans edge-to-edge; show-times:false hides the
// labels (the controls row carries its own time column). Centred in the
// thin 3px strip; same NowPlayingState seek wiring as New.
Rectangle {
height: 3px;
clip: false;
VerticalLayout {
// Pull the seekbar ~2px UP so the progress line hugs the very
// top edge of the bar (the content/NPB divider) instead of
// sitting centred with slack above it.
y: -2px;
alignment: center;
SeekBar {
show-times: false;
progress: NowPlayingState.progress;
cache: NowPlayingState.cache;
seekable-max: NowPlayingState.seekable-max;
elapsed: NowPlayingState.elapsed;
remaining: NowPlayingState.remaining;
duration-secs: NowPlayingState.duration-secs;
seek(fraction) => {
NowPlayingState.seek(fraction);
}
}
}
}
// === B. CONTROLS ROW — symmetric 3 columns (39/22/39 …) ============
// Fills the bar height left over after the 3px seekbar (~39px) via
// vertical-stretch instead of an explicit height, so the total is exactly
// header-height with no bump.
HorizontalLayout {
vertical-stretch: 1;
padding-left: 0px;
padding-right: 6px;
spacing: 0px;
// ---- LEFT column: art + title/artist + time column ------------
Rectangle {
width: (parent.width - 6px) * root.side-frac;
clip: true;
HorizontalLayout {
// Zeroed so the Sep owns its full symmetric gap (the layout
// spacing was DOUBLING the separator gap — adding to the Sep's
// own padding). The Sep#5 now owns the full 10px reference gap
// on each side; the song card stretches to fill the rest.
spacing: 0px;
// No left inset: the album art is FLUSH to the window's left
// edge; its 2px border provides the visual edge instead of a
// margin.
padding-left: 0px;
// Art (37px, fits the ~39px controls row + leaves a hair of
// breathing room) + 2-line title/artist via SongCard. The art
// gets a 2px subtle border (defines it while flush-left).
// show-badges false (the AudioStamp lives in the RIGHT set
// now); the smaller title via the new title-font-size prop.
// The controls row sizes the card (a HorizontalLayout
// vertically stretches its children), so no explicit
// height/y is needed.
SongCard {
horizontal-stretch: 1;
art-size: 37px;
art-border-width: 3px;
art-border-color: Theme.surface-card;
show-badges: false;
title-font-size: 13px;
// Tighten the art -> text gap by 2px (11 -> 9) for Small.
art-text-gap: 9px;
text-center: true;
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
open-context(kind, id) => {
root.media-action(kind, id, "open");
}
track-info() => {
if (!NowPlayingState.is-ephemeral) {
root.media-action("track", NowPlayingState.track-id, "track-info");
}
}
}
// Separator: song-card (art+text) | time column. 8px toward
// the song card, +2px (10px) toward the timer (owner ask).
if NowPlayingState.has-track: Sep {
gap: 8px;
gap-right: 10px;
}
// Time column — a fixed-width 2-row block (elapsed / total),
// where the quality badge used to sit. Uses EXISTING state
// only: NowPlayingState.elapsed (already MM:SS) for row 1 and
// duration-secs formatted MM:SS for row 2.
if NowPlayingState.has-track: VerticalLayout {
alignment: center;
spacing: 1px;
width: 40px;
Text {
text: NowPlayingState.elapsed;
// Monospace so each digit + the colon hold the SAME
// position as values change (tabular, alarm-clock
// style — the proportional UI font shifted the colon).
font-family: "monospace";
font-size: 10px;
color: Theme.text-muted;
horizontal-alignment: left;
}
Text {
// MM:SS from duration-secs (same arithmetic as SeekBar.fmt).
text: "\{Math.floor(NowPlayingState.duration-secs / 60)}:\{Math.mod(NowPlayingState.duration-secs, 60) < 10 ? "0" : ""}\{Math.mod(NowPlayingState.duration-secs, 60)}";
// Monospace for stable digit/colon positions (see above).
font-family: "monospace";
font-size: 10px;
color: Theme.text-muted;
horizontal-alignment: left;
}
}
}
}
// ---- CENTER column: transport, window-centred -----------------
Rectangle {
width: (parent.width - 6px) * root.col-centre;
clip: true;
VerticalLayout {
alignment: center;
HorizontalLayout {
alignment: center;
TransportControls {
play-circle: false;
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
}
}
}
// ---- RIGHT column: the control SET, right-aligned --------------
// Order: AudioStamp · ViewMode · Connect · Cast · Lyrics ·
// Settings · Volume · Queue.
Rectangle {
width: (parent.width - 6px) * root.side-frac;
clip: true;
HorizontalLayout {
alignment: end;
spacing: 1px;
// AudioStamp — first in the set, clamped width.
if NowPlayingState.has-track: VerticalLayout {
alignment: center;
AudioStamp {
// Wider when a QConnect renderer name is shown (it
// grows leftward into the empty space before the
// centre transport; the right zone's clip is the real
// guard). Normal stamp stays compact at 150px.
max-width: (NowPlayingState.is-remote && NowPlayingState.cast-target != "") ? 280px : 150px;
}
}
// Separator: AudioStamp | right-cluster icon buttons. This is
// the REFERENCE gap: 9px Sep padding + 1px parent layout
// spacing = 10px rendered on each side (symmetric). The parent
// keeps spacing:1px because the icon cluster needs it; the Sep
// padding is symmetric, so both sides render the same 10px.
if NowPlayingState.has-track: Sep {
gap: 8px;
// +2px toward the quality badge (owner ask); 8px toward
// the buttons (the right cluster's 1px spacing applies on
// each boundary on top of these).
gap-left: 10px;
}
// Connect — golden when a session is on; opens the connect
// flyout (self-contained upward PopupWindow, verbatim from
// PlayerBar so Small drives the same device picker path).
VerticalLayout {
alignment: center;
Rectangle {
width: 32px;
height: 32px;
ConnectButton {
active: NowPlayingState.qconnect-connected;
clicked => {
qconnect-menu.show();
}
}
qconnect-menu := PopupWindow {
// Inner Rectangle FILLS the popup, so the visible
// bottom == y + height. Homologated to -7 (flush
// just above the 3px seekbar; bar top ≈ -6.5).
x: 32px - 280px;
y: -251px;
width: 280px;
height: 244px;
close-policy: close-on-click-outside;
Rectangle {
background: Theme.surface-main;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-muted;
drop-shadow-blur: 22px;
drop-shadow-color: Theme.card-shadow;
drop-shadow-offset-y: 6px;
VerticalLayout {
padding: 14px;
spacing: 12px;
HorizontalLayout {
spacing: 8px;
QbzIcon {
source: @image-url("../assets/icons/monitor-speaker.svg");
width: 16px;
height: 16px;
tint: Theme.text-primary;
}
Text {
text: @tr("Qobuz Connect");
color: Theme.text-primary;
font-size: 14px;
font-weight: 600;
vertical-alignment: center;
horizontal-stretch: 1;
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
HorizontalLayout {
spacing: 8px;
VerticalLayout {
alignment: center;
Rectangle {
width: 8px;
height: 8px;
border-radius: 4px;
background: NowPlayingState.qconnect-connected ? #22c55e : Theme.text-muted;
}
}
Text {
text: NowPlayingState.qconnect-connected
? @tr("Connected")
: @tr("Disconnected");
color: Theme.text-secondary;
font-size: 12px;
vertical-alignment: center;
horizontal-stretch: 1;
}
}
if NowPlayingState.is-remote && NowPlayingState.cast-target != "": Text {
text: @tr("Playing on: {}", NowPlayingState.cast-target);
color: Theme.accent;
font-size: 11px;
overflow: elide;
}
// Discovery timer — bounds the spinner so
// the "no devices" empty state shows if
// none appear within ~8s. Started on a
// Connect click; reset on disconnect (see
// the toggle button below). UI-only.
qc-discover-timer := Timer {
interval: 8s;
running: false;
triggered => {
root.qc-connecting = false;
self.running = false;
}
}
Rectangle {
vertical-stretch: 1;
background: Theme.surface-elevated;
border-radius: Radius.sm;
clip: true;
// Discovering — Connect was clicked and
// no renderers have arrived yet. Spinner
// + caption; hides once devices appear
// (gated on length == 0) or timer expires.
if root.qc-connecting && QconnectDevState.devices.length == 0: VerticalLayout {
alignment: center;
spacing: 6px;
HorizontalLayout {
alignment: center;
LoadingSpinner {
size: 22px;
}
}
Text {
text: @tr("Looking for devices…");
color: Theme.text-secondary;
font-size: 12px;
horizontal-alignment: center;
}
}
if !root.qc-connecting && QconnectDevState.devices.length == 0: VerticalLayout {
alignment: center;
spacing: 4px;
Text {
text: @tr("No devices found");
color: Theme.text-secondary;
font-size: 12px;
horizontal-alignment: center;
}
Text {
text: @tr("Make sure your renderer is on the same network");
color: Theme.text-muted;
font-size: 10px;
horizontal-alignment: center;
wrap: word-wrap;
}
}
if QconnectDevState.devices.length > 0: Flickable {
viewport-height: dev-rows.preferred-height;
dev-rows := VerticalLayout {
padding: 4px;
spacing: 2px;
for d in QconnectDevState.devices: Rectangle {
height: 34px;
border-radius: Radius.sm;
background: row-ta.has-hover ? Theme.surface-hover : transparent;
row-ta := TouchArea {
clicked => {
QconnectDevState.set-active(d.renderer-id);
qconnect-menu.close();
}
}
HorizontalLayout {
padding-left: 8px;
padding-right: 8px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: d.icon == "mobile"
? @image-url("../assets/icons/smartphone.svg")
: d.icon == "speaker"
? @image-url("../assets/icons/speaker.svg")
: d.icon == "web"
? @image-url("../assets/icons/globe.svg")
: @image-url("../assets/icons/monitor.svg");
width: 14px;
height: 14px;
tint: d.is-active ? Theme.accent : Theme.text-secondary;
}
}
Text {
text: d.is-local ? @tr("Play here") : d.name;
color: d.is-active ? Theme.text-primary : Theme.text-secondary;
font-size: 12px;
font-weight: d.is-active ? 600 : 400;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
VerticalLayout {
alignment: center;
Rectangle {
width: 8px;
height: 8px;
border-radius: 4px;
background: d.is-active ? Theme.accent : transparent;
}
}
}
}
}
}
}
Rectangle {
height: 34px;
border-radius: Radius.sm;
background: connect-ta.pressed
? Theme.accent-pressed
: connect-ta.has-hover ? Theme.accent-hover : Theme.accent;
connect-ta := TouchArea {
clicked => {
if (NowPlayingState.qconnect-connected) {
// Currently connected -> this click DISCONNECTS
// -> close the flyout (keep current behavior).
NowPlayingState.qconnect-toggle();
root.qc-connecting = false;
qc-discover-timer.running = false;
qconnect-menu.close();
} else {
// Currently disconnected -> this click CONNECTS
// -> keep the flyout open + show the spinner
// while renderers are discovered.
NowPlayingState.qconnect-toggle();
root.qc-connecting = true;
qc-discover-timer.running = true;
}
}
}
Text {
text: NowPlayingState.qconnect-connected
? @tr("Disconnect")
: @tr("Connect");
color: Theme.accent-text;
font-size: 13px;
font-weight: 600;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
}
}
}
}
// Cast (Chromecast / DLNA) — opens the cast picker modal.
VerticalLayout {
alignment: center;
Rectangle {
width: 32px;
height: 32px;
IconButton {
icon: @image-url("../assets/icons/cast.svg");
icon-size: 16px;
btn-width: 32px;
tooltip: @tr("Cast");
active: NowPlayingState.cast-active;
clicked => {
CastState.picker-open = true;
CastActions.open();
}
}
}
}
// Settings — the SAME audio-menu flyout as New/Classic
// (Normalization + Gapless), a popup not a single toggle.
VerticalLayout {
alignment: center;
Rectangle {
width: 32px;
height: 32px;
IconButton {
icon: @image-url("../assets/icons/settings-2.svg");
icon-size: 16px;
btn-width: 32px;
tooltip: @tr("Audio settings");
// Neutral always: this button opens a flyout, so its
// colour should NOT reflect a toggle (normalization).
active: false;
clicked => {
audio-menu.show();
}
}
audio-menu := PopupWindow {
// Anchored just above the button (bottom ~-8) at
// its NATURAL height — the two toggle rows only, NO
// inflated envelope/header (owner: the homologation
// is the Y anchor, not the size; keep it short like
// it was). ToggleRow is file-private to PlayerBar,
// so the rows are built inline with QbzToggle.
// Inner Rectangle FILLS the popup, so the visible
// bottom == y + height. Reference flyout: nudged
// 1px DOWN (-126 -> -125) so the bottom lands at
// -7, flush just above the 3px seekbar (bar top
// edge ≈ -6.5) — matching cast/qconnect/layout.
x: 32px - 252px;
// Pushed down ~8px vs the computed -125 so it
// renders biting the seekbar like cast/qconnect/
// layout (same computed bottom rendered higher for
// this short popup — homologated empirically).
y: -117px;
width: 252px;
height: 118px;
close-policy: close-on-click-outside;
Rectangle {
background: Theme.surface-main;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-muted;
drop-shadow-blur: 22px;
drop-shadow-color: Theme.card-shadow;
drop-shadow-offset-y: 6px;
VerticalLayout {
padding: 8px;
spacing: 4px;
HorizontalLayout {
height: 44px;
spacing: 12px;
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 1px;
Text {
text: @tr("Normalization");
color: Theme.text-primary;
font-size: 13px;
}
Text {
text: @tr("Level loudness across tracks");
color: Theme.text-muted;
font-size: 10px;
}
}
VerticalLayout {
alignment: center;
QbzToggle {
checked: SettingsState.normalization;
toggled(v) => {
root.settings-bool("normalization", v);
}
}
}
}
HorizontalLayout {
height: 44px;
spacing: 12px;
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 1px;
Text {
text: @tr("Gapless");
color: Theme.text-primary;
font-size: 13px;
}
Text {
text: @tr("Seamless track transitions");
color: Theme.text-muted;
font-size: 10px;
}
}
VerticalLayout {
alignment: center;
QbzToggle {
checked: SettingsState.gapless;
toggled(v) => {
root.settings-bool("gapless", v);
}
}
}
}
}
}
}
}
}
// ViewMode — the layout-menu flyout (how you exit Small).
VerticalLayout {
alignment: center;
Rectangle {
width: 32px;
height: 32px;
IconButton {
icon: @image-url("../assets/icons/layout-grid.svg");
icon-size: 16px;
btn-width: 32px;
tooltip: @tr("Now Playing view");
clicked => {
layout-menu.show();
}
}
layout-menu := PopupWindow {
// Anchored just above the button at its natural
// content height. The inner ContextMenu is
// CONTENT-sized (6 rows × 33px + a 7px divider +
// the ContextMenu's 5px+5px vertical padding =
// 215px), so the popup height MUST match that
// content height — otherwise the rows top-align
// and leave empty slack at the bottom, floating
// the visible menu high above the bar. With
// height == content, `y + height` is the true
// visible bottom, homologated to the other
// flyouts at -7 (bottom flush just above the 3px
// seekbar; bar top edge sits at ≈ -6.5).
x: 32px - 196px;
y: -222px;
width: 196px;
height: 215px;
close-policy: close-on-click;
ContextMenu {
ContextMenuItem {
icon: @image-url("../assets/icons/panel-left.svg");
label: @tr("New");
selected: ShellState.npb-mode == 0;
clicked => {
root.media-action("npb-view", "", "new");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/panel-right-close.svg");
label: @tr("Classic");
selected: ShellState.npb-mode == 1;
clicked => {
root.media-action("npb-view", "", "classic");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/rows-3.svg");
label: @tr("Small");
selected: ShellState.npb-mode == 2;
clicked => {
root.media-action("npb-view", "", "small");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/layout-grid.svg");
label: @tr("Large");
selected: ShellState.npb-mode == 3;
// Large is gated on the open sidebar (the
// cover + spectrum dock there). Switching
// from Small forces the sidebar open (Rust
// npb-view "large" arm), so it stays
// selectable regardless of the current
// sidebar state.
enabled: true;
clicked => {
root.media-action("npb-view", "", "large");
}
}
Rectangle {
height: 7px;
Rectangle {
height: 1px;
y: 3px;
background: Theme.border-subtle;
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/picture-in-picture-2.svg");
label: @tr("Miniplayer");
clicked => {
root.media-action("npb-view", "", "miniplayer");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/maximize-2.svg");
label: @tr("Immersive");
clicked => {
root.media-action("npb-view", "", "immersive");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/hard-drive.svg");
label: ShellState.kiosk-profile ? @tr("Desktop mode") : @tr("Kiosk mode");
clicked => {
root.media-action("npb-view", "", "toggle-profile");
}
}
}
}
}
}
// Lyrics — toggles the lyrics panel (1:1 with PlayerBar:765).
VerticalLayout {
alignment: center;
IconButton {
icon: @image-url("../assets/icons/mic-vocal.svg");
icon-size: 16px;
btn-width: 32px;
tooltip: @tr("Lyrics");
active: ShellState.lyrics-open;
clicked => {
ShellState.lyrics-open = !ShellState.lyrics-open;
}
}
}
Rectangle { width: 4px; }
// Volume — mute icon + (WIDE) inline horizontal slider /
// (NARROW) a button opening a vertical slider flyout. Both
// respect vol-locked (dim 0.5 + no-op).
VerticalLayout {
alignment: center;
opacity: root.vol-locked ? 0.5 : 1.0;
IconButton {
icon: NowPlayingState.muted
? @image-url("../assets/icons/volume-x.svg")
: @image-url("../assets/icons/volume-2.svg");
icon-size: 16px;
btn-width: 32px;
// Wide = the button mutes (Mute/Unmute); narrow = it
// OPENS the vertical volume flyout, so it's "Volume"
// (the mute glyph lives at the flyout's foot).
tooltip: root.volume-wide
? (NowPlayingState.muted ? @tr("Unmute") : @tr("Mute"))
: @tr("Volume");
active: NowPlayingState.muted;
clicked => {
if (!root.vol-locked) {
if (root.volume-wide) {
NowPlayingState.toggle-mute();
} else {
// Narrow: the button surfaces the vertical
// slider; the mute glyph lives at its foot.
vol-flyout.show();
}
}
}
}
// Narrow vertical-slider flyout, popping UP over the button.
// Homologated to the cast flyout: TOP at -252px, bottom at
// -8px (h244). It is a narrow 32px column, so rather than
// float a short slider in the middle, the slider is grown to
// fill the taller envelope and the mute button stays pinned
// to the FOOT (near the button) — content sensibly placed.
vol-flyout := PopupWindow {
x: 0px;
y: -252px;
width: 32px;
height: 244px;
close-policy: close-on-click-outside;
Rectangle {
background: Theme.surface-main;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-muted;
drop-shadow-blur: 18px;
drop-shadow-color: Theme.card-shadow;
drop-shadow-offset-y: 4px;
VerticalLayout {
padding: 8px;
spacing: 6px;
alignment: center;
HorizontalLayout {
alignment: center;
QbzVerticalSlider {
// Grown from 96px so the slider fills the
// homologated 244px envelope instead of
// leaving dead space above it.
height: 190px;
minimum: 0;
maximum: 100;
value: NowPlayingState.volume * 100;
changed(v) => {
if (!root.vol-locked) {
NowPlayingState.set-volume(v / 100.0);
}
}
}
}
HorizontalLayout {
alignment: center;
IconButton {
icon: NowPlayingState.muted
? @image-url("../assets/icons/volume-x.svg")
: @image-url("../assets/icons/volume-2.svg");
icon-size: 15px;
btn-width: 28px;
tooltip: NowPlayingState.muted ? @tr("Unmute") : @tr("Mute");
active: NowPlayingState.muted;
clicked => {
if (!root.vol-locked) {
NowPlayingState.toggle-mute();
}
}
}
}
}
}
}
}
// Wide: inline horizontal slider beside the mute icon.
if root.volume-wide: VerticalLayout {
alignment: center;
opacity: root.vol-locked ? 0.5 : 1.0;
QbzSlider {
// -10% width (owner: tighten the horizontal volume in
// all NPB modes to free a little room). 80 -> 72.
width: 72px;
minimum: 0;
maximum: 100;
value: NowPlayingState.volume * 100;
changed(v) => {
if (!root.vol-locked) {
NowPlayingState.set-volume(v / 100.0);
}
}
}
}
Rectangle { width: 4px; }
// Queue panel toggle — same ShellState.queue-open flip as New.
VerticalLayout {
alignment: center;
IconButton {
icon: @image-url("../assets/icons/list-ordered.svg");
icon-size: 16px;
btn-width: 32px;
tooltip: @tr("Queue");
active: ShellState.queue-open;
clicked => {
ShellState.queue-open = !ShellState.queue-open;
}
}
}
}
}
}
}
}