PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Preferences: System Title Bar says it applies at next launch (#1677)
midasdfb5320e590e16
diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rsindex 782e09ac2..79aec0d8a 100644--- a/crates/ui-egui/src/prefs_ui.rs+++ b/crates/ui-egui/src/prefs_ui.rs@@ -1022,7 +1022,14 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>Value::Bool(b) => {ui.label("");let mut b = *b;- crate::widgets::checkbox(ui, &mut b, &label);+ if path == "interface.systemTitleBar" && cfg!(all(not(target_arch = "wasm32"), not(target_os = "macos"))) {+ ui.vertical(|ui| {+ crate::widgets::checkbox(ui, &mut b, &label);+ ui.label(RichText::new(tl!("Applies at next launch.")).color(t.text_dim));+ });+ } else {+ crate::widgets::checkbox(ui, &mut b, &label);+ }obj.insert(k, json!(b));}Value::String(s) if path == "interface.language" => {@@ -1993,6 +2000,62 @@ mod tests {assert_eq!(restarted.session.prefs().interface.ui_font_size, prefs::UiFontSize::Large);}+ #[cfg(all(not(target_arch = "wasm32"), not(target_os = "macos")))]+ #[test]+ fn system_title_bar_explains_next_launch_and_preserves_apply_and_cancel() {+ use egui_kittest::{Harness, kittest::Queryable};++ let (mut app, store) = app_with_store();+ app.run("prefs.set", json!({"values": {"interface.language": "en"}})).unwrap();+ app.custom_titlebar = true;+ let id = open_preferences(&mut app, "interface");+ let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| {+ PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());+ app+ });+ h.run_steps(4);+ h.get_by_label("System title bar").scroll_to_me();+ h.run_steps(4);+ h.get_by_label("Applies at next launch.");+ for desired in [true, false] {+ h.get_by_label("System title bar").click();+ h.run_steps(4);+ assert_eq!(h.state().ui.dialogs.iter().find(|d| d.id == id).unwrap().fields["values"]["interface"]["systemTitleBar"], desired);+ assert_eq!(h.state().session.prefs().interface.system_title_bar, !desired, "the draft is not applied yet");+ h.get_by_label("Applies at next launch.");+ h.get_by_label("Apply").click();+ h.run_steps(4);+ assert_eq!(h.state().session.prefs().interface.system_title_bar, desired);+ assert_eq!(stored(&store)["interface"]["systemTitleBar"], desired);+ assert!(h.state().custom_titlebar, "do not change the current window or restart it");+ let (reloaded, _) = app_with_saved(store.lock().unwrap().clone());+ assert_eq!(reloaded.session.prefs().interface.system_title_bar, desired);+ h.get_by_label("Applies at next launch.");+ }+ h.get_by_label("System title bar").click();+ h.run_steps(4);+ h.get_by_label("Cancel").click();+ h.run_steps(4);+ assert!(h.state().ui.dialogs.iter().all(|d| d.id != id));+ assert!(!h.state().session.prefs().interface.system_title_bar);+ assert_eq!(stored(&store)["interface"]["systemTitleBar"], false);+ assert!(h.state().custom_titlebar);+ }++ #[test]+ fn next_launch_notice_does_not_mark_unrelated_interface_preferences() {+ use egui_kittest::{Harness, kittest::Queryable};+ let obj = json!({"showTooltips": true}).as_object().unwrap().clone();+ let mut h =+ Harness::new_ui_state(|ui, obj: &mut Map<String, Value>| section_fields(ui, "interface", obj, &[], crate::i18n::Lang::from_pref("en")), obj);+ h.run_steps(4);+ assert!(h.query_by_label("Applies at next launch.").is_none());+ h.get_by_label("Show tooltips").click();+ h.run_steps(4);+ assert_eq!(h.state()["showTooltips"], false);+ assert!(h.query_by_label("Applies at next launch.").is_none());+ }+#[test]fn preferences_confirm_after_apply_commits_later_edits() {let (mut app, _) = app_with_store();diff --git a/docs/ui-design.md b/docs/ui-design.mdindex bf934f3e8..dfd48c490 100644--- a/docs/ui-design.md+++ b/docs/ui-design.md@@ -88,6 +88,9 @@ Preferences has **Apply**, **OK** and **Cancel**. Apply saves the edited sectiondialog open; it is disabled when the values match the saved preferences. OK saves and closes.Cancel discards only changes made since the last successful Apply. A failed Apply leaves thedraft open for correction. Settings marked for the next launch still require a restart.+On Windows and Linux, System Title Bar displays “Applies at next launch.” beneath its checkbox,+including before editing and after Apply. Saving this preference does not restart the app or+change the current window's decorations; the next launch reads the saved choice.## High DPI and 4K displays