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
Item {
id: speedometer
property real speedometerNeedleRotation: 0.0
property string speed: actualSpeed.toFixed().toString()
property bool animationStopped: ValueSource.runningInDesigner ? true : startupAnimationsFinished
property real actualSpeed: animationStopped
? ValueSource.kph : -speedometerNeedleRotation
property real minValueAngle: 55
property real maxValueAngle: 305
property real minimumSpeed: 0
property real maximumSpeed: 200
Item {
anchors.left: parent.left
anchors.leftMargin: 20
width: 480
height: 480
GaugeFiller {
id: speedFiller
value: speedometer.actualSpeed
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: 244
anchors.leftMargin: 255
visible: false
numVertices: 64
radius: 155
fillWidth: 5
color: speedometer.actualSpeed < 100 ? "green" : "#EF2973"
opacity: 0.6
minAngle: speedometer.minValueAngle
maxAngle: speedometer.maxValueAngle
minValue: speedometer.minimumSpeed
maxValue: speedometer.maximumSpeed
}
}
Item {
id: speedometerNeedle
width: 309
height: 7
rotation: speedFiller.angle - 35
x: 121
y: 243
Image {
opacity: 0.75
width: 97
height: 7
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
source: speedometer.actualSpeed < 100 ? "image://etc/SpeedometerNeedleGreen.png" : "image://etc/SpeedometerNeedle.png"
}
}
Row {
anchors.top: speedometerNeedle.bottom
anchors.topMargin: 80
anchors.horizontalCenter: speedometerNeedle.horizontalCenter
spacing: 7
Text {
font.pixelSize: 18
color:(ValueSource.gear === 0 && ValueSource.parkingBrake) ? "white" : "gray"
text: "P"
}
Text {
font.pixelSize: 18
//font.bold: ValueSource.gear === -1
color: ValueSource.gear === -1 ? "white" : "gray"
text: "R"
}
Text {
font.pixelSize: 18
//font.bold: ValueSource.gear === 0
color: (ValueSource.gear === 0 && !ValueSource.parkingBrake) ? "white" : "gray"
text: "N"
}
Text {
font.pixelSize: 18
//font.bold: ValueSource.gear === 1
color: ValueSource.gear === 1 ? "white" : "gray"
text: "D"
}
}
Text {
id: speedText
anchors.top: speedometerNeedle.top
anchors.topMargin: -27
anchors.horizontalCenter: speedometerNeedle.horizontalCenter
font.pixelSize: 40
color: "lightGray"
text: speedometer.speed
}
Text {
id: speedUnitText
anchors.top: speedText.bottom
anchors.horizontalCenter: speedometerNeedle.horizontalCenter
font.pixelSize: 18
color: "lightGray"
text: "KM/H"
}
}