Skip to content

Commit c0ae13a

Browse files
committed
fix: show startup errors in UI, query registry status live
1 parent b176a26 commit c0ae13a

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/ui/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub struct SettingsApp {
5858
pub current_tab: Tab,
5959
pub update_status: Option<String>,
6060
pub startup_registered: bool,
61+
pub startup_error: Option<String>,
6162
/// Set to true by any tab that modifies config; triggers a save at end of frame.
6263
pub dirty: bool,
6364
}
@@ -73,6 +74,7 @@ impl SettingsApp {
7374
current_tab: Tab::Hotkeys,
7475
update_status: None,
7576
startup_registered,
77+
startup_error: None,
7678
dirty: false,
7779
}
7880
}

src/ui/startup_tab.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ impl SettingsApp {
1515
{
1616
self.dirty = true;
1717
}
18-
ui.label("Places a launcher in your Windows Startup folder.");
1918

2019
ui.add_space(8.0);
2120
ui.separator();
2221

23-
let registered = self.startup_registered;
22+
// Query the registry directly so the status is always accurate.
23+
let registered = crate::startup::is_registered();
24+
self.startup_registered = registered;
25+
2426
ui.label(if registered {
2527
"Status: Registered in startup."
2628
} else {
@@ -30,20 +32,25 @@ impl SettingsApp {
3032
ui.add_space(4.0);
3133
ui.horizontal(|ui| {
3234
if ui.button("Register Now").clicked() {
35+
self.startup_error = None;
3336
let exe = crate::win_ops::current_exe_path();
34-
if let Err(e) = crate::startup::register(&exe, 0) {
35-
eprintln!("Startup register error: {e}");
36-
} else {
37-
self.startup_registered = true;
37+
match crate::startup::register(&exe, 0) {
38+
Ok(()) => self.startup_registered = true,
39+
Err(e) => self.startup_error = Some(format!("Register failed: {e}")),
3840
}
3941
}
4042
if ui.button("Unregister").clicked() {
41-
if let Err(e) = crate::startup::unregister() {
42-
eprintln!("Startup unregister error: {e}");
43-
} else {
44-
self.startup_registered = false;
43+
self.startup_error = None;
44+
match crate::startup::unregister() {
45+
Ok(()) => self.startup_registered = false,
46+
Err(e) => self.startup_error = Some(format!("Unregister failed: {e}")),
4547
}
4648
}
4749
});
50+
51+
if let Some(ref err) = self.startup_error {
52+
ui.add_space(4.0);
53+
ui.colored_label(egui::Color32::RED, err);
54+
}
4855
}
4956
}

0 commit comments

Comments
 (0)