From 3194b36952b82cb9316595d539bb17b9661742df Mon Sep 17 00:00:00 2001 From: Simon Schmeisser Date: Wed, 6 Feb 2019 18:01:12 +0100 Subject: [PATCH] Add a shutdown button in the top drawer it uses the PowerDevil data engine to request a shutdown from ksmserver. Since ksmserver is not yet running on the images this also prints a debug message. Tested to work on desktop neon. --- .../panel/package/contents/config/main.xml | 4 ++++ .../ui/quicksettings/QuickSettings.qml | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/containments/panel/package/contents/config/main.xml b/containments/panel/package/contents/config/main.xml index 61a525b9..c8fc7596 100644 --- a/containments/panel/package/contents/config/main.xml +++ b/containments/panel/package/contents/config/main.xml @@ -9,6 +9,10 @@ + + true + + diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml index 00603a87..1932717b 100644 --- a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml @@ -33,6 +33,14 @@ Item { plasmoid.nativeInterface.toggleTorch() } + function requestShutdown() { + print("Shutdown requested, depends on ksmserver running"); + var service = pmSource.serviceForSource("PowerDevil"); + //note the strange camelCasing is intentional + var operation = service.operationDescription("requestShutDown"); + return service.startOperationCall(operation); + } + function addPlasmoid(applet) { settingsModel.append({"icon": applet.icon, "text": applet.title, @@ -107,6 +115,18 @@ Item { "settingsCommand": "", "applet": null }); + if (plasmoid.configuration.ShowPowerButton) { + settingsModel.append({ + "text": i18n("Shutdown"), + "icon": "system-shutdown-symbolic", + "enabled": false, + "settingsCommand": "", + "toggleFunction": "requestShutdown", + "plasmoidId": -1, + "applet": null + }); + } + brightnessSlider.valueChanged.connect(function() { root.screenBrightness = brightnessSlider.value; });