Files
pallectrum/electrum/gui/qml/components/controls/ElDialog.qml

105 lines
2.8 KiB
QML
Raw Normal View History

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Controls.Material
Dialog {
id: abstractdialog
property bool allowClose: true
2022-09-30 14:37:14 +02:00
property string iconSource
property bool resizeWithKeyboard: true
property bool _result: false
// workaround: remember opened state, to inhibit closed -> closed event
property bool _wasOpened: false
// called to finally close dialog after checks by onClosing handler in main.qml
2022-11-16 12:12:43 +01:00
function doClose() {
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
}
parent: resizeWithKeyboard ? app.keyboardFreeZone : Overlay.overlay
modal: true
Overlay.modal: Rectangle {
color: "#aa000000"
}
closePolicy: allowClose
? Popup.CloseOnEscape | Popup.CloseOnPressOutside
: Popup.NoAutoClose
onOpenedChanged: {
if (opened) {
2022-09-26 13:55:54 +02:00
app.activeDialogs.push(abstractdialog)
_wasOpened = true
_result = false
} else {
if (!_wasOpened)
return
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-09-30 14:37:14 +02:00
header: ColumnLayout {
spacing: 0
2022-09-30 14:37:14 +02:00
RowLayout {
2022-09-30 14:37:14 +02:00
spacing: 0
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
}
Label {
text: title
wrapMode: Text.Wrap
elide: Label.ElideRight
2022-09-30 14:37:14 +02:00
Layout.fillWidth: true
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
}
}
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
}
}