From e1951d4aed4d8633085671c47bf28e89b4742229 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 20 Jul 2017 10:30:23 +0200 Subject: Fix all vehiclefunctions examples to use the new API Change-Id: I2446ac002f509646a5736f3a2c40150fc572a448 Reviewed-by: Mike Krus --- examples/examples.pro | 2 +- examples/vehiclefunctions/climate_qml/main.qml | 94 ++++++++-------------- .../vehiclefunctions/climate_widget/mainwindow.cpp | 60 +++----------- .../vehiclefunctions/climate_widget/mainwindow.h | 8 +- .../vehiclefunctions/window_qml/WindowItem.qml | 41 ++++------ 5 files changed, 63 insertions(+), 142 deletions(-) (limited to 'examples') diff --git a/examples/examples.pro b/examples/examples.pro index 1ca1abb..d58eb45 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs SUBDIRS += core -#qtHaveModule(ivivehiclefunctions): SUBDIRS += vehiclefunctions +qtHaveModule(ivivehiclefunctions): SUBDIRS += vehiclefunctions qtHaveModule(ivimedia): SUBDIRS += media qtHaveModule(geniviextras): SUBDIRS += geniviextras diff --git a/examples/vehiclefunctions/climate_qml/main.qml b/examples/vehiclefunctions/climate_qml/main.qml index 1d84f47..3dc8c6f 100644 --- a/examples/vehiclefunctions/climate_qml/main.qml +++ b/examples/vehiclefunctions/climate_qml/main.qml @@ -83,37 +83,34 @@ ApplicationWindow { anchors.fill: parent CheckBox { text: "Windshield" - checked: climateControl.airflowDirections.value & ClimateControl.Windshield - enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Windshield) !== -1 + checked: climateControl.airflowDirections & ClimateControl.Windshield onClicked: { if (checked) - climateControl.airflowDirections.value |= ClimateControl.Windshield + climateControl.airflowDirections |= ClimateControl.Windshield else - climateControl.airflowDirections.value &= ~ClimateControl.Windshield + climateControl.airflowDirections &= ~ClimateControl.Windshield } } CheckBox { text: "Dashboard" - checked: climateControl.airflowDirections.value & ClimateControl.Dashboard - enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Dashboard) !== -1 + checked: climateControl.airflowDirections & ClimateControl.Dashboard onClicked: { if (checked) - climateControl.airflowDirections.value |= ClimateControl.Dashboard + climateControl.airflowDirections |= ClimateControl.Dashboard else - climateControl.airflowDirections.value &= ~ClimateControl.Dashboard + climateControl.airflowDirections &= ~ClimateControl.Dashboard } } CheckBox { text: "Floor" - checked: climateControl.airflowDirections.value & ClimateControl.Floor - enabled: climateControl.airflowDirections.availableValues.indexOf(ClimateControl.Floor) !== -1 + checked: climateControl.airflowDirections & ClimateControl.Floor onClicked: { if (checked) - climateControl.airflowDirections.value |= ClimateControl.Floor + climateControl.airflowDirections |= ClimateControl.Floor else - climateControl.airflowDirections.value &= ~ClimateControl.Floor + climateControl.airflowDirections &= ~ClimateControl.Floor } } } @@ -121,31 +118,28 @@ ApplicationWindow { CheckBox { text: "Air Condition" - checked: climateControl.airConditioning.value - enabled: climateControl.airConditioning.available + checked: climateControl.airConditioningEnabled onClicked: { - climateControl.airConditioning.value = checked + climateControl.airConditioningEnabled = checked } } CheckBox { text: "Heater" - checked: climateControl.heater.value - enabled: climateControl.heater.available + checked: climateControl.heaterEnabled onClicked: { - climateControl.heater.value = checked + climateControl.heaterEnabled = checked } } CheckBox { text: "Air Recirculation" - checked: climateControl.recirculationMode.value === ClimateControl.RecirculationOn - enabled: climateControl.airRecirculation.available + checked: climateControl.recirculationMode === ClimateControl.RecirculationOn onClicked: { if (checked) - climateControl.recirculationMode.value = ClimateControl.RecirculationOn + climateControl.recirculationMode = ClimateControl.RecirculationOn else - climateControl.recirculationMode.value = ClimateControl.RecirculationOff + climateControl.recirculationMode = ClimateControl.RecirculationOff } } @@ -157,12 +151,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.fanSpeedLevel.value - minimumValue: climateControl.fanSpeedLevel.minimumValue - maximumValue: climateControl.fanSpeedLevel.maximumValue - enabled: climateControl.fanSpeedLevel.available + value: climateControl.fanSpeedLevel onValueChanged: { - climateControl.fanSpeedLevel.value = value + climateControl.fanSpeedLevel = value } } } @@ -175,12 +166,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.steeringWheelHeater.value - minimumValue: climateControl.steeringWheelHeater.minimumValue - maximumValue: climateControl.steeringWheelHeater.maximumValue - enabled: climateControl.steeringWheelHeater.available + value: climateControl.steeringWheelHeater onValueChanged: { - climateControl.steeringWheelHeater.value = value + climateControl.steeringWheelHeater = value } } } @@ -199,12 +187,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.FrontLeft.targetTemperature.value - minimumValue: climateControl.zoneAt.FrontLeft.targetTemperature.minimumValue - maximumValue: climateControl.zoneAt.FrontLeft.targetTemperature.maximumValue - enabled: climateControl.zoneAt.FrontLeft.targetTemperature.available + value: climateControl.zoneAt.FrontLeft.targetTemperature onValueChanged: { - climateControl.zoneAt.FrontLeft.targetTemperature.value = value + climateControl.zoneAt.FrontLeft.targetTemperature = value } } } @@ -217,12 +202,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.FrontLeft.seatHeater.value - minimumValue: climateControl.zoneAt.FrontLeft.seatHeater.minimumValue - maximumValue: climateControl.zoneAt.FrontLeft.seatHeater.maximumValue - enabled: climateControl.zoneAt.FrontLeft.seatHeater.available + value: climateControl.zoneAt.FrontLeft.seatHeater onValueChanged: { - climateControl.zoneAt.FrontLeft.seatHeater.value = value + climateControl.zoneAt.FrontLeft.seatHeater = value } } } @@ -240,12 +222,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.FrontRight.targetTemperature.value - minimumValue: climateControl.zoneAt.FrontRight.targetTemperature.minimumValue - maximumValue: climateControl.zoneAt.FrontRight.targetTemperature.maximumValue - enabled: climateControl.zoneAt.FrontRight.targetTemperature.available + value: climateControl.zoneAt.FrontRight.targetTemperature onValueChanged: { - climateControl.zoneAt.FrontRight.targetTemperature.value = value + climateControl.zoneAt.FrontRight.targetTemperature = value } } } @@ -258,12 +237,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.FrontRight.seatHeater.value - minimumValue: climateControl.zoneAt.FrontRight.seatHeater.minimumValue - maximumValue: climateControl.zoneAt.FrontRight.seatHeater.maximumValue - enabled: climateControl.zoneAt.FrontRight.seatHeater.available + value: climateControl.zoneAt.FrontRight.seatHeater onValueChanged: { - climateControl.zoneAt.FrontRight.seatHeater.value = value + climateControl.zoneAt.FrontRight.seatHeater = value } } } @@ -281,12 +257,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.Rear.targetTemperature.value - minimumValue: climateControl.zoneAt.Rear.targetTemperature.minimumValue - maximumValue: climateControl.zoneAt.Rear.targetTemperature.maximumValue - enabled: climateControl.zoneAt.Rear.targetTemperature.available + value: climateControl.zoneAt.Rear.targetTemperature onValueChanged: { - climateControl.zoneAt.Rear.targetTemperature.value = value + climateControl.zoneAt.Rear.targetTemperature = value } } } @@ -299,12 +272,9 @@ ApplicationWindow { } SpinBox { - value: climateControl.zoneAt.Rear.seatHeater.value - minimumValue: climateControl.zoneAt.Rear.seatHeater.minimumValue - maximumValue: climateControl.zoneAt.Rear.seatHeater.maximumValue - enabled: climateControl.zoneAt.Rear.seatHeater.available + value: climateControl.zoneAt.Rear.seatHeater onValueChanged: { - climateControl.zoneAt.Rear.seatHeater.value = value + climateControl.zoneAt.Rear.seatHeater = value } } } diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.cpp b/examples/vehiclefunctions/climate_widget/mainwindow.cpp index 15dca4e..9e46a87 100644 --- a/examples/vehiclefunctions/climate_widget/mainwindow.cpp +++ b/examples/vehiclefunctions/climate_widget/mainwindow.cpp @@ -81,42 +81,30 @@ MainWindow::MainWindow(QWidget *parent) : //![2] //Air Flow Direction setupFlowDirectionRadioButtons(m_climateControl->airflowDirections()); - setupFlowDirectionAttribute(m_climateControl->airflowDirectionsAttribute()); connect(m_buttonGroup, static_cast(&QButtonGroup::buttonToggled), this, &MainWindow::onFlowDirectionButtonToggled); connect(m_climateControl, &QIviClimateControl::airflowDirectionsChanged, this, &MainWindow::setupFlowDirectionRadioButtons); - connect(m_climateControl, &QIviClimateControl::airflowDirectionsAttributeChanged, - this, &MainWindow::setupFlowDirectionAttribute); //Air Condition ui->cb_airCondition->setChecked(m_climateControl->isAirConditioningEnabled()); - ui->cb_airCondition->setEnabled(m_climateControl->airConditioningAttribute().isAvailable()); connect(m_climateControl, &QIviClimateControl::airConditioningEnabledChanged, ui->cb_airCondition, &QCheckBox::setChecked); - connect(m_climateControl, &QIviClimateControl::airConditioningAttributeChanged, - this, &MainWindow::onAirConditioningAttributeChanged); connect(ui->cb_airCondition, &QCheckBox::clicked, m_climateControl, &QIviClimateControl::setAirConditioningEnabled); //Air Recirculation - ui->cb_airRecirculation->setChecked(m_climateControl->recirculationMode() == QIviClimateControl::RecirculationOn); - ui->cb_airRecirculation->setEnabled(m_climateControl->recirculationModeAttribute().isAvailable()); + ui->cb_airRecirculation->setChecked(m_climateControl->recirculationMode() == QtIviVehicleFunctionsModule::RecirculationOn); connect(m_climateControl, &QIviClimateControl::recirculationModeChanged, this, &MainWindow::onAirRecirculationModeChanged); - connect(m_climateControl, &QIviClimateControl::recirculationModeAttributeChanged, - this, &MainWindow::onAirRecirculationAttributeChanged); connect(ui->cb_airRecirculation, &QCheckBox::clicked, this, &MainWindow::setAirRecirculationEnabled); //Heater ui->cb_heater->setChecked(m_climateControl->isHeaterEnabled()); - ui->cb_heater->setEnabled(m_climateControl->heaterAttribute().isAvailable()); connect(m_climateControl, &QIviClimateControl::heaterEnabledChanged, ui->cb_heater, &QCheckBox::setChecked); - connect(m_climateControl, &QIviClimateControl::heaterAttributeChanged, - this, &MainWindow::onHeaterAttributeChanged); connect(ui->cb_heater, &QCheckBox::clicked, m_climateControl, &QIviClimateControl::setHeaterEnabled); } @@ -130,44 +118,22 @@ MainWindow::~MainWindow() void MainWindow::setAirRecirculationEnabled(bool enabled) { if (enabled) - m_climateControl->setRecirculationMode(QIviClimateControl::RecirculationOn); + m_climateControl->setRecirculationMode(QtIviVehicleFunctionsModule::RecirculationOn); else - m_climateControl->setRecirculationMode(QIviClimateControl::RecirculationOff); + m_climateControl->setRecirculationMode(QtIviVehicleFunctionsModule::RecirculationOff); } -void MainWindow::onAirRecirculationModeChanged(QIviClimateControl::RecirculationMode mode) +void MainWindow::onAirRecirculationModeChanged(QtIviVehicleFunctionsModule::RecirculationMode mode) { - ui->cb_airRecirculation->setChecked(mode == QIviClimateControl::RecirculationOn); -} - -void MainWindow::onAirRecirculationAttributeChanged(const QIviPropertyAttribute &attribute) -{ - ui->cb_airRecirculation->setEnabled(attribute.isAvailable()); -} - -void MainWindow::onHeaterAttributeChanged(const QIviPropertyAttribute &attribute) -{ - ui->cb_heater->setEnabled(attribute.isAvailable()); -} - -void MainWindow::onAirConditioningAttributeChanged(const QIviPropertyAttribute & attribute) -{ - ui->cb_airCondition->setEnabled(attribute.isAvailable()); + ui->cb_airRecirculation->setChecked(mode == QtIviVehicleFunctionsModule::RecirculationOn); } //![3] -void MainWindow::setupFlowDirectionRadioButtons(QIviClimateControl::AirflowDirections direction) -{ - ui->cb_windshield->setChecked(direction.testFlag(QIviClimateControl::Windshield)); - ui->cb_dashboard->setChecked(direction.testFlag(QIviClimateControl::Dashboard)); - ui->cb_floor->setChecked(direction.testFlag(QIviClimateControl::Floor)); -} - -void MainWindow::setupFlowDirectionAttribute(const QIviPropertyAttribute &attribute) +void MainWindow::setupFlowDirectionRadioButtons(QtIviVehicleFunctionsModule::AirflowDirections direction) { - ui->cb_windshield->setEnabled(attribute.availableValues().contains(QIviClimateControl::Windshield)); - ui->cb_dashboard->setEnabled(attribute.availableValues().contains(QIviClimateControl::Dashboard)); - ui->cb_floor->setEnabled(attribute.availableValues().contains(QIviClimateControl::Floor)); + ui->cb_windshield->setChecked(direction.testFlag(QtIviVehicleFunctionsModule::Windshield)); + ui->cb_dashboard->setChecked(direction.testFlag(QtIviVehicleFunctionsModule::Dashboard)); + ui->cb_floor->setChecked(direction.testFlag(QtIviVehicleFunctionsModule::Floor)); } void MainWindow::onFlowDirectionButtonToggled(QAbstractButton *button, bool checked) @@ -175,14 +141,14 @@ void MainWindow::onFlowDirectionButtonToggled(QAbstractButton *button, bool chec Q_UNUSED(button) Q_UNUSED(checked) - QIviClimateControl::AirflowDirections direction; + QtIviVehicleFunctionsModule::AirflowDirections direction; if (ui->cb_windshield->isChecked()) - direction |= QIviClimateControl::Windshield; + direction |= QtIviVehicleFunctionsModule::Windshield; if (ui->cb_dashboard->isChecked()) - direction |= QIviClimateControl::Dashboard; + direction |= QtIviVehicleFunctionsModule::Dashboard; if (ui->cb_floor->isChecked()) - direction |= QIviClimateControl::Floor; + direction |= QtIviVehicleFunctionsModule::Floor; m_climateControl->setAirflowDirections(direction); } diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.h b/examples/vehiclefunctions/climate_widget/mainwindow.h index f14e35a..a7e0cd1 100644 --- a/examples/vehiclefunctions/climate_widget/mainwindow.h +++ b/examples/vehiclefunctions/climate_widget/mainwindow.h @@ -75,12 +75,8 @@ public: private slots: void setAirRecirculationEnabled(bool enabled); - void onAirRecirculationModeChanged(QIviClimateControl::RecirculationMode mode); - void onAirRecirculationAttributeChanged(const QIviPropertyAttribute &attribute); - void onHeaterAttributeChanged(const QIviPropertyAttribute &attribute); - void onAirConditioningAttributeChanged(const QIviPropertyAttribute &attribute); - void setupFlowDirectionRadioButtons(QIviClimateControl::AirflowDirections direction); - void setupFlowDirectionAttribute(const QIviPropertyAttribute &attribute); + void onAirRecirculationModeChanged(QtIviVehicleFunctionsModule::RecirculationMode mode); + void setupFlowDirectionRadioButtons(QtIviVehicleFunctionsModule::AirflowDirections direction); void onFlowDirectionButtonToggled(QAbstractButton *button, bool checked); private: diff --git a/examples/vehiclefunctions/window_qml/WindowItem.qml b/examples/vehiclefunctions/window_qml/WindowItem.qml index 31bf053..3212e71 100644 --- a/examples/vehiclefunctions/window_qml/WindowItem.qml +++ b/examples/vehiclefunctions/window_qml/WindowItem.qml @@ -73,25 +73,22 @@ GroupBox { ColumnLayout { RowLayout { - enabled: zone.state.available Label { text: "Window state: " } Label { - text: stateToString(zone.state.value) + text: stateToString(zone.state) } } Button { text: "open" - enabled: zone.state.available onClicked: zone.open() } Button { text: "close" - enabled: zone.state.available onClicked: zone.close() } @@ -101,14 +98,13 @@ GroupBox { ColumnLayout { RowLayout { - enabled: zone.blindState.available Label { text: "State: " } Label { - text: stateToString(zone.blindState.value) + text: stateToString(zone.blindState) } } @@ -119,33 +115,30 @@ GroupBox { RadioButton { text: "Open" exclusiveGroup: blindGroup - enabled: zone.blindMode.availableValues.indexOf(WindowControl.BlindOpen) !== -1 - checked: zone.blindMode.value === WindowControl.BlindOpen + checked: zone.blindMode === WindowControl.BlindOpen onCheckedChanged: { if (checked) - zone.blindMode.value = WindowControl.BlindOpen + zone.blindMode = WindowControl.BlindOpen } } RadioButton { text: "Closed" exclusiveGroup: blindGroup - enabled: zone.blindMode.availableValues.indexOf(WindowControl.BlindClosed) !== -1 - checked: zone.blindMode.value === WindowControl.BlindClosed + checked: zone.blindMode === WindowControl.BlindClosed onCheckedChanged: { if (checked) - zone.blindMode.value = WindowControl.BlindClosed + zone.blindMode = WindowControl.BlindClosed } } RadioButton { text: "Automatic" exclusiveGroup: blindGroup - enabled: zone.blindMode.availableValues.indexOf(WindowControl.AutoBlind) !== -1 - checked: zone.blindMode.value === WindowControl.AutoBlind + checked: zone.blindMode === WindowControl.AutoBlind onCheckedChanged: { if (checked) - zone.blindMode.value = WindowControl.AutoBlind + zone.blindMode = WindowControl.AutoBlind } } } @@ -157,14 +150,13 @@ GroupBox { ColumnLayout { RowLayout { - enabled: zone.heater.available Label { text: "Running: " } Label { - text: zone.heater.value + text: zone.heater } } @@ -175,33 +167,30 @@ GroupBox { RadioButton { text: "On" exclusiveGroup: heaterGroup - enabled: zone.heaterMode.availableValues.indexOf(WindowControl.HeaterOn) !== -1 - checked: zone.heaterMode.value === WindowControl.HeaterOn + checked: zone.heaterMode === WindowControl.HeaterOn onCheckedChanged: { if (checked) - zone.heaterMode.value = WindowControl.HeaterOn + zone.heaterMode = WindowControl.HeaterOn } } RadioButton { text: "Off" exclusiveGroup: heaterGroup - enabled: zone.heaterMode.availableValues.indexOf(WindowControl.HeaterOff) !== -1 - checked: zone.heaterMode.value === WindowControl.HeaterOff + checked: zone.heaterMode === WindowControl.HeaterOff onCheckedChanged: { if (checked) - zone.heaterMode.value = WindowControl.HeaterOff + zone.heaterMode = WindowControl.HeaterOff } } RadioButton { text: "Automatic" exclusiveGroup: heaterGroup - enabled: zone.heaterMode.availableValues.indexOf(WindowControl.AutoHeater) !== -1 - checked: zone.heaterMode.value === WindowControl.AutoHeater + checked: zone.heaterMode === WindowControl.AutoHeater onCheckedChanged: { if (checked) - zone.heaterMode.value = WindowControl.AutoHeater + zone.heaterMode = WindowControl.AutoHeater } } } -- cgit v1.2.1