Wizard: add qrcode scanner to recover page

This commit is contained in:
Jaquee 2017-08-06 17:29:43 +02:00
parent a3088b1eeb
commit b205acc51b
3 changed files with 52 additions and 2 deletions

View File

@ -132,6 +132,8 @@ ColumnLayout {
print ("show recovery wallet page"); print ("show recovery wallet page");
currentPath = "recovery_wallet" currentPath = "recovery_wallet"
pages = paths[currentPath] pages = paths[currentPath]
// Create temporary wallet
createWalletPage.createWallet(settings)
wizard.nextButton.visible = true wizard.nextButton.visible = true
// goto next page // goto next page
switchPage(true); switchPage(true);

View File

@ -86,6 +86,31 @@ ColumnLayout {
return wordsArray.length === 25 return wordsArray.length === 25
} }
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name, extra_parameters) {
// Switch to recover from keys
recoverFromSeedMode = false
spendKeyLine.text = ""
viewKeyLine.text = ""
restoreHeightItem.text = ""
if(typeof extra_parameters.secret_view_key != "undefined") {
viewKeyLine.text = extra_parameters.secret_view_key
}
if(typeof extra_parameters.secret_spend_key != "undefined") {
spendKeyLine.text = extra_parameters.secret_spend_key
}
if(typeof extra_parameters.restore_height != "undefined") {
restoreHeightItem.text = extra_parameters.restore_height
}
addressLine.text = address
cameraUi.qrcode_decoded.disconnect(updateFromQrCode)
// Check if keys are correct
checkNextButton();
}
RowLayout { RowLayout {
id: dotsRow id: dotsRow
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
@ -144,9 +169,10 @@ ColumnLayout {
} }
} }
RowLayout{ GridLayout{
columns: (isMobile)? 2 : 4
visible: recoverMode visible: recoverMode
spacing: 0
StandardButton { StandardButton {
id: recoverFromSeedButton id: recoverFromSeedButton
text: qsTr("Restore from seed") + translationManager.emptyString text: qsTr("Restore from seed") + translationManager.emptyString
@ -174,6 +200,22 @@ ColumnLayout {
checkNextButton(); checkNextButton();
} }
} }
StandardButton {
id: qrfinderButton
text: qsTr("From QR Code") + translationManager.emptyString
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
visible : true //appWindow.qrScannerEnabled
enabled : visible
onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(updateFromQrCode)
}
}
} }
// Recover from seed // Recover from seed

View File

@ -81,6 +81,12 @@ ColumnLayout {
var tmp_wallet_filename = oshelper.temporaryFilename() var tmp_wallet_filename = oshelper.temporaryFilename()
console.log("Creating temporary wallet", tmp_wallet_filename) console.log("Creating temporary wallet", tmp_wallet_filename)
// delete the temporary wallet object before creating new
if (typeof m_wallet !== 'undefined') {
walletManager.closeWallet()
console.log("deleting temporary wallet")
}
// From seed or keys // From seed or keys
if(fromSeed) if(fromSeed)
var wallet = walletManager.recoveryWallet(tmp_wallet_filename, settingsObject.words, testnet, restoreHeight) var wallet = walletManager.recoveryWallet(tmp_wallet_filename, settingsObject.words, testnet, restoreHeight)