diff options
| author | mmbyday <mmbyday@protonmail.com> | 2018-12-14 17:28:07 -0800 |
|---|---|---|
| committer | dsc <xmrdsc@protonmail.com> | 2019-02-22 03:05:29 +0100 |
| commit | c6107d8376244560068184cbfafd38d3b2f536b8 (patch) | |
| tree | d7ba6e21f470a56d88fbe9be9ed8a7d068910c59 /wizard/WizardRestoreWallet1.qml | |
| parent | f329a710295deed3c15f2acff9a519c0a70e98e1 (diff) | |
| download | monzero-gui-c6107d8376244560068184cbfafd38d3b2f536b8.tar.gz monzero-gui-c6107d8376244560068184cbfafd38d3b2f536b8.tar.xz monzero-gui-c6107d8376244560068184cbfafd38d3b2f536b8.zip | |
wizard: allow calendar date for restoration height
Diffstat (limited to 'wizard/WizardRestoreWallet1.qml')
| -rw-r--r-- | wizard/WizardRestoreWallet1.qml | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/wizard/WizardRestoreWallet1.qml b/wizard/WizardRestoreWallet1.qml index cab4a03e..8b426969 100644 --- a/wizard/WizardRestoreWallet1.qml +++ b/wizard/WizardRestoreWallet1.qml @@ -40,11 +40,16 @@ Rectangle { property string viewName: "wizardCreateWallet1" function verify() { + if (restoreHeight.text.indexOf('-') === 4 && restoreHeight.text.length !== 10) { + return false; + } + + var valid = false; if(wizardController.walletRestoreMode === "keys") { - var valid = wizardRestoreWallet1.verifyFromKeys(); + valid = wizardRestoreWallet1.verifyFromKeys(); return valid; } else if(wizardController.walletRestoreMode === "seed") { - var valid = wizardWalletInput.verify(); + valid = wizardWalletInput.verify(); if(!valid) return false; valid = Wizard.checkSeed(seedInput.text); return valid; @@ -74,6 +79,10 @@ Rectangle { addressLineLength != 0 && viewKeyLineLength != 0 && spendKeyLineLength != 0) } + function checkRestoreHeight() { + return (parseInt(restoreHeight) >= 0 || restoreHeight === "") && restoreHeight.indexOf("-") === -1; + } + ColumnLayout { Layout.alignment: Qt.AlignHCenter; width: parent.width - 100 @@ -233,11 +242,13 @@ Rectangle { MoneroComponents.LineEdit { id: restoreHeight Layout.fillWidth: true - labelText: qsTr("Restore height") + translationManager.emptyString + labelText: qsTr("Wallet creation date as `YYYY-MM-DD` or restore height") + translationManager.emptyString labelFontSize: 14 * scaleRatio placeholderFontSize: 16 * scaleRatio placeholderText: qsTr("Restore height") + translationManager.emptyString - validator: RegExpValidator { regExp: /(\d+)?$/ } + validator: RegExpValidator { + regExp: /^(\d+|\d{4}-\d{2}-\d{2})$/ + } text: "0" } @@ -263,8 +274,18 @@ Rectangle { wizardController.walletOptionsName = wizardWalletInput.walletName.text; wizardController.walletOptionsLocation = wizardWalletInput.walletLocation.text; wizardController.walletOptionsSeed = seedInput.text; - if(restoreHeight.text) - wizardController.walletOptionsRestoreHeight = parseInt(restoreHeight.text); + + var _restoreHeight = 0; + if(restoreHeight.text){ + // Parse date string or restore height as integer + if(restoreHeight.text.indexOf('-') === 4 && restoreHeight.text.length === 10){ + _restoreHeight = Wizard.getApproximateBlockchainHeight(restoreHeight.text); + } else { + _restoreHeight = parseInt(restoreHeight.text) + } + + wizardController.walletOptionsRestoreHeight = _restoreHeight; + } wizardStateView.state = "wizardRestoreWallet2"; } |
