/*!
 *
 * Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    WaitDone.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      30-Aug-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  12-Mar-2021
 *
 */

// Qt
import QtQuick 2.12

// Project
//  Qml imports
import "qrc:/globals"

/*!
 * \brief   Denali project busy indicator with done check mark
 */
Item { id: _root
    property int  diameter: 50
    property bool done    : false
    property bool fail    : false
    property bool pause   : false

    Image { id: _busyIndicator
        visible : true
        anchors.centerIn: _root
        width   : _root.diameter
        height  : _root.diameter
        opacity : ! _root.done ? 1 : 0
        source  : "qrc:/images/iBusy"

        RotationAnimator on rotation {
            running : ! _root.done && ! _root.pause
            from    : 0
            to      : 360
            loops   : Animation.Infinite
            duration: 7200
        }
        Behavior on opacity { OpacityAnimator { duration: 1200 } }
    }

    Image { id: _checkIndicator
        anchors.centerIn: _root
        opacity : _root.done ? 1 : 0
        width   : _root.diameter + 15
        height  : _root.diameter + 15
        source  : fail ? "qrc:/images/iBusyFail" : "qrc:/images/iBusyDone"
        Behavior on opacity { OpacityAnimator { duration: 1200 } }
    }
}
