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>
271 lines
9.5 KiB
QML
271 lines
9.5 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
import ".."
|
|
import "../../services"
|
|
import "../../theme"
|
|
|
|
// CPU/GPU gauges with history, memory, storage and network throughput.
|
|
Item {
|
|
id: root
|
|
property bool current: false
|
|
implicitWidth: grid.implicitWidth
|
|
implicitHeight: grid.implicitHeight
|
|
Demand {
|
|
service: MetricsService
|
|
active: root.current
|
|
}
|
|
readonly property var gpu: MetricsService.gpu
|
|
readonly property bool hasGpu: gpu.percent !== undefined && gpu.percent !== null
|
|
readonly property var cpuHistory: MetricsService.history.map(h => h.cpu)
|
|
function temp(v) {
|
|
return Number.isFinite(v) ? Math.round(v) + "°C" : "—";
|
|
}
|
|
function ghz(mhz) {
|
|
return Number.isFinite(mhz) ? (mhz / 1000).toFixed(2) + " GHz" : "";
|
|
}
|
|
|
|
GridLayout {
|
|
id: grid
|
|
columns: 6
|
|
rowSpacing: 12
|
|
columnSpacing: 12
|
|
Hero {
|
|
Layout.columnSpan: root.hasGpu ? 3 : 6
|
|
glyph: ""
|
|
title: "CPU"
|
|
subtitle: MetricsService.cpu.name || "Processor"
|
|
value: MetricsService.cpu.percent
|
|
details: [root.temp(MetricsService.cpu.temperature), root.ghz(MetricsService.cpu.frequency)].filter(s => s && s !== "—").join(" · ") || "Temperature unavailable"
|
|
history: root.cpuHistory
|
|
}
|
|
Hero {
|
|
visible: root.hasGpu
|
|
Layout.columnSpan: 3
|
|
glyph: ""
|
|
title: "GPU"
|
|
subtitle: root.gpu.name || "Graphics"
|
|
value: root.gpu.percent
|
|
details: [root.temp(root.gpu.temperature), Number.isFinite(root.gpu.used) && Number.isFinite(root.gpu.total) ? MetricsService.bytes(root.gpu.used) + " / " + MetricsService.bytes(root.gpu.total) : ""].filter(s => s && s !== "—").join(" · ")
|
|
history: []
|
|
}
|
|
DashCard {
|
|
Layout.columnSpan: 2
|
|
Layout.fillWidth: true
|
|
Layout.preferredWidth: 220
|
|
Layout.preferredHeight: 150
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 14
|
|
Gauge {
|
|
size: 96
|
|
value: MetricsService.ram.percent
|
|
color: Theme.accentVivid
|
|
}
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
spacing: 2
|
|
Header {
|
|
glyph: ""
|
|
title: "Memory"
|
|
}
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: MetricsService.bytes(MetricsService.ram.used)
|
|
color: Theme.text
|
|
font.pixelSize: 16
|
|
font.weight: Font.DemiBold
|
|
elide: Text.ElideRight
|
|
}
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: "of " + MetricsService.bytes(MetricsService.ram.total)
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 11
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
}
|
|
}
|
|
DashCard {
|
|
Layout.columnSpan: 2
|
|
Layout.fillWidth: true
|
|
Layout.preferredWidth: 220
|
|
Layout.preferredHeight: 150
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 8
|
|
Header {
|
|
glyph: ""
|
|
title: "Storage"
|
|
}
|
|
Repeater {
|
|
model: (MetricsService.snapshot.storage || []).slice(0, 3)
|
|
ColumnLayout {
|
|
id: disk
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
spacing: 3
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Text {
|
|
text: disk.modelData.path
|
|
color: Theme.text
|
|
font.pixelSize: 11
|
|
elide: Text.ElideMiddle
|
|
Layout.fillWidth: true
|
|
}
|
|
Text {
|
|
text: disk.modelData.available ? MetricsService.bytes(disk.modelData.free) + " free" : "Unavailable"
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 10
|
|
}
|
|
}
|
|
Rectangle {
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 6
|
|
radius: 3
|
|
color: Qt.alpha(Theme.text, 0.1)
|
|
Rectangle {
|
|
width: parent.width * Math.min(1, (disk.modelData.percent || 0) / 100)
|
|
height: parent.height
|
|
radius: 3
|
|
color: (disk.modelData.percent || 0) > 90 ? Theme.urgent : Theme.accentVivid
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
Layout.fillHeight: true
|
|
}
|
|
}
|
|
}
|
|
DashCard {
|
|
Layout.columnSpan: 2
|
|
Layout.fillWidth: true
|
|
Layout.preferredWidth: 220
|
|
Layout.preferredHeight: 150
|
|
ColumnLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 4
|
|
Header {
|
|
glyph: ""
|
|
title: "Network"
|
|
}
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
Text {
|
|
text: "↓ " + MetricsService.bytes(MetricsService.network.download) + "/s"
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
font.features: {
|
|
"tnum": 1
|
|
}
|
|
Layout.fillWidth: true
|
|
}
|
|
Text {
|
|
text: "↑ " + MetricsService.bytes(MetricsService.network.upload) + "/s"
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 12
|
|
font.features: {
|
|
"tnum": 1
|
|
}
|
|
}
|
|
}
|
|
Item {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
Sparkline {
|
|
anchors.fill: parent
|
|
max: 0
|
|
values: MetricsService.history.map(h => h.down)
|
|
}
|
|
Sparkline {
|
|
anchors.fill: parent
|
|
max: 0
|
|
color: Theme.textSecondary
|
|
values: MetricsService.history.map(h => h.up)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
component Header: RowLayout {
|
|
id: header
|
|
property string glyph
|
|
property string title
|
|
spacing: 6
|
|
Text {
|
|
text: Icons.available ? header.glyph : ""
|
|
visible: Icons.available
|
|
font.family: Icons.family
|
|
font.pixelSize: 14
|
|
color: Theme.textSecondary
|
|
}
|
|
Text {
|
|
text: header.title
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 12
|
|
font.weight: Font.DemiBold
|
|
}
|
|
}
|
|
component Hero: DashCard {
|
|
id: hero
|
|
property string glyph
|
|
property string title
|
|
property string subtitle
|
|
property var value: null
|
|
property string details
|
|
property var history: []
|
|
Layout.fillWidth: true
|
|
Layout.preferredWidth: 340
|
|
Layout.preferredHeight: 150
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
anchors.margins: 16
|
|
spacing: 16
|
|
Gauge {
|
|
size: 108
|
|
value: hero.value
|
|
caption: hero.title
|
|
color: Number.isFinite(hero.value) && hero.value > 85 ? Theme.urgent : Theme.accentVivid
|
|
}
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
spacing: 2
|
|
Header {
|
|
glyph: hero.glyph
|
|
title: hero.title
|
|
}
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: hero.subtitle
|
|
color: Theme.text
|
|
font.pixelSize: 13
|
|
font.weight: Font.DemiBold
|
|
elide: Text.ElideRight
|
|
}
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: hero.details
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 11
|
|
elide: Text.ElideRight
|
|
}
|
|
Sparkline {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
Layout.topMargin: 4
|
|
visible: hero.history.length > 0
|
|
values: hero.history
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|