Show details about charging session on home screen

This commit is contained in:
2024-09-14 22:17:05 +02:00
parent 21d87bf30b
commit 625c69e34c
3 changed files with 179 additions and 50 deletions

View File

@@ -70,6 +70,22 @@ AnimatedStackView {
}
Text {
ApiKeyValueHelper {
id: chargingDurationInfo
deviceConnection: theDeviceConnection
apiKey: "cdi"
}
ApiKeyValueHelper {
id: powerInfo
deviceConnection: theDeviceConnection
apiKey: "nrg"
}
ApiKeyValueHelper {
id: energyInfo
deviceConnection: theDeviceConnection
apiKey: "wh"
}
Layout.fillWidth: true
text: {
@@ -77,13 +93,45 @@ AnimatedStackView {
{
case 0: return null
case 1: return qsTr("Plug in the cable to start charging your car")
case 2: return "TODO duration"
case 2: return qsTr("Duration: %0").arg(getDurationInfo()) + "\n" +
qsTr("Speed: %0").arg(getChargingSpeed()) + "\n" +
qsTr("Amount: %0").arg(getChargingAmount())
case 3: return qsTr("Charger is connecting to your car, it usually takes a few seconds")
case 4: return qsTr("Let's go-e :)")
case 5: return null
}
}
wrapMode: Text.Wrap
function getDurationInfo() {
if (!chargingDurationInfo.exists)
return qsTr("(api key doesnt exist)")
if (typeof chargingDurationInfo.value == null)
return qsTr("(api key is null)")
if (typeof chargingDurationInfo.value !== 'object')
return qsTr("(api key is not an object)")
if (!('type' in chargingDurationInfo.value))
return qsTr("(api key does not contain a type)")
switch (chargingDurationInfo.value.type)
{
case 0: // counter going up, use rbt
return formatDuration(rebootTime.value - chargingDurationInfo.value.value)
case 1: // counter frozen, absolute duration
return formatDuration(chargingDurationInfo.value.value)
}
return qsTr("(api key has unknown type %0)").arg(chargingDurationInfo.value.type)
}
function getChargingSpeed() {
return qsTr("%0 %1 %2")
.arg(qsTr("%0 A").arg(Qt.locale().toString(powerInfo.value[4], 'f', 1)))
.arg(qsTr("%0 A").arg(Qt.locale().toString(powerInfo.value[5], 'f', 1)))
.arg(qsTr("%0 A").arg(Qt.locale().toString(powerInfo.value[6], 'f', 1)))
}
function getChargingAmount() {
return qsTr("%0 kWh").arg(Qt.locale().toString(energyInfo.value / 1000., 'f', 1))
}
}
}

View File

@@ -66,25 +66,30 @@ AnimatedStackView {
}
WhiteBox {
GridLayout {
colums: 3
Layout.fillWidth: true
Layout.preferredHeight: gridLayout.implicitHeight + 20
Pane {
Component.onCompleted: {
background.color = "white"
background.radius = 5
}
}
Pane {
Component.onCompleted: {
background.color = "white"
background.radius = 5
}
}
Pane {
Component.onCompleted: {
background.color = "white"
background.radius = 5
GridLayout {
id: gridLayout
anchors.fill: parent
columns: 3
Repeater {
model: 9
Pane {
Layout.fillWidth: true
Layout.preferredHeight: 50
Component.onCompleted: {
background.color = "grey"
background.radius = 5
}
Text {
anchors.fill: parent
text: qsTr("Category")
}
}
}
}
@@ -104,7 +109,7 @@ AnimatedStackView {
Text {
Layout.fillWidth: true
<
text: "Controller TODO"
}

View File

@@ -403,86 +403,156 @@
<translation>Unbekannter Fehler %0</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="79"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="79"/>
<location filename="../ChargerTabPage.qml" line="95"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="95"/>
<source>Plug in the cable to start charging your car</source>
<translation>Stecke das Kabel ein, um dein Auto aufzuladen</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="81"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="81"/>
<location filename="../ChargerTabPage.qml" line="96"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="96"/>
<source>Duration: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="97"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="97"/>
<source>Speed: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="98"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="98"/>
<source>Amount: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="99"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="99"/>
<source>Charger is connecting to your car, it usually takes a few seconds</source>
<translation>Der Charger stellt die Verbindung zu deinem Auto her, das dauert in der Regel ein paar Sekunden</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="82"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="82"/>
<location filename="../ChargerTabPage.qml" line="100"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="100"/>
<source>Let&apos;s go-e :)</source>
<translation>Let&apos;s go-e :)</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="154"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="154"/>
<location filename="../ChargerTabPage.qml" line="108"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="108"/>
<source>(api key doesnt exist)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="110"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="110"/>
<source>(api key is null)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="112"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="112"/>
<source>(api key is not an object)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="114"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="114"/>
<source>(api key does not contain a type)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="122"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="122"/>
<source>(api key has unknown type %0)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="126"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="126"/>
<source>%0 %1 %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="127"/>
<location filename="../ChargerTabPage.qml" line="128"/>
<location filename="../ChargerTabPage.qml" line="129"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="127"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="128"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="129"/>
<source>%0 A</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="133"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="133"/>
<source>%0 kWh</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="202"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="202"/>
<source>Price limit</source>
<translation>Preisgrenze</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="155"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="155"/>
<location filename="../ChargerTabPage.qml" line="203"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="203"/>
<source>%0 ct/kWh</source>
<translation>%0 ct/kWh</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="163"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="163"/>
<location filename="../ChargerTabPage.qml" line="211"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="211"/>
<source>By %0 with %1</source>
<translation>Bis %0 mit %1</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="163"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="163"/>
<location filename="../ChargerTabPage.qml" line="211"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="211"/>
<source>%0 km</source>
<translation>%0 km</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="181"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="181"/>
<location filename="../ChargerTabPage.qml" line="229"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="229"/>
<source>Charging speed</source>
<translation>Ladegeschwindigkeit</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="182"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="182"/>
<location filename="../ChargerTabPage.qml" line="230"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="230"/>
<source>%0 &amp; %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="183"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="183"/>
<location filename="../ChargerTabPage.qml" line="231"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="231"/>
<source>%0 Ampere</source>
<translation>%0 Ampere</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="187"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="187"/>
<location filename="../ChargerTabPage.qml" line="235"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="235"/>
<source>Automatic phase selection</source>
<translation>Automatische Phasenwahl</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="188"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="188"/>
<location filename="../ChargerTabPage.qml" line="236"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="236"/>
<source>1-phase</source>
<translation>1-phasig</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="189"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="189"/>
<location filename="../ChargerTabPage.qml" line="237"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="237"/>
<source>3-phase</source>
<translation>3-phasig</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="190"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="190"/>
<location filename="../ChargerTabPage.qml" line="238"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="238"/>
<source>Unknown phase selection (%0)</source>
<translation>Unbekannte Phasen Selektion (%0)</translation>
</message>
@@ -499,8 +569,8 @@
<translation type="vanished">Start</translation>
</message>
<message>
<location filename="../ChargerTabPage.qml" line="162"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="162"/>
<location filename="../ChargerTabPage.qml" line="210"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ChargerTabPage.qml" line="210"/>
<source>Daily trip</source>
<translation>Daily trip</translation>
</message>
@@ -787,6 +857,12 @@
<source>Connected</source>
<translation>Verbunden</translation>
</message>
<message>
<location filename="../ControllerTabPage.qml" line="91"/>
<location filename="../build/Desktop-Debug/EVChargerApp/ControllerTabPage.qml" line="91"/>
<source>Category</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CurrentLevelsPage</name>