From d96304dc33526b4ca910dbe3a7a9abcccfc940b0 Mon Sep 17 00:00:00 2001 From: miruka Date: Tue, 17 Mar 2020 13:40:58 -0400 Subject: [PATCH] Have labels for text fields --- src/gui/Dialogs/ExportKeys.qml | 2 +- src/gui/Dialogs/ImportKeys.qml | 4 +-- src/gui/Pages/AddAccount/SignIn.qml | 38 ++++++++++---------- src/gui/Pages/AddChat/CreateRoom.qml | 25 ++++++------- src/gui/Pages/AddChat/DirectChat.qml | 17 ++++----- src/gui/Pages/AddChat/JoinRoom.qml | 17 ++++----- src/gui/Pages/Chat/RoomPane/SettingsView.qml | 30 ++++++++-------- src/gui/Popups/PasswordPopup.qml | 1 - 8 files changed, 69 insertions(+), 65 deletions(-) diff --git a/src/gui/Dialogs/ExportKeys.qml b/src/gui/Dialogs/ExportKeys.qml index cfe0d067..8a6bac35 100644 --- a/src/gui/Dialogs/ExportKeys.qml +++ b/src/gui/Dialogs/ExportKeys.qml @@ -37,7 +37,7 @@ HFileDialogOpener { PasswordPopup { id: exportPasswordPopup - details.text: qsTr("Please enter a passphrase to protect this file:") + details.text: qsTr("Passphrase to protect this file:") okText: qsTr("Export") onAcceptedPasswordChanged: exportKeys(file, acceptedPassword) diff --git a/src/gui/Dialogs/ImportKeys.qml b/src/gui/Dialogs/ImportKeys.qml index 5f1da97b..5b2fa52c 100644 --- a/src/gui/Dialogs/ImportKeys.qml +++ b/src/gui/Dialogs/ImportKeys.qml @@ -19,9 +19,7 @@ HFileDialogOpener { PasswordPopup { id: importPasswordPopup - details.text: qsTr( - "Please enter the passphrase that was used to protect this file:" - ) + details.text: qsTr("Passphrase used to protect this file:") okText: qsTr("Import") diff --git a/src/gui/Pages/AddAccount/SignIn.qml b/src/gui/Pages/AddAccount/SignIn.qml index 973784e3..5044b5bf 100644 --- a/src/gui/Pages/AddAccount/SignIn.qml +++ b/src/gui/Pages/AddAccount/SignIn.qml @@ -8,7 +8,7 @@ HBox { id: signInBox clickButtonOnEnter: "apply" - onFocusChanged: idField.forceActiveFocus() + onFocusChanged: idField.field.forceActiveFocus() buttonModel: [ { @@ -31,8 +31,8 @@ HBox { errorMessage.text = "" const args = [ - idField.text.trim(), passwordField.text, - undefined, serverField.text.trim(), + idField.field.text.trim(), passwordField.field.text, + undefined, serverField.field.text.trim(), ] loginFuture = py.callCoro("login_client", args, userId => { @@ -82,8 +82,8 @@ HBox { property string signInWith: "username" readonly property bool canSignIn: - serverField.text.trim() && idField.text.trim() && passwordField.text && - ! serverField.error + serverField.field.text.trim() && idField.field.text.trim() && + passwordField.field.text && ! serverField.field.error Timer { @@ -124,35 +124,35 @@ HBox { } } - HTextField { + HLabeledTextField { id: idField - placeholderText: qsTr( - signInWith === "email" ? "Email" : - signInWith === "phone" ? "Phone" : - "Username" + label.text: qsTr( + signInWith === "email" ? "Email:" : + signInWith === "phone" ? "Phone:" : + "Username:" ) Layout.fillWidth: true } - HTextField { + HLabeledTextField { id: passwordField - placeholderText: qsTr("Password") - echoMode: HTextField.Password + label.text: qsTr("Password:") + field.echoMode: HTextField.Password Layout.fillWidth: true } - HTextField { + HLabeledTextField { id: serverField - placeholderText: qsTr("Homeserver URL") - text: "https://matrix.org" - error: ! /.+:\/\/.+/.test(cleanText) + label.text: qsTr("Homeserver:") + field.text: "https://matrix.org" + field.error: ! /.+:\/\/.+/.test(cleanText) Layout.fillWidth: true - readonly property string cleanText: text.toLowerCase().trim() + readonly property string cleanText: field.text.toLowerCase().trim() // 2019-11-11 https://www.hello-matrix.net/public_servers.php readonly property var knownServers: [ @@ -186,6 +186,8 @@ HBox { ) Layout.fillWidth: true + Layout.topMargin: theme.spacing / 2 + Layout.bottomMargin: Layout.topMargin } HLabel { diff --git a/src/gui/Pages/AddChat/CreateRoom.qml b/src/gui/Pages/AddChat/CreateRoom.qml index 9595010a..2b9d1a86 100644 --- a/src/gui/Pages/AddChat/CreateRoom.qml +++ b/src/gui/Pages/AddChat/CreateRoom.qml @@ -8,7 +8,7 @@ HBox { id: addChatBox clickButtonOnEnter: "apply" - onFocusChanged: nameField.forceActiveFocus() + onFocusChanged: nameField.field.forceActiveFocus() buttonModel: [ { name: "apply", text: qsTr("Create"), iconName: "room-create" }, @@ -21,8 +21,8 @@ HBox { errorMessage.text = "" const args = [ - nameField.text, - topicField.text, + nameField.field.text, + topicField.field.text, publicCheckBox.checked, encryptCheckBox.checked, ! blockOtherServersCheckBox.checked, @@ -40,8 +40,8 @@ HBox { }, cancel: button => { - nameField.text = "" - topicField.text = "" + nameField.field.text = "" + topicField.field.text = "" publicCheckBox.checked = false encryptCheckBox.checked = false blockOtherServersCheckBox.checked = false @@ -57,7 +57,7 @@ HBox { HRoomAvatar { id: avatar roomId: "" - displayName: nameField.text + displayName: nameField.field.text Layout.alignment: Qt.AlignCenter Layout.preferredWidth: 128 @@ -66,24 +66,25 @@ HBox { CurrentUserAvatar { anchors.fill: parent z: 10 - opacity: nameField.text ? 0 : 1 + opacity: nameField.field.text ? 0 : 1 visible: opacity > 0 Behavior on opacity { HNumberAnimation {} } } } - HTextField { + HLabeledTextField { id: nameField - placeholderText: qsTr("Name") - maximumLength: 255 + label.text: qsTr("Name:") + field.maximumLength: 255 Layout.fillWidth: true } - HTextField { + HLabeledTextField { id: topicField - placeholderText: qsTr("Topic (optional)") + label.text: qsTr("Topic:") + field.placeholderText: qsTr("This room is about...") Layout.fillWidth: true } diff --git a/src/gui/Pages/AddChat/DirectChat.qml b/src/gui/Pages/AddChat/DirectChat.qml index a196c249..11ee2e1d 100644 --- a/src/gui/Pages/AddChat/DirectChat.qml +++ b/src/gui/Pages/AddChat/DirectChat.qml @@ -8,14 +8,14 @@ HBox { id: addChatBox clickButtonOnEnter: "apply" - onFocusChanged: userField.forceActiveFocus() + onFocusChanged: userField.field.forceActiveFocus() buttonModel: [ { name: "apply", text: qsTr("Start chat"), iconName: "start-direct-chat", - enabled: Boolean(userField.text.trim()) + enabled: Boolean(userField.field.text.trim()) }, { name: "cancel", text: qsTr("Cancel"), iconName: "cancel" }, ] @@ -25,7 +25,7 @@ HBox { button.loading = true errorMessage.text = "" - const args = [userField.text.trim(), encryptCheckBox.checked] + const args = [userField.field.text.trim(), encryptCheckBox.checked] py.callClientCoro(userId, "new_direct_chat", args, roomId => { button.loading = false @@ -52,8 +52,8 @@ HBox { }, cancel: button => { - userField.text = "" - errorMessage.text = "" + userField.field.text = "" + errorMessage.text = "" pageLoader.showPrevious() } }) @@ -68,10 +68,11 @@ HBox { Layout.preferredHeight: Layout.preferredWidth } - HTextField { + HLabeledTextField { id: userField - placeholderText: qsTr("Peer user ID (e.g. @bob:matrix.org)") - error: Boolean(errorMessage.text) + label.text: qsTr("Peer user ID:") + field.placeholderText: qsTr("@example:matrix.org") + field.error: Boolean(errorMessage.text) Layout.fillWidth: true } diff --git a/src/gui/Pages/AddChat/JoinRoom.qml b/src/gui/Pages/AddChat/JoinRoom.qml index 1f6e873b..b6d5bab6 100644 --- a/src/gui/Pages/AddChat/JoinRoom.qml +++ b/src/gui/Pages/AddChat/JoinRoom.qml @@ -8,14 +8,14 @@ HBox { id: addChatBox clickButtonOnEnter: "apply" - onFocusChanged: roomField.forceActiveFocus() + onFocusChanged: roomField.field.forceActiveFocus() buttonModel: [ { name: "apply", text: qsTr("Join"), iconName: "room-join", - enabled: Boolean(roomField.text.trim()), + enabled: Boolean(roomField.field.text.trim()), }, { name: "cancel", text: qsTr("Cancel"), iconName: "cancel" }, ] @@ -25,7 +25,7 @@ HBox { button.loading = true errorMessage.text = "" - const args = [roomField.text.trim()] + const args = [roomField.field.text.trim()] py.callClientCoro(userId, "room_join", args, roomId => { button.loading = false @@ -51,8 +51,8 @@ HBox { }, cancel: button => { - roomField.text = "" - errorMessage.text = "" + roomField.field.text = "" + errorMessage.text = "" pageLoader.showPrevious() } }) @@ -67,10 +67,11 @@ HBox { Layout.preferredHeight: Layout.preferredWidth } - HTextField { + HLabeledTextField { id: roomField - placeholderText: qsTr("Alias (e.g. #example:matrix.org), URL or ID") - error: Boolean(errorMessage.text) + label.text: qsTr("Alias, URL or room ID:") + field.placeholderText: qsTr("#example:matrix.org") + field.error: Boolean(errorMessage.text) Layout.fillWidth: true } diff --git a/src/gui/Pages/Chat/RoomPane/SettingsView.qml b/src/gui/Pages/Chat/RoomPane/SettingsView.qml index a2a4758e..9b755415 100644 --- a/src/gui/Pages/Chat/RoomPane/SettingsView.qml +++ b/src/gui/Pages/Chat/RoomPane/SettingsView.qml @@ -5,7 +5,7 @@ import QtQuick.Layouts 1.12 import "../../../Base" HBox { - color: theme.chat.roomPane.roomSettings.background + color: theme.chat.roomPane.roomSettings.background buttonModel: [ { @@ -37,8 +37,8 @@ HBox { saveFuture = null } - nameField.reset() - topicField.reset() + nameField.field.reset() + topicField.field.reset() encryptCheckBox.reset() requireInviteCheckbox.reset() forbidGuestsCheckBox.reset() @@ -49,8 +49,9 @@ HBox { property var saveFuture: null readonly property bool anyChange: - nameField.changed || topicField.changed || encryptCheckBox.changed || - requireInviteCheckbox.changed || forbidGuestsCheckBox.changed + nameField.field.changed || topicField.field.changed || + encryptCheckBox.changed || requireInviteCheckbox.changed || + forbidGuestsCheckBox.changed HRoomAvatar { @@ -65,21 +66,22 @@ HBox { Layout.maximumWidth: 256 * theme.uiScale } - HTextField { + HLabeledTextField { id: nameField - placeholderText: qsTr("Room name") - maximumLength: 255 - defaultText: chat.roomInfo.given_name - enabled: chat.roomInfo.can_set_name + label.text: qsTr("Name:") + field.maximumLength: 255 + field.defaultText: chat.roomInfo.given_name + field.enabled: chat.roomInfo.can_set_name Layout.fillWidth: true } - HScrollableTextArea { + HLabeledTextField { id: topicField - placeholderText: qsTr("Room topic") - defaultText: chat.roomInfo.plain_topic - enabled: chat.roomInfo.can_set_topic + label.text: qsTr("Topic:") + field.placeholderText: qsTr("This room is about...") + field.defaultText: chat.roomInfo.plain_topic + field.enabled: chat.roomInfo.can_set_topic Layout.fillWidth: true } diff --git a/src/gui/Popups/PasswordPopup.qml b/src/gui/Popups/PasswordPopup.qml index eb6ba818..e834cdd5 100644 --- a/src/gui/Popups/PasswordPopup.qml +++ b/src/gui/Popups/PasswordPopup.qml @@ -65,7 +65,6 @@ BoxPopup { HTextField { id: passwordField - placeholderText: qsTr("Passphrase") echoMode: TextInput.Password focus: true error: passwordValid === false