qml: show when PIN is wrong
This commit is contained in:
@@ -39,6 +39,8 @@ ElDialog {
|
|||||||
property int _phase: mode == 'enter' ? 1 : 0 // 0 = existing pin, 1 = new pin, 2 = re-enter new pin
|
property int _phase: mode == 'enter' ? 1 : 0 // 0 = existing pin, 1 = new pin, 2 = re-enter new pin
|
||||||
property string _pin
|
property string _pin
|
||||||
|
|
||||||
|
property bool checkError: false
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
if (_phase == 0) {
|
if (_phase == 0) {
|
||||||
if (pin.text == pincode) {
|
if (pin.text == pincode) {
|
||||||
@@ -48,6 +50,9 @@ ElDialog {
|
|||||||
else
|
else
|
||||||
_phase = 1
|
_phase = 1
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
pin.text = ''
|
||||||
|
checkError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_phase == 1) {
|
if (_phase == 1) {
|
||||||
@@ -126,12 +131,20 @@ ElDialog {
|
|||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
focus: true
|
focus: true
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
checkError = false
|
||||||
if (text.length == 6) {
|
if (text.length == 6) {
|
||||||
submit()
|
submit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
opacity: checkError ? 1 : 0
|
||||||
|
text: qsTr('Wrong PIN')
|
||||||
|
color: constants.colorError
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
}
|
||||||
|
|
||||||
Item { Layout.fillHeight: true; Layout.preferredWidth: 1 }
|
Item { Layout.fillHeight: true; Layout.preferredWidth: 1 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user