mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:17:02 +00:00
Merge 1d2b0fcb0f into 7d01aa0417
This commit is contained in:
commit
db2a294780
@ -0,0 +1,6 @@
|
||||
---
|
||||
'tauri': 'patch:enhance'
|
||||
'@tauri-apps/api': 'patch:enhance'
|
||||
---
|
||||
|
||||
Add Bring All to Front predefined menu item type
|
||||
@ -642,6 +642,31 @@ macro_rules! shared_menu_builder {
|
||||
.push(PredefinedMenuItem::services(self.manager, Some(text.as_ref())).map(|i| i.kind()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Add Bring All to Front menu item to the menu.
|
||||
///
|
||||
/// ## Platform-specific:
|
||||
///
|
||||
/// - **Windows / Linux:** Unsupported.
|
||||
pub fn bring_all_to_front(mut self) -> Self {
|
||||
self
|
||||
.items
|
||||
.push(PredefinedMenuItem::bring_all_to_front(self.manager, None).map(|i| i.kind()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Add Bring All to Front menu item with specified text to the menu.
|
||||
///
|
||||
/// ## Platform-specific:
|
||||
///
|
||||
/// - **Windows / Linux:** Unsupported.
|
||||
pub fn bring_all_to_front_with_text<S: AsRef<str>>(mut self, text: S) -> Self {
|
||||
self.items.push(
|
||||
PredefinedMenuItem::bring_all_to_front(self.manager, Some(text.as_ref()))
|
||||
.map(|i| i.kind()),
|
||||
);
|
||||
self
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -91,6 +91,7 @@ enum Predefined {
|
||||
Quit,
|
||||
About(Option<AboutMetadata>),
|
||||
Services,
|
||||
BringAllToFront,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@ -303,6 +304,9 @@ impl PredefinedMenuItemPayload {
|
||||
PredefinedMenuItem::about(webview, self.text.as_deref(), metadata)
|
||||
}
|
||||
Predefined::Services => PredefinedMenuItem::services(webview, self.text.as_deref()),
|
||||
Predefined::BringAllToFront => {
|
||||
PredefinedMenuItem::bring_all_to_front(webview, self.text.as_deref())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,6 +384,29 @@ impl<R: Runtime> PredefinedMenuItem<R> {
|
||||
Ok(Self(Arc::new(item)))
|
||||
}
|
||||
|
||||
/// Bring All to Front menu item
|
||||
///
|
||||
/// ## Platform-specific:
|
||||
///
|
||||
/// - **Windows / Linux:** Unsupported.
|
||||
pub fn bring_all_to_front<M: Manager<R>>(manager: &M, text: Option<&str>) -> crate::Result<Self> {
|
||||
let handle = manager.app_handle();
|
||||
let app_handle = handle.clone();
|
||||
|
||||
let text = text.map(|t| t.to_owned());
|
||||
|
||||
let item = run_main_thread!(handle, || {
|
||||
let item = muda::PredefinedMenuItem::bring_all_to_front(text.as_deref());
|
||||
PredefinedMenuItemInner {
|
||||
id: item.id().clone(),
|
||||
inner: Some(item),
|
||||
app_handle,
|
||||
}
|
||||
})?;
|
||||
|
||||
Ok(Self(Arc::new(item)))
|
||||
}
|
||||
|
||||
/// Returns a unique identifier associated with this menu item.
|
||||
pub fn id(&self) -> &MenuId {
|
||||
&self.0.id
|
||||
|
||||
@ -32,7 +32,8 @@
|
||||
'ShowAll',
|
||||
'CloseWindow',
|
||||
'Quit',
|
||||
'Services'
|
||||
'Services',
|
||||
'BringAllToFront'
|
||||
]
|
||||
|
||||
function onKindChange(event) {
|
||||
|
||||
@ -102,6 +102,7 @@ export interface PredefinedMenuItemOptions {
|
||||
| 'CloseWindow'
|
||||
| 'Quit'
|
||||
| 'Services'
|
||||
| 'BringAllToFront'
|
||||
| {
|
||||
About: AboutMetadata | null
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user