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: calendarContainer

    property string appointment: "No appointments"
    property var currentDate
    property string date
    property string time
    opacity: 0.5
    property alias xTarget: startupAnimation.to
    property int defaultXPos: 300

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

    Text {
        id: dateText
        anchors.top: image.bottom
        anchors.topMargin: 10
        anchors.horizontalCenter: image.horizontalCenter
        text: date
        color: "gray"
        font.pixelSize: 24
    }

    Text {
        id: timeText
        anchors.top: dateText.bottom
        anchors.horizontalCenter: image.horizontalCenter
        text: time
        color: "gray"
        font.pixelSize: 21
    }

    Text {
        anchors.top: timeText.bottom
        anchors.horizontalCenter: image.horizontalCenter
        text: appointment
        color: "lightGray"
        font.pixelSize: 21
    }

    Timer {
        id: fadeOutTimer
        interval: 5000
        running: false
        repeat: false
        onTriggered: {
            calendarContainer.opacity = 0.5
        }
    }

    Behavior on opacity { PropertyAnimation { duration: 500 } }

    PropertyAnimation on x {
        id: startupAnimation
        duration: 500
        easing.type: Easing.InCubic
        onStopped: {
            calendarContainer.opacity = 1.0
            fadeOutTimer.start()
        }
    }

    onVisibleChanged: {
        if (visible) {
            currentDate = new Date()
            date = currentDate.toLocaleDateString(Qt.locale("en_GB"))
            time = currentDate.toLocaleTimeString(Qt.locale("en_GB"), "hh:mm")
            x = defaultXPos
            startupAnimation.start()
        }
    }
}