Files
att_menu/modules/ConfirmDialog.qml
T
2026-07-26 21:16:55 +02:00

149 lines
4.1 KiB
QML

import Quickshell
import Quickshell.Wayland
import QtQuick
import qs.config
// Confirmation for session actions. Same full-screen layer surface approach as
// the launcher, so Escape and click-away work everywhere.
PanelWindow {
id: root
required property var bar
property string actionLabel: ""
signal accepted
visible: false
screen: root.bar.screen
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: Config.namespace + "-confirm"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
anchors {
left: true
right: true
top: true
bottom: true
}
exclusionMode: ExclusionMode.Ignore
color: "#66000000"
function accept(): void {
root.visible = false;
root.accepted();
}
onVisibleChanged: if (root.visible)
keyHandler.forceActiveFocus()
MouseArea {
anchors.fill: parent
onClicked: root.visible = false
}
Item {
id: keyHandler
anchors.fill: parent
focus: true
Keys.onEscapePressed: root.visible = false
Keys.onReturnPressed: root.accept()
Keys.onEnterPressed: root.accept()
}
Rectangle {
anchors.centerIn: parent
width: Math.min(320, root.width - Theme.padding * 4)
implicitHeight: dialogColumn.implicitHeight + Theme.padding * 6
radius: Theme.radius * 2
color: Theme.surface
border.width: Theme.borderWidth
border.color: Theme.border
MouseArea {
anchors.fill: parent
}
Column {
id: dialogColumn
anchors.centerIn: parent
width: parent.width - Theme.padding * 6
spacing: Theme.padding * 3
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
text: root.actionLabel + "?"
color: Theme.text
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSize + 2
font.bold: true
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: Theme.padding * 2
Rectangle {
id: cancel
implicitWidth: 100
implicitHeight: 32
radius: Theme.radius
color: cancelMouse.containsMouse ? Theme.surfaceHover : Theme.background
border.width: Theme.borderWidth
border.color: Theme.border
Text {
anchors.centerIn: parent
text: "Cancel"
color: Theme.text
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSize
}
MouseArea {
id: cancelMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.visible = false
}
}
Rectangle {
id: accept
implicitWidth: 100
implicitHeight: 32
radius: Theme.radius
color: acceptMouse.containsMouse ? Qt.lighter(Theme.danger, 1.15) : Theme.danger
Text {
anchors.centerIn: parent
text: "Confirm"
color: Theme.background
font.family: Theme.fontFamily
font.pixelSize: Theme.fontSize
font.bold: true
}
MouseArea {
id: acceptMouse
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: root.accept()
}
}
}
}
}
}