refactor(slint): split qbz-slint into qbz-ui lib + qbz bin; reclaim qbz binary

Slint cannot split the .slint compilation across crates, but a Slint LIBRARY
crate exposes its generated Rust types to dependent crates (verified with a
minimal proof). So:

- NEW crate `qbz-ui` (lib): owns the whole .slint tree + build.rs + bundled
  translations; `slint::include_modules!()` + the generated types (AppWindow,
  MiniPlayerWindow, all globals/structs) are re-exported. Translation domain is
  now `qbz-ui` (the .po files renamed accordingly).
- `qbz-slint` (bin) -> renamed to `qbz` (package + `[[bin]] name = "qbz"`),
  reclaiming the binary name from the retired Tauri app. It depends on `qbz-ui`
  and does `pub use qbz_ui::*;` so existing `crate::AppWindow` / `crate::*State`
  references resolve unchanged.

This splits the single ~20 GB rustc into two crates (UI/codegen vs the 75k LOC
of logic) — the foundation for lower build peak, incremental caching, and the
upcoming per-feature crate extraction.

Also fixed for the move: qbz-i18n bundled-.po include paths, the font/WGSL
`include_bytes!`/`include_str!` paths (-> ../../qbz-ui/ui/), workspace members,
dev scripts (`-p qbz`), and the CI workflows. `cargo check -p qbz` is green.

cc
This commit is contained in:
vicrodh committed 2026-06-25 17:51:09 -06:00
1 parent b9eb300516
commit c8ef2a1b1d
465 files changed
+129 -89

No files matched your search

