]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
macOS: Present errors as a sheet when applicable
authorRoopesh Chander <roop@roopc.net>
Sat, 5 Jan 2019 08:46:28 +0000 (14:16 +0530)
committerRoopesh Chander <roop@roopc.net>
Mon, 14 Jan 2019 09:22:32 +0000 (14:52 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/UI/macOS/ErrorPresenter.swift

index c83a339c82f62224dede4639b7896c12dd62ce51..69ea731d2b2a93f8269e3b5e77a03a8e115f9d91 100644 (file)
@@ -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?()
+        }
     }
 }