Skip to content

Commit

Permalink
clippy, fmt, and config option
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 19, 2024
1 parent 6edb84f commit d816040
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/tauri-cli/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,12 @@
"type": "boolean"
},
"menuOnLeftClick": {
"description": "A Boolean value that determines whether the menu should appear when the tray icon receives a left click.\n\n ## Platform-specific:\n\n - **Linux**: Unsupported.",
"default": true,
"deprecated": true,
"type": "boolean"
},
"showMenuOnLeftClick": {
"description": "A Boolean value that determines whether the menu should appear when the tray icon receives a left click.\n\n ## Platform-specific:\n\n - **Linux**: Unsupported.",
"default": true,
"type": "boolean"
Expand Down
6 changes: 6 additions & 0 deletions crates/tauri-schema-generator/schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,12 @@
"type": "boolean"
},
"menuOnLeftClick": {
"description": "A Boolean value that determines whether the menu should appear when the tray icon receives a left click.\n\n ## Platform-specific:\n\n - **Linux**: Unsupported.",
"default": true,
"deprecated": true,
"type": "boolean"
},
"showMenuOnLeftClick": {
"description": "A Boolean value that determines whether the menu should appear when the tray icon receives a left click.\n\n ## Platform-specific:\n\n - **Linux**: Unsupported.",
"default": true,
"type": "boolean"
Expand Down
11 changes: 11 additions & 0 deletions crates/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,15 @@ pub struct TrayIconConfig {
///
/// - **Linux**: Unsupported.
#[serde(default = "default_true", alias = "menu-on-left-click")]
#[deprecated(since = "2.2.0", note = "Use `show_menu_on_left_click` instead.")]
pub menu_on_left_click: bool,
/// A Boolean value that determines whether the menu should appear when the tray icon receives a left click.
///
/// ## Platform-specific:
///
/// - **Linux**: Unsupported.
#[serde(default = "default_true", alias = "show-menu-on-left-click")]
pub show_menu_on_left_click: bool,
/// Title for MacOS tray
pub title: Option<String>,
/// Tray icon tooltip on Windows and macOS
Expand Down Expand Up @@ -3355,7 +3363,9 @@ mod build {
fn to_tokens(&self, tokens: &mut TokenStream) {
let id = opt_str_lit(self.id.as_ref());
let icon_as_template = self.icon_as_template;
#[allow(deprecated)]
let menu_on_left_click = self.menu_on_left_click;
let show_menu_on_left_click = self.show_menu_on_left_click;
let icon_path = path_buf_lit(&self.icon_path);
let title = opt_str_lit(self.title.as_ref());
let tooltip = opt_str_lit(self.tooltip.as_ref());
Expand All @@ -3366,6 +3376,7 @@ mod build {
icon_path,
icon_as_template,
menu_on_left_click,
show_menu_on_left_click,
title,
tooltip
);
Expand Down
4 changes: 3 additions & 1 deletion crates/tauri/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2042,10 +2042,12 @@ tauri::Builder::default()
{
let config = app.config();
if let Some(tray_config) = &config.app.tray_icon {
#[allow(deprecated)]
let mut tray =
TrayIconBuilder::with_id(tray_config.id.clone().unwrap_or_else(|| "main".into()))
.icon_as_template(tray_config.icon_as_template)
.menu_on_left_click(tray_config.menu_on_left_click);
.menu_on_left_click(tray_config.menu_on_left_click)
.show_menu_on_left_click(tray_config.show_menu_on_left_click);
if let Some(icon) = &app.manager.tray.icon {
tray = tray.icon(icon.clone());
}
Expand Down
5 changes: 4 additions & 1 deletion crates/tauri/src/tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ impl<R: Runtime> TrayIconBuilder<R> {
/// ## Platform-specific:
///
/// - **Linux:** Unsupported.
#[deprecated(since = "2.2.0", note = "Use `TrayIconBuiler::show_menu_on_left_click` instead.")]
#[deprecated(
since = "2.2.0",
note = "Use `TrayIconBuiler::show_menu_on_left_click` instead."
)]
pub fn menu_on_left_click(mut self, enable: bool) -> Self {
self.inner = self.inner.with_menu_on_left_click(enable);
self
Expand Down
2 changes: 1 addition & 1 deletion examples/api/src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
.tooltip("Tauri")
.icon(app.default_window_icon().unwrap().clone())
.menu(&menu1)
.menu_on_left_click(false)
.show_menu_on_left_click(false)
.on_menu_event(move |app, event| match event.id.as_ref() {
"quit" => {
app.exit(0);
Expand Down

0 comments on commit d816040

Please sign in to comment.