GODT-1314: Limit description field length within 150/800 bounds

This commit is contained in:
Alexander Bilyak
2021-10-07 09:51:59 +00:00
committed by Jakub
parent c5699700b3
commit 9d0368de97
7 changed files with 58 additions and 17 deletions

View File

@ -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()
}
}

View File

@ -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 }

View File

@ -180,6 +180,4 @@ SettingsView {
Layout.fillWidth: true
}
onBack: root.parent.showAccount()
}

View File

@ -111,8 +111,4 @@ SettingsView {
onLinkActivated: Qt.openUrlExternally(link)
}
onBack: {
root.parent.showAccount()
}
}

View File

@ -114,7 +114,6 @@ SettingsView {
}
onBack: {
root.parent.showGeneralSettings()
root.setDefaultValues()
}

View File

@ -101,7 +101,6 @@ SettingsView {
}
onBack: {
root.parent.showGeneralSettings()
root.setDefaultValues()
}

View File

@ -101,7 +101,6 @@ SettingsView {
}
onBack: {
root.parent.showGeneralSettings()
root.setDefaultValues()
}