summaryrefslogtreecommitdiff
path: root/src/webenginequick/ui/PromptDialog.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginequick/ui/PromptDialog.qml')
-rw-r--r--src/webenginequick/ui/PromptDialog.qml70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/webenginequick/ui/PromptDialog.qml b/src/webenginequick/ui/PromptDialog.qml
index c4dcd6b98..81b9812ad 100644
--- a/src/webenginequick/ui/PromptDialog.qml
+++ b/src/webenginequick/ui/PromptDialog.qml
@@ -37,62 +37,78 @@
**
****************************************************************************/
-// FIXME: prompt missing in Qt Quick Dialogs atm. Make our own for now.
-import QtQuick.Controls 1.4
-import QtQuick.Layouts 1.0
-import QtQuick 2.5
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
-ApplicationWindow {
- signal input(string text)
- signal accepted
- signal rejected
+Dialog {
property alias text: message.text
property alias prompt: field.text
+ property bool handled: false
+ signal input(string text)
+ signal accepted()
+ signal rejected()
+ title: qsTr("Prompt Dialog")
+ modal: false
+ anchors.centerIn: parent
+ objectName: "promptDialog"
- width: 350
- height: 100
- flags: Qt.Dialog
+ //handle the case where users simply closes the dialog
+ onVisibleChanged: {
+ if (visible == false && handled == false) {
+ handled = true;
+ rejected();
+ } else {
+ handled = false;
+ }
+ }
- onClosing: {
- rejected();
+ function acceptDialog() {
+ input(field.text);
+ accepted();
+ handled = true;
+ close();
}
- function open() {
- show();
+ function rejectDialog() {
+ rejected();
+ handled = true;
+ close();
}
ColumnLayout {
+ id: rootLayout
anchors.fill: parent
anchors.margins: 4
+ property int minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins
+ property int minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins
+ property int doubleMargins: anchors.margins * 2
+ SystemPalette { id: palette; colorGroup: SystemPalette.Active }
Text {
id: message
Layout.fillWidth: true
+ color: palette.windowText
}
TextField {
id:field
+ focus: true
Layout.fillWidth: true
+ onAccepted: acceptDialog()
+ }
+ Item {
+ Layout.fillHeight: true
}
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: 8
Button {
text: qsTr("OK")
- onClicked: {
- input(field.text);
- accepted();
- close();
- destroy();
- }
+ onClicked: acceptDialog()
}
Button {
text: qsTr("Cancel")
- onClicked: {
- rejected();
- close();
- destroy();
- }
+ onClicked: rejectDialog()
}
}
}
-
}