Canvas and Decal: the file picker opens on PNG and JPEG images (#3266)

* Canvas and Decal: the file picker opens on PNG and JPEG images

canvas.insert and canvas.decal opened the general Open dialog with no file
type, so it started on "Designs, CAD files and meshes" and PNG/JPEG files
were greyed out. Offer the image types first, as Insert SVG/DXF do (#1801).

* Canvas and Decal: rustfmt the file-picker test
This commit is contained in:
Nathan Charles
2026-10-20 12:34:23 +00:00
committed by GitHub
parent a7bc7fe2ff
commit 3f7959b536
2 changed files with 9 additions and 2 deletions
+7 -1
View File
@@ -310,7 +310,13 @@ mod tests {
Box::pin(std::future::ready(None))
}));
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
for (command, want) in [("sketch.insert_svg", vec!["svg"]), ("sketch.insert_dxf", vec!["dxf"]), ("file.insert_step", vec![])] {
for (command, want) in [
("sketch.insert_svg", vec!["svg"]),
("sketch.insert_dxf", vec!["dxf"]),
("file.insert_step", vec![]),
("canvas.insert", vec!["png", "jpg", "jpeg"]),
("canvas.decal", vec!["png", "jpg", "jpeg"]),
] {
h.app.start(command);
tick(&mut h.app, &h.ctx);
assert_eq!(asked.borrow().last().cloned(), Some(want.iter().map(|e| e.to_string()).collect::<Vec<_>>()), "{command}");
+2 -1
View File
@@ -276,7 +276,8 @@ pub fn start_hook(app: &mut SolveApp, id: &str) -> bool {
return true;
}
let command = id.to_string();
app.pick_open(move |app, path| {
// Offer the image types first: the default Open filter lists only designs and meshes.
app.pick_open_for(&["png", "jpg", "jpeg"], move |app, path| {
if let Some(path) = path {
IMAGE.with(|i| *i.borrow_mut() = Some(path));
app.last_command = solidcraft_engine::find_command(&command).map(|spec| (spec.id.into(), spec.label.into()));