PR #569 follow-through with the owner-corrected scope: on macOS BOTH titlebar modes work (native bar, or traffic lights integrated in the QBZ header) — what's broken is hot-applying the toggle: the overlay window attributes are fixed at creation, but the .slint chrome (no-frame, header drag+inset, Purchases placement) flipped reactively, hiding the buttons one way and overlapping them the other. Split pref from applied state: the toggle edits use-system-title-bar (persisted), the chrome reads a new system-title-bar-active seeded at startup; the handler mirrors pref->active live on Linux only (behavior byte-identical there), macOS keeps the session value + the existing restart toast. The hide-title-bar row is macOS-hidden (that part of the PR was right); the system-bar toggle stays. cc
1244 lines
55 KiB
Plaintext
1244 lines
55 KiB
Plaintext
// Top header bar — navigation tabs anchored left, the user element
|
||
// anchored right, and the search field absolutely centered on the window.
|
||
//
|
||
// The search field is positioned at the true window center (not inside a
|
||
// layout column) so it stays centered regardless of how wide the tab row
|
||
// or the user element become.
|
||
//
|
||
// Responsive: below the first breakpoint the tabs drop their icons;
|
||
// below the second the search field narrows.
|
||
|
||
import { Theme } from "../foundation/semantic-colors.slint";
|
||
import { Palette } from "../foundation/palette.slint";
|
||
import { Spacing } from "../foundation/spacing.slint";
|
||
import { Typography } from "../foundation/typography.slint";
|
||
import { Layout } from "../foundation/layout.slint";
|
||
import { Radius } from "../foundation/radius.slint";
|
||
import { SessionState, NavState, ContentView, ShellState, HeaderMenuState, NavMenuEntry, SearchActions, SearchState, SidebarPlaylistsPopupState, OfflineState, SettingsState, OfflineModeActions, AppearanceState, KeyboardShortcutsState, LinkResolverState, UiFocusState, ReportIssueState, AboutState, WhatsNewActions, AlbumActions, WindowControlActions } from "../state.slint";
|
||
import { WindowControls } from "WindowControls.slint";
|
||
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
||
import { SecondaryButton } from "../primitives/SecondaryButton.slint";
|
||
import { QbzToggle } from "../primitives/QbzToggle.slint";
|
||
|
||
component NavTab inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <string> label;
|
||
in property <bool> active: false;
|
||
in property <bool> show-icon: true;
|
||
// Dimmed + pointer-inert (no click, no hover-to-open). NOTE: no longer
|
||
// used for offline gating — offline tabs are HIDDEN at the mount site
|
||
// (`if` per ADR-010). Kept for future use.
|
||
in property <bool> disabled: false;
|
||
callback clicked();
|
||
// Fires when the pointer first enters the tab — drives hover-to-open.
|
||
callback hovered();
|
||
// Fires on hover enter/leave so the host can keep the menu open while the
|
||
// pointer rests on the tab (idle-close must pause then).
|
||
callback hover-changed(bool);
|
||
|
||
height: 30px;
|
||
width: tab-row.preferred-width;
|
||
border-radius: Radius.sm;
|
||
opacity: root.disabled ? 0.5 : 1.0;
|
||
background: root.active ? Theme.surface-elevated
|
||
: ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
tab-row := HorizontalLayout {
|
||
padding-left: root.show-icon ? 9px : 11px;
|
||
padding-right: 11px;
|
||
spacing: 6px;
|
||
if root.show-icon: VerticalLayout {
|
||
alignment: center;
|
||
QbzIcon {
|
||
source: root.icon;
|
||
width: 14px;
|
||
height: 14px;
|
||
tint: root.active ? Theme.text-primary : Theme.text-secondary;
|
||
}
|
||
}
|
||
// The dropdown caret was dropped (it ate width on small screens; the
|
||
// dropdown nature is learned after first use).
|
||
Text {
|
||
text: root.label;
|
||
height: root.height;
|
||
vertical-alignment: center;
|
||
color: Theme.text-primary;
|
||
font-size: 11px;
|
||
font-weight: root.active ? Typography.semibold : Typography.regular;
|
||
}
|
||
}
|
||
|
||
ta := TouchArea {
|
||
enabled: !root.disabled;
|
||
mouse-cursor: pointer;
|
||
clicked => {
|
||
root.clicked();
|
||
}
|
||
changed has-hover => {
|
||
root.hover-changed(self.has-hover);
|
||
if (self.has-hover) {
|
||
root.hovered();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
component MenuItem inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <string> label;
|
||
callback clicked();
|
||
|
||
height: 34px;
|
||
background: ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
HorizontalLayout {
|
||
padding-left: 12px;
|
||
padding-right: 18px;
|
||
spacing: 10px;
|
||
VerticalLayout {
|
||
alignment: center;
|
||
QbzIcon {
|
||
source: root.icon;
|
||
width: 15px;
|
||
height: 15px;
|
||
tint: Theme.text-secondary;
|
||
}
|
||
}
|
||
Text {
|
||
text: root.label;
|
||
color: Theme.text-secondary;
|
||
font-size: 13px;
|
||
vertical-alignment: center;
|
||
horizontal-stretch: 1;
|
||
}
|
||
}
|
||
|
||
ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => {
|
||
root.clicked();
|
||
}
|
||
}
|
||
}
|
||
|
||
// A nav tab plus its dropdown menu.
|
||
//
|
||
// The tab no longer owns a PopupWindow — a PopupWindow grabs the pointer
|
||
// while open, so hovering a sibling tab delivered no hover event and the
|
||
// menus could not be hover-switched. Instead, hovering or clicking the
|
||
// tab writes this tab's identity (index, header x-position, menu rows,
|
||
// home-item) into the HeaderMenuState global. The actual menu panel is
|
||
// drawn by HeaderMenuOverlay, a late child of the AppShell root, so it
|
||
// renders on top of the content area and does not grab the pointer.
|
||
//
|
||
// Hovering a different tab simply overwrites HeaderMenuState, so the new
|
||
// menu opens and the previous one closes instantly. Single-open is
|
||
// automatic — there is one global `open-index`.
|
||
component NavTabWithMenu inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <string> label;
|
||
in property <bool> active: false;
|
||
in property <bool> show-icon: true;
|
||
// Forwarded to the inner NavTab. NOTE: no longer used for offline
|
||
// gating (offline tabs are hidden at the mount site). Kept for future use.
|
||
in property <bool> disabled: false;
|
||
in property <[NavMenuEntry]> items;
|
||
// This tab's index (0..3) — written into HeaderMenuState.open-index.
|
||
in property <int> tab-index;
|
||
// Index of the row wired to Home (-1 = none). Clicking it switches
|
||
// to ContentView.home; all other rows are harmless no-ops.
|
||
in property <int> home-item: -1;
|
||
|
||
width: tab.width;
|
||
height: 30px;
|
||
|
||
// Publishes this tab's menu into the shared overlay state. The
|
||
// overlay aligns the panel under `anchor-x`; `absolute-position`
|
||
// resolves to a window-relative coordinate, which is what the
|
||
// AppShell-level overlay needs (the tab itself sits inside the
|
||
// header's tab-row layout, several offsets deep).
|
||
function open-menu() {
|
||
HeaderMenuState.open-index = root.tab-index;
|
||
HeaderMenuState.anchor-x = root.absolute-position.x;
|
||
// Header dropdown — NOT a sidebar flyout. Resetting these is what
|
||
// glues the panel under the tab: a stale from-sidebar/anchor-y from a
|
||
// previous sidebar flyout would otherwise fling it far away.
|
||
HeaderMenuState.from-sidebar = false;
|
||
HeaderMenuState.title = "";
|
||
HeaderMenuState.items = root.items;
|
||
HeaderMenuState.home-item = root.home-item;
|
||
}
|
||
|
||
tab := NavTab {
|
||
icon: root.icon;
|
||
label: root.label;
|
||
active: root.active;
|
||
show-icon: root.show-icon;
|
||
disabled: root.disabled;
|
||
clicked => {
|
||
root.open-menu();
|
||
}
|
||
// Open the dropdown on hover, no click needed. Hovering a
|
||
// different tab overwrites the global → instant switch.
|
||
hovered => {
|
||
root.open-menu();
|
||
}
|
||
// Pause the idle-close while the cursor rests on the tab; only the
|
||
// active tab clears the flag (avoids a leave/enter race).
|
||
hover-changed(h) => {
|
||
if (h) {
|
||
HeaderMenuState.trigger-hovered = true;
|
||
} else if (root.active) {
|
||
HeaderMenuState.trigger-hovered = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Compact icon-only nav button shown in the header ONLY while the sidebar is
|
||
// fully closed (Cerrado), so the section nav stays reachable. Opens a downward
|
||
// dropdown headed by the section name (label + hairline + the clickable rows).
|
||
component CompactNavBtn inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <string> title;
|
||
in property <[NavMenuEntry]> items;
|
||
in property <int> tab-index;
|
||
in property <int> home-item: -1;
|
||
// Dimmed + pointer-inert. NOTE: no longer used for offline gating
|
||
// (offline buttons are hidden at the mount site). Kept for future use.
|
||
in property <bool> disabled: false;
|
||
|
||
width: 30px;
|
||
height: 30px;
|
||
border-radius: Radius.sm;
|
||
opacity: root.disabled ? 0.5 : 1.0;
|
||
property <bool> active: HeaderMenuState.open-index == root.tab-index;
|
||
background: root.active ? Theme.surface-elevated
|
||
: cn-ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
function open-menu() {
|
||
HeaderMenuState.open-index = root.tab-index;
|
||
HeaderMenuState.anchor-x = root.absolute-position.x;
|
||
HeaderMenuState.from-sidebar = false;
|
||
HeaderMenuState.title = root.title;
|
||
HeaderMenuState.items = root.items;
|
||
HeaderMenuState.home-item = root.home-item;
|
||
}
|
||
|
||
QbzIcon {
|
||
source: root.icon;
|
||
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 ? Theme.text-primary : Theme.text-secondary;
|
||
}
|
||
cn-ta := TouchArea {
|
||
enabled: !root.disabled;
|
||
mouse-cursor: pointer;
|
||
clicked => { root.open-menu(); }
|
||
changed has-hover => {
|
||
if (self.has-hover) {
|
||
HeaderMenuState.trigger-hovered = true;
|
||
root.open-menu();
|
||
} else if (root.active) {
|
||
// Only the trigger owning the open menu clears the flag — this
|
||
// avoids a leave/enter race when sliding between triggers.
|
||
HeaderMenuState.trigger-hovered = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Compact DIRECT nav button (icon-only, no dropdown) — used by Purchases while
|
||
// the sidebar is fully closed. Active highlight reflects the current view.
|
||
component CompactDirectBtn inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <bool> active: false;
|
||
callback clicked();
|
||
|
||
width: 30px;
|
||
height: 30px;
|
||
border-radius: Radius.sm;
|
||
background: root.active ? Theme.surface-elevated
|
||
: cd-ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
QbzIcon {
|
||
source: root.icon;
|
||
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 ? Theme.text-primary : Theme.text-secondary;
|
||
}
|
||
cd-ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => { root.clicked(); }
|
||
}
|
||
}
|
||
|
||
// Like CompactNavBtn, but instead of a section dropdown it opens the playlists
|
||
// flyout (SidebarPlaylistsPopup). Shown in the closed-sidebar header cluster so
|
||
// playlists stay reachable with the sidebar fully collapsed. Header buttons are
|
||
// not inside a Flickable, so absolute-position needs no correction here.
|
||
component CompactPlaylistsBtn inherits Rectangle {
|
||
width: 30px;
|
||
height: 30px;
|
||
border-radius: Radius.sm;
|
||
property <bool> active: SidebarPlaylistsPopupState.open;
|
||
background: root.active ? Theme.surface-elevated
|
||
: cp-ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
QbzIcon {
|
||
source: @image-url("../assets/icons/list-music.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 ? Theme.text-primary : Theme.text-secondary;
|
||
}
|
||
cp-ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => {
|
||
SidebarPlaylistsPopupState.anchor-x = root.absolute-position.x;
|
||
SidebarPlaylistsPopupState.anchor-y = root.absolute-position.y + root.height + 6px;
|
||
SidebarPlaylistsPopupState.open = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Circular history / collapse button for the header's right cluster —
|
||
// same look as the Discover carousel navigators. `enabled` dims + disables.
|
||
component HeaderNavBtn inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <bool> enabled: true;
|
||
callback clicked();
|
||
|
||
width: 28px;
|
||
height: 28px;
|
||
border-radius: 14px;
|
||
opacity: root.enabled ? 1.0 : 0.4;
|
||
background: hn-ta.has-hover && root.enabled
|
||
? Theme.surface-hover
|
||
: Theme.surface-elevated;
|
||
|
||
QbzIcon {
|
||
source: root.icon;
|
||
width: 15px;
|
||
height: 15px;
|
||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||
tint: root.enabled ? Theme.text-primary : Theme.text-muted;
|
||
}
|
||
|
||
hn-ta := TouchArea {
|
||
enabled: root.enabled;
|
||
mouse-cursor: root.enabled ? pointer : default;
|
||
clicked => {
|
||
if (root.enabled) {
|
||
root.clicked();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Square icon button for the header's right-side controls. `active`
|
||
// gives it a highlighted look when its associated panel is open.
|
||
component HeaderIconButton inherits Rectangle {
|
||
in property <image> icon;
|
||
in property <bool> active: false;
|
||
callback clicked();
|
||
|
||
width: 36px;
|
||
height: 36px;
|
||
border-radius: Radius.sm;
|
||
background: root.active ? Theme.surface-elevated
|
||
: ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
QbzIcon {
|
||
source: root.icon;
|
||
width: 19px;
|
||
height: 19px;
|
||
// Round the centering to whole pixels — a fractional offset
|
||
// (here 8.5px) makes the glyph render blurry.
|
||
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||
tint: root.active ? Theme.accent
|
||
: ta.has-hover ? Theme.text-primary : Theme.text-secondary;
|
||
}
|
||
|
||
ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => {
|
||
root.clicked();
|
||
}
|
||
}
|
||
}
|
||
|
||
// Offline status badge — sits immediately LEFT of the app-menu button.
|
||
// Tri-state (OfflineState.badge-state): 1 = hard offline (amber cloud-off),
|
||
// 2 = manual/induced offline (accent cloud-off), 3 = logged out (muted user
|
||
// glyph; wins over the other two — it's the actionable fact). Not mounted
|
||
// at all when online + authenticated. NOT a pill (ADR-008): ghost chrome
|
||
// styling like NavTab — transparent, hover -> surface-hover, Radius.sm.
|
||
// Clicking opens a small flyout with the full status line plus the state's
|
||
// action (Sign in / Open Settings).
|
||
component OfflineStatusBadge inherits Rectangle {
|
||
// Fires the AppShell recovery-login() chain (the same saved-token
|
||
// sign-in the old recovery banner used).
|
||
callback recovery-login();
|
||
|
||
property <int> badge-state: OfflineState.badge-state;
|
||
property <bool> connectivity-up: OfflineState.connectivity == 1;
|
||
// Only a CONFIRMED-down link disables sign-in. Unknown (0, pre-first-
|
||
// probe — e.g. right after app start) must NOT gate the button: the
|
||
// attempt is harmless and fails into a visible toast if the network is
|
||
// really absent, while a dead button reads as "does nothing".
|
||
property <bool> connectivity-down: OfflineState.connectivity == 2;
|
||
// Icon tint per state: warning/amber = hard, accent = manual,
|
||
// muted = logged out. Same mapping Settings > Offline's status row uses.
|
||
property <color> state-tint: root.badge-state == 1 ? Palette.warning
|
||
: root.badge-state == 2 ? Theme.accent
|
||
: Theme.text-muted;
|
||
|
||
height: 30px;
|
||
width: badge-row.preferred-width;
|
||
border-radius: Radius.sm;
|
||
background: badge-ta.has-hover ? Theme.surface-hover : transparent;
|
||
|
||
badge-row := HorizontalLayout {
|
||
padding-left: 9px;
|
||
padding-right: 11px;
|
||
spacing: 6px;
|
||
VerticalLayout {
|
||
alignment: center;
|
||
QbzIcon {
|
||
source: root.badge-state == 3
|
||
? @image-url("../assets/icons/user.svg")
|
||
: @image-url("../assets/icons/cloud-off.svg");
|
||
width: 14px;
|
||
height: 14px;
|
||
tint: root.state-tint;
|
||
}
|
||
}
|
||
Text {
|
||
text: root.badge-state == 3 ? @tr("Logged out")
|
||
: root.badge-state == 2 ? @tr("Offline (manual)")
|
||
: @tr("Offline (hard)");
|
||
height: root.height;
|
||
vertical-alignment: center;
|
||
color: Theme.text-secondary;
|
||
font-size: 11px;
|
||
}
|
||
}
|
||
|
||
badge-ta := TouchArea {
|
||
mouse-cursor: pointer;
|
||
clicked => {
|
||
status-flyout.show();
|
||
}
|
||
}
|
||
|
||
// Status flyout — the former banner texts + actions, right edge aligned
|
||
// with the badge. PopupWindow footgun: explicit height + close-policy.
|
||
// Buttons close it explicitly before acting.
|
||
status-flyout := PopupWindow {
|
||
x: root.width - 320px;
|
||
y: root.height + 6px;
|
||
width: 320px;
|
||
height: root.badge-state == 1 ? 74px
|
||
: root.badge-state == 2 ? 108px
|
||
: 116px;
|
||
close-policy: PopupClosePolicy.close-on-click-outside;
|
||
|
||
Rectangle {
|
||
background: Theme.surface-main;
|
||
border-radius: Radius.sm;
|
||
border-width: 1px;
|
||
border-color: Theme.border-muted;
|
||
drop-shadow-blur: 24px;
|
||
drop-shadow-color: Theme.card-shadow;
|
||
drop-shadow-offset-y: 6px;
|
||
|
||
VerticalLayout {
|
||
padding: 14px;
|
||
spacing: 12px;
|
||
HorizontalLayout {
|
||
spacing: 8px;
|
||
VerticalLayout {
|
||
alignment: start;
|
||
QbzIcon {
|
||
source: root.badge-state == 3
|
||
? @image-url("../assets/icons/user.svg")
|
||
: @image-url("../assets/icons/cloud-off.svg");
|
||
width: 15px;
|
||
height: 15px;
|
||
tint: root.state-tint;
|
||
}
|
||
}
|
||
Text {
|
||
// Full status line per state; logged-out also keys
|
||
// on raw connectivity (1 up / 2 down / 0 unknown).
|
||
text: root.badge-state == 3
|
||
? (root.connectivity-down
|
||
? @tr("You're signed out. Sign-in needs a connection.")
|
||
: root.connectivity-up
|
||
? @tr("Connection available — sign back in to Qobuz.")
|
||
: @tr("You're signed out — sign back in to Qobuz."))
|
||
: root.badge-state == 2
|
||
? @tr("Offline mode is enabled. Disable it in Settings to use Qobuz.")
|
||
: @tr("No internet connection — your local library and downloads keep working.");
|
||
color: Theme.text-primary;
|
||
font-size: 12px;
|
||
wrap: word-wrap;
|
||
horizontal-stretch: 1;
|
||
}
|
||
}
|
||
// Sign in — logged-out state only; disabled only when the
|
||
// link is CONFIRMED down (Unknown still allows the attempt).
|
||
// Fires the existing recovery-login() chain.
|
||
if root.badge-state == 3: HorizontalLayout {
|
||
alignment: end;
|
||
SecondaryButton {
|
||
label: @tr("Sign in");
|
||
enabled: !root.connectivity-down;
|
||
clicked => {
|
||
// Fire the chain BEFORE close(): the popup
|
||
// teardown must never be able to swallow it
|
||
// (same action-then-close ordering as the
|
||
// PlayerBar's qconnect menu items).
|
||
root.recovery-login();
|
||
status-flyout.close();
|
||
}
|
||
}
|
||
}
|
||
// Manual/induced state: quick toggle straight back to online
|
||
// (same persistence + #279 path as the Settings toggle). The
|
||
// toggle is the whole control set here — owner dropped the
|
||
// Settings shortcut (2026-06-10).
|
||
if root.badge-state == 2: HorizontalLayout {
|
||
spacing: 8px;
|
||
Text {
|
||
text: @tr("Offline mode");
|
||
color: Theme.text-secondary;
|
||
font-size: 12px;
|
||
vertical-alignment: center;
|
||
horizontal-stretch: 1;
|
||
}
|
||
QbzToggle {
|
||
checked: true;
|
||
toggled(value) => {
|
||
OfflineModeActions.set-offline(value);
|
||
status-flyout.close();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
export component HeaderBar inherits Rectangle {
|
||
callback logout();
|
||
callback close-app();
|
||
// Forwarded up to AppShell — the badge flyout's "Sign in" (saved-token
|
||
// re-login during an unauthenticated offline session).
|
||
callback recovery-login();
|
||
// Direct route navigation (Purchases header tab) — funnels into the same
|
||
// `header-menu-navigate` route handler the dropdown menus use.
|
||
callback navigate(string /* route */);
|
||
|
||
height: Layout.header-height;
|
||
background: Theme.surface-card;
|
||
|
||
// Responsive breakpoints.
|
||
property <bool> show-tab-icons: root.width >= 1140px;
|
||
// 80% of the prior search width (was 224px / 320px). When the section nav
|
||
// is in the header (nav-in-sidebar off) it gives up 60px to make room.
|
||
property <length> search-width:
|
||
(root.width < 960px ? 179px : 256px) - (ShellState.nav-in-sidebar ? 0px : 60px);
|
||
|
||
// The section nav now lives inside the left-controls cluster (after the
|
||
// three sacred nav buttons), so it can never overlap them.
|
||
|
||
// Defensive hotkey-guard hygiene on every page change: release the search
|
||
// field's keyboard focus (a TouchArea click that navigates does NOT steal
|
||
// focus from a TextInput, so single-key hotkeys stayed dead after a search
|
||
// until the user clicked into another focusable) and drop the typing guard
|
||
// in case the previously focused input was unmounted with the old view
|
||
// (an unmounted input's `changed has-focus` never fires false, leaving the
|
||
// flag stuck true).
|
||
property <ContentView> nav-view-probe: NavState.view;
|
||
changed nav-view-probe => {
|
||
search-input.clear-focus();
|
||
search-scope.clear-focus();
|
||
UiFocusState.text-input-focused = false;
|
||
}
|
||
|
||
// --- Custom window chrome (the header IS the title bar) ----------------
|
||
// Owner decision 2026-07-03: the header is always present; custom chrome
|
||
// only adds the window controls + drag to it (and app.slint drops the
|
||
// system decorations). Linux draws the min/max/close cluster; macOS keeps
|
||
// the native traffic lights (overlay attributes from the winit hook) and
|
||
// only needs the drag surface + a left inset under the lights.
|
||
property <bool> chrome-drag-enabled:
|
||
!AppearanceState.system-title-bar-active && !AppearanceState.hide-title-bar;
|
||
property <bool> chrome-controls:
|
||
root.chrome-drag-enabled && !AppearanceState.is-macos
|
||
&& AppearanceState.show-window-controls;
|
||
property <bool> wc-on-left: AppearanceState.wc-position-index == 0;
|
||
// 3 × 34px buttons + 2 × 2px spacing (WindowControls.slint).
|
||
property <length> wc-cluster-width: 106px;
|
||
// Left inset: the native traffic-light band on macOS (~70px logical; 78px
|
||
// keeps a comfortable gap) or the drawn cluster when positioned left.
|
||
property <length> chrome-left-inset:
|
||
AppearanceState.is-macos && !AppearanceState.system-title-bar-active ? 78px
|
||
: (root.chrome-controls && root.wc-on-left ? root.wc-cluster-width + 6px : 0px);
|
||
|
||
// Custom-chrome drag surface. Declared FIRST among the header's elements
|
||
// so every interactive element declared later wins hit-testing — presses
|
||
// on empty header area move the window; double-click toggles maximize.
|
||
// The drag starts only after a real movement: the OS drag steals the
|
||
// pointer, which would kill click/double-click semantics (same threshold
|
||
// idiom as the TrackRow drag).
|
||
if root.chrome-drag-enabled: TouchArea {
|
||
// drag_window() must fire ONCE per press: on Wayland the compositor
|
||
// move-grab swallows the button release, so `pressed` goes stale-true
|
||
// and every later motion would re-grab the window onto the cursor.
|
||
// The latch resets on the next real press (pointer-event down).
|
||
property <bool> drag-started: false;
|
||
double-clicked => { WindowControlActions.toggle-maximize(); }
|
||
pointer-event(ev) => {
|
||
if (ev.kind == PointerEventKind.down) {
|
||
self.drag-started = false;
|
||
}
|
||
}
|
||
moved => {
|
||
if (self.pressed && !self.drag-started
|
||
&& (Math.abs((self.mouse-x - self.pressed-x) / 1px) > 4
|
||
|| Math.abs((self.mouse-y - self.pressed-y) / 1px) > 4)) {
|
||
self.drag-started = true;
|
||
WindowControlActions.drag-move();
|
||
}
|
||
}
|
||
}
|
||
|
||
// Drawn window controls (Linux custom chrome). Right placement sits at the
|
||
// window edge, right of the hamburger; left placement takes the corner the
|
||
// traffic lights use on macOS (the left cluster shifts right to clear it).
|
||
if root.chrome-controls && !root.wc-on-left: WindowControls {
|
||
x: root.width - self.preferred-width - 8px;
|
||
y: (root.height - self.preferred-height) / 2;
|
||
}
|
||
if root.chrome-controls && root.wc-on-left: WindowControls {
|
||
x: 8px;
|
||
y: (root.height - self.preferred-height) / 2;
|
||
}
|
||
|
||
// --- Search (absolutely centered on the window) ------------------------
|
||
// The search box is wrapped in a FocusScope so the cortinilla (the live
|
||
// dropdown) can be driven by the keyboard WITHOUT stealing focus from the
|
||
// input. Idiom (mirrors PlaylistPickerModal): the FocusScope owns focus and
|
||
// `forward-focus: search-input` routes typing into the TextInput. The
|
||
// FocusScope's key-pressed runs FIRST — it `accept`s Up/Down/Enter/Escape
|
||
// (cortinilla nav) so the input never sees them as cursor moves, and
|
||
// `reject`s every other key so normal typing reaches the input. This keeps
|
||
// the input visibly focused + typeable while arrows move the highlight.
|
||
search-scope := FocusScope {
|
||
x: (root.width - self.width) / 2;
|
||
y: (root.height - self.height) / 2;
|
||
width: root.search-width;
|
||
// Smoothly animate the width change when the nav moves in/out of the
|
||
// header (and the x recenters with it).
|
||
animate width { duration: 220ms; easing: ease-in-out; }
|
||
height: 32px;
|
||
forward-focus: search-input;
|
||
|
||
// Enter ALWAYS goes to Search > All when the cortinilla is open — it
|
||
// never opens a hovered/lingering selection (the user's rule: only a
|
||
// CLICK opens a specific row; Enter is always the full search). Closed ->
|
||
// the plain submit, which also lands on the results page (All tab).
|
||
// Enter activates the CURRENT keyboard selection: a row when one is
|
||
// arrow-highlighted (selected-index >= 0), else "Full results" (Search >
|
||
// All). Hover no longer writes selected-index, so a stale hover can never
|
||
// hijack Enter. Cortinilla closed -> the plain submit (also Search > All).
|
||
function on-enter() {
|
||
if (SearchState.cortinilla-open) {
|
||
if (SearchState.selected-index >= 0) {
|
||
SearchActions.cortinilla-row-clicked(SearchState.selected-index);
|
||
} else {
|
||
SearchActions.cortinilla-search-all();
|
||
}
|
||
} else {
|
||
SearchActions.submit(search-input.text);
|
||
}
|
||
}
|
||
|
||
key-pressed(event) => {
|
||
// While the cortinilla is open, arrows move the keyboard selection,
|
||
// Enter activates it, Escape dismisses — all WITHOUT the input losing
|
||
// focus. Otherwise the keys reach the input (single-line cursor moves
|
||
// are a harmless no-op).
|
||
if (event.text == Key.DownArrow) {
|
||
if (SearchState.cortinilla-open) {
|
||
SearchActions.cortinilla-move-selection(1);
|
||
return accept;
|
||
}
|
||
return reject;
|
||
}
|
||
if (event.text == Key.UpArrow) {
|
||
if (SearchState.cortinilla-open) {
|
||
SearchActions.cortinilla-move-selection(-1);
|
||
return accept;
|
||
}
|
||
return reject;
|
||
}
|
||
if (event.text == Key.Return) {
|
||
search-scope.on-enter();
|
||
return accept;
|
||
}
|
||
if (event.text == Key.Escape) {
|
||
if (SearchState.cortinilla-open) {
|
||
SearchActions.cortinilla-dismiss();
|
||
return accept;
|
||
}
|
||
return reject;
|
||
}
|
||
// Everything else (letters, backspace, …) goes to the input.
|
||
return reject;
|
||
}
|
||
|
||
Rectangle {
|
||
width: 100%;
|
||
height: 100%;
|
||
border-radius: 6px;
|
||
border-width: 1px;
|
||
border-color: Theme.border-subtle;
|
||
background: Theme.surface-elevated;
|
||
|
||
// Magnifier — absolutely positioned on the left so it does NOT take
|
||
// layout space; the text/placeholder center against the full input
|
||
// width as if the icon weren't there.
|
||
QbzIcon {
|
||
source: @image-url("../assets/icons/search.svg");
|
||
width: 14px;
|
||
height: 14px;
|
||
x: 10px;
|
||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||
tint: Theme.text-muted;
|
||
}
|
||
|
||
// Full-width input — text centered against the whole box.
|
||
search-input := TextInput {
|
||
width: parent.width;
|
||
height: 100%;
|
||
color: Theme.text-primary;
|
||
font-size: 13px;
|
||
vertical-alignment: center;
|
||
horizontal-alignment: center;
|
||
single-line: true;
|
||
// Two-way bound so the controller can clear the field after a
|
||
// cortinilla element is activated (stops the focus-bounce
|
||
// re-invocation). Typing still flows through `edited` below.
|
||
text <=> SearchState.header-search-text;
|
||
// Enter is handled by the FocusScope (cortinilla-aware); keep
|
||
// `accepted` as a fallback for the rare case the input owns the
|
||
// event directly (e.g. focus routed straight to it).
|
||
accepted => { search-scope.on-enter(); }
|
||
edited => { SearchActions.live(self.text); }
|
||
// On focus-IN: route focus to the wrapping scope (so its
|
||
// key-pressed intercepts arrows) and re-open the cortinilla.
|
||
// On focus-OUT the AppShell scrim handles click-outside; a pure
|
||
// focus-out (e.g. Tab away) is dismissed via Escape /
|
||
// click-outside, matching the menu overlays.
|
||
changed has-focus => {
|
||
// Hotkey guard: while the search field has focus, the global
|
||
// key dispatcher must ignore single-key shortcuts.
|
||
UiFocusState.text-input-focused = self.has-focus;
|
||
if (self.has-focus) {
|
||
// A direct click focuses the TextInput, NOT the wrapping
|
||
// FocusScope — and then the scope's key-pressed (the
|
||
// cortinilla arrow/Enter/Escape interception) would not
|
||
// run. Route focus to the scope so it owns the key
|
||
// events; `forward-focus: search-input` immediately hands
|
||
// the cursor back to this input, so typing is unaffected.
|
||
search-scope.focus();
|
||
// Refresh the cortinilla when focus returns with a usable
|
||
// query — but ONLY while it is already open. Focus can
|
||
// land here without user intent (Slint reassigns focus
|
||
// when the focused element unmounts on a page change, and
|
||
// on window re-activation); an ungated live() here
|
||
// resurrected the dropdown out of nowhere on navigation.
|
||
// Typing still opens it through `edited` above.
|
||
if (self.text != "" && SearchState.cortinilla-open) {
|
||
SearchActions.live(self.text);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Text {
|
||
visible: search-input.text == "";
|
||
text: @tr("Search");
|
||
width: parent.width;
|
||
height: 100%;
|
||
color: Theme.text-muted;
|
||
font-size: 13px;
|
||
vertical-alignment: center;
|
||
horizontal-alignment: center;
|
||
}
|
||
|
||
// Enter hint — mirrors the magnifier but on the RIGHT edge, shown
|
||
// only while the cortinilla is open (the live dropdown replaced the
|
||
// in-dropdown "Full results" row with this contextual key hint).
|
||
// Absolutely positioned so it takes no layout space — the centered
|
||
// query text is unaffected. Enter runs the search / opens the
|
||
// highlighted result.
|
||
Text {
|
||
visible: SearchState.cortinilla-open;
|
||
text: "↵ " + @tr("Enter");
|
||
color: Theme.text-muted;
|
||
font-size: 11px;
|
||
font-weight: Typography.medium;
|
||
x: parent.width - self.width - 10px;
|
||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||
}
|
||
}
|
||
}
|
||
|
||
// --- Left controls: history nav + collapse (anchored left) -------------
|
||
// The three navigation buttons (back / forward / sidebar-collapse) float
|
||
// at the header's LEFT edge.
|
||
left-controls := HorizontalLayout {
|
||
x: Spacing.md + root.chrome-left-inset;
|
||
y: (root.height - self.height) / 2;
|
||
width: self.preferred-width;
|
||
height: 36px;
|
||
spacing: 6px;
|
||
VerticalLayout {
|
||
alignment: center;
|
||
HeaderNavBtn {
|
||
icon: @image-url("../assets/icons/panel-left.svg");
|
||
clicked => { ShellState.cycle-sidebar(); }
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
HeaderNavBtn {
|
||
icon: @image-url("../assets/icons/chevron-left.svg");
|
||
enabled: NavState.can-back;
|
||
clicked => { NavState.request-back(); }
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
HeaderNavBtn {
|
||
icon: @image-url("../assets/icons/chevron-right.svg");
|
||
enabled: NavState.can-forward;
|
||
clicked => { NavState.request-forward(); }
|
||
}
|
||
}
|
||
// Full section nav (text tabs) — header-nav mode (nav-in-sidebar OFF)
|
||
// while the sidebar isn't fully closed. Sits AFTER the three sacred
|
||
// buttons, so it never overlaps them. Mutually exclusive with the
|
||
// compact icons below (which show when fully closed, or always when
|
||
// the user opted into the compact header nav).
|
||
if !ShellState.nav-in-sidebar && ShellState.sidebar-state != 2
|
||
&& !ShellState.nav-header-compact: HorizontalLayout {
|
||
spacing: 2px;
|
||
Rectangle { width: 6px; }
|
||
// Qobuz-only — HIDDEN entirely while offline (ADR-010 `if` at
|
||
// the mount site, not rendered-disabled).
|
||
// Discover. Two mounts (Slint can't infer [NavMenuEntry] from a
|
||
// ternary of array literals): WITH the opt-in Recommendations entry,
|
||
// or without, gated by the opt-out setting.
|
||
if !OfflineState.offline && SettingsState.show-recommendations: VerticalLayout {
|
||
alignment: center;
|
||
NavTabWithMenu {
|
||
tab-index: 0;
|
||
icon: @image-url("../assets/icons/compass.svg");
|
||
label: @tr("Discover");
|
||
active: true;
|
||
show-icon: root.show-tab-icons;
|
||
home-item: 0;
|
||
items: [
|
||
{ label: @tr("Home"), has-glyph: false, route: "discover-home" },
|
||
{ label: @tr("Editor's Picks"), has-glyph: false, route: "discover-editorPicks" },
|
||
{ label: @tr("For You"), has-glyph: false, route: "discover-forYou" },
|
||
{ label: @tr("Recommendations"), has-glyph: false, route: "discover-recommendations" },
|
||
];
|
||
}
|
||
}
|
||
if !OfflineState.offline && !SettingsState.show-recommendations: VerticalLayout {
|
||
alignment: center;
|
||
NavTabWithMenu {
|
||
tab-index: 0;
|
||
icon: @image-url("../assets/icons/compass.svg");
|
||
label: @tr("Discover");
|
||
active: true;
|
||
show-icon: root.show-tab-icons;
|
||
home-item: 0;
|
||
items: [
|
||
{ label: @tr("Home"), has-glyph: false, route: "discover-home" },
|
||
{ label: @tr("Editor's Picks"), has-glyph: false, route: "discover-editorPicks" },
|
||
{ label: @tr("For You"), has-glyph: false, route: "discover-forYou" },
|
||
];
|
||
}
|
||
}
|
||
// Qobuz favorites — HIDDEN entirely while offline.
|
||
if !OfflineState.offline: VerticalLayout {
|
||
alignment: center;
|
||
NavTabWithMenu {
|
||
tab-index: 1;
|
||
icon: @image-url("../assets/icons/music-library-2.svg");
|
||
label: @tr("Library");
|
||
show-icon: root.show-tab-icons;
|
||
items: [
|
||
{ label: @tr("Tracks"), icon: @image-url("../assets/icons/music.svg"), has-glyph: true, route: "favorites-tracks" },
|
||
{ label: @tr("Albums"), icon: @image-url("../assets/icons/disc.svg"), has-glyph: true, route: "favorites-albums" },
|
||
{ label: @tr("Artists"), icon: @image-url("../assets/icons/user.svg"), has-glyph: true, route: "favorites-artists" },
|
||
{ label: @tr("Playlists"), icon: @image-url("../assets/icons/list-music.svg"), has-glyph: true, route: "favorites-playlists" },
|
||
{ label: @tr("Labels"), icon: @image-url("../assets/icons/disc-3.svg"), has-glyph: true, route: "favorites-labels" },
|
||
];
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
NavTabWithMenu {
|
||
tab-index: 2;
|
||
icon: @image-url("../assets/icons/hard-drive.svg");
|
||
label: @tr("Local Library");
|
||
show-icon: root.show-tab-icons;
|
||
items: [
|
||
{ label: @tr("Albums"), icon: @image-url("../assets/icons/disc.svg"), has-glyph: true, route: "local-albums" },
|
||
{ label: @tr("Artists"), icon: @image-url("../assets/icons/user.svg"), has-glyph: true, route: "local-artists" },
|
||
{ label: @tr("Folders"), icon: @image-url("../assets/icons/folder.svg"), has-glyph: true, route: "local-folders" },
|
||
{ label: @tr("Tracks"), icon: @image-url("../assets/icons/music.svg"), has-glyph: true, route: "local-tracks" },
|
||
];
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
NavTabWithMenu {
|
||
tab-index: 3;
|
||
icon: @image-url("../assets/icons/qbz-symbolic.svg");
|
||
label: @tr("My QBZ");
|
||
show-icon: root.show-tab-icons;
|
||
items: [
|
||
{ label: @tr("Collections"), icon: @image-url("../assets/icons/library-big.svg"), has-glyph: true, route: "myqbz-collections" },
|
||
{ label: @tr("Mixtapes"), icon: @image-url("../assets/icons/cassette-tape.svg"), has-glyph: true, route: "myqbz-mixtapes" },
|
||
];
|
||
}
|
||
}
|
||
// Purchases — opt-in (default OFF). DIRECT tab (no dropdown), active
|
||
// for both the list + per-album detail views. HIDDEN while offline.
|
||
// Titlebar-placement (§5.8 truth table): the title bar hosts the
|
||
// entry iff `S && T && TB` — only when the user enabled "Purchases
|
||
// in title bar" (`nav-tb-purchases`) AND the custom title bar is
|
||
// actually shown. Otherwise it stays in the sidebar (Sidebar.slint).
|
||
if AppearanceState.show-purchases && !OfflineState.offline
|
||
&& AppearanceState.nav-tb-purchases
|
||
&& !AppearanceState.hide-title-bar
|
||
&& !AppearanceState.system-title-bar-active: VerticalLayout {
|
||
alignment: center;
|
||
NavTab {
|
||
icon: @image-url("../assets/icons/shopping-bag.svg");
|
||
label: @tr("Purchases");
|
||
show-icon: root.show-tab-icons;
|
||
active: NavState.view == ContentView.purchases
|
||
|| NavState.view == ContentView.purchase-album;
|
||
clicked => {
|
||
root.navigate("purchases");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// Compact section nav — while the sidebar is fully closed (Cerrado),
|
||
// so Discover / Library / Local Library / My QBZ stay reachable, or
|
||
// ALWAYS when the user opted into the compact header nav (nav in
|
||
// header + "Compact header navigation" ON). Icon-only; each opens a
|
||
// titled downward dropdown.
|
||
if ShellState.sidebar-state == 2
|
||
|| (!ShellState.nav-in-sidebar && ShellState.nav-header-compact): HorizontalLayout {
|
||
spacing: 2px;
|
||
// A small gap from the history buttons.
|
||
Rectangle { width: 6px; }
|
||
// Qobuz-only — HIDDEN entirely while offline (ADR-010 `if` at
|
||
// the mount site, not rendered-disabled).
|
||
// Discover. Two mounts (Slint can't infer [NavMenuEntry] from a
|
||
// ternary of array literals): WITH the opt-in Recommendations entry,
|
||
// or without, gated by the opt-out setting.
|
||
if !OfflineState.offline && SettingsState.show-recommendations: VerticalLayout {
|
||
alignment: center;
|
||
CompactNavBtn {
|
||
tab-index: 0;
|
||
title: @tr("Discover");
|
||
icon: @image-url("../assets/icons/compass.svg");
|
||
home-item: 0;
|
||
items: [
|
||
{ label: @tr("Home"), has-glyph: false, route: "discover-home" },
|
||
{ label: @tr("Editor's Picks"), has-glyph: false, route: "discover-editorPicks" },
|
||
{ label: @tr("For You"), has-glyph: false, route: "discover-forYou" },
|
||
{ label: @tr("Recommendations"), has-glyph: false, route: "discover-recommendations" },
|
||
];
|
||
}
|
||
}
|
||
if !OfflineState.offline && !SettingsState.show-recommendations: VerticalLayout {
|
||
alignment: center;
|
||
CompactNavBtn {
|
||
tab-index: 0;
|
||
title: @tr("Discover");
|
||
icon: @image-url("../assets/icons/compass.svg");
|
||
home-item: 0;
|
||
items: [
|
||
{ label: @tr("Home"), has-glyph: false, route: "discover-home" },
|
||
{ label: @tr("Editor's Picks"), has-glyph: false, route: "discover-editorPicks" },
|
||
{ label: @tr("For You"), has-glyph: false, route: "discover-forYou" },
|
||
];
|
||
}
|
||
}
|
||
// Qobuz favorites — HIDDEN entirely while offline.
|
||
if !OfflineState.offline: VerticalLayout {
|
||
alignment: center;
|
||
CompactNavBtn {
|
||
tab-index: 1;
|
||
title: @tr("Library");
|
||
icon: @image-url("../assets/icons/music-library-2.svg");
|
||
items: [
|
||
{ label: @tr("Tracks"), icon: @image-url("../assets/icons/music.svg"), has-glyph: true, route: "favorites-tracks" },
|
||
{ label: @tr("Albums"), icon: @image-url("../assets/icons/disc.svg"), has-glyph: true, route: "favorites-albums" },
|
||
{ label: @tr("Artists"), icon: @image-url("../assets/icons/user.svg"), has-glyph: true, route: "favorites-artists" },
|
||
{ label: @tr("Playlists"), icon: @image-url("../assets/icons/list-music.svg"), has-glyph: true, route: "favorites-playlists" },
|
||
{ label: @tr("Labels"), icon: @image-url("../assets/icons/disc-3.svg"), has-glyph: true, route: "favorites-labels" },
|
||
];
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
CompactNavBtn {
|
||
tab-index: 2;
|
||
title: @tr("Local Library");
|
||
icon: @image-url("../assets/icons/hard-drive.svg");
|
||
items: [
|
||
{ label: @tr("Albums"), icon: @image-url("../assets/icons/disc.svg"), has-glyph: true, route: "local-albums" },
|
||
{ label: @tr("Artists"), icon: @image-url("../assets/icons/user.svg"), has-glyph: true, route: "local-artists" },
|
||
{ label: @tr("Folders"), icon: @image-url("../assets/icons/folder.svg"), has-glyph: true, route: "local-folders" },
|
||
{ label: @tr("Tracks"), icon: @image-url("../assets/icons/music.svg"), has-glyph: true, route: "local-tracks" },
|
||
];
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
CompactNavBtn {
|
||
tab-index: 3;
|
||
title: @tr("My QBZ");
|
||
icon: @image-url("../assets/icons/qbz-symbolic.svg");
|
||
items: [
|
||
{ label: @tr("Collections"), icon: @image-url("../assets/icons/library-big.svg"), has-glyph: true, route: "myqbz-collections" },
|
||
{ label: @tr("Mixtapes"), icon: @image-url("../assets/icons/cassette-tape.svg"), has-glyph: true, route: "myqbz-mixtapes" },
|
||
];
|
||
}
|
||
}
|
||
// Purchases — opt-in (default OFF). DIRECT button. HIDDEN offline.
|
||
// Titlebar-placement (§5.8 truth table): shown in the header iff
|
||
// `S && T && TB` — same gate as the full-nav tab above.
|
||
if AppearanceState.show-purchases && !OfflineState.offline
|
||
&& AppearanceState.nav-tb-purchases
|
||
&& !AppearanceState.hide-title-bar
|
||
&& !AppearanceState.system-title-bar-active: VerticalLayout {
|
||
alignment: center;
|
||
CompactDirectBtn {
|
||
icon: @image-url("../assets/icons/shopping-bag.svg");
|
||
active: NavState.view == ContentView.purchases
|
||
|| NavState.view == ContentView.purchase-album;
|
||
clicked => {
|
||
root.navigate("purchases");
|
||
}
|
||
}
|
||
}
|
||
// Thin separator, then the playlists flyout button (no sidebar list
|
||
// to reach playlists from while fully closed). Gated on the
|
||
// sidebar actually being closed — in the opt-in always-compact
|
||
// mode the sidebar list is reachable, so the button keeps its
|
||
// original closed-sidebar-only behavior.
|
||
if ShellState.sidebar-state == 2: Rectangle {
|
||
width: 1px;
|
||
height: 18px;
|
||
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
||
background: Theme.border-subtle;
|
||
}
|
||
if ShellState.sidebar-state == 2: VerticalLayout {
|
||
alignment: center;
|
||
CompactPlaylistsBtn { }
|
||
}
|
||
}
|
||
}
|
||
|
||
// --- Right controls: status badge + app menu (anchored right) ----------
|
||
right-controls := HorizontalLayout {
|
||
// Shifts left of the drawn window controls when those sit on the right.
|
||
x: root.width - self.width - Spacing.md + 2px
|
||
- (root.chrome-controls && !root.wc-on-left ? root.wc-cluster-width + 4px : 0px);
|
||
y: (root.height - self.height) / 2;
|
||
width: self.preferred-width;
|
||
height: 36px;
|
||
spacing: 4px;
|
||
// Offline status badge — mounted only when there is something to
|
||
// say (ADR-010). Lives INSIDE this fixed-height header row, so it
|
||
// can never affect the shell's vertical layout.
|
||
if OfflineState.badge-state != 0: VerticalLayout {
|
||
alignment: center;
|
||
OfflineStatusBadge {
|
||
recovery-login => {
|
||
root.recovery-login();
|
||
}
|
||
}
|
||
}
|
||
VerticalLayout {
|
||
alignment: center;
|
||
HeaderIconButton {
|
||
icon: @image-url("../assets/icons/menu.svg");
|
||
clicked => {
|
||
menu.show();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
menu := PopupWindow {
|
||
// Tracks the hamburger, which shifts left of the drawn window controls
|
||
// in custom-chrome mode (right placement).
|
||
x: parent.width - 234px - Spacing.md
|
||
- (root.chrome-controls && !root.wc-on-left ? root.wc-cluster-width + 4px : 0px);
|
||
y: Layout.header-height - 4px;
|
||
width: 234px;
|
||
height: 344px;
|
||
|
||
Rectangle {
|
||
background: Theme.surface-main;
|
||
border-radius: Radius.sm;
|
||
border-width: 1px;
|
||
border-color: Theme.border-muted;
|
||
drop-shadow-blur: 24px;
|
||
drop-shadow-color: Theme.card-shadow;
|
||
drop-shadow-offset-y: 6px;
|
||
|
||
VerticalLayout {
|
||
padding-top: 6px;
|
||
padding-bottom: 6px;
|
||
|
||
// Signed-in user — name and subscription tier.
|
||
HorizontalLayout {
|
||
padding-left: 14px;
|
||
padding-right: 14px;
|
||
padding-top: 6px;
|
||
padding-bottom: 10px;
|
||
VerticalLayout {
|
||
spacing: 2px;
|
||
Text {
|
||
text: SessionState.user-name == ""
|
||
? @tr("Guest")
|
||
: SessionState.user-name;
|
||
color: Theme.text-primary;
|
||
font-size: Typography.body;
|
||
font-weight: Typography.semibold;
|
||
}
|
||
Text {
|
||
text: SessionState.subscription == ""
|
||
? @tr("Not signed in")
|
||
: SessionState.subscription;
|
||
color: Theme.text-muted;
|
||
font-size: 12px;
|
||
}
|
||
}
|
||
}
|
||
Rectangle {
|
||
height: 1px;
|
||
background: Theme.border-subtle;
|
||
}
|
||
Rectangle { height: 4px; }
|
||
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/settings.svg");
|
||
label: @tr("Settings");
|
||
clicked => {
|
||
NavState.request-settings();
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/link.svg");
|
||
label: @tr("Open Music Link");
|
||
clicked => {
|
||
menu.close();
|
||
LinkResolverState.url = "";
|
||
LinkResolverState.platform = "";
|
||
LinkResolverState.error = "";
|
||
LinkResolverState.playlist-detected = false;
|
||
LinkResolverState.resolving = false;
|
||
LinkResolverState.open = true;
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/keyboard.svg");
|
||
label: @tr("Keyboard Shortcuts");
|
||
clicked => {
|
||
menu.close();
|
||
KeyboardShortcutsState.open = true;
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/book-open.svg");
|
||
label: @tr("Documentation");
|
||
clicked => {
|
||
menu.close();
|
||
// Opens in the system browser (generic external-link
|
||
// handler). Points at the project Wiki.
|
||
AlbumActions.open-external-link("https://github.com/vicrodh/qbz/wiki");
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/bug.svg");
|
||
label: @tr("Report an Issue");
|
||
clicked => {
|
||
menu.close();
|
||
ReportIssueState.open = true;
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/wand-sparkles.svg");
|
||
label: @tr("What's New");
|
||
clicked => {
|
||
menu.close();
|
||
WhatsNewActions.open();
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/info.svg");
|
||
label: @tr("About QBZ");
|
||
clicked => {
|
||
menu.close();
|
||
AboutState.open = true;
|
||
}
|
||
}
|
||
Rectangle {
|
||
height: 1px;
|
||
background: Theme.border-subtle;
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/log-out.svg");
|
||
label: @tr("Log Out");
|
||
clicked => {
|
||
root.logout();
|
||
}
|
||
}
|
||
MenuItem {
|
||
icon: @image-url("../assets/icons/x.svg");
|
||
label: @tr("Close");
|
||
clicked => {
|
||
root.close-app();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|