"macMenuHideApp" = "Hide WireGuard";
"macMenuHideOtherApps" = "Hide Others";
"macMenuShowAllApps" = "Show All";
-"macMenuQuitManagingTunnels" = "Quit Tunnel Manager";
"macMenuFile" = "File";
"macMenuCloseWindow" = "Close Window";
// Mac alert
+"macConfirmAndQuitAlertMessage" = "Do you want to close the tunnels manager or quit WireGuard entirely?";
+"macConfirmAndQuitAlertInfo" = "If you close the tunnels manager, WireGuard will continue to be available from the menu bar icon.";
+"macConfirmAndQuitInfoWithActiveTunnel (%@)" = "If you close the tunnels manager, WireGuard will continue to be available from the menu bar icon.\n\nNote that if you quit WireGuard entirely the currently active tunnel ('%@') will still remain active until you deactivate it from this application or through the Network panel in System Preferences.";
+"macConfirmAndQuitAlertQuitWireGuard" = "Quit WireGuard";
+"macConfirmAndQuitAlertCloseWindow" = "Close Tunnels Manager";
+
"macAppExitingWithActiveTunnelMessage" = "WireGuard is exiting with an active tunnel";
"macAppExitingWithActiveTunnelInfo" = "The tunnel will remain active after exiting. You may disable it by reopening this application or through the Network panel in System Preferences.";
"macPrivacyNoticeMessage" = "Privacy notice: be sure you trust this configuration file";
return false
}
+ @objc func confirmAndQuit() {
+ let alert = NSAlert()
+ alert.messageText = tr("macConfirmAndQuitAlertMessage")
+ if let currentTunnel = tunnelsTracker?.currentTunnel, currentTunnel.status == .active || currentTunnel.status == .activating {
+ alert.informativeText = tr(format: "macConfirmAndQuitInfoWithActiveTunnel (%@)", currentTunnel.name)
+ } else {
+ alert.informativeText = tr("macConfirmAndQuitAlertInfo")
+ }
+ alert.addButton(withTitle: tr("macConfirmAndQuitAlertCloseWindow"))
+ alert.addButton(withTitle: tr("macConfirmAndQuitAlertQuitWireGuard"))
+
+ NSApp.activate(ignoringOtherApps: true)
+ if let manageWindow = manageTunnelsWindowObject {
+ manageWindow.orderFront(self)
+ alert.beginSheetModal(for: manageWindow) { response in
+ switch response {
+ case .alertFirstButtonReturn:
+ manageWindow.close()
+ case .alertSecondButtonReturn:
+ NSApp.terminate(nil)
+ default:
+ break
+ }
+ }
+ }
+ }
+
@objc func quit() {
if let manageWindow = manageTunnelsWindowObject, manageWindow.attachedSheet != nil {
NSApp.activate(ignoringOtherApps: true)
menu.addItem(NSMenuItem.separator())
- menu.addItem(withTitle: tr("macMenuQuitManagingTunnels"),
- action: #selector(NSWindow.performClose(_:)), keyEquivalent: "q")
+ menu.addItem(withTitle: tr("macMenuQuit"),
+ action: #selector(AppDelegate.confirmAndQuit), keyEquivalent: "q")
return menu
}