/*!
 *
 * Copyright (c) 2020-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    NotificationBar.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      29-Jul-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  30-Mar-2020
 *
 */

// Qt
import QtQuick 2.12

// Project
import Gui.Actions 0.1
//  Qml imports
import "qrc:/globals"

Rectangle { id: _root
    objectName: "NotificationBar" // SquishQt
    property int   alarmID          : -1
    property alias text             : _text.text
    property alias textPixelSize    : _text.font.pixelSize
    property alias textColor        : _text.color
    property alias isSilenced       : _headerButtonGroup.isSilenced
    property alias timeout          : _headerButtonGroup.timeout
    property bool  iconVisible      : true

    clip    : true // the mute button expands so we need to clip the outside unwanted area.
    visible : _text.text
    height  : Variables.notificationHeight
    color   : Colors.textNotificationNoneBg

    gradient: Gradient {
        orientation: Gradient.Horizontal
        GradientStop { position: 0.0; color: Qt.darker  (_root.color, 1.1) }
        GradientStop { position: 0.5; color: Qt.lighter (_root.color, 1.1) }
        GradientStop { position: 0.9; color: Qt.darker  (_root.color, 1.1) }
    }

    anchors {
        bottom  : parent.bottom
        left    : parent.left
        right   : parent.right
    }

    signal clicked()
    signal muteClicked()
    signal listClicked()
    signal maximizeClicked()

    MouseArea { id: _minimizeArea
        anchors.fill    : parent
        onClicked : { _root.maximizeClicked() }
    }

    Text { id: _text
        color               : Colors.textNotificationNoneFg
        anchors.centerIn    : parent
        font.pixelSize      : Fonts.fontPixelNotification
        font.weight         : Font.DemiBold
        horizontalAlignment : Text.AlignHCenter
        verticalAlignment   : Text.AlignVCenter
    }

    AlarmButtonRow { id: _headerButtonGroup
        anchors {
            verticalCenter  : _root.verticalCenter
            right           : _root.right
            rightMargin     : Variables.defaultMargin * 2
        }

        isMaxButton         : true
        backgroundColor     : _root.color
        onMuteClicked       :  _root.muteClicked()
        onMinMaxClicked     : _root.maximizeClicked()
        onListClicked       : _root.listClicked()
    }

    Text { id: _alarmID
        text            :  ("[%1:%2]")  .arg(qsTr("ID"))
                                        .arg(_root.alarmID)
        anchors {
            left            : parent.left
            leftMargin      : Variables.defaultMargin * 2
            verticalCenter  : parent.verticalCenter

        }
        color           : Colors.textMain
        font.pixelSize  : Fonts.fontPixelAlarmID
    }
}
