Skip to content

Commit de5cce8

Browse files
kddlbkode54
authored andcommitted
[About Dialog] Switched to WebView for credits
Signed-off-by: Kevin López Brante <kevin@kddlb.cl>
1 parent 05da745 commit de5cce8

3 files changed

Lines changed: 57 additions & 54 deletions

File tree

Window/AboutWindowController.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
//
77

88
import Cocoa
9+
import WebKit
910

1011
class AboutWindowController: NSWindowController {
1112

1213
@IBOutlet weak var appName: NSTextField!
1314
@IBOutlet weak var appVersion: NSTextField!
1415
@IBOutlet weak var appCopyright: NSTextField!
1516

16-
@IBOutlet var creditsView: NSTextView!
17+
@IBOutlet weak var creditsView: WKWebView!
1718

1819
override var windowNibName: NSNib.Name? {
1920
return "AboutWindowController"
@@ -26,12 +27,9 @@ class AboutWindowController: NSWindowController {
2627

2728
self.window?.center()
2829
self.window?.isMovableByWindowBackground = true
29-
30-
vfxView.wantsLayer = true
31-
vfxView.canDrawSubviewsIntoLayer = true
3230

33-
vfxView.layer?.cornerRadius = 10.0
34-
vfxView.layer?.masksToBounds = true
31+
creditsView.setValue(false, forKey: "drawsBackground")
32+
3533

3634
// fill up labels
3735

@@ -47,9 +45,8 @@ class AboutWindowController: NSWindowController {
4745
if let creditsFile = Bundle.main.url(forResource: "Credits", withExtension: "html") {
4846
let data = try! Data(contentsOf: creditsFile)
4947

50-
if let attributedString = try? NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil) {
51-
creditsView.textStorage?.setAttributedString(attributedString)
52-
}
48+
creditsView.loadHTMLString(String(data: data, encoding: .utf8) ?? "Could not load credits.", baseURL: nil)
49+
5350
}
5451

5552
}

Window/AboutWindowController.xib

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<dependencies>
44
<deployment identifier="macosx"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="20037"/>
6+
<plugIn identifier="com.apple.WebKit2IBPlugin" version="20037"/>
67
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
78
</dependencies>
89
<objects>
@@ -11,7 +12,7 @@
1112
<outlet property="appCopyright" destination="ht5-N1-YXd" id="cUK-kB-F2V"/>
1213
<outlet property="appName" destination="Lya-f1-R7S" id="ZVN-sE-MQp"/>
1314
<outlet property="appVersion" destination="7dE-CE-MBv" id="qOe-3F-tMG"/>
14-
<outlet property="creditsView" destination="iz8-0U-jtY" id="uMm-WQ-Fui"/>
15+
<outlet property="creditsView" destination="LZw-Xy-wYl" id="jyQ-Rg-oqx"/>
1516
<outlet property="imageView" destination="aIO-L9-zMj" id="cIl-Ce-onP"/>
1617
<outlet property="vfxView" destination="2nK-dq-1h6" id="ToT-af-ycD"/>
1718
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
@@ -39,39 +40,15 @@
3940
<visualEffectView blendingMode="withinWindow" material="fullScreenUI" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="2nK-dq-1h6">
4041
<rect key="frame" x="387" y="84" width="262" height="230"/>
4142
<subviews>
42-
<scrollView appearanceType="aqua" borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HLG-H1-ARK">
43+
<wkWebView wantsLayer="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LZw-Xy-wYl">
4344
<rect key="frame" x="0.0" y="0.0" width="262" height="230"/>
44-
<clipView key="contentView" drawsBackground="NO" id="VsR-Lq-AhX">
45-
<rect key="frame" x="0.0" y="0.0" width="247" height="230"/>
46-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
47-
<subviews>
48-
<textView editable="NO" verticallyResizable="YES" findStyle="bar" allowsDocumentBackgroundColorChange="YES" spellingCorrection="YES" smartInsertDelete="YES" id="iz8-0U-jtY">
49-
<rect key="frame" x="0.0" y="0.0" width="247" height="230"/>
50-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
51-
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
52-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
53-
<size key="minSize" width="247" height="230"/>
54-
<size key="maxSize" width="247" height="10000000"/>
55-
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
56-
</textView>
57-
</subviews>
58-
</clipView>
59-
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="Jrl-HU-vmJ">
60-
<rect key="frame" x="-100" y="-100" width="225" height="15"/>
61-
<autoresizingMask key="autoresizingMask"/>
62-
</scroller>
63-
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="z2b-Sa-SQ9">
64-
<rect key="frame" x="247" y="0.0" width="15" height="230"/>
65-
<autoresizingMask key="autoresizingMask"/>
66-
</scroller>
67-
</scrollView>
45+
<autoresizingMask key="autoresizingMask"/>
46+
<wkWebViewConfiguration key="configuration" applicationNameForUserAgent="Cog">
47+
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
48+
<wkPreferences key="preferences"/>
49+
</wkWebViewConfiguration>
50+
</wkWebView>
6851
</subviews>
69-
<constraints>
70-
<constraint firstItem="HLG-H1-ARK" firstAttribute="leading" secondItem="2nK-dq-1h6" secondAttribute="leading" id="RIy-GD-jCE"/>
71-
<constraint firstItem="HLG-H1-ARK" firstAttribute="top" secondItem="2nK-dq-1h6" secondAttribute="top" id="Ye7-Xs-CXc"/>
72-
<constraint firstAttribute="trailing" secondItem="HLG-H1-ARK" secondAttribute="trailing" id="tZ8-S3-bky"/>
73-
<constraint firstAttribute="bottom" secondItem="HLG-H1-ARK" secondAttribute="bottom" id="vNr-Wi-0vq"/>
74-
</constraints>
7552
</visualEffectView>
7653
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Lya-f1-R7S">
7754
<rect key="frame" x="385" y="351" width="266" height="31"/>

en.lproj/Credits.html

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1+
<!DOCTYPE html>
12
<html>
2-
<body style="text-align:center;">
3-
Now with 92% more future!
4-
<br><br>
5-
<em>This program has been made possible through contributions from users like you.</em>
6-
<br><br>
7-
All Cog code is copyrighted by me, and is licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GPL</a>. Cog contains bits of other code from third parties that are under their own licenses.
8-
<br><br>
9-
Sample rate converter designed by Aleksey Vaneev of Voxengo.
10-
<br><br>
11-
Thanks to my patrons:
12-
<br>
13-
Alexander Pecheny, Electric Keet, Antti Aro, Fj&ouml;lnir &Aacute;sgeirsson, Giampaolo Bellavite, Louis Martinez V, alga
14-
</body>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>SpoGen web view</title>
7+
<style>
8+
9+
:root {
10+
color-scheme: light dark;
11+
}
12+
13+
html, body {
14+
font: -apple-system-body;
15+
-webkit-text-size-adjust: 100%;
16+
}
17+
18+
div {
19+
text-align: center;
20+
}
21+
22+
a:link {
23+
color: #ffb565;
24+
text-decoration: none;
25+
}
26+
27+
</style>
28+
</head>
29+
<body>
30+
<div>
31+
Now with 92% more future!
32+
<br><br>
33+
<em>This program has been made possible through contributions from users like you.</em>
34+
<br><br>
35+
All Cog code is copyrighted by me, and is licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">GPL</a>. Cog contains bits of other code from third parties that are under their own licenses.
36+
<br><br>
37+
Sample rate converter designed by Aleksey Vaneev of Voxengo.
38+
<br><br>
39+
Thanks to my patrons:
40+
<br>
41+
Alexander Pecheny, Electric Keet, Antti Aro, Fj&ouml;lnir &Aacute;sgeirsson, Giampaolo Bellavite, Louis Martinez V, alga
42+
</div>
43+
</body>
1544
</html>

0 commit comments

Comments
 (0)