C

Qt Quick Ultralite Motorcycle Cluster Demo

/****************************************************************************** ** ** Copyright (C) 2019 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: 700 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: 81 xPos: 0 } ListElement { yPos: 63 xPos: 35 } ListElement { yPos: 43 xPos: 75 } ListElement { yPos: 25 xPos: 113 } ListElement { yPos: 7 xPos: 156 } ListElement { yPos: 0 xPos: 204 } ListElement { yPos: 0 xPos: 251 } ListElement { yPos: 0 xPos: 298 } ListElement { yPos: 0 xPos: 345 } ListElement { yPos: 0 xPos: 390 } ListElement { yPos: 0 xPos: 433 } ListElement { yPos: 0 xPos: 485 } ListElement { yPos: 7 xPos: 528 } ListElement { yPos: 25 xPos: 572 } ListElement { yPos: 43 xPos: 612 } ListElement { yPos: 63 xPos: 649 } ListElement { yPos: 81 xPos: 685 } } 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 } } } }