fix(LoginView): Password field design inconsistencies

Closes #6519
This commit is contained in:
Alexandra Betouni 2022-07-26 17:17:53 +03:00 committed by Alexandra Betouni
parent 25c79230b6
commit a4127925df
2 changed files with 12 additions and 20 deletions

View File

@ -219,13 +219,16 @@ Item {
Input { Input {
id: txtPassword id: txtPassword
width: 318
height: 70
anchors.top: userInfo.bottom anchors.top: userInfo.bottom
anchors.topMargin: Style.current.padding * 2 anchors.topMargin: Style.current.padding * 2
anchors.left: undefined anchors.left: undefined
anchors.right: undefined anchors.right: undefined
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
width: 318
enabled: !loading enabled: !loading
validationErrorAlignment: Text.AlignHCenter
validationErrorTopMargin: 10
placeholderText: loading ? placeholderText: loading ?
qsTr("Connecting...") : qsTr("Connecting...") :
qsTr("Password") qsTr("Password")
@ -234,7 +237,7 @@ Item {
doLogin(textField.text) doLogin(textField.text)
} }
onTextEdited: { onTextEdited: {
errMsg.visible = false validationError = "";
loading = false loading = false
} }
} }
@ -246,9 +249,10 @@ Item {
type: StatusQControls.StatusRoundButton.Type.Secondary type: StatusQControls.StatusRoundButton.Type.Secondary
icon.name: "arrow-right" icon.name: "arrow-right"
opacity: (loading || txtPassword.text.length > 0) ? 1 : 0 opacity: (loading || txtPassword.text.length > 0) ? 1 : 0
anchors.top: userInfo.bottom
anchors.topMargin: 34
anchors.left: txtPassword.right anchors.left: txtPassword.right
anchors.leftMargin: (loading || txtPassword.text.length > 0) ? Style.current.padding : Style.current.smallPadding anchors.leftMargin: (loading || txtPassword.text.length > 0) ? Style.current.padding : Style.current.smallPadding
anchors.verticalCenter: txtPassword.verticalCenter
state: loading ? "pending" : "default" state: loading ? "pending" : "default"
onClicked: { onClicked: {
doLogin(txtPassword.textField.text) doLogin(txtPassword.textField.text)
@ -274,27 +278,14 @@ Item {
if (error) { if (error) {
// SQLITE_NOTADB: "file is not a database" // SQLITE_NOTADB: "file is not a database"
if (error === "file is not a database") { if (error === "file is not a database") {
errMsg.text = errMsg.incorrectPasswordMsg txtPassword.validationError = qsTr("Password incorrect")
} else { } else {
errMsg.text = qsTr("Login failed: %1").arg(error.toUpperCase()) txtPassword.validationError = qsTr("Login failed: %1").arg(error.toUpperCase())
} }
errMsg.visible = true
loading = false loading = false
txtPassword.textField.forceActiveFocus() txtPassword.textField.forceActiveFocus()
} }
} }
} }
StyledText {
id: errMsg
readonly property string incorrectPasswordMsg: qsTr("Password incorrect")
anchors.top: txtPassword.bottom
anchors.topMargin: Style.current.padding
anchors.horizontalCenter: parent.horizontalCenter
visible: false
text: incorrectPasswordMsg
font.pixelSize: 13
color: Style.current.danger
}
} }
} }

View File

@ -179,12 +179,13 @@ Item {
} }
StatusBaseText { StatusBaseText {
visible: !!validationError
id: validationErrorText id: validationErrorText
visible: !!validationError
text: validationError text: validationError
anchors.top: inputField.bottom anchors.top: inputField.bottom
anchors.topMargin: validationErrorTopMargin anchors.topMargin: validationErrorTopMargin
anchors.right: inputField.right width: parent.width
horizontalAlignment: Text.AlignRight
font.pixelSize: 12 font.pixelSize: 12
height: 16 height: 16
color: validationErrorColor color: validationErrorColor