C

Qt Cluster: Rendering and Recovery from Main UI Failure

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

// This file is part of the Qt Safe Renderer module

import QtQuick
import ClusterDemo
import Qt.SafeRenderer
import "gauges"

DashboardForm
{
    id: dashboardEntity

    state: "start"

    meterOpacity: 0.0

    anchors.fill: parent

    property real timeScaleMultiplier: 1.5
    property bool startupAnimationsFinished: false

    //onNeedleRotationChanged: speedometer.speedometerNeedleRotation = needleRotation / 40.

    property bool animationStopped: ValueSource.runningInDesigner ? true : startupAnimationsFinished

    speedometer.actualValue: animationStopped ? ValueSource.kph : -needleRotation / 40

    tachometer.actualValue: animationStopped ? ValueSource.rpm : -needleRotation

    speedText.text: speedometer.actualValue.toFixed().toString()

    property color iconRed: "#e41e25"
    property color iconGreen: "#5caa15"
    property color iconYellow: "#face20"
    property color iconDark: "transparent" //hide icons

    turnIndicatorLeft.source: "qrc:/images/Icon_TurnLeft_OFF_small.png"
    turnIndicatorRight.source: "qrc:/images/Icon_TurnRight_OFF_small.png"
    iconCoolant.color: dashboardEntity.iconDark
    iconBattery.color: dashboardEntity.iconDark
    iconFuel.color: dashboardEntity.iconDark
    iconParkingBrake.color: dashboardEntity.iconDark
    iconLights.color: dashboardEntity.iconDark
    iconTyre.color: dashboardEntity.iconDark
    iconLamp.color: dashboardEntity.iconDark
    iconSeatbelt.color: dashboardEntity.iconDark
    safeText.visible: false
    speedText.visible: false

    //
    // Startup animations
    //
    SequentialAnimation {
        id: speedometerStartupAnimations
        running: true

        PauseAnimation { duration: 1000 }
        ScriptAction { script: bottompanel.visible = true }

        SmoothedAnimation {
            target: dashboardEntity
            property: "bottomPanelY"
            from: 720
            to: 720 - 138
            duration: 1000 * timeScaleMultiplier
            easing.type: Easing.InCirc
        }

        PauseAnimation {
            duration: 1000
        }

        NumberAnimation {
            target: dashboardEntity
            property: "meterOpacity"
            from: 0
            to: 1
            duration: 2000
        }

        SmoothedAnimation {
            target: dashboardEntity
            property: "needleRotation"
            from: 0.0
            to: -8000.0
            duration: 1000 * timeScaleMultiplier
            easing.type: Easing.InCubic
        }

        SmoothedAnimation {
            target: dashboardEntity
            property: "needleRotation"
            from: -8000.0
            to: 0.0
            duration: 1000 * timeScaleMultiplier
            easing.type: Easing.OutCubic
        }

        ScriptAction { script: startupAnimationsFinished = true }
    }

    function stopAll() {
        speedometerStartupAnimations.stop()
    }

}