macOS: Tunnels list: Double-click to activate / deactivate
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
439fb6bbac
commit
121d223229
|
@ -78,6 +78,8 @@ class TunnelsListTableViewController: NSViewController {
|
||||||
tableView.dataSource = self
|
tableView.dataSource = self
|
||||||
tableView.delegate = self
|
tableView.delegate = self
|
||||||
|
|
||||||
|
tableView.doubleAction = #selector(listDoubleClicked(sender:))
|
||||||
|
|
||||||
let isSelected = selectTunnelInOperation() || selectTunnel(at: 0)
|
let isSelected = selectTunnelInOperation() || selectTunnel(at: 0)
|
||||||
if !isSelected {
|
if !isSelected {
|
||||||
delegate?.tunnelsListEmpty()
|
delegate?.tunnelsListEmpty()
|
||||||
|
@ -242,6 +244,17 @@ class TunnelsListTableViewController: NSViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func listDoubleClicked(sender: AnyObject) {
|
||||||
|
let tunnelIndex = tableView.clickedRow
|
||||||
|
guard tunnelIndex >= 0 && tunnelIndex < tunnelsManager.numberOfTunnels() else { return }
|
||||||
|
let tunnel = tunnelsManager.tunnel(at: tunnelIndex)
|
||||||
|
if tunnel.status == .inactive {
|
||||||
|
tunnelsManager.startActivation(of: tunnel)
|
||||||
|
} else if tunnel.status == .active {
|
||||||
|
tunnelsManager.startDeactivation(of: tunnel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
private func selectTunnel(at index: Int) -> Bool {
|
private func selectTunnel(at index: Int) -> Bool {
|
||||||
if index < tunnelsManager.numberOfTunnels() {
|
if index < tunnelsManager.numberOfTunnels() {
|
||||||
|
|
Loading…
Reference in New Issue