Merge branch 'reorganize-menu'
This commit is contained in:
commit
5e1997e856
|
@ -10,7 +10,7 @@
|
|||
<scene sceneID="5Pm-Xi-FR8">
|
||||
<objects>
|
||||
<windowController storyboardIdentifier="OrganizerWindowController" id="qvz-MB-haa" sceneMemberID="viewController">
|
||||
<window key="window" title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="iHm-B8-M67">
|
||||
<window key="window" title="Passepartout" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="iHm-B8-M67">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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<NSWindowController>, existing: NSWindowController?, title: String) -> NSWindowController? {
|
||||
private func presentWindowController(_ wcScene: SceneType<NSWindowController>, 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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MainMenu" customModule="Passepartout" customModuleProvider="target"/>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="NewApplication" systemMenu="apple" id="uQy-DD-JDr">
|
||||
<items>
|
||||
<menuItem title="About NewApplication" id="5kV-Vb-QxS">
|
||||
<menuItem title="About Passepartout" id="5kV-Vb-QxS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
||||
|
@ -673,6 +673,7 @@
|
|||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="-13" y="120"/>
|
||||
</menu>
|
||||
</objects>
|
||||
</document>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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...";
|
||||
|
|
|
@ -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...";
|
||||
|
|
Loading…
Reference in New Issue