add percentage for the battery

battery shows percentage in the panel, panel
suports rectangular items
This commit is contained in:
Marco Martin 2016-01-25 11:08:25 +01:00
parent 1c8a653b1d
commit 8cef8fe532
2 changed files with 42 additions and 11 deletions

View file

@ -23,6 +23,7 @@ import QtQuick 2.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.workspace.components 2.0 import org.kde.plasma.workspace.components 2.0
@ -115,16 +116,46 @@ Item {
return status; return status;
} }
Plasmoid.compactRepresentation: BatteryIcon { Plasmoid.compactRepresentation: MouseArea {
Layout.minimumWidth: batteryLayout.implicitWidth
Layout.minimumHeight: batteryLayout.implicitHeight
property bool wasExpanded: false
onPressed: {
if (mouse.button == Qt.LeftButton) {
wasExpanded = plasmoid.expanded;
} else if (mouse.button == Qt.MiddleButton) {
muteVolume();
}
}
onClicked: {
if (mouse.button == Qt.LeftButton) {
plasmoid.expanded = !wasExpanded;
}
}
RowLayout {
id: batteryLayout
anchors.fill: parent
PlasmaComponents.Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: pmSource.data["Battery"]["Percent"]
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
BatteryIcon {
id: batteryIcon id: batteryIcon
Layout.minimumHeight: units.iconSizes.small Layout.minimumWidth: height
anchors.horizontalCenter: parent.horizontalCenter Layout.maximumWidth: height
Layout.fillHeight: true
hasBattery: true hasBattery: true
percent: pmSource.data["Battery"]["Percent"] percent: pmSource.data["Battery"]["Percent"]
//pluggedIn: batteryContainer.pluggedIn //pluggedIn: batteryContainer.pluggedIn
// height: batteryContainer.iconSize // height: batteryContainer.iconSize
// width: height // width: height
} }
}
}
Plasmoid.fullRepresentation: ExpandedRepresentation { Plasmoid.fullRepresentation: ExpandedRepresentation {

View file

@ -90,8 +90,8 @@ PlasmaCore.ColorScope {
property bool animationsEnabled: false property bool animationsEnabled: false
property Item applet property Item applet
Layout.fillHeight: true Layout.fillHeight: true
Layout.minimumWidth: appletIconsRow.height Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height
Layout.maximumWidth: appletIconsRow.height Layout.maximumWidth: Layout.minimumWidth
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent