|
@@ -64,6 +64,7 @@ pub struct SystemTray {
|
|
icon_as_template_set: bool,
|
|
icon_as_template_set: bool,
|
|
#[cfg(target_os = "macos")]
|
|
#[cfg(target_os = "macos")]
|
|
title: Option<String>,
|
|
title: Option<String>,
|
|
|
|
+ tooltip: Option<String>,
|
|
}
|
|
}
|
|
|
|
|
|
impl fmt::Debug for SystemTray {
|
|
impl fmt::Debug for SystemTray {
|
|
@@ -98,6 +99,7 @@ impl Default for SystemTray {
|
|
menu_on_left_click_set: false,
|
|
menu_on_left_click_set: false,
|
|
#[cfg(target_os = "macos")]
|
|
#[cfg(target_os = "macos")]
|
|
title: None,
|
|
title: None,
|
|
|
|
+ tooltip: None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -257,6 +259,29 @@ impl SystemTray {
|
|
self
|
|
self
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// Sets the tray icon tooltip.
|
|
|
|
+ ///
|
|
|
|
+ /// ## Platform-specific:
|
|
|
|
+ ///
|
|
|
|
+ /// - **Linux:** Unsupported
|
|
|
|
+ ///
|
|
|
|
+ /// # Examples
|
|
|
|
+ ///
|
|
|
|
+ /// ```
|
|
|
|
+ /// use tauri::SystemTray;
|
|
|
|
+ ///
|
|
|
|
+ /// tauri::Builder::default()
|
|
|
|
+ /// .setup(|app| {
|
|
|
|
+ /// let tray_handle = SystemTray::new().with_tooltip("My App").build(app)?;
|
|
|
|
+ /// Ok(())
|
|
|
|
+ /// });
|
|
|
|
+ /// ```
|
|
|
|
+ #[must_use]
|
|
|
|
+ pub fn with_tooltip(mut self, tooltip: &str) -> Self {
|
|
|
|
+ self.tooltip = Some(tooltip.to_owned());
|
|
|
|
+ self
|
|
|
|
+ }
|
|
|
|
+
|
|
/// Sets the event listener for this system tray.
|
|
/// Sets the event listener for this system tray.
|
|
///
|
|
///
|
|
/// # Examples
|
|
/// # Examples
|
|
@@ -414,6 +439,10 @@ impl SystemTray {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if let Some(tooltip) = self.tooltip {
|
|
|
|
+ runtime_tray = runtime_tray.with_tooltip(&tooltip);
|
|
|
|
+ }
|
|
|
|
+
|
|
let id = runtime_tray.id;
|
|
let id = runtime_tray.id;
|
|
let tray_handler = match manager.runtime() {
|
|
let tray_handler = match manager.runtime() {
|
|
RuntimeOrDispatch::Runtime(r) => r.system_tray(runtime_tray),
|
|
RuntimeOrDispatch::Runtime(r) => r.system_tray(runtime_tray),
|
|
@@ -610,6 +639,15 @@ impl<R: Runtime> SystemTrayHandle<R> {
|
|
self.inner.set_title(title).map_err(Into::into)
|
|
self.inner.set_title(title).map_err(Into::into)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// Set the tooltip for this tray icon.
|
|
|
|
+ ///
|
|
|
|
+ /// ## Platform-specific:
|
|
|
|
+ ///
|
|
|
|
+ /// - **Linux:** Unsupported
|
|
|
|
+ pub fn set_tooltip(&self, tooltip: &str) -> crate::Result<()> {
|
|
|
|
+ self.inner.set_tooltip(tooltip).map_err(Into::into)
|
|
|
|
+ }
|
|
|
|
+
|
|
/// Destroys this system tray.
|
|
/// Destroys this system tray.
|
|
pub fn destroy(&self) -> crate::Result<()> {
|
|
pub fn destroy(&self) -> crate::Result<()> {
|
|
self.inner.destroy().map_err(Into::into)
|
|
self.inner.destroy().map_err(Into::into)
|