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:
+32
-10
@@ -922,6 +922,20 @@ impl SaveError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Read Lightroom presets from a file or a folder and say what came of it.
|
||||
///
|
||||
/// Synchronous, deliberately. A preset folder is a few hundred small text
|
||||
/// files and the read is milliseconds; a worker and a progress bar would be
|
||||
/// machinery around a wait nobody sees.
|
||||
fn import_presets(w: &AppWindow, named: &Rc<NamedPresets>, path: &Path) {
|
||||
if path.as_os_str().is_empty() {
|
||||
return;
|
||||
}
|
||||
let report = named.import(path);
|
||||
w.set_preset_import_report(report.into());
|
||||
render_named(w, named);
|
||||
}
|
||||
|
||||
/// Push the listing onto the window.
|
||||
pub fn render_named(window: &AppWindow, named: &Rc<NamedPresets>) {
|
||||
window.set_preset_rows(slint::ModelRc::new(slint::VecModel::from(named.rows())));
|
||||
@@ -1077,16 +1091,24 @@ pub fn wire_named(
|
||||
let named = named.clone();
|
||||
window.on_import_presets(move |path| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let path = path.trim();
|
||||
if path.is_empty() {
|
||||
return;
|
||||
}
|
||||
// Synchronous, deliberately. A preset folder is a few hundred
|
||||
// small text files and the read is milliseconds; a worker and a
|
||||
// progress bar would be machinery around a wait nobody sees.
|
||||
let report = named.import(Path::new(path));
|
||||
w.set_preset_import_report(report.into());
|
||||
render_named(&w, &named);
|
||||
import_presets(&w, &named, Path::new(path.trim()));
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let named = named.clone();
|
||||
window.on_browse_presets(move |file| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let (title, pick) = if file {
|
||||
("Import a Lightroom preset", crate::folder_dialog::Pick::File(&["xmp"]))
|
||||
} else {
|
||||
("Import a folder of Lightroom presets", crate::folder_dialog::Pick::Folder)
|
||||
};
|
||||
let (weak, named) = (weak.clone(), named.clone());
|
||||
crate::folder_dialog::ask(&w, title, pick, None, move |path| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
import_presets(&w, &named, &path);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user