5 #if defined(HAVE_CONFIG_H) 17 #include <validation.h> 28 #include <QNetworkProxy> 30 #include <QStringList> 34 QAbstractListModel(parent)
60 if (!settings.contains(
"fHideTrayIcon"))
61 settings.setValue(
"fHideTrayIcon",
false);
65 if (!settings.contains(
"fMinimizeToTray"))
66 settings.setValue(
"fMinimizeToTray",
false);
69 if (!settings.contains(
"fMinimizeOnClose"))
70 settings.setValue(
"fMinimizeOnClose",
false);
74 if (!settings.contains(
"nDisplayUnit"))
78 if (!settings.contains(
"strThirdPartyTxUrls"))
79 settings.setValue(
"strThirdPartyTxUrls",
"");
82 if (!settings.contains(
"fCoinControlFeatures"))
83 settings.setValue(
"fCoinControlFeatures",
false);
95 if (!settings.contains(
"nDatabaseCache"))
96 settings.setValue(
"nDatabaseCache", (qint64)nDefaultDbCache);
97 if (!
gArgs.
SoftSetArg(
"-dbcache", settings.value(
"nDatabaseCache").toString().toStdString()))
100 if (!settings.contains(
"fLogEvents"))
105 if (!settings.contains(
"nReserveBalance"))
110 nReserveBalance = settings.value(
"nReserveBalance").toLongLong();
114 if (!settings.contains(
"nThreadsScriptVerif"))
115 settings.setValue(
"nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
116 if (!
gArgs.
SoftSetArg(
"-par", settings.value(
"nThreadsScriptVerif").toString().toStdString()))
119 if (!settings.contains(
"strDataDir"))
124 if (!settings.contains(
"bSpendZeroConfChange"))
125 settings.setValue(
"bSpendZeroConfChange",
true);
126 if (!
gArgs.
SoftSetBoolArg(
"-spendzeroconfchange", settings.value(
"bSpendZeroConfChange").toBool()))
129 if (!settings.contains(
"bZeroBalanceAddressToken"))
130 settings.setValue(
"bZeroBalanceAddressToken",
true);
131 if (!
gArgs.
SoftSetBoolArg(
"-zerobalanceaddresstoken", settings.value(
"bZeroBalanceAddressToken").toBool()))
134 if (!settings.contains(
"fCheckForUpdates"))
135 settings.setValue(
"fCheckForUpdates", DEFAULT_CHECK_FOR_UPDATES);
139 if (!settings.contains(
"fUseUPnP"))
140 settings.setValue(
"fUseUPnP", DEFAULT_UPNP);
144 if (!settings.contains(
"fListen"))
145 settings.setValue(
"fListen", DEFAULT_LISTEN);
149 if (!settings.contains(
"fNotUseChangeAddress"))
150 settings.setValue(
"fNotUseChangeAddress", DEFAULT_NOT_USE_CHANGE_ADDRESS);
153 if (!settings.contains(
"fUseProxy"))
154 settings.setValue(
"fUseProxy",
false);
155 if (!settings.contains(
"addrProxy"))
156 settings.setValue(
"addrProxy",
"127.0.0.1:9050");
158 if (settings.value(
"fUseProxy").toBool() && !
gArgs.
SoftSetArg(
"-proxy", settings.value(
"addrProxy").toString().toStdString()))
160 else if(!settings.value(
"fUseProxy").toBool() && !
gArgs.
GetArg(
"-proxy",
"").empty())
163 if (!settings.contains(
"fUseSeparateProxyTor"))
164 settings.setValue(
"fUseSeparateProxyTor",
false);
165 if (!settings.contains(
"addrSeparateProxyTor"))
166 settings.setValue(
"addrSeparateProxyTor",
"127.0.0.1:9050");
168 if (settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
SoftSetArg(
"-onion", settings.value(
"addrSeparateProxyTor").toString().toStdString()))
170 else if(!settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
GetArg(
"-onion",
"").empty())
174 if (!settings.contains(
"language"))
175 settings.setValue(
"language",
"");
176 if (!
gArgs.
SoftSetArg(
"-lang", settings.value(
"language").toString().toStdString()))
179 language = settings.value(
"language").toString();
185 static void CopySettings(QSettings& dst,
const QSettings& src)
187 for (
const QString& key : src.allKeys()) {
188 dst.setValue(key, src.value(key));
193 static void BackupSettings(
const fs::path& filename,
const QSettings& src)
198 CopySettings(dst, src);
206 BackupSettings(
GetDataDir(
true) /
"guisettings.ini.bak", settings);
210 dataDir = settings.value(
"strDataDir", dataDir).toString();
216 settings.setValue(
"strDataDir", dataDir);
219 settings.setValue(
"fReset",
true);
234 if(role == Qt::EditRole)
247 return settings.value(
"fUseUPnP");
256 return settings.value(
"fUseProxy",
false);
259 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
260 return strlIpPort.at(0);
264 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
265 return strlIpPort.at(1);
270 return settings.value(
"fUseSeparateProxyTor",
false);
273 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
274 return strlIpPort.at(0);
278 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
279 return strlIpPort.at(1);
284 return settings.value(
"bSpendZeroConfChange");
287 return settings.value(
"bZeroBalanceAddressToken");
295 return settings.value(
"language");
299 return settings.value(
"nDatabaseCache");
301 return settings.value(
"fLogEvents");
303 return settings.value(
"nThreadsScriptVerif");
305 return settings.value(
"fListen");
307 return settings.value(
"fNotUseChangeAddress");
309 return settings.value(
"fCheckForUpdates");
320 bool successful =
true;
321 if(role == Qt::EditRole)
339 settings.setValue(
"fUseUPnP", value.toBool());
349 if (settings.value(
"fUseProxy") != value) {
350 settings.setValue(
"fUseProxy", value.toBool());
356 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
358 if (!settings.contains(
"addrProxy") || strlIpPort.at(0) != value.toString()) {
360 QString strNewValue = value.toString() +
":" + strlIpPort.at(1);
361 settings.setValue(
"addrProxy", strNewValue);
368 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
370 if (!settings.contains(
"addrProxy") || strlIpPort.at(1) != value.toString()) {
372 QString strNewValue = strlIpPort.at(0) +
":" + value.toString();
373 settings.setValue(
"addrProxy", strNewValue);
381 if (settings.value(
"fUseSeparateProxyTor") != value) {
382 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
388 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
390 if (!settings.contains(
"addrSeparateProxyTor") || strlIpPort.at(0) != value.toString()) {
392 QString strNewValue = value.toString() +
":" + strlIpPort.at(1);
393 settings.setValue(
"addrSeparateProxyTor", strNewValue);
400 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
402 if (!settings.contains(
"addrSeparateProxyTor") || strlIpPort.at(1) != value.toString()) {
404 QString strNewValue = strlIpPort.at(0) +
":" + value.toString();
405 settings.setValue(
"addrSeparateProxyTor", strNewValue);
413 if (settings.value(
"bSpendZeroConfChange") != value) {
414 settings.setValue(
"bSpendZeroConfChange", value);
435 if (settings.value(
"language") != value) {
436 settings.setValue(
"language", value);
446 if (settings.value(
"nDatabaseCache") != value) {
447 settings.setValue(
"nDatabaseCache", value);
452 if (settings.value(
"fLogEvents") != value) {
453 settings.setValue(
"fLogEvents", value);
458 if (settings.value(
"nReserveBalance") != value) {
459 settings.setValue(
"nReserveBalance", value);
465 if (settings.value(
"nThreadsScriptVerif") != value) {
466 settings.setValue(
"nThreadsScriptVerif", value);
471 if (settings.value(
"fListen") != value) {
472 settings.setValue(
"fListen", value);
477 if (settings.value(
"fNotUseChangeAddress") != value) {
478 settings.setValue(
"fNotUseChangeAddress", value);
483 if (settings.value(
"fCheckForUpdates") != value) {
484 settings.setValue(
"fCheckForUpdates", value);
493 Q_EMIT dataChanged(index, index);
516 proxy.setType(QNetworkProxy::Socks5Proxy);
517 proxy.setHostName(QString::fromStdString(curProxy.
proxy.
ToStringIP()));
523 proxy.setType(QNetworkProxy::NoProxy);
531 return settings.setValue(
"fRestartRequired", fRequired);
537 return settings.value(
"fRestartRequired",
false).toBool();
545 static const char strSettingsVersionKey[] =
"nSettingsVersion";
546 int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0;
547 if (settingsVersion < CLIENT_VERSION)
552 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") && settings.value(
"nDatabaseCache").toLongLong() == 100)
553 settings.setValue(
"nDatabaseCache", (qint64)nDefaultDbCache);
555 settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
unsigned short GetPort() const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void addOverriddenOption(const std::string &option)
void hideTrayIconChanged(bool)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
std::string ToStringIP() const
CAmount nReserveBalance
Settings.
bool GetStartOnSystemStartup()
void coinControlFeaturesChanged(bool)
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
static QString getDefaultDataDirectory()
Determine default data directory for operating system.
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
OptionsModel(QObject *parent=0, bool resetSettings=false)
int rowCount(const QModelIndex &parent=QModelIndex()) const
bool getProxySettings(QNetworkProxy &proxy) const
void zeroBalanceAddressTokenChanged(bool)
bool ParseMoney(const std::string &str, CAmount &nRet)
void Init(bool resetSettings=false)
void displayUnitChanged(int unit)
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
bool fCoinControlFeatures
void setRestartRequired(bool fRequired)
void reserveBalanceChanged(CAmount)
QString strThirdPartyTxUrls
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool SetStartOnSystemStartup(bool fAutoStart)
const fs::path & GetDataDir(bool fNetSpecific)
QString boostPathToQString(const fs::path &path)
bool fNotUseChangeAddress
bool bZeroBalanceAddressToken
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QString strOverriddenByCommandLine