Choose folders in the platform's dialogue, not by typing a path
Every folder the desktop asked for was a text field: the library folder at launch, an import's source and second copy, a preset folder brought over from Lightroom. A typed path is how a destination silently becomes a new folder nobody meant — one wrong letter three levels down and the write succeeds somewhere the photographer will never look — and a field cannot make the folder that is not there yet. They now open the platform's own dialogue through rfd: the XDG desktop portal on Linux, the common item dialogue on Windows. The portal rather than GTK because it reaches the user's files from inside the Flatpak and needs no GTK in a Slint application, and it draws whichever desktop's chooser is running, "New folder" included. It is awaited on Slint's event loop (spawn_local), so the window keeps drawing while it is open, and parented to the window so it opens over it. PathRow shows what is chosen, read-only, beside the button. Android has no filesystem dialogue — only SAF, which returns document trees, not paths — so there the same rows stay typed fields (Pickers.local-paths). The launch screen keeps the folder used last on screen with "Open folder" beside it, so reopening is one press. Presets get two buttons, a folder and a single .xmp file, because no platform dialogue picks "a file or a folder" in one go.
This commit is contained in:
@@ -37,6 +37,7 @@ export { Develop, Capture, Levels, Peaking, Adjustments, Framing, Transfer, Mask
|
||||
export { Collections }
|
||||
export { Library }
|
||||
export { ExportOptions }
|
||||
export { Pickers } from "pickers.slint";
|
||||
export { Duplicates, DuplicateRow, DuplicateCopy }
|
||||
export { Scrolling }
|
||||
|
||||
@@ -301,6 +302,7 @@ export component AppWindow inherits Window {
|
||||
callback launch-sign-in(string);
|
||||
/// The path of a folder library — no account, no credential.
|
||||
callback launch-use-folder(string);
|
||||
callback launch-browse-local-folder();
|
||||
/// server, username, app password
|
||||
callback launch-sign-in-direct(string, string, string);
|
||||
callback launch-sign-out();
|
||||
@@ -532,6 +534,7 @@ export component AppWindow inherits Window {
|
||||
/// Reading Lightroom presets in, and what came of the last attempt.
|
||||
in property <string> preset-import-report;
|
||||
callback import-presets(string);
|
||||
callback browse-presets(bool);
|
||||
|
||||
// --- settings (FR-EXP-1, FR-EXP-3, FR-NC-6a) ---
|
||||
//
|
||||
@@ -619,6 +622,7 @@ export component AppWindow inherits Window {
|
||||
callback import-close();
|
||||
callback import-volume-picked(int);
|
||||
callback import-card-path-changed(string);
|
||||
callback import-choose-card();
|
||||
callback import-refresh-volumes();
|
||||
callback import-template-changed(string);
|
||||
callback import-mode-picked(int);
|
||||
@@ -626,6 +630,7 @@ export component AppWindow inherits Window {
|
||||
callback import-verify-toggled(bool);
|
||||
callback import-backup-toggled(bool);
|
||||
callback import-backup-path-changed(string);
|
||||
callback import-choose-backup();
|
||||
callback import-start();
|
||||
callback import-stop();
|
||||
|
||||
@@ -1132,6 +1137,7 @@ in property <bool> panel-visible: true;
|
||||
|
||||
volume-picked(i) => { root.import-volume-picked(i); }
|
||||
card-path-changed(t) => { root.import-card-path-changed(t); }
|
||||
choose-card => { root.import-choose-card(); }
|
||||
refresh-volumes() => { root.import-refresh-volumes(); }
|
||||
template-changed(t) => { root.import-template-changed(t); }
|
||||
mode-picked(i) => { root.import-mode-picked(i); }
|
||||
@@ -1139,6 +1145,7 @@ in property <bool> panel-visible: true;
|
||||
verify-toggled(on) => { root.import-verify-toggled(on); }
|
||||
backup-toggled(on) => { root.import-backup-toggled(on); }
|
||||
backup-path-changed(t) => { root.import-backup-path-changed(t); }
|
||||
choose-backup => { root.import-choose-backup(); }
|
||||
begin() => { root.import-start(); }
|
||||
stop() => { root.import-stop(); }
|
||||
close() => { root.import-close(); }
|
||||
@@ -1348,6 +1355,7 @@ in property <bool> panel-visible: true;
|
||||
|
||||
sign-in(server) => { root.launch-sign-in(server); }
|
||||
use-folder(path) => { root.launch-use-folder(path); }
|
||||
browse-local-folder => { root.launch-browse-local-folder(); }
|
||||
sign-in-direct(server, user, pw) => {
|
||||
root.launch-sign-in-direct(server, user, pw);
|
||||
}
|
||||
@@ -3422,6 +3430,7 @@ in property <bool> panel-visible: true;
|
||||
scope-toggled(name) => { root.copy-scope-toggled(name); }
|
||||
import-report: root.preset-import-report;
|
||||
import-presets(path) => { root.import-presets(path); }
|
||||
browse-presets(file) => { root.browse-presets(file); }
|
||||
save(name) => { root.save-preset(name); }
|
||||
apply(name) => { root.apply-preset(name); }
|
||||
rename(from, to) => { root.rename-preset(from, to); }
|
||||
|
||||
+22
-10
@@ -1,6 +1,7 @@
|
||||
import { Theme } from "theme.slint";
|
||||
import { Button, PanelHeading, Label, Value, Caption, Panel, ProgressBar } from "widgets.slint";
|
||||
import { Segmented, TextRow, Check, ChoiceChip } from "controls.slint";
|
||||
import { PathRow, Pickers } from "pickers.slint";
|
||||
|
||||
// TRACES: FR-CAT-10 | FR-CAT-11 | FR-NC-7a
|
||||
// Import: bringing a card into the library.
|
||||
@@ -77,6 +78,8 @@ export component ImportPage inherits Rectangle {
|
||||
|
||||
callback volume-picked(int);
|
||||
callback card-path-changed(string);
|
||||
/// Browse for the source with the platform's dialogue.
|
||||
callback choose-card();
|
||||
callback refresh-volumes();
|
||||
|
||||
// --- what is on it ---------------------------------------------------
|
||||
@@ -113,6 +116,7 @@ export component ImportPage inherits Rectangle {
|
||||
callback verify-toggled(bool);
|
||||
callback backup-toggled(bool);
|
||||
callback backup-path-changed(string);
|
||||
callback choose-backup();
|
||||
|
||||
// --- doing it --------------------------------------------------------
|
||||
in property <bool> running: false;
|
||||
@@ -219,7 +223,9 @@ export component ImportPage inherits Rectangle {
|
||||
PanelHeading { text: "From"; }
|
||||
|
||||
if root.volume-labels.length == 0: Caption {
|
||||
text: "No removable volume found. Type where the card is mounted, or plug it in and refresh.";
|
||||
text: Pickers.local-paths
|
||||
? "No removable volume found. Browse to where the card is mounted, or plug it in and refresh."
|
||||
: "No removable volume found. Type where the card is mounted, or plug it in and refresh.";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
@@ -230,13 +236,17 @@ export component ImportPage inherits Rectangle {
|
||||
clicked => { root.volume-picked(i); }
|
||||
}
|
||||
|
||||
TextRow {
|
||||
// A card mounted somewhere this app does not think to
|
||||
// look is still a card: the dialogue reaches it, where
|
||||
// the list above only knows the usual mount points.
|
||||
PathRow {
|
||||
label: "Location";
|
||||
text <=> root.card-path;
|
||||
path: root.card-path;
|
||||
placeholder: "/run/media/…";
|
||||
field-width: 320px;
|
||||
button-text: "Browse…";
|
||||
enabled: !root.running;
|
||||
accepted(t) => { root.card-path-changed(t); }
|
||||
choose => { root.choose-card(); }
|
||||
typed(t) => { root.card-path-changed(t); }
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
@@ -359,13 +369,15 @@ export component ImportPage inherits Rectangle {
|
||||
toggled(v) => { if (!root.running) { root.backup-toggled(v); } }
|
||||
}
|
||||
|
||||
if root.backup-on: TextRow {
|
||||
if root.backup-on: PathRow {
|
||||
label: "Second copy in";
|
||||
text <=> root.backup-path;
|
||||
placeholder: "/mnt/backup/Photos";
|
||||
field-width: 320px;
|
||||
// The toggle stores a single space to mean "on, no
|
||||
// folder yet" (see `import_ui`), which is not a path.
|
||||
path: root.backup-path == " " ? "" : root.backup-path;
|
||||
placeholder: "No folder chosen";
|
||||
enabled: !root.running;
|
||||
accepted(t) => { root.backup-path-changed(t); }
|
||||
choose => { root.choose-backup(); }
|
||||
typed(t) => { root.backup-path-changed(t); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Theme } from "theme.slint";
|
||||
import { Button, PanelHeading, Label, Value, Caption, Panel, Field, Disclosure } from "widgets.slint";
|
||||
import { Check } from "controls.slint";
|
||||
import { Pickers } from "pickers.slint";
|
||||
|
||||
// Launch screen: connect an account, or resume a saved one.
|
||||
//
|
||||
@@ -102,6 +103,9 @@ export component LaunchScreen inherits Rectangle {
|
||||
// A folder library: no browser, no credential, no waiting state — the
|
||||
// whole sign-in is checking the directory is there.
|
||||
callback use-folder(string);
|
||||
/// Browse for the library folder with the platform's dialogue; a folder
|
||||
/// chosen there is used at once, as a typed one is on Enter.
|
||||
callback browse-local-folder();
|
||||
/// server, username, app password
|
||||
callback sign-in-direct(string, string, string);
|
||||
callback sign-out();
|
||||
@@ -307,17 +311,48 @@ export component LaunchScreen inherits Rectangle {
|
||||
}
|
||||
|
||||
PanelHeading { text: @tr("FOLDER"); }
|
||||
folder-input := Field {
|
||||
label: @tr("Library folder");
|
||||
|
||||
// Where there is a platform dialogue, the folder is chosen
|
||||
// in it; the one used last is shown so reopening it is a
|
||||
// single press. Where there is not (Android), typed.
|
||||
if Pickers.local-paths && root.folder-path != "": Value {
|
||||
text: root.folder-path;
|
||||
placeholder: "/home/you/Pictures";
|
||||
accepted(path) => { root.use-folder(path); }
|
||||
overflow: elide;
|
||||
}
|
||||
|
||||
FormButton {
|
||||
text: @tr("Open folder");
|
||||
enabled: !root.busy && folder-input.text != "";
|
||||
clicked => { root.use-folder(folder-input.text); }
|
||||
if Pickers.local-paths: HorizontalLayout {
|
||||
spacing: Theme.gap;
|
||||
FormButton {
|
||||
text: root.folder-path != "" ? @tr("Choose another…") : @tr("Choose folder…");
|
||||
primary: root.folder-path == "";
|
||||
enabled: !root.busy;
|
||||
horizontal-stretch: 1;
|
||||
clicked => { root.browse-local-folder(); }
|
||||
}
|
||||
if root.folder-path != "": FormButton {
|
||||
text: @tr("Open folder");
|
||||
primary: true;
|
||||
enabled: !root.busy;
|
||||
horizontal-stretch: 1;
|
||||
clicked => { root.use-folder(root.folder-path); }
|
||||
}
|
||||
}
|
||||
|
||||
// One block, because the button reads the field: an id
|
||||
// inside one `if` is invisible to a sibling `if`.
|
||||
if !Pickers.local-paths: VerticalLayout {
|
||||
spacing: Theme.gap;
|
||||
folder-input := Field {
|
||||
label: @tr("Library folder");
|
||||
text: root.folder-path;
|
||||
placeholder: "/home/you/Pictures";
|
||||
accepted(path) => { root.use-folder(path); }
|
||||
}
|
||||
FormButton {
|
||||
text: @tr("Open folder");
|
||||
enabled: !root.busy && folder-input.text != "";
|
||||
clicked => { root.use-folder(folder-input.text); }
|
||||
}
|
||||
}
|
||||
|
||||
Caption {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// Choosing a folder or a file by pointing at it, not by typing its path.
|
||||
//
|
||||
// See `folder_dialog.rs` for why the platform's dialogue rather than a field:
|
||||
// a typed path is how a destination silently becomes a new folder nobody
|
||||
// meant, and the dialogue offers "New folder" where this app could not.
|
||||
|
||||
import { Theme } from "theme.slint";
|
||||
import { Button, Value } from "widgets.slint";
|
||||
import { TextRow, FieldRow } from "controls.slint";
|
||||
|
||||
// What this build can ask the platform for. Set once from Rust at startup.
|
||||
export global Pickers {
|
||||
/// A dialogue that returns filesystem paths: true on the desktop. False on
|
||||
/// Android, whose only chooser (SAF) returns document trees, not paths —
|
||||
/// so a screen that needs a path keeps its field there.
|
||||
in property <bool> local-paths: true;
|
||||
}
|
||||
|
||||
// A path setting: what is chosen now, and the button that changes it.
|
||||
//
|
||||
// Read-only where the platform has a dialogue — the value is shown so it is
|
||||
// clear what the button will change, but it is not a field, because a field is
|
||||
// the thing this replaced. Where there is no dialogue (Android) it is the
|
||||
// ordinary typed row it always was.
|
||||
export component PathRow inherits VerticalLayout {
|
||||
in property <string> label;
|
||||
in property <string> hint;
|
||||
in property <string> path;
|
||||
/// Shown dimmed when nothing is chosen yet.
|
||||
in property <string> placeholder;
|
||||
in property <string> button-text: @tr("Choose…");
|
||||
in property <bool> enabled: true;
|
||||
in property <length> field-width: 320px;
|
||||
|
||||
/// The button, where there is a dialogue.
|
||||
callback choose();
|
||||
/// The typed path, where there is not.
|
||||
callback typed(string);
|
||||
|
||||
spacing: 4px;
|
||||
|
||||
if Pickers.local-paths: FieldRow { label: root.label; hint: root.hint; }
|
||||
|
||||
if Pickers.local-paths: HorizontalLayout {
|
||||
spacing: Theme.gap-sm;
|
||||
|
||||
Value {
|
||||
text: root.path != "" ? root.path : root.placeholder;
|
||||
placeholder: root.path == "";
|
||||
overflow: elide;
|
||||
vertical-alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
min-width: 0px;
|
||||
}
|
||||
|
||||
Button {
|
||||
text: root.button-text;
|
||||
enabled: root.enabled;
|
||||
clicked => { root.choose(); }
|
||||
}
|
||||
}
|
||||
|
||||
if !Pickers.local-paths: TextRow {
|
||||
label: root.label;
|
||||
hint: root.hint;
|
||||
text: root.path;
|
||||
placeholder: root.placeholder;
|
||||
field-width: root.field-width;
|
||||
enabled: root.enabled;
|
||||
accepted(t) => { root.typed(t); }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Theme } from "theme.slint";
|
||||
import { Button, Field, Caption, PanelHeading } from "widgets.slint";
|
||||
import { ChoiceChip } from "controls.slint";
|
||||
import { Pickers } from "pickers.slint";
|
||||
|
||||
// TRACES: FR-DEV-6
|
||||
// One kind of edit, and whether a copy carries it.
|
||||
@@ -137,12 +138,13 @@ export component PresetSheet inherits Rectangle {
|
||||
callback scope-toggled(string);
|
||||
|
||||
/// TRACES: FR-DEV-6
|
||||
/// Read Lightroom presets from a typed path, and what came of the last
|
||||
/// attempt. A typed path rather than a file dialogue because that is the
|
||||
/// idiom this application already has — the launch screen takes a library
|
||||
/// the same way, and there is no native picker anywhere in it.
|
||||
/// Read Lightroom presets from a path, and what came of the last attempt.
|
||||
/// Chosen in the platform's dialogue where there is one — `true` asks for
|
||||
/// a single `.xmp` file, `false` for a folder of them — and typed where
|
||||
/// there is not (Android).
|
||||
in property <string> import-report;
|
||||
callback import-presets(string);
|
||||
callback browse-presets(bool);
|
||||
|
||||
background: #000000CC;
|
||||
|
||||
@@ -314,7 +316,24 @@ export component PresetSheet inherits Rectangle {
|
||||
|
||||
PanelHeading { text: "IMPORT"; }
|
||||
|
||||
Field {
|
||||
// Two buttons rather than one dialogue, because no platform
|
||||
// dialogue picks "a file or a folder" in one go: the portal
|
||||
// and Windows each ask for one kind.
|
||||
if Pickers.local-paths: HorizontalLayout {
|
||||
spacing: Theme.gap-sm;
|
||||
Button {
|
||||
text: "Folder…";
|
||||
horizontal-stretch: 1;
|
||||
clicked => { root.browse-presets(false); }
|
||||
}
|
||||
Button {
|
||||
text: ".xmp file…";
|
||||
horizontal-stretch: 1;
|
||||
clicked => { root.browse-presets(true); }
|
||||
}
|
||||
}
|
||||
|
||||
if !Pickers.local-paths: Field {
|
||||
placeholder: "Path to a .xmp file or folder";
|
||||
accepted(path) => { root.import-presets(path); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user