Files
homelab/dotfiles/quickshell/widgets/vitals/VitalBar.qml
T
darmanandClaude Opus 5 b16cc93ff6 refactor(quickshell): move every color and font into a Theme singleton
The shell was running two unrelated palettes: an amber one (#FFD063 accent,
#EEEEEE text, #0F1012 panels) hardcoded as ~200 raw hex literals across the
launchers, sidebar, systray, vitals and notifications, and an orange one
(#e8722a) that only the dense bar had, tokenized as per-file properties.

This unifies on the ORANGE values under the AMBER naming scheme, and moves the
lot into widgets/theme/Theme.qml. `surface` takes the dense bar's void
(#0a0a0a) rather than the old panel background. Zero color and font literals
remain anywhere under widgets/ outside Theme.qml.

Collisions resolved, all near-duplicates that wanted to be one token:
  - #0F1012 + #0A0A0C + #0a0a0a -> surface
  - #EEEEEE + #dedede           -> text
  - #7A7B7D + #858585           -> muted
  - #292C30 + #22262C           -> raised
  - #FFD063 + #e8722a           -> accent

Two derived things rather than literals. accentSoft (the pale flash the
top/bottom bars show while a launcher is open) was a hand-picked #FFF3C0
against amber, which is simply wrong against orange; it is now
Qt.tint(accent, white 55%), a ratio checked against the original (amber tinted
55% gives #FFE9B8 vs the hand-picked #FFF3C0). And the dense bar had been
hand-encoding Qt.rgba(0.87,0.87,0.87,a) and Qt.rgba(0.91,0.45,0.16,a), which
are just text and accent at alpha -- now textAlpha(a)/accentAlpha(a), so they
track a palette change instead of silently drifting.

Fonts came along too. Digital-7 Mono is dropped for DepartureMono: it was
never packaged, relying on a manual ~/.dots/fonts/digital_7 install that does
not exist on terra, so `fc-match "Digital-7 Mono"` resolved to DejaVu Sans and
all 38 of those sites -- the launcher lists, sidebar clock, systray labels,
every vitals readout -- were silently rendering in a PROPORTIONAL fallback.
Numeric columns should visibly improve. readoutFont is an alias of displayFont
rather than a second literal so the two roles cannot drift apart.

quickshell/CLAUDE.md updated: it said "No shared theme/tokens file yet" and
told contributors to grep for the existing hex color, which would now
reintroduce exactly what this removes.

Verified: no file references Theme. without the import, none imports it
unused, and the whole shell -- launchers, sidebar, vitals, systray,
notifications, not just the harness -- hot-reloaded clean on terra.
tests/HeadlessSmoke.qml deliberately keeps its own copies; its value is having
no dependencies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SgcWkm3t6BDQktYHQvb8Hx
2026-08-28 07:56:25 +02:00

96 lines
2.7 KiB
QML

import QtQuick
import QtQuick.Shapes
import qs.widgets.theme
// Horizontal meter in the Slant language: a chamfered track whose fill is a
// clipped copy of the SAME hexagon, so empty and full always share one
// silhouette (the trick the sidebar's volume meter uses vertically).
Item {
id: bar
property real value: 0 // 0..1
property real warn: 0.85 // fraction at which the fill goes hot
property bool unknown: false // no reading — draw an empty, dimmed track
readonly property real frac: bar.unknown ? 0 : Math.max(0, Math.min(1, bar.value))
readonly property bool hot: !bar.unknown && bar.frac >= bar.warn
implicitWidth: 200
implicitHeight: 13
readonly property int chamfer: 5
// Track.
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
strokeWidth: 1
strokeColor: bar.unknown ? Theme.disabled : Theme.muted
fillColor: Theme.raised
startX: bar.chamfer
startY: 0
PathLine { x: bar.width; y: 0 }
PathLine { x: bar.width; y: bar.height - bar.chamfer }
PathLine { x: bar.width - bar.chamfer; y: bar.height }
PathLine { x: 0; y: bar.height }
PathLine { x: 0; y: bar.chamfer }
PathLine { x: bar.chamfer; y: 0 }
}
}
// Fill — revealed from the left.
Item {
id: fillClip
anchors.left: parent.left
anchors.leftMargin: 2
anchors.top: parent.top
anchors.topMargin: 2
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
clip: true
width: bar.frac * (bar.width - 4)
Behavior on width {
NumberAnimation {
duration: 220
easing.type: Easing.OutCubic
}
}
Shape {
id: fill
width: bar.width - 4
height: bar.height - 4
preferredRendererType: Shape.CurveRenderer
readonly property int chamfer: bar.chamfer - 2
ShapePath {
strokeWidth: 0
fillColor: bar.hot ? Theme.hot : Theme.accent
Behavior on fillColor {
ColorAnimation {
duration: 200
}
}
startX: fill.chamfer
startY: 0
PathLine { x: fill.width; y: 0 }
PathLine { x: fill.width; y: fill.height - fill.chamfer }
PathLine { x: fill.width - fill.chamfer; y: fill.height }
PathLine { x: 0; y: fill.height }
PathLine { x: 0; y: fill.chamfer }
PathLine { x: fill.chamfer; y: 0 }
}
}
}
}