mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
Re-enable brightness slider
Some of logic copied from battery monitor to avoid updates at start.
This commit is contained in:
parent
19c18b51ba
commit
ee00e6a0bf
1 changed files with 45 additions and 1 deletions
|
|
@ -22,7 +22,6 @@ import QtQuick.Layouts 1.1
|
|||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
|
|
@ -42,6 +41,34 @@ Item {
|
|||
signal plasmoidTriggered(var applet, var id)
|
||||
Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2
|
||||
|
||||
property int screenBrightness
|
||||
property bool disableBrightnessUpdate: true
|
||||
readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0
|
||||
|
||||
onScreenBrightnessChanged: {
|
||||
if(!disableBrightnessUpdate) {
|
||||
var service = pmSource.serviceForSource("PowerDevil");
|
||||
var operation = service.operationDescription("setBrightness");
|
||||
operation.brightness = screenBrightness;
|
||||
operation.silent = true
|
||||
service.startOperationCall(operation);
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: pmSource
|
||||
engine: "powermanagement"
|
||||
connectedSources: ["PowerDevil"]
|
||||
onSourceAdded: {
|
||||
if (source === "PowerDevil") {
|
||||
disconnectSource(source);
|
||||
connectSource(source);
|
||||
}
|
||||
}
|
||||
onDataChanged: {
|
||||
root.screenBrightness = pmSource.data["PowerDevil"]["Screen Brightness"];
|
||||
}
|
||||
}
|
||||
//HACK: make the list know about the applet delegate which is a qtobject
|
||||
QtObject {
|
||||
id: nullApplet
|
||||
|
|
@ -76,6 +103,10 @@ Item {
|
|||
"plasmoidId": -1,
|
||||
"applet": null
|
||||
});
|
||||
brightnessSlider.valueChanged.connect(function() {
|
||||
root.screenBrightness = brightnessSlider.value;
|
||||
});
|
||||
disableBrightnessUpdate = false;
|
||||
}
|
||||
|
||||
ListModel {
|
||||
|
|
@ -104,5 +135,18 @@ Item {
|
|||
properties: "x,y"
|
||||
}
|
||||
}
|
||||
|
||||
BrightnessItem {
|
||||
id: brightnessSlider
|
||||
width: flow.width
|
||||
icon: "video-display-brightness"
|
||||
label: i18n("Display Brightness")
|
||||
value: root.screenBrightness
|
||||
maximumValue: root.maximumScreenBrightness
|
||||
Connections {
|
||||
target: root
|
||||
onScreenBrightnessChanged: brightnessSlider.value = root.screenBrightness
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue