Files
glassMxrph/quickshell/dashboard/Gauge.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

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

75 lines
2.5 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import QtQuick
import "../theme"
// Ring gauge (0–100) with a centred label; null values draw an empty ring.
Item {
id: root
property var value: null
property int size: 92
property real thickness: 8
property color color: Theme.accentVivid
property string label: value === null || value === undefined || !Number.isFinite(value) ? "—" : Math.round(value) + "%"
property string caption: ""
implicitWidth: size
implicitHeight: size
readonly property real target: Number.isFinite(value) ? Math.max(0, Math.min(100, value)) : 0
// Only visible jumps animate: easing every small sample change kept the
// window rendering at the display's refresh rate.
property real shown
property bool easeJump: false
Component.onCompleted: shown = target
onTargetChanged: {
easeJump = Math.abs(target - shown) >= 2;
shown = target;
}
Behavior on shown {
enabled: root.easeJump
NumberAnimation {
duration: Theme.duration * 2
easing.type: Easing.OutCubic
}
}
onShownChanged: canvas.requestPaint()
onColorChanged: canvas.requestPaint()
Canvas {
id: canvas
anchors.fill: parent
onPaint: {
const c = getContext("2d"), r = (width - root.thickness) / 2, start = Math.PI * 0.75, sweep = Math.PI * 1.5;
c.reset();
c.lineCap = "round";
c.lineWidth = root.thickness;
c.strokeStyle = Qt.alpha(Theme.text, 0.1);
c.beginPath();
c.arc(width / 2, height / 2, r, start, start + sweep);
c.stroke();
if (root.shown > 0) {
c.strokeStyle = root.color;
c.beginPath();
c.arc(width / 2, height / 2, r, start, start + sweep * root.shown / 100);
c.stroke();
}
}
}
Column {
anchors.centerIn: parent
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: root.label
color: Theme.text
font.pixelSize: Math.round(root.size * 0.21)
font.weight: Font.DemiBold
font.features: {
"tnum": 1
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
visible: text !== ""
text: root.caption
color: Theme.textSecondary
font.pixelSize: Math.max(9, Math.round(root.size * 0.11))
}
}
}