From 1cec871ac9ea701295fead72c47817282ca74ddd Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Fri, 12 Jul 2019 15:06:50 -0700 Subject: [PATCH] #161 Allow configuration for prices/check updates --- src/connection.cpp | 4 ++ src/createzcashconfdialog.ui | 48 +++++++++---- src/mainwindow.cpp | 12 ++++ src/rpc.cpp | 13 ++-- src/settings.cpp | 16 +++++ src/settings.h | 6 ++ src/settings.ui | 132 +++++++++++++++++++---------------- 7 files changed, 156 insertions(+), 75 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 2b5ae81..9547c2f 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -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); diff --git a/src/createzcashconfdialog.ui b/src/createzcashconfdialog.ui index a5b45e6..623993f 100644 --- a/src/createzcashconfdialog.ui +++ b/src/createzcashconfdialog.ui @@ -99,17 +99,24 @@ - - + + - Use custom datadir + - - + + - Please choose a directory to store your wallet.dat and blockchain + Allow connections to the internet to check for updates, get ZEC/USD prices etc... + + + + + + + Use custom datadir @@ -144,24 +151,41 @@ - - + + - + Please note that you'll need to already have a Tor service configured on port 9050 + + + Connect to the internet for updates and price feeds + + + true + + + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + Connect over Tor - - + + - Please note that you'll need to already have a Tor service configured on port 9050 + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 57d78a6..e6ef0e4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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) { @@ -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"); diff --git a/src/rpc.cpp b/src/rpc.cpp index ce138df..c72afcb 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -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 @@ -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 diff --git a/src/settings.cpp b/src/settings.cpp index 2773364..56484ca 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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(); diff --git a/src/settings.h b/src/settings.h index 8e1b7ef..245ae29 100644 --- a/src/settings.h +++ b/src/settings.h @@ -60,6 +60,12 @@ public: bool getAllowCustomFees(); void setAllowCustomFees(bool allow); + + bool getAllowFetchPrices(); + void setAllowFetchPrices(bool allow); + + bool getCheckForUpdates(); + void setCheckForUpdates(bool allow); bool isSaplingActive(); diff --git a/src/settings.ui b/src/settings.ui index f107bd4..296a4f6 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -26,7 +26,7 @@ - 2 + 1 @@ -145,32 +145,18 @@ Options - - - - 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. - - - true - - - - - - - Clear History - - - - - - - Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab. + + + + Qt::Vertical - - true + + + 20 + 40 + - + @@ -185,21 +171,35 @@ - - + + - Remember shielded transactions + Connect via Tor - - + + - Allow custom fees + Check github for updates at startup - + + + + Qt::Horizontal + + + + + + + Remember shielded transactions + + + + 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. @@ -209,61 +209,75 @@ - - - - Qt::Horizontal + + + + Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. + + + true - - - - Qt::Vertical - - - - 20 - 40 - + + + + Clear History - + - - + + - Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. + Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab. true - + + + + Allow custom fees + + + + Shield change from t-Addresses to your sapling address - - + + - + 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. + + + true - - + + - Connect via Tor + Connect to github on startup to check for updates - + - + Connect to the internet to fetch ZEC prices + + + + + + + Fetch ZEC / USD prices