Tunal/crates/tunal/ui/dialogs/folder-appearance.slint
astar76 7b13c1658e Seek bar, spring motion, archive formats, file pickers, icon browser and launchers
Seeking and the sidebar selection spring to the click. Compress and extract
cover the 7z formats. Path fields get a file picker, icon dialogs a browser
with categories. Create new makes launchers, Edit launcher changes them. New
tabs open Home and a file path opens its folder. Dialogs opened from a menu
keep the focus. Remote noted in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 01:51:39 -06:00

89 lines
2.7 KiB
Text

import { Theme } from "../theme.slint";
import { Icon, Icons } from "../components/icon.slint";
import { Dialog } from "../components/dialog.slint";
import { ButtonKind } from "../components/button.slint";
import { Switch } from "../components/switch.slint";
import { TextField } from "../components/text-field.slint";
import { IconChoice, IconPicker } from "../components/icon-picker.slint";
// Display name, icon and per-folder view settings of one folder. `saved` runs on Save with the
// fields; the owner closes the dialog, or sets `error` (with `can-elevate` after a permission
// failure, which turns Save into "Save as administrator").
export component FolderAppearanceDialog inherits Dialog {
glyph: Icons.folder;
in property <[IconChoice]> icons;
in-out property <int> choice;
in-out property <string> name-text;
in-out property <string> image-path;
in-out property <IconChoice> browsed;
in-out property <bool> remember;
in property <string> placeholder;
in property <string> error;
in property <bool> can-elevate;
callback saved(bool);
title: "Folder appearance";
dialog-width: 456px;
actions: [
{ text: "Cancel", kind: ButtonKind.text },
{ text: root.can-elevate ? "Save as administrator" : "Save", kind: ButtonKind.filled }
];
default-action: 1;
cancel-action: 0;
content-focus: true;
focus-content => {
name-field.focus-input();
}
action(i) => {
picker.browsing = false;
if i == 1 {
root.saved(root.can-elevate);
} else {
root.close();
}
}
name-field := TextField {
label: "Display name";
placeholder: root.placeholder;
text <=> root.name-text;
accepted => {
root.saved(root.can-elevate);
}
}
picker := IconPicker {
icons: root.icons;
choice <=> root.choice;
image-path <=> root.image-path;
browsed <=> root.browsed;
accepted => {
root.saved(root.can-elevate);
}
}
HorizontalLayout {
spacing: Theme.space-3;
Text {
horizontal-stretch: 1;
text: "Remember this view for the folder";
color: Theme.on-surface;
font-size: Theme.body-medium.size;
font-weight: Theme.body-medium.weight;
vertical-alignment: center;
}
Switch {
checked <=> root.remember;
accessible-label: "Remember this view for the folder";
}
}
if root.error != "": Text {
text: root.error;
color: Theme.error;
font-size: Theme.body-small.size;
wrap: word-wrap;
}
}