mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
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:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user