feat: add an option to enable split value (System/User) for CPU and RAM in the BarChart (#441)

This commit is contained in:
Serhiy Mytrovtsiy
2021-08-03 20:11:18 +02:00
parent 918a07150b
commit 0fe2c0dd98
4 changed files with 97 additions and 11 deletions

View File

@@ -38,6 +38,11 @@ public class CPU: Module {
return Store.shared.bool(key: "\(self.config.name)_usagePerCore", defaultValue: false)
}
}
private var splitValueState: Bool {
get {
return Store.shared.bool(key: "\(self.config.name)_splitValue", defaultValue: false)
}
}
public init() {
self.settingsView = Settings("CPU")
@@ -132,6 +137,11 @@ public class CPU: Module {
var val: [[ColorValue]] = [[ColorValue(value.totalUsage)]]
if self.usagePerCoreState {
val = value.usagePerCore.map({ [ColorValue($0)] })
} else if self.splitValueState {
val = [[
ColorValue(value.systemLoad, color: NSColor.systemRed),
ColorValue(value.userLoad, color: NSColor.systemBlue)
]]
}
widget.setValue(val)
case let widget as PieChart: