Skip to content

Commit

Permalink
feat(collectibles): add basic window menu items (#3847)
Browse files Browse the repository at this point in the history
Description
---

- Adds Copy, Cut, Paste, SelectAll, Undo, Redo and Quit to menu items
- Command + ? keys are now working on Mac
- Upgraded Tauri lib to 1.0.0.rc.2

Motivation and Context
---
These are basic and expected features for desktop apps.

Not able to set the mac default menu title, seems that is not currently possible (Ref tauri-apps/tauri#2398)

How Has This Been Tested?
---
Manually
  • Loading branch information
sdbondi committed Feb 18, 2022
1 parent d907849 commit c8ebe5b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 26 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions applications/tari_collectibles/src-tauri/Cargo.toml
Expand Up @@ -24,23 +24,23 @@ tari_key_manager = { path = "../../../base_layer/key_manager" }
tari_mmr = { path = "../../../base_layer/mmr"}
tari_utilities = "*"
tari_dan_common_types = { path = "../../../dan_layer/common_types"}
log = { version = "0.4.8", features = ["std"] }

blake2 = "^0.9.0"
futures = "0.3.17"
rand = "0.8"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tonic = "0.6.2"
tauri = { version = "1.0.0-beta.8", features = ["api-all"] }
diesel = { version = "1.4.8", features = ["sqlite"] }
diesel_migrations = "1.4.0"
thiserror = "1.0.30"
uuid = { version = "0.8.2", features = ["serde"] }
futures = "0.3.17"
log = { version = "0.4.8", features = ["std"] }
prost = "0.9"
prost-types = "0.9"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
structopt = "0.3.25"
tauri = { version = "1.0.0-rc.2", features = ["api-all"] }
thiserror = "1.0.30"
tokio = { version = "1.11", features = ["signal"] }
tonic = "0.6.2"
uuid = { version = "0.8.2", features = ["serde"] }

[features]
default = [ "custom-protocol" ]
Expand Down
28 changes: 26 additions & 2 deletions applications/tari_collectibles/src-tauri/src/main.rs
Expand Up @@ -4,6 +4,7 @@
)]

use std::error::Error;
use tauri::{Menu, MenuItem, Submenu};

use tari_app_utilities::initialization::init_configuration;
use tari_common::configuration::bootstrap::ApplicationType;
Expand Down Expand Up @@ -33,7 +34,8 @@ fn main() -> Result<(), Box<dyn Error>> {
config.collectibles_config.unwrap_or_default(),
);

let result = tauri::Builder::default()
tauri::Builder::default()
.menu(build_menu())
.manage(state)
.invoke_handler(tauri::generate_handler![
commands::create_db,
Expand All @@ -60,5 +62,27 @@ fn main() -> Result<(), Box<dyn Error>> {
])
.run(tauri::generate_context!())?;

Ok(result)
Ok(())
}

fn build_menu() -> Menu {
Menu::new()
.add_submenu(Submenu::new(
"Tari Collectibles",
Menu::new()
.add_native_item(MenuItem::Hide)
.add_native_item(MenuItem::Quit),
))
.add_submenu(Submenu::new(
"Edit",
Menu::new()
.add_native_item(MenuItem::Copy)
.add_native_item(MenuItem::Cut)
.add_native_item(MenuItem::Paste)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Undo)
.add_native_item(MenuItem::Redo)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::SelectAll),
))
}
4 changes: 2 additions & 2 deletions applications/tari_collectibles/src-tauri/tauri.conf.json
@@ -1,6 +1,6 @@
{
"package": {
"productName": "tari_collectibles",
"productName": "Tari Collectibles",
"version": "0.1.0"
},
"build": {
Expand Down Expand Up @@ -53,7 +53,7 @@
},
"windows": [
{
"title": "tari_collectibles",
"title": "Tari Collectibles",
"width": 1524,
"height": 800,
"resizable": true,
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_collectibles/web-app/package.json
Expand Up @@ -7,7 +7,7 @@
"@emotion/styled": "^11.3.0",
"@mui/icons-material": "^5.0.3",
"@mui/material": "^5.0.3",
"@tauri-apps/api": "^1.0.0-beta.8",
"@tauri-apps/api": "^1.0.0-rc.1",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
Expand Down

0 comments on commit c8ebe5b

Please sign in to comment.