feat: now few widgets can be enabled for one module

This commit is contained in:
Serhiy Mytrovtsiy
2021-02-13 16:39:11 +01:00
parent 1761d9cc59
commit 7b2b786b86
35 changed files with 718 additions and 602 deletions

View File

@@ -93,9 +93,6 @@ public class GPU: Module {
self.infoReader?.smc = smc
self.selectedGPU = store.pointee.string(key: "\(self.config.name)_gpu", defaultValue: self.selectedGPU)
self.infoReader?.readyCallback = { [unowned self] in
self.readyHandler()
}
self.infoReader?.callbackHandler = { [unowned self] value in
self.infoCallback(value)
}
@@ -135,15 +132,15 @@ public class GPU: Module {
return
}
if let widget = self.widget as? Mini {
widget.setValue(utilization)
widget.setTitle(self.showType ? "\(selectedGPU.type)GPU" : nil)
}
if let widget = self.widget as? LineChart {
widget.setValue(utilization)
}
if let widget = self.widget as? BarChart {
widget.setValue([utilization])
self.widgets.filter{ $0.isActive }.forEach { (w: Widget) in
switch w.item {
case let widget as Mini:
widget.setValue(utilization)
widget.setTitle(self.showType ? "\(selectedGPU.type)GPU" : nil)
case let widget as LineChart: widget.setValue(utilization)
case let widget as BarChart: widget.setValue([utilization])
default: break
}
}
}
}