Fix Compact Representation which broke in fa52f0f737

CCMAIL: aleixpol@kde.org
wilder-5.14
Kai Uwe Broulik 12 years ago
parent bb6eabc0c9
commit 9cbd9290ca
  1. 82
      applets/batterymonitor/contents/ui/CompactRepresentation.qml

@ -26,68 +26,66 @@ import org.kde.plasma.components 2.0 as Components
import org.kde.plasma.workspace.components 2.0 import org.kde.plasma.workspace.components 2.0
import "plasmapackage:/code/logic.js" as Logic import "plasmapackage:/code/logic.js" as Logic
//Should we consider turning this into a Flow item? MouseArea {
Row {
id: root id: root
Layout.minimumWidth: isConstrained() ? units.iconSizes.medium : 24 // NOTE: Keep in sync with systray Layout.minimumWidth: isConstrained() ? units.iconSizes.medium : 24 // NOTE: Keep in sync with systray
Layout.minimumHeight: isConstrained() ? units.iconSizes.medium * view.count : 24 Layout.minimumHeight: isConstrained() ? units.iconSizes.medium * view.count : 24
property real itemSize: Math.min(root.height, root.width/view.count) property real itemSize: Math.min(root.height, root.width/view.count)
onClicked: plasmoid.expanded = !plasmoid.expanded
function isConstrained() { function isConstrained() {
return (plasmoid.formFactor == PlasmaCore.Types.Vertical || plasmoid.formFactor == PlasmaCore.Types.Horizontal) return (plasmoid.formFactor == PlasmaCore.Types.Vertical || plasmoid.formFactor == PlasmaCore.Types.Horizontal)
} }
MouseArea { //Should we consider turning this into a Flow item?
anchors.fill: parent Row {
onClicked: plasmoid.expanded = !plasmoid.expanded Repeater {
} id: view
Repeater {
id: view
anchors.fill: parent
property bool hasBattery: pmSource.data["Battery"]["Has Battery"] property bool hasBattery: pmSource.data["Battery"]["Has Battery"]
/*property QtObject pmSource: batterymonitor.pmSource /*property QtObject pmSource: batterymonitor.pmSource
property QtObject batteries: batterymonitor.batteries*/ property QtObject batteries: batterymonitor.batteries*/
property bool singleBattery: isConstrained() || !hasBattery property bool singleBattery: isConstrained() || !hasBattery
model: singleBattery ? 1 : batteries model: singleBattery ? 1 : batteries
delegate: Item { Item {
id: batteryContainer id: batteryContainer
property bool hasBattery: view.singleBattery ? batteries.count : model["Plugged in"] property bool hasBattery: view.singleBattery ? batteries.count : model["Plugged in"]
property int percent: view.singleBattery ? batteries.cumulativePercent : model["Percent"] property int percent: view.singleBattery ? batteries.cumulativePercent : model["Percent"]
property bool pluggedIn: pmSource.data["AC Adapter"] != undefined && pmSource.data["AC Adapter"]["Plugged in"] && (view.singleBattery || model["Is Power Supply"]) property bool pluggedIn: view.singleBattery ? batteries.charging : (model["Is Power Supply"] && model["State"] != "Discharging")
height: root.itemSize height: root.itemSize
width: root.width/view.count width: root.width/view.count
property real iconSize: Math.min(width, height) property real iconSize: Math.min(width, height)
Column { Column {
anchors.centerIn: parent anchors.centerIn: parent
BatteryIcon { BatteryIcon {
id: batteryIcon id: batteryIcon
anchors.horizontalCenter: isConstrained() ? undefined : parent.horizontalCenter anchors.horizontalCenter: isConstrained() ? undefined : parent.horizontalCenter
hasBattery: batteryContainer.hasBattery hasBattery: batteryContainer.hasBattery
percent: batteryContainer.percent percent: batteryContainer.percent
pluggedIn: batteryContainer.pluggedIn pluggedIn: batteryContainer.pluggedIn
height: isConstrained() ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height height: isConstrained() ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height
width: height width: height
} }
Components.Label { Components.Label {
id: batteryLabel id: batteryLabel
width: parent.width width: parent.width
height: visible ? paintedHeight : 0 height: visible ? paintedHeight : 0
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
text: i18nc("battery percentage below battery icon", "%1%", percent) text: i18nc("battery percentage below battery icon", "%1%", percent)
font.pixelSize: Math.max(batteryContainer.iconSize/8, theme.mSize(theme.smallestFont).height) font.pixelSize: Math.max(batteryContainer.iconSize/8, theme.mSize(theme.smallestFont).height)
visible: false//!isConstrained() visible: false//!isConstrained()
}
} }
} }
} }

Loading…
Cancel
Save