Skip to content

Commit

Permalink
#161 Allow configuration for prices/check updates
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapk00 committed Jul 12, 2019
1 parent fc68820 commit 1cec871
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 75 deletions.
4 changes: 4 additions & 0 deletions src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ void ConnectionLoader::createZcashConf() {
if (d.exec() == QDialog::Accepted) {
datadir = ui.lblDirName->text();
useTor = ui.chkUseTor->isChecked();
if (!ui.chkAllowInternet->isChecked()) {
Settings::getInstance()->setAllowFetchPrices(false);
Settings::getInstance()->setCheckForUpdates(false);
}
}

main->logger->write("Creating file " + confLocation);
Expand Down
48 changes: 36 additions & 12 deletions src/createzcashconfdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,24 @@
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="chkCustomDatadir">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Use custom datadir</string>
<string notr="true"/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Please choose a directory to store your wallet.dat and blockchain</string>
<string>Allow connections to the internet to check for updates, get ZEC/USD prices etc...</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="chkCustomDatadir">
<property name="text">
<string>Use custom datadir</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -144,24 +151,41 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string notr="true"/>
<string>Please note that you'll need to already have a Tor service configured on port 9050</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="chkAllowInternet">
<property name="text">
<string>Connect to the internet for updates and price feeds</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Please choose a directory to store your wallet.dat and blockchain</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="chkUseTor">
<property name="text">
<string>Connect over Tor</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<item row="6" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Please note that you'll need to already have a Tor service configured on port 9050</string>
<string/>
</property>
</widget>
</item>
Expand Down
12 changes: 12 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,12 @@ void MainWindow::setupSettingsModal() {
// Auto shielding
settings.chkAutoShield->setChecked(Settings::getInstance()->getAutoShield());

// Check for updates
settings.chkCheckUpdates->setChecked(Settings::getInstance()->getCheckForUpdates());

// Fetch prices
settings.chkFetchPrices->setChecked(Settings::getInstance()->getAllowFetchPrices());

// Use Tor
bool isUsingTor = false;
if (rpc->getConnection() != nullptr) {
Expand Down Expand Up @@ -545,6 +551,12 @@ void MainWindow::setupSettingsModal() {
// Auto shield
Settings::getInstance()->setAutoShield(settings.chkAutoShield->isChecked());

// Check for updates
Settings::getInstance()->setCheckForUpdates(settings.chkCheckUpdates->isChecked());

// Allow fetching prices
Settings::getInstance()->setAllowFetchPrices(settings.chkFetchPrices->isChecked());

if (!isUsingTor && settings.chkTor->isChecked()) {
// If "use tor" was previously unchecked and now checked
Settings::addToZcashConf(zcashConfLocation, "proxy=127.0.0.1:9050");
Expand Down
13 changes: 9 additions & 4 deletions src/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ RPC::RPC(MainWindow* main) {
// Set up timer to refresh Price
priceTimer = new QTimer(main);
QObject::connect(priceTimer, &QTimer::timeout, [=]() {
refreshZECPrice();
if (Settings::getInstance()->getAllowFetchPrices())
refreshZECPrice();
});
priceTimer->start(Settings::priceRefreshSpeed); // Every hour

Expand Down Expand Up @@ -96,9 +97,13 @@ void RPC::setConnection(Connection* c) {
Settings::removeFromZcashConf(zcashConfLocation, "rescan");
Settings::removeFromZcashConf(zcashConfLocation, "reindex");

// Refresh the UI
refreshZECPrice();
checkForUpdate();
// If we're allowed to get the Zec Price, get the prices
if (Settings::getInstance()->getAllowFetchPrices())
refreshZECPrice();

// If we're allowed to check for updates, check for a new release
if (Settings::getInstance()->getCheckForUpdates())
checkForUpdate();

// Force update, because this might be coming from a settings update
// where we need to immediately refresh
Expand Down
16 changes: 16 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ void Settings::setAutoShield(bool allow) {
QSettings().setValue("options/autoshield", allow);
}

bool Settings::getCheckForUpdates() {
return QSettings().value("options/allowcheckupdates", true).toBool();
}

void Settings::setCheckForUpdates(bool allow) {
QSettings().setValue("options/allowcheckupdates", allow);
}

bool Settings::getAllowFetchPrices() {
return QSettings().value("options/allowfetchprices", true).toBool();
}

void Settings::setAllowFetchPrices(bool allow) {
QSettings().setValue("options/allowfetchprices", allow);
}

bool Settings::getAllowCustomFees() {
// Load from the QT Settings.
return QSettings().value("options/customfees", false).toBool();
Expand Down
6 changes: 6 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class Settings

bool getAllowCustomFees();
void setAllowCustomFees(bool allow);

bool getAllowFetchPrices();
void setAllowFetchPrices(bool allow);

bool getCheckForUpdates();
void setCheckForUpdates(bool allow);

bool isSaplingActive();

Expand Down
132 changes: 73 additions & 59 deletions src/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand Down Expand Up @@ -145,32 +145,18 @@
<string>Options</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="lblTor">
<property name="text">
<string>Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Clear History</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
<item row="14" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
<item row="2" column="0">
<spacer name="horizontalSpacer">
Expand All @@ -185,21 +171,35 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs">
<item row="7" column="0">
<widget class="QCheckBox" name="chkTor">
<property name="text">
<string>Remember shielded transactions</string>
<string>Connect via Tor</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkCustomFees">
<item row="9" column="0" colspan="2">
<widget class="QCheckBox" name="chkCheckUpdates">
<property name="text">
<string>Allow custom fees</string>
<string>Check github for updates at startup</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="13" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="chkSaveTxs">
<property name="text">
<string>Remember shielded transactions</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy.</string>
Expand All @@ -209,61 +209,75 @@
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. </string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<item row="2" column="1">
<widget class="QPushButton" name="btnClearSaved">
<property name="text">
<string>Clear History</string>
</property>
</spacer>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. </string>
<string>Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="3" column="0">
<widget class="QCheckBox" name="chkCustomFees">
<property name="text">
<string>Allow custom fees</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="chkAutoShield">
<property name="text">
<string>Shield change from t-Addresses to your sapling address</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="lblTor">
<property name="text">
<string/>
<string>Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QCheckBox" name="chkTor">
<item row="10" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Connect via Tor</string>
<string>Connect to github on startup to check for updates</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="12" column="0" colspan="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string notr="true"/>
<string>Connect to the internet to fetch ZEC prices</string>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="QCheckBox" name="chkFetchPrices">
<property name="text">
<string>Fetch ZEC / USD prices</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 1cec871

Please sign in to comment.