Wires the Library header dropdown to a real Favorites view. Mirrors
Tauri's FavoritesView.svelte core: a tab bar over per-tab content,
each tab lazy-loaded on first open.
Slint:
- ContentView gains `favorites`. NavMenuEntry gains a `route`
field; the Library dropdown rows carry "favorites-tracks" /
"-albums" / "-artists" / "-playlists" / "-labels". The
HeaderMenuOverlay click bubbles the route up through AppShell ->
AppWindow -> Rust (new header-menu-navigate callback).
- FavoritesState / FavoritesActions globals. Tracks reuse
SearchTrackItem (so the shared SearchTrackRow renders them with
per-row cover art), albums reuse AlbumCardItem + the Discover
AlbumCard, artists use a new FavoriteArtistItem round-portrait
grid.
- New ui/favorites/FavoritesView.slint: title, tab bar with live
counts + active underline, and the three populated tabs.
Playlists / Labels show "Coming soon" pending their backing
views. AppShell routes ContentView.favorites.
Rust:
- crate::favorites controller — load_favorites parses the raw
get_favorites JSON (`{ <type>: { items, total } }`) into typed
qbz-models Track / Album / Artist, maps to the Slint structs.
Lazy per-tab: select-tab and the header route both call
navigate_favorites, which fetches only the opened tab.
- artwork::ArtworkTarget gains FavoriteTrack / FavoriteAlbum /
FavoriteArtist; covers stream in via the shared pipeline.
- main.rs: navigate_favorites + on_header_menu_navigate +
FavoritesActions (select-tab / open-album / open-artist /
play-track / track-action). No new qbz-core method —
get_favorites already existed.
Deferred: Playlists + Labels tab content, full pagination (one 500
page is fetched per tab), favorites preferences (tab order).
cc
135 lines
5.1 KiB
Plaintext
135 lines
5.1 KiB
Plaintext
// In-window overlay that draws the open header nav-tab dropdown.
|
|
//
|
|
// Why this exists: the four header tabs used to each own a PopupWindow.
|
|
// A PopupWindow grabs the pointer while open, so hovering a sibling tab
|
|
// delivered no hover event — the menus could not be hover-switched, the
|
|
// new menu only appeared after the old one's idle timer fired.
|
|
//
|
|
// This overlay is a plain Rectangle, so it does NOT grab the pointer:
|
|
// the header tabs stay hoverable while a menu is open. It must be the
|
|
// LAST child of the AppShell root so it draws on top of the content
|
|
// area (the header itself is only 48px tall — a menu hosted inside it
|
|
// would be clipped by the content region below).
|
|
//
|
|
// Tabs publish their identity into HeaderMenuState (open-index, anchor-x,
|
|
// items, home-item). Hovering a different tab overwrites the global, so
|
|
// the menu switches instantly. open-index == -1 means nothing is open.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { Layout } from "../foundation/layout.slint";
|
|
import { HeaderMenuState, NavState, ContentView } from "../state.slint";
|
|
import { NavMenuItem } from "NavMenuItem.slint";
|
|
|
|
export component HeaderMenuOverlay inherits Rectangle {
|
|
// Fills the whole shell; only visible (and only consumes events)
|
|
// while a menu is open.
|
|
visible: HeaderMenuState.open-index >= 0;
|
|
|
|
// Bubbles a row's destination route (e.g. "favorites-tracks") up
|
|
// to the shell so Rust can run the navigation + data load.
|
|
callback navigate(string);
|
|
|
|
// (Re)arms the idle countdown — called on any pointer activity over
|
|
// the panel or its rows.
|
|
function reset-idle() {
|
|
idle-timer.restart();
|
|
}
|
|
|
|
// Closes the menu and disarms the timer.
|
|
function close-menu() {
|
|
HeaderMenuState.open-index = -1;
|
|
idle-timer.running = false;
|
|
}
|
|
|
|
// Restart the idle countdown every time a tab (re)publishes the
|
|
// open menu — covers both the initial open and hover-switching
|
|
// between tabs.
|
|
changed open-index => {
|
|
if (HeaderMenuState.open-index >= 0) {
|
|
idle-timer.running = true;
|
|
idle-timer.restart();
|
|
} else {
|
|
idle-timer.running = false;
|
|
}
|
|
}
|
|
property <int> open-index: HeaderMenuState.open-index;
|
|
|
|
// Closes the menu after 1s without pointer interaction (project rule:
|
|
// no menu stays open more than 1s idle).
|
|
idle-timer := Timer {
|
|
interval: 1000ms;
|
|
running: false;
|
|
triggered => {
|
|
self.running = false;
|
|
HeaderMenuState.open-index = -1;
|
|
}
|
|
}
|
|
|
|
// Transparent scrim — a click outside the panel closes the menu.
|
|
// It starts BELOW the header so the tabs stay hoverable while a menu
|
|
// is open: a full-window scrim would intercept the tabs' hover
|
|
// events and block hover-switching, exactly like the old
|
|
// PopupWindow's pointer grab did.
|
|
if HeaderMenuState.open-index >= 0: TouchArea {
|
|
y: Layout.header-height;
|
|
height: parent.height - Layout.header-height;
|
|
clicked => {
|
|
root.close-menu();
|
|
}
|
|
}
|
|
|
|
// The menu panel — same styling as the former PopupWindow content:
|
|
// surface-main background, 1px border-muted, Radius.sm, drop shadow.
|
|
if HeaderMenuState.open-index >= 0: panel := Rectangle {
|
|
x: HeaderMenuState.anchor-x;
|
|
// Snug under the tabs — the 30px tab is centered in the 48px
|
|
// header, so its bottom edge sits at ~39px.
|
|
y: 45px;
|
|
width: 188px;
|
|
height: panel-box.preferred-height;
|
|
|
|
panel-box := Rectangle {
|
|
background: Theme.surface-main;
|
|
border-radius: Radius.sm;
|
|
border-width: 1px;
|
|
border-color: Theme.border-muted;
|
|
drop-shadow-blur: 24px;
|
|
drop-shadow-color: Theme.card-shadow;
|
|
drop-shadow-offset-y: 6px;
|
|
|
|
// Keeps the pointer "inside" the menu so the scrim's click
|
|
// does not pass through, and resets the idle countdown on
|
|
// any movement over the panel body.
|
|
panel-ta := TouchArea {
|
|
moved => {
|
|
root.reset-idle();
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
padding-top: 6px;
|
|
padding-bottom: 6px;
|
|
for entry[idx] in HeaderMenuState.items: NavMenuItem {
|
|
label: entry.label;
|
|
icon: entry.icon;
|
|
has-glyph: entry.has-glyph;
|
|
clicked => {
|
|
if (entry.route != "") {
|
|
root.navigate(entry.route);
|
|
} else if (idx == HeaderMenuState.home-item) {
|
|
NavState.view = ContentView.home;
|
|
}
|
|
root.close-menu();
|
|
}
|
|
// Any pointer interaction with a row resets the
|
|
// idle-close countdown.
|
|
hovered => {
|
|
root.reset-idle();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|