- Default view (Details, Icons, Large icons) now applies to every folder that keeps no view of its own: on opening, on leaving a folder with a saved view, and at once in open panes when the setting changes. - Grid icon sizes small / medium / large / extra large: Ctrl+scroll over a pane, Ctrl+plus, Ctrl+minus, Ctrl+0; per pane, kept in `.directory` (IconSize) with the rest of a remembered view. - A Sort button in the toolbar opens the sort menu (keys, ascending/descending, folders first, group by); the context menu of empty space and folders gets Sort by and View mode submenus (new action ids, also in the menu editor). - Grid in a new tab showed one item per row: the reused pane view never reported its column count to the new folder model. FolderState now carries the model's columns and the grid reports again when they differ. - Item and the sort functions are pure modules now (folder/item.rs, sort.rs). Co-Authored-By: Claude Opus 5.5 <[email protected]>
203 lines
6.1 KiB
Text
203 lines
6.1 KiB
Text
import { Theme } from "../theme.slint";
|
|
import { Icons } from "../components/icon.slint";
|
|
import { IconButton } from "../components/icon-button.slint";
|
|
import { ViewMode } from "../views/details-view.slint";
|
|
import { ViewSwitch } from "../views/view-switch.slint";
|
|
import { Breadcrumb, Crumb, Completion } from "breadcrumb.slint";
|
|
|
|
// Navigation for the active pane: sidebar toggle, back, forward, up, the breadcrumb, the
|
|
// sort menu, the view mode and the split view toggle.
|
|
export component Toolbar inherits Rectangle {
|
|
in property <bool> can-back;
|
|
in property <bool> can-forward;
|
|
in property <bool> can-up;
|
|
in property <bool> split;
|
|
in property <bool> sidebar;
|
|
in property <[Crumb]> crumbs;
|
|
in property <string> path;
|
|
in property <[Completion]> completions;
|
|
in property <ViewMode> view-mode;
|
|
in property <bool> previews;
|
|
in-out property <int> highlight <=> crumb.highlight;
|
|
out property <bool> editing: crumb.editing;
|
|
// Where the completion list goes, in window coordinates.
|
|
out property <length> crumb-x: crumb.absolute-position.x;
|
|
out property <length> crumb-bottom: crumb.absolute-position.y + crumb.height;
|
|
out property <length> crumb-width: crumb.width;
|
|
|
|
callback back();
|
|
callback forward();
|
|
callback up();
|
|
callback toggle-split();
|
|
callback view-mode-selected(ViewMode);
|
|
callback previews-toggled();
|
|
// The sort button was pressed; window coordinates of its bottom right.
|
|
callback sort-menu(length, length);
|
|
callback toggle-sidebar();
|
|
callback go(int);
|
|
callback path-edited(string);
|
|
callback path-accepted(string);
|
|
callback path-reverted();
|
|
// The actions menu button was pressed; window coordinates of its bottom right.
|
|
callback actions(length, length);
|
|
|
|
public function edit-path() {
|
|
crumb.edit();
|
|
}
|
|
|
|
public function pick(to: string) {
|
|
crumb.pick(to);
|
|
}
|
|
|
|
height: 56px;
|
|
// A short bar (the smallest window) drops Forward (Alt+Right) and the previews toggle so
|
|
// the path keeps its room. Set by the window: the bar's own width depends on its buttons.
|
|
in property <bool> compact;
|
|
|
|
HorizontalLayout {
|
|
padding-left: Theme.space-2;
|
|
padding-right: Theme.space-2;
|
|
spacing: Theme.space-2;
|
|
alignment: stretch;
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.side-navigation;
|
|
toggle: true;
|
|
bound: true;
|
|
checked: root.sidebar;
|
|
tooltip: "Sidebar (F9)";
|
|
clicked => {
|
|
root.toggle-sidebar();
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.arrow-back;
|
|
tonal: true;
|
|
enabled: root.can-back;
|
|
tooltip: "Back (Alt+Left)";
|
|
clicked => {
|
|
root.back();
|
|
}
|
|
}
|
|
}
|
|
|
|
if !root.compact: VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.arrow-forward;
|
|
tonal: true;
|
|
enabled: root.can-forward;
|
|
tooltip: "Forward (Alt+Right)";
|
|
clicked => {
|
|
root.forward();
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.arrow-upward;
|
|
tonal: true;
|
|
enabled: root.can-up;
|
|
tooltip: "Parent folder (Alt+Up)";
|
|
clicked => {
|
|
root.up();
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
horizontal-stretch: 1;
|
|
padding-left: root.compact ? 0 : Theme.space-2;
|
|
padding-right: root.compact ? 0 : Theme.space-2;
|
|
|
|
crumb := Breadcrumb {
|
|
crumbs: root.crumbs;
|
|
path: root.path;
|
|
completions: root.completions;
|
|
go(i) => {
|
|
root.go(i);
|
|
}
|
|
edited(text) => {
|
|
root.path-edited(text);
|
|
}
|
|
accepted(text) => {
|
|
root.path-accepted(text);
|
|
}
|
|
reverted => {
|
|
root.path-reverted();
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.sort;
|
|
tonal: true;
|
|
tooltip: "Sort";
|
|
clicked => {
|
|
root.sort-menu(self.absolute-position.x + self.width, self.absolute-position.y + self.height);
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
ViewSwitch {
|
|
mode: root.view-mode;
|
|
selected(mode) => {
|
|
root.view-mode-selected(mode);
|
|
}
|
|
}
|
|
}
|
|
|
|
if !root.compact: VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.image;
|
|
toggle: true;
|
|
bound: true;
|
|
checked: root.previews;
|
|
tooltip: "Previews";
|
|
clicked => {
|
|
root.previews-toggled();
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.more-vert;
|
|
tonal: true;
|
|
tooltip: "File actions";
|
|
clicked => {
|
|
root.actions(self.absolute-position.x + self.width, self.absolute-position.y + self.height);
|
|
}
|
|
}
|
|
}
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: Icons.vertical-split;
|
|
toggle: true;
|
|
bound: true;
|
|
checked: root.split;
|
|
tooltip: "Split view (F3)";
|
|
clicked => {
|
|
root.toggle-split();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|