summaryrefslogtreecommitdiff
path: root/src/webenginequick/ui/PromptDialog.qml
diff options
context:
space:
mode:
authorBalazs Egedi <egedib@inf.u-szeged.hu>2021-06-16 14:55:18 +0200
committerMichal Klocek <michal.klocek@qt.io>2021-07-06 13:05:49 +0000
commita060012ecef7ecc60f5518b6718136b22a10dc6b (patch)
treef8caddb6190f3a4bea0b8e1e161b9e0708333181 /src/webenginequick/ui/PromptDialog.qml
parentccb3fece7d9306bf2c02fcd80505d6a4c3822f35 (diff)
downloadqtwebengine-a060012ecef7ecc60f5518b6718136b22a10dc6b.tar.gz
Remove Quick Controls 1 UIDelegates and introduce UIDelegates test
- Renamed Controls2Delegates to ControlsDelegates - Removed option to use Quick Controls 1 delegates - Added test to check if controls are shown Task-number: QTBUG-93666 Change-Id: Iccca948615309285db7fc57d14fb1cdcdef28051 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu> (cherry picked from commit 4fe808a8c0ecd143199781e9644a46e4b1b90653) Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
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()
}
}
}
-
}