2023-07-17 10:49:06 +02:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Controls.Material
|
2022-07-26 16:20:17 +02:00
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
|
id: abstractdialog
|
|
|
|
|
|
|
|
|
|
property bool allowClose: true
|
2022-09-30 14:37:14 +02:00
|
|
|
property string iconSource
|
2023-03-22 13:56:03 +01:00
|
|
|
property bool resizeWithKeyboard: true
|
2022-07-26 16:20:17 +02:00
|
|
|
|
2023-04-11 11:29:00 +02:00
|
|
|
property bool _result: false
|
2023-10-10 16:57:44 +02:00
|
|
|
// workaround: remember opened state, to inhibit closed -> closed event
|
|
|
|
|
property bool _wasOpened: false
|
2023-04-11 11:29:00 +02:00
|
|
|
|
|
|
|
|
// called to finally close dialog after checks by onClosing handler in main.qml
|
2022-11-16 12:12:43 +01:00
|
|
|
function doClose() {
|
2023-04-11 11:29:00 +02:00
|
|
|
doReject()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// avoid potential multiple signals, only emit once
|
|
|
|
|
function doAccept() {
|
|
|
|
|
if (_result)
|
|
|
|
|
return
|
|
|
|
|
_result = true
|
|
|
|
|
accept()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// avoid potential multiple signals, only emit once
|
|
|
|
|
function doReject() {
|
|
|
|
|
if (_result)
|
|
|
|
|
return
|
|
|
|
|
_result = true
|
|
|
|
|
reject()
|
2022-11-16 12:12:43 +01:00
|
|
|
}
|
|
|
|
|
|
2023-10-31 12:12:10 +01:00
|
|
|
parent: resizeWithKeyboard ? app.keyboardFreeZone : Overlay.overlay
|
2023-03-20 16:52:21 +01:00
|
|
|
modal: true
|
|
|
|
|
Overlay.modal: Rectangle {
|
|
|
|
|
color: "#aa000000"
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-23 20:44:25 +01:00
|
|
|
closePolicy: allowClose
|
2023-03-23 10:12:05 +01:00
|
|
|
? Popup.CloseOnEscape | Popup.CloseOnPressOutside
|
2023-02-23 20:44:25 +01:00
|
|
|
: Popup.NoAutoClose
|
|
|
|
|
|
2022-07-26 16:20:17 +02:00
|
|
|
onOpenedChanged: {
|
|
|
|
|
if (opened) {
|
2022-09-26 13:55:54 +02:00
|
|
|
app.activeDialogs.push(abstractdialog)
|
2023-10-10 16:57:44 +02:00
|
|
|
_wasOpened = true
|
2023-11-10 11:59:22 +01:00
|
|
|
_result = false
|
2022-07-26 16:20:17 +02:00
|
|
|
} else {
|
2023-10-10 16:57:44 +02:00
|
|
|
if (!_wasOpened)
|
|
|
|
|
return
|
2023-02-06 12:43:54 +01:00
|
|
|
if (app.activeDialogs.indexOf(abstractdialog) < 0) {
|
|
|
|
|
console.log('dialog should exist in activeDialogs!')
|
|
|
|
|
app.activeDialogs.pop()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
app.activeDialogs.splice(app.activeDialogs.indexOf(abstractdialog),1)
|
2022-07-26 16:20:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-30 14:37:14 +02:00
|
|
|
|
2023-03-15 15:39:35 +01:00
|
|
|
header: ColumnLayout {
|
|
|
|
|
spacing: 0
|
2022-09-30 14:37:14 +02:00
|
|
|
|
2023-03-15 15:39:35 +01:00
|
|
|
RowLayout {
|
2022-09-30 14:37:14 +02:00
|
|
|
spacing: 0
|
|
|
|
|
|
2023-03-15 15:39:35 +01:00
|
|
|
Image {
|
|
|
|
|
visible: iconSource
|
|
|
|
|
source: iconSource
|
|
|
|
|
Layout.preferredWidth: constants.iconSizeXLarge
|
|
|
|
|
Layout.preferredHeight: constants.iconSizeXLarge
|
|
|
|
|
Layout.leftMargin: constants.paddingMedium
|
|
|
|
|
Layout.topMargin: constants.paddingMedium
|
|
|
|
|
Layout.bottomMargin: constants.paddingMedium
|
2022-09-30 14:37:14 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-15 15:39:35 +01:00
|
|
|
Label {
|
|
|
|
|
text: title
|
2023-04-17 17:08:11 +02:00
|
|
|
wrapMode: Text.Wrap
|
2023-03-15 15:39:35 +01:00
|
|
|
elide: Label.ElideRight
|
2022-09-30 14:37:14 +02:00
|
|
|
Layout.fillWidth: true
|
2023-03-15 15:39:35 +01:00
|
|
|
leftPadding: constants.paddingXLarge
|
|
|
|
|
topPadding: constants.paddingXLarge
|
|
|
|
|
bottomPadding: constants.paddingXLarge
|
|
|
|
|
rightPadding: constants.paddingXLarge
|
|
|
|
|
font.bold: true
|
|
|
|
|
font.pixelSize: constants.fontSizeMedium
|
2022-09-30 14:37:14 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-03-15 15:39:35 +01:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.leftMargin: constants.paddingXXSmall
|
|
|
|
|
Layout.rightMargin: constants.paddingXXSmall
|
|
|
|
|
height: 1
|
|
|
|
|
color: Qt.rgba(0,0,0,0.5)
|
|
|
|
|
}
|
2022-09-30 14:37:14 +02:00
|
|
|
}
|
2023-03-15 15:39:35 +01:00
|
|
|
|
2022-07-26 16:20:17 +02:00
|
|
|
}
|