wizard: reworked testnet settings

pull/2/head
Jaquee 7 years ago
parent ea49e84215
commit 80618c83fd

@ -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

@ -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

@ -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

@ -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

@ -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)
}
}
}
}
}

@ -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) {