From f5fefd3feb35a15744de8173eb68354484f93f6e Mon Sep 17 00:00:00 2001 From: multiplex55 <6619098+multiplex55@users.noreply.github.com> Date: Thu, 8 Jan 2026 19:20:10 -0500 Subject: [PATCH] Harden settings dialog activation --- src/gui/mod.rs | 27 +++++++++++++++++++++++++-- src/plugins/settings.rs | 2 +- src/settings_editor.rs | 11 ++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index e0b57c3..3f324ee 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -526,6 +526,29 @@ impl LauncherApp { self.error = Some(msg); self.error_time = Some(Instant::now()); } + + fn open_settings_dialog(&mut self) { + if !self.show_settings { + match Settings::load(&self.settings_path) { + Ok(settings) => { + self.settings_editor = SettingsEditor::new_with_plugins(&settings); + } + Err(e) => { + let msg = format!("Failed to load settings: {e}"); + self.set_error(msg.clone()); + if self.enable_toasts { + self.add_toast(Toast { + text: msg.into(), + kind: ToastKind::Error, + options: ToastOptions::default() + .duration_in_seconds(self.toast_duration as f64), + }); + } + } + } + } + self.show_settings = true; + } pub fn update_paths( &mut self, plugin_dirs: Option>, @@ -1554,7 +1577,7 @@ impl LauncherApp { } else if a.action == "tempfile:dialog" { self.tempfile_dialog.open(); } else if a.action == "settings:dialog" { - self.show_settings = true; + self.open_settings_dialog(); } else if a.action == "dashboard:settings" { let registry = self.dashboard.registry().clone(); self.dashboard_editor.open(&self.dashboard_path, ®istry); @@ -2252,7 +2275,7 @@ impl LauncherApp { Panel::CpuListDialog => self.cpu_list_dialog.open = true, Panel::ToastLogDialog => self.toast_log_dialog.open = true, Panel::Editor => self.show_editor = true, - Panel::Settings => self.show_settings = true, + Panel::Settings => self.open_settings_dialog(), Panel::Plugins => self.show_plugins = true, } if !self.panel_stack.contains(&panel) { diff --git a/src/plugins/settings.rs b/src/plugins/settings.rs index 11c7eef..6770be6 100644 --- a/src/plugins/settings.rs +++ b/src/plugins/settings.rs @@ -47,7 +47,7 @@ impl Plugin for SettingsPlugin { Action { label: "settings".into(), desc: "Settings".into(), - action: "query:settings".into(), + action: "settings:dialog".into(), args: None, }, Action { diff --git a/src/settings_editor.rs b/src/settings_editor.rs index 3bd7440..91b2835 100644 --- a/src/settings_editor.rs +++ b/src/settings_editor.rs @@ -812,7 +812,16 @@ impl SettingsEditor { } } Err(e) => { - app.set_error(format!("Failed to read settings: {e}")) + let msg = format!("Failed to read settings: {e}"); + app.set_error(msg.clone()); + if app.enable_toasts { + app.add_toast(Toast { + text: msg.into(), + kind: ToastKind::Error, + options: ToastOptions::default() + .duration_in_seconds(app.toast_duration as f64), + }); + } } } }