Files
glassMxrph/quickshell/controlcenter/modules/Metrics.qml
T
mxandClaude Opus 5.5 11bdc4c751 Lay the Control Center out as a resizable, editable grid
Modules are tiles on a 4-column grid, each 1x1 to 4x4 and adapting its
layout to its size. Edit Controls in the panel reorders by dragging,
resizes from a corner handle, removes with a badge and adds from a tray.
Connectivity splits into Wi-Fi, Bluetooth and Network tiles and Audio
into Sound and Microphone; right-clicking Sound extends it with output
devices and a volume slider per app. Adds a Caffeine tile. Config
version 2 migrates existing layouts in place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 20:52:14 +02:00

100 lines
3.1 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.
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts
import ".."
import "../../core"
import "../../metrics"
import "../../services"
import "../../theme"
// CPU, RAM and GPU load. Small tiles show the figures as text (1×1 just CPU);
// wide tall tiles show ring gauges. Click opens the Metrics settings.
CCModule {
id: root
readonly property var stats: [
{
label: "CPU",
value: MetricsService.cpu.percent
},
{
label: "RAM",
value: MetricsService.ram.percent
},
{
label: "GPU",
value: MetricsService.gpu.percent
}
]
readonly property int shown: compact ? 1 : Math.min(stats.length, wide ? cols : rows)
readonly property bool gauges: wide && tall
objectName: "metricsTile"
hovered: area.containsMouse
Demand {
service: MetricsService
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: ShellState.openSettings("metrics")
}
GridLayout {
visible: !root.gauges
anchors.fill: parent
anchors.margins: 8
columns: root.wide ? root.shown : 1
rowSpacing: 4
columnSpacing: 4
Repeater {
model: root.stats.slice(0, root.shown)
ColumnLayout {
id: stat
required property var modelData
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 0
Text {
text: MetricsService.value(stat.modelData.value, "%")
color: Theme.text
font.pixelSize: 17
font.weight: Font.DemiBold
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom
Layout.fillWidth: true
Layout.fillHeight: true
}
Text {
text: stat.modelData.label
color: Theme.textSecondary
font.pixelSize: 10
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}
Row {
visible: root.gauges
anchors.centerIn: parent
Repeater {
model: root.gauges ? root.stats.slice(0, root.shown) : []
Item {
id: cell
required property var modelData
readonly property real scaleBy: Math.min(1, (root.width - 16) / root.shown / 100, (root.baseHeight - 16) / 106)
width: 100 * scaleBy
height: 106 * scaleBy
MetricGauge {
label: cell.modelData.label
value: cell.modelData.value
scale: cell.scaleBy
transformOrigin: Item.TopLeft
}
}
}
}
}