67 lines
1.9 KiB
QML
67 lines
1.9 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import "../config"
|
|
import "../services"
|
|
|
|
// CPU usage as a live filled-area graph plus the current percentage.
|
|
Pill {
|
|
id: root
|
|
spacing: Theme.spacing
|
|
|
|
Text {
|
|
text: Icons.cpu
|
|
font.family: Theme.monoFont
|
|
font.pixelSize: Theme.fontSize + 1
|
|
color: Theme.loadColor(SysStats.cpu)
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
// One vertical bar per core, filled from the bottom by that core's load.
|
|
Row {
|
|
id: cores
|
|
Layout.alignment: Qt.AlignVCenter
|
|
spacing: 1
|
|
readonly property int barH: Theme.barHeight - Theme.gap * 2 - 12
|
|
|
|
Repeater {
|
|
model: SysStats.coreCount
|
|
delegate: Rectangle {
|
|
readonly property real load: SysStats.coreLoads[index] || 0
|
|
width: 3
|
|
height: cores.barH
|
|
radius: 1
|
|
color: Qt.rgba(1, 1, 1, 0.08) // unfilled track
|
|
|
|
Rectangle {
|
|
anchors.bottom: parent.bottom
|
|
width: parent.width
|
|
radius: 1
|
|
height: Math.max(1, parent.height * (parent.load / 100))
|
|
color: Theme.loadColor(parent.load)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Text {
|
|
text: SysStats.cpu.toFixed(0) + "%"
|
|
font.family: Theme.font
|
|
font.pixelSize: Theme.fontSize
|
|
color: Theme.text
|
|
Layout.alignment: Qt.AlignVCenter
|
|
Layout.preferredWidth: 42 // fits "100%" at fontSize 15
|
|
horizontalAlignment: Text.AlignRight
|
|
}
|
|
|
|
// Max current core frequency, shown in GHz.
|
|
Text {
|
|
text: (SysStats.cpuFreq / 1000).toFixed(1) + "GHz"
|
|
font.family: Theme.font
|
|
font.pixelSize: Theme.fontSize
|
|
color: Theme.subtext
|
|
Layout.alignment: Qt.AlignVCenter
|
|
Layout.preferredWidth: 56 // fits "0.0GHz" at fontSize 15
|
|
horizontalAlignment: Text.AlignRight
|
|
}
|
|
}
|