diff options
author | Lukáš Tinkl <ltinkl@luxoft.com> | 2017-08-08 16:50:09 +0200 |
---|---|---|
committer | Lukáš Tinkl <ltinkl@luxoft.com> | 2017-08-09 10:00:03 +0000 |
commit | 2118a6388953579c12b5ec63df971787dd8361b1 (patch) | |
tree | 64078b8eeadcb0175d6c5f08662033971609d27b | |
parent | 8a7319ef7b098136c06acb2bd776e123d939170a (diff) |
fix the climate controls after recent qtivi API changes
NOTE: the temperature slider no longer works with "half" degrees,
as "targetTemperature" is an int and is now propertly assigned
(instead of breaking the ClimateModel value bindings)
Fix for qtivi to follow
Change-Id: I84b299acb55ea530f510e44cbd105e73eac7b02a
Reviewed-by: Nedim Hadzic <nedim.hadzic@pelagicore.com>
-rw-r--r-- | dummyimports/QtIvi/VehicleFunctions/DummyClimateControl.qml | 18 | ||||
-rw-r--r-- | imports/system/models/climate/ClimateModel.qml | 76 | ||||
-rw-r--r-- | imports/system/models/climate/ClimateStateMachine.qml | 50 | ||||
-rw-r--r-- | sysui/climate/ClimateBar.qml | 19 | ||||
-rw-r--r-- | sysui/climate/ClimatePane.qml | 4 |
5 files changed, 98 insertions, 69 deletions
diff --git a/dummyimports/QtIvi/VehicleFunctions/DummyClimateControl.qml b/dummyimports/QtIvi/VehicleFunctions/DummyClimateControl.qml index 87d2f8e..857448b 100644 --- a/dummyimports/QtIvi/VehicleFunctions/DummyClimateControl.qml +++ b/dummyimports/QtIvi/VehicleFunctions/DummyClimateControl.qml @@ -32,11 +32,15 @@ import QtQuick 2.0 QtObject { - property var discoveryMode - property bool steeringWheelHeater: false - property bool airRecirculation: false - property bool airConditioning: true - property QtObject zoneAt: QtObject { - - } + property int discoveryMode: 0 /* QIviAbstractFeature::NoAutoDiscovery */ + property int steeringWheelHeater: 0 + property bool recirculationEnabled: false + property int recirculationMode: 0 /* QtIviVehicleFunctionsModule::RecirculationOff */ + property bool airConditioningEnabled: true + property bool defrostEnabled: false + property bool heaterEnabled: true + property int outsideTemperature: 15 + property int fanSpeedLevel: 3 + property int airflowDirections: 0 + property QtObject zoneAt: QtObject {} } diff --git a/imports/system/models/climate/ClimateModel.qml b/imports/system/models/climate/ClimateModel.qml index 4c3946a..92849fe 100644 --- a/imports/system/models/climate/ClimateModel.qml +++ b/imports/system/models/climate/ClimateModel.qml @@ -47,16 +47,21 @@ QtObject { readonly property real minValue: 16 readonly property real maxValue: 28 readonly property real stepValue: 0.5 - property real value: climateControl.zoneAt.FrontLeft.targetTemperature.value + readonly property real value: climateControl.zoneAt.FrontLeft.targetTemperature - property bool heat: climateControl.zoneAt.FrontLeft.seatHeater.value + readonly property bool heat: climateControl.zoneAt.FrontLeft.seatHeater > 0 function setValue(newValue) { - climateControl.zoneAt.FrontLeft.targetTemperature.value = newValue + climateControl.zoneAt.FrontLeft.targetTemperature = newValue } function setHeat(newHeat) { - climateControl.zoneAt.FrontLeft.seatHeater.value = newHeat + climateControl.zoneAt.FrontLeft.seatHeater = newHeat + } + + // set some sane default value + Component.onCompleted: { + setValue(21); } } @@ -64,52 +69,57 @@ QtObject { readonly property real minValue: 16 readonly property real maxValue: 28 readonly property real stepValue: 0.5 - property real value: climateControl.zoneAt.FrontRight.targetTemperature.value + readonly property real value: climateControl.zoneAt.FrontRight.targetTemperature - property bool heat: climateControl.zoneAt.FrontRight.seatHeater.value + readonly property bool heat: climateControl.zoneAt.FrontRight.seatHeater > 0 function setValue(newValue) { - climateControl.zoneAt.FrontRight.targetTemperature.value = newValue + climateControl.zoneAt.FrontRight.targetTemperature = newValue } function setHeat(newHeat) { - climateControl.zoneAt.FrontRight.seatHeater.value = newHeat + climateControl.zoneAt.FrontRight.seatHeater = newHeat + } + + // set some sane default value + Component.onCompleted: { + setValue(22.5); } } property QtObject frontHeat: QtObject { property string symbol: "front" - property bool enabled: true + readonly property bool enabled: climateControl.defrostEnabled function setEnabled(newEnabled) { - enabled = newEnabled; + climateControl.defrostEnabled = newEnabled; } } property QtObject rearHeat: QtObject { property string symbol: "rear" - property bool enabled: true + readonly property bool enabled: climateControl.heaterEnabled function setEnabled(newEnabled) { - enabled = newEnabled; + climateControl.heaterEnabled = newEnabled; } } property QtObject airCondition: QtObject { - property string symbol: "ac" - property bool enabled: climateControl.airConditioning.value + readonly property string symbol: "ac" + readonly property bool enabled: climateControl.airConditioningEnabled function setEnabled(newEnabled) { - climateControl.airConditioning.value = newEnabled; + climateControl.airConditioningEnabled = newEnabled; } } property QtObject airQuality: QtObject { - property string symbol: "air_quality" - property bool enabled: climateControl.recirculationMode.value == ClimateControl.RecirculationOn + readonly property string symbol: "air_quality" + readonly property bool enabled: climateControl.recirculationMode === ClimateControl.RecirculationOn function setEnabled(newEnabled) { - climateControl.recirculationMode.value = newEnabled ? ClimateControl.RecirculationOn : ClimateControl.RecirculationOff; + climateControl.recirculationMode = newEnabled ? ClimateControl.RecirculationOn : ClimateControl.RecirculationOff; } } @@ -123,34 +133,34 @@ QtObject { } property QtObject steeringWheelHeat: QtObject { - property string symbol: "stearing_wheel" - property bool enabled: climateControl.steeringWheelHeater.value >= 5 + readonly property string symbol: "stearing_wheel" + readonly property bool enabled: climateControl.steeringWheelHeater >= 5 function setEnabled(newEnabled) { - climateControl.steeringWheelHeater.value = newEnabled ? 10 : 0; + climateControl.steeringWheelHeater = newEnabled ? 10 : 0; } } - property var climateOptions: [frontHeat, rearHeat, airCondition, airQuality, eco, steeringWheelHeat] + readonly property var climateOptions: [frontHeat, rearHeat, airCondition, airQuality, eco, steeringWheelHeat] - property int outsideTemp: calculateUnitValue(15) + property int outsideTemp: climateControl.outsideTemperature != 0 ? calculateUnitValue(climateControl.outsideTemperature) + : calculateUnitValue(15) property string outsideTempText: qsTr("%1" + tempSuffix).arg(outsideTemp) - property int ventilation: climateControl.fanSpeedLevel.value - property string tempSuffix: SettingsModel.metric ? "°C" : "°F" + property int ventilation: climateControl.fanSpeedLevel + readonly property string tempSuffix: SettingsModel.metric ? "°C" : "°F" property int ventilationLevels: 7 // 6 + off (0) function setVentilation(newVentilation) { - climateControl.fanSpeedLevel.value = newVentilation; + climateControl.fanSpeedLevel = newVentilation; } property QtObject airflowDirections: QtObject { - property int directions: climateControl.airflowDirections.value - property var availableDirections: climateControl.airflowDirections.availableValues - onDirectionsChanged: climateControl.airflowDirections.value = directions - } - property Connections airflowDirectionsConnections: Connections { - target: climateControl.airflowDirections - onValueChanged: airflowDirections.directions = climateControl.airflowDirections.value + property int directions: climateControl.airflowDirections + // FIXME this is stupid, how to get the available list programatically? + // TODO ClimateControl.Windshield missing; when added, this will get fun ;) + readonly property var availableDirections: [ClimateControl.Dashboard, ClimateControl.Floor, + ClimateControl.Dashboard | ClimateControl.Floor] + onDirectionsChanged: climateControl.airflowDirections = directions } property QtObject stateMachine: ClimateStateMachine { diff --git a/imports/system/models/climate/ClimateStateMachine.qml b/imports/system/models/climate/ClimateStateMachine.qml index bfc9925..8ba44cc 100644 --- a/imports/system/models/climate/ClimateStateMachine.qml +++ b/imports/system/models/climate/ClimateStateMachine.qml @@ -57,55 +57,55 @@ QtObject { DSM.State { id: airConditionState - initialState: climateControl.airConditioning.value ? airConditionOn : airConditionOff + initialState: climateControl.airConditioningEnabled ? airConditionOn : airConditionOff DSM.State { id: airConditionOff - onEntered: climateControl.airConditioning.value = false + onEntered: climateControl.airConditioningEnabled = false DSM.SignalTransition { targetState: airConditionOn - signal: climateControl.airConditioning.valueChanged - guard: climateControl.airConditioning.value + signal: climateControl.airConditioningEnabledChanged + guard: climateControl.airConditioningEnabled } } DSM.State { id: airConditionOn onEntered: { - climateControl.airConditioning.value = true - steeringWheelHeat.setEnabled(false) + climateControl.airConditioningEnabled = true + climateControl.steeringWheelHeater = 0 } DSM.SignalTransition { targetState: airConditionOff - signal: climateControl.airConditioning.valueChanged - guard: !climateControl.airConditioning.value + signal: climateControl.airConditioningEnabledChanged + guard: !climateControl.airConditioningEnabled } } } // airConditionState DSM.State { id: airRecirculationState - initialState: climateControl.recirculation.value ? airRecirculationOn : airRecirculationOff + initialState: climateControl.recirculationEnabled ? airRecirculationOn : airRecirculationOff DSM.State { id: airRecirculationOff - onEntered: climateControl.recirculationMode.value = ClimateControl.RecirculationOff + onEntered: climateControl.recirculationMode = ClimateControl.RecirculationOff DSM.SignalTransition { targetState: airRecirculationOn - signal: climateControl.recirculationMode.valueChanged - guard: climateControl.recirculationMode.value == ClimateControl.RecirculationOn + signal: climateControl.recirculationModeChanged + guard: climateControl.recirculationEnabled } } DSM.State { id: airRecirculationOn onEntered: { - climateControl.recirculationMode.value = ClimateControl.RecirculationOn + climateControl.recirculationMode = ClimateControl.RecirculationOn } DSM.SignalTransition { targetState: airRecirculationOff - signal: climateControl.recirculationMode.valueChanged - guard: climateControl.recirculationMode.value == ClimateControl.RecirculationOff + signal: climateControl.recirculationModeChanged + guard: climateControl.recirculationMode === ClimateControl.RecirculationOff } } } // airRecirculationState @@ -126,8 +126,8 @@ QtObject { DSM.State { id: suspended onEntered: { - climateControl.airConditioning.value = false - climateControl.recirculationMode.value = ClimateControl.RecirculationOff + climateControl.airConditioningEnabled = false + climateControl.recirculationMode = ClimateControl.RecirculationOff } DSM.SignalTransition { targetState: historyState @@ -140,28 +140,28 @@ QtObject { DSM.State { id: steeringWheelHeatState - initialState: (climateControl.steeringWheelHeater.value >= 5) ? steeringWheelHeatOn : steeringWheelHeatOff + initialState: (climateControl.steeringWheelHeater >= 5) ? steeringWheelHeatOn : steeringWheelHeatOff DSM.State { id: steeringWheelHeatOff - onEntered: climateControl.steeringWheelHeater.value = 0 + onEntered: climateControl.steeringWheelHeater = 0 DSM.SignalTransition { targetState: steeringWheelHeatOn - signal: climateControl.steeringWheelHeater.valueChanged - guard: climateControl.steeringWheelHeater.value >= 5 + signal: climateControl.steeringWheelHeaterChanged + guard: climateControl.steeringWheelHeater >= 5 } } DSM.State { id: steeringWheelHeatOn onEntered: { - climateControl.steeringWheelHeater.value = 10 - climateControl.airConditioning.value = false + climateControl.steeringWheelHeater = 10 + climateControl.airConditioningEnabled = false } DSM.SignalTransition { targetState: steeringWheelHeatOff - signal: climateControl.steeringWheelHeater.valueChanged - guard: climateControl.steeringWheelHeater.value < 5 + signal: climateControl.steeringWheelHeaterChanged + guard: climateControl.steeringWheelHeater < 5 } } } diff --git a/sysui/climate/ClimateBar.qml b/sysui/climate/ClimateBar.qml index 9d8d9ea..5e9e3ec 100644 --- a/sysui/climate/ClimateBar.qml +++ b/sysui/climate/ClimateBar.qml @@ -77,8 +77,16 @@ Control { width: Style.hspan(2) height: Style.climateCollapsedVspan symbol: "seat_left" + checkable: true checked: ClimateModel.leftSeat.heat - onClicked: ClimateModel.leftSeat.heat = !ClimateModel.leftSeat.heat + onClicked: { + if (ClimateModel.leftSeat.heat) { + ClimateModel.leftSeat.setHeat(0); + } else { + ClimateModel.leftSeat.setHeat(1); + } + } + anchors.left: tempLevelLeft.right anchors.leftMargin: Style.hspan(1) anchors.verticalCenter: parent.verticalCenter @@ -98,8 +106,15 @@ Control { width: Style.hspan(2) height: Style.climateCollapsedVspan symbol: "seat_right" + checkable: true checked: ClimateModel.rightSeat.heat - onClicked: ClimateModel.rightSeat.heat = !ClimateModel.rightSeat.heat + onClicked: { + if (ClimateModel.rightSeat.heat) { + ClimateModel.rightSeat.setHeat(0); + } else { + ClimateModel.rightSeat.setHeat(1); + } + } anchors.right: tempLevelRight.left anchors.rightMargin: Style.hspan(1) anchors.verticalCenter: parent.verticalCenter diff --git a/sysui/climate/ClimatePane.qml b/sysui/climate/ClimatePane.qml index 1a07dc5..ecf4f44 100644 --- a/sysui/climate/ClimatePane.qml +++ b/sysui/climate/ClimatePane.qml @@ -83,7 +83,7 @@ Item { to: ClimateModel.leftSeat.maxValue value: ClimateModel.leftSeat.value stepSize: ClimateModel.leftSeat.stepValue - onValueChanged: ClimateModel.leftSeat.value = value + onValueChanged: ClimateModel.leftSeat.setValue(value) } Spacer { @@ -149,7 +149,7 @@ Item { to: ClimateModel.rightSeat.maxValue value: ClimateModel.rightSeat.value stepSize: ClimateModel.rightSeat.stepValue - onValueChanged: ClimateModel.rightSeat.value = value + onValueChanged: ClimateModel.rightSeat.setValue(value) } } |