diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 13:02:25 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 13:02:25 +0200 |
| commit | d53b21ab5b86c9b91b84f013901c7e5ba0762035 (patch) | |
| tree | a1646f18e582a7e9b6c867ee233d1dc187e3784f | |
| parent | 5f73e8c655e65d31f1d400c95d5f8aa4578e8e41 (diff) | |
| download | sddm-theme-udt-d53b21ab5b86c9b91b84f013901c7e5ba0762035.tar.gz sddm-theme-udt-d53b21ab5b86c9b91b84f013901c7e5ba0762035.zip | |
feat: add power bar to login card
| -rw-r--r-- | theme/components/LoginCard.qml | 4 | ||||
| -rw-r--r-- | theme/components/PowerBar.qml | 67 | ||||
| -rw-r--r-- | theme/icons/hibernate.svg | 4 | ||||
| -rw-r--r-- | theme/icons/power.svg | 4 | ||||
| -rw-r--r-- | theme/icons/reboot.svg | 4 | ||||
| -rw-r--r-- | theme/icons/suspend.svg | 3 |
6 files changed, 86 insertions, 0 deletions
diff --git a/theme/components/LoginCard.qml b/theme/components/LoginCard.qml index b12eecb..e980dfd 100644 --- a/theme/components/LoginCard.qml +++ b/theme/components/LoginCard.qml @@ -215,6 +215,10 @@ Item { } } + PowerBar { + anchors.horizontalCenter: parent.horizontalCenter + } + Text { width: parent.width horizontalAlignment: Text.AlignHCenter diff --git a/theme/components/PowerBar.qml b/theme/components/PowerBar.qml new file mode 100644 index 0000000..9db65e7 --- /dev/null +++ b/theme/components/PowerBar.qml @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (C) 2026 Danilo M. <danix@danix.xyz> +// +// Shutdown, restart, sleep and hibernate. Each button is disabled when SDDM +// reports the action is unavailable. + +import QtQuick +import QtQuick.Controls.Basic +import QtQuick.Effects + +Row { + id: bar + spacing: 8 + + readonly property var actions: [ + { icon: "../icons/power.svg", label: "Shut down", enabled: sddm.canPowerOff, run: function() { sddm.powerOff() } }, + { icon: "../icons/reboot.svg", label: "Restart", enabled: sddm.canReboot, run: function() { sddm.reboot() } }, + { icon: "../icons/suspend.svg", label: "Sleep", enabled: sddm.canSuspend, run: function() { sddm.suspend() } }, + { icon: "../icons/hibernate.svg", label: "Hibernate", enabled: sddm.canHibernate, run: function() { sddm.hibernate() } } + ] + + Repeater { + model: bar.actions + delegate: Item { + width: 44 + height: 44 + opacity: modelData.enabled ? 1 : 0.35 + + Rectangle { + anchors.fill: parent + radius: 8 + color: config.stringValue("surface0") + opacity: mouse.containsMouse && modelData.enabled ? 1 : 0 + } + + Image { + id: icon + anchors.centerIn: parent + width: 22 + height: 22 + source: modelData.icon + visible: false + } + + MultiEffect { + anchors.fill: icon + source: icon + colorization: 1.0 + colorizationColor: mouse.containsMouse && modelData.enabled + ? config.stringValue("accent") + : config.stringValue("subtext0") + } + + MouseArea { + id: mouse + anchors.fill: parent + hoverEnabled: true + enabled: modelData.enabled + onClicked: modelData.run() + } + + ToolTip.visible: mouse.containsMouse && modelData.enabled + ToolTip.text: modelData.label + ToolTip.delay: 400 + } + } +} diff --git a/theme/icons/hibernate.svg b/theme/icons/hibernate.svg new file mode 100644 index 0000000..0956d95 --- /dev/null +++ b/theme/icons/hibernate.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> + <path d="M12 3v18"/> + <path d="M5 10l7 7 7-7"/> +</svg> diff --git a/theme/icons/power.svg b/theme/icons/power.svg new file mode 100644 index 0000000..a6573d4 --- /dev/null +++ b/theme/icons/power.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round"> + <path d="M12 3v9"/> + <path d="M6.6 6.6a8 8 0 1 0 10.8 0"/> +</svg> diff --git a/theme/icons/reboot.svg b/theme/icons/reboot.svg new file mode 100644 index 0000000..f3bafa9 --- /dev/null +++ b/theme/icons/reboot.svg @@ -0,0 +1,4 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> + <path d="M20 11a8 8 0 1 0-2.3 5.7"/> + <polyline points="20 5 20 11 14 11"/> +</svg> diff --git a/theme/icons/suspend.svg b/theme/icons/suspend.svg new file mode 100644 index 0000000..00fc4e8 --- /dev/null +++ b/theme/icons/suspend.svg @@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="round"> + <path d="M21 12.8A8.5 8.5 0 1 1 11.2 3a6.5 6.5 0 0 0 9.8 9.8z"/> +</svg> |
