From e5d5a6082fdcacfd9f1de1b2144101e705f2d322 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Thu, 21 Jul 2016 13:56:17 +0300 Subject: [PATCH] Wizard refactoring --- translations/monero-core_de.ts | 36 ++++++++++----------- translations/monero-core_en.ts | 36 ++++++++++----------- translations/monero-core_it.ts | 36 ++++++++++----------- translations/monero-core_pl.ts | 36 ++++++++++----------- translations/monero-core_ru.ts | 36 ++++++++++----------- translations/monero-core_zh.ts | 36 ++++++++++----------- wizard/WizardCreateWallet.qml | 9 ++++++ wizard/WizardFinish.qml | 4 +++ wizard/WizardMain.qml | 57 ++++++++++++++++----------------- wizard/WizardPassword.qml | 22 +++++++++++-- wizard/WizardRecoveryWallet.qml | 12 +++++-- 11 files changed, 179 insertions(+), 141 deletions(-) diff --git a/translations/monero-core_de.ts b/translations/monero-core_de.ts index ea08d710..24e76b60 100644 --- a/translations/monero-core_de.ts +++ b/translations/monero-core_de.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/translations/monero-core_en.ts b/translations/monero-core_en.ts index dca4c577..6e8d5bcc 100644 --- a/translations/monero-core_en.ts +++ b/translations/monero-core_en.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/translations/monero-core_it.ts b/translations/monero-core_it.ts index 2c9c4b78..403d3859 100644 --- a/translations/monero-core_it.ts +++ b/translations/monero-core_it.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/translations/monero-core_pl.ts b/translations/monero-core_pl.ts index a3496ddb..bb152986 100644 --- a/translations/monero-core_pl.ts +++ b/translations/monero-core_pl.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/translations/monero-core_ru.ts b/translations/monero-core_ru.ts index 29bf9b7f..5ca9c499 100644 --- a/translations/monero-core_ru.ts +++ b/translations/monero-core_ru.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/translations/monero-core_zh.ts b/translations/monero-core_zh.ts index e5e60dab..14f60021 100644 --- a/translations/monero-core_zh.ts +++ b/translations/monero-core_zh.ts @@ -542,12 +542,12 @@ WizardCreateWallet - + A new wallet has been created for you - + This is the 25 word mnemonic for your wallet @@ -628,7 +628,7 @@ - + You’re all setup! @@ -636,17 +636,7 @@ WizardMain - - Now that your wallet has been created, please set a password for the wallet - - - - - Now that your wallet has been restored, please set a password for the wallet - - - - + USE MONERO @@ -708,7 +698,17 @@ WizardPassword - + + Now that your wallet has been created, please set a password for the wallet + + + + + Now that your wallet has been restored, please set a password for the wallet + + + + Note that this password cannot be recovered, and if forgotten you will need to restore your wallet from the mnemonic seed you were just given<br/><br/> Your password will be used to protect your wallet and to confirm actions, so make sure that your password is sufficiently secure. @@ -717,17 +717,17 @@ WizardRecoveryWallet - + My account name - + We're ready to recover your account - + Please enter your 25 word private key diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml index 2181a359..771a13ec 100644 --- a/wizard/WizardCreateWallet.qml +++ b/wizard/WizardCreateWallet.qml @@ -42,6 +42,10 @@ Item { //! function called each time we display this page + function onPageOpened(settingsOblect) { + checkNextButton() + } + function onPageClosed(settingsObject) { settingsObject['account_name'] = uiItem.accountNameText settingsObject['words'] = uiItem.wordsTexttext @@ -49,6 +53,11 @@ Item { return true; } + function checkNextButton() { + var wordsArray = cleanWordsInput(uiItem.wordsTextItem.memoText).split(" "); + wizard.nextButton.enabled = wordsArray.length === 25; + } + //! function called each time we hide this page // diff --git a/wizard/WizardFinish.qml b/wizard/WizardFinish.qml index 7c9c89e7..431b5a89 100644 --- a/wizard/WizardFinish.qml +++ b/wizard/WizardFinish.qml @@ -54,6 +54,10 @@ Item { + buildSettingsString(); } + function onPageOpened(settings) { + updateSettingsSummary(); + wizard.nextButton.visible = false; + } Row { diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index 1103c2ff..f0556efc 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -58,7 +58,7 @@ Rectangle { }; } - print ("switchpage: start: currentPage: ", currentPage); + print ("switchpage: currentPage: ", currentPage); if (currentPage > 0 || currentPage < pages.length - 1) { pages[currentPage].opacity = 0 @@ -66,40 +66,35 @@ Rectangle { currentPage += step_value pages[currentPage].opacity = 1; + var nextButtonVisible = pages[currentPage] !== optionsPage; + nextButton.visible = nextButtonVisible; + if (next && typeof pages[currentPage].onPageOpened !== 'undefined') { pages[currentPage].onPageOpened(settings) } - handlePageChanged(); + + + } } + // TODO: remove it function handlePageChanged() { - var nextButtonVisible = pages[currentPage] !== optionsPage; - nextButton.visible = nextButtonVisible; - print ("next button visible: " + nextButtonVisible); - switch (pages[currentPage]) { - case passwordPage: - // disable "next" button until passwords match - nextButton.enabled = passwordPage.passwordValid; - if (currentPath === "create_wallet") { - passwordPage.titleText = qsTr("Now that your wallet has been created, please set a password for the wallet") + translationManager.emptyString - } else { - passwordPage.titleText = qsTr("Now that your wallet has been restored, please set a password for the wallet") + translationManager.emptyString - } - break; - case finishPage: - // display settings summary - finishPage.updateSettingsSummary(); - nextButton.visible = false; - break; - case recoveryWalletPage: - // TODO: disable "next button" until 25 words private key entered - nextButton.enabled = false - break - default: - nextButton.enabled = true - } +// switch (pages[currentPage]) { +//// case finishPage: +//// // display settings summary +//// finishPage.updateSettingsSummary(); +//// nextButton.visible = false; +//// break; +// case recoveryWalletPage: +// // disable "next button" until 25 words private key entered +// nextButton.enabled = false +// break +// default: +// nextButton.enabled = true + +// } } @@ -111,7 +106,9 @@ Rectangle { pages = paths[currentPath] currentPage = pages.indexOf(createWalletPage) createWalletPage.createWallet(settings) - handlePageChanged() + wizard.nextButton.visible = true + createWalletPage.onPageOpened(settings); + } @@ -122,7 +119,9 @@ Rectangle { currentPath = "recovery_wallet" pages = paths[currentPath] currentPage = pages.indexOf(recoveryWalletPage) - handlePageChanged() + wizard.nextButton.visible = true + recoveryWalletPage.onPageOpened(settings); + } //! actually writes the wallet diff --git a/wizard/WizardPassword.qml b/wizard/WizardPassword.qml index 0e79d57c..8318a785 100644 --- a/wizard/WizardPassword.qml +++ b/wizard/WizardPassword.qml @@ -31,10 +31,10 @@ import "../components" import "utils.js" as Utils Item { + + id: passwordPage opacity: 0 visible: false - property bool passwordValid : passwordItem.password != '' - && passwordItem.password === retypePasswordItem.password property alias titleText: titleText.text Behavior on opacity { @@ -43,6 +43,17 @@ Item { onOpacityChanged: visible = opacity !== 0 + + function onPageOpened(settingsObject) { + wizard.nextButton.enabled = true + + if (wizard.currentPath === "create_wallet") { + passwordPage.titleText = qsTr("Now that your wallet has been created, please set a password for the wallet") + translationManager.emptyString + } else { + passwordPage.titleText = qsTr("Now that your wallet has been restored, please set a password for the wallet") + translationManager.emptyString + } + } + function onPageClosed(settingsObject) { // TODO: set password on the final page // settingsObject.wallet.setPassword(passwordItem.password) @@ -52,11 +63,14 @@ Item { function handlePassword() { // allow to forward step only if passwords match + wizard.nextButton.enabled = passwordItem.password === retypePasswordItem.password + // scorePassword returns value from 1..100 var strength = Utils.scorePassword(passwordItem.password) // privacyLevel component uses 1..13 scale privacyLevel.fillLevel = Utils.mapScope(1, 100, 1, 13, strength) + } @@ -155,4 +169,8 @@ Item { height: 62 onChanged: handlePassword() } + + Component.onCompleted: { + console.log + } } diff --git a/wizard/WizardRecoveryWallet.qml b/wizard/WizardRecoveryWallet.qml index 972ee6a1..2e6fe5f6 100644 --- a/wizard/WizardRecoveryWallet.qml +++ b/wizard/WizardRecoveryWallet.qml @@ -41,6 +41,15 @@ Item { onOpacityChanged: visible = opacity !== 0 + function onPageOpened(settingsObject) { + checkNextButton(); + } + + function checkNextButton() { + var wordsArray = cleanWordsInput(uiItem.wordsTextItem.memoText).split(" "); + wizard.nextButton.enabled = wordsArray.length === 25; + } + function onPageClosed(settingsObject) { settingsObject['account_name'] = uiItem.accountNameText settingsObject['words'] = cleanWordsInput(uiItem.wordsTextItem.memoText) @@ -74,8 +83,7 @@ Item { wordsTextItem.memoTextReadOnly: false wordsTextItem.memoText: "" wordsTextItem.onMemoTextChanged: { - var wordsArray = cleanWordsInput(wordsTextItem.memoText).split(" "); - wizard.nextButton.enabled = wordsArray.length === 25 + checkNextButton(); } } }