Files
homelab/dotfiles/quickshell/widgets/sidebar/SideBar.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

478 lines
18 KiB
QML

pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Hyprland
import Quickshell.Services.Pipewire
import Quickshell.Wayland
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts
import QtQuick.Shapes
import qs.widgets.theme
// A vertical sidebar carrying the "Slant" (launcher V6) visual language —
// chamfered panel, thick trapezoid bevel accents, an outward bracket, a
// floating triangle cap and a slanted divider. Right-anchored, mirrored.
Scope {
id: root
property bool active: true
function toggle() {
root.active = !root.active;
}
GlobalShortcut {
name: "sidebar"
description: "Toggle the Slant sidebar"
onPressed: root.toggle()
}
readonly property PwNode sink: Pipewire.defaultAudioSink
readonly property real volume: sink?.audio?.volume ?? 0
readonly property bool muted: sink?.audio?.muted ?? false
readonly property real maxVolume: 1.5
PwObjectTracker {
objects: [root.sink]
}
PanelWindow {
id: win
visible: root.active
color: "transparent"
anchors {
top: true
right: true
bottom: true
}
margins {
top: 8
}
// Frame width plus the gutter the outward bracket grows into.
readonly property int pad: 10
implicitWidth: 72 + 2 * pad
Item {
id: frame
// Inset so the outward bracket has room in the gutter.
anchors.fill: parent
anchors.margins: win.pad
readonly property int chamfer: 18 // big cut corners (top-right, bottom-left)
readonly property int smallChamfer: 7 // small bevel (top-left, bottom-right)
readonly property int bevel: 4 // inward thickness of the trapezoid accents
readonly property int chunkThick: 7 // outward thickness of the bracket
readonly property int chunkSlant: 10 // slant of the bracket end pieces
readonly property int capSize: 10 // floating triangle cap
readonly property int armSide: 58 // bracket arm down the left edge
readonly property int armTop: 34 // bracket arm along the top edge
Shape {
id: panelShape
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
// Panel: big chamfers on top-right & bottom-left, small bevels
// on top-left & bottom-right (mirror of the left-anchored panel).
ShapePath {
fillColor: Theme.surface
strokeColor: Theme.accent
strokeWidth: 2
startX: panelShape.width - frame.chamfer
startY: 0
PathLine {
x: frame.smallChamfer
y: 0
}
PathLine {
x: 0
y: frame.smallChamfer
}
PathLine {
x: 0
y: panelShape.height - frame.chamfer
}
PathLine {
x: frame.chamfer
y: panelShape.height
}
PathLine {
x: panelShape.width - frame.smallChamfer
y: panelShape.height
}
PathLine {
x: panelShape.width
y: panelShape.height - frame.smallChamfer
}
PathLine {
x: panelShape.width
y: frame.chamfer
}
PathLine {
x: panelShape.width - frame.chamfer
y: 0
}
}
// Thick top-right bevel accent (trapezoid to the edges).
ShapePath {
strokeWidth: 0
fillColor: Theme.accent
startX: panelShape.width
startY: frame.chamfer
PathLine {
x: panelShape.width - frame.chamfer
y: 0
}
PathLine {
x: panelShape.width - frame.chamfer - 2 * frame.bevel
y: 0
}
PathLine {
x: panelShape.width
y: frame.chamfer + 2 * frame.bevel
}
PathLine {
x: panelShape.width
y: frame.chamfer
}
}
// Thick bottom-left bevel accent.
ShapePath {
strokeWidth: 0
fillColor: Theme.accent
startX: 0
startY: panelShape.height - frame.chamfer
PathLine {
x: frame.chamfer
y: panelShape.height
}
PathLine {
x: frame.chamfer + 2 * frame.bevel
y: panelShape.height
}
PathLine {
x: 0
y: panelShape.height - frame.chamfer - 2 * frame.bevel
}
PathLine {
x: 0
y: panelShape.height - frame.chamfer
}
}
// Floating triangle cap in the bottom-left notch.
ShapePath {
strokeWidth: 0
fillColor: Theme.accent
startX: 0
startY: panelShape.height
PathLine {
x: 0
y: panelShape.height - frame.capSize
}
PathLine {
x: frame.capSize
y: panelShape.height
}
PathLine {
x: 0
y: panelShape.height
}
}
// Outward bracket wrapping the top-left corner: down the left
// edge and along the top edge, with slanted ends and a beveled
// corner following the small chamfer.
ShapePath {
strokeWidth: 0
fillColor: Theme.accent
startX: 0
startY: frame.armSide
PathLine {
x: -frame.chunkThick
y: frame.armSide - frame.chunkSlant
}
PathLine {
x: -frame.chunkThick
y: frame.smallChamfer
}
PathLine {
x: frame.smallChamfer
y: -frame.chunkThick
}
PathLine {
x: frame.armTop - frame.chunkSlant
y: -frame.chunkThick
}
PathLine {
x: frame.armTop
y: 0
}
PathLine {
x: frame.smallChamfer
y: 0
}
PathLine {
x: 0
y: frame.smallChamfer
}
PathLine {
x: 0
y: frame.armSide
}
}
}
// ── Content ────────────────────────────────────────────────────
ColumnLayout {
anchors.fill: parent
anchors.topMargin: 16
anchors.bottomMargin: 16
anchors.leftMargin: 10
anchors.rightMargin: 8
spacing: 10
// Clock — readout font, hh over mm
Text {
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
text: Qt.formatDateTime(clock.date, "hh\nmm")
font.family: Theme.readoutFont
font.pointSize: 22
font.letterSpacing: 1
color: Theme.text
SystemClock {
id: clock
precision: SystemClock.Minutes
}
}
// Date
Text {
Layout.alignment: Qt.AlignHCenter
horizontalAlignment: Text.AlignHCenter
text: Qt.formatDateTime(clock.date, "dd\nMMM").toUpperCase()
font.family: Theme.readoutFont
font.pointSize: 13
color: Theme.accent
}
// Slanted divider
Item {
Layout.fillWidth: true
implicitHeight: 4
Shape {
id: divider
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
strokeWidth: 0
fillColor: Theme.accent
startX: 8
startY: 0
PathLine { x: divider.width; y: 0 }
PathLine { x: divider.width - 8; y: divider.height }
PathLine { x: 0; y: divider.height }
PathLine { x: 8; y: 0 }
}
}
}
Item {
Layout.fillHeight: true
}
// Volume — vertical meter with a sheared fill and a % readout
Text {
Layout.alignment: Qt.AlignHCenter
text: "VOL"
font.family: Theme.readoutFont
font.pointSize: 10
color: Theme.muted
}
ColumnLayout {
Layout.alignment: Qt.AlignHCenter
spacing: 3
// Overflow — three floating slanted segments for volume
// pushed above 100%, lit with the same overload color as
// the volume OSD.
Repeater {
model: 3
delegate: Item {
id: seg
required property int index
readonly property real segStart: 1 + (2 - index) / 3 * (root.maxVolume - 1)
readonly property real segEnd: 1 + (3 - index) / 3 * (root.maxVolume - 1)
readonly property real frac: root.muted ? 0 : Math.max(0, Math.min(1, (root.volume - segStart) / (segEnd - segStart)))
readonly property int chamfer: 4
Layout.alignment: Qt.AlignHCenter
implicitWidth: 16
implicitHeight: 12
// Empty track, chamfered to match the main meter.
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
strokeWidth: 1
strokeColor: Theme.muted
fillColor: Theme.raised
startX: seg.chamfer
startY: 0
PathLine { x: seg.width; y: 0 }
PathLine { x: seg.width; y: seg.height - seg.chamfer }
PathLine { x: seg.width - seg.chamfer; y: seg.height }
PathLine { x: 0; y: seg.height }
PathLine { x: 0; y: seg.chamfer }
PathLine { x: seg.chamfer; y: 0 }
}
}
// Overload fill — reveals a fixed copy of the same
// chamfered hexagon from the bottom, so filled and
// empty states always share one silhouette.
Item {
id: segFillClip
anchors.left: parent.left
anchors.leftMargin: 2
anchors.right: parent.right
anchors.rightMargin: 2
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
clip: true
height: seg.frac * (seg.height - 4)
Shape {
id: segFill
width: seg.width - 4
height: seg.height - 4
y: segFillClip.height - height
preferredRendererType: Shape.CurveRenderer
readonly property int chamfer: seg.chamfer - 2
ShapePath {
strokeWidth: 0
fillColor: Theme.hot
startX: segFill.chamfer
startY: 0
PathLine { x: segFill.width; y: 0 }
PathLine { x: segFill.width; y: segFill.height - segFill.chamfer }
PathLine { x: segFill.width - segFill.chamfer; y: segFill.height }
PathLine { x: 0; y: segFill.height }
PathLine { x: 0; y: segFill.chamfer }
PathLine { x: segFill.chamfer; y: 0 }
}
}
}
}
}
Item {
id: volMeter
Layout.alignment: Qt.AlignHCenter
implicitWidth: 16
implicitHeight: 96
readonly property int chamfer: 6
// Track — chamfered top-left/bottom-right to match the
// panel's slant, so the sheared fill sits in a shape that
// agrees with it rather than a plain rectangle.
Shape {
anchors.fill: parent
preferredRendererType: Shape.CurveRenderer
ShapePath {
strokeWidth: 1
strokeColor: Theme.muted
fillColor: Theme.raised
startX: volMeter.chamfer
startY: 0
PathLine { x: volMeter.width; y: 0 }
PathLine { x: volMeter.width; y: volMeter.height - volMeter.chamfer }
PathLine { x: volMeter.width - volMeter.chamfer; y: volMeter.height }
PathLine { x: 0; y: volMeter.height }
PathLine { x: 0; y: volMeter.chamfer }
PathLine { x: volMeter.chamfer; y: 0 }
}
}
// Accent fill — reveals a fixed copy of the same
// chamfered hexagon as the track from the bottom, so
// the fill and background always share one silhouette.
Item {
id: fillClip
anchors.left: parent.left
anchors.leftMargin: 2
anchors.right: parent.right
anchors.rightMargin: 2
anchors.bottom: parent.bottom
anchors.bottomMargin: 2
clip: true
readonly property real frac: root.muted ? 0 : Math.min(root.volume, 1)
height: frac * (volMeter.height - 4)
Shape {
id: vol
width: volMeter.width - 4
height: volMeter.height - 4
y: fillClip.height - height
preferredRendererType: Shape.CurveRenderer
readonly property int chamfer: volMeter.chamfer - 2
ShapePath {
strokeWidth: 0
fillColor: root.muted ? Theme.muted : Theme.accent
startX: vol.chamfer
startY: 0
PathLine { x: vol.width; y: 0 }
PathLine { x: vol.width; y: vol.height - vol.chamfer }
PathLine { x: vol.width - vol.chamfer; y: vol.height }
PathLine { x: 0; y: vol.height }
PathLine { x: 0; y: vol.chamfer }
PathLine { x: vol.chamfer; y: 0 }
}
}
}
}
}
Text {
Layout.alignment: Qt.AlignHCenter
text: root.muted ? "--" : Math.round(root.volume * 100)
font.family: Theme.readoutFont
font.pointSize: 14
color: root.muted ? Theme.muted : Theme.text
}
}
}
}
}