diff --git a/Passepartout/App/macOS/Base.lproj/Main.storyboard b/Passepartout/App/macOS/Base.lproj/Main.storyboard index f1eddc16..9b6ff5b6 100644 --- a/Passepartout/App/macOS/Base.lproj/Main.storyboard +++ b/Passepartout/App/macOS/Base.lproj/Main.storyboard @@ -10,7 +10,7 @@ - + diff --git a/Passepartout/App/macOS/Global/SwiftGen+Strings.swift b/Passepartout/App/macOS/Global/SwiftGen+Strings.swift index ec70a78b..ceeeb93d 100644 --- a/Passepartout/App/macOS/Global/SwiftGen+Strings.swift +++ b/Passepartout/App/macOS/Global/SwiftGen+Strings.swift @@ -70,6 +70,10 @@ internal enum L10n { internal static let confirm = L10n.tr("App", "menu.quit.messages.confirm") } } + internal enum Show { + /// Show + internal static let title = L10n.tr("App", "menu.show.title") + } internal enum Support { /// Support internal static let title = L10n.tr("App", "menu.support.title") diff --git a/Passepartout/App/macOS/Global/WindowManager.swift b/Passepartout/App/macOS/Global/WindowManager.swift index cbc2c793..66082794 100644 --- a/Passepartout/App/macOS/Global/WindowManager.swift +++ b/Passepartout/App/macOS/Global/WindowManager.swift @@ -37,11 +37,7 @@ class WindowManager: NSObject { } @discardableResult func showOrganizer() -> NSWindowController? { - organizer = presentWindowController( - StoryboardScene.Main.organizerWindowController, - existing: organizer, - title: L10n.App.Organizer.title(GroupConstants.App.name) - ) + organizer = presentWindowController(StoryboardScene.Main.organizerWindowController, existing: organizer) return organizer } @@ -61,11 +57,10 @@ class WindowManager: NSObject { // MARK: Helpers - private func presentWindowController(_ wcScene: SceneType, existing: NSWindowController?, title: String) -> NSWindowController? { + private func presentWindowController(_ wcScene: SceneType, existing: NSWindowController?) -> NSWindowController? { var wc: NSWindowController? if existing == nil { wc = wcScene.instantiate() - wc?.window?.title = title wc?.window?.delegate = self wc?.window?.center() wc?.showWindow(nil) diff --git a/Passepartout/App/macOS/Menu/MainMenu.swift b/Passepartout/App/macOS/Menu/MainMenu.swift index 99702030..4993669c 100644 --- a/Passepartout/App/macOS/Menu/MainMenu.swift +++ b/Passepartout/App/macOS/Menu/MainMenu.swift @@ -27,9 +27,8 @@ import Cocoa class MainMenu: NSObject { @IBAction private func showPreferences(_ sender: Any?) { - guard let vc = NSApp.mainWindow?.contentViewController else { - return - } - vc.presentAsModalWindow(StoryboardScene.Preferences.initialScene.instantiate()) + let organizer = WindowManager.shared.showOrganizer() + let preferences = StoryboardScene.Preferences.initialScene.instantiate() + organizer?.contentViewController?.presentAsModalWindow(preferences) } } diff --git a/Passepartout/App/macOS/Menu/MainMenu.xib b/Passepartout/App/macOS/Menu/MainMenu.xib index ac8696b0..2fcc4300 100644 --- a/Passepartout/App/macOS/Menu/MainMenu.xib +++ b/Passepartout/App/macOS/Menu/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -15,7 +15,7 @@ - + @@ -673,6 +673,7 @@ + diff --git a/Passepartout/App/macOS/Menu/StatusMenu.swift b/Passepartout/App/macOS/Menu/StatusMenu.swift index b1455676..60010a1f 100644 --- a/Passepartout/App/macOS/Menu/StatusMenu.swift +++ b/Passepartout/App/macOS/Menu/StatusMenu.swift @@ -109,22 +109,15 @@ class StatusMenu: NSObject { private func rebuild() { menu.removeAllItems() - // main windows - - let itemAbout = NSMenuItem(title: L10n.Core.Organizer.Cells.About.caption(GroupConstants.App.name), action: #selector(showAbout), keyEquivalent: "") - let itemOrganizer = NSMenuItem(title: L10n.App.Menu.Organizer.title.asContinuation, action: #selector(showOrganizer), keyEquivalent: "o") + // main actions + + let itemShow = NSMenuItem(title: L10n.App.Menu.Show.title, action: #selector(showOrganizer), keyEquivalent: "") let itemPreferences = NSMenuItem(title: L10n.App.Menu.Preferences.title.asContinuation, action: #selector(showPreferences), keyEquivalent: ",") - itemAbout.target = self - itemOrganizer.target = self - itemPreferences.target = self - menu.addItem(itemAbout) - menu.addItem(itemOrganizer) - menu.addItem(itemPreferences) - menu.addItem(.separator()) - - // profiles - itemSwitchProfile = NSMenuItem(title: L10n.App.Menu.SwitchProfile.title, action: nil, keyEquivalent: "") + itemShow.target = self + itemPreferences.target = self + menu.addItem(itemShow) + menu.addItem(itemPreferences) menu.addItem(itemSwitchProfile!) reloadProfiles() menu.addItem(.separator()) @@ -135,7 +128,7 @@ class StatusMenu: NSObject { menu.addItem(itemProfileName!) setActiveProfile(service.activeProfile) menu.addItem(.separator()) - + // support let menuSupport = NSMenu() @@ -167,10 +160,13 @@ class StatusMenu: NSObject { menu.addItem(itemSupport) menu.addItem(.separator()) - // quit + // secondary + let itemAbout = NSMenuItem(title: L10n.Core.Organizer.Cells.About.caption(GroupConstants.App.name), action: #selector(showAbout), keyEquivalent: "") let itemQuit = NSMenuItem(title: L10n.App.Menu.Quit.title(GroupConstants.App.name), action: #selector(quit), keyEquivalent: "q") + itemAbout.target = self itemQuit.target = self + menu.addItem(itemAbout) menu.addItem(itemQuit) } @@ -309,8 +305,8 @@ class StatusMenu: NSObject { for category in infrastructure.categories { let title = category.name.isEmpty ? L10n.Core.Global.Values.default : category.name.capitalized let submenu = NSMenu() - let item = NSMenuItem(title: title, action: nil, keyEquivalent: "") - item.indentationLevel = 1 + let itemCategory = NSMenuItem(title: title, action: nil, keyEquivalent: "") + itemCategory.indentationLevel = 1 for group in category.groups.sorted() { let title = group.localizedCountry @@ -332,6 +328,7 @@ class StatusMenu: NSObject { submenuGroup.addItem(item) if pool.id == providerProfile.poolId { + itemCategory.state = .on itemGroup.state = .on item.state = .on } @@ -343,10 +340,10 @@ class StatusMenu: NSObject { submenu.addItem(itemGroup) } - menu.setSubmenu(submenu, for: item) - menu.insertItem(item, at: i) + menu.setSubmenu(submenu, for: itemCategory) + menu.insertItem(itemCategory, at: i) i += 1 - itemsProfile.append(item) + itemsProfile.append(itemCategory) } } else { @@ -388,7 +385,7 @@ class StatusMenu: NSObject { let preferences = StoryboardScene.Preferences.initialScene.instantiate() organizer?.contentViewController?.presentAsModalWindow(preferences) } - + @objc private func switchActiveProfile(_ sender: Any?) { guard let item = sender as? NSMenuItem else { return diff --git a/Passepartout/App/macOS/en.lproj/App.strings b/Passepartout/App/macOS/en.lproj/App.strings index 48492316..2319a7e5 100644 --- a/Passepartout/App/macOS/en.lproj/App.strings +++ b/Passepartout/App/macOS/en.lproj/App.strings @@ -59,6 +59,7 @@ "trusted.ethernet.title" = "Trust wired connections"; "trusted.ethernet.description" = "Check to trust any wired cable connection."; +"menu.show.title" = "Show"; "menu.switch_profile.title" = "Active profile"; "menu.active_profile.title.none" = "No active profile"; "menu.active_profile.items.customize.title" = "Customize..."; diff --git a/Passepartout/App/macOS/it.lproj/App.strings b/Passepartout/App/macOS/it.lproj/App.strings index ae3f8af6..6e12a2d9 100644 --- a/Passepartout/App/macOS/it.lproj/App.strings +++ b/Passepartout/App/macOS/it.lproj/App.strings @@ -59,6 +59,7 @@ "trusted.ethernet.title" = "Connessioni cablate sicure"; "trusted.ethernet.description" = "Seleziona per considerare sicura qualsiasi rete cablata."; +"menu.show.title" = "Mostra"; "menu.switch_profile.title" = "Profilo attivo"; "menu.active_profile.title.none" = "Nessun profilo attivo"; "menu.active_profile.items.customize.title" = "Personalizza...";