Add glassMxrph shell sources
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>
This commit is contained in:
commit
99e64a7713
433 files changed
+57792
No files matched your search
@@ -0,0 +1,282 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Services.Mpris
|
||||
import Quickshell.Widgets
|
||||
import ".."
|
||||
import "../../components"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
// Now playing with full transport controls, a Cava strip and the EasyEffects equalizer.
|
||||
Item {
|
||||
id: root
|
||||
property bool current: false
|
||||
property bool showEqualizer: true
|
||||
implicitWidth: row.implicitWidth
|
||||
implicitHeight: row.implicitHeight
|
||||
readonly property var player: MediaService.player
|
||||
// Streams report no length or absurd ones; show them as live.
|
||||
readonly property bool live: MediaService.length <= 0 || MediaService.length > 7 * 86400
|
||||
property bool subscribed: false
|
||||
onCurrentChanged: sync()
|
||||
Component.onCompleted: sync()
|
||||
Component.onDestruction: if (subscribed) {
|
||||
MediaService.progressConsumers--;
|
||||
CavaService.widgetConsumers--;
|
||||
}
|
||||
function sync() {
|
||||
if (current === subscribed)
|
||||
return;
|
||||
MediaService.progressConsumers += current ? 1 : -1;
|
||||
CavaService.widgetConsumers += current ? 1 : -1;
|
||||
subscribed = current;
|
||||
if (current)
|
||||
EasyEffectsService.refresh();
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
spacing: 12
|
||||
DashCard {
|
||||
id: playerCard
|
||||
objectName: "dashPlayer"
|
||||
Layout.preferredWidth: 400
|
||||
Layout.preferredHeight: Math.max(330 + (MediaService.players.length > 1 ? 30 : 0), root.showEqualizer ? equalizer.implicitHeight : 0)
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 18
|
||||
spacing: 18
|
||||
ClippingRectangle {
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.preferredWidth: 150
|
||||
Layout.preferredHeight: 150
|
||||
radius: 20
|
||||
color: Theme.fill
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: art.status !== Image.Ready
|
||||
text: Icons.available ? "" : "♪"
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: 52
|
||||
color: Theme.textSecondary
|
||||
}
|
||||
Image {
|
||||
id: art
|
||||
anchors.fill: parent
|
||||
source: MediaService.artwork
|
||||
sourceSize: Qt.size(300, 300)
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
opacity: status === Image.Ready ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 4
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: MediaService.title
|
||||
color: Theme.text
|
||||
font.pixelSize: 18
|
||||
font.weight: Font.DemiBold
|
||||
elide: Text.ElideRight
|
||||
maximumLineCount: 2
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: MediaService.artist
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 13
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
visible: text !== ""
|
||||
text: MediaService.album
|
||||
color: Theme.textSecondary
|
||||
opacity: 0.75
|
||||
font.pixelSize: 12
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
// Cava bars for system audio while playing. The fixed-size
|
||||
// wrapper keeps bar heights out of the layout: otherwise each
|
||||
// Cava frame re-polished the column and rendered twice.
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 8
|
||||
Layout.preferredHeight: 34
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
spacing: 3
|
||||
opacity: MediaService.playing ? 1 : 0.25
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
model: 24
|
||||
Rectangle {
|
||||
required property int index
|
||||
anchors.bottom: parent.bottom
|
||||
width: 4
|
||||
radius: 2
|
||||
height: Math.max(3, 34 * (MediaService.playing ? (CavaService.bars[index] || 0) : 0.05))
|
||||
color: Qt.alpha(Theme.accentVivid, 0.85)
|
||||
// No height Behavior: Cava already smooths at 30 fps, and
|
||||
// interpolating raised rendering to the display rate.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 18
|
||||
spacing: 6
|
||||
GlassSlider {
|
||||
objectName: "dashSeek"
|
||||
Layout.fillWidth: true
|
||||
from: 0
|
||||
to: root.live ? 1 : Math.max(1, MediaService.length)
|
||||
value: root.live ? 0 : MediaService.position
|
||||
enabled: MediaService.seekable && !root.live
|
||||
opacity: root.live ? 0.4 : 1
|
||||
onMoved: MediaService.seek(value)
|
||||
}
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: -6
|
||||
Text {
|
||||
text: MediaService.time(MediaService.position)
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
font.features: {
|
||||
"tnum": 1
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Text {
|
||||
text: root.live ? "LIVE" : MediaService.time(MediaService.length)
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
font.features: {
|
||||
"tnum": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Row {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
spacing: 12
|
||||
DashButton {
|
||||
objectName: "dashShuffle"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
glyph: ""
|
||||
fallback: "⤨"
|
||||
size: 34
|
||||
active: !!root.player && root.player.shuffle
|
||||
interactive: !!root.player && root.player.shuffleSupported && root.player.canControl
|
||||
onClicked: root.player.shuffle = !root.player.shuffle
|
||||
Accessible.name: "Shuffle"
|
||||
}
|
||||
DashButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
glyph: ""
|
||||
fallback: "‹"
|
||||
size: 40
|
||||
interactive: !!root.player && root.player.canGoPrevious
|
||||
onClicked: MediaService.previous()
|
||||
Accessible.name: "Previous track"
|
||||
}
|
||||
DashButton {
|
||||
objectName: "dashToggle"
|
||||
size: 54
|
||||
accented: true
|
||||
glyph: MediaService.playing ? "" : ""
|
||||
fallback: MediaService.playing ? "Ⅱ" : "▶"
|
||||
interactive: !!root.player && root.player.canTogglePlaying
|
||||
onClicked: MediaService.toggle()
|
||||
Accessible.name: "Play or pause"
|
||||
}
|
||||
DashButton {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
glyph: ""
|
||||
fallback: "›"
|
||||
size: 40
|
||||
interactive: !!root.player && root.player.canGoNext
|
||||
onClicked: MediaService.next()
|
||||
Accessible.name: "Next track"
|
||||
}
|
||||
DashButton {
|
||||
objectName: "dashLoop"
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
glyph: !!root.player && root.player.loopState === MprisLoopState.Track ? "" : ""
|
||||
fallback: "↻"
|
||||
size: 34
|
||||
active: !!root.player && root.player.loopState !== MprisLoopState.None
|
||||
interactive: !!root.player && root.player.loopSupported && root.player.canControl
|
||||
onClicked: root.player.loopState = root.player.loopState === MprisLoopState.None ? MprisLoopState.Playlist : root.player.loopState === MprisLoopState.Playlist ? MprisLoopState.Track : MprisLoopState.None
|
||||
Accessible.name: "Repeat"
|
||||
}
|
||||
}
|
||||
// Player chooser when several MPRIS players are present.
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 4
|
||||
spacing: 6
|
||||
visible: MediaService.players.length > 1
|
||||
Repeater {
|
||||
model: MediaService.players
|
||||
Rectangle {
|
||||
id: chip
|
||||
required property var modelData
|
||||
readonly property bool active: MediaService.player === modelData
|
||||
implicitWidth: chipText.implicitWidth + 20
|
||||
implicitHeight: 24
|
||||
radius: 12
|
||||
color: active ? Qt.alpha(Theme.accent, 0.3) : chipArea.containsMouse ? Theme.hover : Theme.fill
|
||||
border.width: 1
|
||||
border.color: active ? Qt.alpha(Theme.accent, 0.6) : Theme.hairline
|
||||
Text {
|
||||
id: chipText
|
||||
anchors.centerIn: parent
|
||||
text: chip.modelData.identity || chip.modelData.dbusName
|
||||
color: Theme.text
|
||||
font.pixelSize: 11
|
||||
}
|
||||
MouseArea {
|
||||
id: chipArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: MediaService.choose(chip.modelData.dbusName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Equalizer {
|
||||
id: equalizer
|
||||
visible: root.showEqualizer
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.preferredHeight: Math.max(implicitHeight, playerCard.Layout.preferredHeight)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import ".."
|
||||
import "../../widgets/faces" as Faces
|
||||
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
|
||||
property bool subscribed: false
|
||||
onLiveChanged: sync()
|
||||
Component.onCompleted: sync()
|
||||
Component.onDestruction: if (subscribed) {
|
||||
MetricsService.consumers--;
|
||||
MediaService.progressConsumers--;
|
||||
}
|
||||
function sync() {
|
||||
if (live === subscribed)
|
||||
return;
|
||||
MetricsService.consumers += live ? 1 : -1;
|
||||
MediaService.progressConsumers += live ? 1 : -1;
|
||||
subscribed = 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
|
||||
readonly property real target: Number.isFinite(value) ? Math.max(0, Math.min(100, value)) : 0
|
||||
// Only visible jumps animate (see Gauge).
|
||||
property real shown
|
||||
property bool easeJump: false
|
||||
Component.onCompleted: shown = target
|
||||
onTargetChanged: {
|
||||
easeJump = Math.abs(target - shown) >= 2;
|
||||
shown = target;
|
||||
}
|
||||
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 * bar.shown / 100)
|
||||
radius: 5
|
||||
color: bar.shown > 85 ? Theme.urgent : Theme.accentVivid
|
||||
Behavior on height {
|
||||
enabled: bar.easeJump
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 2
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
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
|
||||
property bool subscribed: false
|
||||
onCurrentChanged: sync()
|
||||
Component.onCompleted: sync()
|
||||
Component.onDestruction: if (subscribed)
|
||||
MetricsService.consumers--
|
||||
function sync() {
|
||||
if (current === subscribed)
|
||||
return;
|
||||
MetricsService.consumers += current ? 1 : -1;
|
||||
subscribed = 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import ".."
|
||||
import "../../components"
|
||||
import "../../core"
|
||||
import "../../services"
|
||||
import "../../theme"
|
||||
|
||||
// Lock, restart and shut down. Restart and shut down ask for confirmation.
|
||||
Item {
|
||||
id: root
|
||||
property bool current: false
|
||||
implicitWidth: card.implicitWidth
|
||||
implicitHeight: card.implicitHeight
|
||||
onCurrentChanged: if (!current)
|
||||
PowerService.cancel()
|
||||
FileView {
|
||||
id: uptime
|
||||
path: "/proc/uptime"
|
||||
}
|
||||
Timer {
|
||||
interval: 60000
|
||||
running: root.current
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: uptime.reload()
|
||||
}
|
||||
readonly property string uptimeText: {
|
||||
const seconds = parseFloat(uptime.text());
|
||||
if (!Number.isFinite(seconds))
|
||||
return "";
|
||||
const d = Math.floor(seconds / 86400), h = Math.floor(seconds % 86400 / 3600), m = Math.floor(seconds % 3600 / 60);
|
||||
return "Up " + (d ? d + "d " : "") + (d || h ? h + "h " : "") + m + "m";
|
||||
}
|
||||
readonly property var actions: [
|
||||
{
|
||||
id: "lock",
|
||||
label: "Lock",
|
||||
glyph: "",
|
||||
fallback: "L"
|
||||
},
|
||||
{
|
||||
id: "reboot",
|
||||
label: "Restart",
|
||||
glyph: "",
|
||||
fallback: "R"
|
||||
},
|
||||
{
|
||||
id: "shutdown",
|
||||
label: "Shut down",
|
||||
glyph: "",
|
||||
fallback: "⏻"
|
||||
}
|
||||
]
|
||||
function available(id) {
|
||||
if (id === "lock" && ConfigService.ready && ConfigService.data.lock.enabled)
|
||||
return true;
|
||||
return !!SystemService.state.power && !!SystemService.state.power[id] && !SystemService.acting;
|
||||
}
|
||||
function run(id) {
|
||||
if (id === "lock")
|
||||
ShellState.dashboardOpen = false;
|
||||
PowerService.request(id);
|
||||
}
|
||||
|
||||
DashCard {
|
||||
id: card
|
||||
implicitWidth: 520
|
||||
implicitHeight: body.implicitHeight + 48
|
||||
ColumnLayout {
|
||||
id: body
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 24
|
||||
spacing: 20
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 2
|
||||
Text {
|
||||
text: (Quickshell.env("USER") || "user") + "@" + hostname.text().trim()
|
||||
color: Theme.text
|
||||
font.pixelSize: 16
|
||||
font.weight: Font.DemiBold
|
||||
FileView {
|
||||
id: hostname
|
||||
path: "/etc/hostname"
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: root.uptimeText
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 12
|
||||
}
|
||||
}
|
||||
Row {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
Layout.topMargin: 4
|
||||
spacing: 56
|
||||
Repeater {
|
||||
model: root.actions
|
||||
Column {
|
||||
id: action
|
||||
required property var modelData
|
||||
readonly property bool armed: PowerService.pending === modelData.id
|
||||
spacing: 10
|
||||
DashButton {
|
||||
objectName: "dashPower-" + action.modelData.id
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
size: 84
|
||||
glyphScale: 0.36
|
||||
glyph: action.modelData.glyph
|
||||
fallback: action.modelData.fallback
|
||||
active: action.armed
|
||||
danger: action.modelData.id !== "lock"
|
||||
interactive: root.available(action.modelData.id)
|
||||
onClicked: root.run(action.modelData.id)
|
||||
Accessible.name: action.modelData.label
|
||||
}
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: action.modelData.label
|
||||
color: action.armed ? Theme.text : Theme.textSecondary
|
||||
font.pixelSize: 13
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
id: confirm
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
readonly property var pending: root.actions.find(a => a.id === PowerService.pending)
|
||||
opacity: pending ? 1 : 0
|
||||
visible: opacity > 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: confirm.pending ? confirm.pending.label + " now? Unsaved work may be lost." : ""
|
||||
color: Theme.text
|
||||
font.pixelSize: 12
|
||||
wrapMode: Text.Wrap
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "dashPowerCancel"
|
||||
text: "Cancel"
|
||||
onClicked: PowerService.cancel()
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "dashPowerConfirm"
|
||||
text: confirm.pending ? confirm.pending.label : "Confirm"
|
||||
accented: true
|
||||
enabled: !SystemService.acting
|
||||
onClicked: PowerService.confirm()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user