diff options
Diffstat (limited to 'examples')
154 files changed, 8846 insertions, 40 deletions
diff --git a/examples/ivicore/ivicore.pro b/examples/ivicore/ivicore.pro index e5895e5..4d47b4f 100644 --- a/examples/ivicore/ivicore.pro +++ b/examples/ivicore/ivicore.pro @@ -6,3 +6,5 @@ qtConfig(ivigenerator) { qface-ivi-addressbook } qtConfig(ivigenerator): qtConfig(remoteobjects): SUBDIRS += qface-ivi-remote + +qtConfig(ivigenerator): qtConfig(remoteobjects): SUBDIRS += qface-tutorial diff --git a/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro index a65f7d5..c1cc0e1 100644 --- a/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro +++ b/examples/ivicore/qface-ivi-addressbook/backend_simulator/backend_simulator.pro @@ -23,3 +23,5 @@ INSTALLS += target #! [0] RESOURCES += plugin_resource.qrc #! [0] + +QML_IMPORT_PATH = $$OUT_PWD/qml diff --git a/examples/ivicore/qface-ivi-addressbook/backend_simulator/simulation.qml b/examples/ivicore/qface-ivi-addressbook/backend_simulator/simulation.qml index 73806c0..7aed660 100644 --- a/examples/ivicore/qface-ivi-addressbook/backend_simulator/simulation.qml +++ b/examples/ivicore/qface-ivi-addressbook/backend_simulator/simulation.qml @@ -53,7 +53,7 @@ //! [0] import QtQuick 2.0 -import example.ivi.addressbook.simulation 1.0 +import Example.IVI.AddressBook.simulation 1.0 Item { AddressBookBackend { diff --git a/examples/ivicore/qface-ivi-addressbook/demo/demo.pro b/examples/ivicore/qface-ivi-addressbook/demo/demo.pro index 7905c88..4eeaf8f 100644 --- a/examples/ivicore/qface-ivi-addressbook/demo/demo.pro +++ b/examples/ivicore/qface-ivi-addressbook/demo/demo.pro @@ -2,7 +2,7 @@ TARGET = qface-ivi-addressbook QMAKE_PROJECT_NAME = $$TARGET TEMPLATE = app -QT += qml quick quickcontrols2 +QT += qml quick CONFIG += c++11 CONFIG -= app_bundle DESTDIR = ../ @@ -17,7 +17,7 @@ RESOURCES += qml.qrc QMAKE_RPATHDIR += $ORIGIN # Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = diff --git a/examples/ivicore/qface-ivi-addressbook/demo/main.cpp b/examples/ivicore/qface-ivi-addressbook/demo/main.cpp index f5d4d87..d2264ec 100644 --- a/examples/ivicore/qface-ivi-addressbook/demo/main.cpp +++ b/examples/ivicore/qface-ivi-addressbook/demo/main.cpp @@ -53,7 +53,6 @@ #include <QGuiApplication> #include <QQmlApplicationEngine> -#include <QQuickStyle> #include <addressbookmodule.h> @@ -62,9 +61,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); AddressBookModule::registerTypes(); - AddressBookModule::registerQmlTypes(QLatin1String("IviAddressBook"), 1, 0); - - QQuickStyle::setStyle(QStringLiteral("Material")); + AddressBookModule::registerQmlTypes(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/ivicore/qface-ivi-addressbook/demo/main.qml b/examples/ivicore/qface-ivi-addressbook/demo/main.qml index cb057d7..9a487ed 100644 --- a/examples/ivicore/qface-ivi-addressbook/demo/main.qml +++ b/examples/ivicore/qface-ivi-addressbook/demo/main.qml @@ -55,7 +55,7 @@ import QtQuick 2.11 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 -import IviAddressBook 1.0 +import Example.IVI.AddressBook 1.0 Window { id: root @@ -91,7 +91,7 @@ Window { Button { Layout.fillWidth: true text: "New Contact" - onClicked: addressBook.insertContact(0, AddressBookModule.contact("Foo", "Bar", "12234")) + onClicked: addressBook.insertContact(0, AddressBook.contact("Foo", "Bar", "12234")) } } } diff --git a/examples/ivicore/qface-ivi-climate/demo/demo.pro b/examples/ivicore/qface-ivi-climate/demo/demo.pro index 6bc3bc1..e95e1f0 100644 --- a/examples/ivicore/qface-ivi-climate/demo/demo.pro +++ b/examples/ivicore/qface-ivi-climate/demo/demo.pro @@ -17,7 +17,7 @@ RESOURCES += qml.qrc QMAKE_RPATHDIR += $ORIGIN # Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = +QML_IMPORT_PATH += $$OUT_PWD/../frontend/qml # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = diff --git a/examples/ivicore/qface-ivi-climate/demo/main.cpp b/examples/ivicore/qface-ivi-climate/demo/main.cpp index 6dcce8e..c8bd770 100644 --- a/examples/ivicore/qface-ivi-climate/demo/main.cpp +++ b/examples/ivicore/qface-ivi-climate/demo/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); ClimateModule::registerTypes(); - ClimateModule::registerQmlTypes(QLatin1String("IviClimate"), 1, 0); + ClimateModule::registerQmlTypes(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/ivicore/qface-ivi-climate/demo/main.qml b/examples/ivicore/qface-ivi-climate/demo/main.qml index 93b28e8..eeb8808 100644 --- a/examples/ivicore/qface-ivi-climate/demo/main.qml +++ b/examples/ivicore/qface-ivi-climate/demo/main.qml @@ -54,7 +54,7 @@ import QtQuick 2.7 import QtQuick.Window 2.2 //! [0] -import IviClimate 1.0 +import Example.IVI.Climate 1.0 Window { diff --git a/examples/ivicore/qface-ivi-climate/example-ivi-climate.qface b/examples/ivicore/qface-ivi-climate/example-ivi-climate.qface index ec99060..07b5be7 100644 --- a/examples/ivicore/qface-ivi-climate/example-ivi-climate.qface +++ b/examples/ivicore/qface-ivi-climate/example-ivi-climate.qface @@ -10,111 +10,111 @@ module Example.IVI.Climate 1.0; @config: { zoned: true, id: "example.qtivi.ClimateControl/1.0", qml_type: "UiClimateControl" } interface ClimateControl { /** - * @brief Value is true if the air conditioning is enabled. + * \brief Value is true if the air conditioning is enabled. */ bool airConditioning; /** - * @brief value is true if the heater is enabled. + * \brief value is true if the heater is enabled. */ bool heater; /** - * @brief value holds the fan speed level, where the level can be between + * \brief value holds the fan speed level, where the level can be between * minimumValue(off) to maximumValue (strongest). */ @config_simulator: { range: [0, 50] } int fanSpeedLevel; /** - * @brief value holds the steering wheel heater level, where the level can + * \brief value holds the steering wheel heater level, where the level can * be between minimumValue(off) to maximumValue (warmest). */ @config_simulator: { minimum: 0 } int steeringWheelHeater; /** - * @brief value holds the target temperature of the zone expressed + * \brief value holds the target temperature of the zone expressed * in centigrades, where the temperature can be between * minimumValue(coolest) to maximumValue (warmest). */ @config_simulator: { maximum: 30.0 } real targetTemperature; /** - * @brief value holds the seat cooler level, where the level can be + * \brief value holds the seat cooler level, where the level can be * between minimumValue(off) to maximumValue (coolest). */ int seatCooler; /** - * @brief value holds the seat heater level, where the level can be between + * \brief value holds the seat heater level, where the level can be between * minimumValue(off) to maximumValue (warmest). */ int seatHeater; /** - * @brief value holds the outside temperature of the zone expressed in + * \brief value holds the outside temperature of the zone expressed in * centigrades, where the temperature can be between * minimumValue(coolest) to maximumValue (warmest). */ int outsideTemperature; /** - * @brief outside temp lable + * \brief outside temp lable */ @config_simulator: { domain: ["cold", "mild", "warm" ] } string outsideTemperatureLabel; /** - * @brief value is true if the zone synchronization is enabled. + * \brief value is true if the zone synchronization is enabled. * * Which zones and properties are synchronized is controlled * by the backend implementing it. */ bool zoneSynchronization; /** - * @brief value is true if defrost is enabled. Usually that means that the fans + * \brief value is true if defrost is enabled. Usually that means that the fans * are on the highest level to remove ice from the windshield. */ bool defrost; /** - * @brief value holds the recirculation mode + * \brief value holds the recirculation mode */ RecirculationMode recirculationMode; /** - * @brief value is true if the recirculation is currently running. + * \brief value is true if the recirculation is currently running. */ bool recirculation; /** - * @brief value holds the sensitivity level of the recirculation + * \brief value holds the sensitivity level of the recirculation * system when the recirculationMode is set to AutoRecirculation, * where the level can be between minimumValue(least sensitive) * to maximumValue(most sensitive). */ int recirculationSensitivityLevel; /** - * @brief value holds the climate mode + * \brief value holds the climate mode */ ClimateMode climateMode; /** - * @brief value holds the intensity level of the fan when the climateMode + * \brief value holds the intensity level of the fan when the climateMode * is set to AutoClimate, where the level can be between * minimumValue(least intensity) to maximumValue(most intensity). */ int automaticClimateFanIntensityLevel; /** - * @brief value holds the combination of flags indicating the areas + * \brief value holds the combination of flags indicating the areas * where airflow is on. */ AirflowDirection airflowDirections; } /** - * @brief Control where the airflow goes + * \brief Control where the airflow goes */ flag AirflowDirection { /** - * @brief Airflow to the windshield + * \brief Airflow to the windshield */ Windshield = 1, /** - * @brief Airflow to the dashboard + * \brief Airflow to the dashboard */ Dashboard = 2, /** - * @brief Airflow to the floor + * \brief Airflow to the floor */ Floor = 4 } diff --git a/examples/ivicore/qface-ivi-remote/demo/demo.pro b/examples/ivicore/qface-ivi-remote/demo/demo.pro index 4380fba..3013949 100644 --- a/examples/ivicore/qface-ivi-remote/demo/demo.pro +++ b/examples/ivicore/qface-ivi-remote/demo/demo.pro @@ -17,7 +17,7 @@ RESOURCES += qml.qrc QMAKE_RPATHDIR += $ORIGIN # Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = diff --git a/examples/ivicore/qface-ivi-remote/demo/main.cpp b/examples/ivicore/qface-ivi-remote/demo/main.cpp index 907faea..401ddb9 100644 --- a/examples/ivicore/qface-ivi-remote/demo/main.cpp +++ b/examples/ivicore/qface-ivi-remote/demo/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); RemoteModule::registerTypes(); - RemoteModule::registerQmlTypes(QLatin1String("IviRemote"), 1, 0); + RemoteModule::registerQmlTypes(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/examples/ivicore/qface-ivi-remote/demo/main.qml b/examples/ivicore/qface-ivi-remote/demo/main.qml index 8e421e9..ee95384 100644 --- a/examples/ivicore/qface-ivi-remote/demo/main.qml +++ b/examples/ivicore/qface-ivi-remote/demo/main.qml @@ -55,7 +55,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.3 import QtQuick.Window 2.2 //! [0] -import IviRemote 1.0 +import Example.IVI.Remote 1.0 Window { visible: true diff --git a/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.cpp b/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.cpp index 3f20ec9..e266407 100644 --- a/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.cpp +++ b/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.cpp @@ -57,7 +57,7 @@ ProcessingService::ProcessingService() setLastMessage(QStringLiteral("Service online.")); } -int ProcessingService::process(const QString & data) +QVariant ProcessingService::process(const QString & data) { setLastMessage(QStringLiteral("Processed data \'%1\'").arg(data)); return data.length(); diff --git a/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.h b/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.h index 8c7f6b2..1f65e82 100644 --- a/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.h +++ b/examples/ivicore/qface-ivi-remote/server_qtro/processingservice.h @@ -60,7 +60,7 @@ class ProcessingService : public ProcessingServiceSimpleSource public: ProcessingService(); - int process(const QString & data) override; + QVariant process(const QString & data) override; }; //! [0] #endif // PROCESSINGSERVICE_H diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/chapter1-basics.pro b/examples/ivicore/qface-tutorial/chapter1-basics/chapter1-basics.pro new file mode 100644 index 0000000..242571e --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/chapter1-basics.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + +instrument-cluster.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter1-basics/frontend/frontend.pro new file mode 100644 index 0000000..d80cc92 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter1-basics +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster.qface new file mode 100644 index 0000000..62dc847 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster.qface @@ -0,0 +1,5 @@ +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + int speed; +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..cbdd138 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Cluster.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 1") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: 3000 + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: 15 + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..1e6c3e4 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter1-basics +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter1-basics/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/main.cpp new file mode 100644 index 0000000..f291fce --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +#include "instrumentclustermodule.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + InstrumentClusterModule::registerQmlTypes(); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/chapter2-enums-structs.pro b/examples/ivicore/qface-tutorial/chapter2-enums-structs/chapter2-enums-structs.pro new file mode 100644 index 0000000..242571e --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/chapter2-enums-structs.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + +instrument-cluster.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter2-enums-structs/frontend/frontend.pro new file mode 100644 index 0000000..a899222 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter2-enums-structs +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster.qface new file mode 100644 index 0000000..5e74475 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster.qface @@ -0,0 +1,21 @@ +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + readonly int speed; + readonly int rpm; + readonly real fuel; + readonly real temperature; + readonly SystemType systemType; + readonly Warning currentWarning; +} + +enum SystemType { + Imperial, + Metric +} + +struct Warning { + string color + string text + string icon +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..1f73533 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Cluster.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 2") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + metricSystem: instrumentCluster.systemType === InstrumentCluster.Metric + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: instrumentCluster.rpm + warningColor: instrumentCluster.currentWarning.color + warningText: instrumentCluster.currentWarning.text + warningIcon: instrumentCluster.currentWarning.icon + fuelLevel: instrumentCluster.fuel + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: instrumentCluster.temperature + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..32a9570 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter2-enums-structs +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/main.cpp new file mode 100644 index 0000000..f291fce --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +#include "instrumentclustermodule.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + InstrumentClusterModule::registerQmlTypes(); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..ef80b73 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/backend_simulator/backend_simulator.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_simulation) +DESTDIR = ../qtivi + +QT += core ivicore +CONFIG += ivigenerator plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../instrument-cluster.qface +PLUGIN_TYPE = qtivi + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter3-simulation-backend +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/chapter3-simulation-backend.pro b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/chapter3-simulation-backend.pro new file mode 100644 index 0000000..ccb1fdd --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/chapter3-simulation-backend.pro @@ -0,0 +1,12 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + backend_simulator \ + imports \ + +instrument-cluster.depends = frontend +backend_simulator.depends = frontend +imports.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/frontend/frontend.pro new file mode 100644 index 0000000..28073c8 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter3-simulation-backend +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/imports/imports.pro b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/imports/imports.pro new file mode 100644 index 0000000..9b26bad --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/imports/imports.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +CONFIG += plugin +QT += ivicore + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../instrument-cluster.qface + +load(ivigenerator) + +DESTDIR = $$OUT_PWD/$$replace(URI, \\., /) + +exists($$OUT_PWD/qmldir) { + cpqmldir.files = $$OUT_PWD/qmldir \ + $$OUT_PWD/plugins.qmltypes + cpqmldir.path = $$DESTDIR + cpqmldir.CONFIG = no_check_exist + COPIES += cpqmldir +} + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter3-simulation-backend/imports +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster.qface new file mode 100644 index 0000000..e0a1ea3 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster.qface @@ -0,0 +1,21 @@ +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + readonly int speed; + readonly int rpm; + readonly int fuel; + readonly real temperature; + readonly SystemType systemType; + readonly Warning currentWarning; +} + +enum SystemType { + Imperial, + Metric +} + +struct Warning { + string color + string text + string icon +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..cd7dd95 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Cluster.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 3") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + metricSystem: instrumentCluster.systemType === InstrumentCluster.Metric + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: instrumentCluster.rpm + warningColor: instrumentCluster.currentWarning.color + warningText: instrumentCluster.currentWarning.text + warningIcon: instrumentCluster.currentWarning.icon + fuelLevel: instrumentCluster.fuel + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: instrumentCluster.temperature + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..6cfaacb --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter3-simulation-backend +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/main.cpp new file mode 100644 index 0000000..57b00b6 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.addImportPath(app.applicationDirPath() + "/imports"); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..73e020f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/backend_simulator.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_simulation) +DESTDIR = ../qtivi + +QT += core ivicore +CONFIG += ivigenerator plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../instrument-cluster.qface +PLUGIN_TYPE = qtivi + +RESOURCES += \ + simulation.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter4-simulation-behavior +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qml new file mode 100644 index 0000000..39c0ca4 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.10 +import Example.IVI.InstrumentCluster.simulation 1.0 + +QtObject { + property var settings : IviSimulator.findData(IviSimulator.simulationData, "InstrumentCluster") + property bool defaultInitialized: false + property LoggingCategory qLcInstrumentCluster: LoggingCategory { + name: "example.ivi.instrumentcluster.simulation.instrumentclusterbackend" + } + property var backend : InstrumentClusterBackend { + + function initialize() { + console.log(qLcInstrumentCluster, "INITIALIZE") + if (!defaultInitialized) { + IviSimulator.initializeDefault(settings, backend) + defaultInitialized = true + } + Base.initialize() + } + + property int gearSpeed: 260 / 6 + property int currentGear: speed / gearSpeed + rpm : currentGear >= 1 ? 3000 + (speed % gearSpeed) / gearSpeed * 2000 + : (speed % gearSpeed) / gearSpeed * 5000 + + property var animation: SequentialAnimation { + loops: Animation.Infinite + running: true + + ParallelAnimation { + SequentialAnimation { + + NumberAnimation { + target: backend + property: "speed" + from: 0 + to: 80 + duration: 4000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 50 + duration: 2000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 200 + duration: 7000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning("red","LOW FUEL", "images/fuelsymbol_orange.png") + } + } + + NumberAnimation { + target: backend + property: "speed" + to: 0 + duration: 5000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning() + } + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 1 + to: 0.22 + duration: 18000 + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 0.22 + to: 1 + duration: 4000 + } + } + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qrc b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qrc new file mode 100644 index 0000000..d2b5685 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/simulation"/> + <qresource prefix="/"> + <file>simulation.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/chapter4-simulation-behavior.pro b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/chapter4-simulation-behavior.pro new file mode 100644 index 0000000..ccb1fdd --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/chapter4-simulation-behavior.pro @@ -0,0 +1,12 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + backend_simulator \ + imports \ + +instrument-cluster.depends = frontend +backend_simulator.depends = frontend +imports.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/frontend/frontend.pro new file mode 100644 index 0000000..42ae87a --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter4-simulation-behavior +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/imports/imports.pro b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/imports/imports.pro new file mode 100644 index 0000000..631ab63 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/imports/imports.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +CONFIG += plugin +QT += ivicore + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../instrument-cluster.qface + +load(ivigenerator) + +DESTDIR = $$OUT_PWD/$$replace(URI, \\., /) + +exists($$OUT_PWD/qmldir) { + cpqmldir.files = $$OUT_PWD/qmldir \ + $$OUT_PWD/plugins.qmltypes + cpqmldir.path = $$DESTDIR + cpqmldir.CONFIG = no_check_exist + COPIES += cpqmldir +} + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter4-simulation-behavior/imports +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster.qface new file mode 100644 index 0000000..f6a5c9f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster.qface @@ -0,0 +1,23 @@ +@config_simulator: { simulationFile: "qrc:/simulation.qml" } +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + readonly int speed; + readonly int rpm; + readonly real fuel; + @config_simulator: { default: 15 } + readonly real temperature; + readonly SystemType systemType; + readonly Warning currentWarning; +} + +enum SystemType { + Imperial, + Metric +} + +struct Warning { + string color + string text + string icon +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..db33660 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Cluster.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 4") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + metricSystem: instrumentCluster.systemType === InstrumentCluster.Metric + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: instrumentCluster.rpm + warningColor: instrumentCluster.currentWarning.color + warningText: instrumentCluster.currentWarning.text + warningIcon: instrumentCluster.currentWarning.icon + fuelLevel: instrumentCluster.fuel + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: instrumentCluster.temperature + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..e52efd2 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter4-simulation-behavior +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/main.cpp new file mode 100644 index 0000000..57b00b6 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.addImportPath(app.applicationDirPath() + "/imports"); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/miles.json b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/miles.json new file mode 100644 index 0000000..98055c3 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter4-simulation-behavior/miles.json @@ -0,0 +1,9 @@ + +{ + "InstrumentCluster": { + "systemType": { + "type": "enum", + "value": "InstrumentClusterModule::Imperial" + } + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/backend_qtro/backend_qtro.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_qtro/backend_qtro.pro new file mode 100644 index 0000000..ad237bc --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_qtro/backend_qtro.pro @@ -0,0 +1,17 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_qtro) +DESTDIR = ../qtivi + +QT += core ivicore +CONFIG += ivigenerator plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = backend_qtro +QFACE_SOURCES = ../instrument-cluster.qface +PLUGIN_TYPE = qtivi + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..0a1f191 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/backend_simulator.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_simulation) +DESTDIR = ../qtivi + +QT += core ivicore +CONFIG += ivigenerator plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../instrument-cluster.qface +PLUGIN_TYPE = qtivi + +RESOURCES += \ + simulation.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qml new file mode 100644 index 0000000..e052160 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.10 +import Example.IVI.InstrumentCluster.simulation 1.0 + +QtObject { + property var settings : IviSimulator.findData(IviSimulator.simulationData, "InstrumentCluster") + property bool defaultInitialized: false + property LoggingCategory qLcInstrumentCluster: LoggingCategory { + name: "example.ivi.instrumentcluster.simulation.instrumentclusterbackend" + } + property var backend : InstrumentClusterBackend { + + function initialize() { + console.log(qLcInstrumentCluster, "INITIALIZE") + if (!defaultInitialized) { + IviSimulator.initializeDefault(settings, backend) + defaultInitialized = true + } + Base.initialize() + } + + property int gearSpeed: 260 / 6 + property int currentGear: speed / gearSpeed + rpm : currentGear >= 1 ? 3000 + (speed % gearSpeed) / gearSpeed * 2000 + : (speed % gearSpeed) / gearSpeed * 5000 + + property var animation: SequentialAnimation { + loops: Animation.Infinite + running: true + + ParallelAnimation { + SequentialAnimation { + + NumberAnimation { + target: backend + property: "speed" + from: 0 + to: 80 + duration: 4000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 50 + duration: 2000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 200 + duration: 7000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning("red","LOW FUEL", "images/fuelsymbol_orange.png") + } + } + + NumberAnimation { + target: backend + property: "speed" + to: 0 + duration: 5000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning() + } + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 1 + to: 0 + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 0 + to: 1 + duration: 4000 + } + } + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qrc b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qrc new file mode 100644 index 0000000..d2b5685 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/simulation"/> + <qresource prefix="/"> + <file>simulation.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/chapter5-ipc.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/chapter5-ipc.pro new file mode 100644 index 0000000..4409a6d --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/chapter5-ipc.pro @@ -0,0 +1,16 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + backend_simulator \ + backend_qtro \ + imports \ + simulation_server \ + +instrument-cluster.depends = frontend +backend_simulator.depends = frontend +backend_qtro.depends = frontend +imports.depends = frontend +simulation_server.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/frontend/frontend.pro new file mode 100644 index 0000000..6560c90 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/imports/imports.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/imports/imports.pro new file mode 100644 index 0000000..2f11d1f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/imports/imports.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +CONFIG += plugin +QT += ivicore + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../instrument-cluster.qface + +load(ivigenerator) + +DESTDIR = $$OUT_PWD/$$replace(URI, \\., /) + +exists($$OUT_PWD/qmldir) { + cpqmldir.files = $$OUT_PWD/qmldir \ + $$OUT_PWD/plugins.qmltypes + cpqmldir.path = $$DESTDIR + cpqmldir.CONFIG = no_check_exist + COPIES += cpqmldir +} + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc/imports +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster.qface new file mode 100644 index 0000000..f6a5c9f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster.qface @@ -0,0 +1,23 @@ +@config_simulator: { simulationFile: "qrc:/simulation.qml" } +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + readonly int speed; + readonly int rpm; + readonly real fuel; + @config_simulator: { default: 15 } + readonly real temperature; + readonly SystemType systemType; + readonly Warning currentWarning; +} + +enum SystemType { + Imperial, + Metric +} + +struct Warning { + string color + string text + string icon +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..5ca46eb --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Cluster.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 5") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + metricSystem: instrumentCluster.systemType === InstrumentCluster.Metric + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: instrumentCluster.rpm + warningColor: instrumentCluster.currentWarning.color + warningText: instrumentCluster.currentWarning.text + warningIcon: instrumentCluster.currentWarning.icon + fuelLevel: instrumentCluster.fuel + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: instrumentCluster.temperature + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..38b428d --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter5-ipc +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/main.cpp new file mode 100644 index 0000000..57b00b6 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.addImportPath(app.applicationDirPath() + "/imports"); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro b/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro new file mode 100644 index 0000000..43536d2 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro @@ -0,0 +1,19 @@ +TARGET = chapter5-ipc-server +DESTDIR = .. + +QT = core ivicore +QT -= gui +CONFIG += ivigenerator + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = server_qtro_simulator +QFACE_SOURCES = ../instrument-cluster.qface + +RESOURCES += ../backend_simulator/simulation.qrc + +QML_IMPORT_PATH = $$OUT_PWD/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter5-ipc/simulation_server +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/backend_dbus.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/backend_dbus.pro new file mode 100644 index 0000000..3529cf6 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/backend_dbus.pro @@ -0,0 +1,32 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_dbus) +DESTDIR = ../qtivi + +QT += ivicore dbus +CONFIG += plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend $$PWD/../demo_server + +PLUGIN_TYPE = qtivi + +cluster.files = ../demo_server/instrumentcluster.xml +cluster.header_flags += -i dbus_conversion.h + +DBUS_INTERFACES += cluster + +HEADERS += \ + ../demo_server/dbus_conversion.h \ + instrumentclusterbackend.h \ + instrumentclusterplugin.h + +SOURCES += \ + instrumentclusterbackend.cpp \ + instrumentclusterplugin.cpp + +OTHER_FILES += \ + instrumentcluster_dbus.json + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentcluster_dbus.json b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentcluster_dbus.json new file mode 100644 index 0000000..7461695 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentcluster_dbus.json @@ -0,0 +1,5 @@ +{ + "interfaces" : [ + "Example.IVI.InstrumentCluster.InstrumentCluster" + ] +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.cpp b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.cpp new file mode 100644 index 0000000..6bc8335 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include "instrumentclusterbackend.h" + +#include <QDBusConnection> + +InstrumentClusterBackend::InstrumentClusterBackend(QObject *parent) + : InstrumentClusterBackendInterface(parent) + , m_client(nullptr) +{ + qDBusRegisterMetaType<Warning>(); + qDBusRegisterMetaType<InstrumentClusterModule::SystemType>(); +} + +void InstrumentClusterBackend::initialize() +{ + if (!m_client) + setupConnection(); + if (m_fetchList.isEmpty()) { + emit speedChanged(m_speed); + emit rpmChanged(m_rpm); + emit fuelChanged(m_fuel); + emit temperatureChanged(m_temperature); + emit systemTypeChanged(m_systemType); + emit currentWarningChanged(m_warning); + emit initializationDone(); + } +} + +void InstrumentClusterBackend::setupConnection() +{ + qInfo() << "Connecting to the Server"; + m_client = new ExampleIVIInstrumentClusterInterface("Example.IVI.InstrumentCluster", "/", QDBusConnection::sessionBus()); + connect(m_client, &ExampleIVIInstrumentClusterInterface::speedChanged, + this, &InstrumentClusterBackend::onSpeedChanged); + connect(m_client, &ExampleIVIInstrumentClusterInterface::rpmChanged, + this, &InstrumentClusterBackend::onRpmChanged); + connect(m_client, &ExampleIVIInstrumentClusterInterface::fuelChanged, + this, &InstrumentClusterBackend::onFuelChanged); + connect(m_client, &ExampleIVIInstrumentClusterInterface::temperatureChanged, + this, &InstrumentClusterBackend::onTemperaturChanged); + connect(m_client, &ExampleIVIInstrumentClusterInterface::systemTypeChanged, + this, &InstrumentClusterBackend::onSystemTypeChanged); + connect(m_client, &ExampleIVIInstrumentClusterInterface::currentWarningChanged, + this, &InstrumentClusterBackend::onCurrentWarningChanged); + fetchSpeed(); + fetchRpm(); + fetchFuel(); + fetchTemperature(); + fetchSystemType(); + fetchCurrentWarning(); +} + +void InstrumentClusterBackend::fetchSpeed() +{ + m_fetchList.append("speed"); + auto reply = m_client->asyncCall("speed"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<int> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("speed"); + this->onSpeedChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::fetchRpm() +{ + m_fetchList.append("rpm"); + auto reply = m_client->asyncCall("rpm"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<int> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("rpm"); + this->onRpmChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::fetchFuel() +{ + m_fetchList.append("fuel"); + auto reply = m_client->asyncCall("fuel"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<int> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("fuel"); + this->onFuelChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::fetchTemperature() +{ + m_fetchList.append("temperature"); + auto reply = m_client->asyncCall("temperature"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<qreal> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("temperature"); + this->temperatureChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::fetchSystemType() +{ + m_fetchList.append("systemType"); + auto reply = m_client->asyncCall("systemType"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<InstrumentClusterModule::SystemType> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("systemType"); + this->onSystemTypeChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::fetchCurrentWarning() +{ + m_fetchList.append("currentWarning"); + auto reply = m_client->asyncCall("currentWarning"); + auto watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply<Warning> reply = *watcher; + if (reply.isError()) { + qCritical() << reply.error(); + } else { + m_fetchList.removeAll("currentWarning"); + this->onCurrentWarningChanged(reply.value()); + watcher->deleteLater(); + this->checkInitDone(); + } + }); +} + +void InstrumentClusterBackend::checkInitDone() +{ + if (m_fetchList.isEmpty()) { + qInfo() << "All properties initialized"; + emit initializationDone(); + } +} + +void InstrumentClusterBackend::onSpeedChanged(int speed) +{ + m_speed = speed; + emit speedChanged(speed); +} + +void InstrumentClusterBackend::onRpmChanged(int rpm) +{ + m_rpm = rpm; + emit rpmChanged(rpm); +} + +void InstrumentClusterBackend::onFuelChanged(qreal fuel) +{ + m_fuel = fuel; + emit fuelChanged(fuel); +} + +void InstrumentClusterBackend::onTemperaturChanged(qreal temperature) +{ + m_temperature = temperature; + emit temperatureChanged(temperature); +} + +void InstrumentClusterBackend::onSystemTypeChanged(InstrumentClusterModule::SystemType systemType) +{ + m_systemType = systemType; + emit systemTypeChanged(systemType); +} + +void InstrumentClusterBackend::onCurrentWarningChanged(const Warning &warning) +{ + m_warning = warning; + emit currentWarningChanged(warning); +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.h b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.h new file mode 100644 index 0000000..f6f0a5c --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#ifndef INSTRUMENTCLUSTERBACKEND_H +#define INSTRUMENTCLUSTERBACKEND_H + +#include "instrumentclusterbackendinterface.h" +#include "instrumentcluster_interface.h" + +class InstrumentClusterBackend : public InstrumentClusterBackendInterface +{ + Q_OBJECT +public: + InstrumentClusterBackend(QObject *parent = nullptr); + +public: + virtual void initialize() override; + + void setupConnection(); + void fetchSpeed(); + void fetchRpm(); + void fetchFuel(); + void fetchTemperature(); + void fetchSystemType(); + void fetchCurrentWarning(); + void checkInitDone(); + +public Q_SLOTS: + void onSpeedChanged(int speed); + void onRpmChanged(int rpm); + void onFuelChanged(qreal fuel); + void onTemperaturChanged(qreal temperature); + void onSystemTypeChanged(InstrumentClusterModule::SystemType systemType); + void onCurrentWarningChanged(const Warning &warning); + +private: + ExampleIVIInstrumentClusterInterface *m_client; + QStringList m_fetchList; + int m_speed; + int m_rpm; + qreal m_fuel; + qreal m_temperature; + InstrumentClusterModule::SystemType m_systemType; + Warning m_warning; +}; + +#endif // INSTRUMENTCLUSTERBACKEND_H diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.cpp b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.cpp new file mode 100644 index 0000000..8c7d65d --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include "instrumentclusterplugin.h" + +InstrumentClusterPlugin::InstrumentClusterPlugin(QObject *parent) + : QObject(parent) + , m_backend(new InstrumentClusterBackend) +{ +} + +QStringList InstrumentClusterPlugin::interfaces() const +{ + return QStringList(InstrumentCluster_InstrumentCluster_iid); +} + +QIviFeatureInterface *InstrumentClusterPlugin::interfaceInstance(const QString &interface) const +{ + if (interface == InstrumentCluster_InstrumentCluster_iid) + return m_backend; + + return nullptr; +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.h b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.h new file mode 100644 index 0000000..153091c --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#ifndef INSTRUMENTCLUSTERPLUGIN_H +#define INSTRUMENTCLUSTERPLUGIN_H + +#include <QObject> +#include <QIviServiceInterface> +#include "instrumentclusterbackend.h" + +class InstrumentClusterPlugin : public QObject, public QIviServiceInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID QIviServiceInterface_iid FILE "instrumentcluster_dbus.json") + Q_INTERFACES(QIviServiceInterface) + +public: + explicit InstrumentClusterPlugin(QObject *parent = nullptr); + + QStringList interfaces() const override; + QIviFeatureInterface *interfaceInstance(const QString &interface) const override; + +private: + InstrumentClusterBackend *m_backend; +}; + +#endif // INSTRUMENTCLUSTERPLUGIN_H diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/backend_simulator.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/backend_simulator.pro new file mode 100644 index 0000000..e0bf54a --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/backend_simulator.pro @@ -0,0 +1,23 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(instrumentcluster_simulation) +DESTDIR = ../qtivi + +QT += core ivicore +CONFIG += ivigenerator plugin + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = backend_simulator +QFACE_SOURCES = ../instrument-cluster.qface +PLUGIN_TYPE = qtivi + +RESOURCES += \ + simulation.qrc + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qml new file mode 100644 index 0000000..58cac5b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.10 +import Example.IVI.InstrumentCluster.simulation 1.0 + +QtObject { + property var settings : IviSimulator.findData(IviSimulator.simulationData, "InstrumentCluster") + property bool defaultInitialized: false + property LoggingCategory qLcInstrumentCluster: LoggingCategory { + name: "example.ivi.instrumentcluster.simulation.instrumentclusterbackend" + } + property var backend : InstrumentClusterBackend { + + function initialize() { + console.log(qLcInstrumentCluster, "INITIALIZE") + if (!defaultInitialized) { + IviSimulator.initializeDefault(settings, backend) + defaultInitialized = true + } + Base.initialize() + } + + property int gearSpeed: 260 / 6 + property int currentGear: speed / gearSpeed + rpm: currentGear >= 1 ? 3000 + (speed % gearSpeed) / gearSpeed * 2000 + : (speed % gearSpeed) / gearSpeed * 5000 + + property var animation: SequentialAnimation { + loops: Animation.Infinite + running: true + + ParallelAnimation { + SequentialAnimation { + + NumberAnimation { + target: backend + property: "speed" + from: 0 + to: 80 + duration: 4000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 50 + duration: 2000 + } + + NumberAnimation { + target: backend + property: "speed" + to: 200 + duration: 7000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning("red","LOW FUEL", "images/fuelsymbol_orange.png") + } + } + + NumberAnimation { + target: backend + property: "speed" + to: 0 + duration: 5000 + } + + ScriptAction { + script: { + backend.currentWarning = InstrumentCluster.warning() + } + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 1 + to: 0 + } + } + + NumberAnimation { + target: backend + property: "fuel" + from: 0 + to: 1 + duration: 4000 + } + } + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qrc b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qrc new file mode 100644 index 0000000..d2b5685 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/simulation"/> + <qresource prefix="/"> + <file>simulation.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/chapter6-own-backend.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/chapter6-own-backend.pro new file mode 100644 index 0000000..8658911 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/chapter6-own-backend.pro @@ -0,0 +1,16 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + frontend \ + backend_simulator \ + backend_dbus \ + imports \ + demo_server \ + +instrument-cluster.depends = frontend +backend_simulator.depends = frontend +backend_dbus.depends = frontend +imports.depends = frontend +demo_server.depends = frontend + +OTHER_FILES += instrument-cluster.qface diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/dbus_conversion.h b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/dbus_conversion.h new file mode 100644 index 0000000..631c4d2 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/dbus_conversion.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#ifndef DBUS_CONVERSION_H +#define DBUS_CONVERSION_H + +#include <QDBusArgument> +#include "warning.h" +#include "instrumentclustermodule.h" + +QT_BEGIN_NAMESPACE + +Q_ALWAYS_INLINE QDBusArgument &operator<<(QDBusArgument &argument, const Warning &data) +{ + argument.beginStructure(); + argument << data.color(); + argument << data.text(); + argument << data.icon(); + argument.endStructure(); + + return argument; +} + +Q_ALWAYS_INLINE const QDBusArgument &operator>>(const QDBusArgument &argument, Warning &data) +{ + argument.beginStructure(); + QString color; + QString text; + QString icon; + argument >> color; + argument >> text; + argument >> icon; + data.setColor(color); + data.setText(text); + data.setIcon(icon); + argument.endStructure(); + + return argument; +} + +Q_ALWAYS_INLINE QDBusArgument &operator<<(QDBusArgument &argument, InstrumentClusterModule::SystemType data) +{ + argument.beginStructure(); + argument << quint32(data); + argument.endStructure(); + + return argument; +} + +Q_ALWAYS_INLINE const QDBusArgument &operator>>(const QDBusArgument &argument, InstrumentClusterModule::SystemType &data) +{ + argument.beginStructure(); + quint32 systemType; + argument >> systemType; + data = InstrumentClusterModule::toSystemType(systemType, nullptr); + argument.endStructure(); + + return argument; +} + +QT_END_NAMESPACE + +#endif // DBUS_CONVERSION_H diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/demo_server.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/demo_server.pro new file mode 100644 index 0000000..4e6703a --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/demo_server.pro @@ -0,0 +1,24 @@ +TARGET = chapter6-demo-server + +QT += ivicore dbus +QT -= gui + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +cluster.files = instrumentcluster.xml +cluster.header_flags += -i dbus_conversion.h + +DBUS_ADAPTORS += cluster + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend +INSTALLS += target + +SOURCES += \ + instrumentcluster.cpp \ + main.cpp + +HEADERS += \ + instrumentcluster.h \ + dbus_conversion.h \ diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.cpp b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.cpp new file mode 100644 index 0000000..45c7a03 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include "instrumentcluster.h" +#include <QThread> + +InstrumentCluster::InstrumentCluster(QObject *parent) + : QObject(parent) + , m_speed(0) + , m_rpm(0) + , m_fuel(0) + , m_temperature(15) + , m_systemType(InstrumentClusterModule::Metric) +{ + startTimer(100); +} + +int InstrumentCluster::speed() const +{ + //QThread::sleep(5); + return m_speed; +} + +int InstrumentCluster::rpm() const +{ + return m_rpm; +} + +qreal InstrumentCluster::fuel() const +{ + return m_fuel; +} + +qreal InstrumentCluster::temperature() const +{ + return m_temperature; +} + +InstrumentClusterModule::SystemType InstrumentCluster::systemType() const +{ + return m_systemType; +} + +Warning InstrumentCluster::currentWarning() const +{ + return m_currentWarning; +} + +void InstrumentCluster::setSpeed(int speed) +{ + if (m_speed == speed) + return; + + m_speed = speed; + emit speedChanged(m_speed); +} + +void InstrumentCluster::setRpm(int rpm) +{ + if (m_rpm == rpm) + return; + + m_rpm = rpm; + emit rpmChanged(m_rpm); +} + +void InstrumentCluster::setFuel(qreal fuel) +{ + if (qFuzzyCompare(m_fuel, fuel)) + return; + + m_fuel = fuel; + emit fuelChanged(m_fuel); +} + +void InstrumentCluster::setTemperature(qreal temperature) +{ + if (qFuzzyCompare(m_temperature, temperature)) + return; + + m_temperature = temperature; + emit temperatureChanged(m_temperature); +} + +void InstrumentCluster::setSystemType(InstrumentClusterModule::SystemType systemType) +{ + if (m_systemType == systemType) + return; + + m_systemType = systemType; + emit systemTypeChanged(m_systemType); +} + +void InstrumentCluster::setCurrentWarning(const Warning ¤tWarning) +{ + if (m_currentWarning == currentWarning) + return; + + m_currentWarning = currentWarning; + emit currentWarningChanged(m_currentWarning); +} + +void InstrumentCluster::timerEvent(QTimerEvent *event) +{ + Q_UNUSED(event); + + if (speed() >= 250) + setSpeed(0); + else + setSpeed(speed() + 1); + + if (rpm() >= 5000) + setRpm(0); + else + setRpm(rpm() + 100); +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.h b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.h new file mode 100644 index 0000000..17ea567 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.h @@ -0,0 +1,111 @@ + +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#ifndef INSTRUMENTCLUSTER_H +#define INSTRUMENTCLUSTER_H + +#include <QObject> +#include "warning.h" +#include "instrumentclustermodule.h" + +class InstrumentCluster : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int speed READ speed WRITE setSpeed NOTIFY speedChanged) + Q_PROPERTY(int rpm READ rpm WRITE setRpm NOTIFY rpmChanged) + Q_PROPERTY(qreal fuel READ fuel WRITE setFuel NOTIFY fuelChanged) + Q_PROPERTY(qreal temperature READ temperature WRITE setTemperature NOTIFY temperatureChanged) + Q_PROPERTY(InstrumentClusterModule::SystemType systemType READ systemType WRITE setSystemType NOTIFY systemTypeChanged) + Q_PROPERTY(Warning currentWarning READ currentWarning WRITE setCurrentWarning NOTIFY currentWarningChanged) + +public: + explicit InstrumentCluster(QObject *parent = nullptr); + + Q_INVOKABLE int speed() const; + Q_INVOKABLE int rpm() const; + Q_INVOKABLE qreal fuel() const; + Q_INVOKABLE qreal temperature() const; + Q_INVOKABLE InstrumentClusterModule::SystemType systemType() const; + Q_INVOKABLE Warning currentWarning() const; + +signals: + void speedChanged(int speed); + void rpmChanged(int rpm); + void fuelChanged(qreal fuel); + void temperatureChanged(qreal temperature); + void systemTypeChanged(InstrumentClusterModule::SystemType systemType); + void currentWarningChanged(Warning currentWarning); + +public slots: + void setSpeed(int speed); + void setRpm(int rpm); + void setFuel(qreal fuel); + void setTemperature(qreal temperature); + void setSystemType(InstrumentClusterModule::SystemType systemType); + void setCurrentWarning(const Warning ¤tWarning); + +protected: + virtual void timerEvent(QTimerEvent *event) override; + +private: + int m_speed; + int m_rpm; + qreal m_fuel; + qreal m_temperature; + InstrumentClusterModule::SystemType m_systemType; + Warning m_currentWarning; +}; + +#endif // INSTRUMENTCLUSTER_H diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.xml b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.xml new file mode 100644 index 0000000..8a72b0d --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.xml @@ -0,0 +1,55 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="Example.IVI.InstrumentCluster"> + <property name="speed" type="i" access="read"/> + <property name="rpm" type="i" access="read"/> + <property name="fuel" type="d" access="read"/> + <property name="temperature" type="d" access="read"/> + <property name="systemType" type="(i)" access="read"> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="InstrumentClusterModule::SystemType"/> + </property> + <property name="currentWarning" type="(sss)" access="read"> + <annotation name="org.qtproject.QtDBus.QtTypeName" value="Warning"/> + </property> + <method name="speed" > + <arg name="speed" type="i" direction="out"/> + </method> + <method name="rpm" > + <arg name="rpm" type="i" direction="out"/> + </method> + <method name="fuel" > + <arg name="fuel" type="d" direction="out"/> + </method> + <method name="temperature" > + <arg name="temperature" type="d" direction="out"/> + </method> + <method name="systemType" > + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="InstrumentClusterModule::SystemType"/> + <arg name="systemType" type="(i)" direction="out"/> + </method> + <method name="currentWarning" > + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="Warning"/> + <arg name="currentWarning" type="(sss)" direction="out"/> + </method> + <signal name="speedChanged"> + <arg name="speed" type="i" direction="out"/> + </signal> + <signal name="rpmChanged"> + <arg name="rpm" type="i" direction="out"/> + </signal> + <signal name="fuelChanged"> + <arg name="fuel" type="d" direction="out"/> + </signal> + <signal name="temperatureChanged"> + <arg name="temperature" type="d" direction="out"/> + </signal> + <signal name="systemTypeChanged"> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="InstrumentClusterModule::SystemType"/> + <arg name="systemType" type="(i)" direction="out"/> + </signal> + <signal name="currentWarningChanged"> + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="Warning"/> + <arg name="currentWarning" type="(sss)" direction="out"/> + </signal> + </interface> +</node> diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/main.cpp b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/main.cpp new file mode 100644 index 0000000..c3f3243 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/main.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QCoreApplication> +#include <QDBusConnection> + +#include "instrumentcluster.h" +#include "instrumentcluster_adaptor.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + InstrumentCluster cluster; + qDBusRegisterMetaType<Warning>(); + qDBusRegisterMetaType<InstrumentClusterModule::SystemType>(); + + InstrumentClusterAdaptor adaptor(&cluster); + QDBusConnection connection = QDBusConnection::sessionBus(); + connection.registerObject("/", &cluster); + connection.registerService("Example.IVI.InstrumentCluster"); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/frontend/frontend.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/frontend/frontend.pro new file mode 100644 index 0000000..a17027e --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/frontend/frontend.pro @@ -0,0 +1,13 @@ +TARGET = $$qtLibraryTarget(QtIviInstrumentCluster) +TEMPLATE = lib +DESTDIR = .. + +QT += ivicore ivicore-private qml quick + +DEFINES += QT_BUILD_EXAMPLE_IVI_INSTRUMENTCLUSTER_LIB +CONFIG += ivigenerator +QFACE_SOURCES = ../instrument-cluster.qface + +CONFIG += install_ok # Do not cargo-cult this! +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/imports/imports.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/imports/imports.pro new file mode 100644 index 0000000..f78be28 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/imports/imports.pro @@ -0,0 +1,24 @@ +TEMPLATE = lib +CONFIG += plugin +QT += ivicore + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend + +QFACE_FORMAT = qmlplugin +QFACE_SOURCES = ../instrument-cluster.qface + +load(ivigenerator) + +DESTDIR = $$OUT_PWD/$$replace(URI, \\., /) + +exists($$OUT_PWD/qmldir) { + cpqmldir.files = $$OUT_PWD/qmldir \ + $$OUT_PWD/plugins.qmltypes + cpqmldir.path = $$DESTDIR + cpqmldir.CONFIG = no_check_exist + COPIES += cpqmldir +} + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend/imports +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster.qface b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster.qface new file mode 100644 index 0000000..f6a5c9f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster.qface @@ -0,0 +1,23 @@ +@config_simulator: { simulationFile: "qrc:/simulation.qml" } +module Example.IVI.InstrumentCluster 1.0 + +interface InstrumentCluster { + readonly int speed; + readonly int rpm; + readonly real fuel; + @config_simulator: { default: 15 } + readonly real temperature; + readonly SystemType systemType; + readonly Warning currentWarning; +} + +enum SystemType { + Imperial, + Metric +} + +struct Warning { + string color + string text + string icon +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..3833d67 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Cluster.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 +import Example.IVI.InstrumentCluster 1.0 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster Chapter 6") + visible: true + color: "#0c0c0c" + + InstrumentCluster { + id: instrumentCluster + } + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: instrumentCluster.speed + metricSystem: instrumentCluster.systemType === InstrumentCluster.Metric + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: instrumentCluster.rpm + warningColor: instrumentCluster.currentWarning.color + warningText: instrumentCluster.currentWarning.text + warningIcon: instrumentCluster.currentWarning.icon + fuelLevel: 1.0//instrumentCluster.fuel + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: instrumentCluster.temperature + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..5245ce9 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,19 @@ +TARGET = chapter6-own-backend +DESTDIR = .. + +QT += qml quick +CONFIG -= app_bundle + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../../images/images.qrc \ + +LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(QtIviInstrumentCluster) +INCLUDEPATH += $$OUT_PWD/../frontend +QMAKE_RPATHDIR += $ORIGIN + +# Additional import path used to resolve QML modules in Qt Creator's code model +QML_IMPORT_PATH = $$OUT_PWD/../frontend/qml + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/main.cpp new file mode 100644 index 0000000..57b00b6 --- /dev/null +++ b/examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.addImportPath(app.applicationDirPath() + "/imports"); + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/images/+--.png b/examples/ivicore/qface-tutorial/images/+--.png Binary files differnew file mode 100644 index 0000000..9f1ba24 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/+--.png diff --git a/examples/ivicore/qface-tutorial/images/P-R-N-D.png b/examples/ivicore/qface-tutorial/images/P-R-N-D.png Binary files differnew file mode 100644 index 0000000..6801f73 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/P-R-N-D.png diff --git a/examples/ivicore/qface-tutorial/images/dial_cursor.png b/examples/ivicore/qface-tutorial/images/dial_cursor.png Binary files differnew file mode 100644 index 0000000..79d5b0e --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/dial_cursor.png diff --git a/examples/ivicore/qface-tutorial/images/dial_cursor_right.png b/examples/ivicore/qface-tutorial/images/dial_cursor_right.png Binary files differnew file mode 100644 index 0000000..93e4567 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/dial_cursor_right.png diff --git a/examples/ivicore/qface-tutorial/images/dial_fill_color.png b/examples/ivicore/qface-tutorial/images/dial_fill_color.png Binary files differnew file mode 100644 index 0000000..2be4959 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/dial_fill_color.png diff --git a/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png b/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png Binary files differnew file mode 100644 index 0000000..bc2899c --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png diff --git a/examples/ivicore/qface-tutorial/images/dial_pattern.png b/examples/ivicore/qface-tutorial/images/dial_pattern.png Binary files differnew file mode 100644 index 0000000..e44b202 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/dial_pattern.png diff --git a/examples/ivicore/qface-tutorial/images/fuel.png b/examples/ivicore/qface-tutorial/images/fuel.png Binary files differnew file mode 100644 index 0000000..422f16f --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/fuel.png diff --git a/examples/ivicore/qface-tutorial/images/fuel_level.png b/examples/ivicore/qface-tutorial/images/fuel_level.png Binary files differnew file mode 100644 index 0000000..7c29998 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/fuel_level.png diff --git a/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png b/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png Binary files differnew file mode 100644 index 0000000..8518dbb --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png diff --git a/examples/ivicore/qface-tutorial/images/images.qrc b/examples/ivicore/qface-tutorial/images/images.qrc new file mode 100644 index 0000000..4a7f626 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/images.qrc @@ -0,0 +1,20 @@ +<RCC> + <qresource prefix="/images"> + <file>top_bar.png</file> + <file>right_dial.png</file> + <file>middle-circle.png</file> + <file>middle-bkg.png</file> + <file>mask_overlay.png</file> + <file>left_dial.png</file> + <file>fuelsymbol_orange.png</file> + <file>fuel_level.png</file> + <file>fuel.png</file> + <file>dial_pattern.png</file> + <file>dial_fill_color_left.png</file> + <file>dial_cursor_right.png</file> + <file>dial_cursor.png</file> + <file>P-R-N-D.png</file> + <file>+--.png</file> + <file>dial_fill_color.png</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/images/left_dial.png b/examples/ivicore/qface-tutorial/images/left_dial.png Binary files differnew file mode 100644 index 0000000..85cd9b1 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/left_dial.png diff --git a/examples/ivicore/qface-tutorial/images/mask_overlay.png b/examples/ivicore/qface-tutorial/images/mask_overlay.png Binary files differnew file mode 100644 index 0000000..fe656fa --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/mask_overlay.png diff --git a/examples/ivicore/qface-tutorial/images/middle-bkg.png b/examples/ivicore/qface-tutorial/images/middle-bkg.png Binary files differnew file mode 100644 index 0000000..e7da650 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/middle-bkg.png diff --git a/examples/ivicore/qface-tutorial/images/middle-circle.png b/examples/ivicore/qface-tutorial/images/middle-circle.png Binary files differnew file mode 100644 index 0000000..b1af2b8 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/middle-circle.png diff --git a/examples/ivicore/qface-tutorial/images/right_dial.png b/examples/ivicore/qface-tutorial/images/right_dial.png Binary files differnew file mode 100644 index 0000000..f798e64 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/right_dial.png diff --git a/examples/ivicore/qface-tutorial/images/top_bar.png b/examples/ivicore/qface-tutorial/images/top_bar.png Binary files differnew file mode 100644 index 0000000..e0c41a5 --- /dev/null +++ b/examples/ivicore/qface-tutorial/images/top_bar.png diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/Cluster.qml b/examples/ivicore/qface-tutorial/instrument-cluster/Cluster.qml new file mode 100644 index 0000000..08ded0c --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/Cluster.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Window 2.2 + +Window { + id: root + + width: 1920 + height: 720 + title: qsTr("QtIVI Instrument Cluster") + visible: true + color: "#0c0c0c" + + LeftDial { + id: leftDial + anchors.left: parent.left + anchors.leftMargin: 0.1 * width + + value: 80 + } + + RightDial { + id: rightDial + anchors.right: parent.right + anchors.rightMargin: 0.1 * width + + value: 3000 + } + + Top { + id: topbar + y: 7 + anchors.horizontalCenter: parent.horizontalCenter + + temperature: 15 + } + + Image { + anchors.fill: parent + source: Qt.resolvedUrl("images/mask_overlay.png") + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/Dial.qml b/examples/ivicore/qface-tutorial/instrument-cluster/Dial.qml new file mode 100644 index 0000000..a4b5c3f --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/Dial.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 + +Item { + id: root + + width: 480 + height: 480 + + property real value: 0 + property int upDuration: 2000 + property int downDuration: 1000 + property string fillImage: "images/dial_fill_color_left.png" + property string circleRadius: "0.193" + property string dialCursor: "images/dial_cursor.png" + + Image { + id: meter + property real min: -83.5 + property real max: 157 + width: root.width + height: width - 1 + rotation: min + (max - min) * root.value + source: Qt.resolvedUrl(root.dialCursor) + } + + ShaderEffect { + anchors.fill: meter + property var pattern: Image { + source: Qt.resolvedUrl("images/dial_pattern.png") + } + property var fill: Image { + source: Qt.resolvedUrl(root.fillImage) + } + property real value: root.value + + fragmentShader: " +#define M_PI 3.141592653589793 +#define INNER " + root.circleRadius + " + +varying highp vec2 qt_TexCoord0; +uniform lowp float qt_Opacity; +uniform sampler2D pattern; +uniform sampler2D fill; +uniform lowp float value; + +void main() { + lowp vec4 pattern = texture2D(pattern, qt_TexCoord0); + lowp vec4 fill = texture2D(fill, qt_TexCoord0); + + lowp vec2 pos = vec2(qt_TexCoord0.x - 0.5, 0.501 - qt_TexCoord0.y); + lowp float d = length(pos); + lowp float angle = atan(pos.x, pos.y) / (2.0 * M_PI); + lowp float v = 0.66 * value - 0.33; + + // Flare pattern + lowp vec4 color = mix(pattern, vec4(0.0), smoothstep(v, v + 0.1, angle)); + // Gradient fill color + color += mix(fill, vec4(0.0), step(v, angle)); + // Punch out the center hole + color = mix(vec4(0.0), color, smoothstep(INNER - 0.001, INNER + 0.001, d)); + // Fade out below 0 + gl_FragColor = mix(color, vec4(0.0), smoothstep(-0.35, -0.5, angle)); +} + " + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/Fuel.qml b/examples/ivicore/qface-tutorial/instrument-cluster/Fuel.qml new file mode 100644 index 0000000..46e9dee --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/Fuel.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.73 * 720 + height: width - 1 + + property real value: 0 + + Item { + width: root.value * parent.width + height: parent.height + clip: true + Image { + width: root.width + height: root.height + source: Qt.resolvedUrl("images/fuel_level.png") + } + } + + Image { + id: fuel + anchors.fill: parent + source: Qt.resolvedUrl("images/fuel.png") + + } +} + diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/Label.qml b/examples/ivicore/qface-tutorial/instrument-cluster/Label.qml new file mode 100644 index 0000000..d574080 --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/Label.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + property alias textObject: textElement + property alias text: textElement.text + property alias font: textElement.font + property alias fontSize: textElement.font.pixelSize + property alias color: textElement.color + property alias textFormat: textElement.textFormat + property alias horizontalAlignment: textElement.horizontalAlignment + property alias elide: textElement.elide + property alias wrapMode: textElement.wrapMode + property alias verticalAlignment: textElement.verticalAlignment + + Text { + id: textElement + + anchors.fill: parent + anchors.margins: 8 + + verticalAlignment: Text.AlignVCenter + + font.family: "Source Sans Pro" + font.pixelSize: 28 + font.weight: Font.Light + + color: "white" + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/LeftDial.qml b/examples/ivicore/qface-tutorial/instrument-cluster/LeftDial.qml new file mode 100644 index 0000000..f57b8af --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/LeftDial.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 +import QtGraphicalEffects 1.0 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property real value: 0.0 + property bool metricSystem: false + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.98 * width + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/left_dial.png") + } + + Text { + id: speedText + + anchors.verticalCenter: overlay.verticalCenter + anchors.horizontalCenter: overlay.horizontalCenter + anchors.verticalCenterOffset: -7 + anchors.horizontalCenterOffset: 5 + font.family: "Source Sans Pro" + font.pixelSize: 60 + font.letterSpacing: 4 + color: "white" + text: root.value + } + + Rectangle { + width: 60 + height: 1 + opacity: 0.4 + anchors.top: speedText.bottom + anchors.topMargin: -8 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + } + + Text { + id: mph + anchors.top: speedText.bottom + anchors.topMargin: -5 + anchors.horizontalCenter: overlay.horizontalCenter + anchors.horizontalCenterOffset: 2 + font.family: "Source Sans Pro" + font.pixelSize: 24 + color: "white" + text: root.metricSystem ? "km/h" : "mph" + } + + Dial { + width: 0.66 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 2 + fillImage: "images/dial_fill_color_left.png" + value: root.value / 240 + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/RightDial.qml b/examples/ivicore/qface-tutorial/instrument-cluster/RightDial.qml new file mode 100644 index 0000000..4c52a58 --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/RightDial.qml @@ -0,0 +1,228 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + + width: 0.8 * 720 + height: 720 + + property color warningColor: "transparent" + property string warningIcon + property string warningText + property int value + property alias fuelLevel: fuelMeter.value + + Item { + width: root.width/3 + height: 0.1 * root.width + anchors.bottom: overlay.top + anchors.left: parent.left + anchors.leftMargin: 0.2 * root.width + + Image { + id: gears + + width: 0.2 * root.width + height: 0.25 * width + anchors.bottom: parent.bottom + anchors.right: parent.right + source: Qt.resolvedUrl("images/P-R-N-D.png") + } + + Image { + id: plusMinus + anchors.bottom: parent.bottom + anchors.left: gears.right + anchors.leftMargin: 10 + source: Qt.resolvedUrl("images/+--.png") + } + } + + Image { + id: overlay + + width: 0.91 * root.width + height: 0.99 * width + + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: Qt.resolvedUrl("images/right_dial.png") + + Rectangle { + id: rect + width: circle.width + 5 + height: width + radius: width + color: "transparent" + border.color: root.warningColor + border.width: rect.borderWidth + anchors.centerIn: parent + anchors.horizontalCenterOffset: -3 + + property int borderWidth: 3 + + SequentialAnimation { + running: root.warningColor != "transparent" + loops: Animation.Infinite + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 3 + to: 7 + duration: 500 + } + + NumberAnimation { + + target: rect + properties: "borderWidth" + from: 7 + to: 3 + duration: 500 + } + + onStopped: rect.borderWidth = 3 + + } + } + + Image { + id: circle + + width: root.width/2 + height: width + anchors.centerIn: parent + anchors.horizontalCenterOffset: -6 + anchors.verticalCenterOffset: 0 + source: Qt.resolvedUrl("images/middle-bkg.png") + + Image { + id: circle_overlay + + width: parent.width + height: parent.height + anchors.centerIn: parent + source: Qt.resolvedUrl("images/middle-circle.png") + } + + Image { + id: fuelSymbol + width: 70 + height: 70 + anchors.top: parent.top + anchors.topMargin: 55 + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: 0 + source: root.warningIcon + fillMode: Image.PreserveAspectFit + + } + + Item { + width: parent.width + height: parent.height/4 + anchors.centerIn: parent + anchors.verticalCenterOffset: 40 + + Rectangle { + id: speedText + width: parent.width - 80 + height: 40 + radius: 20 + anchors.horizontalCenter: parent.horizontalCenter + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.darker("grey", 1.5) } + GradientStop { position: 0.4; color: "#0c0c0c" } + } + + Label { + width: parent.width + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + font.pixelSize: text.length > 10 ? 18 : 24 + font.bold: true + text: root.warningText + elide: Text.ElideMiddle + } + } + } + } + } + + Fuel { + id: fuelMeter + anchors.bottom: parent.bottom + anchors.bottomMargin: 0.05 * root.height + anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenterOffset: -20 + } + + Dial { + id: dial + + width: 0.69 * root.height + height: width + anchors.centerIn: overlay + anchors.verticalCenterOffset: 0 + anchors.horizontalCenterOffset: -5 + fillImage: "images/dial_fill_color.png" + circleRadius: "0.29" + dialCursor: "images/dial_cursor_right.png" + value: root.value / 7000 + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/Top.qml b/examples/ivicore/qface-tutorial/instrument-cluster/Top.qml new file mode 100644 index 0000000..b43ef9b --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/Top.qml @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.1 + +Item { + id: root + width: 0.37 * 1920 + height: 0.12 * 720 + + property real temperature: 0 + + Image { + id: background + width: parent.width + height: parent.height + source: Qt.resolvedUrl("images/top_bar.png") + } + + Label { + id: timeText + anchors.verticalCenter: background.verticalCenter + anchors.left: background.left + anchors.leftMargin: 0.2 * background.width + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: Qt.formatTime(currentDate, "hh:mm") + + property var currentDate: new Date(); + + Timer { + interval: 1000 + repeat: true + running: true + onTriggered: { + timeText.currentDate = new Date(); + } + } + } + + Item { + id: navigator + + width: 0.25 * background.width + height: background.height + anchors.verticalCenter: background.verticalCenter + anchors.horizontalCenter: background.horizontalCenter + + Row { + id: row + property int radius: 7 + anchors.centerIn: parent + anchors.verticalCenterOffset: -16 + spacing: 8 + + Repeater { + model: 3 + delegate: Rectangle { + height: row.radius * 2 + width: row.radius * 2 + radius: row.radius + color: 1 === index ? "white" : "#4d4d4d" + } + } + } + } + + Label { + id: temperatureText + anchors.verticalCenter: background.verticalCenter + anchors.left: navigator.right + anchors.leftMargin: 15 + + font.pixelSize: 0.42 * background.height + font.bold: true + + text: root.temperature + "°C" + } +} diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/app.qrc b/examples/ivicore/qface-tutorial/instrument-cluster/app.qrc new file mode 100644 index 0000000..9794820 --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/app.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/"> + <file>Cluster.qml</file> + <file>Top.qml</file> + <file>RightDial.qml</file> + <file>LeftDial.qml</file> + <file>Dial.qml</file> + <file>Fuel.qml</file> + <file>Label.qml</file> + </qresource> +</RCC> diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/instrument-cluster.pro b/examples/ivicore/qface-tutorial/instrument-cluster/instrument-cluster.pro new file mode 100644 index 0000000..dacdc1f --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/instrument-cluster.pro @@ -0,0 +1,8 @@ +QT += qml quick + +SOURCES = main.cpp +RESOURCES += app.qrc \ + ../images/images.qrc \ + +target.path = $$[QT_INSTALL_EXAMPLES]/ivicore/qface-tutorial/instrument-cluster +INSTALLS += target diff --git a/examples/ivicore/qface-tutorial/instrument-cluster/main.cpp b/examples/ivicore/qface-tutorial/instrument-cluster/main.cpp new file mode 100644 index 0000000..d56f5af --- /dev/null +++ b/examples/ivicore/qface-tutorial/instrument-cluster/main.cpp @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtIvi module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///Cluster.qml"))); + + return app.exec(); +} diff --git a/examples/ivicore/qface-tutorial/qface-tutorial.pro b/examples/ivicore/qface-tutorial/qface-tutorial.pro new file mode 100644 index 0000000..724d501 --- /dev/null +++ b/examples/ivicore/qface-tutorial/qface-tutorial.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS += \ + instrument-cluster \ + chapter1-basics \ + chapter2-enums-structs \ + chapter3-simulation-backend \ + chapter4-simulation-behavior \ + chapter5-ipc \ + +qtHaveModule(dbus): SUBDIRS += chapter6-own-backend diff --git a/examples/ivimedia/mediaplayer/main.qml b/examples/ivimedia/mediaplayer/main.qml index 7977ea6..c78b236 100644 --- a/examples/ivimedia/mediaplayer/main.qml +++ b/examples/ivimedia/mediaplayer/main.qml @@ -65,6 +65,7 @@ ApplicationWindow { MediaPlayer { id: mediaPlayer + discoveryMode: MediaPlayer.LoadOnlySimulationBackends } SplitView { @@ -186,6 +187,7 @@ ApplicationWindow { RowLayout { Label { text: "filter:" } TextField { id: filterEdit } + Button { text: "Refresh"; onClicked: searchModel.reload(); } } ListView { @@ -281,6 +283,11 @@ ApplicationWindow { model: MediaDeviceDiscoveryModel { id: discoveryModel + + onDeviceRemoved: { + if (device === filterModel.serviceObject) + browseView.model = discoveryModel + } } SearchAndBrowseModel { diff --git a/examples/ivivehiclefunctions/climate_qml/main.qml b/examples/ivivehiclefunctions/climate_qml/main.qml index 75d36ed..1aba4c9 100644 --- a/examples/ivivehiclefunctions/climate_qml/main.qml +++ b/examples/ivivehiclefunctions/climate_qml/main.qml @@ -68,7 +68,7 @@ ApplicationWindow { //![1] ClimateControl { id: climateControl - discoveryMode: ClimateControl.AutoDiscovery + discoveryMode: ClimateControl.LoadOnlySimulationBackends } //![1] diff --git a/examples/ivivehiclefunctions/climate_widget/mainwindow.cpp b/examples/ivivehiclefunctions/climate_widget/mainwindow.cpp index ab8504a..a6d1503 100644 --- a/examples/ivivehiclefunctions/climate_widget/mainwindow.cpp +++ b/examples/ivivehiclefunctions/climate_widget/mainwindow.cpp @@ -73,6 +73,7 @@ MainWindow::MainWindow(QWidget *parent) : //![1] m_climateControl = new QIviClimateControl(QString(), this); + m_climateControl->setDiscoveryMode(QIviAbstractFeature::LoadOnlySimulationBackends); m_climateControl->startAutoDiscovery(); if (!m_climateControl->isValid()) diff --git a/examples/ivivehiclefunctions/window_qml/main.qml b/examples/ivivehiclefunctions/window_qml/main.qml index 5679044..c9fb2a1 100644 --- a/examples/ivivehiclefunctions/window_qml/main.qml +++ b/examples/ivivehiclefunctions/window_qml/main.qml @@ -65,7 +65,7 @@ ApplicationWindow { WindowControl { id: windowControl - discoveryMode: WindowControl.AutoDiscovery + discoveryMode: WindowControl.LoadOnlySimulationBackends } ColumnLayout { |