aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-05 14:16:28 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-14 14:52:32 +0530
commit252d940d34484a9f0580d36ea29e44b9c1738561 (patch)
treed109b799326edf689cc378608c5824b006ce721e /WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift
parentmacOS: Manage tunnels: Remove tunnel (diff)
downloadwireguard-apple-252d940d34484a9f0580d36ea29e44b9c1738561.tar.xz
wireguard-apple-252d940d34484a9f0580d36ea29e44b9c1738561.zip
macOS: Present errors as a sheet when applicable
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift')
-rw-r--r--WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift12
1 files changed, 10 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift b/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift
index c83a339..69ea731 100644
--- a/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift
+++ b/WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift
@@ -9,7 +9,15 @@ class ErrorPresenter: ErrorPresenterProtocol {
alert.messageText = title
alert.informativeText = message
onPresented?()
- alert.runModal()
- onDismissal?()
+ if let sourceVC = sourceVC as? NSViewController {
+ NSApp.activate(ignoringOtherApps: true)
+ sourceVC.view.window!.makeKeyAndOrderFront(nil)
+ alert.beginSheetModal(for: sourceVC.view.window!) { _ in
+ onDismissal?()
+ }
+ } else {
+ alert.runModal()
+ onDismissal?()
+ }
}
}