112 lines
3.6 KiB
QML
112 lines
3.6 KiB
QML
// --- This file has been auto-generated. For permanent changes alter the appropriate block in the README.org. ---
|
|
// PowerMenu.qml
|
|
import "root:/"
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
ShellRoot {
|
|
// Load colors from shared Colors.qml
|
|
Colors { id: colors }
|
|
|
|
FloatingWindow {
|
|
id: root
|
|
visible: true
|
|
width: 220
|
|
height: contentLayout.implicitHeight + 32
|
|
color: "transparent"
|
|
|
|
// Close on Escape
|
|
Shortcut {
|
|
sequence: "Escape"
|
|
onActivated: Qt.quit()
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: 16
|
|
color: colors.base
|
|
border.width: 2
|
|
border.color: colors.blue
|
|
|
|
ColumnLayout {
|
|
id: contentLayout
|
|
anchors {
|
|
top: parent.top
|
|
left: parent.left
|
|
right: parent.right
|
|
margins: 16
|
|
}
|
|
spacing: 4
|
|
|
|
// Title
|
|
Text {
|
|
text: " Power Menu"
|
|
color: colors.teal
|
|
font.pixelSize: 13
|
|
font.bold: true
|
|
Layout.bottomMargin: 8
|
|
}
|
|
|
|
// Menu items
|
|
Repeater {
|
|
model: [
|
|
{ label: " Lock", cmd: ["loginctl", "lock-session"] },
|
|
{ label: " Shutdown", cmd: ["systemctl", "poweroff"] },
|
|
{ label: " Reboot", cmd: ["systemctl", "reboot"] },
|
|
{ label: " Logout", cmd: ["bash", "-c", "loginctl terminate-session $XDG_SESSION_ID"] },
|
|
{ label: " Hibernate", cmd: ["systemctl", "hibernate"] },
|
|
{ label: " Suspend", cmd: ["systemctl", "suspend"] },
|
|
]
|
|
|
|
delegate: Rectangle {
|
|
id: item
|
|
Layout.fillWidth: true
|
|
height: 38
|
|
radius: 8
|
|
color: hovered ? colors.surface1 : "transparent"
|
|
|
|
property bool hovered: false
|
|
|
|
// Gradient border on hover
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: parent.radius
|
|
color: "transparent"
|
|
border.width: item.hovered ? 2 : 0
|
|
border.color: colors.blue
|
|
}
|
|
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.left: parent.left
|
|
anchors.leftMargin: 12
|
|
text: modelData.label
|
|
color: item.hovered ? colors.text : colors.subtext1
|
|
font.pixelSize: 13
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
onEntered: item.hovered = true
|
|
onExited: item.hovered = false
|
|
onClicked: proc.running = true
|
|
}
|
|
|
|
Process {
|
|
id: proc
|
|
command: modelData.cmd
|
|
onExited: Qt.quit()
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bottom padding
|
|
Item { height: 4 }
|
|
}
|
|
}
|
|
}
|
|
}
|