Files
mxandClaude Opus 5.5 bf0ef09cec Share demand counting and jump easing; split Settings sidebar
Add services/Demand.qml, which holds one count on a service's demand
counter while active. It replaces 13 hand-written consumer counters
across the bar, Control Center, dashboard, media and desktop widgets.
The desktop Cava widget now releases Cava while its desktop is covered.

Add components/JumpValue.qml for the "animate only visible jumps" rule
shared by the dashboard gauge and resource bars.

Move the Settings sidebar (search and navigation) into
settings/SettingsSidebar.qml and the drag handle into
settings/controls/SettingsDragArea.qml, halving Settings.qml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:42:56 +02:00

173 lines
6.1 KiB
QML

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import "../components"
import "../theme"
import "../services"
import "../core"
GlassPanel {
id: root
objectName: "metricsCard"
property bool compact: false
implicitWidth: 390
implicitHeight: body.implicitHeight + 32
Demand {
service: MetricsService
}
ColumnLayout {
id: body
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: 16
}
spacing: 12
RowLayout {
Text {
text: "System"
color: Theme.text
font.pixelSize: 18
Layout.fillWidth: true
}
GlassIconButton {
text: "⚙"
onClicked: ShellState.openSettings("metrics")
Accessible.name: "Metrics settings"
}
}
RowLayout {
Layout.fillWidth: true
MetricGauge {
label: "CPU"
value: MetricsService.cpu.percent
Layout.fillWidth: true
}
MetricGauge {
label: "GPU"
value: MetricsService.gpu.percent
Layout.fillWidth: true
}
MetricGauge {
label: "RAM"
value: MetricsService.ram.percent
Layout.fillWidth: true
}
}
Canvas {
id: graph
visible: !root.compact
Layout.fillWidth: true
Layout.preferredHeight: visible ? 36 : 0
property var values: MetricsService.history
property color stroke: Theme.accent
onValuesChanged: if (visible)
requestPaint()
onStrokeChanged: requestPaint()
onWidthChanged: requestPaint()
onPaint: {
const c = getContext("2d");
c.reset();
c.strokeStyle = stroke;
c.lineWidth = 1.5;
c.beginPath();
let started = false;
for (let i = 0; i < values.length; i++) {
if (values[i].cpu == null) {
started = false;
continue;
}
const x = i * width / 59, y = height * (1 - values[i].cpu / 100);
if (!started) {
c.moveTo(x, y);
started = true;
} else
c.lineTo(x, y);
}
c.stroke();
}
Accessible.name: "CPU utilization history"
}
Text {
visible: !root.compact
text: MetricsService.cpu.name || "CPU"
color: Theme.textSecondary
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
text: "CPU " + MetricsService.value(MetricsService.cpu.temperature, " °C") + " · " + MetricsService.value((MetricsService.cpu.frequency == null ? null : MetricsService.cpu.frequency / 1000), " GHz", 2)
color: Theme.textSecondary
Layout.fillWidth: true
}
Text {
visible: !root.compact
text: MetricsService.gpu.name || "No GPU telemetry"
color: Theme.textSecondary
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
visible: !root.compact
text: "GPU " + MetricsService.value(MetricsService.gpu.temperature, " °C") + " · " + MetricsService.value(MetricsService.gpu.frequency, " MHz") + " · " + MetricsService.value(MetricsService.gpu.power, " W", 1)
color: Theme.textSecondary
Layout.fillWidth: true
}
Text {
visible: !root.compact
text: "VRAM " + MetricsService.bytes(MetricsService.gpu.used) + " / " + MetricsService.bytes(MetricsService.gpu.total)
color: Theme.textSecondary
Layout.fillWidth: true
}
Text {
text: "RAM " + MetricsService.bytes(MetricsService.ram.used) + " / " + MetricsService.bytes(MetricsService.ram.total)
color: Theme.textSecondary
Layout.fillWidth: true
}
Repeater {
model: root.compact ? [] : (MetricsService.snapshot.storage || [])
ColumnLayout {
id: disk
required property var modelData
Layout.fillWidth: true
Text {
text: disk.modelData.path + " · " + (disk.modelData.available ? MetricsService.bytes(disk.modelData.used) + " / " + MetricsService.bytes(disk.modelData.total) : "Unavailable")
color: Theme.text
elide: Text.ElideMiddle
Layout.fillWidth: true
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 5
radius: 3
color: Theme.border
Rectangle {
width: parent.width * (MetricsService.stale ? 0 : (disk.modelData.percent || 0) / 100)
height: parent.height
radius: 3
color: Theme.accent
}
}
Text {
text: "Free " + MetricsService.bytes(disk.modelData.free)
color: Theme.textSecondary
visible: disk.modelData.available
}
}
}
Text {
text: "↓ " + MetricsService.bytes(MetricsService.network.download) + "/s ↑ " + MetricsService.bytes(MetricsService.network.upload) + "/s"
color: Theme.text
Layout.fillWidth: true
}
Text {
visible: MetricsService.stale || !!MetricsService.error
text: MetricsService.error || "Waiting for metrics…"
color: Theme.textSecondary
wrapMode: Text.Wrap
Layout.fillWidth: true
}
}
}