initial commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import qs.config
|
||||
import qs.components
|
||||
import qs.services
|
||||
|
||||
// Right section: the session button. The actions live in PowerPanel.qml as a
|
||||
// separate layer surface; running them, and confirming the destructive ones,
|
||||
// stays here so the confirmation outlives the menu closing.
|
||||
Item {
|
||||
id: root
|
||||
|
||||
required property var bar
|
||||
|
||||
implicitWidth: button.implicitWidth
|
||||
|
||||
property var pendingAction: null
|
||||
|
||||
function trigger(action: var): void {
|
||||
if (action.dangerous && Config.confirmDangerous) {
|
||||
root.pendingAction = action;
|
||||
confirm.visible = true;
|
||||
} else {
|
||||
root.run(action);
|
||||
}
|
||||
}
|
||||
|
||||
function run(action: var): void {
|
||||
Quickshell.execDetached(action.command);
|
||||
}
|
||||
|
||||
PanelButton {
|
||||
id: button
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
height: root.height - Theme.spacing
|
||||
minContentWidth: Theme.iconSize
|
||||
active: panel.visible
|
||||
activeColor: Theme.accent
|
||||
|
||||
onClicked: Session.toggle("power", panel.screenName)
|
||||
|
||||
AppIcon {
|
||||
icon: "system-shutdown"
|
||||
fallbackGlyph: "⏻"
|
||||
glyphColor: button.active ? Theme.background : Theme.text
|
||||
size: Theme.iconSize
|
||||
}
|
||||
}
|
||||
|
||||
PowerPanel {
|
||||
id: panel
|
||||
|
||||
bar: root.bar
|
||||
|
||||
onTriggered: action => root.trigger(action)
|
||||
}
|
||||
|
||||
ConfirmDialog {
|
||||
id: confirm
|
||||
|
||||
bar: root.bar
|
||||
actionLabel: root.pendingAction ? root.pendingAction.label : ""
|
||||
|
||||
onAccepted: {
|
||||
const action = root.pendingAction;
|
||||
root.pendingAction = null;
|
||||
if (action)
|
||||
root.run(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user