C

Qt Cluster: Rendering and Recovery from Main UI Failure

// Copyright (C) 2016 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR QTAS OR GPL-3.0-only

// This file is part of the Qt Safe Renderer module

import QtQuick

Item {
    id: contactContainer
    opacity: 0.5
    property int defaultYPos: 75
    property alias icon: contactImage.source
    property alias name: contactName.text
    property alias yTarget: startupAnimation.to

    Image {
        id: contactImage
        source: "image://etc/contacts.png"
    }

    Text {
        id: title
        anchors.top: contactImage.bottom
        anchors.topMargin: 10
        anchors.horizontalCenter: contactImage.horizontalCenter
        text: contactContainer.name === "" ? "Browsing\ncontacts" : "Calling"
        color: "gray"
        font.pixelSize: 30
    }

    Text {
        id: contactName
        anchors.top: title.bottom
        anchors.horizontalCenter: contactImage.horizontalCenter
        color: "lightGray"
        font.pixelSize: 36
    }

    Timer {
        id: fadeOutTimer
        interval: 5000
        running: false
        repeat: false
        onTriggered: {
            fadeOut.start()
        }
    }

    PropertyAnimation on opacity {
        id: fadeIn
        to: 1.0
        duration: 500
        onStopped: {
            call.start()
        }
    }

    PropertyAnimation on opacity {
        id: fadeOut
        to: 0.5
        duration: 500
    }

    PropertyAnimation on y {
        id: startupAnimation
        duration: 500
        easing.type: Easing.InCubic
        onStopped: {
            fadeIn.start()
            fadeOutTimer.start()
        }
    }

    Timer {
        id: call
        interval: 2000
        running: false
        onTriggered: {
            name = "Jane"
            icon = "image://etc/jane.png"
        }
    }

    onVisibleChanged: {
        if (visible) {
            name = ""
            icon = "image://etc/contacts.png"
            y = defaultYPos
            startupAnimation.start()
        }
    }
}