Hold power actions to confirm instead of a confirm row

Logout, reboot and shut down now fill with accent liquid while held and
run once full; letting go early drains it. A tap hints to hold. Replaces
the Confirm/Cancel rows in the control center tile and dashboard tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mxandClaude Opus 5.5 committed 2026-11-28 01:05:11 +01:00
1 parent 1e918414d1
commit d37f9b7121
10 files changed
+350 -102

No files matched your search

+24 -1
View File
@@ -1,4 +1,5 @@
import QtQuick
import "../components"
import "../theme"
// Round glyph button used by the media controls and the power tab.
@@ -12,7 +13,17 @@ Rectangle {
property bool active: false
property bool danger: false
property bool interactive: true
// Hold-to-confirm: liquid fills the button while held, held() fires once
// full and clicked() is not emitted.
property bool hold: false
// Callers may withhold filling, e.g. until an action is pending.
property bool armed: true
readonly property bool holding: hold && armed && area.pressed && area.containsMouse
readonly property bool pressed: area.pressed
readonly property bool filled: fill.active
signal clicked
signal held
signal holdCancelled
implicitWidth: size
implicitHeight: size
radius: size / 2
@@ -42,13 +53,25 @@ Rectangle {
font.pixelSize: Math.round(root.size * root.glyphScale)
color: root.accented ? Theme.accentText : root.active ? Theme.accentVivid : Theme.text
}
HoldFill {
id: fill
anchors.fill: parent
visible: root.hold
holding: root.holding
glyph: root.glyph
fallback: root.fallback
glyphSize: Math.round(root.size * root.glyphScale)
onCompleted: root.held()
onCancelled: root.holdCancelled()
}
MouseArea {
id: area
anchors.fill: parent
hoverEnabled: true
enabled: root.interactive
cursorShape: Qt.PointingHandCursor
onClicked: root.clicked()
onClicked: if (!root.hold)
root.clicked()
}
Accessible.role: Accessible.Button
}
+24 -38
View File
@@ -4,12 +4,12 @@ import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import ".."
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
// Lock, restart and shut down. Restart and shut down ask for confirmation.
// Lock, restart and shut down. Restart and shut down are held to confirm:
// accent liquid fills the button, then the action runs.
Item {
id: root
property bool current: false
@@ -106,7 +106,14 @@ Item {
id: action
required property var modelData
readonly property bool armed: PowerService.pending === modelData.id
// A tap on a hold button says to hold it, in place of the label.
property bool hint: false
spacing: 10
Timer {
id: hintTimer
interval: 1600
onTriggered: action.hint = false
}
DashButton {
objectName: "dashPower-" + action.modelData.id
anchors.horizontalCenter: parent.horizontalCenter
@@ -114,53 +121,32 @@ Item {
glyphScale: 0.36
glyph: action.modelData.glyph
fallback: action.modelData.fallback
active: action.armed
danger: action.modelData.id !== "lock"
hold: PowerService.needsHold(action.modelData.id)
armed: action.armed
interactive: root.available(action.modelData.id)
onClicked: root.run(action.modelData.id)
Accessible.name: action.modelData.label
onPressedChanged: if (hold) {
if (pressed)
PowerService.request(action.modelData.id);
else if (action.armed)
PowerService.cancel();
}
onHeld: PowerService.confirm()
onHoldCancelled: {
action.hint = true;
hintTimer.restart();
}
Accessible.name: hold ? "Hold to " + action.modelData.label.toLowerCase() : action.modelData.label
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: action.modelData.label
text: action.hint ? "Hold to " + action.modelData.label.toLowerCase() : action.modelData.label
color: action.armed ? Theme.text : Theme.textSecondary
font.pixelSize: 13
}
}
}
}
RowLayout {
id: confirm
Layout.fillWidth: true
spacing: 8
readonly property var pending: root.actions.find(a => a.id === PowerService.pending)
opacity: pending ? 1 : 0
visible: opacity > 0
Behavior on opacity {
NumberAnimation {
duration: Theme.duration
}
}
Text {
text: confirm.pending ? confirm.pending.label + " now? Unsaved work may be lost." : ""
color: Theme.text
font.pixelSize: 12
wrapMode: Text.Wrap
Layout.fillWidth: true
}
GlassButton {
objectName: "dashPowerCancel"
text: "Cancel"
onClicked: PowerService.cancel()
}
GlassButton {
objectName: "dashPowerConfirm"
text: confirm.pending ? confirm.pending.label : "Confirm"
accented: true
enabled: !SystemService.acting
onClicked: PowerService.confirm()
}
}
}
}
}