2014-02-08 22:50:24 +01:00
|
|
|
// Copyright (c) 2011-2014 The Bitcoin developers
|
2013-11-04 16:20:43 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2013-05-28 01:55:01 +02:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include "bitcoin-config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
#include "optionsmodel.h"
|
2011-06-26 19:23:24 +02:00
|
|
|
|
2013-01-23 21:51:02 +01:00
|
|
|
#include "bitcoinunits.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "guiutil.h"
|
|
|
|
|
2011-12-20 00:49:07 +01:00
|
|
|
#include "init.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "main.h"
|
|
|
|
#include "net.h"
|
2014-02-16 22:00:12 +01:00
|
|
|
#include "txdb.h" // for -dbcache defaults
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-12-13 16:14:48 +01:00
|
|
|
#include "wallet.h"
|
2012-04-15 23:39:49 +02:00
|
|
|
#include "walletdb.h"
|
2013-12-11 15:00:56 +01:00
|
|
|
#endif
|
2011-05-31 22:24:53 +02:00
|
|
|
|
2013-12-20 18:47:49 +01:00
|
|
|
#include <QNetworkProxy>
|
2013-01-23 21:51:02 +01:00
|
|
|
#include <QSettings>
|
2013-12-03 09:10:10 +01:00
|
|
|
#include <QStringList>
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2012-02-17 03:09:41 +01:00
|
|
|
OptionsModel::OptionsModel(QObject *parent) :
|
|
|
|
QAbstractListModel(parent)
|
2011-05-31 22:24:53 +02:00
|
|
|
{
|
2012-02-17 03:09:41 +01:00
|
|
|
Init();
|
2011-05-31 22:24:53 +02:00
|
|
|
}
|
|
|
|
|
2014-03-14 07:22:59 +01:00
|
|
|
void OptionsModel::addOverriddenOption(const std::string &option)
|
|
|
|
{
|
|
|
|
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(mapArgs[option]) + " ";
|
|
|
|
}
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// Writes all missing QSettings with their default values
|
2012-02-17 03:09:41 +01:00
|
|
|
void OptionsModel::Init()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// Ensure restart flag is unset on client startup
|
|
|
|
setRestartRequired(false);
|
|
|
|
|
2012-07-07 16:35:29 +02:00
|
|
|
// These are Qt-only settings:
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
// Window
|
|
|
|
if (!settings.contains("fMinimizeToTray"))
|
|
|
|
settings.setValue("fMinimizeToTray", false);
|
|
|
|
fMinimizeToTray = settings.value("fMinimizeToTray").toBool();
|
|
|
|
|
|
|
|
if (!settings.contains("fMinimizeOnClose"))
|
|
|
|
settings.setValue("fMinimizeOnClose", false);
|
|
|
|
fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool();
|
|
|
|
|
|
|
|
// Display
|
|
|
|
if (!settings.contains("nDisplayUnit"))
|
|
|
|
settings.setValue("nDisplayUnit", BitcoinUnits::BTC);
|
|
|
|
nDisplayUnit = settings.value("nDisplayUnit").toInt();
|
|
|
|
|
|
|
|
if (!settings.contains("bDisplayAddresses"))
|
|
|
|
settings.setValue("bDisplayAddresses", false);
|
2012-02-17 03:09:41 +01:00
|
|
|
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
|
2013-12-03 09:10:10 +01:00
|
|
|
|
2014-04-24 22:21:45 +02:00
|
|
|
if (!settings.contains("strThirdPartyTxUrls"))
|
|
|
|
settings.setValue("strThirdPartyTxUrls", "");
|
|
|
|
strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
if (!settings.contains("fCoinControlFeatures"))
|
|
|
|
settings.setValue("fCoinControlFeatures", false);
|
2013-08-12 17:03:03 +02:00
|
|
|
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
|
2012-02-17 03:09:41 +01:00
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// These are shared with the core or have a command-line parameter
|
|
|
|
// and we want command-line parameters to overwrite the GUI settings.
|
|
|
|
//
|
|
|
|
// If setting doesn't exist create it with defaults.
|
|
|
|
//
|
|
|
|
// If SoftSetArg() or SoftSetBoolArg() return false we were overridden
|
|
|
|
// by command-line and show this in the UI.
|
|
|
|
|
|
|
|
// Main
|
2014-02-18 12:48:16 +01:00
|
|
|
if (!settings.contains("nDatabaseCache"))
|
|
|
|
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
|
|
|
|
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
|
|
|
|
addOverriddenOption("-dbcache");
|
|
|
|
|
|
|
|
if (!settings.contains("nThreadsScriptVerif"))
|
|
|
|
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
|
|
|
|
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
|
|
|
|
addOverriddenOption("-par");
|
|
|
|
|
|
|
|
// Wallet
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-12-03 09:10:10 +01:00
|
|
|
if (!settings.contains("nTransactionFee"))
|
2014-05-08 12:22:47 +02:00
|
|
|
settings.setValue("nTransactionFee", (qint64)DEFAULT_TRANSACTION_FEE);
|
2014-04-10 20:14:18 +02:00
|
|
|
payTxFee = CFeeRate(settings.value("nTransactionFee").toLongLong()); // if -paytxfee is set, this will be overridden later in init.cpp
|
2014-02-02 01:59:57 +01:00
|
|
|
if (mapArgs.count("-paytxfee"))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-paytxfee");
|
2014-02-15 10:38:06 +01:00
|
|
|
|
|
|
|
if (!settings.contains("bSpendZeroConfChange"))
|
|
|
|
settings.setValue("bSpendZeroConfChange", true);
|
|
|
|
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-spendzeroconfchange");
|
2013-12-11 15:00:56 +01:00
|
|
|
#endif
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
// Network
|
|
|
|
if (!settings.contains("fUseUPnP"))
|
2014-05-05 21:06:14 +02:00
|
|
|
settings.setValue("fUseUPnP", DEFAULT_UPNP);
|
2013-12-03 09:10:10 +01:00
|
|
|
if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-upnp");
|
2013-12-03 09:10:10 +01:00
|
|
|
|
2014-05-29 13:02:22 +02:00
|
|
|
if (!settings.contains("fListen"))
|
|
|
|
settings.setValue("fListen", DEFAULT_LISTEN);
|
|
|
|
if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
|
|
|
|
addOverriddenOption("-listen");
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
if (!settings.contains("fUseProxy"))
|
|
|
|
settings.setValue("fUseProxy", false);
|
|
|
|
if (!settings.contains("addrProxy"))
|
|
|
|
settings.setValue("addrProxy", "127.0.0.1:9050");
|
|
|
|
// Only try to set -proxy, if user has enabled fUseProxy
|
|
|
|
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-proxy");
|
2013-12-03 09:10:10 +01:00
|
|
|
if (!settings.contains("nSocksVersion"))
|
|
|
|
settings.setValue("nSocksVersion", 5);
|
|
|
|
// Only try to set -socks, if user has enabled fUseProxy
|
|
|
|
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-socks", settings.value("nSocksVersion").toString().toStdString()))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-socks");
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
// Display
|
|
|
|
if (!settings.contains("language"))
|
|
|
|
settings.setValue("language", "");
|
|
|
|
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
|
2014-03-14 07:22:59 +01:00
|
|
|
addOverriddenOption("-lang");
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
language = settings.value("language").toString();
|
2012-02-17 03:09:41 +01:00
|
|
|
}
|
|
|
|
|
2012-08-18 15:54:39 +02:00
|
|
|
void OptionsModel::Reset()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// Remove all entries from our QSettings object
|
2012-08-18 15:54:39 +02:00
|
|
|
settings.clear();
|
|
|
|
|
|
|
|
// default setting for OptionsModel::StartAtStartup - disabled
|
|
|
|
if (GUIUtil::GetStartOnSystemStartup())
|
|
|
|
GUIUtil::SetStartOnSystemStartup(false);
|
2012-02-17 03:09:41 +01:00
|
|
|
}
|
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
int OptionsModel::rowCount(const QModelIndex & parent) const
|
|
|
|
{
|
|
|
|
return OptionIDRowCount;
|
|
|
|
}
|
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// read QSettings values and return them
|
2011-05-31 22:24:53 +02:00
|
|
|
QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|
|
|
{
|
|
|
|
if(role == Qt::EditRole)
|
|
|
|
{
|
2012-02-17 03:09:41 +01:00
|
|
|
QSettings settings;
|
2011-05-31 22:24:53 +02:00
|
|
|
switch(index.row())
|
|
|
|
{
|
|
|
|
case StartAtStartup:
|
2013-12-03 09:10:10 +01:00
|
|
|
return GUIUtil::GetStartOnSystemStartup();
|
2011-05-31 22:24:53 +02:00
|
|
|
case MinimizeToTray:
|
2013-12-03 09:10:10 +01:00
|
|
|
return fMinimizeToTray;
|
2011-05-31 22:24:53 +02:00
|
|
|
case MapPortUPnP:
|
2012-12-12 08:31:30 +01:00
|
|
|
#ifdef USE_UPNP
|
2013-12-03 09:10:10 +01:00
|
|
|
return settings.value("fUseUPnP");
|
2012-12-12 08:31:30 +01:00
|
|
|
#else
|
2013-12-03 09:10:10 +01:00
|
|
|
return false;
|
2012-12-12 08:31:30 +01:00
|
|
|
#endif
|
2011-05-31 22:24:53 +02:00
|
|
|
case MinimizeOnClose:
|
2013-12-03 09:10:10 +01:00
|
|
|
return fMinimizeOnClose;
|
|
|
|
|
|
|
|
// default proxy
|
|
|
|
case ProxyUse:
|
|
|
|
return settings.value("fUseProxy", false);
|
2012-05-24 19:02:21 +02:00
|
|
|
case ProxyIP: {
|
2013-12-03 09:10:10 +01:00
|
|
|
// contains IP at index 0 and port at index 1
|
|
|
|
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
|
|
|
|
return strlIpPort.at(0);
|
2012-05-24 19:02:21 +02:00
|
|
|
}
|
|
|
|
case ProxyPort: {
|
2013-12-03 09:10:10 +01:00
|
|
|
// contains IP at index 0 and port at index 1
|
|
|
|
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
|
|
|
|
return strlIpPort.at(1);
|
2012-10-02 13:30:44 +02:00
|
|
|
}
|
2013-12-03 09:10:10 +01:00
|
|
|
case ProxySocksVersion:
|
|
|
|
return settings.value("nSocksVersion", 5);
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2014-04-10 20:14:18 +02:00
|
|
|
case Fee: {
|
|
|
|
// Attention: Init() is called before payTxFee is set in AppInit2()!
|
2013-12-03 09:10:10 +01:00
|
|
|
// To ensure we can change the fee on-the-fly update our QSetting when
|
|
|
|
// opening OptionsDialog, which queries Fee via the mapper.
|
2014-04-10 20:14:18 +02:00
|
|
|
if (!(payTxFee == CFeeRate(settings.value("nTransactionFee").toLongLong(), 1000)))
|
|
|
|
settings.setValue("nTransactionFee", (qint64)payTxFee.GetFeePerK());
|
|
|
|
// Todo: Consider to revert back to use just payTxFee here, if we don't want
|
2013-12-03 09:10:10 +01:00
|
|
|
// -paytxfee to update our QSettings!
|
|
|
|
return settings.value("nTransactionFee");
|
2014-04-10 20:14:18 +02:00
|
|
|
}
|
2014-02-15 10:38:06 +01:00
|
|
|
case SpendZeroConfChange:
|
|
|
|
return settings.value("bSpendZeroConfChange");
|
2013-12-11 15:00:56 +01:00
|
|
|
#endif
|
2011-07-29 14:36:35 +02:00
|
|
|
case DisplayUnit:
|
2013-12-03 09:10:10 +01:00
|
|
|
return nDisplayUnit;
|
2011-07-30 17:42:02 +02:00
|
|
|
case DisplayAddresses:
|
2013-12-03 09:10:10 +01:00
|
|
|
return bDisplayAddresses;
|
2014-04-24 22:21:45 +02:00
|
|
|
case ThirdPartyTxUrls:
|
|
|
|
return strThirdPartyTxUrls;
|
2012-05-08 23:03:41 +02:00
|
|
|
case Language:
|
2013-12-03 09:10:10 +01:00
|
|
|
return settings.value("language");
|
2013-08-12 17:03:03 +02:00
|
|
|
case CoinControlFeatures:
|
2013-12-03 09:10:10 +01:00
|
|
|
return fCoinControlFeatures;
|
|
|
|
case DatabaseCache:
|
|
|
|
return settings.value("nDatabaseCache");
|
|
|
|
case ThreadsScriptVerif:
|
|
|
|
return settings.value("nThreadsScriptVerif");
|
2014-05-29 13:02:22 +02:00
|
|
|
case Listen:
|
|
|
|
return settings.value("fListen");
|
2011-05-31 22:24:53 +02:00
|
|
|
default:
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
2012-09-23 12:55:05 +02:00
|
|
|
|
2013-12-03 09:10:10 +01:00
|
|
|
// write QSettings values
|
2011-05-31 22:24:53 +02:00
|
|
|
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
|
|
|
|
{
|
2011-06-01 14:40:06 +02:00
|
|
|
bool successful = true; /* set to false on parse error */
|
|
|
|
if(role == Qt::EditRole)
|
|
|
|
{
|
2012-02-17 03:09:41 +01:00
|
|
|
QSettings settings;
|
2011-06-01 14:40:06 +02:00
|
|
|
switch(index.row())
|
|
|
|
{
|
|
|
|
case StartAtStartup:
|
2012-05-01 18:44:11 +02:00
|
|
|
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
|
|
|
case MinimizeToTray:
|
|
|
|
fMinimizeToTray = value.toBool();
|
2012-02-17 03:09:41 +01:00
|
|
|
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
2013-12-03 09:10:10 +01:00
|
|
|
case MapPortUPnP: // core option - can be changed on-the-fly
|
2013-03-07 04:31:26 +01:00
|
|
|
settings.setValue("fUseUPnP", value.toBool());
|
|
|
|
MapPort(value.toBool());
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
|
|
|
case MinimizeOnClose:
|
|
|
|
fMinimizeOnClose = value.toBool();
|
2012-02-17 03:09:41 +01:00
|
|
|
settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
// default proxy
|
2012-05-24 19:02:21 +02:00
|
|
|
case ProxyUse:
|
2013-12-03 09:10:10 +01:00
|
|
|
if (settings.value("fUseProxy") != value) {
|
|
|
|
settings.setValue("fUseProxy", value.toBool());
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
2012-09-23 12:55:05 +02:00
|
|
|
case ProxyIP: {
|
2013-12-03 09:10:10 +01:00
|
|
|
// contains current IP at index 0 and current port at index 1
|
|
|
|
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
|
|
|
|
// if that key doesn't exist or has a changed IP
|
|
|
|
if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) {
|
|
|
|
// construct new value from new IP and current port
|
|
|
|
QString strNewValue = value.toString() + ":" + strlIpPort.at(1);
|
|
|
|
settings.setValue("addrProxy", strNewValue);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
2012-09-23 12:55:05 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ProxyPort: {
|
2013-12-03 09:10:10 +01:00
|
|
|
// contains current IP at index 0 and current port at index 1
|
|
|
|
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
|
|
|
|
// if that key doesn't exist or has a changed port
|
|
|
|
if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) {
|
|
|
|
// construct new value from current IP and new port
|
|
|
|
QString strNewValue = strlIpPort.at(0) + ":" + value.toString();
|
|
|
|
settings.setValue("addrProxy", strNewValue);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
2012-09-23 12:55:05 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ProxySocksVersion: {
|
2013-12-03 09:10:10 +01:00
|
|
|
if (settings.value("nSocksVersion") != value) {
|
|
|
|
settings.setValue("nSocksVersion", value.toInt());
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
2012-09-23 12:55:05 +02:00
|
|
|
}
|
|
|
|
break;
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2014-04-10 20:14:18 +02:00
|
|
|
case Fee: { // core option - can be changed on-the-fly
|
2013-12-03 09:10:10 +01:00
|
|
|
// Todo: Add is valid check and warn via message, if not
|
2014-04-10 20:14:18 +02:00
|
|
|
qint64 nTransactionFee = value.toLongLong();
|
|
|
|
payTxFee = CFeeRate(nTransactionFee, 1000);
|
|
|
|
settings.setValue("nTransactionFee", nTransactionFee);
|
2013-08-12 17:03:03 +02:00
|
|
|
emit transactionFeeChanged(nTransactionFee);
|
2011-06-01 14:40:06 +02:00
|
|
|
break;
|
2014-04-10 20:14:18 +02:00
|
|
|
}
|
2014-02-15 10:38:06 +01:00
|
|
|
case SpendZeroConfChange:
|
|
|
|
if (settings.value("bSpendZeroConfChange") != value) {
|
|
|
|
settings.setValue("bSpendZeroConfChange", value);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
|
|
|
break;
|
2013-12-11 15:00:56 +01:00
|
|
|
#endif
|
2012-07-09 13:40:22 +02:00
|
|
|
case DisplayUnit:
|
|
|
|
nDisplayUnit = value.toInt();
|
2012-02-17 03:09:41 +01:00
|
|
|
settings.setValue("nDisplayUnit", nDisplayUnit);
|
2012-07-09 13:40:22 +02:00
|
|
|
emit displayUnitChanged(nDisplayUnit);
|
2012-04-17 23:27:59 +02:00
|
|
|
break;
|
2012-07-09 13:40:22 +02:00
|
|
|
case DisplayAddresses:
|
2011-07-30 17:42:02 +02:00
|
|
|
bDisplayAddresses = value.toBool();
|
2012-02-17 03:09:41 +01:00
|
|
|
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
2012-04-17 23:27:59 +02:00
|
|
|
break;
|
2014-04-24 22:21:45 +02:00
|
|
|
case ThirdPartyTxUrls:
|
|
|
|
if (strThirdPartyTxUrls != value.toString()) {
|
|
|
|
strThirdPartyTxUrls = value.toString();
|
|
|
|
settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
|
|
|
break;
|
2012-07-09 13:40:22 +02:00
|
|
|
case Language:
|
2013-12-03 09:10:10 +01:00
|
|
|
if (settings.value("language") != value) {
|
|
|
|
settings.setValue("language", value);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
2012-05-08 23:03:41 +02:00
|
|
|
break;
|
2013-11-16 17:37:31 +01:00
|
|
|
case CoinControlFeatures:
|
2013-08-12 17:03:03 +02:00
|
|
|
fCoinControlFeatures = value.toBool();
|
|
|
|
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
|
|
|
|
emit coinControlFeaturesChanged(fCoinControlFeatures);
|
2013-11-16 17:37:31 +01:00
|
|
|
break;
|
2013-12-03 09:10:10 +01:00
|
|
|
case DatabaseCache:
|
|
|
|
if (settings.value("nDatabaseCache") != value) {
|
|
|
|
settings.setValue("nDatabaseCache", value);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ThreadsScriptVerif:
|
|
|
|
if (settings.value("nThreadsScriptVerif") != value) {
|
|
|
|
settings.setValue("nThreadsScriptVerif", value);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
|
|
|
break;
|
2014-05-29 13:02:22 +02:00
|
|
|
case Listen:
|
|
|
|
if (settings.value("fListen") != value) {
|
|
|
|
settings.setValue("fListen", value);
|
|
|
|
setRestartRequired(true);
|
|
|
|
}
|
|
|
|
break;
|
2011-06-01 14:40:06 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-05-31 22:24:53 +02:00
|
|
|
emit dataChanged(index, index);
|
2011-06-01 14:40:06 +02:00
|
|
|
|
|
|
|
return successful;
|
2011-05-31 22:24:53 +02:00
|
|
|
}
|
2011-06-01 09:34:12 +02:00
|
|
|
|
2013-12-20 18:47:49 +01:00
|
|
|
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
|
2013-07-22 08:50:39 +02:00
|
|
|
{
|
2013-12-20 18:47:49 +01:00
|
|
|
// 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);
|
2013-07-22 08:50:39 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-03 09:10:10 +01:00
|
|
|
|
|
|
|
void OptionsModel::setRestartRequired(bool fRequired)
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
return settings.setValue("fRestartRequired", fRequired);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OptionsModel::isRestartRequired()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
return settings.value("fRestartRequired", false).toBool();
|
|
|
|
}
|