From 62e1dc490f7e2b49bcd319e06a36005cc66f01db Mon Sep 17 00:00:00 2001 From: Jaquee Date: Thu, 4 May 2017 14:06:29 +0200 Subject: [PATCH] Setttings: blockchain folder location --- main.qml | 3 +- pages/Settings.qml | 89 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/main.qml b/main.qml index 33b66929..cde1ae04 100644 --- a/main.qml +++ b/main.qml @@ -405,7 +405,7 @@ ApplicationWindow { currentWallet.pauseRefresh(); appWindow.showProcessingSplash(qsTr("Waiting for daemon to start...")) - daemonManager.start(flags, persistentSettings.testnet); + daemonManager.start(flags, persistentSettings.testnet, persistentSettings.blockchainDataDir); persistentSettings.daemonFlags = flags } @@ -884,6 +884,7 @@ ApplicationWindow { property string daemonUsername: "" property string daemonPassword: "" property bool transferShowAdvanced: false + property string blockchainDataDir: "" } // Information dialog diff --git a/pages/Settings.qml b/pages/Settings.qml index b64d4752..3885fa05 100644 --- a/pages/Settings.qml +++ b/pages/Settings.qml @@ -224,11 +224,38 @@ Rectangle { } } - - } - ColumnLayout { + RowLayout { + id: blockchainFolderRow + Label { + id: blockchainFolderLabel + color: "#4A4949" + text: qsTr("Blockchain location") + translationManager.emptyString + fontSize: 16 + } + LineEdit { + id: blockchainFolder + Layout.preferredWidth: 200 + Layout.fillWidth: true + text: persistentSettings.blockchainDataDir + placeholderText: qsTr("(optional)") + translationManager.emptyString + + MouseArea { + anchors.fill: parent + onClicked: { + mouse.accepted = false + if(persistentSettings.blockchainDataDir != "") + blockchainFileDialog.folder = "file://" + persistentSettings.blockchainDataDir + blockchainFileDialog.open() + blockchainFolder.focus = true + } + } + + } + } + + RowLayout { id: daemonFlagsRow Label { id: daemonFlagsLabel @@ -517,6 +544,62 @@ Rectangle { } } + // Choose blockchain folder + FileDialog { + id: blockchainFileDialog + title: qsTr("Please choose a folder") + translationManager.emptyString; + selectFolder: true + folder: "file://" + persistentSettings.blockchainDataDir + + onAccepted: { + var dataDir = walletManager.urlToLocalPath(blockchainFileDialog.fileUrl) + var validator = daemonManager.validateDataDir(dataDir); + if(!validator.valid) { + + confirmationDialog.title = qsTr("Warning") + translationManager.emptyString; + confirmationDialog.text = ""; + if(validator.readOnly) { + confirmationDialog.text += qsTr("Error: Filesystem is read only") + "\n\n" + } + + if(validator.storageAvailable < 20) { + confirmationDialog.text += qsTr("Warning: There's only %1 GB available on the device. Blockchain requires ~%2 GB of data.").arg(validator.storageAvailable).arg(15) + "\n\n" + } else { + confirmationDialog.text += qsTr("Note: There's %1 GB available on the device. Blockchain requires ~%2 GB of data.").arg(validator.storageAvailable).arg(15) + "\n\n" + } + + if(!validator.lmdbExists) { + confirmationDialog.text += qsTr("Note: lmdb folder not found. A new folder will be created.") + "\n\n" + } + + + confirmationDialog.icon = StandardIcon.Question + confirmationDialog.cancelText = qsTr("Cancel") + + // Continue + confirmationDialog.onAcceptedCallback = function() { + persistentSettings.blockchainDataDir = dataDir + } + + // Cancel + confirmationDialog.onRejectedCallback = function() { + }; + + confirmationDialog.open() + } else { + persistentSettings.blockchainDataDir = dataDir + } + + delete validator; + + + } + onRejected: { + console.log("data dir selection canceled") + } + + } + // fires on every page load function onPageCompleted() { console.log("Settings page loaded");