feat: add Input to Login screen and enable otherProps for the Input

This commit is contained in:
Jonathan Rainville 2020-05-29 15:54:06 -04:00 committed by Iuri Matias
parent c29160fff7
commit 545bb751c1
2 changed files with 17 additions and 18 deletions

View File

@ -128,24 +128,22 @@ SwipeView {
anchors.horizontalCenter: parent.horizontalCenter
}
Rectangle {
color: "#EEEEEE"
Input {
id: txtPassword
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: Theme.padding
anchors.leftMargin: Theme.padding
anchors.left: parent.left
anchors.right: parent.right
anchors.centerIn: parent
height: 32
width: parent.width - 40
TextInput {
id: txtPassword
anchors.fill: parent
focus: true
echoMode: TextInput.Password
selectByMouse: true
otherProps: {
this.textField.focus = true
this.textField.focus
this.textField.echoMode = TextInput.Password
}
Keys.onReturnPressed: {
submitBtn.clicked()
}
}
}
MessageDialog {
id: loginError
@ -154,8 +152,8 @@ SwipeView {
icon: StandardIcon.Critical
standardButtons: StandardButton.Ok
onAccepted: {
txtPassword.clear()
txtPassword.focus = true
txtPassword.textField.clear()
txtPassword.textField.focus = true
}
}
@ -177,7 +175,7 @@ SwipeView {
anchors.bottomMargin: 20
onClicked: {
const selectedAccountIndex = wizardStep1.selectedIndex
const response = loginModel.login(selectedAccountIndex, txtPassword.text)
const response = loginModel.login(selectedAccountIndex, txtPassword.textField.text)
// TODO: replace me with something graphical (ie spinner)
console.log("Logging in...")
}

View File

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.3
import "../imports"
Item {
property alias textField: inputValue
property string placeholderText: "My placeholder"
property string text: ""
property string label: ""
@ -11,12 +12,12 @@ Item {
// property url icon: "../app/img/hash.svg"
property url icon: ""
readonly property bool hasIcon: icon.toString() !== ""
readonly property bool hasLabel: label !== ""
readonly property var forceActiveFocus: function () {
inputValue.forceActiveFocus(Qt.MouseFocusReason)
}
readonly property int labelMargin: 7
property var otherProps // Only used to assign stuff to textField
id: inputBox
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)