feat: added Automatic option in the GPU to show setting. Allow showing the currently active GPU when selected. (#232)

This commit is contained in:
Serhiy Mytrovtsiy
2020-12-19 17:25:11 +01:00
parent d82480a49d
commit aa2cd64f88
2 changed files with 47 additions and 21 deletions

View File

@@ -86,18 +86,19 @@ public class GPU: Module {
}
}
private func infoCallback(_ value: GPUs?) {
guard value != nil && !value!.list.isEmpty else {
private func infoCallback(_ raw: GPUs?) {
guard raw != nil && !raw!.list.isEmpty, let value = raw else {
return
}
DispatchQueue.main.async(execute: {
self.popupView.infoCallback(value!)
self.popupView.infoCallback(value)
})
self.settingsView.setList(value!)
self.settingsView.setList(value)
let activeGPU = value!.active()
let selectedGPU = activeGPU.first{ $0.model == self.selectedGPU } ?? value!.igpu() ?? value!.list[0]
let activeGPUs = value.active()
let activeGPU = activeGPUs.first{ $0.state } ?? activeGPUs[0]
let selectedGPU: GPU_Info = activeGPUs.first{ $0.model == self.selectedGPU } ?? value.igpu() ?? activeGPU
if let widget = self.widget as? Mini {
widget.setValue(selectedGPU.utilization)