6 #if defined(HAVE_CONFIG_H) 17 #include "validation.h" 29 #include <QNetworkProxy> 31 #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);
86 if (!settings.contains(
"fCustomFeeFeatures"))
87 settings.setValue(
"fCustomFeeFeatures",
false);
90 if (!settings.contains(
"fDarkModeEnabled"))
91 settings.setValue(
"fDarkModeEnabled",
false);
103 if (!settings.contains(
"nDatabaseCache"))
104 settings.setValue(
"nDatabaseCache", (qint64)nDefaultDbCache);
105 if (!
gArgs.
SoftSetArg(
"-dbcache", settings.value(
"nDatabaseCache").toString().toStdString()))
108 if (!settings.contains(
"nThreadsScriptVerif"))
109 settings.setValue(
"nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
110 if (!
gArgs.
SoftSetArg(
"-par", settings.value(
"nThreadsScriptVerif").toString().toStdString()))
113 if (!settings.contains(
"strDataDir"))
118 if (!settings.contains(
"bSpendZeroConfChange"))
119 settings.setValue(
"bSpendZeroConfChange",
true);
120 if (!
gArgs.
SoftSetBoolArg(
"-spendzeroconfchange", settings.value(
"bSpendZeroConfChange").toBool()))
125 if (!settings.contains(
"fUseUPnP"))
126 settings.setValue(
"fUseUPnP", DEFAULT_UPNP);
130 if (!settings.contains(
"fListen"))
131 settings.setValue(
"fListen", DEFAULT_LISTEN);
135 if (!settings.contains(
"fUseProxy"))
136 settings.setValue(
"fUseProxy",
false);
137 if (!settings.contains(
"addrProxy") || !settings.value(
"addrProxy").toString().contains(
':'))
138 settings.setValue(
"addrProxy",
"127.0.0.1:9050");
140 if (settings.value(
"fUseProxy").toBool() && !
gArgs.
SoftSetArg(
"-proxy", settings.value(
"addrProxy").toString().toStdString()))
142 else if(!settings.value(
"fUseProxy").toBool() && !
gArgs.
GetArg(
"-proxy",
"").empty())
145 if (!settings.contains(
"fUseSeparateProxyTor"))
146 settings.setValue(
"fUseSeparateProxyTor",
false);
147 if (!settings.contains(
"addrSeparateProxyTor") || !settings.value(
"addrSeparateProxyTor").toString().contains(
':'))
148 settings.setValue(
"addrSeparateProxyTor",
"127.0.0.1:9050");
150 if (settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
SoftSetArg(
"-onion", settings.value(
"addrSeparateProxyTor").toString().toStdString()))
152 else if(!settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
GetArg(
"-onion",
"").empty())
156 if (!settings.contains(
"language"))
157 settings.setValue(
"language",
"");
158 if (!
gArgs.
SoftSetArg(
"-lang", settings.value(
"language").toString().toStdString()))
161 language = settings.value(
"language").toString();
167 static void CopySettings(QSettings& dst,
const QSettings& src)
169 for (
const QString& key : src.allKeys()) {
170 dst.setValue(key, src.value(key));
175 static void BackupSettings(
const fs::path& filename,
const QSettings& src)
180 CopySettings(dst, src);
188 BackupSettings(
GetDataDir(
true) /
"guisettings.ini.bak", settings);
192 dataDir = settings.value(
"strDataDir", dataDir).toString();
198 settings.setValue(
"strDataDir", dataDir);
201 settings.setValue(
"fReset",
true);
216 if(role == Qt::EditRole)
229 return settings.value(
"fUseUPnP");
238 return settings.value(
"fUseProxy",
false);
241 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
242 return strlIpPort.at(0);
246 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
247 return strlIpPort.at(1);
252 return settings.value(
"fUseSeparateProxyTor",
false);
255 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
256 return strlIpPort.at(0);
260 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
261 return strlIpPort.at(1);
266 return settings.value(
"bSpendZeroConfChange");
273 return settings.value(
"language");
277 return settings.value(
"nDatabaseCache");
279 return settings.value(
"nThreadsScriptVerif");
281 return settings.value(
"fListen");
296 bool successful =
true;
297 if(role == Qt::EditRole)
315 settings.setValue(
"fUseUPnP", value.toBool());
325 if (settings.value(
"fUseProxy") != value) {
326 settings.setValue(
"fUseProxy", value.toBool());
332 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
334 if (!settings.contains(
"addrProxy") || strlIpPort.at(0) != value.toString()) {
336 QString strNewValue = value.toString() +
":" + strlIpPort.at(1);
337 settings.setValue(
"addrProxy", strNewValue);
344 QStringList strlIpPort = settings.value(
"addrProxy").toString().split(
":", QString::SkipEmptyParts);
346 if (!settings.contains(
"addrProxy") || strlIpPort.at(1) != value.toString()) {
348 QString strNewValue = strlIpPort.at(0) +
":" + value.toString();
349 settings.setValue(
"addrProxy", strNewValue);
357 if (settings.value(
"fUseSeparateProxyTor") != value) {
358 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
364 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
366 if (!settings.contains(
"addrSeparateProxyTor") || strlIpPort.at(0) != value.toString()) {
368 QString strNewValue = value.toString() +
":" + strlIpPort.at(1);
369 settings.setValue(
"addrSeparateProxyTor", strNewValue);
376 QStringList strlIpPort = settings.value(
"addrSeparateProxyTor").toString().split(
":", QString::SkipEmptyParts);
378 if (!settings.contains(
"addrSeparateProxyTor") || strlIpPort.at(1) != value.toString()) {
380 QString strNewValue = strlIpPort.at(0) +
":" + value.toString();
381 settings.setValue(
"addrSeparateProxyTor", strNewValue);
389 if (settings.value(
"bSpendZeroConfChange") != value) {
390 settings.setValue(
"bSpendZeroConfChange", value);
406 if (settings.value(
"language") != value) {
407 settings.setValue(
"language", value);
417 if (settings.value(
"nDatabaseCache") != value) {
418 settings.setValue(
"nDatabaseCache", value);
423 if (settings.value(
"nThreadsScriptVerif") != value) {
424 settings.setValue(
"nThreadsScriptVerif", value);
429 if (settings.value(
"fListen") != value) {
430 settings.setValue(
"fListen", value);
448 Q_EMIT dataChanged(index, index);
471 proxy.setType(QNetworkProxy::Socks5Proxy);
472 proxy.setHostName(QString::fromStdString(curProxy.
proxy.
ToStringIP()));
478 proxy.setType(QNetworkProxy::NoProxy);
486 return settings.setValue(
"fRestartRequired", fRequired);
492 return settings.value(
"fRestartRequired",
false).toBool();
500 static const char strSettingsVersionKey[] =
"nSettingsVersion";
501 int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0;
502 if (settingsVersion < CLIENT_VERSION)
507 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") && settings.value(
"nDatabaseCache").toLongLong() == 100)
508 settings.setValue(
"nDatabaseCache", (qint64)nDefaultDbCache);
510 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.
bool getProxySettings(QNetworkProxy &proxy) const
bool GetStartOnSystemStartup()
void coinControlFeaturesChanged(bool)
void customFeeFeaturesChanged(bool)
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
bool isRestartRequired() const
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)
std::string ToStringIP() const
void Init(bool resetSettings=false)
void displayUnitChanged(int unit)
bool fCoinControlFeatures
bool fCustomFeeFeatures
RVN START.
void setRestartRequired(bool fRequired)
QString strThirdPartyTxUrls
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
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)
int rowCount(const QModelIndex &parent=QModelIndex()) const
QString strOverriddenByCommandLine
RVN END.