windows: the app leaves a system proxy set by hand alone; a calmer tray
- The check for a system proxy a killed app left on the local proxy ran on every refresh while the option was off, so a proxy the user pointed at the listener by hand was switched off within two seconds. It now runs once, at the start. The registry sits behind a small trait, and the state machine has tests. - The tray's tooltip and menu are only touched when what they say changes (a menu rebuilt while open would close). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
adcd734479
commit
c0b089dea8
2 files changed
+114
-14
No files matched your search
@@ -17,8 +17,10 @@ struct Shell {
|
||||
model: Entity<Model>,
|
||||
window: Option<WindowHandle<AppView>>,
|
||||
tray: Option<Tray>,
|
||||
/// The icon's colour now, so it is only replaced when that changes.
|
||||
/// The icon's colour and the tooltip now: the tray is only touched when they change (a
|
||||
/// menu rebuilt while open would close).
|
||||
colour: &'static str,
|
||||
tooltip: String,
|
||||
system_proxy: SystemProxy,
|
||||
/// The system proxy's last failure, said once.
|
||||
system_proxy_error: Option<String>,
|
||||
@@ -28,7 +30,7 @@ impl Global for Shell {}
|
||||
|
||||
pub fn start(model: Entity<Model>, open: bool, cx: &mut App) {
|
||||
cx.on_action(open_window).on_action(toggle_proxy).on_action(toggle_dpi).on_action(toggle_telegram).on_action(quit);
|
||||
cx.set_global(Shell { model: model.clone(), window: None, tray: None, colour: "", system_proxy: SystemProxy::default(), system_proxy_error: None });
|
||||
cx.set_global(Shell { model: model.clone(), window: None, tray: None, colour: "", tooltip: String::new(), system_proxy: SystemProxy::default(), system_proxy_error: None });
|
||||
|
||||
let mut builder = Tray::builder().tooltip("Proxy Suite").on_activate(OpenWindow).menu(menu);
|
||||
if let Some(icon) = icon("#6b7280", cx) {
|
||||
@@ -123,8 +125,12 @@ fn refresh(cx: &mut App) {
|
||||
} else {
|
||||
"Proxy Suite — the service is not running".into()
|
||||
};
|
||||
let _ = tray.set_tooltip(Some(tip), cx);
|
||||
let _ = tray.refresh_menu(cx);
|
||||
// The tooltip says what the menu's checks do: the same news.
|
||||
if tip != cx.global::<Shell>().tooltip {
|
||||
cx.global_mut::<Shell>().tooltip = tip.clone();
|
||||
let _ = tray.set_tooltip(Some(tip), cx);
|
||||
let _ = tray.refresh_menu(cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn menu(cx: &mut App) -> Vec<MenuItem> {
|
||||
|
||||
Reference in new issue
Block a user