Files
glassMxrph/quickshell/dashboard/tabs/OverviewTab.qml
T
mxandClaude Opus 5.5 bf0ef09cec Share demand counting and jump easing; split Settings sidebar
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>
2026-10-07 22:42:56 +02:00

251 lines
8.9 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 Quickshell
import Quickshell.Widgets
import ".."
import "../../widgets/faces" as Faces
import "../../components"
import "../../services"
import "../../theme"
// User, clock, calendar, resource bars and a compact player.
Item {
id: root
property bool current: false
implicitWidth: row.implicitWidth
implicitHeight: row.implicitHeight
// Collectors only run while this tab is on screen.
readonly property bool live: current
Demand {
service: MetricsService
active: root.live
}
Demand {
service: MediaService
counter: "progressConsumers"
active: root.live
}
readonly property var disk: (MetricsService.snapshot.storage || []).find(s => s.available) || ({})
RowLayout {
id: row
spacing: 12
ColumnLayout {
spacing: 12
Layout.preferredWidth: 260
DashCard {
Layout.fillWidth: true
Layout.preferredHeight: 112
Faces.UserFace {
anchors.fill: parent
}
}
DashCard {
id: clockCard
Layout.fillWidth: true
Layout.preferredHeight: 172
SystemClock {
id: clock
precision: SystemClock.Minutes
}
readonly property bool use24: ConfigService.ready && ConfigService.data.bar.clock.use24Hour
Column {
anchors.centerIn: parent
spacing: 2
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Qt.formatDateTime(clock.date, clockCard.use24 ? "HH:mm" : "h:mm")
color: Theme.text
font.pixelSize: 58
font.weight: Font.Light
font.features: {
"tnum": 1
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Qt.formatDateTime(clock.date, "dddd, d MMMM")
color: Theme.textSecondary
font.pixelSize: 13
}
}
}
}
DashCard {
Layout.preferredWidth: 280
Layout.preferredHeight: 296
Faces.CalendarFace {
anchors.fill: parent
}
}
DashCard {
Layout.preferredWidth: 132
Layout.preferredHeight: 296
Row {
anchors.centerIn: parent
spacing: 14
ResourceBar {
value: MetricsService.cpu.percent
glyph: "󰻠"
fallback: "C"
label: "CPU"
}
ResourceBar {
value: MetricsService.ram.percent
glyph: "󰍛"
fallback: "M"
label: "Memory"
}
ResourceBar {
value: root.disk.percent
glyph: "󰋊"
fallback: "D"
label: "Disk"
}
}
}
DashCard {
Layout.preferredWidth: 220
Layout.preferredHeight: 296
ColumnLayout {
anchors.fill: parent
anchors.margins: 16
spacing: 8
ClippingRectangle {
Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 132
Layout.preferredHeight: 132
radius: 18
color: Theme.fill
Text {
anchors.centerIn: parent
visible: art.status !== Image.Ready
text: Icons.available ? "󰝚" : "♪"
font.family: Icons.available ? Icons.family : ""
font.pixelSize: 44
color: Theme.textSecondary
}
Image {
id: art
anchors.fill: parent
source: MediaService.artwork
sourceSize: Qt.size(264, 264)
fillMode: Image.PreserveAspectCrop
asynchronous: true
opacity: status === Image.Ready ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: Theme.duration
}
}
}
}
Text {
Layout.fillWidth: true
text: MediaService.title
color: Theme.text
font.pixelSize: 14
font.weight: Font.DemiBold
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
}
Text {
Layout.fillWidth: true
Layout.topMargin: -6
text: MediaService.artist
color: Theme.textSecondary
font.pixelSize: 12
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 4
radius: 2
color: Qt.alpha(Theme.text, 0.12)
Rectangle {
width: MediaService.length > 0 && MediaService.length < 7 * 86400 ? parent.width * Math.min(1, MediaService.position / MediaService.length) : 0
height: parent.height
radius: 2
color: Theme.accentVivid
}
}
Row {
Layout.alignment: Qt.AlignHCenter
spacing: 10
DashButton {
anchors.verticalCenter: parent.verticalCenter
glyph: "󰒮"
fallback: "‹"
interactive: !!MediaService.player && MediaService.player.canGoPrevious
onClicked: MediaService.previous()
Accessible.name: "Previous track"
}
DashButton {
size: 44
accented: true
glyph: MediaService.playing ? "󰏤" : "󰐊"
fallback: MediaService.playing ? "Ⅱ" : "▶"
interactive: !!MediaService.player && MediaService.player.canTogglePlaying
onClicked: MediaService.toggle()
Accessible.name: "Play or pause"
}
DashButton {
anchors.verticalCenter: parent.verticalCenter
glyph: "󰒭"
fallback: "›"
interactive: !!MediaService.player && MediaService.player.canGoNext
onClicked: MediaService.next()
Accessible.name: "Next track"
}
}
}
}
}
component ResourceBar: Column {
id: bar
property var value: null
property string glyph
property string fallback
property string label
spacing: 8
JumpValue {
id: level
target: Number.isFinite(bar.value) ? Math.max(0, Math.min(100, bar.value)) : 0
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Number.isFinite(bar.value) ? Math.round(bar.value) + "%" : "—"
color: Theme.text
font.pixelSize: 11
font.features: {
"tnum": 1
}
}
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: 10
height: 196
radius: 5
color: Qt.alpha(Theme.text, 0.1)
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: Math.max(parent.width, parent.height * level.value / 100)
radius: 5
color: level.target > 85 ? Theme.urgent : Theme.accentVivid
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: Icons.available ? bar.glyph : bar.fallback
font.family: Icons.available ? Icons.family : ""
font.pixelSize: 15
color: Theme.textSecondary
Accessible.name: bar.label
}
}
}