import QtQuick import QtQuick.Layouts import Quickshell import Quickshell.Wayland import "." PanelWindow { id: root required property QtObject theme required property QtObject commands property bool open: false property string pendingAction: "" // This is the future CTRL+ALT+Delete target. It improves on hyprshutdown by // making destructive/session actions two-step while keeping execution gated. visible: open focusable: open anchors { top: true; left: true; right: true } margins { top: 96 } exclusiveZone: -1 implicitHeight: 250 color: "transparent" WlrLayershell { layer: WlrLayer.Overlay namespace: "nugu-power-menu" keyboardFocus: root.open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None } function show(): string { pendingAction = "" open = true return "open" } function close(): void { open = false pendingAction = "" } function request(action: string): string { pendingAction = action open = true return pendingAction } function confirm(): string { if (pendingAction.length === 0) return "none" const result = commands.confirmedPower(pendingAction) pendingAction = "" open = false return result } function label(action: string): string { if (action === "poweroff") return "power off" if (action === "reboot") return "reboot" if (action === "logout") return "log out" if (action === "sleep") return "sleep" if (action === "lock") return "lock" return "choose" } MouseArea { anchors.fill: parent onClicked: root.close() } Rectangle { anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter width: Math.min(parent.width - 32, 480) height: parent.height radius: 14 color: `${theme.ui.backdrop}f2` border.width: 2 border.color: pendingAction === "reboot" || pendingAction === "poweroff" ? theme.error : theme.ui.accent ColumnLayout { anchors.fill: parent anchors.margins: 14 spacing: 10 Text { Layout.fillWidth: true text: pendingAction.length === 0 ? "Power" : `Confirm ${root.label(root.pendingAction)}` color: pendingAction === "reboot" || pendingAction === "poweroff" ? theme.error : theme.ui.important_global font.family: "IBM Plex Sans" font.pixelSize: 20 font.bold: true horizontalAlignment: Text.AlignHCenter } Text { Layout.fillWidth: true text: commands.executeConfirmedPowerActions ? "Confirmed action will execute." : "Confirmed non-lock actions are dry-run until parity approval." color: theme.ui.minor font.family: "IBM Plex Mono" font.pixelSize: 12 horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap } GridLayout { Layout.fillWidth: true columns: 2 rowSpacing: 8 columnSpacing: 8 visible: pendingAction.length === 0 StatusItem { theme: root.theme; text: "󰌾 lock"; minWidth: 210; onLeftClicked: root.request("lock") } StatusItem { theme: root.theme; text: "󰤄 sleep"; minWidth: 210; muted: true; onLeftClicked: root.request("sleep") } StatusItem { theme: root.theme; text: "󰍃 out"; minWidth: 210; muted: true; onLeftClicked: root.request("logout") } StatusItem { theme: root.theme; text: "󰜉 reboot"; minWidth: 210; critical: true; onLeftClicked: root.request("reboot") } StatusItem { theme: root.theme; text: "󰐥 off"; minWidth: 210; critical: true; onLeftClicked: root.request("poweroff") } } RowLayout { Layout.fillWidth: true visible: pendingAction.length > 0 spacing: 8 StatusItem { theme: root.theme text: "cancel" minWidth: 210 onLeftClicked: root.pendingAction = "" } StatusItem { theme: root.theme text: `confirm ${root.label(root.pendingAction)}` minWidth: 210 critical: root.pendingAction === "reboot" || root.pendingAction === "poweroff" warning: root.pendingAction === "sleep" || root.pendingAction === "logout" onLeftClicked: root.confirm() } } } } Shortcut { sequence: "Escape" onActivated: root.close() } }