C
Qt Quick Ultralite Motorcycle Cluster Demo
/****************************************************************************** ** ** Copyright (C) 2024 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** 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 http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/import QtQuick 2.4 import QtQuickUltralite.Extras 2.0 Item { id: root width: 1076 property int rpm: 10000 property int rpmAnimationTime: 1000 Behavior on rpm { NumberAnimation { duration: rpmAnimationTime } } readonly property int changeOpacityAnimationDuration: 250 readonly property int changeColorAnimationDuration: 1000 property bool isDayMode: false property color normalColor: root.isDayMode ? Style.tachoElementDayMode : Style.tachoElementNightMode property color redColor: root.isDayMode ? Style.tachoElementRedDayMode : Style.tachoElementRedNightMode Behavior on normalColor { NumberAnimation { duration: 1000 } } Behavior on redColor { NumberAnimation { duration: 1000 } } readonly property ListModel tachoElements: ListModel { id: tachoImagesModel ListElement { yPos: 90 xPos: 0 yPosDayMode: 111 xPosDayMode: 26 img: "qrc:///images/tacho/1.png" imgDayMode: "qrc:///images/tacho/light/01.png" } ListElement { yPos: 63 xPos: 56 yPosDayMode: 84 xPosDayMode: 81 img: "qrc:///images/tacho/2.png" imgDayMode: "qrc:///images/tacho/light/02.png" } ListElement { yPos: 36 xPos: 116 yPosDayMode: 57 xPosDayMode: 141 img: "qrc:///images/tacho/3.png" imgDayMode: "qrc:///images/tacho/light/03.png" } ListElement { yPos: 14 xPos: 176 yPosDayMode: 33 xPosDayMode: 201 img: "qrc:///images/tacho/4.png" imgDayMode: "qrc:///images/tacho/light/04.png" } ListElement { yPos: 3 xPos: 236 yPosDayMode: 26 xPosDayMode: 261 img: "qrc:///images/tacho/5.png" imgDayMode: "qrc:///images/tacho/light/05.png" } ListElement { yPos: 0 xPos: 306 yPosDayMode: 24 xPosDayMode: 332 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 0 xPos: 377 yPosDayMode: 24 xPosDayMode: 402 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 0 xPos: 447 yPosDayMode: 24 xPosDayMode: 473 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 0 xPos: 518 yPosDayMode: 24 xPosDayMode: 543 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 0 xPos: 588 yPosDayMode: 24 xPosDayMode: 614 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 0 xPos: 659 yPosDayMode: 24 xPosDayMode: 684 img: "qrc:///images/tacho/6.png" imgDayMode: "qrc:///images/tacho/light/06.png" } ListElement { yPos: 3 xPos: 729 yPosDayMode: 26 xPosDayMode: 755 img: "qrc:///images/tacho/5.png" imgDayMode: "qrc:///images/tacho/light/05.png" } ListElement { yPos: 14 xPos: 800 yPosDayMode: 35 xPosDayMode: 824 img: "qrc:///images/tacho/4.png" imgDayMode: "qrc:///images/tacho/light/04.png" } ListElement { yPos: 36 xPos: 860 yPosDayMode: 59 xPosDayMode: 885 img: "qrc:///images/tacho/3.png" imgDayMode: "qrc:///images/tacho/light/03.png" } ListElement { yPos: 63 xPos: 920 yPosDayMode: 86 xPosDayMode: 945 img: "qrc:///images/tacho/2.png" imgDayMode: "qrc:///images/tacho/light/02.png" } ListElement { yPos: 90 xPos: 980 yPosDayMode: 113 xPosDayMode: 1005 img: "qrc:///images/tacho/1.png" imgDayMode: "qrc:///images/tacho/light/01.png" } } Repeater { id: tachoImages model: tachoElements ColorizedImage { id: img source: root.isDayMode ? model.imgDayMode : model.img y: root.isDayMode ? model.yPosDayMode : model.yPos x: root.isDayMode ? model.xPosDayMode : model.xPos opacity: index * 1000 < root.rpm ? 1 : 0 color: index >= 13 ? root.redColor : root.normalColor transform: Scale { xScale: index > 8 ? -1 : 1 origin.x: img.implicitWidth / 2 } Behavior on opacity { NumberAnimation { duration: changeOpacityAnimationDuration } } Behavior on color { NumberAnimation { duration: changeColorAnimationDuration } } } } }