aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/optionsmodel.cpp')
-rw-r--r--src/qt/optionsmodel.cpp108
1 files changed, 37 insertions, 71 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 1133c457b3..3b83a5ff62 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2011-2013 The Bitcoin developers
+// Copyright (c) 2011-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -14,11 +14,13 @@
#include "init.h"
#include "main.h"
#include "net.h"
+#include "txdb.h" // for -dbcache defaults
#ifdef ENABLE_WALLET
#include "wallet.h"
#include "walletdb.h"
#endif
+#include <QNetworkProxy>
#include <QSettings>
#include <QStringList>
@@ -72,10 +74,18 @@ void OptionsModel::Init()
#ifdef ENABLE_WALLET
if (!settings.contains("nTransactionFee"))
settings.setValue("nTransactionFee", 0);
+ nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp
+ if (mapArgs.count("-paytxfee"))
+ strOverriddenByCommandLine += "-paytxfee ";
+
+ if (!settings.contains("bSpendZeroConfChange"))
+ settings.setValue("bSpendZeroConfChange", true);
+ if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
+ strOverriddenByCommandLine += "-spendzeroconfchange ";
#endif
if (!settings.contains("nDatabaseCache"))
- settings.setValue("nDatabaseCache", 25);
+ settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
strOverriddenByCommandLine += "-dbcache ";
@@ -126,69 +136,6 @@ void OptionsModel::Reset()
// default setting for OptionsModel::StartAtStartup - disabled
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(false);
-
- // Ensure Upgrade() is not running again by setting the bImportFinished flag
- settings.setValue("bImportFinished", true);
-}
-
-void OptionsModel::Upgrade()
-{
- QSettings settings;
-
- // Already upgraded
- if (settings.contains("bImportFinished"))
- return;
-
- settings.setValue("bImportFinished", true);
-
-#ifdef ENABLE_WALLET
- // Move settings from old wallet.dat (if any):
- CWalletDB walletdb(strWalletFile);
-
- QList<QString> intOptions;
- intOptions << "nDisplayUnit" << "nTransactionFee";
- foreach(QString key, intOptions)
- {
- int value = 0;
- if (walletdb.ReadSetting(key.toStdString(), value))
- {
- settings.setValue(key, value);
- walletdb.EraseSetting(key.toStdString());
- }
- }
- QList<QString> boolOptions;
- boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
- foreach(QString key, boolOptions)
- {
- bool value = false;
- if (walletdb.ReadSetting(key.toStdString(), value))
- {
- settings.setValue(key, value);
- walletdb.EraseSetting(key.toStdString());
- }
- }
- try
- {
- CAddress addrProxyAddress;
- if (walletdb.ReadSetting("addrProxy", addrProxyAddress))
- {
- settings.setValue("addrProxy", addrProxyAddress.ToStringIPPort().c_str());
- walletdb.EraseSetting("addrProxy");
- }
- }
- catch (std::ios_base::failure &e)
- {
- // 0.6.0rc1 saved this as a CService, which causes failure when parsing as a CAddress
- CService addrProxy;
- if (walletdb.ReadSetting("addrProxy", addrProxy))
- {
- settings.setValue("addrProxy", addrProxy.ToStringIPPort().c_str());
- walletdb.EraseSetting("addrProxy");
- }
- }
-#endif
-
- Init();
}
int OptionsModel::rowCount(const QModelIndex & parent) const
@@ -243,6 +190,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
// Todo: Consider to revert back to use just nTransactionFee here, if we don't want
// -paytxfee to update our QSettings!
return settings.value("nTransactionFee");
+ case SpendZeroConfChange:
+ return settings.value("bSpendZeroConfChange");
#endif
case DisplayUnit:
return nDisplayUnit;
@@ -333,6 +282,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("nTransactionFee", (qint64)nTransactionFee);
emit transactionFeeChanged(nTransactionFee);
break;
+ case SpendZeroConfChange:
+ if (settings.value("bSpendZeroConfChange") != value) {
+ settings.setValue("bSpendZeroConfChange", value);
+ setRestartRequired(true);
+ }
+ break;
#endif
case DisplayUnit:
nDisplayUnit = value.toInt();
@@ -375,14 +330,25 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
return successful;
}
-bool OptionsModel::getProxySettings(QString& proxyIP, quint16 &proxyPort) const
+bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
{
- std::string proxy = GetArg("-proxy", "");
- if (proxy.empty()) return false;
+ // Directly query current base proxy, because
+ // GUI settings can be overridden with -proxy.
+ proxyType curProxy;
+ if (GetProxy(NET_IPV4, curProxy)) {
+ if (curProxy.second == 5) {
+ proxy.setType(QNetworkProxy::Socks5Proxy);
+ proxy.setHostName(QString::fromStdString(curProxy.first.ToStringIP()));
+ proxy.setPort(curProxy.first.GetPort());
+
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ proxy.setType(QNetworkProxy::NoProxy);
- CService addrProxy(proxy);
- proxyIP = QString(addrProxy.ToStringIP().c_str());
- proxyPort = addrProxy.GetPort();
return true;
}