Take BatteryGraph into use

This commit is contained in:
Matti Viljanen 2019-01-29 01:27:30 +02:00
parent 5914ff6488
commit 7d2e964e5a
No known key found for this signature in database
GPG key ID: CF32A1495158F888
2 changed files with 46 additions and 10 deletions

View file

@ -17,11 +17,43 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import Sailfish.Silica 1.0 import Sailfish.Silica 1.0
import "../components"
CoverBackground { CoverBackground {
id: coverPage
BatteryGraph {
id: batteryGraph
x: coverPage.width * 0.3
y: coverPage.width * 0.25
width: 0.4 * coverPage.width
onChargingChanged: onChargeChanged()
onChargeChanged: {
if(charge <= settings.lowerLimit && battery.state === "discharging") {
coverText.text = qsTr("Connect\ncharger")
}
else if(battery.charge >= settings.upperLimit &&
((battery.state === "charging" && battery.charging === true) || (battery.state === "idle" && battery.charging === false))) {
coverText.text = qsTr("Disconnect\ncharger")
}
else if(battery.charging) {
coverText.text = qsTr("Charging...")
}
else {
coverText.text = qsTr("Battery\nBuddy")
}
}
}
Label { Label {
id: label id: coverText
anchors.centerIn: parent anchors.top: batteryGraph.bottom
text: qsTr("Battery Buddy") anchors.bottom: coverPage.bottom
anchors.horizontalCenter: coverPage.horizontalCenter
width: coverPage.width * 0.9
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.Wrap
maximumLineCount: 2
} }
} }

View file

@ -121,13 +121,17 @@ Page {
text: qsTr("Battery status") text: qsTr("Battery status")
color: Theme.highlightColor color: Theme.highlightColor
} }
DetailItem { Item {
label: qsTr("Charge:")+"\n" width: parent.width
+qsTr("Charging:")+"\n" // Rotation: width <==> height
+qsTr("State:") height: batteryGraph.width
value: battery.charge+"%\n" BatteryGraph {
+(battery.charging ? qsTr("yes") : qsTr("no"))+"\n" id: batteryGraph
+statusText[battery.state] transformOrigin: Item.Center
rotation: 90
width: parent.width * 0.2
anchors.centerIn: parent
}
} }
// Detail column // Detail column
Column { Column {