C

Qt Quick Ultralite Motorcycle Cluster Demo

/****************************************************************************** ** ** Copyright (C) 2020 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 list tachoElements: [ Qt.point(0, 81), Qt.point(35, 63), Qt.point(75, 43), Qt.point(113, 25), Qt.point(156, 7), Qt.point(204, 0), Qt.point(251, 0), Qt.point(298, 0), Qt.point(345, 0), Qt.point(390, 0), Qt.point(433, 0), Qt.point(485, 0), Qt.point(528, 7), Qt.point(572, 25), Qt.point(612, 43), Qt.point(649, 63), Qt.point(685, 81) ] Repeater { id: scale model: root.tachoElements.length Text { text: index y: root.tachoElements[index].y x: root.tachoElements[index].x 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 } } } }