fix: moved WKWebView initialization to the moment when it should be displayed, which prevents the initialization of the web view on app start and silences some system logs

This commit is contained in:
Serhiy Mytrovtsiy
2025-12-25 19:26:04 +01:00
parent 26d21e9010
commit ab7dffdf3a
4 changed files with 14 additions and 9 deletions

View File

@@ -1603,24 +1603,29 @@ public class PreferencesSwitch: NSStackView {
}
public class HelpHUD: NSPanel {
private let text: String
public init(_ text: String, origin: CGPoint = CGPoint(x: 0, y: 0), size: CGSize = CGSize(width: 420, height: 300)) {
self.text = text
super.init(
contentRect: NSRect(origin: origin, size: size),
styleMask: [.hudWindow, .titled, .closable],
styleMask: [.hudWindow, .utilityWindow, .titled, .closable],
backing: .buffered, defer: false
)
self.isFloatingPanel = true
self.isMovableByWindowBackground = true
self.level = .floating
self.title = "Help"
let webView = WKWebView()
webView.setValue(false, forKey: "drawsBackground")
webView.loadHTMLString("<html><body style='color: #ffffff;margin: 10px;'>\(text)</body></html>", baseURL: nil)
self.contentView = webView
}
public func show() {
if self.contentView as? WKWebView == nil {
let webView = WKWebView()
webView.setValue(false, forKey: "drawsBackground")
webView.loadHTMLString("<html><body style='color: #ffffff;margin: 10px;'>\(self.text)</body></html>", baseURL: nil)
self.contentView = webView
}
self.makeKeyAndOrderFront(self)
self.center()
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2610"
LastUpgradeVersion = "2620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2610"
LastUpgradeVersion = "2620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2610"
LastUpgradeVersion = "2620"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction