141 lines
4.9 KiB
QML
141 lines
4.9 KiB
QML
// {{{autogen}}}
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
ShellRoot {
|
|
QtObject {
|
|
id: colors
|
|
readonly property color baseAlpha: Qt.rgba(30/255, 30/255, 46/255, 0.9)
|
|
readonly property color base: "#1e1e2e"
|
|
readonly property color surface0: "#313244"
|
|
readonly property color surface1: "#45475a"
|
|
readonly property color surface2: "#585b70"
|
|
readonly property color text: "#cdd6f4"
|
|
readonly property color subtext0: "#a6adc8"
|
|
readonly property color subtext1: "#bac2de"
|
|
readonly property color blue: "#89b4fa"
|
|
readonly property color green: "#a6e3a1"
|
|
readonly property color teal: "#94e2d5"
|
|
readonly property color red: "#f38ba8"
|
|
readonly property color mauve: "#cba6f7"
|
|
readonly property color peach: "#fab387"
|
|
readonly property color lavender: "#b4befe"
|
|
}
|
|
|
|
FloatingWindow {
|
|
id: root
|
|
title: "quickshell-powermenu"
|
|
visible: true
|
|
width: 220
|
|
height: contentLayout.implicitHeight + 32
|
|
color: colors.base
|
|
|
|
Shortcut {
|
|
sequence: "Escape"
|
|
onActivated: Qt.quit()
|
|
}
|
|
|
|
// Gradient border — hidden when app has focus
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
anchors.margins: -2
|
|
radius: 18
|
|
z: -1
|
|
opacity: Qt.application.active ? 0 : 1
|
|
Behavior on opacity {
|
|
NumberAnimation { duration: 150 }
|
|
}
|
|
gradient: Gradient {
|
|
orientation: Gradient.Horizontal
|
|
GradientStop { position: 0.0; color: colors.blue }
|
|
GradientStop { position: 1.0; color: colors.green }
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: 16
|
|
color: colors.base
|
|
|
|
ColumnLayout {
|
|
id: contentLayout
|
|
anchors {
|
|
top: parent.top
|
|
left: parent.left
|
|
right: parent.right
|
|
margins: 16
|
|
}
|
|
spacing: 4
|
|
|
|
Text {
|
|
text: " Power Menu"
|
|
color: colors.text
|
|
font.pixelSize: 13
|
|
font.bold: true
|
|
Layout.bottomMargin: 8
|
|
}
|
|
|
|
Repeater {
|
|
model: [
|
|
{ label: " Lock", cmd: ["hyprlock"] },
|
|
{ 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 : colors.base
|
|
property bool hovered: false
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
anchors.margins: -2
|
|
radius: parent.radius + 2
|
|
visible: item.hovered
|
|
z: -1
|
|
gradient: Gradient {
|
|
orientation: Gradient.Horizontal
|
|
GradientStop { position: 0.0; color: colors.blue }
|
|
GradientStop { position: 1.0; color: colors.green }
|
|
}
|
|
}
|
|
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
|
|
Item { height: 4 }
|
|
}
|
|
}
|
|
}
|
|
}
|