summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslaw Kubik <jarek@froglogic.com>2016-12-16 13:02:44 +0100
committerJaroslaw Kubik <jarek@froglogic.com>2016-12-21 13:53:26 +0000
commitc906c39ad014b69337e94e5ea511a2c2adb0eeab (patch)
treecf99265586e15f2be66ca185764470ea217432e7
parent97fcbfb824d27299fa7d8470918c742e0ec3d5f1 (diff)
downloadneptune-ui-c906c39ad014b69337e94e5ea511a2c2adb0eeab.tar.gz
Fix the problems with UI not reflecting the QtIvi backend changes
In current implementation the property bindings between QtIvi backend properties and GUI object properties are used for two-way communication. In case GUI requests a change, the requested GUI object property is assigned with a new value. This operation removes property binding to the QtIvi backend. Additional code in onXXXChanged: handler must be written explicitly to propagate the change to the backend and recreate the binding afterwards. This scheme is difficult to maintain and test. In this modification a second channel is introduced - the property bindings take care of propagation of updates from backend to GUI, and functions are used by GUI in order to request backend changes. GUI itself does not update it's own internal variables on user actions, and instead relies on property bindings to follow the change in backend - this approach makes the code simpler, avoids binding recreation, and handles well cases where backend properties changes value to a different than assigned to it - backend can react to property assignments in non-trivial ways. Change-Id: I55423fe806d1db9d099c7983676dd1afeb1b5b69 Reviewed-by: Andreas Hartmetz <andreas.hartmetz@kdab.com> Reviewed-by: Harri Porten <porten@froglogic.com> Reviewed-by: Nedim Hadzic <nedim.hadzic@pelagicore.com>
-rw-r--r--imports/shared/service/climate/ClimateService.qml69
-rw-r--r--imports/shared/service/climate/ClimateStateMachine.qml2
-rw-r--r--sysui/Climate/ClimateBar.qml25
-rw-r--r--sysui/Climate/Ventilation.qml9
4 files changed, 44 insertions, 61 deletions
diff --git a/imports/shared/service/climate/ClimateService.qml b/imports/shared/service/climate/ClimateService.qml
index ae8ce20..37e7480 100644
--- a/imports/shared/service/climate/ClimateService.qml
+++ b/imports/shared/service/climate/ClimateService.qml
@@ -49,17 +49,13 @@ QtObject {
property bool heat: climateControl.zoneAt.FrontLeft.seatHeater.value
- onValueChanged: climateControl.zoneAt.FrontLeft.targetTemperature.value = value
- onHeatChanged: climateControl.zoneAt.FrontLeft.seatHeater.value = heat
- }
- property Connections leftSeatTargetTempConnections: Connections {
- target: climateControl.zoneAt.FrontLeft.targetTemperature
- onValueChanged: leftSeat.value =
- calculateUnitValue(climateControl.zoneAt.FrontLeft.targetTemperature.value)
- }
- property Connections leftSeatHeaterConnections: Connections {
- target: climateControl.zoneAt.FrontLeft.seatHeater
- onValueChanged: leftSeat.heat = climateControl.zoneAt.FrontLeft.seatHeater.value
+ function setValue(newValue) {
+ climateControl.zoneAt.FrontLeft.targetTemperature.value = newValue
+ }
+
+ function setHeat(newHeat) {
+ climateControl.zoneAt.FrontLeft.seatHeater.value = newHeat
+ }
}
property QtObject rightSeat: QtObject {
@@ -70,36 +66,39 @@ QtObject {
property bool heat: climateControl.zoneAt.FrontRight.seatHeater.value
- onValueChanged: climateControl.zoneAt.FrontRight.targetTemperature.value = value
- onHeatChanged: climateControl.zoneAt.FrontRight.seatHeater.value = heat
- }
- property Connections rightSeatTargetTempConnections: Connections {
- target: climateControl.zoneAt.FrontRight.targetTemperature
- onValueChanged: rightSeat.value =
- calculateUnitValue(climateControl.zoneAt.FrontRight.targetTemperature.value)
- }
- property Connections rightSeatHeaterConnections: Connections {
- target: climateControl.zoneAt.FrontRight.seatHeater
- onValueChanged: rightSeat.heat = climateControl.zoneAt.FrontRight.seatHeater.value
+ function setValue(newValue) {
+ climateControl.zoneAt.FrontRight.targetTemperature.value = newValue
+ }
+
+ function setHeat(newHeat) {
+ climateControl.zoneAt.FrontRight.seatHeater.value = newHeat
+ }
}
property QtObject frontHeat: QtObject {
property string symbol: "front"
property bool enabled: true
+
+ function setEnabled(newEnabled) {
+ enabled = newEnabled;
+ }
}
property QtObject rearHeat: QtObject {
property string symbol: "rear"
property bool enabled: true
+
+ function setEnabled(newEnabled) {
+ enabled = newEnabled;
+ }
}
property QtObject airCondition: QtObject {
property string symbol: "ac"
property bool enabled: climateControl.airConditioning.value
- onEnabledChanged: {
- climateControl.airConditioning.value = enabled;
- enabled = Qt.binding(function() { return climateControl.airConditioning.value; });
+ function setEnabled(newEnabled) {
+ climateControl.airConditioning.value = newEnabled;
}
}
@@ -107,24 +106,26 @@ QtObject {
property string symbol: "air_quality"
property bool enabled: climateControl.recirculationMode.value == ClimateControl.RecirculationOn
- onEnabledChanged: {
- climateControl.recirculationMode.value = enabled ? ClimateControl.RecirculationOn : ClimateControl.RecirculationOff;
- enabled = Qt.binding(function() { return climateControl.recirculationMode.value == ClimateControl.RecirculationOn });
+ function setEnabled(newEnabled) {
+ climateControl.recirculationMode.value = newEnabled ? ClimateControl.RecirculationOn : ClimateControl.RecirculationOff;
}
}
property QtObject eco: QtObject {
property string symbol: "eco"
property bool enabled: false
+
+ function setEnabled(newEnabled) {
+ enabled = newEnabled;
+ }
}
property QtObject steeringWheelHeat: QtObject {
property string symbol: "stearing_wheel"
property bool enabled: climateControl.steeringWheelHeater.value >= 5
- onEnabledChanged: {
- climateControl.steeringWheelHeater.value = enabled ? 10 : 0;
- enabled = Qt.binding(function() { return climateControl.steeringWheelHeater.value >= 5 });
+ function setEnabled(newEnabled) {
+ climateControl.steeringWheelHeater.value = newEnabled ? 10 : 0;
}
}
@@ -136,10 +137,8 @@ QtObject {
property string tempSuffix: SettingsService.metric ? "°C" : "°F"
property int ventilationLevels: 7 // 6 + off (0)
- onVentilationChanged: climateControl.fanSpeedLevel.value = ventilation
- property Connections fanSpeedLevelConnections: Connections {
- target: climateControl.fanSpeedLevel
- onValueChanged: ventilation = climateControl.fanSpeedLevel.value
+ function setVentilation(newVentilation) {
+ climateControl.fanSpeedLevel.value = newVentilation;
}
property QtObject stateMachine: ClimateStateMachine {
diff --git a/imports/shared/service/climate/ClimateStateMachine.qml b/imports/shared/service/climate/ClimateStateMachine.qml
index 2b36520..bfc9925 100644
--- a/imports/shared/service/climate/ClimateStateMachine.qml
+++ b/imports/shared/service/climate/ClimateStateMachine.qml
@@ -73,7 +73,7 @@ QtObject {
id: airConditionOn
onEntered: {
climateControl.airConditioning.value = true
- steeringWheelHeat.enabled = false
+ steeringWheelHeat.setEnabled(false)
}
DSM.SignalTransition {
targetState: airConditionOff
diff --git a/sysui/Climate/ClimateBar.qml b/sysui/Climate/ClimateBar.qml
index f391b6c..a300400 100644
--- a/sysui/Climate/ClimateBar.qml
+++ b/sysui/Climate/ClimateBar.qml
@@ -89,7 +89,7 @@ UIElement {
vspan: root.collapsedVspan
name: "seat_left"
active: ClimateService.leftSeat.heat
- onClicked: ClimateService.leftSeat.heat = !active
+ onClicked: ClimateService.leftSeat.setHeat(!active)
anchors.left: tempLevelLeft.right
anchors.verticalCenter: parent.verticalCenter
}
@@ -108,7 +108,7 @@ UIElement {
vspan: root.collapsedVspan
name: "seat_right"
active: ClimateService.rightSeat.heat
- onClicked: ClimateService.rightSeat.heat = !active
+ onClicked: ClimateService.rightSeat.setHeat(!active)
anchors.right: tempLevelRight.left
anchors.verticalCenter: parent.verticalCenter
}
@@ -135,7 +135,7 @@ UIElement {
maxValue: ClimateService.leftSeat.maxValue
value: ClimateService.leftSeat.value
stepValue: ClimateService.leftSeat.stepValue
- onValueChanged: ClimateService.leftSeat.value = value
+ onValueChanged: ClimateService.leftSeat.setValue(value)
}
Spacer {
@@ -161,11 +161,7 @@ UIElement {
vspan: 2
levels: ClimateService.ventilationLevels
currentLevel: ClimateService.ventilation
- onCurrentLevelChanged: ClimateService.ventilation = currentLevel
- Connections {
- target: ClimateService
- onVentilationChanged: ventilation.currentLevel = ClimateService.ventilation
- }
+ onNewLevelRequested: ClimateService.setVentilation(newLevel)
}
Spacer {
@@ -184,7 +180,7 @@ UIElement {
vspan: 5
symbolName: modelData.symbol
active: modelData.enabled
- onClicked: modelData.enabled = !modelData.enabled
+ onClicked: modelData.setEnabled(!modelData.enabled)
}
}
}
@@ -203,7 +199,7 @@ UIElement {
maxValue: ClimateService.rightSeat.maxValue
value: ClimateService.rightSeat.value
stepValue: ClimateService.rightSeat.stepValue
- onValueChanged: ClimateService.rightSeat.value = value
+ onValueChanged: ClimateService.rightSeat.setValue(value)
}
}
@@ -214,13 +210,4 @@ UIElement {
}
}
- Connections {
- target: ClimateService.leftSeat
- onValueChanged: leftTempSlider.value = ClimateService.leftSeat.value
- }
-
- Connections {
- target: ClimateService.rightSeat
- onValueChanged: rightTempSlider.value = ClimateService.rightSeat.value
- }
}
diff --git a/sysui/Climate/Ventilation.qml b/sysui/Climate/Ventilation.qml
index c6f4bfa..f71f80e 100644
--- a/sysui/Climate/Ventilation.qml
+++ b/sysui/Climate/Ventilation.qml
@@ -40,16 +40,13 @@ UIElement {
property int levels
property int currentLevel
- property bool _updateInProgress: false
+ onCurrentLevelChanged: view.currentIndex = currentLevel;
- onCurrentLevelChanged: if (!_updateInProgress) updateLevelInternal(currentLevel);
+ signal newLevelRequested(int newLevel)
function updateLevelInternal(newLevel) {
var boundedLevel = Math.max(0, Math.min(levels - 1, newLevel));
- _updateInProgress = true;
- currentLevel = boundedLevel;
- _updateInProgress = false;
- view.currentIndex = boundedLevel;
+ newLevelRequested( boundedLevel );
}
MouseArea {