diff options
author | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-11-06 16:49:37 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2015-11-09 11:13:37 +0000 |
commit | ca2098638a51f5541cce3f9d8a23c0c6fe76eaa7 (patch) | |
tree | 9c18795c112e2ab802ff2f2e8776f0a577e57ca6 /src/webengine/ui | |
parent | 8b37025cde3848fbd8acabe9ff50fbd68a196416 (diff) |
rework QML authentication dialog
Improve AuthenticationDialog.qml in the following ways:
- Make all user-visible strings translatable.
- Make the dialog a Window instead of an ApplicationWindow, because
we don't need status bar or tool bar support.
- Do not mix layouts and anchors.
- Do not hard-code the dialog's size.
- Longer strings in the message label are now actually visible.
- Pressing enter in input fields accepts the dialog.
- Remove calls to destroy() that would not destroy the dialog but the
Button items.
Task-number: QTBUG-49244
Change-Id: I490d30aeea740d436e060aa2b5f5bf288603b8f2
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/webengine/ui')
-rw-r--r-- | src/webengine/ui/AuthenticationDialog.qml | 77 |
1 files changed, 47 insertions, 30 deletions
diff --git a/src/webengine/ui/AuthenticationDialog.qml b/src/webengine/ui/AuthenticationDialog.qml index 46e2e3151..441235980 100644 --- a/src/webengine/ui/AuthenticationDialog.qml +++ b/src/webengine/ui/AuthenticationDialog.qml @@ -35,71 +35,88 @@ ****************************************************************************/ // FIXME: authentication missing in Qt Quick Dialogs atm. Make our own for now. +import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.0 -import QtQuick 2.5 +import QtQuick.Window 2.2 -ApplicationWindow { +Window { signal accepted(string user, string password); signal rejected; - property alias text: message.text; + property alias text: message.text - width: 350 - height: 100 + title: qsTr("Authentication Required") flags: Qt.Dialog + modality: Qt.WindowModal - title: "Authentication Required" + width: minimumWidth + height: minimumHeight + minimumWidth: rootLayout.implicitWidth + rootLayout.doubleMargins + minimumHeight: rootLayout.implicitHeight + rootLayout.doubleMargins + + SystemPalette { id: palette; colorGroup: SystemPalette.Active } + color: palette.window function open() { show(); } + function acceptDialog() { + accepted(userField.text, passwordField.text); + close(); + } + ColumnLayout { - anchors.fill: parent; - anchors.margins: 4; + id: rootLayout + anchors.fill: parent + anchors.margins: 4 + property int doubleMargins: anchors.margins * 2 Text { id: message; - Layout.fillWidth: true; + color: palette.windowText } - RowLayout { + GridLayout { + columns: 2 Label { - text: "Username:" + text: qsTr("Username:") + color: palette.windowText } TextField { - id: userField; - Layout.fillWidth: true; + id: userField + focus: true + Layout.fillWidth: true + onAccepted: acceptDialog() } - } - RowLayout { Label { - text: "Password:" + text: qsTr("Password:") + color: palette.windowText } TextField { - id: passwordField; - Layout.fillWidth: true; - echoMode: TextInput.Password; + id: passwordField + Layout.fillWidth: true + echoMode: TextInput.Password + onAccepted: acceptDialog() } } + Item { + Layout.fillHeight: true + } RowLayout { Layout.alignment: Qt.AlignRight - spacing: 8; + spacing: 8 Button { - text: "Log In" + id: cancelButton + text: qsTr("&Cancel") onClicked: { - accepted(userField.text, passwordField.text); + rejected(); close(); - destroy(); } } Button { - text: "Cancel" - onClicked: { - rejected(); - close(); - destroy(); - } + text: qsTr("&Log In") + isDefault: true + onClicked: acceptDialog() } } } - } |