+407
View File
@@ -0,0 +1,407 @@
// Album card for the Discover sections.
//
// Mirrors the Svelte AlbumCardLite, scaled to a 200px column / 200px artwork
// with a bottom-left award ribbon and a hover overlay (dark scrim,
// genre/year meta, and play / favorite / more action buttons), then a
// tight title / artist stack alongside an icon-only quality badge.
// Deterministic 266px height.
//
// The "more" overlay button opens a context menu; its actions bubble up
// as media-action(kind, id, action).
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { Spacing } from "../foundation/spacing.slint";
import { AlbumCardItem, NavState, TooltipState } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QualityBadge } from "../primitives/QualityBadge.slint";
import { ContextMenu } from "../primitives/ContextMenu.slint";
import { ContextMenuItem } from "../primitives/ContextMenuItem.slint";
// Circular hover-overlay action button. Solid (semi-transparent) fill so
// the whole circle is a stable hit/hover surface — an outline-only button
// makes the pointer flicker between the ring and the transparent center.
component OverlayButton inherits Rectangle {
in property <image> icon;
in property <bool> primary: false;
in property <length> diameter: 36px;
in property <length> icon-size: 16px;
in property <bool> active: false;
out property <bool> hovered: ta.has-hover;
callback clicked();
width: root.diameter;
height: root.diameter;
border-radius: root.diameter / 2;
background: root.primary
? (ta.has-hover ? #ffffffd6 : #ffffff)
: (ta.has-hover ? #ffffff3d : #ffffff24);
border-width: root.primary ? 0px : 1.5px;
border-color: #ffffffcc;
QbzIcon {
source: root.icon;
width: root.icon-size;
height: root.icon-size;
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
: (root.primary ? #000000 : #ffffff);
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
// Forward the mouse back/forward buttons to history nav (a TouchArea
// swallows them, so they never reach the AppShell catcher).
pointer-event(e) => {
if (e.kind == PointerEventKind.down && e.button == PointerEventButton.back) {
NavState.request-back();
}
if (e.kind == PointerEventKind.down && e.button == PointerEventButton.forward) {
NavState.request-forward();
}
}
}
}
export component AlbumCard inherits Rectangle {
in property <AlbumCardItem> album;
// Hide the favorite heart + its menu item in non-favoritable contexts
// (e.g. Local Library albums). Mirrors Tauri's AlbumCardLibraryLite.
in property <bool> show-favorite: true;
// Always-visible source badge on the artwork (Local Library: local |
// qobuz-offline | plex). Off elsewhere (single-source catalogs).
in property <bool> show-source-badge: false;
// Fade out when the card is being removed (favorites un-favorite).
opacity: root.album.removing ? 0.0 : 1.0;
animate opacity { duration: 250ms; }
callback clicked(string);
// kind ("album") , album id, action ("play" | "queue" | "favorite").
callback media-action(string, string, string);
// Fully deterministic height: artwork 200 + 6 spacer + 40 meta.
width: 200px;
height: 246px;
// The overlay stays up while the pointer is anywhere over the artwork
// OR over one of its buttons. A child button steals `has-hover` from
// the artwork detector, so the states are OR-combined.
property <bool> overlay-on: hover.has-hover
|| fav-btn.hovered || play-btn.hovered || more-btn.hovered;
VerticalLayout {
alignment: start;
spacing: 0px;
// --- Artwork + hover overlay -------------------------------------
Rectangle {
width: 200px;
height: 200px;
border-radius: Radius.sm;
background: Theme.surface-elevated;
clip: true;
// Cover art. Empty until the artwork pipeline resolves it,
// leaving the elevated placeholder visible underneath.
Image {
width: 100%;
height: 100%;
source: root.album.artwork;
image-fit: cover;
}
// Hover scrim.
Rectangle {
width: 100%;
height: 100%;
background: #000000;
opacity: root.overlay-on ? 0.6 : 0.0;
animate opacity { duration: 150ms; }
}
// Hover meta — genre + year, top-left. The year sits one
// single line below the genre.
VerticalLayout {
x: 12px;
y: 12px;
spacing: 2px;
opacity: root.overlay-on ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
if root.album.genre != "": Text {
text: root.album.genre;
height: 20px;
color: #ffffffeb;
font-size: 13px;
font-weight: Typography.bold;
vertical-alignment: center;
}
if root.album.year != "": Text {
text: root.album.year;
height: 17px;
color: #ffffffcc;
font-size: 12px;
vertical-alignment: center;
}
}
// Card-open + hover detector. Declared before the action
// buttons so those, when interactive, win the pointer.
hover := TouchArea {
width: 100%;
height: 100%;
mouse-cursor: pointer;
clicked => {
root.clicked(root.album.id);
}
}
// Hover action buttons — favorite / play / more.
HorizontalLayout {
x: 0px;
y: 120px;
width: 200px;
height: 44px;
alignment: center;
spacing: 12px;
opacity: root.overlay-on ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
VerticalLayout {
alignment: center;
fav-btn := OverlayButton {
visible: root.show-favorite;
icon: root.album.is-favorite
? @image-url("../assets/icons/heart-filled.svg")
: @image-url("../assets/icons/heart.svg");
active: root.album.is-favorite;
clicked => {
root.media-action("album", root.album.id, "favorite");
}
}
}
play-btn := OverlayButton {
icon: @image-url("../assets/icons/play-fill.svg");
primary: true;
diameter: 44px;
icon-size: 18px;
clicked => {
root.media-action("album", root.album.id, "play");
}
}
VerticalLayout {
alignment: center;
more-btn := OverlayButton {
icon: @image-url("../assets/icons/ellipsis.svg");
clicked => {
album-menu.show();
}
}
}
}
// Award ribbon — content-width only (it is a ribbon, not a
// full-width band), capped so long labels still elide.
if root.album.ribbon != "": Rectangle {
x: 0px;
y: parent.height - self.height - 8px;
height: 20px;
// Hug the label; cap below the card width so a runaway
// label elides instead of spanning the whole card.
width: Math.min(ribbon-row.preferred-width, 200px);
background: root.album.ribbon-kind == "press"
? #d49511
: #000000e0;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
clip: true;
// Left accent stripe (not on the gold press ribbon).
Rectangle {
x: 0px;
width: root.album.ribbon-kind == "press" ? 0px : 3px;
background: root.album.ribbon-kind == "qobuzissime"
? #8b5cf6
: #eab308;
}
ribbon-row := HorizontalLayout {
padding-left: 10px;
padding-right: 10px;
Text {
text: root.album.ribbon;
color: root.album.ribbon-kind == "press"
? #1f1407
: #ffffff;
font-size: 9px;
font-weight: Typography.semibold;
vertical-alignment: center;
overflow: elide;
}
}
}
// Always-visible source badge (Local Library) — bottom-right of
// the art, on top of the scrim/buttons. Small rounded square
// (ADR-008: not a pill). Logos render in their own colors; the
// hard-drive glyph is tinted white.
if root.show-source-badge && root.album.source != "": Rectangle {
x: parent.width - self.width - 6px;
y: parent.height - self.height - 6px;
width: 24px;
height: 24px;
border-radius: 4px;
// `qobuz_purchase` → §8.7 gold chip: dark-amber translucent fill +
// gold 1px border (the visual that distinguishes a purchased album
// in the local library; the glyph is GOLD-tinted below).
background: root.album.source == "qobuz_purchase" ? #1e1400d9
: (root.album.source == "qobuz_download" ? transparent : #000000b3);
border-width: root.album.source == "qobuz_purchase" ? 1px : 0px;
border-color: #eab30880;
Image {
source: root.album.source == "plex"
? @image-url("../assets/icons/plex-logo.svg")
: (root.album.source == "qobuz_download" || root.album.source == "qobuz_purchase"
? @image-url("../assets/icons/qobuz-logo-filled.svg")
: @image-url("../assets/icons/hard-drive.svg"));
colorize: root.album.source == "qobuz_purchase" ? #eab308
: (root.album.source == "local" ? #ffffff : transparent);
width: root.album.source == "plex" ? 16px
: (root.album.source == "qobuz_download" ? 22px
: (root.album.source == "qobuz_purchase" ? 18px : 14px));
height: self.width;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
image-fit: contain;
}
// §8.7: the gold purchase badge carries a hover tooltip
// `library.qobuzPurchaseIndicator` ("Purchased from Qobuz"),
// mirroring Tauri's SourceBadge `title=` on the qobuz_purchase
// chip. Bare hover TouchArea drives the shared TooltipState;
// wired ONLY for qobuz_purchase (the download/plex/local badges
// have no source tooltip — matching the Tauri baseline).
if root.album.source == "qobuz_purchase": TouchArea {
changed has-hover => {
if (self.has-hover) {
TooltipState.text = @tr("Purchased from Qobuz");
TooltipState.anchor-x = self.absolute-position.x + self.width / 2;
TooltipState.anchor-y = self.absolute-position.y;
TooltipState.show = true;
} else {
TooltipState.show = false;
}
}
}
}
// Context menu for the "more" button.
album-menu := PopupWindow {
x: 26px;
y: 56px;
width: 196px;
height: 142px;
ContextMenu {
ContextMenuItem {
icon: @image-url("../assets/icons/library-big.svg");
label: @tr("Open album");
clicked => {
root.clicked(root.album.id);
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/play.svg");
label: @tr("Play");
clicked => {
root.media-action("album", root.album.id, "play");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/list-plus.svg");
label: @tr("Play next");
clicked => {
root.media-action("album", root.album.id, "play-next");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/list-end.svg");
label: @tr("Add to queue");
clicked => {
root.media-action("album", root.album.id, "queue");
}
}
if root.show-favorite: ContextMenuItem {
icon: @image-url("../assets/icons/heart.svg");
label: @tr("Add to favorites");
clicked => {
root.media-action("album", root.album.id, "favorite");
}
}
}
}
}
Rectangle { height: 6px; }
// --- Title / artist + quality badge ------------------------------
HorizontalLayout {
height: 40px;
spacing: Spacing.sm;
VerticalLayout {
alignment: center;
spacing: 2px;
horizontal-stretch: 1;
Text {
text: root.album.title;
height: 20px;
color: Theme.text-primary;
font-size: Typography.body - 2px;
font-weight: Typography.medium;
vertical-alignment: center;
overflow: elide;
}
// Artist name — clickable when an artist id is known,
// navigating to the artist page (1:1 with Tauri).
artist-area := TouchArea {
height: 18px;
mouse-cursor: root.album.artist-id != "" ? pointer : default;
clicked => {
if (root.album.artist-id != "") {
root.media-action("artist", root.album.artist-id, "open");
}
}
artist-text := Text {
// Fill the title column and elide. Binding the TouchArea
// width to this text's preferred-width clamped the whole
// title column to the (often short) artist name, which
// truncated titles to a few letters and shoved the quality
// badge inward instead of letting it float right.
width: 100%;
text: root.album.artist;
color: root.album.artist-id != "" && artist-area.has-hover
? Theme.text-primary
: Theme.text-muted;
font-size: Typography.link - 1px;
vertical-alignment: center;
overflow: elide;
}
}
}
// Icon-only quality badge with an exact-quality hover tooltip.
VerticalLayout {
alignment: center;
QualityBadge {
tier: root.album.quality-tier;
label: root.album.quality-label;
detail: root.album.quality-detail;
}
}
}
}
}
@@ -0,0 +1,175 @@
// Album collection content — renders a flat grid, a flat list, or
// group-by sections (each a title + grid). The surrounding view owns the
// toolbar and the loading / empty / load-more states; this component is
// purely the rendered collection, so the grid column math and the list
// header+rows live in one place. Shared by Discover Browse, Label
// Releases, and Favorites albums.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { AlbumCardItem, DiscoverSection } from "../state.slint";
import { AlbumCard } from "AlbumCard.slint";
import { AlbumListRow, AlbumListHeader } from "../primitives/AlbumListRow.slint";
// Wrapping album grid over a model — column math in one place, shared by
// the flat grid and each group-by section.
component AlbumGrid inherits Rectangle {
in property <[AlbumCardItem]> albums;
in property <length> card-width: 200px;
in property <length> card-height: 246px;
in property <length> card-gap: 24px;
in property <bool> show-favorite: true;
in property <bool> show-source-badge: false;
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
property <int> columns: Math.max(
1,
Math.floor((self.width + root.card-gap) / (root.card-width + root.card-gap)));
property <int> rows: Math.ceil(root.albums.length / self.columns);
height: self.rows > 0
? self.rows * root.card-height + Math.max(0, self.rows - 1) * root.card-gap
: 0px;
for album[i] in root.albums: AlbumCard {
x: Math.mod(i, root.columns) * (root.card-width + root.card-gap);
y: Math.floor(i / root.columns) * (root.card-height + root.card-gap);
width: root.card-width;
height: root.card-height;
album: album;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
if (kind == "artist") {
root.open-artist(id);
} else {
root.media-action(kind, id, action);
}
}
}
}
export component AlbumCollectionView inherits VerticalLayout {
in property <[AlbumCardItem]> albums; // flat set (grid/list)
in property <[DiscoverSection]> grouped; // group-by sections
in property <bool> is-grouped: false;
in property <string> view-mode: "grid"; // "grid" | "list"
in property <bool> show-source: false;
// Forwarded to AlbumCard — hide the favorite heart in non-favoritable
// contexts (Local Library albums).
in property <bool> show-favorite: true;
// Forwarded to AlbumCard — show the always-visible source badge on the
// grid card art (Local Library: local | qobuz-offline | plex).
in property <bool> show-source-badge: false;
in property <length> card-width: 200px;
in property <length> card-height: 246px;
in property <length> card-gap: 24px;
in property <length> list-row-gap: 4px;
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
spacing: 0px;
// --- Grouped (sections) — each section follows the grid/list mode --
if root.is-grouped && root.grouped.length > 0: VerticalLayout {
spacing: 0px;
// In list mode the column header sits once above all sections.
if root.view-mode == "list": AlbumListHeader {
show-source: root.show-source;
}
for section[s] in root.grouped: VerticalLayout {
spacing: 12px;
if s > 0: Rectangle { height: 24px; }
Text {
text: section.title;
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
}
// List view: rows for this section.
if root.view-mode == "list": VerticalLayout {
spacing: root.list-row-gap;
for album[i] in section.albums: AlbumListRow {
album: album;
index: i;
show-source: root.show-source;
clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
if (kind == "artist") {
root.open-artist(id);
} else {
root.media-action(kind, id, action);
}
}
}
}
// Grid view: a card grid for this section.
if root.view-mode != "list": AlbumGrid {
albums: section.albums;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
// --- Flat grid -----------------------------------------------------
if !root.is-grouped && root.view-mode == "grid" && root.albums.length > 0: AlbumGrid {
albums: root.albums;
show-favorite: root.show-favorite;
show-source-badge: root.show-source-badge;
card-width: root.card-width;
card-height: root.card-height;
card-gap: root.card-gap;
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// --- Flat list -----------------------------------------------------
if !root.is-grouped && root.view-mode == "list" && root.albums.length > 0: VerticalLayout {
spacing: root.list-row-gap;
AlbumListHeader {
show-source: root.show-source;
}
for album[i] in root.albums: AlbumListRow {
album: album;
index: i;
show-source: root.show-source;
clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
if (kind == "artist") {
root.open-artist(id);
} else {
root.media-action(kind, id, action);
}
}
}
}
}
+130
View File
@@ -0,0 +1,130 @@
// Artist card — ported 1:1 from the Tauri SearchView `.artist-card`:
// 160x220 tile inside a surface-card container, with a 120px circular
// avatar (gradient placeholder), centered name, and an optional Follow
// chip (rectangular per ADR-008) shown only when the user does not yet
// follow the artist.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { SlimItem } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
export component ArtistCard inherits Rectangle {
in property <SlimItem> artist;
// Follow-chip behavior:
// "auto" show only when NOT following (artist search default);
// "toggle" always show, reflecting Follow/Following (label more-labels);
// "none" never show (label artists carousel — no follow there).
in property <string> follow-mode: "auto";
// kind passed in the follow media-action ("artist" | "label").
in property <string> follow-kind: "artist";
callback clicked(string);
// kind ("artist" | "label"), id, action ("follow").
callback media-action(string, string, string);
width: 160px;
height: 220px;
border-radius: 12px;
background: ta.has-hover ? Theme.surface-elevated : Theme.surface-card;
animate background { duration: 150ms; }
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked(root.artist.id);
}
}
VerticalLayout {
padding: 16px;
spacing: 12px;
alignment: start;
// 120px circular avatar with a soft gradient placeholder.
HorizontalLayout {
alignment: center;
Rectangle {
width: 120px;
height: 120px;
border-radius: 60px;
clip: true;
background: @linear-gradient(
135deg,
Theme.surface-elevated 0%,
Theme.surface-card 100%);
QbzIcon {
source: @image-url("../assets/icons/user.svg");
width: 38px;
height: 38px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: Theme.text-muted;
}
Image {
width: 100%;
height: 100%;
source: root.artist.artwork;
image-fit: cover;
}
}
}
Text {
text: root.artist.title;
width: 128px;
color: Theme.text-primary;
font-size: 14px;
font-weight: Typography.medium;
horizontal-alignment: center;
overflow: elide;
}
// Rectangular Follow / Following chip (ADR-008 — no pills). See
// `follow-mode`: "auto" shows it only when not yet following,
// "toggle" always shows it (and reflects the state), "none" hides it.
if (root.follow-mode == "auto" && !root.artist.following)
|| root.follow-mode == "toggle": HorizontalLayout {
alignment: center;
spacing: 0px;
Rectangle {
width: chip-row.preferred-width;
height: 28px;
border-radius: Radius.sm;
background: follow-ta.has-hover
? Theme.surface-hover
: Theme.surface-elevated;
animate background { duration: 150ms; }
chip-row := HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 6px;
VerticalLayout {
alignment: center;
QbzIcon {
source: root.artist.following
? @image-url("../assets/icons/check.svg")
: @image-url("../assets/icons/user-plus.svg");
width: 13px;
height: 13px;
tint: Theme.text-primary;
}
}
Text {
text: root.artist.following ? @tr("Following") : @tr("Follow");
color: Theme.text-primary;
font-size: 12px;
font-weight: Typography.medium;
vertical-alignment: center;
}
}
follow-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.media-action(root.follow-kind, root.artist.id, "follow");
}
}
}
}
}
}
@@ -0,0 +1,175 @@
// Artist carousel — title, "View all" link, prev/next page controls, and
// a clipped sliding track of artist cards. Same paging mechanism as
// Carousel. Used by the search results All tab.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { SlimItem } from "../state.slint";
import { ArtistCard } from "ArtistCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component NavButton 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: 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;
}
ta := TouchArea {
enabled: root.enabled;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.clicked();
}
}
}
component ViewAllLink inherits Rectangle {
callback clicked();
width: link-text.preferred-width + 16px;
height: 26px;
border-radius: 4px;
background: ta.has-hover ? Theme.surface-hover : transparent;
link-text := Text {
text: @tr("View all");
color: Theme.accent;
font-size: 14px;
font-weight: Typography.medium;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component ArtistCarousel inherits VerticalLayout {
in property <string> title;
in property <[SlimItem]> artists;
in property <bool> show-view-all: false;
// Follow-chip behavior + kind for the cards (see ArtistCard).
// Defaults keep the artist-search usage unchanged.
in property <string> card-follow-mode: "auto";
in property <string> card-follow-kind: "artist";
callback artist-clicked(string);
callback media-action(string, string, string);
callback view-all-clicked();
property <length> card-width: 160px;
property <length> card-height: 220px;
property <length> gap: 16px;
property <int> count: root.artists.length;
property <int> per-page: Math.max(
1,
Math.floor((viewport.width + root.gap) / (root.card-width + root.gap)));
property <int> page-count: Math.max(1, Math.ceil(root.count / root.per-page));
property <int> page: 0;
property <int> current-page: Math.min(Math.max(0, root.page), root.page-count - 1);
property <length> step: root.per-page * (root.card-width + root.gap);
property <length> content-width:
root.count * root.card-width + Math.max(0, root.count - 1) * root.gap;
spacing: 12px;
HorizontalLayout {
spacing: 8px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-left.svg");
enabled: root.current-page > 0;
clicked => {
root.page = root.current-page - 1;
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-right.svg");
enabled: root.current-page < root.page-count - 1;
clicked => {
root.page = root.current-page + 1;
}
}
}
if root.show-view-all: VerticalLayout {
alignment: center;
ViewAllLink {
clicked => {
root.view-all-clicked();
}
}
}
}
viewport := Rectangle {
height: root.card-height;
clip: true;
Rectangle {
x: -root.current-page * root.step;
y: 0px;
width: root.content-width;
height: root.card-height;
animate x { duration: 220ms; easing: ease-in-out; }
HorizontalLayout {
spacing: root.gap;
for artist in root.artists: ArtistCard {
artist: artist;
follow-mode: root.card-follow-mode;
follow-kind: root.card-follow-kind;
clicked(id) => {
root.artist-clicked(id);
}
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
}
}
Rectangle {
x: 0px;
width: 56px;
background: @linear-gradient(90deg, Theme.surface-main 0%, transparent 100%);
opacity: root.current-page > 0 ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
Rectangle {
x: parent.width - self.width;
width: 56px;
background: @linear-gradient(90deg, transparent 0%, Theme.surface-main 100%);
opacity: root.current-page < root.page-count - 1 ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
}
}
+185
View File
@@ -0,0 +1,185 @@
// Discover section carousel — a title, prev/next page controls, and a
// clipped, sliding track of album cards.
//
// Pagination by slice (no scrollbar), mirroring the Svelte
// DiscoverySection. Because there is no ScrollView the height is exactly
// the card height — nothing injects extra vertical space.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { DiscoverSection } from "../state.slint";
import { AlbumCard } from "AlbumCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component NavButton 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: 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;
}
ta := TouchArea {
enabled: root.enabled;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.clicked();
}
}
}
component ViewAllLink inherits Rectangle {
callback clicked();
width: link-text.preferred-width + 16px;
height: 26px;
border-radius: 4px;
background: ta.has-hover ? Theme.surface-hover : transparent;
link-text := Text {
// Muted, close to normal text (not the theme accent), with the
// trailing arrow — matches Tauri's "See all →".
text: @tr("View all →");
color: ta.has-hover ? Theme.text-primary : Theme.text-secondary;
font-size: 14px;
font-weight: Typography.medium;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component Carousel inherits VerticalLayout {
in property <DiscoverSection> section;
in property <bool> show-view-all: false;
callback album-clicked(string);
callback media-action(string, string, string);
callback view-all-clicked();
property <length> card-width: 200px;
property <length> card-height: 246px;
property <length> gap: 32px;
property <int> count: root.section.albums.length;
property <int> per-page: Math.max(
1,
Math.floor((flick.width + root.gap) / (root.card-width + root.gap)));
property <length> step: root.per-page * (root.card-width + root.gap);
property <length> content-width:
root.count * root.card-width + Math.max(0, root.count - 1) * root.gap;
// Max leftward scroll (viewport-x is 0 at start, negative when
// scrolled right). Zero when everything fits.
property <length> max-scroll: Math.max(0px, root.content-width - flick.width);
spacing: 12px;
// --- Header: title + page controls -----------------------------------
HorizontalLayout {
Text {
text: root.section.title;
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
HorizontalLayout {
spacing: 4px;
// "View all" sits to the LEFT of the carousel page chevrons,
// matching the Tauri DiscoverySection header.
if root.show-view-all: VerticalLayout {
alignment: center;
ViewAllLink {
clicked => {
root.view-all-clicked();
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-left.svg");
enabled: flick.viewport-x < -1px;
clicked => {
flick.viewport-x = Math.min(0px, flick.viewport-x + root.step);
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-right.svg");
enabled: flick.viewport-x > -root.max-scroll + 1px;
clicked => {
flick.viewport-x = Math.max(-root.max-scroll, flick.viewport-x - root.step);
}
}
}
}
}
// --- Track: a horizontal Flickable so the row drags by touch /
// pointer (kinetic), while card taps still register — Flickable
// distinguishes a flick from a tap, unlike nested TouchAreas. The
// prev/next buttons nudge viewport-x by a page. viewport-height ==
// height pins it to horizontal-only so it never fights the home
// page's vertical Flickable.
viewport := Rectangle {
height: root.card-height;
clip: true;
flick := Flickable {
width: 100%;
height: root.card-height;
viewport-width: root.content-width;
viewport-height: self.height;
HorizontalLayout {
spacing: root.gap;
for album in root.section.albums: AlbumCard {
album: album;
clicked(id) => {
root.album-clicked(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
// Cider-style edge fades — content dissolves into the page
// background at the scrolled edges instead of a hard cut.
Rectangle {
x: 0px;
width: 56px;
background: @linear-gradient(90deg, Theme.surface-main 0%, transparent 100%);
opacity: flick.viewport-x < -1px ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
Rectangle {
x: parent.width - self.width;
width: 56px;
background: @linear-gradient(90deg, transparent 0%, Theme.surface-main 100%);
opacity: flick.viewport-x > -root.max-scroll + 1px ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
}
}
@@ -0,0 +1,366 @@
// Discover "View all" full-list page — one album module (New Releases,
// Press Accolades, Ideal Discography, Qobuzissimes, Albums of the Week,
// Most Streamed) shown as a paginated full grid or list. Opened from a
// Carousel's "View all" link. Mirrors Tauri's DiscoverBrowseView: the
// back/forward NavButtons + title sit on the LEFT, the header tools
// (search, genre filter, grid/list toggle) float RIGHT on the same row.
// Pagination is infinite-scroll, driven by DiscoverBrowseState.has-more
// off the backend (no total); load-more is disabled while a search is
// active (Tauri does the same).
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { DiscoverBrowseState, DiscoverBrowseActions, GenreFilterState, GenreFilterActions, NavState, ShellState, UiFocusState } from "../state.slint";
import { AlbumCollectionView } from "AlbumCollectionView.slint";
import { GenreFilterPopup } from "GenreFilterPopup.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { ToggleButton } from "../primitives/ToggleButton.slint";
// Search field — a leading magnifier, the input, and a trailing X that
// clears (mirrors Tauri's .search-wrapper).
component BrowseSearch inherits Rectangle {
height: 34px;
width: 200px;
border-radius: 6px;
background: Theme.surface-elevated;
border-width: 1px;
border-color: input.has-focus ? Theme.accent : Theme.border-subtle;
HorizontalLayout {
padding-left: 10px;
padding-right: 6px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/search.svg");
width: 15px;
height: 15px;
tint: Theme.text-muted;
}
}
Rectangle {
horizontal-stretch: 1;
clip: true;
input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: 13px;
vertical-alignment: center;
single-line: true;
text <=> DiscoverBrowseState.search-query;
changed has-focus => { UiFocusState.text-input-focused = self.has-focus; }
edited => {
DiscoverBrowseActions.search-changed();
}
}
Text {
visible: input.text == "";
width: 100%;
height: 100%;
text: @tr("Search…");
color: Theme.text-muted;
font-size: 13px;
vertical-alignment: center;
overflow: elide;
}
}
// Trailing X — clears the query.
VerticalLayout {
alignment: center;
Rectangle {
visible: DiscoverBrowseState.search-query != "";
width: 22px;
height: 22px;
border-radius: 4px;
background: clear-ta.has-hover ? Theme.surface-hover : transparent;
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 12px;
height: 12px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: clear-ta.has-hover ? Theme.text-primary : Theme.text-muted;
}
clear-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
DiscoverBrowseState.search-query = "";
DiscoverBrowseActions.search-changed();
}
}
}
}
}
}
// Genre-filter trigger — same visual as HomeView's GenreButton: accent
// fill + "N genres" when a selection is active.
component GenreButton inherits Rectangle {
callback clicked();
property <bool> active: GenreFilterState.selected-count > 0;
width: genre-row.preferred-width;
height: 34px;
border-radius: 6px;
background: root.active
? Theme.accent
: (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated);
genre-row := HorizontalLayout {
padding-left: 12px;
padding-right: 14px;
spacing: 7px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/list-filter.svg");
width: 14px;
height: 14px;
tint: root.active ? #ffffff : Theme.text-secondary;
}
}
Text {
text: root.active
? (GenreFilterState.selected-count == 1
? @tr("1 genre")
: @tr("{} genres", GenreFilterState.selected-count))
: @tr("Filter by genre");
color: root.active ? #ffffff : Theme.text-secondary;
font-size: 13px;
font-weight: root.active ? Typography.medium : Typography.regular;
vertical-alignment: center;
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component DiscoverBrowseView inherits Rectangle {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
property <length> album-w: 200px;
property <length> album-h: 266px;
property <length> gap: 24px;
property <length> list-row-h: 64px;
property <length> list-row-gap: 4px;
background: Theme.surface-main;
VerticalLayout {
spacing: 0px;
// --- Fixed header (always visible) -------------------------------
// NavButtons + section title on the LEFT (title inline, right after
// the nav buttons); search / genre / grid-list tools as one group
// floating RIGHT. Like the Discover toolbar: a fixed bar whose
// back/forward buttons keep the same screen position as every page
// (center at y=25 = 11px top + 14px half-button). Only the list
// below scrolls.
Rectangle {
height: 56px;
background: Theme.surface-main;
// Left cluster — nav buttons then the title, inline.
HorizontalLayout {
x: 32px;
y: 25px - self.height / 2;
width: self.preferred-width;
height: self.preferred-height;
spacing: 16px;
VerticalLayout {
alignment: center;
NavButtons { }
}
VerticalLayout {
alignment: center;
Text {
text: DiscoverBrowseState.title;
color: Theme.text-primary;
font-size: Typography.section;
font-weight: Typography.bold;
vertical-alignment: center;
}
}
}
// Right cluster — the header tools as one group, anchored right.
HorizontalLayout {
x: parent.width - self.preferred-width - 32px;
y: 25px - self.height / 2;
width: self.preferred-width;
height: self.preferred-height;
spacing: 8px;
VerticalLayout {
alignment: center;
BrowseSearch { }
}
VerticalLayout {
alignment: center;
GenreButton {
clicked => {
GenreFilterActions.set-context("discover");
GenreFilterState.open = !GenreFilterState.open;
}
}
}
VerticalLayout {
alignment: center;
Rectangle {
width: 68px;
height: 34px;
border-radius: 6px;
background: Theme.surface-elevated;
clip: true;
HorizontalLayout {
ToggleButton {
icon: @image-url("../assets/icons/layout-grid.svg");
active: DiscoverBrowseState.view-mode == "grid";
clicked => {
DiscoverBrowseState.view-mode = "grid";
}
}
ToggleButton {
icon: @image-url("../assets/icons/list.svg");
active: DiscoverBrowseState.view-mode == "list";
clicked => {
DiscoverBrowseState.view-mode = "list";
}
}
}
}
}
}
}
// --- Scrolling list (only the listing scrolls) ------------------
flick := Flickable {
vertical-stretch: 1;
viewport-width: self.width;
viewport-height: page.preferred-height;
// Scroll-position restore on back/forward (see nav::scope_for).
property <string> sr-armed: NavState.restore-scope;
function sr-restore() {
if (NavState.restore-scope == "discover-browse" && self.viewport-height > self.height) {
self.viewport-y = NavState.scroll-restore;
NavState.restore-scope = "";
}
}
init => { self.sr-restore(); }
changed sr-armed => { self.sr-restore(); }
changed viewport-height => { self.sr-restore(); }
// Infinite scroll — when the viewport nears the bottom of the
// content (within 600px), pull the next page. Guarded by
// has-more + the loading flags AND an empty search query, so a
// client-side search filter does not keep paging in the catalog.
changed viewport-y => {
NavState.report-scroll(self.viewport-y);
if (-self.viewport-y + self.height >= self.viewport-height - 600px
&& DiscoverBrowseState.has-more
&& !DiscoverBrowseState.loading-more
&& !DiscoverBrowseState.loading
&& DiscoverBrowseState.search-query == "") {
DiscoverBrowseActions.load-more();
}
}
page := VerticalLayout {
width: parent.width;
padding-left: 32px;
padding-right: 32px;
padding-top: 8px;
padding-bottom: 100px;
spacing: 0px;
alignment: start;
if DiscoverBrowseState.loading: HorizontalLayout {
alignment: center;
LoadingSpinner { size: 36px; }
}
// Empty-state when a search filters everything out.
if !DiscoverBrowseState.loading
&& DiscoverBrowseState.visible.length == 0
&& DiscoverBrowseState.search-query != "": HorizontalLayout {
alignment: center;
Text {
text: @tr("No results found.");
color: Theme.text-muted;
font-size: 14px;
}
}
// --- Album collection (grid / list) --------------------
if !DiscoverBrowseState.loading: AlbumCollectionView {
albums: DiscoverBrowseState.visible;
view-mode: DiscoverBrowseState.view-mode;
is-grouped: false;
show-source: false;
card-width: root.album-w;
card-height: root.album-h;
card-gap: root.gap;
list-row-gap: root.list-row-gap;
open-album(id) => { root.open-album(id); }
open-artist(id) => { root.open-artist(id); }
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// Bottom load-more spinner while the next page is in flight.
if DiscoverBrowseState.loading-more: HorizontalLayout {
alignment: center;
Rectangle { height: 24px; }
LoadingSpinner { size: 28px; }
}
}
}
}
// Shared scrollbar in the right gutter (homologated cross-view). Sits
// below the fixed 56px header so it tracks only the scrolling list.
ListScrollbar {
x: parent.width - self.width - 4px;
y: 56px;
width: 14px;
height: parent.height - 56px;
viewport-height: flick.viewport-height;
visible-height: flick.height;
viewport-y <=> flick.viewport-y;
auto-hide: true;
hover-active: ShellState.pointer-in-window
&& ShellState.pointer-x >= flick.absolute-position.x
&& ShellState.pointer-x <= flick.absolute-position.x + flick.width
&& ShellState.pointer-y >= flick.absolute-position.y
&& ShellState.pointer-y <= flick.absolute-position.y + flick.height;
}
// --- Genre filter overlay --------------------------------------------
// Backdrop closes the popup on outside click; the panel anchors to
// the top-right under the Filter-by-genre button (mirrors HomeView).
if GenreFilterState.open: Rectangle {
width: 100%;
height: 100%;
TouchArea {
clicked => {
GenreFilterState.open = false;
}
}
}
if GenreFilterState.open: GenreFilterPopup {
x: root.width - self.width - 32px;
y: 56px;
}
}
@@ -0,0 +1,289 @@
// Discover section configurator (Slice 5) — the per-tab "Customize" modal:
// reorder + show/hide the active tab's Discover sections, with a perf-warning
// banner, an enabled/total count, and a Reset-to-defaults footer. No Save
// button — every toggle / move / reset persists live (the controller re-pushes
// config-rows immediately, so the list stays authoritative).
//
// Reuses the codebase modal idiom (self-contained Rectangle, full-window scrim +
// centered panel; mounted LAST in AppShell so declaration order = top z-stack,
// satisfying ADR-009 >= 3000 structurally). There is NO shared Modal component.
//
// Labels are resolved in Rust (DiscoverState.config-rows[].label) — Slint @tr
// needs a literal key and the gettext pipeline is unwired, so section labels are
// English strings (consistent with every other Slint section title). The modal's
// own chrome strings use @tr literals (passthrough today).
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { DiscoverState, DiscoverActions, ConfigRow } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QbzCheckbox } from "../primitives/QbzCheckbox.slint";
// A 28x28 ghost reorder button (chevron up / down). Dims + drops the pointer
// cursor at the list boundary.
component ReorderButton inherits Rectangle {
in property <image> glyph;
in property <bool> button-enabled: true;
callback clicked();
width: 28px;
height: 28px;
border-radius: Radius.sm;
opacity: root.button-enabled ? 1.0 : 0.3;
background: (root.button-enabled && ta.has-hover) ? Theme.surface-hover : transparent;
QbzIcon {
source: root.glyph;
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: Theme.text-secondary;
}
ta := TouchArea {
mouse-cursor: root.button-enabled ? pointer : default;
enabled: root.button-enabled;
clicked => {
root.clicked();
}
}
}
// One configurator row: [checkbox] [label (stretch)] [up] [down].
component ConfigRowView inherits Rectangle {
in property <ConfigRow> entry; // NOT `row`: `row` is a reserved Slint grid attached-property
in property <int> index;
in property <int> last-index;
in property <string> tab;
height: 40px;
border-radius: Radius.sm;
background: row-ta.has-hover ? Theme.surface-hover : transparent;
// Whole-row tap toggles (primary affordance). The checkbox below also
// toggles; the Rust re-push of config-rows re-asserts truth either way.
row-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
DiscoverActions.toggle-section(root.tab, root.entry.id);
}
}
HorizontalLayout {
padding-left: 10px;
padding-right: 6px;
spacing: 12px;
VerticalLayout {
alignment: center;
QbzCheckbox {
checked: root.entry.enabled;
toggled => {
DiscoverActions.toggle-section(root.tab, root.entry.id);
}
}
}
Text {
text: root.entry.label;
color: root.entry.enabled ? Theme.text-primary : Theme.text-muted;
font-size: Typography.body;
font-weight: Typography.medium;
vertical-alignment: center;
horizontal-stretch: 1;
}
VerticalLayout {
alignment: center;
ReorderButton {
glyph: @image-url("../assets/icons/chevron-up.svg");
button-enabled: root.index > 0;
clicked => {
DiscoverActions.move-section(root.tab, root.entry.id, -1);
}
}
}
VerticalLayout {
alignment: center;
ReorderButton {
glyph: @image-url("../assets/icons/chevron-down.svg");
button-enabled: root.index < root.last-index;
clicked => {
DiscoverActions.move-section(root.tab, root.entry.id, 1);
}
}
}
}
}
export component DiscoverConfigModal inherits Rectangle {
visible: DiscoverState.configurator-open;
if DiscoverState.configurator-open: Rectangle {
// Scrim — closes on outside click.
background: #000000bf;
TouchArea {
mouse-cursor: default;
clicked => {
DiscoverActions.close-configurator();
}
}
// Panel.
Rectangle {
width: Math.min(root.width - 80px, 520px);
height: Math.min(panel.preferred-height, root.height * 0.78);
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.md;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
clip: true;
// Swallow clicks so they do not fall through to the scrim.
TouchArea { }
panel := VerticalLayout {
padding: 20px;
spacing: 14px;
// Title row + close.
HorizontalLayout {
Text {
text: @tr("Customize");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
horizontal-stretch: 1;
vertical-alignment: center;
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
DiscoverActions.close-configurator();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
// Perf-warning banner.
Rectangle {
border-radius: Radius.sm;
background: Theme.surface-elevated;
banner := HorizontalLayout {
padding: 10px;
spacing: 10px;
VerticalLayout {
alignment: start;
QbzIcon {
source: @image-url("../assets/icons/triangle-alert.svg");
width: 16px;
height: 16px;
tint: Theme.warning;
}
}
Text {
text: @tr("Enabling more sections increases load time.");
color: Theme.text-secondary;
font-size: Typography.legal;
wrap: word-wrap;
horizontal-stretch: 1;
}
}
}
// Count line.
Text {
text: @tr("{} of {} enabled", DiscoverState.enabled-count, DiscoverState.total-count);
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.medium;
}
// Section list (scrolls when taller than the panel cap).
Rectangle {
// Explicit, content-derived height — NOT vertical-stretch: a
// stretch child inside a panel sized to `preferred-height`
// collapses (a Flickable's intrinsic preferred-height is ~0,
// the documented Slint trap). Cap = window minus the modal
// chrome so the whole panel stays within root.height * 0.78;
// the Flickable scrolls when the rows exceed this.
height: Math.min(list-col.preferred-height, root.height * 0.78 - 260px);
clip: true;
list-flick := Flickable {
width: 100%;
height: 100%;
viewport-width: self.width;
viewport-height: list-col.preferred-height;
list-col := VerticalLayout {
spacing: 2px;
alignment: start;
for row[idx] in DiscoverState.config-rows: ConfigRowView {
entry: row;
index: idx;
last-index: DiscoverState.config-rows.length - 1;
tab: DiscoverState.active-tab;
}
}
}
}
// Footer — Reset to defaults, pinned left.
HorizontalLayout {
reset-btn := Rectangle {
width: reset-row.preferred-width + 24px;
height: 34px;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-subtle;
background: reset-ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
reset-row := HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 8px;
alignment: center;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/rotate-ccw.svg");
width: 15px;
height: 15px;
tint: Theme.text-secondary;
}
}
Text {
text: @tr("Reset to defaults");
color: Theme.text-primary;
font-size: Typography.body;
vertical-alignment: center;
}
}
reset-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
DiscoverActions.reset-tab(DiscoverState.active-tab);
}
}
}
// Spacer pushes the reset button to the left edge.
Rectangle {
horizontal-stretch: 1;
}
}
}
}
}
}
+213
View File
@@ -0,0 +1,213 @@
// Discover > For You — ordered, heterogeneous layout for the For You tab.
// Unlike Home / Editor's Picks (uniform album carousels), For You mixes album
// carousels, a track carousel, artist carousels, radio tiles, Qobuz Mixes, and
// the Spotlight, so each row is a different component.
//
// Slice 5: the order + visibility are driven by the prefs configurator. Rust
// pushes DiscoverState.foryou-sections (the ordered ENABLED descriptor ids); a
// single repeater iterates them and an if-chain delegate mounts the right
// component, reading the matching ForYouState field by id. Each arm keeps its
// own data `length > 0` self-hide gate (qobuzMixes excepted — always rendered).
//
// essentialsByGenre is Slice-2c-blocked (no ForYouState.essentials field yet);
// Rust drops it from the descriptor list, so there is intentionally no arm for
// it here. It returns automatically once Slice 2c adds the field + an arm.
//
// Reuses the shared cards/carousels — no new card components here.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { ForYouState, RadioStationItem, DiscoverState } from "../state.slint";
import { Carousel } from "Carousel.slint";
import { SlimCarousel } from "SlimCarousel.slint";
import { ArtistCarousel } from "ArtistCarousel.slint";
import { Spotlight } from "Spotlight.slint";
import { QobuzMixesRow } from "QobuzMixesRow.slint";
import { RadioCard } from "RadioCard.slint";
import { HomeSkeleton } from "HomeSkeleton.slint";
export component ForYouView inherits VerticalLayout {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
callback play-track(string);
callback play-top-tracks(string);
callback start-radio(string);
callback start-radio-album(string);
callback open-mix(string);
// Progressive load: while the first lazy load is in flight, show the
// skeleton Home uses (the Qobuz Mixes tiles stay — they're static). It hides
// as soon as ANY content paints. Static, order-independent (top while empty).
property <bool> show-skeleton:
ForYouState.loading
&& ForYouState.release-watch.albums.length == 0
&& ForYouState.top-artists.length == 0
&& ForYouState.recent-albums.albums.length == 0
&& ForYouState.recent-tracks.length == 0;
spacing: 40px;
alignment: start;
if root.show-skeleton: HomeSkeleton { }
// Prefs-driven loop. DiscoverState.foryou-sections = enabled ids in pref
// order (recomputed in Rust). Delegate = single-root VerticalLayout whose
// inner if-chain mounts the right component + binds the matching global;
// exactly one inner `if` matches per descriptor id, so each row resolves to
// one visible child (or none, when its data is empty and it self-hides).
for desc in DiscoverState.foryou-sections: VerticalLayout {
spacing: 0px;
// qobuzMixes — static navigation tiles, ALWAYS rendered (no data gate).
if desc.id == "qobuzMixes": QobuzMixesRow {
open-mix(which) => {
root.open-mix(which);
}
}
// releaseWatch — album carousel.
if desc.id == "releaseWatch" && ForYouState.release-watch.albums.length > 0: Carousel {
section: ForYouState.release-watch;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// radioStations — album-seeded radio tiles (bespoke Flickable body).
if desc.id == "radioStations" && ForYouState.radio-stations.length > 0: VerticalLayout {
spacing: 12px;
Text {
text: @tr("Radio Stations");
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
}
Rectangle {
height: 234px;
clip: true;
radio-flick := Flickable {
width: 100%;
height: parent.height;
viewport-width: ForYouState.radio-stations.length * (200px + 32px);
viewport-height: self.height;
HorizontalLayout {
spacing: 32px;
alignment: start;
for st in ForYouState.radio-stations: RadioCard {
seed-title: st.title;
seed-subtitle: st.artist;
label: @tr("RADIO");
artwork: st.artwork;
clicked => {
root.start-radio-album(st.album-id);
}
play => {
root.start-radio-album(st.album-id);
}
}
}
}
}
}
// continueListening — recently-played tracks slim carousel.
if desc.id == "continueListening" && ForYouState.recent-tracks.length > 0: SlimCarousel {
title: @tr("Recently Played Tracks");
items: ForYouState.recent-tracks;
item-clicked(id) => {
root.play-track(id);
}
}
// recentlyPlayedAlbums — album carousel.
if desc.id == "recentlyPlayedAlbums" && ForYouState.recent-albums.albums.length > 0: Carousel {
section: ForYouState.recent-albums;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// topArtists — artist carousel.
if desc.id == "topArtists" && ForYouState.top-artists.length > 0: ArtistCarousel {
title: @tr("Your Top Artists");
artists: ForYouState.top-artists;
artist-clicked(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// favoriteAlbums — album carousel.
if desc.id == "favoriteAlbums" && ForYouState.favorite-albums.albums.length > 0: Carousel {
section: ForYouState.favorite-albums;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// similarAlbums — "More From Your Library" album carousel.
if desc.id == "similarAlbums" && ForYouState.more-from-library.albums.length > 0: Carousel {
section: ForYouState.more-from-library;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// rediscoverLibrary — album carousel.
if desc.id == "rediscoverLibrary" && ForYouState.rediscover.albums.length > 0: Carousel {
section: ForYouState.rediscover;
album-clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// artistsToFollow — artist carousel.
if desc.id == "artistsToFollow" && ForYouState.artists-to-follow.length > 0: ArtistCarousel {
title: @tr("Artists to Follow");
artists: ForYouState.artists-to-follow;
artist-clicked(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// artistSpotlight — the Spotlight panel.
if desc.id == "artistSpotlight" && ForYouState.spotlight-visible: Spotlight {
open-artist(id) => {
root.open-artist(id);
}
open-album(id) => {
root.open-album(id);
}
play-top-tracks(id) => {
root.play-top-tracks(id);
}
start-radio(id) => {
root.start-radio(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
@@ -0,0 +1,382 @@
// Filter-by-genre popup — ported from Tauri's GenreFilterPopup.
// Simple grid view (parent genres as selectable chips). The selection
// is shared across the three Discover tabs and re-fetches the discover
// index. The Advanced view (search + 3-level tree + counts) is a
// later increment; its toggle is present but its body is a stub.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { GenreFilterState, GenreFilterActions, GenreChip, GenreTreeRow, UiFocusState } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QbzToggle } from "../primitives/QbzToggle.slint";
// One row of the advanced-view tree: indent + expand arrow + checkbox
// + name + child count.
component GenreTreeRowItem inherits Rectangle {
in property <GenreTreeRow> node;
callback toggle(string);
callback toggle-expand(string);
height: 34px;
border-radius: 6px;
background: ta.has-hover ? Theme.surface-hover : transparent;
HorizontalLayout {
padding-left: 6px + root.node.level * 18px;
padding-right: 10px;
spacing: 6px;
// Expand arrow (parents / children with kids).
Rectangle {
width: 20px;
VerticalLayout {
alignment: center;
if root.node.has-children: QbzIcon {
source: root.node.expanded
? @image-url("../assets/icons/chevron-down.svg")
: @image-url("../assets/icons/chevron-right.svg");
width: 13px;
height: 13px;
tint: Theme.text-muted;
}
}
arrow-ta := TouchArea {
mouse-cursor: root.node.has-children ? pointer : default;
clicked => {
if (root.node.has-children) {
root.toggle-expand(root.node.id);
}
}
}
}
// Checkbox.
VerticalLayout {
alignment: center;
Rectangle {
width: 16px;
height: 16px;
border-radius: 4px;
border-width: 1.5px;
border-color: root.node.selected ? Theme.accent : Theme.border-muted;
background: root.node.selected ? Theme.accent : transparent;
QbzIcon {
visible: root.node.selected;
source: @image-url("../assets/icons/check.svg");
width: 11px;
height: 11px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #ffffff;
}
}
}
Text {
text: root.node.name;
color: root.node.selected ? Theme.text-primary : Theme.text-secondary;
font-size: 13px;
font-weight: root.node.level == 0 ? Typography.medium : Typography.regular;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
if root.node.count > 0: Text {
text: root.node.count;
color: Theme.text-muted;
font-size: Typography.legal;
vertical-alignment: center;
}
}
// Row click (outside the arrow) toggles selection.
ta := TouchArea {
mouse-cursor: pointer;
// Sits below the arrow's TouchArea, so arrow clicks win.
clicked => {
root.toggle(root.node.id);
}
}
}
component GenreCard inherits Rectangle {
in property <GenreChip> chip;
callback clicked(string);
height: 38px;
border-radius: 6px;
background: root.chip.selected
? Theme.accent
: (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated);
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 8px;
Text {
text: root.chip.name;
color: root.chip.selected ? #ffffff : Theme.text-secondary;
font-size: 13px;
font-weight: root.chip.selected ? Typography.medium : Typography.regular;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
// Check circle.
VerticalLayout {
alignment: center;
Rectangle {
width: 16px;
height: 16px;
border-radius: 8px;
border-width: 1.5px;
border-color: root.chip.selected ? #ffffff : Theme.border-muted;
background: root.chip.selected ? #ffffff : transparent;
QbzIcon {
visible: root.chip.selected;
source: @image-url("../assets/icons/check.svg");
width: 11px;
height: 11px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: Theme.accent;
}
}
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked(root.chip.id);
}
}
}
export component GenreFilterPopup inherits Rectangle {
property <int> columns: 3;
property <length> grid-gap: 8px;
property <length> chip-height: 38px;
width: 470px;
// Hug the content vertically — without an explicit height a
// Rectangle child fills its parent (the whole view), which made
// the popup grow to full window height.
height: content.preferred-height;
background: Theme.surface-main;
border-radius: Radius.md;
border-width: 1px;
border-color: Theme.border-muted;
drop-shadow-blur: 28px;
drop-shadow-color: #00000080;
drop-shadow-offset-y: 8px;
content := VerticalLayout {
padding: 16px;
spacing: 14px;
// --- Header --------------------------------------------------
HorizontalLayout {
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/list-filter.svg");
width: 16px;
height: 16px;
tint: Theme.text-secondary;
}
}
Text {
text: @tr("Filter by genre");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
Rectangle {
width: 26px;
height: 26px;
border-radius: 6px;
background: close-ta.has-hover ? Theme.surface-hover : transparent;
QbzIcon {
source: @image-url("../assets/icons/x.svg");
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: close-ta.has-hover ? Theme.text-primary : Theme.text-muted;
}
close-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
GenreFilterState.open = false;
}
}
}
}
// --- Options row: Remember selection + Advanced view ---------
HorizontalLayout {
spacing: 16px;
HorizontalLayout {
spacing: 10px;
horizontal-stretch: 1;
Text {
text: @tr("Remember selection");
color: Theme.text-secondary;
font-size: 13px;
vertical-alignment: center;
horizontal-stretch: 1;
}
VerticalLayout {
alignment: center;
QbzToggle {
checked: GenreFilterState.remember;
toggled(v) => {
GenreFilterActions.set-remember(v);
}
}
}
}
HorizontalLayout {
spacing: 10px;
horizontal-stretch: 1;
Text {
text: @tr("Advanced view");
color: Theme.text-secondary;
font-size: 13px;
vertical-alignment: center;
horizontal-stretch: 1;
}
VerticalLayout {
alignment: center;
QbzToggle {
checked: GenreFilterState.advanced;
toggled(v) => {
GenreFilterActions.set-advanced(v);
}
}
}
}
}
// --- Advanced view: search + 3-level genre tree -------------
if GenreFilterState.advanced: VerticalLayout {
spacing: 10px;
// Search box.
Rectangle {
height: 34px;
border-radius: 6px;
background: Theme.surface-elevated;
border-width: 1px;
border-color: search-input.has-focus ? Theme.border-subtle : Theme.surface-elevated;
HorizontalLayout {
padding-left: 10px;
padding-right: 10px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/search.svg");
width: 14px;
height: 14px;
tint: Theme.text-muted;
}
}
Rectangle {
horizontal-stretch: 1;
search-input := TextInput {
width: 100%;
height: 100%;
color: Theme.text-primary;
font-size: 13px;
vertical-alignment: center;
single-line: true;
text <=> GenreFilterState.search-query;
changed has-focus => { UiFocusState.text-input-focused = self.has-focus; }
edited => {
GenreFilterActions.search(self.text);
}
}
Text {
visible: search-input.text == "";
text: @tr("Search genres…");
color: Theme.text-muted;
font-size: 13px;
vertical-alignment: center;
}
}
}
}
// Tree (scrollable).
Flickable {
height: 320px;
viewport-width: self.width;
viewport-height: tree-col.preferred-height;
tree-col := VerticalLayout {
spacing: 1px;
for entry in GenreFilterState.tree: GenreTreeRowItem {
node: entry;
toggle(id) => {
GenreFilterActions.toggle(id);
}
toggle-expand(id) => {
GenreFilterActions.toggle-expand(id);
}
}
}
}
}
// --- Simple grid: parent genres as chips ---------------------
if !GenreFilterState.advanced: grid := Rectangle {
property <int> count: GenreFilterState.genres.length;
property <int> rows: Math.ceil(self.count / root.columns);
property <length> cell-width:
(self.width - (root.columns - 1) * root.grid-gap) / root.columns;
height: self.rows > 0
? self.rows * root.chip-height + Math.max(0, self.rows - 1) * root.grid-gap
: 0px;
for chip[i] in GenreFilterState.genres: GenreCard {
chip: chip;
width: grid.cell-width;
x: Math.mod(i, root.columns) * (grid.cell-width + root.grid-gap);
y: Math.floor(i / root.columns) * (root.chip-height + root.grid-gap);
clicked(id) => {
GenreFilterActions.toggle(id);
}
}
}
// --- Footer: Clear filter ------------------------------------
Rectangle {
height: 34px;
border-radius: 6px;
background: clear-ta.has-hover && GenreFilterState.selected-count > 0
? Theme.surface-hover
: Theme.surface-elevated;
opacity: GenreFilterState.selected-count > 0 ? 1.0 : 0.5;
Text {
text: @tr("Clear filter");
color: Theme.text-secondary;
font-size: 13px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
clear-ta := TouchArea {
mouse-cursor: GenreFilterState.selected-count > 0 ? pointer : default;
clicked => {
if (GenreFilterState.selected-count > 0) {
GenreFilterActions.clear();
}
}
}
}
}
}
@@ -0,0 +1,50 @@
// A Discover section that lays slim cards in a fixed 4-column grid
// (Popular albums, Recently Played). Non-paginated for now.
//
// GridLayout cannot host a `for`, so cards are absolutely positioned
// inside a Rectangle whose height is derived from the row count.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { SlimItem } from "../state.slint";
import { SlimCard } from "SlimCard.slint";
export component GridSection inherits VerticalLayout {
in property <string> title;
in property <[SlimItem]> items;
callback item-clicked(string);
property <int> columns: 4;
property <length> gap: 8px;
property <length> row-height: 60px;
property <int> rows: Math.ceil(root.items.length / root.columns);
spacing: 12px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
}
grid := Rectangle {
property <length> cell-width:
(self.width - (root.columns - 1) * root.gap) / root.columns;
height: root.rows > 0
? root.rows * root.row-height + (root.rows - 1) * root.gap
: 0px;
for item[i] in root.items: SlimCard {
width: grid.cell-width;
height: root.row-height;
x: Math.mod(i, root.columns) * (grid.cell-width + root.gap);
y: Math.floor(i / root.columns) * (root.row-height + root.gap);
item: item;
clicked(id) => {
root.item-clicked(id);
}
}
}
}
@@ -0,0 +1,70 @@
// Loading skeleton for the Discover home — grey placeholder blocks
// shaped like the real carousels, gently pulsing (fade in/out) while
// the first fetch is in flight. Replaces the spinner + "Loading…"
// text so the first paint reads as the page filling in rather than a
// generic loader.
import { Theme } from "../foundation/semantic-colors.slint";
import { Radius } from "../foundation/radius.slint";
// A single shimmering block. Opacity breathes between two values on a
// shared phase so the whole skeleton pulses in unison.
component Shimmer inherits Rectangle {
in property <bool> phase;
background: Theme.surface-elevated;
border-radius: Radius.sm;
opacity: root.phase ? 0.85 : 0.4;
animate opacity { duration: 900ms; easing: ease-in-out; }
}
// One placeholder carousel: a short title bar over a row of card
// blocks (square art + two text lines).
component SkeletonRow inherits VerticalLayout {
in property <bool> phase;
in property <length> card-size: 200px;
spacing: 12px;
Shimmer {
phase: root.phase;
width: 180px;
height: 22px;
}
HorizontalLayout {
spacing: 32px;
for _ in [0, 1, 2, 3, 4]: VerticalLayout {
spacing: 8px;
Shimmer {
phase: root.phase;
width: root.card-size;
height: root.card-size;
}
Shimmer {
phase: root.phase;
width: root.card-size * 0.7;
height: 14px;
}
Shimmer {
phase: root.phase;
width: root.card-size * 0.45;
height: 12px;
}
}
}
}
export component HomeSkeleton inherits VerticalLayout {
property <bool> phase: false;
spacing: 40px;
// Drives the shared breathing phase.
Timer {
interval: 900ms;
running: true;
triggered => {
root.phase = !root.phase;
}
}
SkeletonRow { phase: root.phase; }
SkeletonRow { phase: root.phase; }
}
+484
View File
@@ -0,0 +1,484 @@
// Discover — Home view: a fixed 56px toolbar (tab pill + genre filter +
// settings gear) over a scrollable column of section carousels.
//
// Section data is supplied by the Rust home controller through the
// HomeState global. The Editor's Picks / For You tabs, the genre filter,
// and the settings gear are visual for now; wiring them is a later
// increment.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { HomeState, HomeActions, DiscoverState, DiscoverActions, GenreFilterState, GenreFilterActions, NavState, ContentView, ShellState } from "../state.slint";
import { Carousel } from "Carousel.slint";
import { SlimCarousel } from "SlimCarousel.slint";
import { PlaylistCarousel } from "PlaylistCarousel.slint";
import { PlaylistTagFilter } from "PlaylistTagFilter.slint";
import { HomeSkeleton } from "HomeSkeleton.slint";
import { ForYouView } from "ForYouView.slint";
import { GenreFilterPopup } from "GenreFilterPopup.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { NavButtons } from "../shell/NavButtons.slint";
// Header + hint shown for a recently-played module while it has no data
// yet (the play history fills once the playback session records plays).
component RecentPlaceholder inherits VerticalLayout {
in property <string> title;
in property <string> hint;
spacing: 10px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
}
Text {
text: root.hint;
color: Theme.text-muted;
font-size: 13px;
}
}
component Tab inherits Rectangle {
in property <string> label;
in property <bool> active: false;
callback clicked();
border-radius: 4px;
background: root.active ? Theme.surface-main
: ta.has-hover ? Theme.surface-hover : transparent;
HorizontalLayout {
padding-left: 14px;
padding-right: 14px;
padding-top: 6px;
padding-bottom: 6px;
Text {
text: root.label;
color: root.active ? Theme.text-primary : Theme.text-muted;
font-size: 13px;
font-weight: Typography.medium;
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
component GenreButton inherits Rectangle {
callback clicked();
// Accent-filled + "N genres" label when a filter is active,
// matching Tauri.
property <bool> active: GenreFilterState.selected-count > 0;
// Hug the content — the button is only as wide as its label.
width: genre-row.preferred-width;
height: 32px;
border-radius: 6px;
background: root.active
? Theme.accent
: (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated);
genre-row := HorizontalLayout {
padding-left: 12px;
padding-right: 14px;
spacing: 7px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/list-filter.svg");
width: 14px;
height: 14px;
tint: root.active ? #ffffff : Theme.text-secondary;
}
}
Text {
text: root.active
? (GenreFilterState.selected-count == 1
? @tr("1 genre")
: @tr("{} genres", GenreFilterState.selected-count))
: @tr("Filter by genre");
color: root.active ? #ffffff : Theme.text-secondary;
font-size: 13px;
font-weight: root.active ? Typography.medium : Typography.regular;
vertical-alignment: center;
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
component GearButton inherits Rectangle {
callback clicked();
width: 32px;
height: 32px;
border-radius: 4px;
background: ta.has-hover ? Theme.surface-hover : transparent;
QbzIcon {
source: @image-url("../assets/icons/home-gear.svg");
width: 20px;
height: 20px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: ta.has-hover ? Theme.text-primary : Theme.text-muted;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component HomeView inherits Rectangle {
callback album-clicked(string);
callback open-artist(string);
callback media-action(string, string, string);
// Open the Discover "View all" full-list page for a section
// (endpoint, title). Only sections with a non-empty endpoint show
// the link.
callback discover-view-all(string, string);
background: Theme.surface-main;
VerticalLayout {
spacing: 0px;
// --- Toolbar (fixed 56px) ----------------------------------------
// Side controls are anchored to the toolbar edges; the three-tab
// pill is absolutely centered on the toolbar so it stays at the
// true horizontal center regardless of the side controls' widths.
Rectangle {
height: 56px;
background: Theme.surface-main;
// History pair + the three-tab nav bar, grouped at the left
// with a gap delimiting the two clusters. Explicit width
// (= content) so the layout does not fill the toolbar and
// overlap the right controls.
left-controls := HorizontalLayout {
x: 32px;
// Align the toolbar content's vertical center to y=25 —
// 11px (the back/forward padding-top used by the album /
// artist / settings views) + 14px (half the 28px nav
// buttons). Keeps the [<] [>] pair at the same screen
// position across every view, with no jump on navigation.
y: 25px - self.height / 2;
width: self.preferred-width;
// Explicit height too — without it the layout fills the
// 56px toolbar, so `y` resolves to 0 and the tab pill
// sticks to the top instead of centering.
height: self.preferred-height;
spacing: 16px;
VerticalLayout {
alignment: center;
NavButtons { }
}
tab-pill := Rectangle {
width: tab-row.preferred-width;
height: tab-row.preferred-height;
background: Theme.surface-elevated;
border-radius: 6px;
tab-row := HorizontalLayout {
padding: 3px;
spacing: 4px;
Tab {
label: @tr("Home");
active: HomeState.active-tab == "home";
clicked => { HomeActions.select-tab("home"); }
}
Tab {
label: @tr("Editor's Picks");
active: HomeState.active-tab == "editorPicks";
clicked => { HomeActions.select-tab("editorPicks"); }
}
Tab {
label: @tr("For You");
active: HomeState.active-tab == "forYou";
clicked => { HomeActions.select-tab("forYou"); }
}
}
}
}
// Genre filter + sort gear, anchored right. Explicit width
// (= content) so `x` resolves correctly — without it the
// layout fills the toolbar and the cluster lands far left,
// on top of the history arrows.
right-controls := HorizontalLayout {
x: parent.width - self.width - 32px;
// Same y baseline as the left controls (see above).
y: 25px - self.height / 2;
width: self.preferred-width;
height: self.preferred-height;
spacing: 6px;
GenreButton {
clicked => {
GenreFilterActions.set-context("discover");
GenreFilterState.open = !GenreFilterState.open;
}
}
// Per-tab show/hide + reorder control for the Discover
// sections (not global Settings — that lives in the header
// menu). Opens the configurator modal for the active tab.
GearButton {
clicked => {
DiscoverActions.open-configurator();
}
}
}
}
Rectangle {
height: 1px;
background: Theme.border-subtle;
}
// --- Scrollable sections -----------------------------------------
// A Flickable (not a ScrollView): wheel scrolling with no scrollbar
// gutters at all. viewport-width is pinned to the Flickable width so
// the carousels' clipped content can never scroll horizontally.
// Wrapped in a non-layout Rectangle so the shared ListScrollbar can
// overlay the right gutter without stealing layout space (see the
// scrollbar homologation note in ListScrollbar.slint).
scroll-host := Rectangle {
vertical-stretch: 1;
flick := Flickable {
width: 100%;
height: 100%;
viewport-width: self.width;
viewport-height: home-content.preferred-height;
// Scroll-position restore on back/forward (see nav::scope_for).
property <string> sr-armed: NavState.restore-scope;
function sr-restore() {
if (NavState.restore-scope == "home" && self.viewport-height > self.height) {
self.viewport-y = NavState.scroll-restore;
NavState.restore-scope = "";
}
}
init => { self.sr-restore(); }
changed sr-armed => { self.sr-restore(); }
changed viewport-height => { self.sr-restore(); }
changed viewport-y => { NavState.report-scroll(self.viewport-y); }
home-content := VerticalLayout {
padding: 32px;
spacing: 40px;
alignment: start;
// Loading skeleton: shown while a discover load is in flight and
// the active tab's descriptor list is still empty (For You has
// its own skeleton inside ForYouView).
// Show the skeleton while the initial discover fetch is in
// flight. The descriptor list already carries the non-album rows
// (recent/continue/playlists) at seed time, so a length check
// would suppress it — gate on `loading` alone. The empty-data
// placeholders below are gated off while loading, so ONLY the
// skeleton shows during the fetch (1:1 Tauri).
if DiscoverState.active-tab != "forYou" && HomeState.loading: HomeSkeleton { }
// Prefs-driven render loop (Slice 5). Rust pushes the ordered
// ENABLED descriptor list for the active tab (home-sections /
// editor-sections); the For You tab's lists are pushed empty so
// this repeater renders nothing for it (the unconditional-
// repeater form — content is controlled purely via the model,
// avoiding an `if cond: for ...`). The delegate is a single-root
// VerticalLayout whose inner if-chain mounts the right component
// and binds the matching data; exactly one arm matches per id.
for desc in (DiscoverState.active-tab == "editorPicks"
? DiscoverState.editor-sections
: DiscoverState.home-sections): VerticalLayout {
spacing: 0px;
// Generic album carousels (data embedded in desc.section by
// Rust): newReleases / pressAwards / idealDiscography /
// editorPicks / qobuzissimes, plus mostStreamed when it
// renders as an album carousel (Editor's Picks).
if desc.id == "newReleases"
|| desc.id == "pressAwards"
|| desc.id == "idealDiscography"
|| desc.id == "editorPicks"
|| desc.id == "qobuzissimes"
|| (desc.id == "mostStreamed" && desc.kind == "albumCarousel"): Carousel {
section: desc.section;
show-view-all: desc.section.endpoint != "";
album-clicked(id) => {
root.album-clicked(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
view-all-clicked => {
root.discover-view-all(desc.section.endpoint, desc.section.title);
}
}
// Qobuz Playlists row — body=open, overlay=play (1:1 Tauri).
// A category multi-select dropdown (ADR-008: no pills) sits
// on the title line and filters the row client-side. Mounted
// when the row has playlists OR there are category tags to
// offer (so a zero-result filter can still be cleared).
if desc.id == "qobuzPlaylists"
&& (HomeState.playlists.length > 0 || HomeState.playlist-tags.length > 0): VerticalLayout {
spacing: 12px;
// Title + filter dropdown on one line (the carousel
// below renders its own paging controls, no title).
HorizontalLayout {
spacing: 12px;
Text {
text: @tr("Qobuz Playlists");
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
if HomeState.playlist-tags.length > 0: VerticalLayout {
alignment: center;
PlaylistTagFilter { }
}
}
if HomeState.playlists.length > 0: PlaylistCarousel {
// Title shown on the header row above, not here.
title: "";
playlists: HomeState.playlists;
body-opens: true;
show-view-all: false;
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
// Empty-result hint when a filter excludes everything.
if HomeState.playlists.length == 0: Text {
text: @tr("No playlists match the selected categories.");
color: Theme.text-muted;
font-size: 13px;
}
}
// Recently Played Albums — carousel when it has data, else a
// placeholder (always present on Home, 1:1 Tauri).
if desc.id == "recentlyPlayedAlbums" && HomeState.recent-albums.length > 0: Carousel {
section: {
title: @tr("Recently Played Albums"),
albums: HomeState.recent-albums,
};
album-clicked(id) => {
root.album-clicked(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if desc.id == "recentlyPlayedAlbums" && HomeState.recent-albums.length == 0 && !HomeState.loading: RecentPlaceholder {
title: @tr("Recently Played Albums");
hint: @tr("Albums you play will appear here.");
}
// Recently Played Tracks — slim carousel when it has data,
// else a placeholder (continueListening id).
if desc.id == "continueListening" && HomeState.recent.length > 0: SlimCarousel {
title: @tr("Recently Played Tracks");
items: HomeState.recent;
item-clicked(id) => {
root.media-action("track", id, "play");
}
}
if desc.id == "continueListening" && HomeState.recent.length == 0 && !HomeState.loading: RecentPlaceholder {
title: @tr("Recently Played Tracks");
hint: @tr("Tracks you play will appear here.");
}
// Most Streamed on Home renders as the Popular slim grid
// (kind == "slimGrid"); on Editor's Picks it is the album
// carousel handled by the generic arm above.
if desc.id == "mostStreamed" && desc.kind == "slimGrid"
&& HomeState.popular.length > 0: SlimCarousel {
title: @tr("Popular albums");
items: HomeState.popular;
item-clicked(id) => {
root.album-clicked(id);
}
}
}
// For You renders its own ordered, heterogeneous
// sections from ForYouState.
if DiscoverState.active-tab == "forYou": ForYouView {
open-album(id) => {
root.album-clicked(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
play-track(id) => {
root.media-action("track", id, "play");
}
play-top-tracks(id) => {
root.media-action("artist", id, "play-top");
}
start-radio(id) => {
root.media-action("artist", id, "radio");
}
start-radio-album(id) => {
root.media-action("album", id, "radio");
}
open-mix(which) => {
root.media-action("mix", which, "open");
}
}
}
}
// Shared scrollbar in the right gutter (homologated cross-view).
ListScrollbar {
x: parent.width - self.width - 4px;
width: 14px;
height: 100%;
viewport-height: flick.viewport-height;
visible-height: flick.height;
viewport-y <=> flick.viewport-y;
auto-hide: true;
hover-active: ShellState.pointer-in-window
&& ShellState.pointer-x >= scroll-host.absolute-position.x
&& ShellState.pointer-x <= scroll-host.absolute-position.x + scroll-host.width
&& ShellState.pointer-y >= scroll-host.absolute-position.y
&& ShellState.pointer-y <= scroll-host.absolute-position.y + scroll-host.height;
}
}
}
// --- Genre filter overlay --------------------------------------------
// Backdrop closes the popup on outside click; the panel anchors to
// the top-right under the Filter-by-genre button.
if GenreFilterState.open: Rectangle {
width: 100%;
height: 100%;
TouchArea {
clicked => {
GenreFilterState.open = false;
}
}
}
if GenreFilterState.open: GenreFilterPopup {
x: root.width - self.width - 32px;
y: 52px;
}
}
@@ -0,0 +1,217 @@
// Playlist card — the album card's twin for playlists: a 162px cover (a
// collage of up to four covers), a hover overlay with favorite / play /
// more, and a title / subtitle stack. No quality badge, no award ribbon.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { Spacing } from "../foundation/spacing.slint";
import { SearchPlaylistItem } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { ContextMenu } from "../primitives/ContextMenu.slint";
import { ContextMenuItem } from "../primitives/ContextMenuItem.slint";
import { PlaylistCollage } from "PlaylistCollage.slint";
component OverlayButton inherits Rectangle {
in property <image> icon;
in property <bool> primary: false;
in property <length> diameter: 36px;
in property <length> icon-size: 16px;
out property <bool> hovered: ta.has-hover;
callback clicked();
width: root.diameter;
height: root.diameter;
border-radius: root.diameter / 2;
background: root.primary
? (ta.has-hover ? #ffffffd6 : #ffffff)
: (ta.has-hover ? #ffffff3d : #ffffff24);
border-width: root.primary ? 0px : 1.5px;
border-color: #ffffffcc;
QbzIcon {
source: root.icon;
width: root.icon-size;
height: root.icon-size;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.primary ? #000000 : #ffffff;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component PlaylistCard inherits Rectangle {
in property <SearchPlaylistItem> playlist;
// kind ("playlist"), playlist id, action ("play" | "play-next" |
// "queue" | "favorite" | "open").
callback media-action(string, string, string);
// When true, a click on the card BODY opens the playlist ("open")
// instead of playing it — the Favorites grid wants body=open, the play
// button=play. Discover/Search leave it false (body=play), unchanged.
in property <bool> body-opens: false;
width: 200px;
height: 246px;
property <bool> overlay-on: hover.has-hover
|| fav-btn.hovered || play-btn.hovered || more-btn.hovered;
VerticalLayout {
alignment: start;
spacing: 0px;
// --- Cover collage + hover overlay -------------------------------
Rectangle {
width: 200px;
height: 200px;
border-radius: Radius.sm;
clip: true;
PlaylistCollage {
playlist: root.playlist;
size: 200px;
}
Rectangle {
width: 100%;
height: 100%;
background: #000000;
opacity: root.overlay-on ? 0.6 : 0.0;
animate opacity { duration: 150ms; }
}
hover := TouchArea {
width: 100%;
height: 100%;
mouse-cursor: pointer;
clicked => {
root.media-action("playlist", root.playlist.id, root.body-opens ? "open" : "play");
}
}
HorizontalLayout {
x: 0px;
y: 120px;
width: 200px;
height: 44px;
alignment: center;
spacing: 12px;
opacity: root.overlay-on ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
VerticalLayout {
alignment: center;
fav-btn := OverlayButton {
icon: @image-url("../assets/icons/heart.svg");
clicked => {
root.media-action("playlist", root.playlist.id, "favorite");
}
}
}
play-btn := OverlayButton {
icon: @image-url("../assets/icons/play-fill.svg");
primary: true;
diameter: 44px;
icon-size: 18px;
clicked => {
root.media-action("playlist", root.playlist.id, "play");
}
}
VerticalLayout {
alignment: center;
more-btn := OverlayButton {
icon: @image-url("../assets/icons/ellipsis.svg");
clicked => {
playlist-menu.show();
}
}
}
}
playlist-menu := PopupWindow {
x: 26px;
y: 56px;
width: 196px;
height: 109px;
ContextMenu {
ContextMenuItem {
icon: @image-url("../assets/icons/play.svg");
label: @tr("Play");
clicked => {
root.media-action("playlist", root.playlist.id, "play");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/list-plus.svg");
label: @tr("Play next");
clicked => {
root.media-action("playlist", root.playlist.id, "play-next");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/list-end.svg");
label: @tr("Add to queue");
clicked => {
root.media-action("playlist", root.playlist.id, "queue");
}
}
ContextMenuItem {
icon: @image-url("../assets/icons/heart.svg");
label: @tr("Add to favorites");
clicked => {
root.media-action("playlist", root.playlist.id, "favorite");
}
}
}
}
}
Rectangle { height: 6px; }
// --- Title / subtitle line ---------------------------------------
// The second line is the playlist's category tag (Discover cards) OR,
// when there is no tag, the muted subtitle (owner / track count — used
// by the Search + Favorites grids). The category is an UPPERCASE accent
// eyebrow (uppercased in Rust; Slint has no text-transform), styled like
// the QbzSelect "BP"/section-header accent-caps. Mutually exclusive so
// the slot never doubles up.
VerticalLayout {
height: 40px;
spacing: 2px;
padding-left: Spacing.xs;
Text {
text: root.playlist.title;
height: 20px;
color: Theme.text-primary;
font-size: Typography.body - 2px;
font-weight: Typography.semibold;
vertical-alignment: center;
overflow: elide;
}
if root.playlist.category != "": Text {
text: root.playlist.category;
height: 16px;
color: Theme.accent;
font-size: 11px;
font-weight: Typography.semibold;
letter-spacing: 0.5px;
vertical-alignment: center;
overflow: elide;
}
if root.playlist.category == "": Text {
text: root.playlist.subtitle;
height: 16px;
color: Theme.text-muted;
font-size: Typography.link - 1px;
vertical-alignment: center;
overflow: elide;
}
}
}
}
@@ -0,0 +1,169 @@
// Playlist carousel — title, "View all" link, prev/next page controls,
// and a clipped sliding track of playlist cards. Same paging mechanism as
// Carousel. Used by the search results All tab.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { SearchPlaylistItem } from "../state.slint";
import { PlaylistCard } from "PlaylistCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component NavButton 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: 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;
}
ta := TouchArea {
enabled: root.enabled;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.clicked();
}
}
}
component ViewAllLink inherits Rectangle {
callback clicked();
width: link-text.preferred-width + 16px;
height: 26px;
border-radius: 4px;
background: ta.has-hover ? Theme.surface-hover : transparent;
link-text := Text {
text: @tr("View all");
color: Theme.accent;
font-size: 14px;
font-weight: Typography.medium;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component PlaylistCarousel inherits VerticalLayout {
in property <string> title;
in property <[SearchPlaylistItem]> playlists;
in property <bool> show-view-all: false;
// When true, a card body click opens the playlist and the overlay button
// plays it (1:1 with Tauri Discover). Default false (body=play).
in property <bool> body-opens: false;
callback view-all-clicked();
callback media-action(string, string, string);
property <length> card-width: 200px;
property <length> card-height: 246px;
property <length> gap: 32px;
property <int> count: root.playlists.length;
property <int> per-page: Math.max(
1,
Math.floor((viewport.width + root.gap) / (root.card-width + root.gap)));
property <int> page-count: Math.max(1, Math.ceil(root.count / root.per-page));
property <int> page: 0;
property <int> current-page: Math.min(Math.max(0, root.page), root.page-count - 1);
property <length> step: root.per-page * (root.card-width + root.gap);
property <length> content-width:
root.count * root.card-width + Math.max(0, root.count - 1) * root.gap;
spacing: 12px;
HorizontalLayout {
spacing: 8px;
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-left.svg");
enabled: root.current-page > 0;
clicked => {
root.page = root.current-page - 1;
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-right.svg");
enabled: root.current-page < root.page-count - 1;
clicked => {
root.page = root.current-page + 1;
}
}
}
if root.show-view-all: VerticalLayout {
alignment: center;
ViewAllLink {
clicked => {
root.view-all-clicked();
}
}
}
}
viewport := Rectangle {
height: root.card-height;
clip: true;
Rectangle {
x: -root.current-page * root.step;
y: 0px;
width: root.content-width;
height: root.card-height;
animate x { duration: 220ms; easing: ease-in-out; }
HorizontalLayout {
spacing: root.gap;
for playlist in root.playlists: PlaylistCard {
playlist: playlist;
body-opens: root.body-opens;
media-action(k, i, a) => {
root.media-action(k, i, a);
}
}
}
}
Rectangle {
x: 0px;
width: 56px;
background: @linear-gradient(90deg, Theme.surface-main 0%, transparent 100%);
opacity: root.current-page > 0 ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
Rectangle {
x: parent.width - self.width;
width: 56px;
background: @linear-gradient(90deg, transparent 0%, Theme.surface-main 100%);
opacity: root.current-page < root.page-count - 1 ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
}
}
}
@@ -0,0 +1,125 @@
// Playlist cover collage. Qobuz returns up to four cover images per
// playlist; the layout is chosen by how many are available — single,
// dual (side by side), triple (one large + two stacked), or quad (three
// stacked left + one large right). Ported from the Tauri PlaylistCollage.
import { Theme } from "../foundation/semantic-colors.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { SearchPlaylistItem } from "../state.slint";
export component PlaylistCollage inherits Rectangle {
in property <SearchPlaylistItem> playlist;
in property <length> size: 220px;
width: root.size;
height: root.size;
clip: true;
background: Theme.surface-elevated;
property <length> gap: 2px;
property <int> n: root.playlist.cover-count;
// 0 covers — placeholder glyph.
if root.n <= 0: QbzIcon {
source: @image-url("../assets/icons/list-music.svg");
width: root.size * 0.32;
height: root.size * 0.32;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: Theme.text-muted;
}
// 1 — Discover cards: contain-fit over a dominant-colour letterbox.
// Discover playlist covers are often non-square (rectangle / portrait);
// cropping butchers them, so the full image is shown and the gaps are
// filled with the cover's dominant colour (1:1 with Tauri's
// PlaylistCardLite). A TRANSPARENT dominant-colour is the sentinel for
// the other surfaces (Search / Favorites / Label) that opt OUT — they
// keep the legacy cover-fit. The 2/3/4 mosaics below always stay `cover`.
if root.n == 1: Rectangle {
width: 100%;
height: 100%;
background: root.playlist.dominant-color;
Image {
width: 100%;
height: 100%;
source: root.playlist.cover1;
image-fit: root.playlist.dominant-color == Colors.transparent ? cover : contain;
}
}
// 2 — side by side halves.
if root.n == 2: HorizontalLayout {
spacing: root.gap;
Image {
source: root.playlist.cover1;
image-fit: cover;
width: (root.size - root.gap) / 2;
height: root.size;
}
Image {
source: root.playlist.cover2;
image-fit: cover;
width: (root.size - root.gap) / 2;
height: root.size;
}
}
// 3 — one large left, two stacked right.
if root.n == 3: HorizontalLayout {
spacing: root.gap;
Image {
source: root.playlist.cover1;
image-fit: cover;
width: (root.size - root.gap) * 0.62;
height: root.size;
}
VerticalLayout {
spacing: root.gap;
Image {
source: root.playlist.cover2;
image-fit: cover;
width: (root.size - root.gap) * 0.38;
height: (root.size - root.gap) / 2;
}
Image {
source: root.playlist.cover3;
image-fit: cover;
width: (root.size - root.gap) * 0.38;
height: (root.size - root.gap) / 2;
}
}
}
// 4+ — three stacked left, one large right.
if root.n >= 4: HorizontalLayout {
spacing: root.gap;
VerticalLayout {
spacing: root.gap;
Image {
source: root.playlist.cover1;
image-fit: cover;
width: (root.size - root.gap) * 0.34;
height: (root.size - 2 * root.gap) / 3;
}
Image {
source: root.playlist.cover2;
image-fit: cover;
width: (root.size - root.gap) * 0.34;
height: (root.size - 2 * root.gap) / 3;
}
Image {
source: root.playlist.cover3;
image-fit: cover;
width: (root.size - root.gap) * 0.34;
height: (root.size - 2 * root.gap) / 3;
}
}
Image {
source: root.playlist.cover4;
image-fit: cover;
width: (root.size - root.gap) * 0.66;
height: root.size;
}
}
}
@@ -0,0 +1,184 @@
// Qobuz Playlists category filter — a compact multi-select dropdown that
// replaces the old WebPlayer category pills (ADR-008: no pills). The button
// shows "Filter by category" (or "N selected") and opens a checkbox list of
// the discover-index `playlists_tags`. Toggling a tag re-filters the cached
// playlists row client-side (union of selected tags); an empty selection
// shows everything. Tag NAMES are pre-localized by the response; the chrome
// ("Filter by category", "All", "Clear") uses @tr literals.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { HomeState, HomeActions, PlaylistTagItem } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
// One checkbox row in the open list: a square check + the localized tag name.
component TagRow inherits Rectangle {
in property <PlaylistTagItem> tag;
callback toggle(string);
height: 32px;
background: ta.has-hover ? Theme.surface-hover : transparent;
HorizontalLayout {
padding-left: 12px;
padding-right: 12px;
spacing: 8px;
VerticalLayout {
alignment: center;
Rectangle {
width: 16px;
height: 16px;
border-radius: 4px;
border-width: 1.5px;
border-color: root.tag.selected ? Theme.accent : Theme.border-muted;
background: root.tag.selected ? Theme.accent : transparent;
QbzIcon {
visible: root.tag.selected;
source: @image-url("../assets/icons/check.svg");
width: 11px;
height: 11px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #ffffff;
}
}
}
Text {
text: root.tag.name;
color: root.tag.selected ? Theme.text-primary : Theme.text-secondary;
font-size: 12px;
font-weight: root.tag.selected ? Typography.medium : Typography.regular;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.toggle(root.tag.slug);
}
}
}
export component PlaylistTagFilter inherits Rectangle {
// Collapsed control: a 34px settings-style dropdown button.
private property <length> control-width: 220px;
private property <length> max-list-height: 320px;
width: root.control-width;
// sm variant — matches QbzSelect { sm: true } used by the toolbar
// selects (favorites Group / Sort): 30px tall, 6px radius, no outline.
height: 30px;
border-radius: 6px;
border-width: 0px;
background: ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
HorizontalLayout {
padding-left: 10px;
padding-right: 8px;
spacing: 8px;
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/list-filter.svg");
width: 13px;
height: 13px;
tint: Theme.text-muted;
}
}
Text {
text: HomeState.playlist-tag-count > 0
? @tr("{} selected", HomeState.playlist-tag-count)
: @tr("Filter by category");
color: HomeState.playlist-tag-count > 0 ? Theme.text-primary : Theme.text-secondary;
font-size: 12px;
vertical-alignment: center;
horizontal-stretch: 1;
overflow: elide;
}
VerticalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/chevron-down.svg");
width: 14px;
height: 14px;
tint: Theme.text-muted;
}
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
popup.show();
}
}
popup := PopupWindow {
x: 0px;
y: root.height + 4px;
width: root.control-width;
// List (capped + scrolling) + the 32px "All categories" footer + the
// 10px vertical padding of the inner column. Reading the capped list
// height (not the child rows) keeps this loop-free.
height: Math.min(list-col.preferred-height, root.max-list-height) + 32px + 10px;
Rectangle {
background: Theme.surface-main;
border-radius: Radius.sm;
border-width: 1px;
border-color: Theme.border-muted;
drop-shadow-blur: 20px;
drop-shadow-color: #00000080;
drop-shadow-offset-y: 5px;
VerticalLayout {
padding-top: 5px;
padding-bottom: 5px;
Flickable {
height: Math.min(list-col.preferred-height, root.max-list-height);
viewport-width: self.width;
viewport-height: list-col.preferred-height;
list-col := VerticalLayout {
for tag in HomeState.playlist-tags: TagRow {
tag: tag;
toggle(slug) => {
HomeActions.toggle-playlist-tag(slug);
}
}
}
}
// "Clear / show all" footer — disabled (dimmed) when nothing
// is selected.
clear-row := Rectangle {
height: 32px;
background: clear-ta.has-hover && HomeState.playlist-tag-count > 0
? Theme.surface-hover
: transparent;
opacity: HomeState.playlist-tag-count > 0 ? 1.0 : 0.5;
Text {
text: @tr("All categories");
color: Theme.text-secondary;
font-size: 12px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
}
clear-ta := TouchArea {
mouse-cursor: HomeState.playlist-tag-count > 0 ? pointer : default;
clicked => {
if (HomeState.playlist-tag-count > 0) {
HomeActions.clear-playlist-tags();
}
}
}
}
}
}
}
}
@@ -0,0 +1,107 @@
// Discover > For You "Qobuz Mixes" — port of Tauri's QobuzMixesRow.
// Four 220px navigation tiles (DailyQ / WeeklyQ / FavQ / TopQ): a
// gradient artwork with a badge + name, and a description below. Pure
// navigation entries (no per-tile data); the mix detail views they
// open are a separate feature, so the callbacks are logged for now.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
component MixTile inherits Rectangle {
in property <brush> gradient;
in property <string> badge;
in property <string> name;
in property <string> desc;
callback clicked();
width: 220px;
height: 268px;
VerticalLayout {
spacing: 8px;
// Gradient artwork.
Rectangle {
width: 220px;
height: 220px;
border-radius: 8px;
background: root.gradient;
clip: true;
Text {
text: root.badge;
x: 12px;
y: 12px;
color: #ffffffcc;
font-size: 10px;
font-weight: Typography.semibold;
letter-spacing: 1px;
}
Text {
text: root.name;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
color: #ffffff;
font-size: 22px;
font-weight: Typography.bold;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
Text {
text: root.desc;
color: Theme.text-muted;
font-size: 12px;
wrap: word-wrap;
width: 220px;
}
}
}
export component QobuzMixesRow inherits VerticalLayout {
callback open-mix(string /* daily | weekly | fav | top */);
spacing: 12px;
Text {
text: @tr("Qobuz Mixes");
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
}
HorizontalLayout {
spacing: 32px;
alignment: start;
MixTile {
gradient: @linear-gradient(135deg, #1e3a8a 0%, #6366f1 50%, #c084fc 100%);
badge: "qobuz";
name: "DailyQ";
desc: @tr("Elevate your day with a customized selection of music.");
clicked => { root.open-mix("daily"); }
}
MixTile {
gradient: @linear-gradient(135deg, #065f46 0%, #10b981 50%, #fbbf24 100%);
badge: "qobuz";
name: "WeeklyQ";
desc: @tr("Take a weekly journey with a fresh mix every Friday.");
clicked => { root.open-mix("weekly"); }
}
MixTile {
gradient: @linear-gradient(135deg, #7f1d1d 0%, #ef4444 50%, #fb923c 100%);
badge: "qbz";
name: "FavQ";
desc: @tr("A fresh shuffle from your personal library.");
clicked => { root.open-mix("fav"); }
}
MixTile {
gradient: @linear-gradient(135deg, #1f2937 0%, #4b5563 50%, #fbbf24 100%);
badge: "qbz";
name: "TopQ";
desc: @tr("Discover new music from your most-played playlists.");
clicked => { root.open-mix("top"); }
}
}
}
+124
View File
@@ -0,0 +1,124 @@
// Radio / Top-Tracks card — port of Tauri's RadioCardLite. A 180px
// tile: a square "display" with the seed artwork centered and a
// wordmark label ("RADIO" / "TOP TRACKS") over it, then a title +
// subtitle below. Hover reveals a play button.
//
// The Tauri version derives the panel colour from the artwork's
// dominant palette; that palette extraction is omitted here (a
// neutral elevated panel stands in), the rest matches.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
export component RadioCard inherits Rectangle {
in property <string> seed-title;
in property <string> seed-subtitle;
in property <string> label: @tr("RADIO");
in property <image> artwork;
callback clicked();
callback play();
// Matches AlbumCard / PlaylistCard (200 x 246): panel 200 + 8 + meta.
width: 200px;
height: 246px;
VerticalLayout {
spacing: 8px;
// Display panel.
panel := Rectangle {
width: 200px;
height: 200px;
border-radius: Radius.sm;
background: Theme.surface-elevated;
clip: true;
// Centered artwork "display".
Rectangle {
width: 126px;
height: 126px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px - 8px;
border-radius: 4px;
background: Theme.surface-card;
clip: true;
Image {
width: 100%;
height: 100%;
source: root.artwork;
image-fit: cover;
}
}
// Wordmark over the display, bottom.
Text {
text: root.label;
color: #ffffffe6;
font-size: 15px;
font-weight: Typography.bold;
letter-spacing: 2px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: parent.height - self.height - 16px;
}
// Hover overlay + play.
Rectangle {
width: 100%;
height: 100%;
background: #000000;
opacity: ta.has-hover || play-ta.has-hover ? 0.45 : 0.0;
animate opacity { duration: 150ms; }
}
play-circle := Rectangle {
width: 44px;
height: 44px;
border-radius: 22px;
background: #ffffff;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
opacity: ta.has-hover || play-ta.has-hover ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
QbzIcon {
source: @image-url("../assets/icons/play-fill.svg");
width: 18px;
height: 18px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: #000000;
}
play-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.play();
}
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
// Meta.
Text {
text: root.seed-title;
color: Theme.text-primary;
font-size: Typography.body;
font-weight: Typography.medium;
overflow: elide;
width: 200px;
}
if root.seed-subtitle != "": Text {
text: root.seed-subtitle;
color: Theme.text-muted;
font-size: Typography.legal;
overflow: elide;
width: 200px;
}
}
}
+77
View File
@@ -0,0 +1,77 @@
// Compact "slim" card — a 44px thumbnail with a title / subtitle, used
// in grid sections like Popular albums and Recently Played. Optionally
// rank-numbered on the left.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { SlimItem } from "../state.slint";
export component SlimCard inherits Rectangle {
in property <SlimItem> item;
callback clicked(string);
height: 60px;
border-radius: Radius.sm;
background: ta.has-hover ? Theme.surface-hover : transparent;
HorizontalLayout {
padding-left: 8px;
padding-right: 8px;
spacing: 12px;
if root.item.rank != "": VerticalLayout {
alignment: center;
Text {
text: root.item.rank;
width: 20px;
color: Theme.text-muted;
font-size: Typography.body;
horizontal-alignment: center;
}
}
VerticalLayout {
alignment: center;
Rectangle {
width: 44px;
height: 44px;
border-radius: 4px;
background: Theme.surface-elevated;
clip: true;
Image {
width: 100%;
height: 100%;
source: root.item.artwork;
image-fit: cover;
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: root.item.title;
color: Theme.text-primary;
font-size: Typography.link;
font-weight: Typography.medium;
overflow: elide;
}
Text {
text: root.item.subtitle;
color: Theme.text-muted;
font-size: 12px;
overflow: elide;
}
}
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked(root.item.id);
}
}
}
@@ -0,0 +1,138 @@
// A paginated slim-card section (Recently Played Tracks, Popular
// albums). 12 items per page (4 columns x 3 rows), capped at two
// pages. The prev/next controls only appear when there is more than
// one page; the track slides horizontally by a full viewport width.
//
// Mirrors the Tauri home: a 4x3 grid that pages rather than growing
// into a tall wall of rows.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { SlimItem } from "../state.slint";
import { SlimCard } from "SlimCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component NavButton 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: 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;
}
ta := TouchArea {
enabled: root.enabled;
mouse-cursor: root.enabled ? pointer : default;
clicked => {
root.clicked();
}
}
}
export component SlimCarousel inherits VerticalLayout {
in property <string> title;
in property <[SlimItem]> items;
callback item-clicked(string);
property <int> columns: 4;
property <int> rows: 3;
property <length> gap: 8px;
property <length> row-height: 60px;
property <int> per-page: root.columns * root.rows; // 12
// Cap at two pages (24 items); excess is not shown.
property <int> total: Math.min(root.items.length, 2 * root.per-page);
property <int> page-count: Math.max(1, Math.ceil(root.total / root.per-page));
// Max leftward scroll (viewport-x is 0 at start, negative scrolled).
property <length> max-scroll: Math.max(0px, (root.page-count - 1) * flick.width);
spacing: 12px;
// --- Header: title + (conditional) page controls ---------------------
HorizontalLayout {
Text {
text: root.title;
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
// Only when there is a second page.
if root.total > root.per-page: HorizontalLayout {
spacing: 4px;
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-left.svg");
enabled: flick.viewport-x < -1px;
clicked => {
flick.viewport-x = Math.min(0px, flick.viewport-x + flick.width);
}
}
}
VerticalLayout {
alignment: center;
NavButton {
icon: @image-url("../assets/icons/chevron-right.svg");
enabled: flick.viewport-x > -root.max-scroll + 1px;
clicked => {
flick.viewport-x = Math.max(-root.max-scroll, flick.viewport-x - flick.width);
}
}
}
}
}
// --- Track: a horizontal Flickable so the grid drags by page like
// the album carousel. Each page block is one viewport width wide; the
// 4x3 cards are positioned absolutely inside their page block. Card
// taps still register (Flickable separates flick from tap).
viewport := Rectangle {
height: root.rows * root.row-height + (root.rows - 1) * root.gap;
clip: true;
flick := Flickable {
width: 100%;
height: parent.height;
viewport-width: root.page-count * self.width;
viewport-height: self.height;
property <length> cell-width:
(self.width - (root.columns - 1) * root.gap) / root.columns;
for item[i] in root.items: SlimCard {
// Only the first `total` items are laid out; the rest
// (beyond two pages) collapse to zero and stay off-screen.
property <bool> shown: i < root.total;
property <int> slot: Math.mod(i, root.per-page);
property <int> page-idx: Math.floor(i / root.per-page);
property <int> slot-col: Math.mod(self.slot, root.columns);
property <int> slot-row: Math.floor(self.slot / root.columns);
visible: self.shown;
width: self.shown ? flick.cell-width : 0px;
height: root.row-height;
x: self.page-idx * flick.width
+ self.slot-col * (flick.cell-width + root.gap);
y: self.slot-row * (root.row-height + root.gap);
item: item;
clicked(id) => {
root.item-clicked(id);
}
}
}
}
}
+194
View File
@@ -0,0 +1,194 @@
// Discover > For You "Spotlight" — port of Tauri's SpotlightLite.
// One favorite artist highlighted: a header, a hero (portrait +
// ARTIST + name + play-top-tracks / open-artist circle buttons), and
// a draggable row mixing a TOP TRACKS card, a RADIO card, and the
// artist's albums.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { ForYouState, AlbumCardItem } from "../state.slint";
import { AlbumCard } from "AlbumCard.slint";
import { RadioCard } from "RadioCard.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
component CircleButton inherits Rectangle {
in property <image> icon;
in property <bool> primary: false;
callback clicked();
width: 44px;
height: 44px;
border-radius: 22px;
background: root.primary
? (ta.has-hover ? #ffffffd6 : Theme.accent)
: (ta.has-hover ? Theme.surface-hover : Theme.surface-elevated);
QbzIcon {
source: root.icon;
width: root.primary ? 18px : 16px;
height: root.primary ? 18px : 16px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.primary ? #ffffff : Theme.text-secondary;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}
export component Spotlight inherits VerticalLayout {
callback open-artist(string);
callback open-album(string);
callback play-top-tracks(string);
callback start-radio(string);
callback media-action(string, string, string);
property <length> gap: 24px;
// Row content width: TopTracks(200) + Radio(200) + albums(200 each)
// + gaps. has-top-tracks toggles the first card.
property <length> radio-cards-width:
(ForYouState.spotlight-has-top-tracks ? 200px + root.gap : 0px) + 200px + root.gap;
property <int> album-count: ForYouState.spotlight-albums.length;
property <length> content-width:
root.radio-cards-width
+ root.album-count * (200px + root.gap);
spacing: 12px;
// Header.
VerticalLayout {
spacing: 2px;
Text {
text: @tr("Spotlight");
color: Theme.text-primary;
font-size: 18px;
font-weight: Typography.semibold;
}
Text {
text: @tr("Shine a light on one of your favourite artists.");
color: Theme.text-muted;
font-size: Typography.legal;
}
}
// Hero.
HorizontalLayout {
spacing: 16px;
alignment: start;
Rectangle {
width: 140px;
height: 140px;
border-radius: 70px;
background: Theme.surface-elevated;
clip: true;
Image {
width: 100%;
height: 100%;
source: ForYouState.spotlight-image;
image-fit: cover;
}
if ForYouState.spotlight-image-url == "": QbzIcon {
source: @image-url("../assets/icons/user.svg");
width: 40px;
height: 40px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: Theme.text-muted;
}
portrait-ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.open-artist(ForYouState.spotlight-artist-id);
}
}
}
VerticalLayout {
alignment: center;
spacing: 8px;
if ForYouState.spotlight-category != "": Text {
text: @tr("ARTIST");
color: Theme.text-muted;
font-size: 10px;
font-weight: Typography.semibold;
letter-spacing: 1.5px;
}
Text {
text: ForYouState.spotlight-name;
color: Theme.text-primary;
font-size: Typography.title;
font-weight: Typography.bold;
}
HorizontalLayout {
spacing: 10px;
alignment: start;
if ForYouState.spotlight-has-top-tracks: CircleButton {
icon: @image-url("../assets/icons/play-fill.svg");
primary: true;
clicked => {
root.play-top-tracks(ForYouState.spotlight-artist-id);
}
}
CircleButton {
icon: @image-url("../assets/icons/user.svg");
clicked => {
root.open-artist(ForYouState.spotlight-artist-id);
}
}
}
}
}
Rectangle { height: 4px; }
// Content row — draggable (Flickable), like the other carousels.
Rectangle {
height: 270px;
clip: true;
Flickable {
width: 100%;
height: parent.height;
viewport-width: root.content-width;
viewport-height: self.height;
HorizontalLayout {
spacing: root.gap;
alignment: start;
if ForYouState.spotlight-has-top-tracks: RadioCard {
seed-title: @tr("Top tracks");
seed-subtitle: @tr("By {}", ForYouState.spotlight-name);
label: @tr("TOP TRACKS");
artwork: ForYouState.spotlight-image;
clicked => {
root.play-top-tracks(ForYouState.spotlight-artist-id);
}
play => {
root.play-top-tracks(ForYouState.spotlight-artist-id);
}
}
RadioCard {
seed-title: ForYouState.spotlight-name;
seed-subtitle: @tr("Qobuz Radio Station");
label: @tr("RADIO");
artwork: ForYouState.spotlight-image;
clicked => {
root.start-radio(ForYouState.spotlight-artist-id);
}
play => {
root.start-radio(ForYouState.spotlight-artist-id);
}
}
for album in ForYouState.spotlight-albums: AlbumCard {
album: album;
clicked(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
}
}
}
}