From 250d8a2c04733133d0b0c5ce596b6e5f8f671746 Mon Sep 17 00:00:00 2001 From: Tobias Breckle <25928171+tbreckle@users.noreply.github.com> Date: Mon, 12 Oct 2026 17:44:07 +0200 Subject: [PATCH] Preferences open over the Home page (#313) The Home page returned from the frame before the Preferences window was drawn, so the gear, Ctrl+, and Home's Preferences / Keyboard Shortcuts links only set the flag and the dialog appeared after leaving Home. Draw the Preferences window on Home too. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/home.rs | 24 ++++++++++++++++++++++++ crates/ui-egui/src/lib.rs | 2 ++ 2 files changed, 26 insertions(+) diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rs index 045c548d..4bbe6f4b 100644 --- a/crates/ui-egui/src/home.rs +++ b/crates/ui-egui/src/home.rs @@ -605,4 +605,28 @@ mod tests { assert_eq!(app.session.doc.name, "Sample Plate"); assert!(!app.session.is_dirty()); } + + /// The gear, Ctrl+, and Home's own links open Preferences over Home, not after leaving it. + #[test] + fn preferences_and_shortcuts_open_over_home() { + let mut h = crate::scenario::Harness::new(); + let rev = h.app.session.revision; + h.app.home.show(rev); + h.frames(2); + assert!(h.app.home.open); + let gear = crate::scenario::handle_at("titlebar:preferences").unwrap(); + h.call("ui.click", serde_json::json!({"x": gear.x, "y": gear.y})); + assert!(h.app.prefs_window.open && h.app.home.open); + let shown = |h: &crate::scenario::Harness| { + h.ctx.memory(|m| m.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new("sc_prefs")))) + }; + assert!(shown(&h), "the Preferences window must be drawn on Home"); + h.call("ui.prefs", serde_json::json!({"button": "cancel"})); + assert!(!shown(&h)); + + // Home › Keyboard Shortcuts opens the same window at its page. + h.app.keymap.open = true; + h.frames(2); + assert!(shown(&h) && h.app.prefs_window.section == crate::prefs::PAGE_SHORTCUTS && h.app.home.open); + } } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index d2a43804..3caa1c5c 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -978,6 +978,8 @@ impl SolveApp { if self.home.open { home::show(self, ui); if self.home.open { + // Preferences and Keyboard Shortcuts open from Home too (its links, the gear, Ctrl+,). + prefs::show(self, ui.ctx()); return; } }