Skip to content

Commit

Permalink
feat: show tray icon variants in different status (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
w568w authored May 28, 2023
1 parent fb653ff commit ef5adab
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
26 changes: 24 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ parking_lot = "0.12.0"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11", features = ["json","rustls-tls"] }
tauri = { version = "1.1.1", features = ["global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
tauri = { version = "1.1.1", features = ["global-shortcut-all", "icon-png", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
tauri-runtime-wry = { version = "0.12" }
window-vibrancy = { version = "0.3.0" }
window-shadows = { version = "0.2.0" }
Expand Down
Binary file added src-tauri/icons/tray-icon-activated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src-tauri/src/core/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ impl Tray {
let system_proxy = verge.enable_system_proxy.as_ref().unwrap_or(&false);
let tun_mode = verge.enable_tun_mode.as_ref().unwrap_or(&false);

let indication_icon = if *system_proxy {
include_bytes!("../../icons/tray-icon-activated.png").to_vec()
} else {
include_bytes!("../../icons/tray-icon.png").to_vec()
};

tray.set_icon(tauri::Icon::Raw(indication_icon))?;

let _ = tray.get_item("system_proxy").set_selected(*system_proxy);
let _ = tray.get_item("tun_mode").set_selected(*tun_mode);

Expand Down

0 comments on commit ef5adab

Please sign in to comment.