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:
1 parent
1e918414d1
commit
d37f9b7121
10 files changed
+350
-102
No files matched your search
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user