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 Item { id: root width: 1050 property int counter: 0 readonly property int opacityAnimationDuration: 1000 readonly property int listingAnimationDuration: 1000 readonly property int elementsCount: 17 property bool active: false property bool isDayMode: true readonly property ListModel tachoElements: ListModel { id: tachoImagesModel ListElement { yPos: 122 xPos: 0 } ListElement { yPos: 95 xPos: 53 } ListElement { yPos: 65 xPos: 113 } ListElement { yPos: 38 xPos: 170 } ListElement { yPos: 11 xPos: 234 } ListElement { yPos: 0 xPos: 306 } ListElement { yPos: 0 xPos: 377 } ListElement { yPos: 0 xPos: 447 } ListElement { yPos: 0 xPos: 518 } ListElement { yPos: 0 xPos: 585 } ListElement { yPos: 0 xPos: 650 } ListElement { yPos: 0 xPos: 728 } ListElement { yPos: 11 xPos: 792 } ListElement { yPos: 38 xPos: 858 } ListElement { yPos: 65 xPos: 918 } ListElement { yPos: 95 xPos: 974 } ListElement { yPos: 122 xPos: 1028 } } Repeater { id: scale model: tachoElements Text { text: index y: model.yPos x: model.xPos color: index >= 13 ? Style.pureRed : (isDayMode ? Style.black : Style.white) opacity: index >= counter ? 0.0 : 1.0 font.pixelSize: 18 font.family: "Barlow-mono" Behavior on opacity { NumberAnimation { duration: root.opacityAnimationDuration } } } } onActiveChanged: { if (active) { root.opacity = 1 startAnimation() } else { hiddingAnimation() } } function startAnimation() { showAnimation.start() } function hiddingAnimation() { hideAnimation.start() } NumberAnimation { id: showAnimation target: root property: "counter" from: 0 to: root.elementsCount duration: root.listingAnimationDuration } SequentialAnimation { id: hideAnimation NumberAnimation { target: root property: "opacity" duration: 500 to: 0 } ScriptAction { script: { root.counter = 0 } } } }