summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2015-03-26 11:00:54 +0100
committerDominik Holland <dominik.holland@pelagicore.com>2015-03-26 15:44:49 +0100
commit2d11f4fd94953bc7f66a0b5dee43d0c7d5ae661d (patch)
tree4ccf95dc8659fa8c57f0656dcafb14beacea46b5 /examples
parent70b8abd12765ca820fdad44050ef3dcc62b84583 (diff)
downloadqtivi-2d11f4fd94953bc7f66a0b5dee43d0c7d5ae661d.tar.gz
Added a first small widget based example for ClimateControl
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro1
-rw-r--r--examples/vehiclefunctions/climate_widget/climate_widget.pro20
-rw-r--r--examples/vehiclefunctions/climate_widget/main.cpp11
-rw-r--r--examples/vehiclefunctions/climate_widget/mainwindow.cpp103
-rw-r--r--examples/vehiclefunctions/climate_widget/mainwindow.h35
-rw-r--r--examples/vehiclefunctions/climate_widget/mainwindow.ui106
-rw-r--r--examples/vehiclefunctions/vehiclefunctions.pro4
7 files changed, 280 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index 9671085..288b557 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1 +1,2 @@
TEMPLATE = subdirs
+SUBDIRS = vehiclefunctions
diff --git a/examples/vehiclefunctions/climate_widget/climate_widget.pro b/examples/vehiclefunctions/climate_widget/climate_widget.pro
new file mode 100644
index 0000000..16bcbe7
--- /dev/null
+++ b/examples/vehiclefunctions/climate_widget/climate_widget.pro
@@ -0,0 +1,20 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2015-03-26T09:15:31
+#
+#-------------------------------------------------
+
+QT += core gui QtIVICore QtIVIVehicleFunctions
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = climate_widget
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui
diff --git a/examples/vehiclefunctions/climate_widget/main.cpp b/examples/vehiclefunctions/climate_widget/main.cpp
new file mode 100644
index 0000000..b48f94e
--- /dev/null
+++ b/examples/vehiclefunctions/climate_widget/main.cpp
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.cpp b/examples/vehiclefunctions/climate_widget/mainwindow.cpp
new file mode 100644
index 0000000..8f1df08
--- /dev/null
+++ b/examples/vehiclefunctions/climate_widget/mainwindow.cpp
@@ -0,0 +1,103 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QMessageBox>
+#include <QSpinBox>
+#include <QButtonGroup>
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow),
+ m_radioButtonGroup(new QButtonGroup(this)),
+ m_climateControl(0)
+{
+ ui->setupUi(this);
+
+ m_radioButtonGroup->addButton(ui->rb_BiLevel);
+ m_radioButtonGroup->addButton(ui->rb_DefrostFloor);
+ m_radioButtonGroup->addButton(ui->rb_FloorDuct);
+ m_radioButtonGroup->addButton(ui->rb_FloorPanel);
+
+ m_climateControl = new QtIVIClimateControl(this);
+ m_climateControl->startAutoDiscovery();
+
+ if (!m_climateControl->serviceObject())
+ QMessageBox::critical(this, "Auto Discovery Failed !", "No Climate Backend available");
+
+ setupUI();
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::setupUI()
+{
+ //Air Flow Direction
+ setupFlowDirectionRadioButtons(m_climateControl->airflowDirection());
+ connect(m_radioButtonGroup, SIGNAL(buttonToggled(QAbstractButton*,bool)), this, SLOT(onFlowDirectionButtonToggled(QAbstractButton*,bool)));
+ //connect(m_radioButtonGroup, &QButtonGroup::buttonToggled, this, &MainWindow::onClimateDirectionButtonToggled);
+ connect(m_climateControl, &QtIVIClimateControl::airflowDirectionChanged, this, &MainWindow::setupFlowDirectionRadioButtons);
+
+ //Air Condition
+ ui->cb_airCondition->setChecked(m_climateControl->isAirConditioningEnabled());
+ connect(m_climateControl, &QtIVIClimateControl::airConditioningEnabledChanged, ui->cb_airCondition, &QCheckBox::setChecked);
+ connect(ui->cb_airCondition, &QCheckBox::clicked, m_climateControl, &QtIVIClimateControl::setAirConditioningEnabled);
+
+ //Air Recirculation
+ ui->cb_airRecirculation->setChecked(m_climateControl->isAirRecirculationEnabled());
+ connect(m_climateControl, &QtIVIClimateControl::airRecirculationEnabledChanged, ui->cb_airRecirculation, &QCheckBox::setChecked);
+ connect(ui->cb_airRecirculation, &QCheckBox::clicked, m_climateControl, &QtIVIClimateControl::setAirRecirculationEnabled);
+
+ //Heater
+ ui->cb_heater->setChecked(m_climateControl->isHeaterEnabled());
+ connect(m_climateControl, &QtIVIClimateControl::heaterEnabledChanged, ui->cb_heater, &QCheckBox::setChecked);
+ connect(ui->cb_heater, &QCheckBox::clicked, m_climateControl, &QtIVIClimateControl::setHeaterEnabled);
+
+ //Heater
+ ui->cb_steeringWheelHeater->setChecked(m_climateControl->isSteeringWheelHeaterEnabled());
+ connect(m_climateControl, &QtIVIClimateControl::steeringWheelHeaterEnabledChanged, ui->cb_steeringWheelHeater, &QCheckBox::setChecked);
+ connect(ui->cb_steeringWheelHeater, &QCheckBox::clicked, m_climateControl, &QtIVIClimateControl::setSteeringWheelHeaterEnabled);
+
+ //Fan Speed
+ ui->sb_fanSpeed->setValue(m_climateControl->fanSpeedLevel());
+ connect(m_climateControl, &QtIVIClimateControl::fanSpeedLevelChanged, ui->sb_fanSpeed, &QSpinBox::setValue);
+ connect(ui->sb_fanSpeed, SIGNAL(valueChanged(int)), m_climateControl, SLOT(setFanSpeedLevel(int)));
+ //connect(ui->sb_fanSpeed, &QSpinBox::valueChanged, m_climateControl, &QtIVIClimateControl::setFanSpeedLevel);
+}
+
+void MainWindow::setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirection direction)
+{
+ QAbstractButton* button = ui->rb_BiLevel;
+
+ if (direction == QtIVIClimateControl::BiLevel)
+ button = ui->rb_BiLevel;
+ else if (direction == QtIVIClimateControl::DefrostFloor)
+ button = ui->rb_DefrostFloor;
+ else if (direction == QtIVIClimateControl::FloorDuct)
+ button = ui->rb_FloorDuct;
+ else if (direction == QtIVIClimateControl::FloorPanel)
+ button = ui->rb_FloorPanel;
+
+ button->setChecked(true);
+}
+
+void MainWindow::onFlowDirectionButtonToggled(QAbstractButton *button, bool checked)
+{
+ if (!checked)
+ return;
+
+ QtIVIClimateControl::AirflowDirection direction = QtIVIClimateControl::BiLevel;
+
+ if (button == ui->rb_BiLevel)
+ direction = QtIVIClimateControl::BiLevel;
+ else if (button == ui->rb_DefrostFloor)
+ direction = QtIVIClimateControl::DefrostFloor;
+ else if (button == ui->rb_FloorDuct)
+ direction = QtIVIClimateControl::FloorDuct;
+ else if (button == ui->rb_FloorPanel)
+ direction = QtIVIClimateControl::FloorPanel;
+
+ m_climateControl->setAirflowDirection(direction);
+}
diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.h b/examples/vehiclefunctions/climate_widget/mainwindow.h
new file mode 100644
index 0000000..93fb91b
--- /dev/null
+++ b/examples/vehiclefunctions/climate_widget/mainwindow.h
@@ -0,0 +1,35 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QtIVIVehicleFunctions/QtIVIClimateControl>
+
+namespace Ui {
+class MainWindow;
+}
+
+class QButtonGroup;
+class QAbstractButton;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+ void setupUI();
+
+private slots:
+ void setupFlowDirectionRadioButtons(QtIVIClimateControl::AirflowDirection direction);
+ void onFlowDirectionButtonToggled(QAbstractButton * button, bool checked);
+
+private:
+
+ Ui::MainWindow *ui;
+ QButtonGroup *m_radioButtonGroup;
+ QtIVIClimateControl* m_climateControl;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/vehiclefunctions/climate_widget/mainwindow.ui b/examples/vehiclefunctions/climate_widget/mainwindow.ui
new file mode 100644
index 0000000..6af7321
--- /dev/null
+++ b/examples/vehiclefunctions/climate_widget/mainwindow.ui
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>384</width>
+ <height>324</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Climate Control</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QGroupBox" name="airFlowDirection">
+ <property name="title">
+ <string>Air Flow Direction</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="rb_FloorPanel">
+ <property name="text">
+ <string>Floor Panel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="rb_FloorDuct">
+ <property name="text">
+ <string>Floor Duct</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="rb_BiLevel">
+ <property name="text">
+ <string>Bi Level</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="rb_DefrostFloor">
+ <property name="text">
+ <string>Defrost Floor</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cb_airCondition">
+ <property name="text">
+ <string>Air Condition</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cb_heater">
+ <property name="text">
+ <string>Heater</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cb_airRecirculation">
+ <property name="text">
+ <string>Air Recirculation</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cb_steeringWheelHeater">
+ <property name="text">
+ <string>Steering Wheel Heater</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QFormLayout" name="formLayout_4">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::FieldsStayAtSizeHint</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="fanSpeedLabel">
+ <property name="text">
+ <string>Fan Speed</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="sb_fanSpeed"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/vehiclefunctions/vehiclefunctions.pro b/examples/vehiclefunctions/vehiclefunctions.pro
new file mode 100644
index 0000000..dd76ec8
--- /dev/null
+++ b/examples/vehiclefunctions/vehiclefunctions.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ climate_widget