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>
167 lines
6.0 KiB
QML
167 lines
6.0 KiB
QML
import QtQuick
|
|
import "../../components"
|
|
import "../../services"
|
|
import "../../theme"
|
|
|
|
// CPU, memory, GPU, CPU temperature and disk: a liquid fill rising with the
|
|
// value (after Serpantinum's usage cards), with title, value and detail.
|
|
Face {
|
|
id: root
|
|
usesMetrics: true
|
|
readonly property var disk: (MetricsService.snapshot.storage || [])[0] || ({})
|
|
readonly property var raw: {
|
|
switch (kind) {
|
|
case "cpu":
|
|
return {
|
|
title: "CPU",
|
|
icon: "",
|
|
value: MetricsService.cpu.percent,
|
|
text: MetricsService.value(MetricsService.cpu.percent, "%"),
|
|
detail: Number.isFinite(MetricsService.cpu.frequency) ? (MetricsService.cpu.frequency / 1000).toFixed(1) + " GHz" : ""
|
|
};
|
|
case "ram":
|
|
return {
|
|
title: "Memory",
|
|
icon: "",
|
|
value: MetricsService.ram.percent,
|
|
text: MetricsService.value(MetricsService.ram.percent, "%"),
|
|
detail: MetricsService.ram.available ? MetricsService.bytes(MetricsService.ram.used) + " of " + MetricsService.bytes(MetricsService.ram.total) : ""
|
|
};
|
|
case "gpu":
|
|
return {
|
|
title: "GPU",
|
|
icon: "",
|
|
value: MetricsService.gpu.percent,
|
|
text: MetricsService.value(MetricsService.gpu.percent, "%"),
|
|
detail: MetricsService.gpu.name || "No GPU telemetry"
|
|
};
|
|
case "temp":
|
|
return {
|
|
title: "CPU temp",
|
|
icon: "",
|
|
value: MetricsService.cpu.temperature,
|
|
text: MetricsService.value(MetricsService.cpu.temperature, "°C"),
|
|
detail: MetricsService.cpu.name || ""
|
|
};
|
|
default:
|
|
return {
|
|
title: "Disk",
|
|
icon: "",
|
|
value: root.disk.percent,
|
|
text: MetricsService.value(root.disk.percent, "%"),
|
|
detail: root.disk.available ? MetricsService.bytes(root.disk.free) + " free · " + root.disk.path : ""
|
|
};
|
|
}
|
|
}
|
|
readonly property real level: Number.isFinite(raw.value) ? Math.max(0, Math.min(1, raw.value / 100)) : 0
|
|
// The wave moves only while easing to a visibly different reading (12 fps,
|
|
// at least `settleTicks` steps), then holds still; small changes repaint
|
|
// once. An endless wave kept every usage widget repainting and the
|
|
// compositor recompositing the glass behind it.
|
|
readonly property bool animated: Theme.intensity > 0
|
|
readonly property int settleTicks: 18
|
|
property real shownLevel: level
|
|
property real phase: 0
|
|
property int ticks: 0
|
|
onLevelChanged: {
|
|
if (!animated || !desktopVisible || (!wave.running && Math.abs(level - shownLevel) < 0.02)) {
|
|
shownLevel = level;
|
|
return;
|
|
}
|
|
ticks = 0;
|
|
wave.start();
|
|
}
|
|
Timer {
|
|
id: wave
|
|
interval: 83
|
|
repeat: true
|
|
onTriggered: {
|
|
root.phase = (root.phase + Math.PI * 2 * interval / 2400) % (Math.PI * 2);
|
|
const gap = root.level - root.shownLevel;
|
|
root.shownLevel = Math.abs(gap) < 0.002 ? root.level : root.shownLevel + gap * 0.3;
|
|
if ((++root.ticks >= root.settleTicks && root.shownLevel === root.level) || !root.desktopVisible || !root.animated)
|
|
stop();
|
|
}
|
|
}
|
|
readonly property bool compact: height < 100 || width < 140
|
|
|
|
Canvas {
|
|
id: liquid
|
|
anchors.fill: parent
|
|
readonly property real level: root.shownLevel
|
|
readonly property real phase: root.phase
|
|
readonly property color fill: Theme.accentVivid
|
|
readonly property real radius: Theme.radius
|
|
onLevelChanged: requestPaint()
|
|
onPhaseChanged: requestPaint()
|
|
onFillChanged: requestPaint()
|
|
onPaint: {
|
|
const ctx = getContext("2d");
|
|
ctx.reset();
|
|
const w = width, h = height, r = Math.min(radius, h / 2, w / 2);
|
|
ctx.beginPath();
|
|
ctx.roundedRect(0, 0, w, h, r, r);
|
|
ctx.clip();
|
|
const surface = h * (1 - level), amp = Math.max(2, h * 0.035);
|
|
for (const [shift, alpha] of [[Math.PI, 0.18], [0, 0.38]]) {
|
|
ctx.beginPath();
|
|
ctx.moveTo(0, h);
|
|
for (let x = 0; x <= w; x += 4)
|
|
ctx.lineTo(x, surface + Math.sin(x / w * Math.PI * 2 + phase + shift) * amp);
|
|
ctx.lineTo(w, h);
|
|
ctx.closePath();
|
|
ctx.fillStyle = Qt.alpha(fill, alpha);
|
|
ctx.fill();
|
|
}
|
|
}
|
|
}
|
|
Column {
|
|
anchors.left: parent.left
|
|
anchors.top: parent.top
|
|
anchors.margins: 12
|
|
spacing: 2
|
|
Row {
|
|
spacing: 6
|
|
GlassIcon {
|
|
size: 22
|
|
glyphSize: 12
|
|
glyph: root.raw.icon
|
|
fallback: root.raw.title.charAt(0)
|
|
color: Theme.transparent
|
|
border.width: 0
|
|
}
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: root.raw.title
|
|
color: Theme.text
|
|
font.pixelSize: 12
|
|
font.weight: Font.DemiBold
|
|
}
|
|
}
|
|
}
|
|
Column {
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
anchors.margins: 12
|
|
spacing: 0
|
|
Text {
|
|
text: root.raw.text
|
|
color: Theme.text
|
|
font.pixelSize: Math.max(18, Math.min(root.height * 0.3, root.width * 0.24))
|
|
font.weight: Font.Light
|
|
font.features: {
|
|
"tnum": 1
|
|
}
|
|
}
|
|
Text {
|
|
visible: !root.compact && text !== ""
|
|
width: parent.width
|
|
text: root.raw.detail
|
|
color: Theme.textSecondary
|
|
font.pixelSize: 10
|
|
elide: Text.ElideRight
|
|
}
|
|
}
|
|
}
|