Improve ev charger view and minor fixes in similar views
This commit is contained in:
parent
4619d257c0
commit
006c449fa2
@ -9,6 +9,7 @@ Item {
|
|||||||
implicitHeight: label.implicitHeight + Style.margins * 2
|
implicitHeight: label.implicitHeight + Style.margins * 2
|
||||||
|
|
||||||
property alias text: label.text
|
property alias text: label.text
|
||||||
|
property alias font: label.font
|
||||||
property alias wrapMode: label.wrapMode
|
property alias wrapMode: label.wrapMode
|
||||||
property alias horizontalAlignment: label.horizontalAlignment
|
property alias horizontalAlignment: label.horizontalAlignment
|
||||||
property alias textFormat: label.textFormat
|
property alias textFormat: label.textFormat
|
||||||
|
|||||||
@ -42,6 +42,7 @@ Item {
|
|||||||
property alias iconSource: icon.name
|
property alias iconSource: icon.name
|
||||||
property color onColor: Style.accentColor
|
property color onColor: Style.accentColor
|
||||||
property bool on: false
|
property bool on: false
|
||||||
|
property alias showOnGradient: opacityMask.visible
|
||||||
|
|
||||||
readonly property Item contentItem: background
|
readonly property Item contentItem: background
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ Item {
|
|||||||
property StateType stateType: thing ? thing.thingClass.stateTypes.findByName(stateName) : null
|
property StateType stateType: thing ? thing.thingClass.stateTypes.findByName(stateName) : null
|
||||||
|
|
||||||
property color color: Style.accentColor
|
property color color: Style.accentColor
|
||||||
|
property bool on: true
|
||||||
property int precision: 1
|
property int precision: 1
|
||||||
|
|
||||||
readonly property State progressState: thing ? thing.states.getState(stateType.id) : null
|
readonly property State progressState: thing ? thing.states.getState(stateType.id) : null
|
||||||
@ -49,8 +50,8 @@ Item {
|
|||||||
|
|
||||||
property int startAngle: 135
|
property int startAngle: 135
|
||||||
property int maxAngle: 270
|
property int maxAngle: 270
|
||||||
readonly property int steps: canvas.roundToPrecision(root.stateType.maxValue - root.stateType.minValue) / root.precision + 1
|
readonly property int steps: canvas.roundToPrecision(root.progressState.maxValue - root.progressState.minValue) / root.precision + 1
|
||||||
readonly property double stepSize: (root.stateType.maxValue - root.stateType.minValue) / steps
|
readonly property double stepSize: (root.progressState.maxValue - root.progressState.minValue) / steps
|
||||||
readonly property double anglePerStep: maxAngle / steps
|
readonly property double anglePerStep: maxAngle / steps
|
||||||
|
|
||||||
|
|
||||||
@ -81,6 +82,10 @@ Item {
|
|||||||
width: Math.min(root.width, root.height)
|
width: Math.min(root.width, root.height)
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
|
property color effectColor: root.on ? root.color : Style.iconColor
|
||||||
|
Behavior on effectColor { ColorAnimation { duration: Style.animationDuration } }
|
||||||
|
onEffectColorChanged: requestPaint()
|
||||||
|
|
||||||
function roundToPrecision(value) {
|
function roundToPrecision(value) {
|
||||||
var tmp = Math.round(value / root.precision) * root.precision;
|
var tmp = Math.round(value / root.precision) * root.precision;
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -96,7 +101,7 @@ Item {
|
|||||||
var currentValue = actionQueue.pendingValue || root.progressState.value
|
var currentValue = actionQueue.pendingValue || root.progressState.value
|
||||||
var currentStep;
|
var currentStep;
|
||||||
if (root.progressState) {
|
if (root.progressState) {
|
||||||
currentStep = roundToPrecision(currentValue - root.stateType.minValue) / root.precision
|
currentStep = roundToPrecision(currentValue - root.progressState.minValue) / root.precision
|
||||||
}
|
}
|
||||||
|
|
||||||
print("* current step", currentStep, root.steps, currentValue)
|
print("* current step", currentStep, root.steps, currentValue)
|
||||||
@ -106,8 +111,8 @@ Item {
|
|||||||
var innerRadius = canvas.width * 0.4
|
var innerRadius = canvas.width * 0.4
|
||||||
var outerRadius = canvas.width * 0.5
|
var outerRadius = canvas.width * 0.5
|
||||||
|
|
||||||
if (step === currentStep) {
|
if (step <= currentStep) {
|
||||||
ctx.strokeStyle = root.color
|
ctx.strokeStyle = canvas.effectColor
|
||||||
innerRadius = canvas.width * 0.38
|
innerRadius = canvas.width * 0.38
|
||||||
ctx.lineWidth = 4;
|
ctx.lineWidth = 4;
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +182,7 @@ Item {
|
|||||||
if (Math.abs(valueDiff) > 0) {
|
if (Math.abs(valueDiff) > 0) {
|
||||||
var currentValue = actionQueue.pendingValue || root.progressState.value
|
var currentValue = actionQueue.pendingValue || root.progressState.value
|
||||||
var newValue = currentValue + valueDiff
|
var newValue = currentValue + valueDiff
|
||||||
newValue = Math.min(root.stateType.maxValue, Math.max(root.stateType.minValue, newValue))
|
newValue = Math.min(root.stateType.maxValue, Math.max(root.progressState.minValue, newValue))
|
||||||
if (currentValue !== newValue) {
|
if (currentValue !== newValue) {
|
||||||
actionQueue.sendValue(newValue)
|
actionQueue.sendValue(newValue)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ ThingPageBase {
|
|||||||
readonly property State powerState: thing.stateByName("power")
|
readonly property State powerState: thing.stateByName("power")
|
||||||
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")
|
||||||
|
|
||||||
ActionQueue {
|
ActionQueue {
|
||||||
id: actionQueue
|
id: actionQueue
|
||||||
@ -48,27 +49,88 @@ ThingPageBase {
|
|||||||
stateName: "power"
|
stateName: "power"
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleBackground {
|
GridLayout {
|
||||||
id: background
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Style.hugeMargins
|
columns: app.landscape ? 2 : 1
|
||||||
iconSource: "ev-charger"
|
|
||||||
onColor: app.interfaceToColor("evcharger")
|
CircleBackground {
|
||||||
on: (actionQueue.pendingValue || powerState.value) === true
|
id: background
|
||||||
onClicked: {
|
Layout.fillWidth: true
|
||||||
PlatformHelper.vibrate(PlatformHelper.HapticsFeedbackSelection)
|
Layout.fillHeight: true
|
||||||
actionQueue.sendValue(!root.powerState.value)
|
Layout.margins: Style.hugeMargins
|
||||||
|
// iconSource: "ev-charger"
|
||||||
|
onColor: app.interfaceToColor("evcharger")
|
||||||
|
// on: (actionQueue.pendingValue || powerState.value) === true
|
||||||
|
onClicked: {
|
||||||
|
PlatformHelper.vibrate(PlatformHelper.HapticsFeedbackSelection)
|
||||||
|
actionQueue.sendValue(!root.powerState.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: background.contentItem.width * .6
|
||||||
|
spacing: Style.margins
|
||||||
|
Label {
|
||||||
|
text: qsTr("Maximum charging current")
|
||||||
|
font: Style.smallFont
|
||||||
|
width: parent.width
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
font: Style.largeFont
|
||||||
|
text: "%1 %2".arg(root.maxChargingCurrentState.value).arg(Types.toUiUnit(root.maxChargingCurrentStateType.unit))
|
||||||
|
width: parent.width
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dial {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
height: background.contentItem.height
|
||||||
|
width: background.contentItem.width
|
||||||
|
visible: root.maxChargingCurrentState
|
||||||
|
|
||||||
|
thing: root.thing
|
||||||
|
stateName: "maxChargingCurrent"
|
||||||
|
color: app.interfaceToColor("evcharger")
|
||||||
|
on: (actionQueue.pendingValue || powerState.value) === true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Dial {
|
ColumnLayout {
|
||||||
anchors.centerIn: parent
|
Layout.fillHeight: true
|
||||||
height: background.contentItem.height
|
Layout.fillWidth: true
|
||||||
width: background.contentItem.width
|
Layout.margins: Style.hugeMargins
|
||||||
visible: root.maxChargingCurrentState
|
spacing: Style.bigMargins
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
property double currentPower: root.currentPowerState.value / (root.currentPowerState.value > 1000 ? 1000 : 1)
|
||||||
|
property string unit: root.currentPowerState.value > 1000 ? "kW" : "W"
|
||||||
|
font: Style.smallFont
|
||||||
|
text: qsTr("Currently charging at %1.")
|
||||||
|
.arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">'
|
||||||
|
+ (currentPower.toFixed(1))
|
||||||
|
+ '</span>' + ' ' + unit)
|
||||||
|
textFormat: Text.RichText
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressButton {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
imageSource: "system-shutdown"
|
||||||
|
mode: "normal"
|
||||||
|
size: Style.bigIconSize
|
||||||
|
busy: root.currentPowerState.value > 0
|
||||||
|
color: (actionQueue.pendingValue || powerState.value) === true ? app.interfaceToColor("evcharger") : Style.iconColor
|
||||||
|
onClicked: {
|
||||||
|
PlatformHelper.vibrate(PlatformHelper.HapticsFeedbackSelection)
|
||||||
|
actionQueue.sendValue(!root.powerState.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
thing: root.thing
|
|
||||||
stateName: "maxChargingCurrent"
|
|
||||||
color: app.interfaceToColor("evcharger")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -268,6 +268,16 @@ ThingPageBase {
|
|||||||
value: stateDelegate.thingState.value
|
value: stateDelegate.thingState.value
|
||||||
when: !stateDelegate.valueCacheDirty && stateDelegate.pendingActionId === -1
|
when: !stateDelegate.valueCacheDirty && stateDelegate.pendingActionId === -1
|
||||||
}
|
}
|
||||||
|
Binding {
|
||||||
|
target: stateDelegateLoader.item
|
||||||
|
property: "from"
|
||||||
|
value: stateDelegate.thingState.minValue
|
||||||
|
}
|
||||||
|
Binding {
|
||||||
|
target: stateDelegateLoader.item
|
||||||
|
property: "to"
|
||||||
|
value: stateDelegate.thingState.maxValue
|
||||||
|
}
|
||||||
Binding {
|
Binding {
|
||||||
target: stateDelegateLoader.item.hasOwnProperty("unit") ? stateDelegateLoader.item : null
|
target: stateDelegateLoader.item.hasOwnProperty("unit") ? stateDelegateLoader.item : null
|
||||||
property: "unit"
|
property: "unit"
|
||||||
|
|||||||
@ -160,9 +160,13 @@ ThingPageBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (root.isProducer) {
|
if (root.isProducer) {
|
||||||
return qsTr("Production")
|
return qsTr("Producing")
|
||||||
}
|
}
|
||||||
return root.currentPower < 0 ? qsTr("Return") : qsTr("Consumption")
|
if (root.isConsumer) {
|
||||||
|
return qsTr("Consuming")
|
||||||
|
}
|
||||||
|
|
||||||
|
return root.currentPower < 0 ? qsTr("Returning") : qsTr("Obtaining")
|
||||||
}
|
}
|
||||||
font: Style.smallFont
|
font: Style.smallFont
|
||||||
}
|
}
|
||||||
@ -223,6 +227,7 @@ ThingPageBase {
|
|||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
visible: isEnergyMeter || isConsumer
|
visible: isEnergyMeter || isConsumer
|
||||||
blurred: periodConsumptionModel.busy
|
blurred: periodConsumptionModel.busy
|
||||||
|
font: Style.smallFont
|
||||||
text: isConsumer ?
|
text: isConsumer ?
|
||||||
qsTr("A total of %1 kWh has been <b>consumed</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodConsumption).toFixed(1) + '</span>')
|
qsTr("A total of %1 kWh has been <b>consumed</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodConsumption).toFixed(1) + '</span>')
|
||||||
: qsTr("A total of %1 kWh has been <b>obtained</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodConsumption).toFixed(1) + '</span>')
|
: qsTr("A total of %1 kWh has been <b>obtained</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodConsumption).toFixed(1) + '</span>')
|
||||||
@ -247,6 +252,7 @@ ThingPageBase {
|
|||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
blurred: periodProductionModel.busy
|
blurred: periodProductionModel.busy
|
||||||
|
font: Style.smallFont
|
||||||
text: isProducer ?
|
text: isProducer ?
|
||||||
qsTr("A total of %1 kWh has been <b>produced</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodProduction).toFixed(1) + '</span>')
|
qsTr("A total of %1 kWh has been <b>produced</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodProduction).toFixed(1) + '</span>')
|
||||||
: qsTr("A total of %1 kWh has been <b>returned</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodProduction).toFixed(1) + '</span>')
|
: qsTr("A total of %1 kWh has been <b>returned</b> in the last 24 hours.").arg('<span style="font-size:' + Style.bigFont.pixelSize + 'px">' + (totalPeriodProduction).toFixed(1) + '</span>')
|
||||||
|
|||||||
@ -54,6 +54,7 @@ ThingPageBase {
|
|||||||
anchors.margins: Style.hugeMargins
|
anchors.margins: Style.hugeMargins
|
||||||
iconSource: "ventilation"
|
iconSource: "ventilation"
|
||||||
onColor: app.interfaceToColor("ventilation")
|
onColor: app.interfaceToColor("ventilation")
|
||||||
|
showOnGradient: root.flowRateState == null
|
||||||
on: (actionQueue.pendingValue || powerState.value) === true
|
on: (actionQueue.pendingValue || powerState.value) === true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
PlatformHelper.vibrate(PlatformHelper.HapticsFeedbackSelection)
|
PlatformHelper.vibrate(PlatformHelper.HapticsFeedbackSelection)
|
||||||
@ -77,6 +78,7 @@ ThingPageBase {
|
|||||||
height: background.contentItem.height
|
height: background.contentItem.height
|
||||||
width: background.contentItem.width
|
width: background.contentItem.width
|
||||||
visible: root.flowRateState
|
visible: root.flowRateState
|
||||||
|
on: (actionQueue.pendingValue || powerState.value) === true
|
||||||
|
|
||||||
thing: root.thing
|
thing: root.thing
|
||||||
stateName: "flowRate"
|
stateName: "flowRate"
|
||||||
|
|||||||
Reference in New Issue
Block a user