import QtQuick import "../theme" import "../services" Item { id: root property string label property var value implicitWidth: 100 implicitHeight: 106 Canvas { id: ring anchors.horizontalCenter: parent.horizontalCenter width: 82 height: 82 property color accent: Theme.accent property color track: Theme.border property var reading: root.value onAccentChanged: requestPaint() onTrackChanged: requestPaint() onReadingChanged: requestPaint() onPaint: { const c = getContext("2d"); c.reset(); c.lineWidth = 6; c.lineCap = "round"; c.strokeStyle = track; c.beginPath(); c.arc(41, 41, 35, 0, Math.PI * 2); c.stroke(); if (!MetricsService.stale && reading !== null && reading !== undefined) { c.strokeStyle = accent; c.beginPath(); c.arc(41, 41, 35, -Math.PI / 2, -Math.PI / 2 + Math.PI * 2 * Math.max(0, Math.min(100, reading)) / 100); c.stroke(); } } Connections { target: MetricsService function onStaleChanged() { ring.requestPaint(); } } Text { anchors.centerIn: parent text: MetricsService.value(root.value, "%") color: Theme.text font.pixelSize: 18 } } Text { anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter text: root.label color: Theme.textSecondary } }