macOS: Add About dialog
This commit is contained in:
parent
e1d329707a
commit
02814ba546
|
@ -232,6 +232,7 @@
|
||||||
"macMenuAddEmptyTunnel" = "Add empty tunnel...";
|
"macMenuAddEmptyTunnel" = "Add empty tunnel...";
|
||||||
"macMenuExportLog" = "Export log to file...";
|
"macMenuExportLog" = "Export log to file...";
|
||||||
"macMenuExportTunnels" = "Export tunnels to zip...";
|
"macMenuExportTunnels" = "Export tunnels to zip...";
|
||||||
|
"macMenuAbout" = "About WireGuard";
|
||||||
"macMenuQuit" = "Quit";
|
"macMenuQuit" = "Quit";
|
||||||
|
|
||||||
// Mac manage tunnels window
|
// Mac manage tunnels window
|
||||||
|
@ -292,3 +293,8 @@
|
||||||
"macAlertInfoUnrecognizedPeerKey" = "Valid keys are: 'PublicKey', 'PresharedKey', 'AllowedIPs', 'Endpoint' and 'PersistentKeepalive'";
|
"macAlertInfoUnrecognizedPeerKey" = "Valid keys are: 'PublicKey', 'PresharedKey', 'AllowedIPs', 'Endpoint' and 'PersistentKeepalive'";
|
||||||
|
|
||||||
"macAlertMultipleEntriesForKey (%@)" = "There should be only one entry per section for key '%@'";
|
"macAlertMultipleEntriesForKey (%@)" = "There should be only one entry per section for key '%@'";
|
||||||
|
|
||||||
|
// Mac about dialog
|
||||||
|
|
||||||
|
"macAppVersion (%@)" = "App version: %@";
|
||||||
|
"macGoBackendVersion (%@)" = "Go backend version: %@";
|
||||||
|
|
|
@ -123,6 +123,9 @@ class StatusMenu: NSMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addApplicationItems() {
|
func addApplicationItems() {
|
||||||
|
let aboutItem = NSMenuItem(title: tr("macMenuAbout"), action: #selector(aboutClicked), keyEquivalent: "")
|
||||||
|
aboutItem.target = self
|
||||||
|
addItem(aboutItem)
|
||||||
let quitItem = NSMenuItem(title: tr("macMenuQuit"), action: #selector(NSApplication.terminate), keyEquivalent: "")
|
let quitItem = NSMenuItem(title: tr("macMenuQuit"), action: #selector(NSApplication.terminate), keyEquivalent: "")
|
||||||
quitItem.target = NSApp
|
quitItem.target = NSApp
|
||||||
addItem(quitItem)
|
addItem(quitItem)
|
||||||
|
@ -148,6 +151,21 @@ class StatusMenu: NSMenu {
|
||||||
manageTunnelsWindow.makeKeyAndOrderFront(self)
|
manageTunnelsWindow.makeKeyAndOrderFront(self)
|
||||||
ImportPanelPresenter.presentImportPanel(tunnelsManager: tunnelsManager, sourceVC: manageTunnelsRootVC!)
|
ImportPanelPresenter.presentImportPanel(tunnelsManager: tunnelsManager, sourceVC: manageTunnelsRootVC!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func aboutClicked() {
|
||||||
|
var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
|
||||||
|
if let appBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String {
|
||||||
|
appVersion += " (\(appBuild))"
|
||||||
|
}
|
||||||
|
let appVersionString = [
|
||||||
|
tr(format: "macAppVersion (%@)", appVersion),
|
||||||
|
tr(format: "macGoBackendVersion (%@)", WIREGUARD_GO_VERSION)
|
||||||
|
].joined(separator: "\n")
|
||||||
|
NSApp.orderFrontStandardAboutPanel(options: [
|
||||||
|
.applicationVersion: appVersionString,
|
||||||
|
.version: ""
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension StatusMenu {
|
extension StatusMenu {
|
||||||
|
|
Loading…
Reference in New Issue