From 63e4d19a9299f8088dd7cde336c901b102d8c220 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Tue, 26 Jan 2016 10:30:07 +0300 Subject: [PATCH] Save settings for each wizard page in "wizard.settings" object and diplay overview at the last page --- wizard/WizardCreateWallet.qml | 7 +++++++ wizard/WizardDonation.qml | 9 +++++++++ wizard/WizardFinish.qml | 19 ++++++++++++++++++- wizard/WizardMain.qml | 30 ++++++++++++++++-------------- wizard/WizardWelcome.qml | 10 +++++++++- 5 files changed, 59 insertions(+), 16 deletions(-) diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml index 4e4c919e69..15e5899da0 100644 --- a/wizard/WizardCreateWallet.qml +++ b/wizard/WizardCreateWallet.qml @@ -39,6 +39,12 @@ Item { onOpacityChanged: visible = opacity !== 0 + function saveSettings(settingsObject) { + settingsObject['account_name'] = accountName.text + settingsObject['words'] = wordsText.text + settingsObject['wallet_path'] = fileUrlInput.text + } + Row { id: dotsRow anchors.top: parent.top @@ -106,6 +112,7 @@ Item { height: 62 TextInput { + id: accountName anchors.fill: parent horizontalAlignment: TextInput.AlignHCenter verticalAlignment: TextInput.AlignVCenter diff --git a/wizard/WizardDonation.qml b/wizard/WizardDonation.qml index d995463985..d42c266e8d 100644 --- a/wizard/WizardDonation.qml +++ b/wizard/WizardDonation.qml @@ -38,6 +38,12 @@ Item { onOpacityChanged: visible = opacity !== 0 + function saveSettings(settingsObject) { + settingsObject['auto_donations_enabled'] = enableAutoDonationCheckBox.checked; + settingsObject['auto_donations_amount'] = autoDonationAmountText.text; + settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked; + } + Row { id: dotsRow anchors.top: parent.top @@ -94,6 +100,7 @@ Item { spacing: 2 CheckBox { + id: enableAutoDonationCheckBox anchors.verticalCenter: parent.verticalCenter text: qsTr("Enable auto-donations of?") background: "#F0EEEE" @@ -110,6 +117,7 @@ Item { width: 41 TextInput { + id: autoDonationAmountText anchors.fill: parent verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter @@ -155,6 +163,7 @@ Item { spacing: 12 CheckBox { + id: allowBackgroundMiningCheckBox text: qsTr("Allow background mining?") anchors.left: parent.left anchors.right: parent.right diff --git a/wizard/WizardFinish.qml b/wizard/WizardFinish.qml index 85ebbdf494..7902c0b29e 100644 --- a/wizard/WizardFinish.qml +++ b/wizard/WizardFinish.qml @@ -37,6 +37,22 @@ Item { onOpacityChanged: visible = opacity !== 0 + function buildSettingsString() { + var str = "
" + qsTr("Language: ") + wizard.settings['language'] + "
" + + qsTr("Account name: ") + wizard.settings['account_name'] + "
" + + qsTr("Words: ") + wizard.settings['words'] + "
" + + qsTr("Wallet Path: ") + wizard.settings['wallet_path'] + "
" + + qsTr("Enable auto donation: ") + wizard.settings['auto_donations_enabled'] + "
" + + qsTr("Auto donation amount: ") + wizard.settings['auto_donations_amount'] + "
" + + qsTr("Allow background mining: ") + wizard.settings['allow_background_mining'] + "
" + return str; + } + function updateSettingsSummary() { + settingsText.text = qsTr("An overview of your Monero configuration is below:") + + "
" + + buildSettingsString(); + } + Row { id: dotsRow anchors.top: parent.top @@ -84,14 +100,15 @@ Item { } Text { + id: settingsText anchors.left: parent.left anchors.right: parent.right font.family: "Arial" font.pixelSize: 18 wrapMode: Text.Wrap + textFormat: Text.RichText //renderType: Text.NativeRendering color: "#4A4646" - text: qsTr("An overview of your Monero configuration is below:") } } } diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index a20d654c20..a024fb9071 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -32,7 +32,9 @@ import "../components" Rectangle { id: wizard property alias nextButton : nextButton - + property var settings : ({}) + property int currentPage: 0 + property var pages: [welcomePage, optionsPage, createWalletPage, passwordPage, /*configurePage,*/ donationPage, finishPage ] signal useMoneroClicked() border.color: "#DBDBDB" @@ -40,6 +42,12 @@ Rectangle { color: "#FFFFFF" function switchPage(next) { + + // save settings for current page; + if (typeof pages[currentPage].saveSettings !== 'undefined') { + pages[currentPage].saveSettings(settings); + } + if(next === false) { if(currentPage > 0) { pages[currentPage].opacity = 0 @@ -52,10 +60,15 @@ Rectangle { } } - // disallow "next" button until password matches + // disallow "next" button until passwords match if (pages[currentPage] === passwordPage) { nextButton.visible = passwordPage.passwordValid } + + // display settings summary + if (pages[currentPage] === finishPage) { + finishPage.updateSettingsSummary(); + } } @@ -84,8 +97,7 @@ Rectangle { } } - property int currentPage: 0 - property var pages: [welcomePage, optionsPage, createWalletPage, passwordPage, /*configurePage,*/ donationPage, finishPage ] + WizardWelcome { @@ -129,16 +141,6 @@ Rectangle { anchors.rightMargin: 50 } -// WizardConfigure { -// id: configurePage -// anchors.top: parent.top -// anchors.bottom: parent.bottom -// anchors.right: nextButton.left -// anchors.left: prevButton.right -// anchors.leftMargin: 50 -// anchors.rightMargin: 50 -// } - WizardDonation { id: donationPage anchors.top: parent.top diff --git a/wizard/WizardWelcome.qml b/wizard/WizardWelcome.qml index b0a243bcc0..f627e88d2c 100644 --- a/wizard/WizardWelcome.qml +++ b/wizard/WizardWelcome.qml @@ -36,6 +36,10 @@ Item { onOpacityChanged: visible = opacity !== 0 + function saveSettings(settingsObject) { + settingsObject['language'] = languagesModel.get(gridView.currentIndex).name + } + Column { id: headerColumn anchors.left: parent.left @@ -76,6 +80,8 @@ Item { XmlRole { name: "name"; query: "@name/string()" } XmlRole { name: "flag"; query: "@flag/string()" } + // TODO: XmlListModel is read only, we should store current language somewhere else + // and set current language accordingly XmlRole { name: "isCurrent"; query: "@enabled/string()" } } @@ -125,7 +131,9 @@ Item { MouseArea { id: delegateArea anchors.fill: parent - onClicked: gridView.currentIndex = index + onClicked: { + gridView.currentIndex = index + } } } }