aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-17 01:44:40 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-17 01:44:50 +0530
commitc477d24d67c359c4a5edc34b9b23232649dcfb6f (patch)
tree9cfdb6dedfaf91e8f8b9812b6cc92572272015a0
parentmacOS: Tunnel edit: Rename action handling methods (diff)
downloadwireguard-apple-c477d24d67c359c4a5edc34b9b23232649dcfb6f.tar.xz
wireguard-apple-c477d24d67c359c4a5edc34b9b23232649dcfb6f.zip
macOS: Manage tunnels: Keyboard shortcuts
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift27
-rw-r--r--WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift8
2 files changed, 35 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
index 1b1dc731..d8e9cfe0 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/ManageTunnelsRootViewController.swift
@@ -7,6 +7,7 @@ class ManageTunnelsRootViewController: NSViewController {
let tunnelsManager: TunnelsManager
var tunnelsListVC: TunnelsListTableViewController?
+ var tunnelDetailVC: TunnelDetailTableViewController?
let tunnelDetailContainerView = NSView()
var tunnelDetailContentVC: NSViewController?
@@ -80,10 +81,36 @@ extension ManageTunnelsRootViewController: TunnelsListTableViewControllerDelegat
func tunnelSelected(tunnel: TunnelContainer) {
let tunnelDetailVC = TunnelDetailTableViewController(tunnelsManager: tunnelsManager, tunnel: tunnel)
setTunnelDetailContentVC(tunnelDetailVC)
+ self.tunnelDetailVC = tunnelDetailVC
}
func tunnelsListEmpty() {
let noTunnelsVC = NoTunnelsDetailViewController(tunnelsManager: tunnelsManager)
setTunnelDetailContentVC(noTunnelsVC)
+ self.tunnelDetailVC = nil
+ }
+}
+
+extension ManageTunnelsRootViewController {
+ override func keyDown(with event: NSEvent) {
+ let modifierFlags = event.modifierFlags.rawValue & NSEvent.ModifierFlags.deviceIndependentFlagsMask.rawValue
+ let isCmdOrCmdShiftDown = (modifierFlags == NSEvent.ModifierFlags.command.rawValue || modifierFlags == NSEvent.ModifierFlags.command.rawValue | NSEvent.ModifierFlags.shift.rawValue)
+
+ if event.specialKey == .delete {
+ tunnelsListVC?.handleRemoveTunnelAction()
+ } else if isCmdOrCmdShiftDown {
+ switch event.charactersIgnoringModifiers {
+ case "n":
+ tunnelsListVC?.handleAddEmptyTunnelAction()
+ case "i":
+ tunnelsListVC?.handleImportTunnelAction()
+ case "t":
+ tunnelDetailVC?.handleToggleActiveStatusAction()
+ case "e":
+ tunnelDetailVC?.handleEditTunnelAction()
+ default:
+ break
+ }
+ }
}
}
diff --git a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
index 2c7f25ad..adb32aa4 100644
--- a/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/macOS/ViewController/TunnelDetailTableViewController.swift
@@ -201,6 +201,14 @@ class TunnelDetailTableViewController: NSViewController {
presentAsSheet(tunnelEditVC)
}
+ @objc func handleToggleActiveStatusAction() {
+ if tunnel.status == .inactive {
+ tunnelsManager.startActivation(of: tunnel)
+ } else if tunnel.status == .active {
+ tunnelsManager.startDeactivation(of: tunnel)
+ }
+ }
+
@objc func statusCheckboxToggled(sender: AnyObject?) {
guard let statusCheckbox = sender as? NSButton else { return }
if statusCheckbox.state == .on {