magpie/qml/Components/Modal.qml

66 lines
1.6 KiB
QML

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Controls
Popup {
property bool closable: true
property bool inProgress: false
property string status: ""
id: modal
anchors.centerIn: parent
modal: true
focus: true
width: column.width + 60
height: column.height + 60
closePolicy: closable ? Popup.CloseOnEscape : Popup.NoAutoClose
onClosed: inProgress = false
Column {
id: column
anchors.centerIn: parent
spacing: 10
Label {
text: status
width: 300
wrapMode: Label.WordWrap
horizontalAlignment: Label.AlignHCenter
}
BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
visible: inProgress
running: inProgress
}
Button {
text: qsTr("Close")
anchors.horizontalCenter: parent.horizontalCenter
visible: closable && !inProgress
onClicked: modal.close()
focus: true
Keys.onReturnPressed: {
if (closable && !inProgress)
modal.close()
}
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0.0
to: 1.0
duration: 200
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1.0
to: 0.0
duration: 200
}
}
}