Skip to content

Commit

Permalink
AboutWindow adjustments
Browse files Browse the repository at this point in the history
Allow opening links in default browser
Close window on Esc
Add rounded corners
  • Loading branch information
nevack authored and kode54 committed Jun 22, 2022
1 parent 632ba36 commit 3a6e41c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions Window/AboutWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Cocoa
import WebKit

class AboutWindowController: NSWindowController {
class AboutWindowController: NSWindowController, WKNavigationDelegate {

@IBOutlet weak var appName: NSTextField!
@IBOutlet weak var appVersion: NSTextField!
Expand All @@ -30,6 +30,8 @@ class AboutWindowController: NSWindowController {

creditsView.setValue(false, forKey: "drawsBackground")

vfxView.wantsLayer = true
vfxView.layer?.cornerRadius = 4

// fill up labels

Expand All @@ -38,7 +40,7 @@ class AboutWindowController: NSWindowController {
let shortVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let fullVersionString = Bundle.main.object(forInfoDictionaryKey: "GitVersion") as! String

appVersion.stringValue = String.localizedStringWithFormat( NSLocalizedString("Version %@ (%@)", comment: "Version string"), shortVersionString, fullVersionString);
appVersion.stringValue = String.localizedStringWithFormat(NSLocalizedString("Version %@ (%@)", comment: "Version string"), shortVersionString, fullVersionString);

appCopyright.stringValue = Bundle.main.object(forInfoDictionaryKey: "NSHumanReadableCopyright") as! String

Expand All @@ -48,7 +50,22 @@ class AboutWindowController: NSWindowController {
creditsView.loadHTMLString(String(data: data, encoding: .utf8) ?? "Could not load credits.", baseURL: nil)

}

creditsView.navigationDelegate = self

}

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == .linkActivated,
let url = navigationAction.request.url {
NSWorkspace.shared.open(url)
decisionHandler(.cancel)
return
}
decisionHandler(.allow)
}

@objc func cancel(_ sender: Any?) {
close()
}
}

0 comments on commit 3a6e41c

Please sign in to comment.