mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-28 14:43:09 +00:00
add percentage for the battery
battery shows percentage in the panel, panel suports rectangular items
This commit is contained in:
parent
1c8a653b1d
commit
8cef8fe532
2 changed files with 42 additions and 11 deletions
|
|
@ -23,6 +23,7 @@ import QtQuick 2.2
|
|||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
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
|
||||
|
||||
|
||||
|
|
@ -115,15 +116,45 @@ Item {
|
|||
return status;
|
||||
}
|
||||
|
||||
Plasmoid.compactRepresentation: BatteryIcon {
|
||||
id: batteryIcon
|
||||
Layout.minimumHeight: units.iconSizes.small
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
hasBattery: true
|
||||
percent: pmSource.data["Battery"]["Percent"]
|
||||
//pluggedIn: batteryContainer.pluggedIn
|
||||
// height: batteryContainer.iconSize
|
||||
// width: height
|
||||
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
|
||||
Layout.minimumWidth: height
|
||||
Layout.maximumWidth: height
|
||||
Layout.fillHeight: true
|
||||
hasBattery: true
|
||||
percent: pmSource.data["Battery"]["Percent"]
|
||||
//pluggedIn: batteryContainer.pluggedIn
|
||||
// height: batteryContainer.iconSize
|
||||
// width: height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Plasmoid.fullRepresentation: ExpandedRepresentation {
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ PlasmaCore.ColorScope {
|
|||
property bool animationsEnabled: false
|
||||
property Item applet
|
||||
Layout.fillHeight: true
|
||||
Layout.minimumWidth: appletIconsRow.height
|
||||
Layout.maximumWidth: appletIconsRow.height
|
||||
Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height
|
||||
Layout.maximumWidth: Layout.minimumWidth
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
|
|||
Loading…
Reference in a new issue