Parameter import and image pickers offer their own file types (#3216) (#3314)

* claim: #3216

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Parameter import and canvas image pickers offer their file types (#3216)

Both opened the picker with no file type of their own, so it listed only
designs, CAD files and meshes (and All files). macOS lets you pick only
the types a filter names: CSV parameters, and PNG or JPEG images for a
canvas, were greyed out. They now ask for csv/json and png/jpg/jpeg,
which the picker lists first (#1801).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Phanoob <phanoob@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
phanoob
2026-10-23 14:31:46 +00:00
committed by GitHub
parent 647a52d0fb
commit b5edd98bc9
2 changed files with 28 additions and 1 deletions
+23
View File
@@ -365,4 +365,27 @@ mod tests {
finish(&mut h.app, &answer, None);
assert!(h.app.tool.is_none(), "cancelling does not resume the old placement");
}
/// #3216: pickers for files that aren't designs list the files' own types. On macOS a type
/// no filter names can't be picked: CSV parameters were greyed out.
#[test]
fn parameter_import_and_canvas_images_ask_for_their_file_types() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
let asked: Rc<RefCell<Vec<Vec<String>>>> = Rc::default();
let log = asked.clone();
h.app.services.pick_open = Some(Box::new(move |types: &[&str]| {
log.borrow_mut().push(types.iter().map(|t| t.to_string()).collect());
Box::pin(std::future::ready(None))
}));
crate::params_dialog::open(&mut h.app);
h.frames(2);
h.step(&json!({"widget": "Import…"})).unwrap();
h.frames(2);
h.app.params = None;
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
h.app.start("canvas.insert");
h.frames(2);
assert_eq!(*asked.borrow(), [vec!["csv", "json"], vec!["png", "jpg", "jpeg"]]);
}
}
+5 -1
View File
@@ -17,6 +17,10 @@ use serde_json::{Value, json};
use crate::SolveApp;
use crate::ui_kit::{self, Column};
/// What Import reads. The picker must list them: on macOS, files of a type no filter names
/// can't be picked (#3216).
pub(crate) const IMPORT_TYPES: &[&str] = &["csv", "json"];
const UNITS: [&str; 9] = ["mm", "cm", "m", "in", "ft", "deg", "rad", "", "um"];
/// Dialog state (what is being typed; the parameters themselves live in the document).
@@ -239,7 +243,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
.on_hover_text(crate::i18n::tr_label("CSV or JSON: updates existing parameters, adds new ones"))
.clicked()
{
app.pick_open_command("parameters.import", json!({}), &[]);
app.pick_open_command("parameters.import", json!({}), IMPORT_TYPES);
}
for (label, ext) in [("Export CSV…", "csv"), ("Export JSON…", "json")] {
if ui_kit::icon_label_button(ui, label, "export_tray", true, false).clicked() {