feat: added Text widget to the Network module with a description of the value that could be used in it (#1868)

This commit is contained in:
Serhiy Mytrovtsiy
2024-09-13 19:08:40 +02:00
parent 6fc3b58779
commit f053555492
5 changed files with 189 additions and 7 deletions

View File

@@ -13,6 +13,7 @@
import Cocoa
import ServiceManagement
import UserNotifications
import WebKit
public struct LaunchAtLogin {
private static let id = "\(Bundle.main.bundleIdentifier!).LaunchAtLogin"
@@ -1571,3 +1572,27 @@ public class PreferencesSwitch: NSStackView {
self.with.isEnabled = controlState(sender)
}
}
public class HelpHUD: NSPanel {
public init(_ text: String, origin: CGPoint = CGPoint(x: 0, y: 0), size: CGSize = CGSize(width: 420, height: 300)) {
super.init(
contentRect: NSRect(origin: origin, size: size),
styleMask: [.hudWindow, .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() {
self.makeKeyAndOrderFront(self)
self.center()
}
}