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,54 @@
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
// Round glyph button used by the media controls and the power tab.
|
||||
Rectangle {
|
||||
id: root
|
||||
property string glyph
|
||||
property string fallback
|
||||
property int size: 36
|
||||
property real glyphScale: 0.45
|
||||
property bool accented: false
|
||||
property bool active: false
|
||||
property bool danger: false
|
||||
property bool interactive: true
|
||||
signal clicked
|
||||
implicitWidth: size
|
||||
implicitHeight: size
|
||||
radius: size / 2
|
||||
opacity: interactive ? 1 : 0.4
|
||||
color: accented ? (area.pressed ? Theme.accentPressed : area.containsMouse ? Theme.accentHover : Theme.accent)
|
||||
: danger && area.containsMouse ? Qt.alpha("#ff5f57", 0.85)
|
||||
: active ? Qt.alpha(Theme.accent, 0.28)
|
||||
: area.containsMouse ? Theme.hover : Theme.fill
|
||||
border.width: accented ? 0 : 1
|
||||
border.color: active ? Qt.alpha(Theme.accent, 0.6) : Theme.hairline
|
||||
scale: area.pressed ? 1 - 0.06 * Theme.intensity : 1
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.duration / 2
|
||||
}
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration / 2
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Icons.available && root.glyph ? root.glyph : root.fallback
|
||||
font.family: Icons.available && root.glyph ? Icons.family : ""
|
||||
font.pixelSize: Math.round(root.size * root.glyphScale)
|
||||
color: root.accented ? Theme.accentText : root.active ? Theme.accentVivid : Theme.text
|
||||
}
|
||||
MouseArea {
|
||||
id: area
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: root.interactive
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
Accessible.role: Accessible.Button
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
// Inner dashboard card: a tinted, hairline-bordered plate on the glass panel.
|
||||
Rectangle {
|
||||
radius: Math.max(12, Theme.radius * 0.75)
|
||||
color: Theme.surfaceVariant
|
||||
border.width: 1
|
||||
border.color: Theme.hairline
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import "../components"
|
||||
import "../core"
|
||||
import "../services"
|
||||
import "../theme"
|
||||
|
||||
// Caelestia-style dashboard: tabbed glass panel below the bar. The layer is
|
||||
// sized to the panel (HyprGlass shapes glass from the layer box) and morphs as
|
||||
// tabs of different sizes slide in.
|
||||
// qmllint disable uncreatable-type
|
||||
PanelWindow {
|
||||
// qmllint enable uncreatable-type
|
||||
id: root
|
||||
screen: ScreenService.current(ShellState.dashboardScreen)
|
||||
readonly property var options: ConfigService.ready ? ConfigService.data.dashboard : null
|
||||
readonly property string position: options ? options.position : "top-center"
|
||||
readonly property var tabs: options ? options.tabs.filter(t => t.enabled && !!DashboardRegistry.entry(t.id)).map(t => t.id) : []
|
||||
readonly property int index: Math.max(0, tabs.indexOf(ShellState.dashboardTab))
|
||||
readonly property string currentId: tabs[index] || ""
|
||||
readonly property int padding: 16
|
||||
readonly property real screenWidth: screen ? screen.width : 1920
|
||||
readonly property real screenHeight: screen ? screen.height : 1080
|
||||
function select(i) {
|
||||
if (tabs.length)
|
||||
ShellState.dashboardTab = tabs[(i + tabs.length) % tabs.length];
|
||||
}
|
||||
// Top placements hang from the bar as a drawer; "center" floats.
|
||||
readonly property bool attached: position !== "center"
|
||||
anchors {
|
||||
top: root.attached
|
||||
left: root.position === "top-left"
|
||||
right: root.position === "top-right"
|
||||
}
|
||||
// The layer starts at the screen top so the bar join is inside its box.
|
||||
// Margins is present at runtime but unresolved in 0.3.1 qmltypes.
|
||||
// qmllint disable unqualified unresolved-type
|
||||
margins {
|
||||
left: BarDrawers.margin + BarDrawers.radius
|
||||
right: BarDrawers.margin + BarDrawers.radius
|
||||
}
|
||||
// qmllint enable unqualified unresolved-type
|
||||
implicitWidth: Math.max(120, Math.round(panel.width))
|
||||
implicitHeight: Math.max(60, Math.round((attached ? BarDrawers.bottom : 0) + panel.contentHeight))
|
||||
visible: ShellState.dashboardOpen || panel.shown
|
||||
color: Theme.transparent
|
||||
exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.namespace: "glassMxrph-dashboard"
|
||||
WlrLayershell.keyboardFocus: ShellState.dashboardOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||
Component.onCompleted: ShellState.dashboardWindow = root
|
||||
Component.onDestruction: ShellState.dashboardWindow = null
|
||||
Connections {
|
||||
target: ShellState
|
||||
function onDashboardOpenChanged() {
|
||||
if (!ShellState.dashboardOpen) {
|
||||
PowerService.cancel();
|
||||
if (root.options && !root.options.rememberTab)
|
||||
ShellState.dashboardTab = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
onOptionsChanged: if (options && !options.enabled)
|
||||
ShellState.dashboardOpen = false
|
||||
|
||||
// Exclusive focus routes outside clicks here (see ControlCenter).
|
||||
MouseArea {
|
||||
objectName: "dashboardOutside"
|
||||
x: -20000
|
||||
y: -20000
|
||||
width: 40000
|
||||
height: 40000
|
||||
onPressed: ShellState.dashboardOpen = false
|
||||
}
|
||||
|
||||
BarDrawer {
|
||||
id: panel
|
||||
objectName: "dashboardSurface"
|
||||
y: root.attached ? BarDrawers.bottom : 0
|
||||
open: ShellState.dashboardOpen
|
||||
attached: root.attached
|
||||
drawerId: "dashboard"
|
||||
screenName: root.screen ? root.screen.name : ""
|
||||
screenX: root.position === "top-left" ? BarDrawers.margin + BarDrawers.radius : root.position === "top-right" ? root.screenWidth - BarDrawers.margin - BarDrawers.radius - width : (root.screenWidth - width) / 2
|
||||
readonly property Loader page: {
|
||||
pages.count;
|
||||
return pages.itemAt(root.index) as Loader;
|
||||
}
|
||||
readonly property Item pageItem: page ? page.item as Item : null
|
||||
readonly property real pageWidth: pageItem ? pageItem.implicitWidth : 600
|
||||
readonly property real pageHeight: pageItem ? pageItem.implicitHeight : 300
|
||||
readonly property bool morph: progress > 0.05 && Theme.duration > 0
|
||||
readonly property real sideSpace: 2 * (BarDrawers.margin + BarDrawers.radius + ear)
|
||||
contentWidth: Math.min(root.screenWidth - sideSpace, pageWidth + 2 * root.padding)
|
||||
contentHeight: Math.min(root.screenHeight - BarDrawers.bottom - 20, tabBar.height + pageHeight + 3 * root.padding)
|
||||
Behavior on contentWidth {
|
||||
enabled: panel.morph
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 1.4
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [0.2, 0, 0, 1, 1, 1]
|
||||
}
|
||||
}
|
||||
Behavior on contentHeight {
|
||||
enabled: panel.morph
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 1.4
|
||||
easing.type: Easing.BezierSpline
|
||||
easing.bezierCurve: [0.2, 0, 0, 1, 1, 1]
|
||||
}
|
||||
}
|
||||
focus: ShellState.dashboardOpen
|
||||
Keys.onEscapePressed: ShellState.dashboardOpen = false
|
||||
Keys.onLeftPressed: root.select(root.index - 1)
|
||||
Keys.onRightPressed: root.select(root.index + 1)
|
||||
Keys.onTabPressed: root.select(root.index + 1)
|
||||
Keys.onBacktabPressed: root.select(root.index - 1)
|
||||
Keys.onPressed: event => {
|
||||
const n = event.key - Qt.Key_1;
|
||||
if (n >= 0 && n < root.tabs.length) {
|
||||
root.select(n);
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: tabBar
|
||||
objectName: "dashboardTabs"
|
||||
x: root.padding
|
||||
y: root.padding
|
||||
width: panel.contentWidth - 2 * root.padding
|
||||
height: 46
|
||||
readonly property real tabWidth: root.tabs.length ? width / root.tabs.length : width
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
Repeater {
|
||||
model: root.tabs
|
||||
Item {
|
||||
id: tab
|
||||
required property string modelData
|
||||
required property int index
|
||||
readonly property var entry: DashboardRegistry.entry(modelData)
|
||||
readonly property bool current: root.index === index
|
||||
objectName: "dashTab-" + modelData
|
||||
width: tabBar.tabWidth
|
||||
height: tabBar.height - 4
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
radius: height / 2
|
||||
color: tabArea.containsMouse && !tab.current ? Theme.hover : Theme.transparent
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.duration / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: 8
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: Icons.available ? tab.entry.glyph : tab.entry.fallback
|
||||
font.family: Icons.available ? Icons.family : ""
|
||||
font.pixelSize: 16
|
||||
color: tab.current ? Theme.accentVivid : Theme.textSecondary
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: tab.entry.title
|
||||
font.pixelSize: 13
|
||||
font.weight: tab.current ? Font.DemiBold : Font.Normal
|
||||
color: tab.current ? Theme.text : Theme.textSecondary
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: tabArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: root.select(tab.index)
|
||||
onWheel: event => root.select(root.index + (event.angleDelta.y < 0 ? 1 : -1))
|
||||
}
|
||||
Accessible.role: Accessible.PageTab
|
||||
Accessible.name: entry.title
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: indicator
|
||||
anchors.bottom: parent.bottom
|
||||
height: 3
|
||||
radius: 1.5
|
||||
width: Math.min(tabBar.tabWidth * 0.5, 72)
|
||||
x: tabBar.tabWidth * root.index + (tabBar.tabWidth - width) / 2
|
||||
color: Theme.accentVivid
|
||||
Behavior on x {
|
||||
enabled: panel.morph
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 1.3
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: parent.bottom
|
||||
anchors.topMargin: 0
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.hairline
|
||||
}
|
||||
}
|
||||
|
||||
// Pages sit side by side; the strip slides to the current one.
|
||||
Item {
|
||||
id: viewport
|
||||
objectName: "dashboardViewport"
|
||||
x: root.padding
|
||||
y: tabBar.y + tabBar.height + root.padding
|
||||
width: panel.contentWidth - 2 * root.padding
|
||||
height: panel.contentHeight - y - root.padding
|
||||
clip: true
|
||||
Row {
|
||||
id: strip
|
||||
spacing: root.padding * 2
|
||||
x: panel.page ? -panel.page.x : 0
|
||||
Behavior on x {
|
||||
enabled: panel.morph
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 1.3
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
Repeater {
|
||||
id: pages
|
||||
model: root.tabs
|
||||
Loader {
|
||||
id: pageLoader
|
||||
required property string modelData
|
||||
required property int index
|
||||
objectName: "dashPage-" + modelData
|
||||
active: ShellState.dashboardOpen || panel.visible
|
||||
source: DashboardRegistry.entry(modelData).source
|
||||
// Off-screen tabs fade so the slide reads as a swap.
|
||||
opacity: root.index === index ? 1 : 0.25
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
onLoaded: {
|
||||
item.current = Qt.binding(() => ShellState.dashboardOpen && root.index === pageLoader.index);
|
||||
if ("showEqualizer" in item)
|
||||
item.showEqualizer = Qt.binding(() => !!root.options && root.options.easyEffects);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "dashboard"
|
||||
function toggle(tab: string): void {
|
||||
ShellState.toggleDashboard(tab);
|
||||
}
|
||||
function open(tab: string): void {
|
||||
ShellState.openDashboard(tab);
|
||||
}
|
||||
function close(): void {
|
||||
ShellState.dashboardOpen = false;
|
||||
}
|
||||
function status(): string {
|
||||
return JSON.stringify({
|
||||
open: ShellState.dashboardOpen,
|
||||
visible: root.visible,
|
||||
tab: root.currentId,
|
||||
tabs: root.tabs,
|
||||
position: root.position,
|
||||
screen: root.screen ? root.screen.name : "",
|
||||
width: root.implicitWidth,
|
||||
height: root.implicitHeight
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import "../components"
|
||||
import "../services"
|
||||
import "../theme"
|
||||
|
||||
// EasyEffects equalizer (serpantinum-style): ten ±12 dB bands, eight presets.
|
||||
// Presets apply at once; dragged bands wait for Apply.
|
||||
DashCard {
|
||||
id: root
|
||||
objectName: "dashEqualizer"
|
||||
readonly property bool usable: EasyEffectsService.installed
|
||||
implicitWidth: 400
|
||||
implicitHeight: body.implicitHeight + 32
|
||||
function freq(f) {
|
||||
return f >= 1000 ? f / 1000 + "k" : String(f);
|
||||
}
|
||||
ColumnLayout {
|
||||
id: body
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 16
|
||||
spacing: 12
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 10
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 0
|
||||
Text {
|
||||
text: "Equalizer"
|
||||
color: Theme.text
|
||||
font.pixelSize: 15
|
||||
font.weight: Font.DemiBold
|
||||
}
|
||||
Text {
|
||||
text: !EasyEffectsService.known ? "Checking EasyEffects…" : !root.usable ? "EasyEffects is not installed" : EasyEffectsService.error ? EasyEffectsService.error : !EasyEffectsService.running ? "EasyEffects · starts on apply" : EasyEffectsService.bypass ? "EasyEffects · bypassed" : "EasyEffects · " + EasyEffectsService.preset
|
||||
color: EasyEffectsService.error ? Theme.urgent : Theme.textSecondary
|
||||
font.pixelSize: 11
|
||||
elide: Text.ElideRight
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
GlassToggle {
|
||||
objectName: "eqEnabled"
|
||||
enabled: root.usable && EasyEffectsService.running
|
||||
checked: !EasyEffectsService.bypass
|
||||
onToggled: EasyEffectsService.setBypass(!checked)
|
||||
Accessible.name: "Effects enabled"
|
||||
}
|
||||
GlassButton {
|
||||
objectName: "eqApply"
|
||||
implicitHeight: 30
|
||||
text: EasyEffectsService.busy ? "Applying…" : EasyEffectsService.pending ? "Apply" : "Saved"
|
||||
accented: EasyEffectsService.pending
|
||||
enabled: root.usable && EasyEffectsService.pending && !EasyEffectsService.busy
|
||||
onClicked: EasyEffectsService.apply()
|
||||
}
|
||||
}
|
||||
Row {
|
||||
id: bands
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
spacing: 6
|
||||
opacity: root.usable ? 1 : 0.45
|
||||
Repeater {
|
||||
model: 10
|
||||
Band {}
|
||||
}
|
||||
}
|
||||
GridLayout {
|
||||
Layout.fillWidth: true
|
||||
columns: 4
|
||||
rowSpacing: 6
|
||||
columnSpacing: 6
|
||||
opacity: root.usable ? 1 : 0.45
|
||||
Repeater {
|
||||
model: EasyEffectsService.presetNames
|
||||
Rectangle {
|
||||
id: chip
|
||||
required property string modelData
|
||||
readonly property bool active: EasyEffectsService.preset === modelData
|
||||
objectName: "eqPreset-" + modelData
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 1
|
||||
implicitHeight: 28
|
||||
radius: 14
|
||||
color: active ? Theme.accent : chipArea.containsMouse ? Theme.hover : Theme.fill
|
||||
border.width: active ? 0 : 1
|
||||
border.color: Theme.hairline
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.duration
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: chip.modelData
|
||||
color: chip.active ? Theme.accentText : Theme.text
|
||||
font.pixelSize: 12
|
||||
}
|
||||
MouseArea {
|
||||
id: chipArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: root.usable
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: EasyEffectsService.usePreset(chip.modelData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical ±12 dB slider: drag or scroll; the fill grows from the 0 dB line.
|
||||
component Band: Column {
|
||||
id: band
|
||||
required property int index
|
||||
readonly property real gain: EasyEffectsService.bands[index] || 0
|
||||
objectName: "eqBand" + index
|
||||
spacing: 4
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: (band.gain > 0 ? "+" : "") + Math.round(band.gain)
|
||||
color: band.gain === 0 ? Theme.textSecondary : Theme.text
|
||||
font.pixelSize: 10
|
||||
font.features: {
|
||||
"tnum": 1
|
||||
}
|
||||
}
|
||||
Item {
|
||||
id: track
|
||||
width: 30
|
||||
height: 120
|
||||
readonly property real zero: height / 2
|
||||
property real shown: band.gain
|
||||
Behavior on shown {
|
||||
enabled: !drag.pressed
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 1.5
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
readonly property real knobY: zero - shown / 12 * (height / 2 - 8)
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 6
|
||||
height: parent.height
|
||||
radius: 3
|
||||
color: Qt.alpha(Theme.text, 0.1)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 6
|
||||
y: Math.min(track.zero, track.knobY)
|
||||
height: Math.abs(track.knobY - track.zero)
|
||||
radius: 3
|
||||
color: Theme.accentVivid
|
||||
}
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: 14
|
||||
height: 1
|
||||
y: track.zero
|
||||
color: Theme.hairline
|
||||
}
|
||||
Rectangle {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: track.knobY - height / 2
|
||||
width: drag.pressed ? 20 : 16
|
||||
height: width
|
||||
radius: width / 2
|
||||
color: Theme.text
|
||||
border.width: 2
|
||||
border.color: Theme.accentVivid
|
||||
Behavior on width {
|
||||
NumberAnimation {
|
||||
duration: Theme.duration / 2
|
||||
}
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: drag
|
||||
anchors.fill: parent
|
||||
enabled: root.usable
|
||||
cursorShape: Qt.SizeVerCursor
|
||||
function set(y) {
|
||||
EasyEffectsService.setBand(band.index, (track.zero - y) / (track.height / 2 - 8) * 12);
|
||||
}
|
||||
onPressed: event => set(event.y)
|
||||
onPositionChanged: event => {
|
||||
if (pressed)
|
||||
set(event.y);
|
||||
}
|
||||
onWheel: event => EasyEffectsService.setBand(band.index, band.gain + (event.angleDelta.y > 0 ? 1 : -1))
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: root.freq(EasyEffectsService.frequencies[band.index] || 0)
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
// Ring gauge (0–100) with a centred label; null values draw an empty ring.
|
||||
Item {
|
||||
id: root
|
||||
property var value: null
|
||||
property int size: 92
|
||||
property real thickness: 8
|
||||
property color color: Theme.accentVivid
|
||||
property string label: value === null || value === undefined || !Number.isFinite(value) ? "—" : Math.round(value) + "%"
|
||||
property string caption: ""
|
||||
implicitWidth: size
|
||||
implicitHeight: size
|
||||
readonly property real target: Number.isFinite(value) ? Math.max(0, Math.min(100, value)) : 0
|
||||
// Only visible jumps animate: easing every small sample change kept the
|
||||
// window rendering at the display's refresh rate.
|
||||
property real shown
|
||||
property bool easeJump: false
|
||||
Component.onCompleted: shown = target
|
||||
onTargetChanged: {
|
||||
easeJump = Math.abs(target - shown) >= 2;
|
||||
shown = target;
|
||||
}
|
||||
Behavior on shown {
|
||||
enabled: root.easeJump
|
||||
NumberAnimation {
|
||||
duration: Theme.duration * 2
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
onShownChanged: canvas.requestPaint()
|
||||
onColorChanged: canvas.requestPaint()
|
||||
Canvas {
|
||||
id: canvas
|
||||
anchors.fill: parent
|
||||
onPaint: {
|
||||
const c = getContext("2d"), r = (width - root.thickness) / 2, start = Math.PI * 0.75, sweep = Math.PI * 1.5;
|
||||
c.reset();
|
||||
c.lineCap = "round";
|
||||
c.lineWidth = root.thickness;
|
||||
c.strokeStyle = Qt.alpha(Theme.text, 0.1);
|
||||
c.beginPath();
|
||||
c.arc(width / 2, height / 2, r, start, start + sweep);
|
||||
c.stroke();
|
||||
if (root.shown > 0) {
|
||||
c.strokeStyle = root.color;
|
||||
c.beginPath();
|
||||
c.arc(width / 2, height / 2, r, start, start + sweep * root.shown / 100);
|
||||
c.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: root.label
|
||||
color: Theme.text
|
||||
font.pixelSize: Math.round(root.size * 0.21)
|
||||
font.weight: Font.DemiBold
|
||||
font.features: {
|
||||
"tnum": 1
|
||||
}
|
||||
}
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: text !== ""
|
||||
text: root.caption
|
||||
color: Theme.textSecondary
|
||||
font.pixelSize: Math.max(9, Math.round(root.size * 0.11))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import QtQuick
|
||||
import "../theme"
|
||||
|
||||
// Filled line graph of the last samples; `max` 0 scales to the largest value.
|
||||
Canvas {
|
||||
id: root
|
||||
property var values: []
|
||||
property real max: 100
|
||||
property color color: Theme.accentVivid
|
||||
property int samples: 60
|
||||
onValuesChanged: requestPaint()
|
||||
onColorChanged: requestPaint()
|
||||
onWidthChanged: requestPaint()
|
||||
onHeightChanged: requestPaint()
|
||||
onPaint: {
|
||||
const c = getContext("2d");
|
||||
c.reset();
|
||||
const v = values.filter(x => x !== null && x !== undefined && Number.isFinite(x));
|
||||
if (v.length < 2)
|
||||
return;
|
||||
const top = root.max > 0 ? root.max : Math.max(1, ...v) * 1.15, step = width / (root.samples - 1), offset = width - (v.length - 1) * step;
|
||||
const y = x => height - 2 - (height - 4) * Math.min(1, x / top);
|
||||
c.beginPath();
|
||||
c.moveTo(offset, height);
|
||||
v.forEach((x, i) => c.lineTo(offset + i * step, y(x)));
|
||||
c.lineTo(offset + (v.length - 1) * step, height);
|
||||
c.closePath();
|
||||
const g = c.createLinearGradient(0, 0, 0, height);
|
||||
g.addColorStop(0, Qt.alpha(root.color, 0.35));
|
||||
g.addColorStop(1, Qt.alpha(root.color, 0));
|
||||
c.fillStyle = g;
|
||||
c.fill();
|
||||
c.beginPath();
|
||||
v.forEach((x, i) => i ? c.lineTo(offset + i * step, y(x)) : c.moveTo(offset, y(x)));
|
||||
c.strokeStyle = root.color;
|
||||
c.lineWidth = 1.6;
|
||||
c.stroke();
|
||||
}
|
||||
}
|
||||
@@ -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