From 80618c83fdda34c80be81a1fe950a53466b8e596 Mon Sep 17 00:00:00 2001 From: Jaquee Date: Mon, 23 Oct 2017 19:49:57 +0200 Subject: [PATCH] wizard: reworked testnet settings --- main.qml | 2 +- wizard/WizardFinish.qml | 4 +- wizard/WizardMain.qml | 3 -- wizard/WizardManageWalletUI.qml | 6 +-- wizard/WizardOptions.qml | 82 +++++++-------------------------- wizard/WizardWelcome.qml | 6 --- 6 files changed, 23 insertions(+), 80 deletions(-) diff --git a/main.qml b/main.qml index e5d312d1..61bb1b99 100644 --- a/main.qml +++ b/main.qml @@ -880,7 +880,7 @@ ApplicationWindow { property bool allow_background_mining : false property bool miningIgnoreBattery : true property bool testnet: false - property string daemon_address: "localhost:18081" + property string daemon_address: testnet ? "localhost:28081" : "localhost:18081" property string payment_id property int restore_height : 0 property bool is_recovering : false diff --git a/wizard/WizardFinish.qml b/wizard/WizardFinish.qml index fd9bafcd..a6999e9c 100644 --- a/wizard/WizardFinish.qml +++ b/wizard/WizardFinish.qml @@ -50,7 +50,7 @@ ColumnLayout { autoDonationAmount = wizard.settings["auto_donations_amount"] + " %", backgroundMiningEnabled = wizard.settings["allow_background_mining"] === true, backgroundMiningText = backgroundMiningEnabled ? qsTr("Enabled") : qsTr("Disabled"), - testnetEnabled = wizard.settings['testnet'] === true, + testnetEnabled = appWindow.persistentSettings.testnet, testnetText = testnetEnabled ? qsTr("Enabled") : qsTr("Disabled"), restoreHeightEnabled = wizard.settings['restore_height'] !== undefined; @@ -64,7 +64,7 @@ ColumnLayout { // ? trStart + qsTr("Donation amount") + trMiddle + autoDonationAmount + trEnd // : "") // + trStart + qsTr("Background mining") + trMiddle + backgroundMiningText + trEnd - + trStart + qsTr("Daemon address") + trMiddle + wizard.settings["daemon_address"] + trEnd + + trStart + qsTr("Daemon address") + trMiddle + persistentSettings.daemon_address + trEnd + trStart + qsTr("Testnet") + trMiddle + testnetText + trEnd + (restoreHeightEnabled ? trStart + qsTr("Restore height") + trMiddle + wizard.settings['restore_height'] + trEnd diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index 9064b875..1b16acfd 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -233,11 +233,8 @@ ColumnLayout { appWindow.persistentSettings.allow_background_mining = false //settings.allow_background_mining appWindow.persistentSettings.auto_donations_enabled = false //settings.auto_donations_enabled appWindow.persistentSettings.auto_donations_amount = false //settings.auto_donations_amount - appWindow.persistentSettings.daemon_address = settings.daemon_address - appWindow.persistentSettings.testnet = settings.testnet appWindow.persistentSettings.restore_height = (isNaN(settings.restore_height))? 0 : settings.restore_height appWindow.persistentSettings.is_recovering = (settings.is_recovering === undefined)? false : settings.is_recovering - } // reading settings from persistent storage diff --git a/wizard/WizardManageWalletUI.qml b/wizard/WizardManageWalletUI.qml index 7e7d2f58..9b3f206d 100644 --- a/wizard/WizardManageWalletUI.qml +++ b/wizard/WizardManageWalletUI.qml @@ -56,10 +56,10 @@ ColumnLayout { property int rowSpacing: 10 function checkFields(){ - var addressOK = walletManager.addressValid(addressLine.text, wizard.settings.testnet) - var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, wizard.settings.testnet) + var addressOK = walletManager.addressValid(addressLine.text, persistentSettings.testnet) + var viewKeyOK = walletManager.keyValid(viewKeyLine.text, addressLine.text, true, persistentSettings.testnet) // Spendkey is optional - var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, wizard.settings.testnet) : true + var spendKeyOK = (spendKeyLine.text.length > 0)? walletManager.keyValid(spendKeyLine.text, addressLine.text, false, persistentSettings.testnet) : true addressLine.error = !addressOK && addressLine.text.length != 0 viewKeyLine.error = !viewKeyOK && viewKeyLine.text.length != 0 diff --git a/wizard/WizardOptions.qml b/wizard/WizardOptions.qml index b173add5..0154b9ce 100644 --- a/wizard/WizardOptions.qml +++ b/wizard/WizardOptions.qml @@ -44,25 +44,12 @@ ColumnLayout { function onPageClosed() { // Save settings used in open from file. // other wizard settings are saved on last page in applySettings() - appWindow.persistentSettings.testnet = wizard.settings["testnet"] - appWindow.persistentSettings.daemon_address = wizard.settings["daemon_address"] appWindow.persistentSettings.language = wizard.settings.language appWindow.persistentSettings.locale = wizard.settings.locale return true; } - function saveDaemonAddress() { - wizard.settings["daemon_address"] = daemonAddress.text - wizard.settings["testnet"] = testNet.checked - } - - QtObject { - id: d - readonly property string daemonAddressTestnet : "localhost:38081" - readonly property string daemonAddressMainnet : "localhost:18081" - } - Behavior on opacity { NumberAnimation { duration: 100; easing.type: Easing.InQuad } } @@ -139,7 +126,6 @@ ColumnLayout { anchors.fill: parent hoverEnabled: true onClicked: { - page.saveDaemonAddress() page.createWalletClicked() } } @@ -182,7 +168,6 @@ ColumnLayout { anchors.fill: parent hoverEnabled: true onClicked: { - page.saveDaemonAddress() page.recoveryWalletClicked() } } @@ -226,7 +211,6 @@ ColumnLayout { anchors.fill: parent hoverEnabled: true onClicked: { - page.saveDaemonAddress() page.openWalletClicked() } } @@ -247,62 +231,30 @@ ColumnLayout { } - // daemon select - // TODO: Move to separate page - - ColumnLayout { + RowLayout { Layout.leftMargin: wizardLeftMargin Layout.rightMargin: wizardRightMargin + Layout.topMargin: 30 Layout.alignment: Qt.AlignCenter + Layout.fillWidth: true - - Label { - Layout.topMargin: 20 - fontSize: 14 - text: qsTr("Custom daemon address (optional)") + translationManager.emptyString - + translationManager.emptyString - } - - GridLayout { - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter - - columnSpacing: 20 - rowSpacing: 20 - flow: isMobile ? GridLayout.TopToBottom : GridLayout.LeftToRight - - RowLayout { - spacing: 20 - Layout.alignment: Qt.AlignCenter - - LineEdit { - id: daemonAddress - Layout.alignment: Qt.AlignCenter - width: 200 - fontSize: 14 - text: { - if(appWindow.persistentSettings.daemon_address) - return appWindow.persistentSettings.daemon_address; - return testNet.checked ? d.daemonAddressTestnet : d.daemonAddressMainnet - } - - } - - CheckBox { - id: testNet - Layout.alignment: Qt.AlignCenter - anchors.verticalCenter: parent.verticalCenter - text: qsTr("Testnet") + translationManager.emptyString - background: "#FFFFFF" - fontColor: "#4A4646" - fontSize: 16 - checkedIcon: "../images/checkedVioletIcon.png" - uncheckedIcon: "../images/uncheckedIcon.png" - checked: appWindow.persistentSettings.testnet; + Rectangle { + width: 100 + CheckBox { + id: testNet + text: qsTr("Testnet") + translationManager.emptyString + background: "#FFFFFF" + fontColor: "#4A4646" + fontSize: 16 + checkedIcon: "../images/checkedVioletIcon.png" + uncheckedIcon: "../images/uncheckedIcon.png" + checked: appWindow.persistentSettings.testnet; + onClicked: { + persistentSettings.testnet = testNet.checked + console.log("testnet set to ", persistentSettings.testnet) } } } } - } diff --git a/wizard/WizardWelcome.qml b/wizard/WizardWelcome.qml index 715a7024..8b440092 100644 --- a/wizard/WizardWelcome.qml +++ b/wizard/WizardWelcome.qml @@ -39,12 +39,6 @@ ColumnLayout { NumberAnimation { duration: 100; easing.type: Easing.InQuad } } - QtObject { - id: d - readonly property string daemonAddressTestnet : "localhost:38018"; - readonly property string daemonAddressMainnet : "localhost:18018"; - } - onOpacityChanged: visible = opacity !== 0 function onPageClosed(settingsObject) {