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>
60 lines
1.8 KiB
QML
60 lines
1.8 KiB
QML
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import "../core"
|
|
|
|
Singleton {
|
|
id: root
|
|
// The action being held to confirm. Its button fills while this is set and
|
|
// confirm() runs it once full; cancel() (release, Escape, closing) drains.
|
|
property string pending: ""
|
|
function needsHold(action) {
|
|
return ["logout", "reboot", "shutdown"].includes(action);
|
|
}
|
|
function request(action) {
|
|
// The built-in lock screen needs no external locker.
|
|
if (action === "lock" && ConfigService.ready && ConfigService.data.lock.enabled) {
|
|
ShellState.requestLock();
|
|
return true;
|
|
}
|
|
if (!SystemService.state.power || !SystemService.state.power[action] || SystemService.acting)
|
|
return false;
|
|
if (needsHold(action)) {
|
|
pending = action;
|
|
return true;
|
|
}
|
|
if (!["lock", "suspend"].includes(action))
|
|
return false;
|
|
|
|
return SystemService.action("power", action, false);
|
|
}
|
|
function confirm() {
|
|
if (!pending || SystemService.acting)
|
|
return false;
|
|
const action = pending;
|
|
pending = "";
|
|
return SystemService.action("power", action, true);
|
|
}
|
|
function cancel() {
|
|
pending = "";
|
|
}
|
|
Connections {
|
|
target: ShellState
|
|
function onControlCenterOpenChanged() {
|
|
if (!ShellState.controlCenterOpen)
|
|
root.cancel();
|
|
}
|
|
function onNotchOpenChanged() {
|
|
if (!ShellState.notchOpen)
|
|
root.cancel();
|
|
}
|
|
function onSettingsPageChanged() {
|
|
root.cancel();
|
|
}
|
|
function onSettingsOpenChanged() {
|
|
if (!ShellState.settingsOpen)
|
|
root.cancel();
|
|
}
|
|
}
|
|
}
|