Allow configuring custom data folder
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "settings.h"
|
||||
#include "ui_connection.h"
|
||||
#include "ui_createzcashconfdialog.h"
|
||||
#include "rpc.h"
|
||||
|
||||
#include "precompiled.h"
|
||||
@@ -128,9 +129,42 @@ void ConnectionLoader::createZcashConf() {
|
||||
main->logger->write("createZcashConf");
|
||||
|
||||
auto confLocation = zcashConfWritableLocation();
|
||||
main->logger->write("Creating file " + confLocation);
|
||||
|
||||
QFileInfo fi(confLocation);
|
||||
|
||||
QDialog d(main);
|
||||
Ui_createZcashConf ui;
|
||||
ui.setupUi(&d);
|
||||
|
||||
QPixmap logo(":/img/res/zcashdlogo.gif");
|
||||
ui.lblTopIcon->setBasePixmap(logo.scaled(256, 256, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
ui.btnPickDir->setEnabled(false);
|
||||
ui.lblDirName->setText(fi.dir().absolutePath());
|
||||
|
||||
QObject::connect(ui.chkCustomDatadir, &QCheckBox::stateChanged, [=](int chked) {
|
||||
if (chked == Qt::Checked) {
|
||||
ui.btnPickDir->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
ui.btnPickDir->setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
QObject::connect(ui.btnPickDir, &QPushButton::clicked, [=]() {
|
||||
auto datadir = QFileDialog::getExistingDirectory(main, QObject::tr("Choose data directory"), fi.dir().absolutePath(), QFileDialog::ShowDirsOnly);
|
||||
if (!datadir.isEmpty()) {
|
||||
ui.lblDirName->setText(datadir);
|
||||
}
|
||||
});
|
||||
|
||||
// Show the dialog
|
||||
QString datadir = "";
|
||||
bool useTor = false;
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
datadir = ui.lblDirName->text();
|
||||
useTor = ui.chkUseTor->isChecked();
|
||||
}
|
||||
|
||||
main->logger->write("Creating file " + confLocation);
|
||||
QDir().mkdir(fi.dir().absolutePath());
|
||||
|
||||
QFile file(confLocation);
|
||||
@@ -145,6 +179,13 @@ void ConnectionLoader::createZcashConf() {
|
||||
out << "addnode=mainnet.z.cash\n";
|
||||
out << "rpcuser=zec-qt-wallet\n";
|
||||
out << "rpcpassword=" % randomPassword() << "\n";
|
||||
if (!datadir.isEmpty()) {
|
||||
out << "datadir=" % QDir::toNativeSeparators(datadir) % "\n";
|
||||
}
|
||||
if (useTor) {
|
||||
out << "proxy=127.0.0.1:9050\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
// Now that zcash.conf exists, try to autoconnect again
|
||||
|
||||
Reference in New Issue
Block a user