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.15 Item { id: root width: 160 height: 86 property bool active property bool engineFailureActive property bool batteryFailureActive property bool highBeamActive property bool engineOilActive property bool engineFailureActiveForStartupAnimation property bool batteryFailureActiveForStartupAnimation property bool highBeamActiveForStartupAnimation property bool engineOilActiveForStartupAnimation TellTalesIndicator { id: highBeamTT x: 0 anchors.verticalCenter: parent.verticalCenter source: "images/telltales/high-beamsOff.png" active: startUpAnimation.running ? highBeamActiveForStartupAnimation : highBeamActive activeColor: Style.telltallesBlue } TellTalesIndicator { id: batteryTT anchors.left: highBeamTT.right anchors.leftMargin: 10 anchors.verticalCenter: parent.verticalCenter source: "images/telltales/batteryOff.png" active: startUpAnimation.running ? batteryFailureActiveForStartupAnimation : batteryFailureActive } TellTalesIndicator { id: engineFailureTT source: "images/telltales/engine-failureOff.png" anchors.left: batteryTT.left anchors.top: batteryTT.bottom anchors.topMargin: 32 active: startUpAnimation.running ? engineFailureActiveForStartupAnimation : engineFailureActive } TellTalesIndicator { id: engineOilTT anchors.left: batteryTT.left anchors.bottom: batteryTT.top anchors.bottomMargin: 32 source: "images/telltales/engine-oilOff.png" active: startUpAnimation.running ? engineOilActiveForStartupAnimation : engineOilActive } function hideElements() { highBeamTT.isVisible = false engineFailureTT.isVisible = false batteryTT.isVisible = false engineOilTT.isVisible = false highBeamActiveForStartupAnimation = false engineFailureActiveForStartupAnimation = false batteryFailureActiveForStartupAnimation = false engineOilActiveForStartupAnimation = false } onActiveChanged: { if(active) { startAnimation() } else { hideElements() } } function startAnimation() { startUpAnimation.start() } readonly property int telltaleDalay: 200 SequentialAnimation { id: startUpAnimation ScriptAction { script: {highBeamTT.isVisible = true; highBeamActiveForStartupAnimation = true} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {engineFailureTT.isVisible = true; engineFailureActiveForStartupAnimation = true} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {batteryTT.isVisible = true; batteryFailureActiveForStartupAnimation = true} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {engineOilTT.isVisible = true; engineOilActiveForStartupAnimation = true} } PauseAnimation { duration: 4000 } ScriptAction { script: {engineOilActiveForStartupAnimation = false} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {batteryFailureActiveForStartupAnimation = false} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {engineFailureActiveForStartupAnimation = false} } PauseAnimation { duration: telltaleDalay } ScriptAction { script: {highBeamActiveForStartupAnimation = false} } } Component.onCompleted: root.hideElements() }