mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: created PopupWrapper for the popup view
This commit is contained in:
@@ -16,6 +16,11 @@ public protocol Popup_p: NSView {
|
||||
func settings() -> NSView?
|
||||
}
|
||||
|
||||
open class PopupWrapper: NSStackView, Popup_p {
|
||||
open var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
open func settings() -> NSView? { return nil }
|
||||
}
|
||||
|
||||
public class PopupWindow: NSWindow, NSWindowDelegate {
|
||||
private let viewController: PopupViewController = PopupViewController()
|
||||
internal var locked: Bool = false
|
||||
|
||||
@@ -253,7 +253,6 @@ public class Widget {
|
||||
self?.sizeCallback?()
|
||||
if let s = self, let item = s.menuBarItem, let width: CGFloat = self?.item.frame.width, item.length != width {
|
||||
item.length = width
|
||||
debug("widget \(s.type) change width to \(Double(width).rounded(toPlaces: 2))", log: s.log)
|
||||
}
|
||||
}
|
||||
self.item.identifier = NSUserInterfaceItemIdentifier(self.type.rawValue)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSView, Popup_p {
|
||||
internal class Popup: PopupWrapper {
|
||||
private var title: String
|
||||
|
||||
private var grid: NSGridView? = nil
|
||||
@@ -72,8 +72,6 @@ internal class Popup: NSView, Popup_p {
|
||||
Store.shared.string(key: "\(self.title)_timeFormat", defaultValue: "short")
|
||||
}
|
||||
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
public init(_ title: String) {
|
||||
self.title = title
|
||||
|
||||
@@ -346,7 +344,7 @@ internal class Popup: NSView, Popup_p {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
public override func settings() -> NSView? {
|
||||
let view = SettingsContainerView()
|
||||
|
||||
view.addArrangedSubview(toggleSettingRow(
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSStackView, Popup_p {
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
internal class Popup: PopupWrapper {
|
||||
private let emptyView: EmptyView = EmptyView(height: 30, isHidden: false, msg: localizedString("No Bluetooth devices are available"))
|
||||
|
||||
public init() {
|
||||
@@ -61,12 +60,6 @@ internal class Popup: NSStackView, Popup_p {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal class BLEView: NSStackView {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSView, Popup_p {
|
||||
internal class Popup: PopupWrapper {
|
||||
private var title: String
|
||||
|
||||
private var grid: NSGridView? = nil
|
||||
@@ -118,8 +118,6 @@ internal class Popup: NSView, Popup_p {
|
||||
return value
|
||||
}
|
||||
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
private var numberOfProcesses: Int {
|
||||
get {
|
||||
return Store.shared.int(key: "\(self.title)_processes", defaultValue: 8)
|
||||
@@ -487,7 +485,7 @@ internal class Popup: NSView, Popup_p {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
public override func settings() -> NSView? {
|
||||
let view = SettingsContainerView()
|
||||
|
||||
view.addArrangedSubview(selectSettingsRow(
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSStackView, Popup_p {
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
internal class Popup: PopupWrapper {
|
||||
private let emptyView: EmptyView = EmptyView(height: 30, isHidden: false, msg: localizedString("No disks are available"))
|
||||
|
||||
public init() {
|
||||
@@ -73,12 +71,6 @@ internal class Popup: NSStackView, Popup_p {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
internal class DiskView: NSStackView {
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSStackView, Popup_p {
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
internal class Popup: PopupWrapper {
|
||||
public init() {
|
||||
super.init(frame: NSRect(x: 0, y: 0, width: Constants.Popup.width, height: 0))
|
||||
|
||||
@@ -53,12 +51,6 @@ internal class Popup: NSStackView, Popup_p {
|
||||
self.sizeCallback?(self.frame.size)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
private class GPUView: NSStackView {
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSStackView, Popup_p {
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
internal class Popup: PopupWrapper {
|
||||
private var title: String
|
||||
|
||||
private var uploadView: NSView? = nil
|
||||
@@ -448,7 +446,7 @@ internal class Popup: NSStackView, Popup_p {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
public override func settings() -> NSView? {
|
||||
let view = SettingsContainerView()
|
||||
|
||||
view.addArrangedSubview(selectSettingsRow(
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import Cocoa
|
||||
import Kit
|
||||
|
||||
internal class Popup: NSView, Popup_p {
|
||||
internal class Popup: PopupWrapper {
|
||||
private var title: String
|
||||
|
||||
private var grid: NSGridView? = nil
|
||||
@@ -97,8 +97,6 @@ internal class Popup: NSView, Popup_p {
|
||||
return value
|
||||
}
|
||||
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
public init(_ title: String) {
|
||||
self.title = title
|
||||
|
||||
@@ -312,7 +310,7 @@ internal class Popup: NSView, Popup_p {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
public override func settings() -> NSView? {
|
||||
let view = SettingsContainerView()
|
||||
|
||||
view.addArrangedSubview(selectSettingsRow(
|
||||
|
||||
@@ -35,9 +35,7 @@ private struct Sensor_t: KeyValue_p {
|
||||
}
|
||||
}
|
||||
|
||||
internal class Popup: NSStackView, Popup_p {
|
||||
public var sizeCallback: ((NSSize) -> Void)? = nil
|
||||
|
||||
internal class Popup: PopupWrapper {
|
||||
private var list: [String: NSView] = [:]
|
||||
private var unknownSensorsState: Bool {
|
||||
Store.shared.bool(key: "Sensors_unknown", defaultValue: false)
|
||||
@@ -201,7 +199,7 @@ internal class Popup: NSStackView, Popup_p {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
public func settings() -> NSView? {
|
||||
public override func settings() -> NSView? {
|
||||
self.settingsView
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user