diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/launcher/ActionItem.qml | 12 | ||||
| -rw-r--r-- | modules/launcher/Actions.qml | 68 |
2 files changed, 77 insertions, 3 deletions
diff --git a/modules/launcher/ActionItem.qml b/modules/launcher/ActionItem.qml index db3242a..720b272 100644 --- a/modules/launcher/ActionItem.qml +++ b/modules/launcher/ActionItem.qml @@ -31,7 +31,9 @@ Item { MaterialIcon { id: icon - text: root.modelData?.icon ?? "" + text: root.modelData?.disabled + ? "disabled_by_default" + : (root.modelData?.icon ?? "") font.pointSize: Appearance.font.size.extraLarge anchors.verticalCenter: parent.verticalCenter @@ -48,14 +50,18 @@ Item { StyledText { id: name - text: root.modelData?.name ?? "" + text: root.modelData?.disabled + ? (root.modelData?.name ?? "") + " - Disabled" + : (root.modelData?.name ?? "") font.pointSize: Appearance.font.size.normal } StyledText { id: desc - text: root.modelData?.desc ?? "" + text: root.modelData?.disabled + ? (root.modelData?.disabledReason ?? "") + : (root.modelData?.desc ?? "") font.pointSize: Appearance.font.size.small color: Colours.alpha(Colours.palette.m3outline, true) diff --git a/modules/launcher/Actions.qml b/modules/launcher/Actions.qml index beb77a5..1f6e72b 100644 --- a/modules/launcher/Actions.qml +++ b/modules/launcher/Actions.qml @@ -68,6 +68,39 @@ Singleton { } }, Action { + name: qsTr("Shutdown") + desc: qsTr("Shutdown the system") + icon: "power_settings_new" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") + + function onClicked(list: AppList): void { + root.handleDangerousAction(list, shutdown); + } + }, + Action { + name: qsTr("Reboot") + desc: qsTr("Reboot the system") + icon: "cached" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") + + function onClicked(list: AppList): void { + root.handleDangerousAction(list, reboot); + } + }, + Action { + name: qsTr("Logout") + desc: qsTr("Logout of the current session") + icon: "exit_to_app" + disabled: !LauncherConfig.allowDangerousActions + disabledReason: qsTr("Enable dangerous actions in config/LauncherConfig.qml first") + + function onClicked(list: AppList): void { + root.handleDangerousAction(list, logout); + } + }, + Action { name: qsTr("Lock") desc: qsTr("Lock the current session") icon: "lock" @@ -107,6 +140,39 @@ Singleton { list.search.text = `${Config.launcher.actionPrefix}${text} `; } + function handleDangerousAction(list: AppList, process: QtObject): void { + list.visibilities.launcher = false; + if (!LauncherConfig.allowDangerousActions) { + dangerousActions.running = true; + return; + } + process.running = true; + } + + Process { + id: dangerousActions + + command: ["notify-send", "Quickshell", qsTr("Enable dangerous actions in config/LauncherConfig.qml to use this action."), "-i", "dialog-warning"] + } + + Process { + id: shutdown + + command: ["systemctl", "poweroff"] + } + + Process { + id: reboot + + command: ["systemctl", "reboot"] + } + + Process { + id: logout + + command: ["sh", "-c", "(uwsm stop | grep -q 'Compositor is not running' && loginctl terminate-user $USER) || uwsm stop"] + } + Process { id: lock @@ -123,6 +189,8 @@ Singleton { required property string name required property string desc required property string icon + property bool disabled + property string disabledReason function onClicked(list: AppList): void { } |