- PR1: gamescope detection at boot — X11 backend, scale 1, kiosk fullscreen; tray + miniplayer suppressed (click-offset fix). - PR2: full keyboard navigation for the kiosk (3 zones, focus ring, scroll-into-view; typing never navigates). - PR3: native gamepad via gilrs — D-pad/stick/A/B to synthetic Slint keys with hysteresis, repeat and debounce; B suppresses Escape while a text field is focused (closes the Steam OSK). - PR4: Steam OSK via the steam://open/keyboard deeplink on text focus. - PR5: scripts/qbz-add-to-steam (stdlib-only, 19/19 unit tests) with artwork assets + pure-gamepad controller layout. Spec: qbz-nix-docs/steam-deck/STEAM_DECK_GAME_MODE_PLAN.md km
367 lines
18 KiB
Plaintext
367 lines
18 KiB
Plaintext
// KioskLibrary — lightweight kiosk Library (Favorites) view (2.0.2 frente #3).
|
|
//
|
|
// Reads the SAME FavoritesState the desktop FavoritesView reads, rendered with
|
|
// the simple kiosk cards. Tabs Tracks/Albums/Artists/Playlists/Labels switch via
|
|
// FavoritesActions.select-tab (Rust lazy-loads each tab). Covers are push-only
|
|
// except album covers (windowed — v1 shows the first ~60; the window hook is a
|
|
// follow-up).
|
|
//
|
|
// Keyboard/gamepad nav (PR 2): the nav index space is the 5 tabs (indices
|
|
// 0-4) followed by the active tab's items as a uniform grid (tracks = a
|
|
// 1-column list). The view publishes that geometry into KioskNavState; each
|
|
// container mirrors the focus index (ring + scroll-into-view) and answers
|
|
// the Enter pulse. viewport-y is only ever WRITTEN from callbacks on a
|
|
// settled layout, never read by layout-feeding bindings (the
|
|
// AlbumCollectionView "Recursion detected" panic class).
|
|
import { ListView } from "std-widgets.slint";
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { FavoritesState, FavoritesActions, KioskNavState } from "../state.slint";
|
|
import { KioskAlbumGrid } from "KioskAlbumGrid.slint";
|
|
import { KioskArtistCard } from "KioskArtistCard.slint";
|
|
import { KioskTrackRow } from "KioskTrackRow.slint";
|
|
|
|
component LibTab inherits Rectangle {
|
|
in property <string> label;
|
|
in property <string> id;
|
|
// Keyboard/gamepad nav (PR 2): this tab holds the shell focus ring.
|
|
in property <bool> nav-focused: false;
|
|
callback picked(string);
|
|
property <bool> active: FavoritesState.active-tab == root.id;
|
|
horizontal-stretch: 0;
|
|
border-width: root.nav-focused ? 2px : 0px;
|
|
border-color: Theme.accent;
|
|
border-radius: Radius.sm;
|
|
HorizontalLayout {
|
|
padding-left: 2px;
|
|
padding-right: 2px;
|
|
VerticalLayout {
|
|
Text {
|
|
text: root.label;
|
|
color: root.active ? Theme.text-primary : Theme.text-muted;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
vertical-alignment: center;
|
|
}
|
|
Rectangle {
|
|
height: 2px;
|
|
background: root.active ? Theme.accent : transparent;
|
|
border-radius: 2px;
|
|
}
|
|
}
|
|
}
|
|
ta := TouchArea {
|
|
clicked => {
|
|
root.picked(root.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
export component KioskLibrary inherits Rectangle {
|
|
callback open-album(string);
|
|
callback open-artist(string);
|
|
|
|
property <length> pad: 16px;
|
|
|
|
// ---- Nav geometry publish (PR 2): 5 tabs + the active tab's items.
|
|
function publish-nav() {
|
|
KioskNavState.tabs = 5;
|
|
KioskNavState.shelves = false;
|
|
if (FavoritesState.active-tab == "tracks") {
|
|
KioskNavState.columns = 1;
|
|
KioskNavState.count = 5 + FavoritesState.tracks-visible.length;
|
|
} else if (FavoritesState.active-tab == "albums") {
|
|
KioskNavState.columns = 6;
|
|
KioskNavState.count = 5 + FavoritesState.albums-visible.length;
|
|
} else if (FavoritesState.active-tab == "artists") {
|
|
KioskNavState.columns = 7;
|
|
KioskNavState.count = 5 + FavoritesState.artists-visible.length;
|
|
} else if (FavoritesState.active-tab == "playlists") {
|
|
KioskNavState.columns = 6;
|
|
KioskNavState.count = 5 + FavoritesState.playlists-visible.length;
|
|
} else {
|
|
KioskNavState.columns = 7;
|
|
KioskNavState.count = 5 + FavoritesState.labels-visible.length;
|
|
}
|
|
KioskNavState.index = Math.max(0, Math.min(KioskNavState.index, KioskNavState.count - 1));
|
|
}
|
|
init => {
|
|
root.publish-nav();
|
|
}
|
|
property <string> nav-tab-probe: FavoritesState.active-tab;
|
|
changed nav-tab-probe => {
|
|
root.publish-nav();
|
|
}
|
|
property <int> nav-len-probe: FavoritesState.tracks-visible.length
|
|
+ FavoritesState.albums-visible.length
|
|
+ FavoritesState.artists-visible.length
|
|
+ FavoritesState.playlists-visible.length
|
|
+ FavoritesState.labels-visible.length;
|
|
changed nav-len-probe => {
|
|
root.publish-nav();
|
|
}
|
|
|
|
// Enter on a tab → the same switch the tab TouchAreas drive. Items are
|
|
// activated by their own container (each watches the same pulse).
|
|
property <int> act-probe: KioskNavState.activate-seq;
|
|
changed act-probe => {
|
|
if (KioskNavState.nav-active && KioskNavState.zone == "content"
|
|
&& KioskNavState.index < KioskNavState.tabs) {
|
|
if (KioskNavState.index == 0) {
|
|
FavoritesActions.select-tab("tracks");
|
|
} else if (KioskNavState.index == 1) {
|
|
FavoritesActions.select-tab("albums");
|
|
} else if (KioskNavState.index == 2) {
|
|
FavoritesActions.select-tab("artists");
|
|
} else if (KioskNavState.index == 3) {
|
|
FavoritesActions.select-tab("playlists");
|
|
} else if (KioskNavState.index == 4) {
|
|
FavoritesActions.select-tab("labels");
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
spacing: 0px;
|
|
|
|
Rectangle {
|
|
height: 48px;
|
|
background: Theme.surface-main;
|
|
HorizontalLayout {
|
|
padding-left: root.pad;
|
|
padding-right: root.pad;
|
|
spacing: 22px;
|
|
alignment: start;
|
|
LibTab { label: @tr("Tracks"); id: "tracks"; nav-focused: KioskNavState.nav-active && KioskNavState.zone == "content" && KioskNavState.index == 0; picked(t) => { FavoritesActions.select-tab(t); } }
|
|
LibTab { label: @tr("Albums"); id: "albums"; nav-focused: KioskNavState.nav-active && KioskNavState.zone == "content" && KioskNavState.index == 1; picked(t) => { FavoritesActions.select-tab(t); } }
|
|
LibTab { label: @tr("Artists"); id: "artists"; nav-focused: KioskNavState.nav-active && KioskNavState.zone == "content" && KioskNavState.index == 2; picked(t) => { FavoritesActions.select-tab(t); } }
|
|
LibTab { label: @tr("Playlists"); id: "playlists"; nav-focused: KioskNavState.nav-active && KioskNavState.zone == "content" && KioskNavState.index == 3; picked(t) => { FavoritesActions.select-tab(t); } }
|
|
LibTab { label: @tr("Labels"); id: "labels"; nav-focused: KioskNavState.nav-active && KioskNavState.zone == "content" && KioskNavState.index == 4; picked(t) => { FavoritesActions.select-tab(t); } }
|
|
}
|
|
Rectangle {
|
|
y: parent.height - 1px;
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
}
|
|
|
|
content := Rectangle {
|
|
vertical-stretch: 1;
|
|
clip: true;
|
|
|
|
// ListView windows the rows (only the visible band is mounted) — a
|
|
// plain VerticalLayout of every track spiked CPU on entry, which a Pi
|
|
// can't afford.
|
|
if FavoritesState.active-tab == "tracks": tracks-list := ListView {
|
|
// PR 2 — focus ring + Enter + scroll-into-view (62px rows).
|
|
property <int> focused-item: KioskNavState.index - KioskNavState.tabs;
|
|
property <bool> item-focused: KioskNavState.nav-active
|
|
&& KioskNavState.zone == "content"
|
|
&& self.focused-item >= 0
|
|
&& self.focused-item < FavoritesState.tracks-visible.length;
|
|
property <int> nav-index-probe: KioskNavState.index;
|
|
changed nav-index-probe => {
|
|
if (self.item-focused) {
|
|
if (self.focused-item * 62px < -self.viewport-y) {
|
|
self.viewport-y = -(self.focused-item * 62px - 8px);
|
|
} else if (self.focused-item * 62px + 62px > -self.viewport-y + self.height) {
|
|
self.viewport-y = -(self.focused-item * 62px + 62px - self.height + 8px);
|
|
}
|
|
}
|
|
}
|
|
property <int> act-probe: KioskNavState.activate-seq;
|
|
changed act-probe => {
|
|
if (self.item-focused) {
|
|
FavoritesActions.play-track(FavoritesState.tracks-visible[self.focused-item].id);
|
|
}
|
|
}
|
|
|
|
for track[i] in FavoritesState.tracks-visible: KioskTrackRow {
|
|
track: track;
|
|
nav-focused: tracks-list.item-focused && tracks-list.focused-item == i;
|
|
play(id) => {
|
|
FavoritesActions.play-track(id);
|
|
}
|
|
}
|
|
}
|
|
|
|
if FavoritesState.active-tab == "albums": KioskAlbumGrid {
|
|
albums: FavoritesState.albums-visible;
|
|
open(id) => {
|
|
root.open-album(id);
|
|
}
|
|
}
|
|
|
|
if FavoritesState.active-tab == "artists": arts := Flickable {
|
|
property <int> cols: 7;
|
|
property <length> gap: 14px;
|
|
property <length> cell: (self.width - 2 * root.pad - (self.cols - 1) * self.gap) / self.cols;
|
|
viewport-width: self.width;
|
|
viewport-height: Math.ceil(FavoritesState.artists-visible.length / self.cols) * (self.cell + 26px + self.gap) + root.pad;
|
|
|
|
// PR 2 — focus ring + Enter + scroll-into-view.
|
|
property <int> focused-item: KioskNavState.index - KioskNavState.tabs;
|
|
property <bool> item-focused: KioskNavState.nav-active
|
|
&& KioskNavState.zone == "content"
|
|
&& self.focused-item >= 0
|
|
&& self.focused-item < FavoritesState.artists-visible.length;
|
|
property <length> focus-top: root.pad + Math.floor(self.focused-item / self.cols) * (self.cell + 26px + self.gap);
|
|
property <int> nav-index-probe: KioskNavState.index;
|
|
changed nav-index-probe => {
|
|
if (self.item-focused) {
|
|
if (self.focus-top < -self.viewport-y) {
|
|
self.viewport-y = -(self.focus-top - 8px);
|
|
} else if (self.focus-top + self.cell + 26px > -self.viewport-y + self.height) {
|
|
self.viewport-y = -(self.focus-top + self.cell + 26px - self.height + 8px);
|
|
}
|
|
}
|
|
}
|
|
property <int> act-probe: KioskNavState.activate-seq;
|
|
changed act-probe => {
|
|
if (self.item-focused) {
|
|
root.open-artist(FavoritesState.artists-visible[self.focused-item].id);
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
for artist[i] in FavoritesState.artists-visible: KioskArtistCard {
|
|
x: root.pad + Math.mod(i, arts.cols) * (arts.cell + arts.gap);
|
|
y: root.pad + Math.floor(i / arts.cols) * (arts.cell + 26px + arts.gap);
|
|
size: arts.cell;
|
|
id: artist.id;
|
|
name: artist.name;
|
|
avatar: artist.image;
|
|
nav-focused: arts.item-focused && arts.focused-item == i;
|
|
clicked(id) => {
|
|
root.open-artist(id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if FavoritesState.active-tab == "labels": labs := Flickable {
|
|
property <int> cols: 7;
|
|
property <length> gap: 14px;
|
|
property <length> cell: (self.width - 2 * root.pad - (self.cols - 1) * self.gap) / self.cols;
|
|
viewport-width: self.width;
|
|
viewport-height: Math.ceil(FavoritesState.labels-visible.length / self.cols) * (self.cell + 26px + self.gap) + root.pad;
|
|
|
|
// PR 2 — focus ring + Enter + scroll-into-view.
|
|
property <int> focused-item: KioskNavState.index - KioskNavState.tabs;
|
|
property <bool> item-focused: KioskNavState.nav-active
|
|
&& KioskNavState.zone == "content"
|
|
&& self.focused-item >= 0
|
|
&& self.focused-item < FavoritesState.labels-visible.length;
|
|
property <length> focus-top: root.pad + Math.floor(self.focused-item / self.cols) * (self.cell + 26px + self.gap);
|
|
property <int> nav-index-probe: KioskNavState.index;
|
|
changed nav-index-probe => {
|
|
if (self.item-focused) {
|
|
if (self.focus-top < -self.viewport-y) {
|
|
self.viewport-y = -(self.focus-top - 8px);
|
|
} else if (self.focus-top + self.cell + 26px > -self.viewport-y + self.height) {
|
|
self.viewport-y = -(self.focus-top + self.cell + 26px - self.height + 8px);
|
|
}
|
|
}
|
|
}
|
|
property <int> act-probe: KioskNavState.activate-seq;
|
|
changed act-probe => {
|
|
if (self.item-focused) {
|
|
FavoritesActions.open-label(
|
|
FavoritesState.labels-visible[self.focused-item].id,
|
|
FavoritesState.labels-visible[self.focused-item].name);
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
for label[i] in FavoritesState.labels-visible: KioskArtistCard {
|
|
x: root.pad + Math.mod(i, labs.cols) * (labs.cell + labs.gap);
|
|
y: root.pad + Math.floor(i / labs.cols) * (labs.cell + 26px + labs.gap);
|
|
size: labs.cell;
|
|
id: label.id;
|
|
name: label.name;
|
|
avatar: label.image;
|
|
nav-focused: labs.item-focused && labs.focused-item == i;
|
|
clicked(id) => {
|
|
FavoritesActions.open-label(label.id, label.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if FavoritesState.active-tab == "playlists": pls := Flickable {
|
|
property <int> cols: 6;
|
|
property <length> gap: 16px;
|
|
property <length> cell: (self.width - 2 * root.pad - (self.cols - 1) * self.gap) / self.cols;
|
|
viewport-width: self.width;
|
|
viewport-height: Math.ceil(FavoritesState.playlists-visible.length / self.cols) * (self.cell + 42px + self.gap) + root.pad;
|
|
|
|
// PR 2 — focus ring + Enter + scroll-into-view.
|
|
property <int> focused-item: KioskNavState.index - KioskNavState.tabs;
|
|
property <bool> item-focused: KioskNavState.nav-active
|
|
&& KioskNavState.zone == "content"
|
|
&& self.focused-item >= 0
|
|
&& self.focused-item < FavoritesState.playlists-visible.length;
|
|
property <length> focus-top: root.pad + Math.floor(self.focused-item / self.cols) * (self.cell + 42px + self.gap);
|
|
property <int> nav-index-probe: KioskNavState.index;
|
|
changed nav-index-probe => {
|
|
if (self.item-focused) {
|
|
if (self.focus-top < -self.viewport-y) {
|
|
self.viewport-y = -(self.focus-top - 8px);
|
|
} else if (self.focus-top + self.cell + 42px > -self.viewport-y + self.height) {
|
|
self.viewport-y = -(self.focus-top + self.cell + 42px - self.height + 8px);
|
|
}
|
|
}
|
|
}
|
|
property <int> act-probe: KioskNavState.activate-seq;
|
|
changed act-probe => {
|
|
if (self.item-focused) {
|
|
FavoritesActions.open-playlist(FavoritesState.playlists-visible[self.focused-item].id);
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
for pl[i] in FavoritesState.playlists-visible: Rectangle {
|
|
x: root.pad + Math.mod(i, pls.cols) * (pls.cell + pls.gap);
|
|
y: root.pad + Math.floor(i / pls.cols) * (pls.cell + 42px + pls.gap);
|
|
width: pls.cell;
|
|
border-width: pls.item-focused && pls.focused-item == i ? 3px : 0px;
|
|
border-color: Theme.accent;
|
|
border-radius: Radius.sm;
|
|
background: pls.item-focused && pls.focused-item == i ? Theme.accent.with-alpha(0.12) : transparent;
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 7px;
|
|
Rectangle {
|
|
width: parent.width;
|
|
height: parent.width;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
clip: true;
|
|
Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: pl.cover1;
|
|
image-fit: cover;
|
|
}
|
|
}
|
|
Text {
|
|
text: pl.title;
|
|
color: Theme.text-primary;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
overflow: elide;
|
|
wrap: no-wrap;
|
|
}
|
|
}
|
|
pl-ta := TouchArea {
|
|
clicked => {
|
|
FavoritesActions.open-playlist(pl.id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|