Save PDF: Flattener preset shows a preset named in another case by its name

A flattenerPreset given as MINE or HIGH RESOLUTION saved with that preset,
but the dropdown compared names exactly and showed [Custom]. It now finds
the preset by name in any case, as the export does.
This commit is contained in:
dotCooCoo
2026-11-18 16:01:48 -08:00
parent 5f23bea81a
commit e81061dd1e
2 changed files with 18 additions and 1 deletions
+4 -1
View File
@@ -1011,9 +1011,12 @@ fn advanced(app: &VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) {
let saved = &app.session.prefs.flattener_presets;
// [Custom] while Custom… options differ from the preset's.
let current = flattener(d, saved).ok();
// The preset as the list names it: the export finds a name in any case.
let name = flattener_name(d);
let name = presets.iter().find(|p| p.name.eq_ignore_ascii_case(name.trim())).map_or(name.as_str(), |p| p.name.as_str());
let mut custom = false;
ui.add_enabled_ui(flat, |ui| {
if let Some(p) = super::flatten::preset_dropdown(ui, "flattenerPreset", &presets, &flattener_name(d), current.as_ref(), 200.0) {
if let Some(p) = super::flatten::preset_dropdown(ui, "flattenerPreset", &presets, name, current.as_ref(), 200.0) {
set(d, "flattenerPreset", json!(p.name));
d.fields.remove("flattener");
}
@@ -1151,6 +1151,20 @@ fn custom_keeps_the_overprint_option_of_a_saved_preset_deleted_meanwhile() {
}
}
/// Flattener preset shows a preset named in another case by its name, not as [Custom].
#[test]
fn flattener_preset_shows_a_name_given_in_any_case() {
let (mut app, _, _) = app();
app.run("flattener.presets.save", json!({"name": "Mine", "balance": 20})).unwrap();
let r = Reader::new();
for (given, shown) in [("MINE", "Mine"), ("HIGH RESOLUTION", "High Resolution")] {
open_advanced(&mut app, json!({"compatibility": "1.3", "flattenerPreset": given}));
let texts = r.texts(&mut app);
assert!(texts.iter().any(|t| t == shown), "{given}: {texts:?}");
assert!(!texts.iter().any(|t| t == "[Custom]"), "{given}: {texts:?}");
}
}
#[test]
fn save_preset_says_it_leaves_the_custom_flattener_options_out() {
let (mut app, _, _) = app();