Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<String>>,
Expand Down Expand Up @@ -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, &registry);
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion src/settings_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
}
}
}
}
Expand Down