aboutsummaryrefslogtreecommitdiff
path: root/wizard
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-06-14 16:09:14 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-06-14 16:09:14 +0300
commit1eac46ae734d31df568cf0f51dd1d5b7e7244cdc (patch)
tree897d58bf18b8265d12bf09d2397dd2f98e74b59b /wizard
parentb7787dc6704ee8395ba20adf0f09af6fc3eb9f8a (diff)
downloadmonzero-gui-1eac46ae734d31df568cf0f51dd1d5b7e7244cdc.tar.gz
monzero-gui-1eac46ae734d31df568cf0f51dd1d5b7e7244cdc.tar.xz
monzero-gui-1eac46ae734d31df568cf0f51dd1d5b7e7244cdc.zip
"new wallet" and "recovery wallet" flows are implemented using libwallet
api
Diffstat (limited to 'wizard')
-rw-r--r--wizard/WizardCreateWallet.qml5
-rw-r--r--wizard/WizardDonation.qml15
-rw-r--r--wizard/WizardFinish.qml2
-rw-r--r--wizard/WizardMain.qml40
-rw-r--r--wizard/WizardPassword.qml1
-rw-r--r--wizard/WizardRecoveryWallet.qml22
-rw-r--r--wizard/WizardWelcome.qml1
7 files changed, 60 insertions, 26 deletions
diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml
index 2332dd5c..0aad0052 100644
--- a/wizard/WizardCreateWallet.qml
+++ b/wizard/WizardCreateWallet.qml
@@ -46,10 +46,7 @@ Item {
settingsObject['account_name'] = uiItem.accountNameText
settingsObject['words'] = uiItem.wordsTexttext
settingsObject['wallet_path'] = uiItem.walletPath
-
- // put wallet files to the subdirectory with the same name as
- // wallet name
-
+ return true;
}
//! function called each time we hide this page
diff --git a/wizard/WizardDonation.qml b/wizard/WizardDonation.qml
index 8cfc68f2..e0b73df8 100644
--- a/wizard/WizardDonation.qml
+++ b/wizard/WizardDonation.qml
@@ -43,22 +43,9 @@ Item {
settingsObject['auto_donations_amount'] = autoDonationAmountText.text;
settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked;
- // here we need to actually move wallet to the new location
- // put wallet files to the subdirectory with the same name as
- // wallet name
- var new_wallet_filename = settingsObject.wallet_path + "/"
- + settingsObject.account_name + "/"
- + settingsObject.account_name;
- // moving wallet files to the new destination, if user changed it
- if (new_wallet_filename !== settingsObject.wallet_filename) {
- // using previously saved wallet;
- settingsObject.wallet.store(new_wallet_filename);
- //walletManager.moveWallet(settingsObject.wallet_filename, new_wallet_filename);
- }
- // saving wallet_filename;
- settingsObject['wallet_filename'] = new_wallet_filename;
+ return true;
}
Row {
diff --git a/wizard/WizardFinish.qml b/wizard/WizardFinish.qml
index 311dfd62..427a2340 100644
--- a/wizard/WizardFinish.qml
+++ b/wizard/WizardFinish.qml
@@ -53,6 +53,8 @@ Item {
+ buildSettingsString();
}
+
+
Row {
id: dotsRow
anchors.top: parent.top
diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml
index a19c622c..da3a9824 100644
--- a/wizard/WizardMain.qml
+++ b/wizard/WizardMain.qml
@@ -49,8 +49,12 @@ Rectangle {
function switchPage(next) {
// save settings for current page;
- if (typeof pages[currentPage].onPageClosed !== 'undefined') {
- pages[currentPage].onPageClosed(settings);
+ if (next && typeof pages[currentPage].onPageClosed !== 'undefined') {
+ if (pages[currentPage].onPageClosed(settings) !== true) {
+ print ("Can't go to the next page");
+ return;
+ };
+
}
print ("switchpage: start: currentPage: ", currentPage);
@@ -59,6 +63,10 @@ Rectangle {
var step_value = next ? 1 : -1
currentPage += step_value
pages[currentPage].opacity = 1;
+
+ if (next && typeof pages[currentPage].onPageOpened !== 'undefined') {
+ pages[currentPage].onPageOpened(settings)
+ }
handlePageChanged();
}
}
@@ -84,7 +92,7 @@ Rectangle {
break;
case recoveryWalletPage:
// TODO: disable "next button" until 25 words private key entered
- // nextButton.enabled = false;
+ nextButton.enabled = false
break
default:
nextButton.enabled = true
@@ -115,6 +123,27 @@ Rectangle {
handlePageChanged()
}
+ //! actually writes the wallet
+ function applySettings() {
+ print ("Here we apply the settings");
+ // here we need to actually move wallet to the new location
+ // put wallet files to the subdirectory with the same name as
+ // wallet name
+ var new_wallet_filename = settings.wallet_path + "/"
+ + settings.account_name + "/"
+ + settings.account_name;
+
+ // moving wallet files to the new destination, if user changed it
+ if (new_wallet_filename !== settings.wallet_filename) {
+ // using previously saved wallet;
+ settings.wallet.store(new_wallet_filename);
+ //walletManager.moveWallet(settingsObject.wallet_filename, new_wallet_filename);
+ }
+
+ // saving wallet_filename;
+ settings['wallet_filename'] = new_wallet_filename;
+ }
+
@@ -255,6 +284,9 @@ Rectangle {
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
visible: parent.paths[currentPath][currentPage] === finishPage
- onClicked: wizard.useMoneroClicked()
+ onClicked: {
+ wizard.applySettings();
+ wizard.useMoneroClicked()
+ }
}
}
diff --git a/wizard/WizardPassword.qml b/wizard/WizardPassword.qml
index aca45d4d..6b14dae9 100644
--- a/wizard/WizardPassword.qml
+++ b/wizard/WizardPassword.qml
@@ -45,6 +45,7 @@ Item {
function onPageClosed(settingsObject) {
settingsObject.wallet.setPassword(passwordItem.password)
+ return true
}
function handlePassword() {
diff --git a/wizard/WizardRecoveryWallet.qml b/wizard/WizardRecoveryWallet.qml
index e7fd6c0d..19530157 100644
--- a/wizard/WizardRecoveryWallet.qml
+++ b/wizard/WizardRecoveryWallet.qml
@@ -29,6 +29,7 @@
import QtQuick 2.2
import moneroComponents 1.0
import QtQuick.Dialogs 1.2
+import Bitmonero.Wallet 1.0
Item {
opacity: 0
@@ -42,12 +43,25 @@ Item {
function onPageClosed(settingsObject) {
settingsObject['account_name'] = uiItem.accountNameText
- settingsObject['words'] = uiItem.wordsTexttext
+ settingsObject['words'] = cleanWordsInput(uiItem.wordsTextItem.memoText)
settingsObject['wallet_path'] = uiItem.walletPath
+ return recoveryWallet(settingsObject)
}
- function recoveryWallet() {
+ function recoveryWallet(settingsObject) {
+ var testnet = true;
+ var wallet = walletManager.recoveryWallet(oshelper.temporaryFilename(), settingsObject.words, testnet);
+ var success = wallet.status === Wallet.Status_Ok;
+ if (success) {
+ settingsObject['wallet'] = wallet;
+ } else {
+ walletManager.closeWallet(wallet);
+ }
+ return success;
+ }
+ function cleanWordsInput(text) {
+ return text.trim().replace(/(\r\n|\n|\r)/gm, " ");
}
WizardManageWalletUI {
@@ -60,8 +74,8 @@ Item {
wordsTextItem.memoTextReadOnly: false
wordsTextItem.memoText: ""
wordsTextItem.onMemoTextChanged: {
- var wordsArray = wordsTextItem.memoText.trim().split(" ")
- //wizard.nextButton.enabled = wordsArray.length === 25
+ var wordsArray = cleanWordsInput(wordsTextItem.memoText).split(" ");
+ wizard.nextButton.enabled = wordsArray.length === 25
}
}
}
diff --git a/wizard/WizardWelcome.qml b/wizard/WizardWelcome.qml
index bdd88b70..8917d212 100644
--- a/wizard/WizardWelcome.qml
+++ b/wizard/WizardWelcome.qml
@@ -41,6 +41,7 @@ Item {
settingsObject['language'] = lang.display_name;
settingsObject['wallet_language'] = lang.wallet_name;
settingsObject['locale'] = lang.locale;
+ return true
}
Column {