Merge branch 'reorganize-menu'
This commit is contained in:
commit
5e1997e856
|
@ -10,7 +10,7 @@
|
||||||
<scene sceneID="5Pm-Xi-FR8">
|
<scene sceneID="5Pm-Xi-FR8">
|
||||||
<objects>
|
<objects>
|
||||||
<windowController storyboardIdentifier="OrganizerWindowController" id="qvz-MB-haa" sceneMemberID="viewController">
|
<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"/>
|
<windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
|
<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 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 {
|
internal enum Support {
|
||||||
/// Support
|
/// Support
|
||||||
internal static let title = L10n.tr("App", "menu.support.title")
|
internal static let title = L10n.tr("App", "menu.support.title")
|
||||||
|
|
|
@ -37,11 +37,7 @@ class WindowManager: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult func showOrganizer() -> NSWindowController? {
|
@discardableResult func showOrganizer() -> NSWindowController? {
|
||||||
organizer = presentWindowController(
|
organizer = presentWindowController(StoryboardScene.Main.organizerWindowController, existing: organizer)
|
||||||
StoryboardScene.Main.organizerWindowController,
|
|
||||||
existing: organizer,
|
|
||||||
title: L10n.App.Organizer.title(GroupConstants.App.name)
|
|
||||||
)
|
|
||||||
return organizer
|
return organizer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +57,10 @@ class WindowManager: NSObject {
|
||||||
|
|
||||||
// MARK: Helpers
|
// 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?
|
var wc: NSWindowController?
|
||||||
if existing == nil {
|
if existing == nil {
|
||||||
wc = wcScene.instantiate()
|
wc = wcScene.instantiate()
|
||||||
wc?.window?.title = title
|
|
||||||
wc?.window?.delegate = self
|
wc?.window?.delegate = self
|
||||||
wc?.window?.center()
|
wc?.window?.center()
|
||||||
wc?.showWindow(nil)
|
wc?.showWindow(nil)
|
||||||
|
|
|
@ -27,9 +27,8 @@ import Cocoa
|
||||||
|
|
||||||
class MainMenu: NSObject {
|
class MainMenu: NSObject {
|
||||||
@IBAction private func showPreferences(_ sender: Any?) {
|
@IBAction private func showPreferences(_ sender: Any?) {
|
||||||
guard let vc = NSApp.mainWindow?.contentViewController else {
|
let organizer = WindowManager.shared.showOrganizer()
|
||||||
return
|
let preferences = StoryboardScene.Preferences.initialScene.instantiate()
|
||||||
}
|
organizer?.contentViewController?.presentAsModalWindow(preferences)
|
||||||
vc.presentAsModalWindow(StoryboardScene.Preferences.initialScene.instantiate())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-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>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="MainMenu" customModule="Passepartout" customModuleProvider="target"/>
|
<customObject id="-2" userLabel="File's Owner" customClass="MainMenu" customModule="Passepartout" customModuleProvider="target"/>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<menu key="submenu" title="NewApplication" systemMenu="apple" id="uQy-DD-JDr">
|
<menu key="submenu" title="NewApplication" systemMenu="apple" id="uQy-DD-JDr">
|
||||||
<items>
|
<items>
|
||||||
<menuItem title="About NewApplication" id="5kV-Vb-QxS">
|
<menuItem title="About Passepartout" id="5kV-Vb-QxS">
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
||||||
|
@ -673,6 +673,7 @@
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
</items>
|
</items>
|
||||||
|
<point key="canvasLocation" x="-13" y="120"/>
|
||||||
</menu>
|
</menu>
|
||||||
</objects>
|
</objects>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -109,22 +109,15 @@ class StatusMenu: NSObject {
|
||||||
private func rebuild() {
|
private func rebuild() {
|
||||||
menu.removeAllItems()
|
menu.removeAllItems()
|
||||||
|
|
||||||
// main windows
|
// main actions
|
||||||
|
|
||||||
let itemAbout = NSMenuItem(title: L10n.Core.Organizer.Cells.About.caption(GroupConstants.App.name), action: #selector(showAbout), keyEquivalent: "")
|
let itemShow = NSMenuItem(title: L10n.App.Menu.Show.title, action: #selector(showOrganizer), keyEquivalent: "")
|
||||||
let itemOrganizer = NSMenuItem(title: L10n.App.Menu.Organizer.title.asContinuation, action: #selector(showOrganizer), keyEquivalent: "o")
|
|
||||||
let itemPreferences = NSMenuItem(title: L10n.App.Menu.Preferences.title.asContinuation, action: #selector(showPreferences), 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: "")
|
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!)
|
menu.addItem(itemSwitchProfile!)
|
||||||
reloadProfiles()
|
reloadProfiles()
|
||||||
menu.addItem(.separator())
|
menu.addItem(.separator())
|
||||||
|
@ -135,7 +128,7 @@ class StatusMenu: NSObject {
|
||||||
menu.addItem(itemProfileName!)
|
menu.addItem(itemProfileName!)
|
||||||
setActiveProfile(service.activeProfile)
|
setActiveProfile(service.activeProfile)
|
||||||
menu.addItem(.separator())
|
menu.addItem(.separator())
|
||||||
|
|
||||||
// support
|
// support
|
||||||
|
|
||||||
let menuSupport = NSMenu()
|
let menuSupport = NSMenu()
|
||||||
|
@ -167,10 +160,13 @@ class StatusMenu: NSObject {
|
||||||
menu.addItem(itemSupport)
|
menu.addItem(itemSupport)
|
||||||
menu.addItem(.separator())
|
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")
|
let itemQuit = NSMenuItem(title: L10n.App.Menu.Quit.title(GroupConstants.App.name), action: #selector(quit), keyEquivalent: "q")
|
||||||
|
itemAbout.target = self
|
||||||
itemQuit.target = self
|
itemQuit.target = self
|
||||||
|
menu.addItem(itemAbout)
|
||||||
menu.addItem(itemQuit)
|
menu.addItem(itemQuit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,8 +305,8 @@ class StatusMenu: NSObject {
|
||||||
for category in infrastructure.categories {
|
for category in infrastructure.categories {
|
||||||
let title = category.name.isEmpty ? L10n.Core.Global.Values.default : category.name.capitalized
|
let title = category.name.isEmpty ? L10n.Core.Global.Values.default : category.name.capitalized
|
||||||
let submenu = NSMenu()
|
let submenu = NSMenu()
|
||||||
let item = NSMenuItem(title: title, action: nil, keyEquivalent: "")
|
let itemCategory = NSMenuItem(title: title, action: nil, keyEquivalent: "")
|
||||||
item.indentationLevel = 1
|
itemCategory.indentationLevel = 1
|
||||||
|
|
||||||
for group in category.groups.sorted() {
|
for group in category.groups.sorted() {
|
||||||
let title = group.localizedCountry
|
let title = group.localizedCountry
|
||||||
|
@ -332,6 +328,7 @@ class StatusMenu: NSObject {
|
||||||
submenuGroup.addItem(item)
|
submenuGroup.addItem(item)
|
||||||
|
|
||||||
if pool.id == providerProfile.poolId {
|
if pool.id == providerProfile.poolId {
|
||||||
|
itemCategory.state = .on
|
||||||
itemGroup.state = .on
|
itemGroup.state = .on
|
||||||
item.state = .on
|
item.state = .on
|
||||||
}
|
}
|
||||||
|
@ -343,10 +340,10 @@ class StatusMenu: NSObject {
|
||||||
|
|
||||||
submenu.addItem(itemGroup)
|
submenu.addItem(itemGroup)
|
||||||
}
|
}
|
||||||
menu.setSubmenu(submenu, for: item)
|
menu.setSubmenu(submenu, for: itemCategory)
|
||||||
menu.insertItem(item, at: i)
|
menu.insertItem(itemCategory, at: i)
|
||||||
i += 1
|
i += 1
|
||||||
itemsProfile.append(item)
|
itemsProfile.append(itemCategory)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -388,7 +385,7 @@ class StatusMenu: NSObject {
|
||||||
let preferences = StoryboardScene.Preferences.initialScene.instantiate()
|
let preferences = StoryboardScene.Preferences.initialScene.instantiate()
|
||||||
organizer?.contentViewController?.presentAsModalWindow(preferences)
|
organizer?.contentViewController?.presentAsModalWindow(preferences)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func switchActiveProfile(_ sender: Any?) {
|
@objc private func switchActiveProfile(_ sender: Any?) {
|
||||||
guard let item = sender as? NSMenuItem else {
|
guard let item = sender as? NSMenuItem else {
|
||||||
return
|
return
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
"trusted.ethernet.title" = "Trust wired connections";
|
"trusted.ethernet.title" = "Trust wired connections";
|
||||||
"trusted.ethernet.description" = "Check to trust any wired cable connection.";
|
"trusted.ethernet.description" = "Check to trust any wired cable connection.";
|
||||||
|
|
||||||
|
"menu.show.title" = "Show";
|
||||||
"menu.switch_profile.title" = "Active profile";
|
"menu.switch_profile.title" = "Active profile";
|
||||||
"menu.active_profile.title.none" = "No active profile";
|
"menu.active_profile.title.none" = "No active profile";
|
||||||
"menu.active_profile.items.customize.title" = "Customize...";
|
"menu.active_profile.items.customize.title" = "Customize...";
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
"trusted.ethernet.title" = "Connessioni cablate sicure";
|
"trusted.ethernet.title" = "Connessioni cablate sicure";
|
||||||
"trusted.ethernet.description" = "Seleziona per considerare sicura qualsiasi rete cablata.";
|
"trusted.ethernet.description" = "Seleziona per considerare sicura qualsiasi rete cablata.";
|
||||||
|
|
||||||
|
"menu.show.title" = "Mostra";
|
||||||
"menu.switch_profile.title" = "Profilo attivo";
|
"menu.switch_profile.title" = "Profilo attivo";
|
||||||
"menu.active_profile.title.none" = "Nessun profilo attivo";
|
"menu.active_profile.title.none" = "Nessun profilo attivo";
|
||||||
"menu.active_profile.items.customize.title" = "Personalizza...";
|
"menu.active_profile.items.customize.title" = "Personalizza...";
|
||||||
|
|
Loading…
Reference in New Issue