mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
feat(ui): Browse… for the source and destination folders of Image Processor and Batch (#9357) (#9360)
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
28e5efa888
commit
a73b1e1d27
3 files changed
+30
-5
No files matched your search
@@ -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 { .. }]));
|
||||
}
|
||||
@@ -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<String, Value>, 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);
|
||||
|
||||
@@ -1170,8 +1170,8 @@ pub fn form_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user