@@ -60,6 +60,13 @@ pub struct MenuTranslations {
6060 pub about : String ,
6161 pub settings : String ,
6262 pub quit : String ,
63+ // App menu items (macOS only: Hide, Hide Others, Show All)
64+ #[ serde( default ) ]
65+ pub hide : String ,
66+ #[ serde( default ) ]
67+ pub hide_others : String ,
68+ #[ serde( default ) ]
69+ pub show_all : String ,
6370 // File menu items
6471 pub import_tracks : String ,
6572 pub add_release : String ,
@@ -202,7 +209,7 @@ pub fn build_menu(app: &AppHandle<Wry>) -> Result<Menu<Wry>, tauri::Error> {
202209
203210fn build_app_menu ( app : & AppHandle < Wry > ) -> Result < Submenu < Wry > , tauri:: Error > {
204211 let app_name = get_app_name ( ) ;
205- SubmenuBuilder :: with_id ( app, ids:: APP_MENU , & app_name)
212+ let mut builder = SubmenuBuilder :: with_id ( app, ids:: APP_MENU , & app_name)
206213 . item ( & MenuItem :: with_id (
207214 app,
208215 ids:: ABOUT ,
@@ -218,7 +225,21 @@ fn build_app_menu(app: &AppHandle<Wry>) -> Result<Submenu<Wry>, tauri::Error> {
218225 true ,
219226 Some ( "CmdOrCtrl+," ) ,
220227 ) ?)
221- . separator ( )
228+ . separator ( ) ;
229+
230+ #[ cfg( target_os = "macos" ) ]
231+ {
232+ builder = builder
233+ . item ( & PredefinedMenuItem :: hide (
234+ app,
235+ Some ( & format ! ( "Hide {app_name}" ) ) ,
236+ ) ?)
237+ . item ( & PredefinedMenuItem :: hide_others ( app, Some ( "Hide Others" ) ) ?)
238+ . item ( & PredefinedMenuItem :: show_all ( app, Some ( "Show All" ) ) ?)
239+ . separator ( ) ;
240+ }
241+
242+ builder
222243 . item ( & MenuItem :: with_id (
223244 app,
224245 ids:: QUIT ,
@@ -708,6 +729,32 @@ pub fn update_menu_translations(
708729 update_item_text ( & menu, ids:: SETTINGS , & translations. settings ) ?;
709730 update_item_text ( & menu, ids:: QUIT , & translations. quit ) ?;
710731
732+ // Update App menu PredefinedMenuItems (Hide, Hide Others, Show All) — macOS only
733+ #[ cfg( target_os = "macos" ) ]
734+ if let Some ( MenuItemKind :: Submenu ( app_submenu) ) = menu. get ( ids:: APP_MENU ) {
735+ let app_texts: [ & str ; 3 ] = [
736+ & translations. hide ,
737+ & translations. hide_others ,
738+ & translations. show_all ,
739+ ] ;
740+ let predefined: Vec < _ > = app_submenu
741+ . items ( ) ?
742+ . into_iter ( )
743+ . filter_map ( |item| match item {
744+ MenuItemKind :: Predefined ( p) => {
745+ if p. text ( ) . unwrap_or_default ( ) . is_empty ( ) {
746+ return None ;
747+ }
748+ Some ( p)
749+ }
750+ _ => None ,
751+ } )
752+ . collect ( ) ;
753+ for ( item, text) in predefined. iter ( ) . zip ( app_texts. iter ( ) ) {
754+ item. set_text ( * text) ?;
755+ }
756+ }
757+
711758 // Update File menu items
712759 update_item_text ( & menu, ids:: IMPORT_TRACKS , & translations. import_tracks ) ?;
713760 update_item_text ( & menu, ids:: ADD_RELEASE , & translations. add_release ) ?;
0 commit comments