Skip to content

Commit

Permalink
Update tray menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Sep 10, 2023
1 parent 53d55da commit 5dcec1d
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct Payload {
fn make_tray() -> SystemTray {
let menu = SystemTrayMenu::new()
.add_item(CustomMenuItem::new("toggle".to_string(), "Hide Authme"))
.add_item(CustomMenuItem::new("settings".to_string(), "Settings"))
.add_item(CustomMenuItem::new("exit".to_string(), "Exit Authme"));
return SystemTray::new().with_menu(menu);
}
Expand Down Expand Up @@ -47,30 +46,16 @@ fn handle_tray_event(app: &AppHandle, event: SystemTrayEvent) {
};

if let SystemTrayEvent::LeftClick { position, size, .. } = event {
toggle_window(app.clone())
if cfg!(target_os = "windows") {
toggle_window(app.clone())
}
}

if let SystemTrayEvent::MenuItemClick { id, .. } = event {
if id.as_str() == "exit" {
std::process::exit(0);
}

if id.as_str() == "settings" {
let window = app.get_window("main").unwrap();
let window_visible = window.is_visible().unwrap();

if window_visible {
window.hide().unwrap();
} else {
window.show().unwrap();
window.unminimize().unwrap();
window.set_focus().unwrap();
}

app.emit_all("openSettings", Payload { event: true })
.unwrap()
}

if id.as_str() == "toggle" {
toggle_window(app.clone())
}
Expand Down

0 comments on commit 5dcec1d

Please sign in to comment.