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 ".."
import "."
import ClusterDemo
import Qt.SafeRenderer

Item {
    id: root
    width: 1920
    height: 1080
    property alias camera: camera
    property alias speedoMeter: speedoMeter
    property alias flipable: flipable

    property bool startupAnimationStopped: false

    property int gaugeDemoTime: 1000
    property alias centerStack: centerStack // duration (/2) of the gauge needle animation at startup
    property alias turnIndicatorLeft: turnleft
    property alias turnIndicatorRight: turnright
    property alias iconCoolant: iconCoolant
    property alias iconBattery: iconBattery
    property alias iconFuel: iconFuel
    property alias iconParkingBrake: iconParkingBrake
    property alias iconLights: iconLights
    property alias iconLowbeam: iconLowBeam
    property alias iconTyre: iconTyre
    property alias iconLamp: iconLamp
    property alias iconSeatbelt: iconSeatbelt
    property alias speedText: speedText

    // TODO: Needed, as background clearing gets messed up after hybrid 3D
    Rectangle {
        anchors.fill: parent
        color: "black"
        z: -1
    }

    Image {
        id: frame
        y: 180
        width: 1920
        height: 720
        fillMode: Image.Stretch
        source: "image://etc/DashboardFrameSport-mask.png"
        z: 2
    }

    //where?
    CameraLoader {
        id: camera

        width: parent.width / 2.5
        height: parent.height - 270

        anchors.centerIn: parent
    }

    // end comment
    Item {
        id: container

        width: root.width
        height: 720
        anchors.verticalCenterOffset: 0
        anchors.horizontalCenterOffset: 0
        anchors.centerIn: parent

        SpeedoMeterLoader {
            id: speedoMeter
            anchors.left: parent.left
            anchors.leftMargin: 72
            anchors.top: parent.top
            anchors.topMargin: 101
            height: 570
            value: 50
            width: 570
            z: 4
        }

        SafePicture {
            id: iconTyre
            objectName: "iconTyre"
            width: 72
            height: 72
            anchors.right: iconParkingBrake.left
            anchors.bottom: iconParkingBrake.bottom
            anchors.bottomMargin: 18

            color: "#face20"
            source: "qrc:/iso-icons/iso_grs_7000_4_1434A.dat"
            z: 4
        }

        SafeText {
            id: speedText
            objectName: "speedText"
            anchors.horizontalCenter: speedoMeter.horizontalCenter
            anchors.top: speedoMeter.top
            anchors.topMargin: 158
            font.pixelSize: 108
            color: "white"
            width: 384
            height: 114
            text: "10"
            verticalAlignment: Text.AlignTop
            anchors.horizontalCenterOffset: 0
            font.family: "Lato"
            horizontalAlignment: Text.AlignHCenter
            runtimeEditable: true
        }

        SafeText {
            id: kmText
            objectName: "kmText"
            text: "km/h"
            verticalAlignment: Text.AlignTop
            font.italic: true
            anchors.horizontalCenterOffset: 0
            anchors.topMargin: 0
            font.family: "Lato"
            color: "white"
            width: 98
            height: 48
            font.pixelSize: 38
            horizontalAlignment: Text.AlignHCenter
            anchors.top: speedText.bottom
            anchors.horizontalCenter: speedoMeter.horizontalCenter
        }

        SafePicture {
            id: iconParkingBrake
            objectName: "iconParkingBrake"
            width: 72
            height: 72
            anchors.centerIn: speedoMeter
            anchors.verticalCenterOffset: 72
            anchors.horizontalCenterOffset: 0

            color: "#e41e25"
            source: "qrc:/iso-icons/iso_grs_7000_4_0238.dat"
            z: 4
        }

        SafePicture {
            id: iconFuel
            objectName: "iconFuel"
            width: 72
            height: 72
            anchors.left: iconParkingBrake.right
            anchors.bottom: iconParkingBrake.bottom
            anchors.bottomMargin: 27

            color: "#e41e25"
            source: "qrc:/iso-icons/iso_grs_7000_4_0245.dat"
            z: 4
        }

        CenterStack {
            id: centerStack
            viewIndex: 3
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.top: parent.top
            anchors.topMargin: 125
        }

        RPMFlipable {
            id: flipable
            anchors.right: parent.right
            anchors.rightMargin: 75
            anchors.top: parent.top
            anchors.topMargin: 104
            width: 570
            height: 570
            rpmValue: 2212
            flipped: false
            z: 4
        }

        SafePicture {
            id: iconBattery
            objectName: "iconBattery"
            width: 72
            height: 72
            anchors.centerIn: flipable
            anchors.verticalCenterOffset: 36
            anchors.horizontalCenterOffset: -36
            source: "qrc:/iso-icons/iso_grs_7000_4_0247.dat"
            color: "#e41e25"
            z: 4
        }

        SafePicture {
            id: iconCoolant
            objectName: "iconCoolant"
            width: 72
            height: 72
            anchors.centerIn: flipable
            anchors.verticalCenterOffset: 36
            anchors.horizontalCenterOffset: 36

            source: "qrc:/iso-icons/iso_grs_7000_4_0246.dat"
            color: "blue"
            z: 4
        }
    }

    Item {
        width: speedoMeter.width
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.top: pilotLights.top

        TurnLeft {
            id: turnleft
        }

        TurnRight {
            id: turnright
        }
    }

    Item {
        id: bottomRow
        height: 102
        width: 480
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 195
        anchors.horizontalCenter: parent.horizontalCenter
        z: 3
        property int pixelSize: 26
        Text {
            text: ValueSource.date
            color: "white"
            font.pixelSize: bottomRow.pixelSize
            anchors.right: temperature.left
            anchors.rightMargin: 23
        }
        Text {
            id: temperature
            text: "+18°C"
            color: "white"
            font.pixelSize: bottomRow.pixelSize
            anchors.right: time.left
            anchors.rightMargin: 23
        }
        Text {
            id: time
            text: ValueSource.time
            color: "white"
            font.pixelSize: bottomRow.pixelSize
            anchors.right: parent.right
        }
    }

    Row {
        id: pilotLights
        anchors.horizontalCenter: parent.horizontalCenter
        y: 215
        spacing: 3.0
        z: 3
        width: 300

        SafePicture {
            id: iconLights
            objectName: "iconLights"
            width: 72
            height: 72

            color: "#5caa15"
            source: "qrc:/iso-icons/iso_grs_7000_4_0456.dat"
        }

        SafePicture {
            id: iconSeatbelt
            objectName: "iconSeatbelt"
            width: 72
            height: 72

            color: "#e41e25"
            source: "qrc:/iso-icons/iso_grs_7000_4_0249.dat"
        }

        SafePicture {
            id: iconLowBeam
            objectName: "iconLowBeam"
            width: 72
            height: 72

            color: "#e41e25"
            source: "qrc:/iso-icons/iso_grs_7000_4_0083.dat"
        }

        SafePicture {
            id: iconLamp
            objectName: "iconLamp"
            width: 72
            height: 72

            color: "#face20"
            source: "qrc:/iso-icons/iso_grs_7000_4_1555.dat"
        }
    }

    SafeText {
        id: safeText
        objectName: "safeText"
        x: 800
        y: 415
        width: 366
        height: 102
        color: "#face20"
        text: "Error occurred. Recovering.."
        wrapMode: Text.WordWrap
        horizontalAlignment: Text.AlignHCenter
        font.pixelSize: 30
        font.family: "Lato"
        visible: false
    }

    // end comment
}