From 0495ad804ec8b218e81d3ebb172dc1976cb287cb Mon Sep 17 00:00:00 2001 From: Ouyang Jun Date: Wed, 24 Jul 2019 04:33:26 -0700 Subject: Minimal cluster demo gauges that can be used standalone Bug-AGL: SPEC-2487 Signed-off-by: Ouyang Jun Signed-off-by: Zhou Mingying Signed-off-by: Liu Wenlong Change-Id: I4859ab9af2f5c3bbeff5ca6b14a7943797518908 (cherry picked from commit a61b0a9931e16a51fd819167cc597d84b52ad266) --- app/CMakeLists.txt | 48 +++ app/DashboardGaugeStyle.qml | 176 ++++++++++ app/IconGaugeStyle.qml | 135 ++++++++ app/TachometerStyle.qml | 127 +++++++ app/TurnIndicator.qml | 111 +++++++ app/ValueSource.qml | 420 +++++++++++++++++++++++ app/cluster-gauges.qml | 478 +++++++++++++++++++++++++++ app/cluster-gauges.qrc | 10 + app/images/AGL_Icons_ABS.svg | 1 + app/images/AGL_Icons_ABS_red.svg | 1 + app/images/AGL_Icons_ABS_yellow.svg | 1 + app/images/AGL_Icons_Battery.svg | 1 + app/images/AGL_Icons_Battery_red.svg | 1 + app/images/AGL_Icons_Battery_yellow.svg | 1 + app/images/AGL_Icons_Engine.svg | 1 + app/images/AGL_Icons_Engine_red.svg | 1 + app/images/AGL_Icons_Engine_yellow.svg | 1 + app/images/AGL_Icons_Lights.svg | 1 + app/images/AGL_Icons_Lights_red.svg | 1 + app/images/AGL_Icons_Lights_yellow.svg | 1 + app/images/AGL_Icons_Oil.svg | 1 + app/images/AGL_Icons_Oil_red.svg | 1 + app/images/AGL_Icons_Oil_yellow.svg | 1 + app/images/AGL_Icons_OpenDoor.svg | 1 + app/images/AGL_Icons_OpenDoor_red.svg | 1 + app/images/AGL_Icons_OpenDoor_yellow.svg | 1 + app/images/AGL_Icons_ParkingBrake.svg | 1 + app/images/AGL_Icons_ParkingBrake_red.svg | 1 + app/images/AGL_Icons_ParkingBrake_yellow.svg | 1 + app/images/AGL_Icons_Seatbelt.svg | 1 + app/images/AGL_Icons_Seatbelt_red.svg | 1 + app/images/AGL_Icons_Seatbelt_yellow.svg | 1 + app/images/Utility_Logo_Grey-01.svg | 84 +++++ app/images/agl_title_793x211.png | Bin 0 -> 55357 bytes app/images/fuel-icon.png | Bin 0 -> 409 bytes app/images/images.qrc | 32 ++ app/images/temperature-icon.png | Bin 0 -> 3302 bytes app/main.cpp | 60 ++++ 38 files changed, 1705 insertions(+) create mode 100644 app/CMakeLists.txt create mode 100644 app/DashboardGaugeStyle.qml create mode 100644 app/IconGaugeStyle.qml create mode 100644 app/TachometerStyle.qml create mode 100644 app/TurnIndicator.qml create mode 100644 app/ValueSource.qml create mode 100644 app/cluster-gauges.qml create mode 100644 app/cluster-gauges.qrc create mode 100644 app/images/AGL_Icons_ABS.svg create mode 100644 app/images/AGL_Icons_ABS_red.svg create mode 100644 app/images/AGL_Icons_ABS_yellow.svg create mode 100644 app/images/AGL_Icons_Battery.svg create mode 100644 app/images/AGL_Icons_Battery_red.svg create mode 100644 app/images/AGL_Icons_Battery_yellow.svg create mode 100644 app/images/AGL_Icons_Engine.svg create mode 100644 app/images/AGL_Icons_Engine_red.svg create mode 100644 app/images/AGL_Icons_Engine_yellow.svg create mode 100644 app/images/AGL_Icons_Lights.svg create mode 100644 app/images/AGL_Icons_Lights_red.svg create mode 100644 app/images/AGL_Icons_Lights_yellow.svg create mode 100644 app/images/AGL_Icons_Oil.svg create mode 100644 app/images/AGL_Icons_Oil_red.svg create mode 100644 app/images/AGL_Icons_Oil_yellow.svg create mode 100644 app/images/AGL_Icons_OpenDoor.svg create mode 100644 app/images/AGL_Icons_OpenDoor_red.svg create mode 100644 app/images/AGL_Icons_OpenDoor_yellow.svg create mode 100644 app/images/AGL_Icons_ParkingBrake.svg create mode 100644 app/images/AGL_Icons_ParkingBrake_red.svg create mode 100644 app/images/AGL_Icons_ParkingBrake_yellow.svg create mode 100644 app/images/AGL_Icons_Seatbelt.svg create mode 100644 app/images/AGL_Icons_Seatbelt_red.svg create mode 100644 app/images/AGL_Icons_Seatbelt_yellow.svg create mode 100644 app/images/Utility_Logo_Grey-01.svg create mode 100644 app/images/agl_title_793x211.png create mode 100644 app/images/fuel-icon.png create mode 100644 app/images/images.qrc create mode 100644 app/images/temperature-icon.png create mode 100644 app/main.cpp (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..8e039e6 --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,48 @@ +########################################################################### +# Copyright 2018 Konsulko Group +# +# Author: Scott Murray +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_CXX_STANDARD 14) + +find_package(Qt5 COMPONENTS Core Gui QuickControls2 WebSockets QuickWidgets REQUIRED) +find_package(PkgConfig REQUIRED) + +qt5_add_resources(RESOURCES cluster-gauges.qrc images/images.qrc) + +PROJECT_TARGET_ADD(cluster-gauges) + +add_executable(${TARGET_NAME} + main.cpp + ${RESOURCES} +) + +set_target_properties(${TARGET_NAME} PROPERTIES + LABELS "EXECUTABLE" + PREFIX "" + COMPILE_FLAGS "${QLIBWINMGR_FLAGS} ${EXTRAS_CFLAGS} -DFOR_AFB_BINDING" + LINK_FLAGS "${BINDINGS_LINK_FLAG}" + LINK_LIBRARIES "${EXTRAS_LIBRARIES}" + OUTPUT_NAME "${TARGET_NAME}" +) + +target_link_libraries(${TARGET_NAME} + Qt5::QuickControls2 + Qt5::QuickWidgets + ${QLIBWINMGR_LIBRARIES} +) diff --git a/app/DashboardGaugeStyle.qml b/app/DashboardGaugeStyle.qml new file mode 100644 index 0000000..aafe50f --- /dev/null +++ b/app/DashboardGaugeStyle.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + + +import QtQuick 2.2 +import QtQuick.Controls.Styles 1.4 + +CircularGaugeStyle { + tickmarkInset: toPixels(0.04) + minorTickmarkInset: tickmarkInset + labelStepSize: 20 + labelInset: toPixels(0.23) + + property real xCenter: outerRadius + property real yCenter: outerRadius + property real needleLength: outerRadius - tickmarkInset * 1.25 + property real needleTipWidth: toPixels(0.02) + property real needleBaseWidth: toPixels(0.06) + property bool halfGauge: false + + function toPixels(percentage) { + return percentage * outerRadius; + } + + function degToRad(degrees) { + return degrees * (Math.PI / 180); + } + + function radToDeg(radians) { + return radians * (180 / Math.PI); + } + + function paintBackground(ctx) { + if (halfGauge) { + ctx.beginPath(); + ctx.rect(0, 0, ctx.canvas.width, ctx.canvas.height / 2); + ctx.clip(); + } + + ctx.beginPath(); + ctx.fillStyle = "black"; + ctx.ellipse(0, 0, ctx.canvas.width, ctx.canvas.height); + ctx.fill(); + + ctx.beginPath(); + ctx.lineWidth = tickmarkInset; + ctx.strokeStyle = "black"; + ctx.arc(xCenter, yCenter, outerRadius - ctx.lineWidth / 2, outerRadius - ctx.lineWidth / 2, 0, Math.PI * 2); + ctx.stroke(); + + ctx.beginPath(); + ctx.lineWidth = tickmarkInset / 2; + ctx.strokeStyle = "#222"; + ctx.arc(xCenter, yCenter, outerRadius - ctx.lineWidth / 2, outerRadius - ctx.lineWidth / 2, 0, Math.PI * 2); + ctx.stroke(); + + ctx.beginPath(); + var gradient = ctx.createRadialGradient(xCenter, yCenter, 0, xCenter, yCenter, outerRadius * 1.5); + gradient.addColorStop(0, Qt.rgba(1, 1, 1, 0)); + gradient.addColorStop(0.7, Qt.rgba(1, 1, 1, 0.13)); + gradient.addColorStop(1, Qt.rgba(1, 1, 1, 1)); + ctx.fillStyle = gradient; + ctx.arc(xCenter, yCenter, outerRadius - tickmarkInset, outerRadius - tickmarkInset, 0, Math.PI * 2); + ctx.fill(); + } + + background: Canvas { + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + paintBackground(ctx); + } + + Text { + id: speedText + font.pixelSize: toPixels(0.3) + text: kphInt + color: "white" + horizontalAlignment: Text.AlignRight + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.verticalCenter + anchors.topMargin: toPixels(0.1) + + readonly property int kphInt: control.value + } + Text { + id: speedLabel + text: valueSource.mphDisplay ? "MPH" : "km/h" + color: "white" + font.pixelSize: toPixels(0.09) + anchors.top: speedText.bottom + anchors.horizontalCenter: parent.horizontalCenter + } + } + + needle: Canvas { + implicitWidth: needleBaseWidth + implicitHeight: needleLength + + property real xCenter: width / 2 + property real yCenter: height / 2 + + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + + ctx.beginPath(); + ctx.moveTo(xCenter, height); + ctx.lineTo(xCenter - needleBaseWidth / 2, height - needleBaseWidth / 2); + ctx.lineTo(xCenter - needleTipWidth / 2, 0); + ctx.lineTo(xCenter, yCenter - needleLength); + ctx.lineTo(xCenter, 0); + ctx.closePath(); + ctx.fillStyle = Qt.rgba(0.66, 0, 0, 0.66); + ctx.fill(); + + ctx.beginPath(); + ctx.moveTo(xCenter, height) + ctx.lineTo(width, height - needleBaseWidth / 2); + ctx.lineTo(xCenter + needleTipWidth / 2, 0); + ctx.lineTo(xCenter, 0); + ctx.closePath(); + ctx.fillStyle = Qt.lighter(Qt.rgba(0.66, 0, 0, 0.66)); + ctx.fill(); + } + } + + foreground: null +} diff --git a/app/IconGaugeStyle.qml b/app/IconGaugeStyle.qml new file mode 100644 index 0000000..6247076 --- /dev/null +++ b/app/IconGaugeStyle.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + + +import QtQuick 2.2 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Extras 1.4 + +DashboardGaugeStyle { + id: fuelGaugeStyle + minimumValueAngle: -60 + maximumValueAngle: 60 + tickmarkStepSize: 1 + labelStepSize: 1 + labelInset: toPixels(-0.25) + minorTickmarkCount: 3 + + needleLength: toPixels(0.85) + needleBaseWidth: toPixels(0.08) + needleTipWidth: toPixels(0.03) + + halfGauge: true + + property string icon: "" + property color minWarningColor: "transparent" + property color maxWarningColor: "transparent" + readonly property real minWarningStartAngle: minimumValueAngle - 90 + readonly property real maxWarningStartAngle: maximumValueAngle - 90 + + tickmark: Rectangle { + implicitWidth: toPixels(0.06) + antialiasing: true + implicitHeight: toPixels(0.2) + color: "#c8c8c8" + } + + minorTickmark: Rectangle { + implicitWidth: toPixels(0.03) + antialiasing: true + implicitHeight: toPixels(0.15) + color: "#c8c8c8" + } + + background: Item { + Canvas { + anchors.fill: parent + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + + paintBackground(ctx); + + if (minWarningColor != "transparent") { + ctx.beginPath(); + ctx.lineWidth = fuelGaugeStyle.toPixels(0.08); + ctx.strokeStyle = minWarningColor; + ctx.arc(outerRadius, outerRadius, + // Start the line in from the decorations, and account for the width of the line itself. + outerRadius - tickmarkInset - ctx.lineWidth / 2, + degToRad(minWarningStartAngle), + degToRad(minWarningStartAngle + angleRange / (minorTickmarkCount + 1)), false); + ctx.stroke(); + } + if (maxWarningColor != "transparent") { + ctx.beginPath(); + ctx.lineWidth = fuelGaugeStyle.toPixels(0.08); + ctx.strokeStyle = maxWarningColor; + ctx.arc(outerRadius, outerRadius, + // Start the line in from the decorations, and account for the width of the line itself. + outerRadius - tickmarkInset - ctx.lineWidth / 2, + degToRad(maxWarningStartAngle - angleRange / (minorTickmarkCount + 1)), + degToRad(maxWarningStartAngle), false); + ctx.stroke(); + } + } + } + + Image { + source: icon + anchors.bottom: parent.verticalCenter + anchors.bottomMargin: toPixels(0.3) + anchors.horizontalCenter: parent.horizontalCenter + width: toPixels(0.3) + height: width + fillMode: Image.PreserveAspectFit + } + } +} diff --git a/app/TachometerStyle.qml b/app/TachometerStyle.qml new file mode 100644 index 0000000..a632eab --- /dev/null +++ b/app/TachometerStyle.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + + +import QtQuick 2.2 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Extras 1.4 + +DashboardGaugeStyle { + id: tachometerStyle + tickmarkStepSize: 1 + labelStepSize: 1 + needleLength: toPixels(0.85) + needleBaseWidth: toPixels(0.08) + needleTipWidth: toPixels(0.03) + + tickmark: Rectangle { + implicitWidth: toPixels(0.03) + antialiasing: true + implicitHeight: toPixels(0.08) + color: styleData.index === 7 || styleData.index === 8 ? Qt.rgba(0.5, 0, 0, 1) : "#c8c8c8" + } + + minorTickmark: null + + tickmarkLabel: Text { + font.pixelSize: Math.max(6, toPixels(0.12)) + text: styleData.value + color: styleData.index === 7 || styleData.index === 8 ? Qt.rgba(0.5, 0, 0, 1) : "#c8c8c8" + antialiasing: true + } + + background: Canvas { + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + paintBackground(ctx); + + ctx.beginPath(); + ctx.lineWidth = tachometerStyle.toPixels(0.08); + ctx.strokeStyle = Qt.rgba(0.5, 0, 0, 1); + var warningCircumference = maximumValueAngle - minimumValueAngle * 0.1; + var startAngle = maximumValueAngle - 90; + ctx.arc(outerRadius, outerRadius, + // Start the line in from the decorations, and account for the width of the line itself. + outerRadius - tickmarkInset - ctx.lineWidth / 2, + degToRad(startAngle - angleRange / 8 + angleRange * 0.015), + degToRad(startAngle - angleRange * 0.015), false); + ctx.stroke(); + } + + Text { + id: rpmText + font.pixelSize: tachometerStyle.toPixels(0.3) + text: rpmInt + color: "white" + horizontalAlignment: Text.AlignRight + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.verticalCenter + anchors.topMargin: 20 + + readonly property int rpmInt: valueSource.rpm + } + Text { + text: "x1000" + color: "white" + font.pixelSize: tachometerStyle.toPixels(0.1) + anchors.top: parent.top + anchors.topMargin: parent.height / 4 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "RPM" + color: "white" + font.pixelSize: tachometerStyle.toPixels(0.1) + anchors.top: rpmText.bottom + anchors.horizontalCenter: parent.horizontalCenter + } + } +} diff --git a/app/TurnIndicator.qml b/app/TurnIndicator.qml new file mode 100644 index 0000000..3bc4c0e --- /dev/null +++ b/app/TurnIndicator.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + + +import QtQuick 2.2 + +Item { + // This enum is actually keyboard-related, but it serves its purpose + // as an indication of direction for us. + property int direction: Qt.LeftArrow + property bool on: false + + property bool flashing: false + + scale: direction === Qt.LeftArrow ? 1 : -1 + Timer { + id: flashTimer + interval: 500 + running: on + repeat: true + onTriggered: flashing = !flashing + } + function paintOutlinePath(ctx) { + ctx.beginPath(); + ctx.moveTo(0, height * 0.5); + ctx.lineTo(0.6 * width, 0); + ctx.lineTo(0.6 * width, height * 0.28); + ctx.lineTo(width, height * 0.28); + ctx.lineTo(width, height * 0.72); + ctx.lineTo(0.6 * width, height * 0.72); + ctx.lineTo(0.6 * width, height); + ctx.lineTo(0, height * 0.5); + } + Canvas { + id: backgroundCanvas + anchors.fill: parent + + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + + paintOutlinePath(ctx); + + ctx.lineWidth = 1; + ctx.strokeStyle = "lightgrey"; + ctx.stroke(); + } + } + Canvas { + id: foregroundCanvas + anchors.fill: parent + visible: on && flashing + + onPaint: { + var ctx = getContext("2d"); + ctx.reset(); + + paintOutlinePath(ctx); + + ctx.fillStyle = "green"; + ctx.fill(); + } + } +} diff --git a/app/ValueSource.qml b/app/ValueSource.qml new file mode 100644 index 0000000..48e5cf6 --- /dev/null +++ b/app/ValueSource.qml @@ -0,0 +1,420 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Konsulko Group +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + +import QtQuick 2.2 +Item { + id: valueSource + property real kph: 0 + property bool mphDisplay: true + property real speedScaling: mphDisplay == true ? 0.621 : 1.0 + property real rpm: 1 + property real fuel: 0.85 + property string gear: { + var g; + if (kph < 30) { + return "1"; + } + if (kph < 50) { + return "2"; + } + if (kph < 80) { + return "3"; + } + if (kph < 120) { + return "4"; + } + if (kph < 160) { + return "5"; + } + } + property string prindle: { + var g; + if (kph > 0) { + return "D"; + } + return "P"; + } + + property bool start: true + property int turnSignal: -1 + property bool startUp: false + property real temperature: 0.6 + + function randomDirection() { + return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow; + } + + SequentialAnimation { + running: true + loops: 1 + + // We want a small pause at the beginning, but we only want it to happen once. + PauseAnimation { + duration: 1000 + } + + PropertyAction { + target: valueSource + property: "start" + value: false + } + + SequentialAnimation { + loops: Animation.Infinite + + // Simulate startup with indicators blink + PropertyAction { + target: valueSource + property: "startUp" + value: true + } + PauseAnimation { + duration: 1000 + } + PropertyAction { + target: valueSource + property: "startUp" + value: false + } + + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + from: 0 + to: 30 + duration: 3000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + from: 1 + to: 6.1 + duration: 3000 + } + } + ParallelAnimation { + // We changed gears so we lost a bit of speed. + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + from: 30 + to: 26 + duration: 600 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + from: 6 + to: 2.4 + duration: 600 + } + } + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 60 + duration: 3000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.6 + duration: 3000 + } + } + ParallelAnimation { + // We changed gears so we lost a bit of speed. + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 56 + duration: 600 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 2.3 + duration: 600 + } + } + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 100 + duration: 3000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.1 + duration: 3000 + } + } + ParallelAnimation { + // We changed gears so we lost a bit of speed. + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 96 + duration: 600 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 2.2 + duration: 600 + } + } + + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 140 + duration: 3000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 6.2 + duration: 3000 + } + } + + // Slow down a bit + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 115 + duration: 6000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.5 + duration: 6000 + } + } + + // Turn signal on + PropertyAction { + target: valueSource + property: "turnSignal" + value: randomDirection() + } + + // Cruise for a while + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 110 + duration: 10000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.2 + duration: 10000 + } + } + + // Turn signal off + PropertyAction { + target: valueSource + property: "turnSignal" + value: -1 + } + + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 115 + duration: 10000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.5 + duration: 10000 + } + } + + // Start downshifting. + + // Fifth to fourth gear. + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.Linear + to: 100 + duration: 5000 + } + + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 3.1 + duration: 5000 + } + } + + // Fourth to third gear. + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 5.5 + duration: 600 + } + + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 60 + duration: 5000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 2.6 + duration: 5000 + } + } + + // Third to second gear. + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 6.3 + duration: 600 + } + + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 30 + duration: 5000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 2.6 + duration: 5000 + } + } + + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 6.5 + duration: 600 + } + + // Second to first gear. + ParallelAnimation { + NumberAnimation { + target: valueSource + property: "kph" + easing.type: Easing.InOutSine + to: 0 + duration: 5000 + } + NumberAnimation { + target: valueSource + property: "rpm" + easing.type: Easing.InOutSine + to: 1 + duration: 4500 + } + } + + PauseAnimation { + duration: 5000 + } + } + } +} diff --git a/app/cluster-gauges.qml b/app/cluster-gauges.qml new file mode 100644 index 0000000..40e4476 --- /dev/null +++ b/app/cluster-gauges.qml @@ -0,0 +1,478 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 Konsulko Group +** Copyright (C) 2019 FUJITSU LIMITED +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt 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$ +** +****************************************************************************/ + +/* + * NOTE: Originally written from scratch, but enough code was eventually + * pasted in from the Qt dashboard.qml example that its license text + * has been adopted. + */ + +import QtQuick 2.2 +import QtQuick.Window 2.1 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Extras 1.4 +import QtWayland.Compositor 1.0 + +WaylandCompositor { + WaylandOutput { + sizeFollowsWindow: true + window: Window{ + id: root + width: 1920 + height: 1080 + visible: true + flags: Qt.FramelessWindowHint + color: "black" + + ValueSource { + id: valueSource + } + + Rectangle { + id: statusFrame + x: (parent.width - width) / 2 + y: 80 + width: 1152 + height: 96 + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Row { + width: parent.width + height: parent.height * 0.75 + spacing: (parent.width - (12 * parent.height * 0.75)) / 13 + + anchors.fill: parent + anchors.topMargin: (parent.height - height) /2 + anchors.bottomMargin: (parent.height - height) /2 + anchors.leftMargin: (parent.width - (12 * parent.height * 0.75)) / 13 + anchors.rightMargin: (parent.width - (12 * parent.height * 0.75)) / 13 + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + TurnIndicator { + id: leftIndicator + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + + direction: Qt.LeftArrow + on: valueSource.turnSignal == Qt.LeftArrow + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Engine_yellow.svg' : './images/AGL_Icons_Engine.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Oil_red.svg' : './images/AGL_Icons_Oil.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_ABS_red.svg' : './images/AGL_Icons_ABS.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Battery_red.svg' : './images/AGL_Icons_Battery.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Text { + id: prindle + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignCenter + + text: valueSource.prindle + color: "white" + font.pixelSize: parent.height * 0.85 + } + } + + Rectangle { + id: gearIndicatior + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Text { + id: gear + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + horizontalAlignment: Text.AlignCenter + + text: valueSource.gear + color: "white" + font.pixelSize: parent.height * 0.85 + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Seatbelt_red.svg' : './images/AGL_Icons_Seatbelt.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_OpenDoor_red.svg' : './images/AGL_Icons_OpenDoor.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Lights_red.svg' : './images/AGL_Icons_Lights.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_ParkingBrake_red.svg' : './images/AGL_Icons_ParkingBrake.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + TurnIndicator { + id: rightIndicator + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + + direction: Qt.RightArrow + on: valueSource.turnSignal == Qt.RightArrow + } + } + } + } + + Item { + x: 36 + y: 240 + width: 600 + height: width + + CircularGauge { + id: accelerometer + x: (parent.width - width) / 2 + //y: (parent.height - height) / 2 + width: parent.width * 0.9 + height: width + + maximumValue: valueSource.mphDisplay ? 140 : 220 + value: valueSource.kph * valueSource.speedScaling + + style: DashboardGaugeStyle {} + } + } + + Item { + x: 1284 + y: 240 + width: 600 + height: width + + CircularGauge { + id: tachometer + x: (parent.width - width) / 2 + width: parent.width * 0.9 + height: width + + maximumValue: 8 + value: valueSource.rpm + + style: TachometerStyle {} + } + + CircularGauge { + id: fuelGauge + value: valueSource.fuel + maximumValue: 1 + y: parent.width * 0.85 + width: parent.width * 0.45 + height: parent.height * 0.25 + + style: IconGaugeStyle { + id: fuelGaugeStyle + + icon: "./images/fuel-icon.png" + minWarningColor: Qt.rgba(0.5, 0, 0, 1) + + tickmarkLabel: Text { + color: "white" + visible: styleData.value === 0 || styleData.value === 1 + font.pixelSize: fuelGaugeStyle.toPixels(0.225) + text: styleData.value === 0 ? "E" : (styleData.value === 1 ? "F" : "") + } + } + } + + CircularGauge { + id: tempGauge + value: valueSource.temperature + maximumValue: 1 + x: parent.width * 0.55 + y: parent.width * 0.85 + width: parent.width * 0.45 + height: parent.height * 0.25 + + style: IconGaugeStyle { + id: tempGaugeStyle + + icon: "./images/temperature-icon.png" + maxWarningColor: Qt.rgba(0.5, 0, 0, 1) + + tickmarkLabel: Text { + color: "white" + visible: styleData.value === 0 || styleData.value === 1 + font.pixelSize: tempGaugeStyle.toPixels(0.225) + text: styleData.value === 0 ? "C" : (styleData.value === 1 ? "H" : "") + } + } + } + } + + Rectangle { + id: frame + x: 672 + y: 264 + width: 576 + height: 552 + + color: "black" + border.width: 4 + border.color: "grey" + + Image { + source: './images/Utility_Logo_Grey-01.svg' + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 2 + height: width + } + } + + Image { + source: './images/agl_title_793x211.png' + //x: 772 + x: (parent.width - width) / 2 + y: 898 + width: 376 + height: 100 + } +} +} + + Component { + id: chromeComponent + ShellSurfaceItem { + anchors.fill: parent + onSurfaceDestroyed: destroy() + onWidthChanged: handleResized() + onHeightChanged: handleResized() + function handleResized() { + shellSurface.sendConfigure(Qt.size(width, height)); + } + } + } + IviApplication { + onIviSurfaceCreated: { + var item = chromeComponent.createObject(frame, { "shellSurface": iviSurface } ); + item.handleResized(); + } + } +} diff --git a/app/cluster-gauges.qrc b/app/cluster-gauges.qrc new file mode 100644 index 0000000..22f7528 --- /dev/null +++ b/app/cluster-gauges.qrc @@ -0,0 +1,10 @@ + + + cluster-gauges.qml + DashboardGaugeStyle.qml + IconGaugeStyle.qml + TachometerStyle.qml + TurnIndicator.qml + ValueSource.qml + + diff --git a/app/images/AGL_Icons_ABS.svg b/app/images/AGL_Icons_ABS.svg new file mode 100644 index 0000000..edbedf9 --- /dev/null +++ b/app/images/AGL_Icons_ABS.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_ABS_red.svg b/app/images/AGL_Icons_ABS_red.svg new file mode 100644 index 0000000..eee96ff --- /dev/null +++ b/app/images/AGL_Icons_ABS_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_ABS_yellow.svg b/app/images/AGL_Icons_ABS_yellow.svg new file mode 100644 index 0000000..253d732 --- /dev/null +++ b/app/images/AGL_Icons_ABS_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Battery.svg b/app/images/AGL_Icons_Battery.svg new file mode 100644 index 0000000..a98e6ba --- /dev/null +++ b/app/images/AGL_Icons_Battery.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Battery_red.svg b/app/images/AGL_Icons_Battery_red.svg new file mode 100644 index 0000000..e2354b5 --- /dev/null +++ b/app/images/AGL_Icons_Battery_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Battery_yellow.svg b/app/images/AGL_Icons_Battery_yellow.svg new file mode 100644 index 0000000..5ab1800 --- /dev/null +++ b/app/images/AGL_Icons_Battery_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Engine.svg b/app/images/AGL_Icons_Engine.svg new file mode 100644 index 0000000..2a878bc --- /dev/null +++ b/app/images/AGL_Icons_Engine.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Engine_red.svg b/app/images/AGL_Icons_Engine_red.svg new file mode 100644 index 0000000..c78cf80 --- /dev/null +++ b/app/images/AGL_Icons_Engine_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Engine_yellow.svg b/app/images/AGL_Icons_Engine_yellow.svg new file mode 100644 index 0000000..fb70571 --- /dev/null +++ b/app/images/AGL_Icons_Engine_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Lights.svg b/app/images/AGL_Icons_Lights.svg new file mode 100644 index 0000000..889582f --- /dev/null +++ b/app/images/AGL_Icons_Lights.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Lights_red.svg b/app/images/AGL_Icons_Lights_red.svg new file mode 100644 index 0000000..fd3ee5e --- /dev/null +++ b/app/images/AGL_Icons_Lights_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Lights_yellow.svg b/app/images/AGL_Icons_Lights_yellow.svg new file mode 100644 index 0000000..b06dcc8 --- /dev/null +++ b/app/images/AGL_Icons_Lights_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Oil.svg b/app/images/AGL_Icons_Oil.svg new file mode 100644 index 0000000..4448b89 --- /dev/null +++ b/app/images/AGL_Icons_Oil.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Oil_red.svg b/app/images/AGL_Icons_Oil_red.svg new file mode 100644 index 0000000..6a0681a --- /dev/null +++ b/app/images/AGL_Icons_Oil_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Oil_yellow.svg b/app/images/AGL_Icons_Oil_yellow.svg new file mode 100644 index 0000000..8af8c0e --- /dev/null +++ b/app/images/AGL_Icons_Oil_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_OpenDoor.svg b/app/images/AGL_Icons_OpenDoor.svg new file mode 100644 index 0000000..9f99ab2 --- /dev/null +++ b/app/images/AGL_Icons_OpenDoor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_OpenDoor_red.svg b/app/images/AGL_Icons_OpenDoor_red.svg new file mode 100644 index 0000000..f4aca7b --- /dev/null +++ b/app/images/AGL_Icons_OpenDoor_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_OpenDoor_yellow.svg b/app/images/AGL_Icons_OpenDoor_yellow.svg new file mode 100644 index 0000000..18c2777 --- /dev/null +++ b/app/images/AGL_Icons_OpenDoor_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_ParkingBrake.svg b/app/images/AGL_Icons_ParkingBrake.svg new file mode 100644 index 0000000..01fa7ef --- /dev/null +++ b/app/images/AGL_Icons_ParkingBrake.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_ParkingBrake_red.svg b/app/images/AGL_Icons_ParkingBrake_red.svg new file mode 100644 index 0000000..d9dec37 --- /dev/null +++ b/app/images/AGL_Icons_ParkingBrake_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_ParkingBrake_yellow.svg b/app/images/AGL_Icons_ParkingBrake_yellow.svg new file mode 100644 index 0000000..8e99d11 --- /dev/null +++ b/app/images/AGL_Icons_ParkingBrake_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Seatbelt.svg b/app/images/AGL_Icons_Seatbelt.svg new file mode 100644 index 0000000..8664864 --- /dev/null +++ b/app/images/AGL_Icons_Seatbelt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Seatbelt_red.svg b/app/images/AGL_Icons_Seatbelt_red.svg new file mode 100644 index 0000000..901da9c --- /dev/null +++ b/app/images/AGL_Icons_Seatbelt_red.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/AGL_Icons_Seatbelt_yellow.svg b/app/images/AGL_Icons_Seatbelt_yellow.svg new file mode 100644 index 0000000..4871125 --- /dev/null +++ b/app/images/AGL_Icons_Seatbelt_yellow.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/images/Utility_Logo_Grey-01.svg b/app/images/Utility_Logo_Grey-01.svg new file mode 100644 index 0000000..16ac88c --- /dev/null +++ b/app/images/Utility_Logo_Grey-01.svg @@ -0,0 +1,84 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/images/agl_title_793x211.png b/app/images/agl_title_793x211.png new file mode 100644 index 0000000..5a183d2 Binary files /dev/null and b/app/images/agl_title_793x211.png differ diff --git a/app/images/fuel-icon.png b/app/images/fuel-icon.png new file mode 100644 index 0000000..70da758 Binary files /dev/null and b/app/images/fuel-icon.png differ diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..9a8e2de --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,32 @@ + + + agl_title_793x211.png + Utility_Logo_Grey-01.svg + fuel-icon.png + temperature-icon.png + AGL_Icons_ABS.svg + AGL_Icons_ABS_red.svg + AGL_Icons_ABS_yellow.svg + AGL_Icons_Battery.svg + AGL_Icons_Battery_red.svg + AGL_Icons_Battery_yellow.svg + AGL_Icons_Engine.svg + AGL_Icons_Engine_red.svg + AGL_Icons_Engine_yellow.svg + AGL_Icons_Lights.svg + AGL_Icons_Lights_red.svg + AGL_Icons_Lights_yellow.svg + AGL_Icons_Oil.svg + AGL_Icons_Oil_red.svg + AGL_Icons_Oil_yellow.svg + AGL_Icons_OpenDoor.svg + AGL_Icons_OpenDoor_red.svg + AGL_Icons_OpenDoor_yellow.svg + AGL_Icons_ParkingBrake.svg + AGL_Icons_ParkingBrake_red.svg + AGL_Icons_ParkingBrake_yellow.svg + AGL_Icons_Seatbelt.svg + AGL_Icons_Seatbelt_red.svg + AGL_Icons_Seatbelt_yellow.svg + + diff --git a/app/images/temperature-icon.png b/app/images/temperature-icon.png new file mode 100644 index 0000000..5a4334e Binary files /dev/null and b/app/images/temperature-icon.png differ diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..a7c832c --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2018 Konsulko Group + * Copyright (C) 2019 FUJITSU LIMITED + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include + +#define DEFAULT_QT_QPA_PLATFORM "eglfs" +#define DEFAULT_EGLFS_CONFIG_FILE "/etc/kms.conf" + +int main(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (!argv[i] || *argv[i] != '-') + continue; + const char *arg = argv[i]; + if (arg[1] == '-') // startsWith("--") + ++arg; + if (strcmp(arg, "-platform") == 0) + break; + } + + /* Using "eglfs" as default if QT_QPA_PLATFORM is not set. */ + QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); + if (platformNameEnv.isEmpty() && i == argc) { + qputenv("QT_QPA_PLATFORM", DEFAULT_QT_QPA_PLATFORM); + } + + /* Using "/etc/kms.conf" as default if QT_QPA_EGLFS_KMS_CONFIG/QT_QPA_KMS_CONFIG are not set. */ + if (qgetenv("QT_QPA_KMS_CONFIG").isEmpty() && + qgetenv("QT_QPA_EGLFS_KMS_CONFIG").isEmpty()) { + qputenv("QT_QPA_EGLFS_KMS_CONFIG", DEFAULT_EGLFS_CONFIG_FILE); + } + + /* FIXTHIS: socket cannot be created successfully in '/run/user/0'. */ + qputenv("XDG_RUNTIME_DIR", "/run/platform/display"); + + QGuiApplication app(argc, argv); + QQmlApplicationEngine appEngine(QUrl("qrc:///cluster-gauges.qml")); + + return app.exec(); +} -- cgit 1.2.3-korg