Skip to content

Commit eb56cd4

Browse files
Add MacOS hide/show shortcuts
1 parent cd6b80f commit eb56cd4

14 files changed

Lines changed: 90 additions & 2 deletions

File tree

src-tauri/src/menu.rs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

203210
fn 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)?;

src/lib/api/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export interface MenuTranslations {
6363
about: string
6464
settings: string
6565
quit: string
66+
// App menu items (macOS only: Hide, Hide Others, Show All)
67+
hide: string
68+
hideOthers: string
69+
showAll: string
6670
// File menu items
6771
importTracks: string
6872
addRelease: string

src/lib/i18n/locales/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "Ton",
601601
"settingsDiagnostics": "Diagnose",
602602
"quit": "{appName} beenden",
603+
"hide": "{appName} ausblenden",
604+
"hideOthers": "Andere ausblenden",
605+
"showAll": "Alle anzeigen",
603606
"importTracks": "Tracks importieren...",
604607
"addRelease": "Release hinzufügen...",
605608
"refreshMetadata": "Metadaten aktualisieren",

src/lib/i18n/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
"settingsSound": "Sound",
602602
"settingsDiagnostics": "Diagnostics",
603603
"quit": "Quit {appName}",
604+
"hide": "Hide {appName}",
605+
"hideOthers": "Hide Others",
606+
"showAll": "Show All",
604607
"importTracks": "Import Tracks...",
605608
"addRelease": "Add Release...",
606609
"refreshMetadata": "Refresh Metadata",

src/lib/i18n/locales/es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "Sonido",
601601
"settingsDiagnostics": "Diagnósticos",
602602
"quit": "Salir de {appName}",
603+
"hide": "Ocultar {appName}",
604+
"hideOthers": "Ocultar otros",
605+
"showAll": "Mostrar todo",
603606
"importTracks": "Importar pistas...",
604607
"addRelease": "Añadir lanzamiento...",
605608
"refreshMetadata": "Actualizar metadatos",

src/lib/i18n/locales/fr.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "Son",
601601
"settingsDiagnostics": "Diagnostics",
602602
"quit": "Quitter {appName}",
603+
"hide": "Masquer {appName}",
604+
"hideOthers": "Masquer les autres",
605+
"showAll": "Afficher tout",
603606
"importTracks": "Importer des pistes...",
604607
"addRelease": "Ajouter une sortie...",
605608
"refreshMetadata": "Actualiser les métadonnées",

src/lib/i18n/locales/it.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "Suono",
601601
"settingsDiagnostics": "Diagnostica",
602602
"quit": "Esci da {appName}",
603+
"hide": "Nascondi {appName}",
604+
"hideOthers": "Nascondi altri",
605+
"showAll": "Mostra tutto",
603606
"importTracks": "Importa tracce...",
604607
"addRelease": "Aggiungi release...",
605608
"refreshMetadata": "Aggiorna metadati",

src/lib/i18n/locales/ja.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
"settingsSound": "サウンド",
602602
"settingsDiagnostics": "診断",
603603
"quit": "{appName}を終了",
604+
"hide": "{appName}を隠す",
605+
"hideOthers": "その他を隠す",
606+
"showAll": "すべて表示",
604607
"importTracks": "トラックをインポート...",
605608
"addRelease": "リリースを追加...",
606609
"refreshMetadata": "メタデータを更新",

src/lib/i18n/locales/ko.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "사운드",
601601
"settingsDiagnostics": "진단",
602602
"quit": "{appName} 종료",
603+
"hide": "{appName} 숨기기",
604+
"hideOthers": "기타 숨기기",
605+
"showAll": "모두 표시",
603606
"importTracks": "트랙 가져오기...",
604607
"addRelease": "릴리스 추가...",
605608
"refreshMetadata": "메타데이터 새로 고침",

src/lib/i18n/locales/nl.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
"settingsSound": "Geluid",
601601
"settingsDiagnostics": "Diagnostiek",
602602
"quit": "{appName} afsluiten",
603+
"hide": "{appName} verbergen",
604+
"hideOthers": "Anderen verbergen",
605+
"showAll": "Alles weergeven",
603606
"importTracks": "Tracks importeren...",
604607
"addRelease": "Release toevoegen...",
605608
"refreshMetadata": "Metagegevens vernieuwen",

0 commit comments

Comments
 (0)