me like nix
1import QtQuick
2import QtQuick.Layouts
3import Quickshell
4import Quickshell.Wayland
5import Quickshell.Io
6import "../../../config" as Config
7import "../../../components"
8
9PopupWindow {
10 id: sessionPopout
11
12 property bool show: false
13 property var parentWindow
14 property real anchorY: 0
15 signal close()
16
17 visible: show || contentRect.opacity > 0
18 anchor.window: parentWindow
19 anchor.onAnchoring: {
20 anchor.rect.x = parentWindow.width + 8
21 anchor.rect.y = Math.max(0, anchorY - implicitHeight / 2)
22 }
23
24 implicitWidth: content.implicitWidth + 48
25 implicitHeight: content.implicitHeight + 48
26 color: "transparent"
27
28 onShowChanged: {
29 if (show) { contentRect._opening = true; fadeIn.start() }
30 else { fadeIn.stop(); contentRect._opening = false; contentRect.opacity = 0 }
31 }
32 Timer { id: fadeIn; interval: 16; onTriggered: contentRect.opacity = 1 }
33
34 Rectangle {
35 id: contentRect
36 anchors.fill: parent
37 color: Config.Colours.base
38 radius: Config.Appearance.rounding.large
39 border.width: 1
40 border.color: Config.Colours.surface0
41 opacity: 0
42 property bool _opening: false
43 Behavior on opacity {
44 Anim {
45 duration: contentRect._opening ? Config.Appearance.anim.durations.normal : Config.Appearance.anim.durations.small
46 easing.bezierCurve: contentRect._opening ? Config.Appearance.anim.curves.standardDecel : Config.Appearance.anim.curves.standardAccel
47 }
48 }
49
50 ColumnLayout {
51 id: content
52 anchors.centerIn: parent
53 spacing: 12
54
55 Text {
56 Layout.alignment: Qt.AlignHCenter
57 color: Config.Colours.text
58 font.family: Config.Appearance.font.family
59 font.pixelSize: Config.Appearance.font.size.large
60 text: "Session"
61 }
62
63 Grid {
64 columns: 2
65 spacing: 8
66
67 Repeater {
68 model: [
69 { label: "Logout", icon: "\udb81\ude99", color: Config.Colours.yellow, cmd: "loginctl terminate-user $USER" },
70 { label: "Suspend", icon: "\udb81\udf86", color: Config.Colours.blue, cmd: "systemctl suspend" },
71 { label: "Reboot", icon: "\udb80\udd30", color: Config.Colours.peach, cmd: "systemctl reboot" },
72 { label: "Shutdown", icon: "\u23fb", color: Config.Colours.red, cmd: "systemctl poweroff" }
73 ]
74
75 delegate: Rectangle {
76 required property var modelData
77 width: 80; height: 80
78 radius: Config.Appearance.rounding.normal
79 color: sessionMouse.containsMouse ? Config.Colours.surface1 : Config.Colours.surface0
80 Behavior on color { CAnim {} }
81
82 ColumnLayout {
83 anchors.centerIn: parent
84 spacing: 4
85 Text { Layout.alignment: Qt.AlignHCenter; color: modelData.color; font.family: Config.Appearance.font.family; font.pixelSize: 24; text: modelData.icon }
86 Text { Layout.alignment: Qt.AlignHCenter; color: Config.Colours.subtext0; font.family: Config.Appearance.font.family; font.pixelSize: Config.Appearance.font.size.small; text: modelData.label }
87 }
88
89 MouseArea {
90 id: sessionMouse
91 anchors.fill: parent
92 hoverEnabled: true
93 cursorShape: Qt.PointingHandCursor
94 onClicked: { sessionPopout.close(); execProc.command = ["sh", "-c", modelData.cmd]; execProc.running = true }
95 }
96 }
97 }
98 }
99
100 Process { id: execProc }
101 }
102
103 Keys.onEscapePressed: sessionPopout.close()
104 }
105
106 MouseArea { anchors.fill: parent; z: -1; onClicked: sessionPopout.close() }
107}