import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12

import Controls 1.0 as Controls
import Utils 1.0

Dialog {
    id: root
    width: 500
    height: 350
    modal: true
    closePolicy: Popup.CloseOnEscape
    bottomPadding: 0

    property string description: ""
    property bool good: true

    header: Controls.DialogHeader {
        dialog: root
    }

    contentItem: ColumnLayout {
        spacing: 20

        RowLayout {
            spacing: 20

            Image {
                source: good ? "qrc:/Icons/info.svg" : "qrc:/Icons/warning.svg"
                sourceSize.width: 52
                sourceSize.height: 48
            }

            Controls.SubtitleLabel {
                text: root.description
                maximumLineCount: 10
                wrapMode: Text.Wrap
                Layout.fillWidth: true
            }

            Layout.fillWidth: true
            Layout.fillHeight: true
        }

        RowLayout {
            Controls.Button {
                text: qsTr("Ok")
                Layout.alignment: Qt.AlignCenter
                Layout.preferredWidth: 100
                onClicked: root.close()
            }

            Layout.alignment: Qt.AlignCenter
            Layout.fillWidth: true
        }
    }

    background: Controls.DialogBackground {}

    onVisibleChanged: {
        x = Qt.binding(function() { return (parent.width - width) / 2})
        y = Qt.binding(function() { return (parent.height - height) / 2})
    }
}
