Commit 3194b369 authored by Simon Schmeisser's avatar Simon Schmeisser

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.
parent 7310f828
......@@ -9,6 +9,10 @@
<entry name="AppletOrder" type="String">
<label>encoded order of items</label>
</entry>
<entry name="ShowPowerButton" type="Bool">
<default>true</default>
<label>optional power button</label>
</entry>
</group>
</kcfg>
......@@ -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;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment