summaryrefslogtreecommitdiffstats
path: root/meta-ivi-common/recipes-automotive/automotive-message-broker/automotive-message-broker/0008-Add-simple-Qt-QML-example.patch
blob: 36f9d7b3bcd614d0bcaed2f2c548ed0ac287532a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
From 7c452ae1228b01a3db697b5a74c9dee60dcfe352 Mon Sep 17 00:00:00 2001
From: Petr Nechaev <petr.nechaev@cogentembedded.com>
Date: Mon, 3 Aug 2015 14:17:40 +0300
Subject: [PATCH 8/9] Add simple Qt-QML example

The example requires qtdeclarative. It outputs values of basic vehicle
properties.
---
 plugins/dbus/amb-qt/CMakeLists.txt  |  6 +++++
 plugins/dbus/amb-qt/Meter.qml       | 46 +++++++++++++++++++++++++++++++++++++
 plugins/dbus/amb-qt/qtquicktest.cpp | 12 ++++++++++
 plugins/dbus/amb-qt/qtquicktest.qml | 35 ++++++++++++++++++++++++++++
 plugins/dbus/amb-qt/qtquicktest.qrc |  6 +++++
 5 files changed, 105 insertions(+)
 create mode 100644 plugins/dbus/amb-qt/Meter.qml
 create mode 100644 plugins/dbus/amb-qt/qtquicktest.cpp
 create mode 100644 plugins/dbus/amb-qt/qtquicktest.qml
 create mode 100644 plugins/dbus/amb-qt/qtquicktest.qrc

diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
index 42b7fb4..99f691b 100644
--- a/plugins/dbus/amb-qt/CMakeLists.txt
+++ b/plugins/dbus/amb-qt/CMakeLists.txt
@@ -31,10 +31,16 @@ target_link_libraries(ambqtquick amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY
 add_executable(ambtestclient test.cpp)
 target_link_libraries(ambtestclient amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
 
+qt5_add_resources(ambqtquicktest_RESOURCES qtquicktest.qrc)
+add_executable(ambqtquicktest qtquicktest.cpp ${ambqtquicktest_RESOURCES})
+target_link_libraries(ambqtquicktest amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
+qt5_use_modules(ambqtquicktest Quick Core)
+
 install (TARGETS amb-qt LIBRARY DESTINATION lib${LIB_SUFFIX})
 
 install (FILES ${ambqt_headers} DESTINATION ${INCLUDE_INSTALL_DIR}/ COMPONENT Devel)
 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb COMPONENT Devel)
 install (TARGETS ambqtquick DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb)
 install (TARGETS ambtestclient RUNTIME DESTINATION bin)
+install (TARGETS ambqtquicktest RUNTIME DESTINATION bin)
 endif(qt_bindings)
diff --git a/plugins/dbus/amb-qt/Meter.qml b/plugins/dbus/amb-qt/Meter.qml
new file mode 100644
index 0000000..370e4da
--- /dev/null
+++ b/plugins/dbus/amb-qt/Meter.qml
@@ -0,0 +1,46 @@
+/*
+Copyright (C) 2015 Cogent Embedded Inc.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+import QtQuick 2.0
+import amb 0.1
+
+Row {
+
+    property string name
+    onNameChanged: {
+        // we use objectName.propertyName format
+        var parts = name.split(".");
+        prop.objectName = parts[0];
+        prop.propertyName = parts.length >= 2 ? parts[1] : "Value";
+        prop.connect();
+    }
+
+    spacing: 10
+    Text {
+        text: parent.name
+        font.pointSize: 14
+        width: 300 // this is a guess
+    }
+    Text {
+        text: qsTr("%1").arg(prop.value)
+        font.pointSize: 14
+    }
+
+    AutomotivePropertyItem {
+        id: prop
+    }
+}
diff --git a/plugins/dbus/amb-qt/qtquicktest.cpp b/plugins/dbus/amb-qt/qtquicktest.cpp
new file mode 100644
index 0000000..4735d57
--- /dev/null
+++ b/plugins/dbus/amb-qt/qtquicktest.cpp
@@ -0,0 +1,12 @@
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+	QGuiApplication app(argc, argv);
+
+	QQmlApplicationEngine engine;
+	engine.load(QUrl(QStringLiteral("qrc:/qtquicktest.qml")));
+
+	return app.exec();
+}
diff --git a/plugins/dbus/amb-qt/qtquicktest.qml b/plugins/dbus/amb-qt/qtquicktest.qml
new file mode 100644
index 0000000..70cd846
--- /dev/null
+++ b/plugins/dbus/amb-qt/qtquicktest.qml
@@ -0,0 +1,35 @@
+/*
+Copyright (C) 2015 Cogent Embedded Inc.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+import QtQuick 2.0
+import QtQuick.Window 2.0
+
+Window {
+    visible: true
+    width: 500
+    height: 400
+
+    Column {
+        anchors.fill: parent;
+
+        Meter { name: "VehicleSpeed.Speed"}
+        Meter { name: "EngineSpeed.Speed"}
+        Meter { name: "SteeringWheel.Angle"}
+        Meter { name: "ThrottlePosition.Value"}
+        Meter { name: "BrakeOperation.BrakePressure"}
+    }
+}
diff --git a/plugins/dbus/amb-qt/qtquicktest.qrc b/plugins/dbus/amb-qt/qtquicktest.qrc
new file mode 100644
index 0000000..998ec70
--- /dev/null
+++ b/plugins/dbus/amb-qt/qtquicktest.qrc
@@ -0,0 +1,6 @@
+<RCC>
+    <qresource prefix="/">
+        <file>qtquicktest.qml</file>
+        <file>Meter.qml</file>
+    </qresource>
+</RCC>
-- 
1.9.1