Setttings: blockchain folder location

This commit is contained in:
Jaquee 2017-05-04 14:06:29 +02:00
parent 9037eed805
commit 62e1dc490f
2 changed files with 88 additions and 4 deletions

View file

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

View file

@ -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");