this repo has no description
1use tauri::{
2 menu::{MenuBuilder, MenuItemBuilder},
3 tray::TrayIconBuilder,
4 AppHandle, Emitter, Manager,
5};
6
7pub fn setup_traymenu(handle: &AppHandle) {
8 // Setup the tray icon and menu buttons
9 let quit = MenuItemBuilder::new("Quit")
10 .id("quit")
11 .build(handle)
12 .unwrap();
13
14 let show = MenuItemBuilder::new("Show Editor")
15 .id("show")
16 .build(handle)
17 .unwrap();
18
19 let tray_menu = MenuBuilder::new(handle)
20 .items(&[&quit, &show])
21 .build()
22 .unwrap();
23
24 TrayIconBuilder::with_id("main")
25 .icon(tauri::image::Image::from_bytes(include_bytes!("../../icons/32x32.png")).unwrap())
26 .menu(&tray_menu)
27 .title("VRCMacros")
28 .tooltip("VRCMacros")
29 .on_menu_event(move |app: &AppHandle, event| match event.id().as_ref() {
30 "quit" => {
31 app.emit("prompt_to_close", ()).unwrap();
32 }
33 "show" => {
34 let window = app.get_webview_window("main").unwrap();
35
36 window.show().unwrap();
37 window.set_focus().unwrap();
38
39 window.emit("show-window", ()).unwrap();
40 }
41 _ => {}
42 })
43 .build(handle)
44 .unwrap();
45}