Commit 471cc374 authored by Nate Graham's avatar Nate Graham
Browse files

applets/batterymonitor: fix CompactRepresentation

f9e39815 introduced a few regressions by
blowing away the custom CompactRepresentation when there are no
batteries. This introduced a race condition that sometimes set the icon
incorrectly and also broke scrolling on the applet to change the volume.

This commit fixes those issues by using the existing infrastructure for
the CompactPepresentation, but simply swapping out its custom battery
icon for normal icon when there are no batteries.
parent 6f5a2866
Pipeline #122046 passed with stage
in 4 minutes and 29 seconds
......@@ -18,6 +18,7 @@ MouseArea {
property real itemSize: Math.min(root.height, root.width/view.count)
readonly property bool isConstrained: plasmoid.formFactor === PlasmaCore.Types.Vertical || plasmoid.formFactor === PlasmaCore.Types.Horizontal
property real brightnessError: 0
property bool hasBatteries: true
onClicked: plasmoid.expanded = !plasmoid.expanded
......@@ -44,8 +45,17 @@ MouseArea {
batterymonitor.screenBrightness = Math.max(minimumBrightness, Math.min(maximumBrightness, newBrightness));
}
// "No Batteries" case
PlasmaCore.IconItem {
anchors.fill: parent
visible: !root.hasBatteries
source: plasmoid.icon
}
// We have any batteries; show their status
//Should we consider turning this into a Flow item?
Row {
visible: root.hasBatteries
anchors.centerIn: parent
Repeater {
id: view
......
......@@ -219,11 +219,9 @@ Item {
}
}
Component {
id: batteryCompact
CompactRepresentation {}
Plasmoid.compactRepresentation: CompactRepresentation {
hasBatteries: batterymonitor.hasBatteries
}
Plasmoid.compactRepresentation: hasBatteries ? batteryCompact : null
readonly property bool isBrightnessAvailable: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Screen Brightness Available"] ? true : false
......
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