The editable Customize Shortcuts modal now lays its categories across three columns (extracted KbEditGroup, reusing the cheatsheet's column models) so it matches the cheatsheet and avoids a tall scroll; panel widened to fit. Keycap text bumped to 15px in both modals so the arrow-key glyphs read clearly. cc
261 lines
11 KiB
Plaintext
261 lines
11 KiB
Plaintext
// Keyboard-shortcuts cheatsheet — read-only 1:1 port of the Tauri
|
|
// `KeyboardShortcutsModal.svelte`. Lists every keybinding grouped by
|
|
// category (Playback / Navigation / Interface / ...), each row showing the
|
|
// localized action label (left) and its formatted shortcut keycap (right).
|
|
// A footer "Customize Shortcuts" button hands off to the editable editor.
|
|
//
|
|
// Self-gated mount in AppShell (ADR-010): `if KeyboardShortcutsState.open`.
|
|
// Opened with the `?` hotkey. Escape / scrim-click / X all close it.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { KeyboardShortcutsState, KeybindingsState, KeybindingCategoryGroup } from "../state.slint";
|
|
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
|
|
|
// One category block (uppercase header + its binding rows). Extracted so the
|
|
// body can lay the groups out across THREE columns instead of one tall
|
|
// scrolling column.
|
|
component KbGroupBlock inherits VerticalLayout {
|
|
in property <KeybindingCategoryGroup> group;
|
|
spacing: 12px;
|
|
|
|
VerticalLayout {
|
|
spacing: 8px;
|
|
Text {
|
|
text: group.label;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.legal;
|
|
font-weight: Typography.semibold;
|
|
}
|
|
Rectangle {
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
}
|
|
|
|
for entry in group.rows: Rectangle {
|
|
height: entry-row.preferred-height + 16px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
|
|
entry-row := HorizontalLayout {
|
|
padding-left: 12px;
|
|
padding-right: 12px;
|
|
padding-top: 8px;
|
|
padding-bottom: 8px;
|
|
spacing: 12px;
|
|
|
|
Text {
|
|
text: entry.label;
|
|
color: Theme.text-primary;
|
|
font-size: Typography.body;
|
|
horizontal-stretch: 1;
|
|
vertical-alignment: center;
|
|
}
|
|
|
|
// Keycap — a subtle key-like chip (Radius.sm, NOT a pill, ADR-008).
|
|
Rectangle {
|
|
width: keycap-label.preferred-width + 16px;
|
|
height: keycap-label.preferred-height + 8px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-card;
|
|
border-width: 1px;
|
|
border-color: Theme.border-muted;
|
|
keycap-label := Text {
|
|
text: entry.shortcut;
|
|
color: Theme.text-secondary;
|
|
// Bigger than the rest so the arrow-key glyphs (← → ↑ ↓)
|
|
// read clearly — their heads were faint at 13px.
|
|
font-size: Typography.body;
|
|
font-family: "monospace";
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export component KeyboardShortcutsModal inherits Rectangle {
|
|
visible: KeyboardShortcutsState.open;
|
|
|
|
if KeyboardShortcutsState.open: Rectangle {
|
|
background: #000000bf;
|
|
|
|
// Scrim — click outside the panel closes.
|
|
TouchArea {
|
|
mouse-cursor: default;
|
|
clicked => {
|
|
KeyboardShortcutsState.open = false;
|
|
}
|
|
}
|
|
|
|
// Card-sized FocusScope so Escape closes (grabs focus on mount).
|
|
keys := FocusScope {
|
|
// Natural height = header + scrollable body content + footer, but
|
|
// the Flickable reports only its own (small) preferred height, so
|
|
// we add the body's real content height back and cap at ~80vh. The
|
|
// Flickable then stretches to whatever room is left and scrolls.
|
|
property <length> chrome-height: header-row.preferred-height
|
|
+ footer-row.preferred-height + 2px;
|
|
property <length> content-height: chrome-height + body.preferred-height + 40px;
|
|
|
|
width: Math.min(root.width - 80px, 980px);
|
|
height: Math.min(self.content-height, root.height - 80px);
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
|
|
key-pressed(event) => {
|
|
if (event.text == Key.Escape) {
|
|
KeyboardShortcutsState.open = false;
|
|
return accept;
|
|
}
|
|
return reject;
|
|
}
|
|
|
|
// Deferred mount focus — synchronous focus during the remount
|
|
// races layout; a one-shot timer grabs it a tick later.
|
|
focus-timer := Timer {
|
|
interval: 30ms;
|
|
running: true;
|
|
triggered => {
|
|
self.running = false;
|
|
keys.focus();
|
|
}
|
|
}
|
|
|
|
card := Rectangle {
|
|
border-radius: Radius.md;
|
|
background: Theme.surface-card;
|
|
border-width: 1px;
|
|
border-color: Theme.border-subtle;
|
|
drop-shadow-blur: 32px;
|
|
drop-shadow-color: #00000080;
|
|
|
|
// Swallow clicks so they don't reach the scrim.
|
|
TouchArea { }
|
|
|
|
panel := VerticalLayout {
|
|
spacing: 0px;
|
|
|
|
// --- Header: title + X close --------------------------
|
|
header-row := HorizontalLayout {
|
|
padding: 20px;
|
|
spacing: 10px;
|
|
|
|
// Fixed-size icon vertically centered in the header row
|
|
// via a 1-stretch-free wrapper (Image has no layout
|
|
// vertical-alignment property).
|
|
Rectangle {
|
|
width: 20px;
|
|
title-icon := QbzIcon {
|
|
source: @image-url("../assets/icons/keyboard.svg");
|
|
width: 20px;
|
|
height: 20px;
|
|
tint: Theme.text-primary;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
}
|
|
Text {
|
|
text: @tr("Keyboard Shortcuts");
|
|
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 => {
|
|
KeyboardShortcutsState.open = false;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Header divider.
|
|
Rectangle {
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
|
|
// --- Body: scrollable grouped list --------------------
|
|
Flickable {
|
|
vertical-stretch: 1;
|
|
viewport-width: self.width;
|
|
viewport-height: body.preferred-height;
|
|
|
|
// Groups laid out across THREE columns (round-robin by
|
|
// index) so the cheatsheet fits without a tall scroll.
|
|
body := HorizontalLayout {
|
|
padding: 20px;
|
|
spacing: 24px;
|
|
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 24px;
|
|
for group in KeybindingsState.groups-col1: KbGroupBlock { group: group; }
|
|
}
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 24px;
|
|
for group in KeybindingsState.groups-col2: KbGroupBlock { group: group; }
|
|
}
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 24px;
|
|
for group in KeybindingsState.groups-col3: KbGroupBlock { group: group; }
|
|
}
|
|
}
|
|
}
|
|
|
|
// Footer divider.
|
|
Rectangle {
|
|
height: 1px;
|
|
background: Theme.border-subtle;
|
|
}
|
|
|
|
// --- Footer: Customize Shortcuts ----------------------
|
|
footer-row := HorizontalLayout {
|
|
padding: 16px;
|
|
alignment: center;
|
|
|
|
customize-btn := Rectangle {
|
|
width: customize-label.preferred-width + 40px;
|
|
height: 40px;
|
|
border-radius: Radius.sm;
|
|
background: customize-ta.has-hover ? Theme.surface-hover : Theme.surface-elevated;
|
|
border-width: 1px;
|
|
border-color: customize-ta.has-hover ? Theme.accent : Theme.border-subtle;
|
|
customize-label := Text {
|
|
text: @tr("Customize Shortcuts");
|
|
color: customize-ta.has-hover ? Theme.text-primary : Theme.text-secondary;
|
|
font-size: Typography.body;
|
|
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
|
|
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
|
|
}
|
|
customize-ta := TouchArea {
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
KeyboardShortcutsState.open = false;
|
|
KeyboardShortcutsState.customize-open = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|