Merge PR #687: Fix layout issues in smart meter views

This commit is contained in:
Jenkins nymea 2021-10-01 12:54:48 +02:00
commit 2b59a118b7
2 changed files with 10 additions and 8 deletions

View File

@ -42,6 +42,7 @@ ThingPageBase {
readonly property State maxChargingCurrentState: thing.stateByName("maxChargingCurrent") readonly property State maxChargingCurrentState: thing.stateByName("maxChargingCurrent")
readonly property StateType maxChargingCurrentStateType: thing.thingClass.stateTypes.findByName("maxChargingCurrent") readonly property StateType maxChargingCurrentStateType: thing.thingClass.stateTypes.findByName("maxChargingCurrent")
readonly property State currentPowerState: thing.stateByName("currentPower") readonly property State currentPowerState: thing.stateByName("currentPower")
readonly property State pluggedInState: thing.stateByName("pluggedIn")
ActionQueue { ActionQueue {
id: actionQueue id: actionQueue
@ -110,10 +111,12 @@ ThingPageBase {
property double currentPower: root.currentPowerState.value / (root.currentPowerState.value > 1000 ? 1000 : 1) property double currentPower: root.currentPowerState.value / (root.currentPowerState.value > 1000 ? 1000 : 1)
property string unit: root.currentPowerState.value > 1000 ? "kW" : "W" property string unit: root.currentPowerState.value > 1000 ? "kW" : "W"
font: Style.smallFont font: Style.smallFont
text: qsTr("Currently charging at %1.") text: root.pluggedInState.value === false
.arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' ? qsTr("The car is not plugged in.")
+ (currentPower.toFixed(1)) : root.powerState.value === true
+ '</span>' + ' ' + unit) ? qsTr("Currently charging at %1.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (currentPower.toFixed(1)) + '</span>' + ' ' + unit)
: ""
textFormat: Text.RichText textFormat: Text.RichText
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap

View File

@ -218,7 +218,7 @@ ThingPageBase {
text: isCharging ? qsTr("At the current rate, the battery will be fully charged at %1.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + endTime.toLocaleTimeString(Locale.ShortFormat) + "</span>") text: isCharging ? qsTr("At the current rate, the battery will be fully charged at %1.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + endTime.toLocaleTimeString(Locale.ShortFormat) + "</span>")
: isDischarging ? qsTr("At the current rate, the battery will last until %1.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + endTime.toLocaleTimeString(Locale.ShortFormat) + "</span>") : isDischarging ? qsTr("At the current rate, the battery will last until %1.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + endTime.toLocaleTimeString(Locale.ShortFormat) + "</span>")
: qsTr("The battery is fully charged") : ""
} }
BlurredLabel { BlurredLabel {
@ -235,8 +235,7 @@ ThingPageBase {
LogsModel { LogsModel {
id: periodConsumptionModel id: periodConsumptionModel
objectName: "Root meter model" engine: root.isEnergyMeter || root.isConsumer ? _engine : null
engine: root.isEnergyMeter ? _engine : null
thingId: root.thing.id thingId: root.thing.id
typeIds: isEnergyMeter ? [root.totalEnergyConsumedStateType.id] : [] typeIds: isEnergyMeter ? [root.totalEnergyConsumedStateType.id] : []
viewStartTime: root.startTime viewStartTime: root.startTime
@ -260,7 +259,7 @@ ThingPageBase {
LogsModel { LogsModel {
id: periodProductionModel id: periodProductionModel
engine: root.isEnergyMeter ? _engine : null engine: root.isEnergyMeter || root.isProducer ? _engine : null
thingId: root.thing.id thingId: root.thing.id
typeIds: isEnergyMeter ? [root.totalEnergyProducedStateType.id] : [] typeIds: isEnergyMeter ? [root.totalEnergyProducedStateType.id] : []
viewStartTime: root.startTime viewStartTime: root.startTime