Skip to content

Commit

Permalink
Merge pull request #55 from KilleenCode/add-version-to-menu
Browse files Browse the repository at this point in the history
feat: show version in system tray menu
  • Loading branch information
RyKilleen authored Mar 21, 2022
2 parents f481cc8 + 42ed014 commit 3addb00
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brancato",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"dependencies": {
"@algolia/autocomplete-js": "^1.5.3",
Expand Down
2 changes: 1 addition & 1 deletion 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
@@ -1,6 +1,6 @@
[package]
name = "brancato"
version = "0.5.0"
version = "0.6.0"
description = "A tool for stage-managing your life"
authors = ["Ryan Killeen"]
license = ""
Expand Down
39 changes: 23 additions & 16 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,14 @@ fn main() {
let app_config = app_config::get_or_create_app_config();
let user_config = user_config::get_user_config(app_config.user_config_path.clone());

let quit = CustomMenuItem::new("quit", "Quit");
let hide = CustomMenuItem::new("hide", "Hide");
let settings = CustomMenuItem::new("settings", "Settings");
let tray_menu = SystemTrayMenu::new()
.add_item(quit)
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(settings)
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(hide);
let system_tray = SystemTray::new().with_menu(tray_menu);
let app = tauri::Builder::default()
.system_tray(system_tray)
.system_tray(SystemTray::new())
.on_system_tray_event(|app, event| match event {
SystemTrayEvent::LeftClick {
position: _,
size: _,
..
} => {
// tauri::window::WindowBuilder::new(
// app,
// "settings",
// tauri::WindowUrl::App("/settings".into()),
// );
focus_window(app, "settings".to_owned()).ok();
}

Expand Down Expand Up @@ -219,6 +204,28 @@ fn main() {
set_shortcut,
set_user_config_path
])
.setup(|app_handle| {
let tray_menu = SystemTrayMenu::new()
.add_item(CustomMenuItem::new("quit", "Quit"))
.add_item(CustomMenuItem::new("settings", "Settings"))
.add_item(CustomMenuItem::new("hide", "Hide"))
.add_native_item(SystemTrayMenuItem::Separator)
.add_item(
CustomMenuItem::new(
"version",
format!(
"Version {version}",
version = &app_handle.package_info().version
),
)
.disabled(),
);
app_handle
.tray_handle()
.set_menu(tray_menu)
.expect("Set the tray damn it");
Ok(())
})
.build(tauri::generate_context!())
.expect("error while running tauri application");

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "brancato",
"version": "0.5.0"
"version": "0.6.0"
},
"build": {
"distDir": "../build",
Expand Down

0 comments on commit 3addb00

Please sign in to comment.