From 013230e3101cec6894cd8c187d07a4a9c2fc0053 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 25 Jul 2019 12:54:06 +0200 Subject: Add a IVI Generator Tutorial The tutorial has multiple chapters and shows how to extend a UI step-by-step with a Middleware API using the IVI Generator. Fixes: AUTOSUITE-1155 Fixes: AUTOSUITE-600 Change-Id: Ib18de9e3d53d7163f880a2258173e0b6119ef3af Reviewed-by: Robert Griebl --- examples/ivicore/ivicore.pro | 2 + .../chapter1-basics/chapter1-basics.pro | 8 + .../chapter1-basics/frontend/frontend.pro | 13 ++ .../chapter1-basics/instrument-cluster.qface | 5 + .../chapter1-basics/instrument-cluster/Cluster.qml | 99 ++++++++ .../chapter1-basics/instrument-cluster/Dial.qml | 119 ++++++++++ .../chapter1-basics/instrument-cluster/Fuel.qml | 82 +++++++ .../chapter1-basics/instrument-cluster/Label.qml | 84 +++++++ .../instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../chapter1-basics/instrument-cluster/Top.qml | 131 +++++++++++ .../chapter1-basics/instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../chapter1-basics/instrument-cluster/main.cpp | 68 ++++++ .../chapter2-enums-structs.pro | 8 + .../chapter2-enums-structs/frontend/frontend.pro | 13 ++ .../instrument-cluster.qface | 21 ++ .../instrument-cluster/Cluster.qml | 104 +++++++++ .../instrument-cluster/Dial.qml | 119 ++++++++++ .../instrument-cluster/Fuel.qml | 82 +++++++ .../instrument-cluster/Label.qml | 84 +++++++ .../instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../instrument-cluster/Top.qml | 131 +++++++++++ .../instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../instrument-cluster/main.cpp | 68 ++++++ .../backend_simulator/backend_simulator.pro | 20 ++ .../chapter3-simulation-backend.pro | 12 + .../frontend/frontend.pro | 13 ++ .../imports/imports.pro | 24 ++ .../instrument-cluster.qface | 21 ++ .../instrument-cluster/Cluster.qml | 104 +++++++++ .../instrument-cluster/Dial.qml | 119 ++++++++++ .../instrument-cluster/Fuel.qml | 82 +++++++ .../instrument-cluster/Label.qml | 84 +++++++ .../instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../instrument-cluster/Top.qml | 131 +++++++++++ .../instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../instrument-cluster/main.cpp | 66 ++++++ .../backend_simulator/backend_simulator.pro | 23 ++ .../backend_simulator/simulation.qml | 147 ++++++++++++ .../backend_simulator/simulation.qrc | 6 + .../chapter4-simulation-behavior.pro | 12 + .../frontend/frontend.pro | 13 ++ .../imports/imports.pro | 24 ++ .../instrument-cluster.qface | 23 ++ .../instrument-cluster/Cluster.qml | 104 +++++++++ .../instrument-cluster/Dial.qml | 119 ++++++++++ .../instrument-cluster/Fuel.qml | 82 +++++++ .../instrument-cluster/Label.qml | 84 +++++++ .../instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../instrument-cluster/Top.qml | 131 +++++++++++ .../instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../instrument-cluster/main.cpp | 66 ++++++ .../chapter4-simulation-behavior/miles.json | 9 + .../chapter5-ipc/backend_qtro/backend_qtro.pro | 17 ++ .../backend_simulator/backend_simulator.pro | 23 ++ .../chapter5-ipc/backend_simulator/simulation.qml | 146 ++++++++++++ .../chapter5-ipc/backend_simulator/simulation.qrc | 6 + .../qface-tutorial/chapter5-ipc/chapter5-ipc.pro | 16 ++ .../chapter5-ipc/frontend/frontend.pro | 13 ++ .../chapter5-ipc/imports/imports.pro | 24 ++ .../chapter5-ipc/instrument-cluster.qface | 23 ++ .../chapter5-ipc/instrument-cluster/Cluster.qml | 104 +++++++++ .../chapter5-ipc/instrument-cluster/Dial.qml | 119 ++++++++++ .../chapter5-ipc/instrument-cluster/Fuel.qml | 82 +++++++ .../chapter5-ipc/instrument-cluster/Label.qml | 84 +++++++ .../chapter5-ipc/instrument-cluster/LeftDial.qml | 121 ++++++++++ .../chapter5-ipc/instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../chapter5-ipc/instrument-cluster/Top.qml | 131 +++++++++++ .../chapter5-ipc/instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../chapter5-ipc/instrument-cluster/main.cpp | 66 ++++++ .../simulation_server/simulation_server.pro | 19 ++ .../backend_dbus/backend_dbus.pro | 32 +++ .../backend_dbus/instrumentcluster_dbus.json | 5 + .../backend_dbus/instrumentclusterbackend.cpp | 255 +++++++++++++++++++++ .../backend_dbus/instrumentclusterbackend.h | 97 ++++++++ .../backend_dbus/instrumentclusterplugin.cpp | 73 ++++++ .../backend_dbus/instrumentclusterplugin.h | 77 +++++++ .../backend_simulator/backend_simulator.pro | 23 ++ .../backend_simulator/simulation.qml | 146 ++++++++++++ .../backend_simulator/simulation.qrc | 6 + .../chapter6-own-backend/chapter6-own-backend.pro | 16 ++ .../demo_server/dbus_conversion.h | 113 +++++++++ .../demo_server/demo_server.pro | 24 ++ .../demo_server/instrumentcluster.cpp | 166 ++++++++++++++ .../demo_server/instrumentcluster.h | 111 +++++++++ .../demo_server/instrumentcluster.xml | 55 +++++ .../chapter6-own-backend/demo_server/main.cpp | 74 ++++++ .../chapter6-own-backend/frontend/frontend.pro | 13 ++ .../chapter6-own-backend/imports/imports.pro | 24 ++ .../chapter6-own-backend/instrument-cluster.qface | 23 ++ .../instrument-cluster/Cluster.qml | 104 +++++++++ .../instrument-cluster/Dial.qml | 119 ++++++++++ .../instrument-cluster/Fuel.qml | 82 +++++++ .../instrument-cluster/Label.qml | 84 +++++++ .../instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../instrument-cluster/Top.qml | 131 +++++++++++ .../instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 19 ++ .../instrument-cluster/main.cpp | 66 ++++++ examples/ivicore/qface-tutorial/images/+--.png | Bin 0 -> 239 bytes examples/ivicore/qface-tutorial/images/P-R-N-D.png | Bin 0 -> 1640 bytes .../ivicore/qface-tutorial/images/dial_cursor.png | Bin 0 -> 11800 bytes .../qface-tutorial/images/dial_cursor_right.png | Bin 0 -> 4197 bytes .../qface-tutorial/images/dial_fill_color.png | Bin 0 -> 13739 bytes .../qface-tutorial/images/dial_fill_color_left.png | Bin 0 -> 19930 bytes .../ivicore/qface-tutorial/images/dial_pattern.png | Bin 0 -> 52069 bytes examples/ivicore/qface-tutorial/images/fuel.png | Bin 0 -> 2952 bytes .../ivicore/qface-tutorial/images/fuel_level.png | Bin 0 -> 8204 bytes .../qface-tutorial/images/fuelsymbol_orange.png | Bin 0 -> 509 bytes examples/ivicore/qface-tutorial/images/images.qrc | 20 ++ .../ivicore/qface-tutorial/images/left_dial.png | Bin 0 -> 124280 bytes .../ivicore/qface-tutorial/images/mask_overlay.png | Bin 0 -> 16841 bytes .../ivicore/qface-tutorial/images/middle-bkg.png | Bin 0 -> 8009 bytes .../qface-tutorial/images/middle-circle.png | Bin 0 -> 10262 bytes .../ivicore/qface-tutorial/images/right_dial.png | Bin 0 -> 83034 bytes examples/ivicore/qface-tutorial/images/top_bar.png | Bin 0 -> 6066 bytes .../qface-tutorial/instrument-cluster/Cluster.qml | 94 ++++++++ .../qface-tutorial/instrument-cluster/Dial.qml | 119 ++++++++++ .../qface-tutorial/instrument-cluster/Fuel.qml | 82 +++++++ .../qface-tutorial/instrument-cluster/Label.qml | 84 +++++++ .../qface-tutorial/instrument-cluster/LeftDial.qml | 121 ++++++++++ .../instrument-cluster/RightDial.qml | 228 ++++++++++++++++++ .../qface-tutorial/instrument-cluster/Top.qml | 131 +++++++++++ .../qface-tutorial/instrument-cluster/app.qrc | 11 + .../instrument-cluster/instrument-cluster.pro | 8 + .../qface-tutorial/instrument-cluster/main.cpp | 65 ++++++ examples/ivicore/qface-tutorial/qface-tutorial.pro | 10 + 136 files changed, 8799 insertions(+) create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/chapter1-basics.pro create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter1-basics/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/chapter2-enums-structs.pro create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter2-enums-structs/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/backend_simulator/backend_simulator.pro create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/chapter3-simulation-backend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/imports/imports.pro create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter3-simulation-backend/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/backend_simulator.pro create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/backend_simulator/simulation.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/chapter4-simulation-behavior.pro create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/imports/imports.pro create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter4-simulation-behavior/miles.json create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/backend_qtro/backend_qtro.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/backend_simulator.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/backend_simulator/simulation.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/chapter5-ipc.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/imports/imports.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter5-ipc/simulation_server/simulation_server.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/backend_dbus.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentcluster_dbus.json create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterbackend.h create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_dbus/instrumentclusterplugin.h create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/backend_simulator.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/backend_simulator/simulation.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/chapter6-own-backend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/dbus_conversion.h create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/demo_server.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.h create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/instrumentcluster.xml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/demo_server/main.cpp create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/frontend/frontend.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/imports/imports.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster.qface create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/chapter6-own-backend/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/images/+--.png create mode 100644 examples/ivicore/qface-tutorial/images/P-R-N-D.png create mode 100644 examples/ivicore/qface-tutorial/images/dial_cursor.png create mode 100644 examples/ivicore/qface-tutorial/images/dial_cursor_right.png create mode 100644 examples/ivicore/qface-tutorial/images/dial_fill_color.png create mode 100644 examples/ivicore/qface-tutorial/images/dial_fill_color_left.png create mode 100644 examples/ivicore/qface-tutorial/images/dial_pattern.png create mode 100644 examples/ivicore/qface-tutorial/images/fuel.png create mode 100644 examples/ivicore/qface-tutorial/images/fuel_level.png create mode 100644 examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png create mode 100644 examples/ivicore/qface-tutorial/images/images.qrc create mode 100644 examples/ivicore/qface-tutorial/images/left_dial.png create mode 100644 examples/ivicore/qface-tutorial/images/mask_overlay.png create mode 100644 examples/ivicore/qface-tutorial/images/middle-bkg.png create mode 100644 examples/ivicore/qface-tutorial/images/middle-circle.png create mode 100644 examples/ivicore/qface-tutorial/images/right_dial.png create mode 100644 examples/ivicore/qface-tutorial/images/top_bar.png create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/Cluster.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/Dial.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/Fuel.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/Label.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/LeftDial.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/RightDial.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/Top.qml create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/app.qrc create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/instrument-cluster.pro create mode 100644 examples/ivicore/qface-tutorial/instrument-cluster/main.cpp create mode 100644 examples/ivicore/qface-tutorial/qface-tutorial.pro (limited to 'examples') 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-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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +#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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +#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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +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 @@ + + + + simulation.qml + + 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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +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 @@ + + + + simulation.qml + + 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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +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 + +InstrumentClusterBackend::InstrumentClusterBackend(QObject *parent) + : InstrumentClusterBackendInterface(parent) + , m_client(nullptr) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); +} + +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 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 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 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 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 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 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 +#include +#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 @@ + + + + simulation.qml + + 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 +#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 + +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 +#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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +#include + +#include "instrumentcluster.h" +#include "instrumentcluster_adaptor.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + InstrumentCluster cluster; + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + 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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +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 new file mode 100644 index 0000000..9f1ba24 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/+--.png differ diff --git a/examples/ivicore/qface-tutorial/images/P-R-N-D.png b/examples/ivicore/qface-tutorial/images/P-R-N-D.png new file mode 100644 index 0000000..6801f73 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/P-R-N-D.png differ diff --git a/examples/ivicore/qface-tutorial/images/dial_cursor.png b/examples/ivicore/qface-tutorial/images/dial_cursor.png new file mode 100644 index 0000000..79d5b0e Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/dial_cursor.png differ diff --git a/examples/ivicore/qface-tutorial/images/dial_cursor_right.png b/examples/ivicore/qface-tutorial/images/dial_cursor_right.png new file mode 100644 index 0000000..93e4567 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/dial_cursor_right.png differ diff --git a/examples/ivicore/qface-tutorial/images/dial_fill_color.png b/examples/ivicore/qface-tutorial/images/dial_fill_color.png new file mode 100644 index 0000000..2be4959 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/dial_fill_color.png differ diff --git a/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png b/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png new file mode 100644 index 0000000..bc2899c Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/dial_fill_color_left.png differ diff --git a/examples/ivicore/qface-tutorial/images/dial_pattern.png b/examples/ivicore/qface-tutorial/images/dial_pattern.png new file mode 100644 index 0000000..e44b202 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/dial_pattern.png differ diff --git a/examples/ivicore/qface-tutorial/images/fuel.png b/examples/ivicore/qface-tutorial/images/fuel.png new file mode 100644 index 0000000..422f16f Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/fuel.png differ diff --git a/examples/ivicore/qface-tutorial/images/fuel_level.png b/examples/ivicore/qface-tutorial/images/fuel_level.png new file mode 100644 index 0000000..7c29998 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/fuel_level.png differ diff --git a/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png b/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png new file mode 100644 index 0000000..8518dbb Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/fuelsymbol_orange.png differ 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 @@ + + + top_bar.png + right_dial.png + middle-circle.png + middle-bkg.png + mask_overlay.png + left_dial.png + fuelsymbol_orange.png + fuel_level.png + fuel.png + dial_pattern.png + dial_fill_color_left.png + dial_cursor_right.png + dial_cursor.png + P-R-N-D.png + +--.png + dial_fill_color.png + + diff --git a/examples/ivicore/qface-tutorial/images/left_dial.png b/examples/ivicore/qface-tutorial/images/left_dial.png new file mode 100644 index 0000000..85cd9b1 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/left_dial.png differ diff --git a/examples/ivicore/qface-tutorial/images/mask_overlay.png b/examples/ivicore/qface-tutorial/images/mask_overlay.png new file mode 100644 index 0000000..fe656fa Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/mask_overlay.png differ diff --git a/examples/ivicore/qface-tutorial/images/middle-bkg.png b/examples/ivicore/qface-tutorial/images/middle-bkg.png new file mode 100644 index 0000000..e7da650 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/middle-bkg.png differ diff --git a/examples/ivicore/qface-tutorial/images/middle-circle.png b/examples/ivicore/qface-tutorial/images/middle-circle.png new file mode 100644 index 0000000..b1af2b8 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/middle-circle.png differ diff --git a/examples/ivicore/qface-tutorial/images/right_dial.png b/examples/ivicore/qface-tutorial/images/right_dial.png new file mode 100644 index 0000000..f798e64 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/right_dial.png differ diff --git a/examples/ivicore/qface-tutorial/images/top_bar.png b/examples/ivicore/qface-tutorial/images/top_bar.png new file mode 100644 index 0000000..e0c41a5 Binary files /dev/null and b/examples/ivicore/qface-tutorial/images/top_bar.png differ 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 @@ + + + Cluster.qml + Top.qml + RightDial.qml + LeftDial.qml + Dial.qml + Fuel.qml + Label.qml + + 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 +#include + +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 -- cgit v1.2.1