wizard: improve restore from device ui/ux

This commit is contained in:
selsta 2019-03-01 08:20:05 +01:00
parent f7ac041b4e
commit fc68567f23
No known key found for this signature in database
GPG key ID: 2EA0A99A8B07AE5E
3 changed files with 46 additions and 2 deletions

View file

@ -60,6 +60,7 @@ Rectangle {
wizardController.walletOptionsIsRecovering = false; wizardController.walletOptionsIsRecovering = false;
wizardController.walletOptionsIsRecoveringFromDevice = false; wizardController.walletOptionsIsRecoveringFromDevice = false;
wizardController.walletOptionsDeviceName = ''; wizardController.walletOptionsDeviceName = '';
wizardController.walletOptionsDeviceIsRestore = false;
wizardController.tmpWalletFilename = ''; wizardController.tmpWalletFilename = '';
wizardController.walletRestoreMode = 'seed' wizardController.walletRestoreMode = 'seed'
wizardController.walletOptionsSubaddressLookahead = ''; wizardController.walletOptionsSubaddressLookahead = '';
@ -89,6 +90,7 @@ Rectangle {
property bool walletOptionsIsRecoveringFromDevice: false property bool walletOptionsIsRecoveringFromDevice: false
property string walletOptionsSubaddressLookahead: '' property string walletOptionsSubaddressLookahead: ''
property string walletOptionsDeviceName: '' property string walletOptionsDeviceName: ''
property bool walletOptionsDeviceIsRestore: false
property string tmpWalletFilename: '' property string tmpWalletFilename: ''
property var remoteNodes: '' property var remoteNodes: ''
@ -388,7 +390,10 @@ Rectangle {
wizardController.m_wallet = wallet; wizardController.m_wallet = wallet;
wizardController.walletOptionsIsRecoveringFromDevice = true; wizardController.walletOptionsIsRecoveringFromDevice = true;
wizardController.tmpWalletFilename = tmp_wallet_filename; wizardController.tmpWalletFilename = tmp_wallet_filename;
wizardController.walletOptionsRestoreHeight = wizardController.m_wallet.walletCreationHeight; if (!wizardController.walletOptionsDeviceIsRestore) {
// User creates a hardware wallet for the first time. Use a recent block height from API.
wizardController.walletOptionsRestoreHeight = wizardController.m_wallet.walletCreationHeight;
}
} else { } else {
console.log(wallet.errorString) console.log(wallet.errorString)
appWindow.showStatusMessage(qsTr(wallet.errorString), 5); appWindow.showStatusMessage(qsTr(wallet.errorString), 5);

View file

@ -79,6 +79,38 @@ Rectangle {
id: walletInput id: walletInput
} }
ColumnLayout {
spacing: 0
Layout.topMargin: 10 * scaleRatio
Layout.fillWidth: true
MoneroComponents.RadioButton {
id: newDeviceWallet
text: qsTr("Create a new wallet from device.") + translationManager.emptyString
fontSize: 16 * scaleRatio
checked: true
onClicked: {
checked = true;
restoreDeviceWallet.checked = false;
wizardController.walletOptionsDeviceIsRestore = false;
}
}
MoneroComponents.RadioButton {
id: restoreDeviceWallet
Layout.topMargin: 10 * scaleRatio
text: qsTr("Restore a wallet from device. Use this if you used your hardware wallet before.") + translationManager.emptyString
fontSize: 16 * scaleRatio
checked: false
onClicked: {
checked = true;
newDeviceWallet.checked = false;
wizardController.walletOptionsDeviceIsRestore = true;
}
}
}
GridLayout { GridLayout {
Layout.topMargin: 10 * scaleRatio Layout.topMargin: 10 * scaleRatio
Layout.fillWidth: true Layout.fillWidth: true
@ -88,6 +120,7 @@ Rectangle {
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: restoreHeight id: restoreHeight
visible: !newDeviceWallet.checked
Layout.fillWidth: true Layout.fillWidth: true
labelText: qsTr("Wallet creation date as `YYYY-MM-DD` or restore height") + translationManager.emptyString labelText: qsTr("Wallet creation date as `YYYY-MM-DD` or restore height") + translationManager.emptyString
labelFontSize: 14 * scaleRatio labelFontSize: 14 * scaleRatio

View file

@ -67,7 +67,13 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
header: qsTr("Restore height") + translationManager.emptyString header: qsTr("Restore height") + translationManager.emptyString
value: wizardController.walletOptionsRestoreHeight value: wizardController.walletOptionsRestoreHeight
visible: wizardController.walletOptionsRestoreHeight > 0 visible: {
if (walletOptionsIsRecoveringFromDevice && !wizardController.walletOptionsDeviceIsRestore) {
return false;
} else {
return (wizardController.walletOptionsRestoreHeight > 0);
}
}
} }
WizardSummaryItem { WizardSummaryItem {