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 "../functions.js" as Functions

Item {
    id: speedoItem
    property real speedValue: speedoMeter.value
    property alias maxValue: speedometer.maxValue
    anchors.fill: parent

    property color iconRed: "#e41e25"
    property color iconGreen: "#5caa15"
    property color iconYellow: "#face20"
    property color iconDark: "#444444"

    Item {
        id: speedometer

        property bool animated: ValueSource.runningInDesigner ? false : startupAnimationStopped
        property real value: animated ? ValueSource.kph : speedValue

        anchors.fill: parent

        property real maxValue: 240
        width: height

        property real outerRadius: Math.min(width, height) * 0.5

        property real maxValueAngle: 90
        property real minValueAngle: -179

        property real degreesPerValue: Math.abs((minValueAngle - maxValueAngle)
                                                / speedometer.maximumValue)

        Image {
            source: "image://etc/Gauge_Speed.png"
            anchors.fill: parent
        }

        CircularIndicator {
            anchors.fill: parent

            startAngle: speedometer.minValueAngle
            endAngle: speedometer.maxValueAngle
            minimumValue: 0
            maximumValue: speedometer.maxValue
            value: speedometer.value
            padding: 13
            backgroundColor: "transparent"
            progressColor: "#E31E24"
        }
    }

    CircularIndicator {
        id: fuelGauge

        anchors.fill: parent

        value: ValueSource.fuelLevel
        minimumValue: 0
        maximumValue: 100
        startAngle: 144
        endAngle: 108
        padding: 13
        backgroundColor: "transparent"
        progressColor: "#464749"
    }
}