/*!
 *
 * Copyright (c) 2022-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    USBProgressItem.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      27-Jun-2022
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  27-Jun-2022
 *
 */

// Qt
import QtQuick 2.12

// Project
//  C++ imports
//  Qml imports
import "qrc:/globals"
import "qrc:/components"

/*!
 * \brief   USBProgressItem is the component to provide user information about the USB Drive.
 * \detials This item includes the space left on the device in percent as well as the ProgressCircle for a graphical representation.
 *          The ProgressCircle turns red if the amount of free space left is less than defined (15% for now)
 *          The percent value in the circle will show "USB" if the device is not present/ready.
 */
Rectangle { id: _root
    readonly property alias total       : _progressCircle.maximum
    readonly property alias avail       : _progressCircle.value
    readonly property int percent       : 100 - _GuiView.usbPercent

    property bool           displayInformation    : true

    color           : Colors.transparent
    width           : 30
    height          : width
    radius          : width

    Text { id: _percent
        visible             : displayInformation
        anchors.centerIn    : parent
        text                : ! _GuiView.usbIsReady ? qsTr("USB") :
                                                      ("%1%\n%2")   .arg(_root.percent)
                                                                    .arg(qsTr("Used"))
        color               : Colors.offWhite
        font.pixelSize      : Fonts.fontPixelContainerUnitSmall
        horizontalAlignment : Text.AlignHCenter
        font.weight         : Font.Medium
    }

    ProgressCircle  { id: _progressCircle
        anchors.fill        : parent
        diameter            : _root.width
        minimum             : 0
        maximum             : 100
        value               : _root.percent
        color               : ! _GuiView.usbIsReady ? "red" : Colors.borderButton
        circleShadowColor   : Colors.panelBorderColor
        thickness           : 5
    }
}
