C

Qt Quick Ultralite Automotive Cluster Demo

// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial

import QtQuick 2.15
import Automotive 1.0

Item {
    id: root;
    opacity: 0;
    visible: opacity != 0

    property bool selected: false;

    Connections {
        target: NormalModeModel
        function onMenuChanged(menu: int) {
            selected = false
        }
    }

    Component.onCompleted: selected = true

    states: [
        State {
            name: "hidden";
            when: !selected;
        },
        State {
            name: "visible";
            when: selected;
            PropertyChanges { target: root; opacity: 1.; }
        }
    ]
    transitions: [
        Transition {
            from: "hidden"; to: "visible";
            SequentialAnimation {
                PropertyAnimation { duration: 250; property: "opacity"; }
            }
        },
        Transition {
            from: "visible"; to: "hidden";
            PropertyAnimation { duration: 250; property: "opacity"; }
        }
    ]
}