linphone-desktop/tests/ui/modules/Common/Dialog/DialogPlus.qml
2016-12-28 14:23:52 +01:00

71 lines
1.7 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2
import Common.Styles 1.0
// =============================================================================
// Helper to build quickly dialogs.
// =============================================================================
Window {
property alias buttons: buttons.data // Optionnal.
property alias descriptionText: description.text // Optionnal.
property bool centeredButtons: false
default property alias _content: content.data // Required.
property bool _disableExitStatus
// ---------------------------------------------------------------------------
signal exitStatus (int status)
// ---------------------------------------------------------------------------
// Derived class must use this function instead of close.
// Destroy the component and send signal to caller.
function exit (status) {
if (!_disableExitStatus) {
_disableExitStatus = true
exitStatus(status)
close()
}
}
modality: Qt.WindowModal
// Handle normal windows close.
onClosing: !_disableExitStatus && exitStatus(0)
ColumnLayout {
anchors.fill: parent
spacing: 0
DialogDescription {
id: description
Layout.fillWidth: true
}
Item {
id: content
Layout.fillHeight: true
Layout.fillWidth: true
}
Row {
id: buttons
Layout.alignment: centeredButtons
? Qt.AlignHCenter
: Qt.AlignLeft
Layout.bottomMargin: DialogStyle.buttons.bottomMargin
Layout.leftMargin: !centeredButtons
? DialogStyle.leftMargin
: undefined
Layout.topMargin: DialogStyle.buttons.topMargin
spacing: DialogStyle.buttons.spacing
}
}
}