1 From 7c452ae1228b01a3db697b5a74c9dee60dcfe352 Mon Sep 17 00:00:00 2001
2 From: Petr Nechaev <petr.nechaev@cogentembedded.com>
3 Date: Mon, 3 Aug 2015 14:17:40 +0300
4 Subject: [PATCH 8/9] Add simple Qt-QML example
6 The example requires qtdeclarative. It outputs values of basic vehicle
9 plugins/dbus/amb-qt/CMakeLists.txt | 6 +++++
10 plugins/dbus/amb-qt/Meter.qml | 46 +++++++++++++++++++++++++++++++++++++
11 plugins/dbus/amb-qt/qtquicktest.cpp | 12 ++++++++++
12 plugins/dbus/amb-qt/qtquicktest.qml | 35 ++++++++++++++++++++++++++++
13 plugins/dbus/amb-qt/qtquicktest.qrc | 6 +++++
14 5 files changed, 105 insertions(+)
15 create mode 100644 plugins/dbus/amb-qt/Meter.qml
16 create mode 100644 plugins/dbus/amb-qt/qtquicktest.cpp
17 create mode 100644 plugins/dbus/amb-qt/qtquicktest.qml
18 create mode 100644 plugins/dbus/amb-qt/qtquicktest.qrc
20 diff --git a/plugins/dbus/amb-qt/CMakeLists.txt b/plugins/dbus/amb-qt/CMakeLists.txt
21 index 42b7fb4..99f691b 100644
22 --- a/plugins/dbus/amb-qt/CMakeLists.txt
23 +++ b/plugins/dbus/amb-qt/CMakeLists.txt
24 @@ -31,10 +31,16 @@ target_link_libraries(ambqtquick amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY
25 add_executable(ambtestclient test.cpp)
26 target_link_libraries(ambtestclient amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries} ${gio_LIBRARIES})
28 +qt5_add_resources(ambqtquicktest_RESOURCES qtquicktest.qrc)
29 +add_executable(ambqtquicktest qtquicktest.cpp ${ambqtquicktest_RESOURCES})
30 +target_link_libraries(ambqtquicktest amb amb-qt ${QT_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
31 +qt5_use_modules(ambqtquicktest Quick Core)
33 install (TARGETS amb-qt LIBRARY DESTINATION lib${LIB_SUFFIX})
35 install (FILES ${ambqt_headers} DESTINATION ${INCLUDE_INSTALL_DIR}/ COMPONENT Devel)
36 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/qmldir DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb COMPONENT Devel)
37 install (TARGETS ambqtquick DESTINATION ${LIB_INSTALL_DIR}/qt5/qml/amb)
38 install (TARGETS ambtestclient RUNTIME DESTINATION bin)
39 +install (TARGETS ambqtquicktest RUNTIME DESTINATION bin)
41 diff --git a/plugins/dbus/amb-qt/Meter.qml b/plugins/dbus/amb-qt/Meter.qml
43 index 0000000..370e4da
45 +++ b/plugins/dbus/amb-qt/Meter.qml
48 +Copyright (C) 2015 Cogent Embedded Inc.
50 +This library is free software; you can redistribute it and/or
51 +modify it under the terms of the GNU Lesser General Public
52 +License as published by the Free Software Foundation; either
53 +version 2.1 of the License, or (at your option) any later version.
55 +This library is distributed in the hope that it will be useful,
56 +but WITHOUT ANY WARRANTY; without even the implied warranty of
57 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
58 +Lesser General Public License for more details.
60 +You should have received a copy of the GNU Lesser General Public
61 +License along with this library; if not, write to the Free Software
62 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
69 + property string name
71 + // we use objectName.propertyName format
72 + var parts = name.split(".");
73 + prop.objectName = parts[0];
74 + prop.propertyName = parts.length >= 2 ? parts[1] : "Value";
82 + width: 300 // this is a guess
85 + text: qsTr("%1").arg(prop.value)
89 + AutomotivePropertyItem {
93 diff --git a/plugins/dbus/amb-qt/qtquicktest.cpp b/plugins/dbus/amb-qt/qtquicktest.cpp
95 index 0000000..4735d57
97 +++ b/plugins/dbus/amb-qt/qtquicktest.cpp
99 +#include <QGuiApplication>
100 +#include <QQmlApplicationEngine>
102 +int main(int argc, char *argv[])
104 + QGuiApplication app(argc, argv);
106 + QQmlApplicationEngine engine;
107 + engine.load(QUrl(QStringLiteral("qrc:/qtquicktest.qml")));
111 diff --git a/plugins/dbus/amb-qt/qtquicktest.qml b/plugins/dbus/amb-qt/qtquicktest.qml
113 index 0000000..70cd846
115 +++ b/plugins/dbus/amb-qt/qtquicktest.qml
118 +Copyright (C) 2015 Cogent Embedded Inc.
120 +This library is free software; you can redistribute it and/or
121 +modify it under the terms of the GNU Lesser General Public
122 +License as published by the Free Software Foundation; either
123 +version 2.1 of the License, or (at your option) any later version.
125 +This library is distributed in the hope that it will be useful,
126 +but WITHOUT ANY WARRANTY; without even the implied warranty of
127 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
128 +Lesser General Public License for more details.
130 +You should have received a copy of the GNU Lesser General Public
131 +License along with this library; if not, write to the Free Software
132 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
135 +import QtQuick.Window 2.0
143 + anchors.fill: parent;
145 + Meter { name: "VehicleSpeed.Speed"}
146 + Meter { name: "EngineSpeed.Speed"}
147 + Meter { name: "SteeringWheel.Angle"}
148 + Meter { name: "ThrottlePosition.Value"}
149 + Meter { name: "BrakeOperation.BrakePressure"}
152 diff --git a/plugins/dbus/amb-qt/qtquicktest.qrc b/plugins/dbus/amb-qt/qtquicktest.qrc
154 index 0000000..998ec70
156 +++ b/plugins/dbus/amb-qt/qtquicktest.qrc
159 + <qresource prefix="/">
160 + <file>qtquicktest.qml</file>
161 + <file>Meter.qml</file>