mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added an option to synchronize the fans (the mode only for now) control (#975)
This commit is contained in:
@@ -16,6 +16,7 @@ internal class Settings: NSStackView, Settings_v {
|
||||
private var updateIntervalValue: Int = 3
|
||||
private var hidState: Bool
|
||||
private var fanSpeedState: Bool = false
|
||||
private var fansSyncState: Bool = false
|
||||
|
||||
private let title: String
|
||||
private var button: NSPopUpButton?
|
||||
@@ -47,6 +48,7 @@ internal class Settings: NSStackView, Settings_v {
|
||||
self.updateIntervalValue = Store.shared.int(key: "\(self.title)_updateInterval", defaultValue: self.updateIntervalValue)
|
||||
self.hidState = Store.shared.bool(key: "\(self.title)_hid", defaultValue: self.hidState)
|
||||
self.fanSpeedState = Store.shared.bool(key: "\(self.title)_speed", defaultValue: self.fanSpeedState)
|
||||
self.fansSyncState = Store.shared.bool(key: "\(self.title)_fansSync", defaultValue: self.fansSyncState)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -72,6 +74,12 @@ internal class Settings: NSStackView, Settings_v {
|
||||
state: self.fanSpeedState
|
||||
))
|
||||
|
||||
self.addArrangedSubview(toggleSettingRow(
|
||||
title: localizedString("Synchronize the fans control"),
|
||||
action: #selector(toggleFansSync),
|
||||
state: self.fansSyncState
|
||||
))
|
||||
|
||||
if isARM {
|
||||
self.addArrangedSubview(toggleSettingRow(
|
||||
title: localizedString("HID sensors"),
|
||||
@@ -191,4 +199,16 @@ internal class Settings: NSStackView, Settings_v {
|
||||
Store.shared.set(key: "\(self.title)_hid", value: self.hidState)
|
||||
self.HIDcallback()
|
||||
}
|
||||
|
||||
@objc func toggleFansSync(_ sender: NSControl) {
|
||||
var state: NSControl.StateValue? = nil
|
||||
if #available(OSX 10.15, *) {
|
||||
state = sender is NSSwitch ? (sender as! NSSwitch).state: nil
|
||||
} else {
|
||||
state = sender is NSButton ? (sender as! NSButton).state: nil
|
||||
}
|
||||
|
||||
self.fansSyncState = state! == .on ? true : false
|
||||
Store.shared.set(key: "\(self.title)_fansSync", value: self.fansSyncState)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user