Browse Source

Allow configuring custom data folder

pull/45/head
adityapk00 5 years ago
parent
commit
1e3953613a
  1. BIN
      src/.ui_createzcashconfdialog.h.swp
  2. 45
      src/connection.cpp
  3. 173
      src/createzcashconfdialog.ui
  4. 3
      zec-qt-wallet.pro

BIN
src/.ui_createzcashconfdialog.h.swp

Binary file not shown.

45
src/connection.cpp

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

173
src/createzcashconfdialog.ui

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>createZcashConf</class>
<widget class="QDialog" name="createZcashConf">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>503</width>
<height>288</height>
</rect>
</property>
<property name="windowTitle">
<string>Configure zcash.conf</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Please chose a directory to store your wallet.dat and blockchain</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="FilledIconLabel" name="lblTopIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background: #fff;</string>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="chkUseTor">
<property name="text">
<string>Connect over Tor</string>
</property>
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnPickDir">
<property name="text">
<string>Choose directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblDirName">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkCustomDatadir">
<property name="text">
<string>Use custom datadir</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Please note that you'll need to already have a Tor service configured on port 9050</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>FilledIconLabel</class>
<extends>QLabel</extends>
<header>fillediconlabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>createZcashConf</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>createZcashConf</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

3
zec-qt-wallet.pro

@ -84,7 +84,8 @@ FORMS += \
src/memodialog.ui \
src/connection.ui \
src/zboard.ui \
src/addressbook.ui
src/addressbook.ui \
src/createzcashconfdialog.ui
TRANSLATIONS = res/zec_qt_wallet_es.ts \

Loading…
Cancel
Save