diff options
| author | Ilya Kitaev <mbg033@gmail.com> | 2016-07-21 13:56:17 +0300 |
|---|---|---|
| committer | Ilya Kitaev <mbg033@gmail.com> | 2016-07-21 13:56:17 +0300 |
| commit | e5d5a6082fdcacfd9f1de1b2144101e705f2d322 (patch) | |
| tree | 4df82794be575cb9da354943a532d3be2c2fcf53 /wizard | |
| parent | ecf844120b62e688e0527316d8f1322bfea06fe0 (diff) | |
| download | monzero-gui-e5d5a6082fdcacfd9f1de1b2144101e705f2d322.tar.gz monzero-gui-e5d5a6082fdcacfd9f1de1b2144101e705f2d322.tar.xz monzero-gui-e5d5a6082fdcacfd9f1de1b2144101e705f2d322.zip | |
Wizard refactoring
Diffstat (limited to 'wizard')
| -rw-r--r-- | wizard/WizardCreateWallet.qml | 9 | ||||
| -rw-r--r-- | wizard/WizardFinish.qml | 4 | ||||
| -rw-r--r-- | wizard/WizardMain.qml | 57 | ||||
| -rw-r--r-- | wizard/WizardPassword.qml | 22 | ||||
| -rw-r--r-- | wizard/WizardRecoveryWallet.qml | 12 |
5 files changed, 71 insertions, 33 deletions
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(); } } } |
