Files
qbz/crates/qbz-slint/ui/shell/AppShell.slint
T
vicrodh 4fe034d86b feat(slint): playlist folders in the sidebar
Local, Tauri-shared playlist folders (library.db) now organize the
sidebar:

  - New folders.rs controller (create / rename / delete / move via
    qbz-library); sidebar.rs reworked to a flattened entries model
    (folder headers + grouped playlists + root playlists) with a
    session expand cache, rebuilt without a refetch on expand/move.
  - Sidebar renders folders (expandable, with playlist counts) and
    playlists (indented inside folders); a hover "..." opens a context
    popup: Move to folder (root + each folder) for playlists, Delete
    folder for folders.
  - Header gains a New-folder button + a CreateFolderModal; folders
    reload after create/delete; moves are optimistic + persisted.

Adds folder-open / folder-plus icons.

cc
2026-05-22 08:44:37 -06:00

241 lines
9.1 KiB
Plaintext

// App shell — the post-login frame: header bar, sidebar, content
// region, and player bar. The content region shows the Discover Home,
// Album detail, or Artist detail view, driven by NavState.
//
// Regions are delineated by their surface colors (chrome over the darker
// content well); no hairline borders.
import { Theme } from "../foundation/semantic-colors.slint";
import { NavState, ContentView, ShellState } from "../state.slint";
import { Sidebar } from "Sidebar.slint";
import { HeaderBar } from "HeaderBar.slint";
import { HeaderMenuOverlay } from "HeaderMenuOverlay.slint";
import { PlaylistPickerModal } from "../primitives/PlaylistPickerModal.slint";
import { CreatePlaylistModal } from "../primitives/CreatePlaylistModal.slint";
import { EditPlaylistModal } from "../primitives/EditPlaylistModal.slint";
import { CreateFolderModal } from "../primitives/CreateFolderModal.slint";
import { PlayerBar } from "PlayerBar.slint";
import { QueueSidebar } from "QueueSidebar.slint";
import { LyricsSidebar } from "LyricsSidebar.slint";
import { HomeView } from "../discover/HomeView.slint";
import { AlbumPageView } from "../album/AlbumPageView.slint";
import { ArtistPageView } from "../artist/ArtistPageView.slint";
import { MusicianPageView } from "../musician/MusicianPageView.slint";
import { LabelReleasesView } from "../label/LabelReleasesView.slint";
import { ArtistsByLocationView } from "../location/ArtistsByLocationView.slint";
import { FavoritesView } from "../favorites/FavoritesView.slint";
import { MixView } from "../mix/MixView.slint";
import { PlaylistView } from "../playlist/PlaylistView.slint";
import { SettingsView } from "../settings/SettingsView.slint";
import { SearchResultsView } from "../search/SearchResultsView.slint";
export component AppShell inherits Rectangle {
callback open-album(string);
callback open-artist(string);
callback media-action(string, string, string);
callback header-menu-navigate(string);
callback settings-bool(string, bool);
callback settings-select(string, int);
callback settings-slider(string, int);
callback settings-reset();
callback logout();
callback close-app();
background: Theme.surface-main;
// Bottom layer: catches the mouse back / forward buttons for history
// navigation. Declared first so the real UI sits on top of it.
TouchArea {
pointer-event(e) => {
if (e.kind == PointerEventKind.down) {
if (e.button == PointerEventButton.back) {
NavState.request-back();
}
if (e.button == PointerEventButton.forward) {
NavState.request-forward();
}
}
}
}
VerticalLayout {
spacing: 0px;
HeaderBar {
logout => {
root.logout();
}
close-app => {
root.close-app();
}
}
HorizontalLayout {
vertical-stretch: 1;
spacing: 0px;
Sidebar { }
// Content region — Home, Album, or Artist.
Rectangle {
horizontal-stretch: 1;
background: Theme.surface-main;
if NavState.view == ContentView.home: HomeView {
album-clicked(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.album: AlbumPageView {
open-artist(id) => {
root.open-artist(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.artist: ArtistPageView {
open-album(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.musician: MusicianPageView {
open-album(id) => {
root.open-album(id);
}
}
if NavState.view == ContentView.label: LabelReleasesView {
open-album(id) => {
root.open-album(id);
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.location: ArtistsByLocationView {
open-artist(id) => {
root.open-artist(id);
}
}
if NavState.view == ContentView.favorites: FavoritesView {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
}
if NavState.view == ContentView.mix: MixView {
play-track(id) => {
root.media-action("mix-track", id, "play");
}
play-all => {
root.media-action("mix", "", "play-all");
}
shuffle => {
root.media-action("mix", "", "shuffle");
}
refresh => {
root.media-action("mix", "", "refresh");
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.playlist: PlaylistView {
play-track(id) => {
root.media-action("playlist-track", id, "play");
}
play-all => {
root.media-action("playlist", "", "play-all");
}
shuffle => {
root.media-action("playlist", "", "shuffle");
}
toggle-favorite => {
root.media-action("playlist", "", "favorite");
}
edit => {
root.media-action("playlist", "", "edit");
}
media-action(kind, id, action) => {
root.media-action(kind, id, action);
}
}
if NavState.view == ContentView.settings: SettingsView {
settings-bool(k, v) => {
root.settings-bool(k, v);
}
settings-select(k, i) => {
root.settings-select(k, i);
}
settings-slider(k, v) => {
root.settings-slider(k, v);
}
settings-reset => {
root.settings-reset();
}
}
if NavState.view == ContentView.search: SearchResultsView {
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);
}
}
}
// Right-side panels — layout siblings of the content area, so
// they shrink the content rather than overlaying it. Always
// present; each animates its own width open/closed.
QueueSidebar { }
LyricsSidebar { }
}
PlayerBar {
open-album(id) => {
root.open-album(id);
}
open-artist(id) => {
root.open-artist(id);
}
}
}
// Header nav-tab dropdown menus. Declared LAST so it draws on top of
// the header and the content region. A plain in-window overlay (not
// a PopupWindow) — it does not grab the pointer, so the header tabs
// stay hoverable and menus can be hover-switched instantly.
HeaderMenuOverlay {
navigate(route) => {
root.header-menu-navigate(route);
}
}
// Global "Add to playlist" picker overlay, opened from any track
// context menu.
PlaylistPickerModal { }
// Global "Create playlist" modal, opened from the sidebar "+".
CreatePlaylistModal { }
// Global "Edit playlist" modal (rename / delete).
EditPlaylistModal { }
// Global "Create folder" modal.
CreateFolderModal { }
}