From 02814ba5463703c1936ffc8fdb4516d24060c3c3 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Sat, 12 Jan 2019 00:20:02 +0530 Subject: [PATCH] macOS: Add About dialog --- .../WireGuard/Base.lproj/Localizable.strings | 6 ++++++ WireGuard/WireGuard/UI/macOS/StatusMenu.swift | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings index cf73bf3..ab42116 100644 --- a/WireGuard/WireGuard/Base.lproj/Localizable.strings +++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings @@ -232,6 +232,7 @@ "macMenuAddEmptyTunnel" = "Add empty tunnel..."; "macMenuExportLog" = "Export log to file..."; "macMenuExportTunnels" = "Export tunnels to zip..."; +"macMenuAbout" = "About WireGuard"; "macMenuQuit" = "Quit"; // Mac manage tunnels window @@ -292,3 +293,8 @@ "macAlertInfoUnrecognizedPeerKey" = "Valid keys are: 'PublicKey', 'PresharedKey', 'AllowedIPs', 'Endpoint' and 'PersistentKeepalive'"; "macAlertMultipleEntriesForKey (%@)" = "There should be only one entry per section for key '%@'"; + +// Mac about dialog + +"macAppVersion (%@)" = "App version: %@"; +"macGoBackendVersion (%@)" = "Go backend version: %@"; diff --git a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift index 3a22d25..78e71ba 100644 --- a/WireGuard/WireGuard/UI/macOS/StatusMenu.swift +++ b/WireGuard/WireGuard/UI/macOS/StatusMenu.swift @@ -123,6 +123,9 @@ class StatusMenu: NSMenu { } 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: "") quitItem.target = NSApp addItem(quitItem) @@ -148,6 +151,21 @@ class StatusMenu: NSMenu { manageTunnelsWindow.makeKeyAndOrderFront(self) 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 {