3e6188ed13
* feat(nym-connect): add android support * fix(nym-connect): android linker issue with sqlite3 get rid of sqlite refs as temporary workaround * fix(nc): fix index.ts (post rebase) * feat(nc-android): wip * hack in config removal of read/write * fix(nc-android): remove more fs read/write calls * wip * chore: remove debug comments * Register gateway * client-core: remove unneeded changes * build: revert crate name change * refactor(socks5-client): add feature mobile * refactor(gateway-client): rename mobile feature * socks5: restore default_root_directory * client-core: further simplifications * get_config_file_location just return error * fix(nc-mobile): fix ui mobile * socks5: minor tweak to default_root_directory * remove unneeded changes * nym-connect build fixes * Use default feature for normal credential storage * rustfmt * rustfmt: nym-connect * restore Cargo.toml * Remove --all-features from workflow * Remove some unused use * Remove two move --all-features from build workflow * Allow unused * Add continue-on-error * another clippy --all-features remove * remove --all-features from clippy nightly * fix(nc-mobile): frontend code errors * feat: restore nc, move mobile under its own dir * fix(nc-android): build * fix(nc-android): lint errors Co-authored-by: Jon Häggblad <jon.haggblad@gmail.com>
63 lines
1.9 KiB
Rust
63 lines
1.9 KiB
Rust
use tauri::{
|
|
AppHandle, CustomMenuItem, Menu, Submenu, SystemTray, SystemTrayEvent, SystemTrayMenu,
|
|
SystemTrayMenuItem, Wry,
|
|
};
|
|
|
|
use crate::window::window_toggle;
|
|
|
|
pub const SHOW_LOG_WINDOW: &str = "show_log_window";
|
|
pub const CLEAR_STORAGE: &str = "clear_storage";
|
|
|
|
pub trait AddDefaultSubmenus {
|
|
fn add_default_app_submenus(self) -> Self;
|
|
}
|
|
|
|
impl AddDefaultSubmenus for Menu {
|
|
fn add_default_app_submenus(self) -> Self {
|
|
let submenu = Submenu::new(
|
|
"Help",
|
|
Menu::new().add_item(CustomMenuItem::new(SHOW_LOG_WINDOW, "Show logs")),
|
|
);
|
|
self.add_submenu(submenu)
|
|
}
|
|
}
|
|
|
|
pub const TRAY_MENU_QUIT: &str = "quit";
|
|
pub const TRAY_MENU_SHOW_HIDE: &str = "show-hide";
|
|
pub const TRAY_MENU_CONNECTION: &str = "connection";
|
|
|
|
pub(crate) fn create_tray_menu() -> SystemTray {
|
|
let quit = CustomMenuItem::new(TRAY_MENU_QUIT, "Quit");
|
|
let hide = CustomMenuItem::new(TRAY_MENU_SHOW_HIDE, "Hide");
|
|
let connection = CustomMenuItem::new(TRAY_MENU_CONNECTION, "Connect");
|
|
let tray_menu = SystemTrayMenu::new()
|
|
.add_item(hide)
|
|
.add_item(connection)
|
|
.add_native_item(SystemTrayMenuItem::Separator)
|
|
.add_item(quit);
|
|
|
|
SystemTray::new().with_menu(tray_menu)
|
|
}
|
|
|
|
pub(crate) fn tray_menu_event_handler(app: &AppHandle<Wry>, event: SystemTrayEvent) {
|
|
match event {
|
|
SystemTrayEvent::LeftClick { position, size, .. } => {
|
|
println!("Event {position:?} {size:?}");
|
|
}
|
|
SystemTrayEvent::MenuItemClick { id, .. } => {
|
|
println!("Event {id}");
|
|
match id.as_str() {
|
|
TRAY_MENU_SHOW_HIDE => {
|
|
window_toggle(app);
|
|
}
|
|
TRAY_MENU_QUIT => {
|
|
// TODO: add disconnecting first
|
|
app.exit(0);
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|