fix(Wallet): fix import seed in account creation
Remove the workaround, to the approach of using the complete last word event, for three letters seed-words. The three letters condition introduced another side effect when completing the "sentence" and made the _internal.mnemonicInput contain an extra duplicate word. Unify the event `doneInsertingWord` generation for the internal purpose with the external. This will trigger a secondary for some usage but I see no problem with even in other usages. Fix corner case when user enters a correct seed word that is not singular and uses the mouse to jump. In that case the doneInsertingWord is not triggered Fixes: #7715
This commit is contained in:
parent
8a45e34870
commit
057d0c565e
|
@ -98,8 +98,12 @@ Item {
|
||||||
*/
|
*/
|
||||||
signal editClicked()
|
signal editClicked()
|
||||||
|
|
||||||
function setWord(word) {
|
function setWord(seedWord) {
|
||||||
seedWordInput.input.edit.text = word
|
let seedWordTrimmed = seedWord.trim()
|
||||||
|
seedWordInput.input.edit.text = seedWordTrimmed
|
||||||
|
seedWordInput.input.edit.cursorPosition = seedWordInput.text.length
|
||||||
|
seedSuggestionsList.model = 0
|
||||||
|
root.doneInsertingWord(seedWordTrimmed)
|
||||||
}
|
}
|
||||||
|
|
||||||
onActiveFocusChanged: {
|
onActiveFocusChanged: {
|
||||||
|
@ -108,6 +112,12 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
|
||||||
|
property bool isInputValidWord: false
|
||||||
|
}
|
||||||
|
|
||||||
StatusInput {
|
StatusInput {
|
||||||
id: seedWordInput
|
id: seedWordInput
|
||||||
|
|
||||||
|
@ -121,12 +131,15 @@ Item {
|
||||||
}
|
}
|
||||||
input.acceptReturn: true
|
input.acceptReturn: true
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
d.isInputValidWord = false
|
||||||
filteredList.clear();
|
filteredList.clear();
|
||||||
let textToCheck = text.trim()
|
let textToCheck = text.trim()
|
||||||
if (textToCheck !== "") {
|
if (textToCheck !== "") {
|
||||||
for (var i = 0; i < inputList.count; i++) {
|
for (var i = 0; i < inputList.count; i++) {
|
||||||
if (inputList.get(i).seedWord.startsWith(textToCheck)) {
|
if (inputList.get(i).seedWord.startsWith(textToCheck)) {
|
||||||
filteredList.insert(filteredList.count, {"seedWord": inputList.get(i).seedWord});
|
filteredList.insert(filteredList.count, {"seedWord": inputList.get(i).seedWord});
|
||||||
|
if(inputList.get(i).seedWord === textToCheck)
|
||||||
|
d.isInputValidWord = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seedSuggestionsList.model = filteredList;
|
seedSuggestionsList.model = filteredList;
|
||||||
|
@ -144,7 +157,7 @@ Item {
|
||||||
onKeyPressed: {
|
onKeyPressed: {
|
||||||
if (input.edit.keyEvent === Qt.Key_Tab || input.edit.keyEvent === Qt.Key_Return || input.edit.keyEvent === Qt.Key_Enter) {
|
if (input.edit.keyEvent === Qt.Key_Tab || input.edit.keyEvent === Qt.Key_Return || input.edit.keyEvent === Qt.Key_Enter) {
|
||||||
if (!!text && seedSuggestionsList.count > 0) {
|
if (!!text && seedSuggestionsList.count > 0) {
|
||||||
seedSuggestionsList.completeWordFill(filteredList.get(seedSuggestionsList.currentIndex).seedWord)
|
root.setWord(filteredList.get(seedSuggestionsList.currentIndex).seedWord)
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -160,6 +173,17 @@ Item {
|
||||||
onEditClicked: {
|
onEditClicked: {
|
||||||
root.editClicked();
|
root.editClicked();
|
||||||
}
|
}
|
||||||
|
// Consider word inserted if input looses focus while a valid word is present ("user" clicks outside)
|
||||||
|
Connections {
|
||||||
|
target: seedWordInput.input.edit
|
||||||
|
onActiveFocusChanged: {
|
||||||
|
if (!seedWordInput.input.edit.activeFocus && d.isInputValidWord) {
|
||||||
|
// There are so many side effects regarding focus and doneInsertingWord that we need to reset this flag not to be processed again.
|
||||||
|
d.isInputValidWord = false
|
||||||
|
root.doneInsertingWord(root.text.trim())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
@ -201,14 +225,6 @@ Item {
|
||||||
seedSuggestionsList.currentIndex = 0
|
seedSuggestionsList.currentIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeWordFill(seedWord) {
|
|
||||||
let seedWordTrimmed = seedWord.trim();
|
|
||||||
root.setWord(seedWordTrimmed);
|
|
||||||
seedWordInput.input.edit.cursorPosition = seedWordInput.text.length;
|
|
||||||
seedSuggestionsList.model = 0;
|
|
||||||
root.doneInsertingWord(seedWordTrimmed);
|
|
||||||
}
|
|
||||||
|
|
||||||
clip: true
|
clip: true
|
||||||
ScrollBar.vertical: ScrollBar { }
|
ScrollBar.vertical: ScrollBar { }
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
|
@ -238,7 +254,7 @@ Item {
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
seedSuggestionsList.completeWordFill(seedWord)
|
root.setWord(seedWord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ StatusGridView {
|
||||||
grid.itemAtIndex(i).textEdit.reset()
|
grid.itemAtIndex(i).textEdit.reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
grid.isValid = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
function validate() {
|
||||||
|
@ -118,14 +119,9 @@ StatusGridView {
|
||||||
timer.setTimeout(function(){
|
timer.setTimeout(function(){
|
||||||
_internal.mnemonicInput = []
|
_internal.mnemonicInput = []
|
||||||
for (let i = 0; i < words.length; i++) {
|
for (let i = 0; i < words.length; i++) {
|
||||||
try {
|
const item = grid.itemAtIndex(i)
|
||||||
grid.itemAtIndex(i).setWord(words[i])
|
if (item && item.leftComponentText)
|
||||||
if (words[i].length === 3) {
|
item.setWord(words[i])
|
||||||
grid.addWord(i + 1, words[i])
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Getting items outside of the current view might not work
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
||||||
|
@ -220,7 +216,7 @@ StatusGridView {
|
||||||
var wordIndex = _internal.mnemonicInput.findIndex(x => x.pos === leftComponentText);
|
var wordIndex = _internal.mnemonicInput.findIndex(x => x.pos === leftComponentText);
|
||||||
if (wordIndex > -1) {
|
if (wordIndex > -1) {
|
||||||
_internal.mnemonicInput.splice(wordIndex , 1);
|
_internal.mnemonicInput.splice(wordIndex , 1);
|
||||||
grid.isValid = _internal.mnemonicInput.length === grid.model
|
grid.isValid = _internal.mnemonicInput.length === grid.model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue