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 QtQuick.Controls
import Qt.SafeRenderer
import ClusterDemoData

Item {
    id: root
    width: 1920
    height: 1080

    property int carId: ValueSource.carId

    Loader {
        id: layoutLoader
        source: "dash_hybrid/DashboardFrame.qml"
    }

    Timer {
        id: heartbeatTimer
        repeat: true
        interval: 500
        running: true
        onTriggered: {
            QSafeMessageSender.sendHeartBeat(1000)
        }
    }

    onCarIdChanged: {
        if (carId === 1) {
            layoutLoader.source = "dash_sports/DashboardFrame.qml"
            QSafeMessageSender.changeLayout("sport")
        }
        else if (carId === 2) {
            layoutLoader.source = "dash_hybrid/DashboardFrame.qml"
            QSafeMessageSender.changeLayout("hybrid")
        }
    }
}