From a73b1e1d27ba43c0eb104966d79f0c2cebbbafdf Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 25 Oct 2026 08:18:37 -0600 Subject: [PATCH] =?UTF-8?q?feat(ui):=20Browse=E2=80=A6=20for=20the=20sourc?= =?UTF-8?q?e=20and=20destination=20folders=20of=20Image=20Processor=20and?= =?UTF-8?q?=20Batch=20(#9357)=20(#9360)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Image Processor, Batch, Lens Correction, Contact Sheet and Create Droplet took their source and destination folders as typed paths only. Photoshop picks them with Select Folder… / Choose… buttons. Their `input` and `output` fields now get the same Browse… folder picker the `dir` fields of the export dialogs have (#7942). Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/browse_field_tests.rs | 18 ++++++++++++++++++ crates/ui-egui/src/dialogs.rs | 13 ++++++++++--- crates/ui-egui/src/view_cmds.rs | 4 ++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/browse_field_tests.rs b/crates/ui-egui/src/browse_field_tests.rs index 2aa3ef44f5..09debf418b 100644 --- a/crates/ui-egui/src/browse_field_tests.rs +++ b/crates/ui-egui/src/browse_field_tests.rs @@ -63,3 +63,21 @@ fn install_plugin_path_is_chosen_with_browse() { } assert_eq!(field(&h, "path"), Some(json!("/tmp/blur.wasm"))); } + +/// #9357: Image Processor's source and destination folders are chosen with Browse…, as +/// Photoshop's Select Folder… buttons choose them, instead of being typed. +#[test] +fn image_processor_folders_are_chosen_with_browse() { + let (mut h, asked) = harness(vec![Some(FileDialogAnswer::FolderTo("/tmp/shoot".into())), Some(FileDialogAnswer::FolderTo("/tmp/web".into()))]); + let ctx = h.ctx.clone(); + crate::menus::invoke(h.state_mut(), &ctx, "file.scripts.imageProcessor", json!({})).unwrap(); + h.run_steps(4); + assert_eq!(h.query_all_by_label("Browse…").count(), 2, "one Browse… for the source and one for the destination"); + h.query_all_by_label("Browse…").next().unwrap().click(); + h.run_steps(4); + assert_eq!(field(&h, "input"), Some(json!("/tmp/shoot"))); + h.query_all_by_label("Browse…").nth(1).unwrap().click(); + h.run_steps(4); + assert_eq!(field(&h, "output"), Some(json!("/tmp/web"))); + assert!(matches!(asked.borrow().as_slice(), [FileDialogRequest::Folder { .. }, FileDialogRequest::Folder { .. }])); +} diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index bc658783cd..2c683bce38 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -11,11 +11,18 @@ use crate::widgets::{ButtonRole, DialogButton, dialog_buttons}; /// [`show`] takes it out again and opens the matching file or folder dialog. pub(crate) const BROWSE_FIELD: &str = "__browse"; -/// Browse… beside a path field of dialog `id`: a folder picker for `dir` fields, a `.wasm` picker -/// for Install Plug-in…'s `path`. The answer fills the field. +/// A text field that names a folder: an export's `dir`, and the source (`input`) and destination +/// (`output`) folders of Image Processor, Batch, Lens Correction, Contact Sheet and Create +/// Droplet, which Photoshop picks with Select Folder… / Choose… (#9357). +pub(crate) fn is_folder_field(key: &str) -> bool { + matches!(key, "dir" | "input" | "output") +} + +/// Browse… beside a path field of dialog `id`: a folder picker for folder fields +/// ([`is_folder_field`]), a `.wasm` picker for Install Plug-in…'s `path`. The answer fills the field. fn browse_field(app: &mut PhotocraftApp, id: u64, fields: &serde_json::Map, key: &str) { let key = key.to_string(); - let r = if key == "dir" { + let r = if is_folder_field(&key) { app.ask_folder(move |app, path| fill_field(app, id, &key, path)) } else if fields.get("__command").and_then(Value::as_str) == Some("plugin.install") { let initial_dir = crate::file_dialog::last_used_dir(&app.ui.recent_files); diff --git a/crates/ui-egui/src/view_cmds.rs b/crates/ui-egui/src/view_cmds.rs index 9fdc456569..ebf7540e38 100644 --- a/crates/ui-egui/src/view_cmds.rs +++ b/crates/ui-egui/src/view_cmds.rs @@ -1170,8 +1170,8 @@ pub fn form_body(ui: &mut egui::Ui, f: &mut Map) { None => { ui.horizontal(|ui| { ui.add(egui::TextEdit::singleline(&mut s).desired_width(260.0)); - // A folder field gets the system folder picker (#7942). - if k == "dir" && crate::widgets::secondary_button(ui, tl!("Browse…"), 0.0).clicked() { + // A folder field gets the system folder picker (#7942, #9357). + if crate::dialogs::is_folder_field(&k) && crate::widgets::secondary_button(ui, tl!("Browse…"), 0.0).clicked() { browse = Some(k.clone()); } });