94 lines
3.0 KiB
Swift
94 lines
3.0 KiB
Swift
//
|
|
// ApplicationMenu.swift
|
|
// PrivadoVPN
|
|
//
|
|
// Created by Juraldinio on 12/2/20.
|
|
// Copyright © 2020 Privado LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import AppKit
|
|
|
|
final class ApplicationMenu: NSMenu {
|
|
|
|
init() {
|
|
super.init(title: "")
|
|
self.setup()
|
|
}
|
|
|
|
required init(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
// MARK: - Private
|
|
|
|
private func setup() {
|
|
|
|
let appMenu = NSMenu()
|
|
/*appMenu.addItem(withTitle: NSLocalizedString("tray.menu.account", comment: ""), action: #selector(self.handleMenuPreferenceAccounts), keyEquivalent: "")
|
|
appMenu.addItem(withTitle: NSLocalizedString("tray.menu.options", comment: ""), action: #selector(self.handleMenuPreferenceOptions), keyEquivalent: "")
|
|
appMenu.addItem(withTitle: NSLocalizedString("tray.menu.protocols", comment: ""), action: #selector(self.handleMenuPreferenceProtocols), keyEquivalent: "")
|
|
appMenu.addItem(withTitle: NSLocalizedString("tray.menu.logs", comment: ""), action: #selector(self.handleMenuPreferenceLogs), keyEquivalent: "")
|
|
appMenu.addItem(NSMenuItem.separator())*/
|
|
// appMenu.addItem(withTitle: NSLocalizedString("main.menu.hide", comment: ""), action: #selector(self.handleMenuHide), keyEquivalent: "h")
|
|
appMenu.addItem(withTitle: NSLocalizedString("main.menu.update", comment: ""), action: #selector(self.handleMenuUpdate), keyEquivalent: "")
|
|
appMenu.addItem(NSMenuItem.separator())
|
|
/*#if INTERNAL
|
|
appMenu.addItem(withTitle: "Package Filter", action: #selector(self.handlePF), keyEquivalent: "")
|
|
appMenu.addItem(NSMenuItem.separator())
|
|
#endif*/
|
|
appMenu.addItem(withTitle: NSLocalizedString("main.menu.quit", comment: ""), action: #selector(self.handleMenuQuit), keyEquivalent: "q")
|
|
|
|
appMenu.items.forEach { $0.target = self }
|
|
|
|
let mainAppMenuItem = NSMenuItem(title: "Application", action: nil, keyEquivalent: "")
|
|
mainAppMenuItem.submenu = appMenu
|
|
|
|
self.addItem(mainAppMenuItem)
|
|
}
|
|
|
|
// MARK: - Handlers
|
|
|
|
/*@objc
|
|
private func handleMenuPreferenceAccounts() {
|
|
openApplicationRoute(Route.preference(tab: .account))
|
|
}
|
|
|
|
@objc
|
|
private func handleMenuPreferenceOptions() {
|
|
openApplicationRoute(Route.preference(tab: .options))
|
|
}
|
|
|
|
@objc
|
|
private func handleMenuPreferenceProtocols() {
|
|
openApplicationRoute(Route.preference(tab: .protocol))
|
|
}
|
|
|
|
@objc
|
|
private func handleMenuPreferenceLogs() {
|
|
openApplicationRoute(Route.preference(tab: .logs))
|
|
}*/
|
|
|
|
@objc
|
|
private func handleMenuUpdate() {
|
|
openApplicationRoute(.update)
|
|
}
|
|
|
|
/*#if INTERNAL
|
|
@objc
|
|
private func handlePF() {
|
|
PackageFilterModule.build()
|
|
}
|
|
#endif*/
|
|
|
|
@objc
|
|
private func handleMenuHide() {
|
|
openApplicationRoute(.hide)
|
|
}
|
|
|
|
@objc
|
|
private func handleMenuQuit() {
|
|
openApplicationRoute(.quit)
|
|
}
|
|
}
|