From 9d0368de978f2d9e1b65fc4d61acb4c425e469fe Mon Sep 17 00:00:00 2001 From: Alexander Bilyak Date: Thu, 7 Oct 2021 09:51:59 +0000 Subject: [PATCH] GODT-1314: Limit description field length within 150/800 bounds --- internal/frontend/qml/BugReportView.qml | 42 ++++++++++++++++---- internal/frontend/qml/ContentWrapper.qml | 24 +++++++++++ internal/frontend/qml/GeneralSettings.qml | 2 - internal/frontend/qml/HelpView.qml | 4 -- internal/frontend/qml/LocalCacheSettings.qml | 1 - internal/frontend/qml/PortSettings.qml | 1 - internal/frontend/qml/SMTPSettings.qml | 1 - 7 files changed, 58 insertions(+), 17 deletions(-) diff --git a/internal/frontend/qml/BugReportView.qml b/internal/frontend/qml/BugReportView.qml index 30868de0..e1f4a9c2 100644 --- a/internal/frontend/qml/BugReportView.qml +++ b/internal/frontend/qml/BugReportView.qml @@ -35,24 +35,34 @@ SettingsView { TextArea { id: description - property int _minChars: 150 - property bool _inputOK: description.text.length>=description._minChars + property int _minLength: 150 + property int _maxLength: 800 + property bool _inputOK: description.text.length>=description._minLength && description.text.length<=description._maxLength label: qsTr("Description") colorScheme: root.colorScheme Layout.fillWidth: true Layout.minimumHeight: 100 - hint: description.text.length + "/800" - placeholderText: qsTr("Tell us what went wrong or isn't working (min. 150 characters).") + hint: description.text.length + "/" + _maxLength + placeholderText: qsTr("Tell us what went wrong or isn't working (min. %1 characters).").arg(_minLength) + onEditingFinished: { if (!description._inputOK) { description.error = true - description.assistiveText = qsTr("Enter a problem description (min. 150 characters)") + if (description.text.length <= description._minLength) { + description.assistiveText = qsTr("Enter a problem description (min. %1 characters).").arg(_minLength) + } else { + description.assistiveText = qsTr("Enter a problem description (max. %1 characters).").arg(_maxLength) + } } else { description.error = false description.assistiveText = "" } } + onTextChanged: { + description.error = false + description.assistiveText = "" + } } @@ -74,6 +84,10 @@ SettingsView { address.error = false } } + onTextChanged: { + address.error = false + address.assistiveText = "" + } } TextField { @@ -84,6 +98,7 @@ SettingsView { colorScheme: root.colorScheme Layout.fillWidth: true placeholderText: qsTr("e.g. Apple Mail 14.0") + onEditingFinished: { if (!emailClient._inputOK) { emailClient.assistiveText = qsTr("Enter an email client name and version") @@ -93,6 +108,10 @@ SettingsView { emailClient.error = false } } + onTextChanged: { + emailClient.error = false + emailClient.assistiveText = "" + } } @@ -137,8 +156,17 @@ SettingsView { function setDefaultValue() { description.text = "" + description.error = false + description.assistiveText = "" + address.text = root.selectedAddress + address.error = false + address.assistiveText = "" + emailClient.text = root.backend.currentEmailClient + emailClient.error = false + emailClient.assistiveText = "" + includeLogs.checked = true } @@ -159,9 +187,7 @@ SettingsView { Component.onCompleted: root.setDefaultValue() - - onBack: { + onVisibleChanged: { root.setDefaultValue() - root.parent.showHelpView() } } diff --git a/internal/frontend/qml/ContentWrapper.qml b/internal/frontend/qml/ContentWrapper.qml index 3df055a9..58af1972 100644 --- a/internal/frontend/qml/ContentWrapper.qml +++ b/internal/frontend/qml/ContentWrapper.qml @@ -284,27 +284,47 @@ Item { colorScheme: root.colorScheme backend: root.backend notifications: root.notifications + + onBack: { + rightContent.showAccount() + } } PortSettings { // 3 colorScheme: root.colorScheme backend: root.backend + + onBack: { + rightContent.showGeneralSettings() + } } SMTPSettings { // 4 colorScheme: root.colorScheme backend: root.backend + + onBack: { + rightContent.showGeneralSettings() + } } LocalCacheSettings { // 5 colorScheme: root.colorScheme backend: root.backend notifications: root.notifications + + onBack: { + rightContent.showGeneralSettings() + } } HelpView { // 6 colorScheme: root.colorScheme backend: root.backend + + onBack: { + rightContent.showAccount() + } } BugReportView { // 7 @@ -317,6 +337,10 @@ Item { if (!user) return "" return user.addresses[0] } + + onBack: { + rightContent.showHelpView() + } } function showAccount () { rightContent.currentIndex = 0 } diff --git a/internal/frontend/qml/GeneralSettings.qml b/internal/frontend/qml/GeneralSettings.qml index 2076839c..202f4bc9 100644 --- a/internal/frontend/qml/GeneralSettings.qml +++ b/internal/frontend/qml/GeneralSettings.qml @@ -180,6 +180,4 @@ SettingsView { Layout.fillWidth: true } - - onBack: root.parent.showAccount() } diff --git a/internal/frontend/qml/HelpView.qml b/internal/frontend/qml/HelpView.qml index bd8310ef..a8de1d52 100644 --- a/internal/frontend/qml/HelpView.qml +++ b/internal/frontend/qml/HelpView.qml @@ -111,8 +111,4 @@ SettingsView { onLinkActivated: Qt.openUrlExternally(link) } - - onBack: { - root.parent.showAccount() - } } diff --git a/internal/frontend/qml/LocalCacheSettings.qml b/internal/frontend/qml/LocalCacheSettings.qml index 25c5a1ca..5701cc25 100644 --- a/internal/frontend/qml/LocalCacheSettings.qml +++ b/internal/frontend/qml/LocalCacheSettings.qml @@ -114,7 +114,6 @@ SettingsView { } onBack: { - root.parent.showGeneralSettings() root.setDefaultValues() } diff --git a/internal/frontend/qml/PortSettings.qml b/internal/frontend/qml/PortSettings.qml index cfde2e49..bd2ebc10 100644 --- a/internal/frontend/qml/PortSettings.qml +++ b/internal/frontend/qml/PortSettings.qml @@ -101,7 +101,6 @@ SettingsView { } onBack: { - root.parent.showGeneralSettings() root.setDefaultValues() } diff --git a/internal/frontend/qml/SMTPSettings.qml b/internal/frontend/qml/SMTPSettings.qml index d03642e9..caddb67e 100644 --- a/internal/frontend/qml/SMTPSettings.qml +++ b/internal/frontend/qml/SMTPSettings.qml @@ -101,7 +101,6 @@ SettingsView { } onBack: { - root.parent.showGeneralSettings() root.setDefaultValues() }