5#if defined(HAVE_CONFIG_H)
21#include <validation.h>
33 QAbstractListModel(parent)
59 if (!settings.contains(
"fHideTrayIcon")) {
60 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(
"bPrune"))
96 settings.setValue(
"bPrune",
false);
97 if (!settings.contains(
"nPruneSize"))
101 if (!settings.contains(
"nDatabaseCache"))
103 if (!
gArgs.
SoftSetArg(
"-dbcache", settings.value(
"nDatabaseCache").toString().toStdString()))
106 if (!settings.contains(
"nThreadsScriptVerif"))
108 if (!
gArgs.
SoftSetArg(
"-par", settings.value(
"nThreadsScriptVerif").toString().toStdString()))
111 if (!settings.contains(
"strDataDir"))
116 if (!settings.contains(
"bSpendZeroConfChange"))
117 settings.setValue(
"bSpendZeroConfChange",
true);
118 if (!
gArgs.
SoftSetBoolArg(
"-spendzeroconfchange", settings.value(
"bSpendZeroConfChange").toBool()))
121 if (!settings.contains(
"external_signer_path"))
122 settings.setValue(
"external_signer_path",
"");
124 if (!
gArgs.
SoftSetArg(
"-signer", settings.value(
"external_signer_path").toString().toStdString())) {
128 if (!settings.contains(
"SubFeeFromAmount")) {
129 settings.setValue(
"SubFeeFromAmount",
false);
135 if (!settings.contains(
"fUseUPnP"))
140 if (!settings.contains(
"fUseNatpmp")) {
147 if (!settings.contains(
"fListen"))
152 if (!settings.contains(
"server")) {
153 settings.setValue(
"server",
false);
159 if (!settings.contains(
"fUseProxy"))
160 settings.setValue(
"fUseProxy",
false);
161 if (!settings.contains(
"addrProxy"))
164 if ((settings.value(
"fUseProxy").toBool() && !
gArgs.
SoftSetArg(
"-proxy", settings.value(
"addrProxy").toString().toStdString())))
166 else if(!settings.value(
"fUseProxy").toBool() && !
gArgs.
GetArg(
"-proxy",
"").empty())
169 if (!settings.contains(
"fUseSeparateProxyTor"))
170 settings.setValue(
"fUseSeparateProxyTor",
false);
171 if (!settings.contains(
"addrSeparateProxyTor"))
174 if ((settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
SoftSetArg(
"-onion", settings.value(
"addrSeparateProxyTor").toString().toStdString())))
176 else if(!settings.value(
"fUseSeparateProxyTor").toBool() && !
gArgs.
GetArg(
"-onion",
"").empty())
180 if (!settings.contains(
"language"))
181 settings.setValue(
"language",
"");
182 if (!
gArgs.
SoftSetArg(
"-lang", settings.value(
"language").toString().toStdString()))
185 language = settings.value(
"language").toString();
187 if (!settings.contains(
"UseEmbeddedMonospacedFont")) {
188 settings.setValue(
"UseEmbeddedMonospacedFont",
"true");
199 for (
const QString& key : src.allKeys()) {
200 dst.setValue(key, src.value(key));
222 dataDir = settings.value(
"strDataDir", dataDir).toString();
228 settings.setValue(
"strDataDir", dataDir);
231 settings.setValue(
"fReset",
true);
253 if (!settings.contains(
name)) {
258 if (ip_port.size() == 2) {
259 return {
true, ip_port.at(0), ip_port.at(1)};
267 settings.setValue(
name, QString{ip_port.
ip + QLatin1Char(
':') + ip_port.
port});
278 settings.setValue(
"bPrune", prune);
279 const int64_t prune_target_mib =
PruneGBtoMiB(settings.value(
"nPruneSize").toInt());
280 std::string prune_val = prune ?
ToString(prune_target_mib) :
"0";
292 const bool prune = prune_target_gb > 0;
295 settings.setValue(
"nPruneSize", prune_target_gb);
303 if(role == Qt::EditRole)
316 return settings.value(
"fUseUPnP");
322 return settings.value(
"fUseNatpmp");
331 return settings.value(
"fUseProxy",
false);
339 return settings.value(
"fUseSeparateProxyTor",
false);
347 return settings.value(
"bSpendZeroConfChange");
349 return settings.value(
"external_signer_path");
358 return settings.value(
"language");
364 return settings.value(
"bPrune");
366 return settings.value(
"nPruneSize");
368 return settings.value(
"nDatabaseCache");
370 return settings.value(
"nThreadsScriptVerif");
372 return settings.value(
"fListen");
374 return settings.value(
"server");
385 bool successful =
true;
386 if(role == Qt::EditRole)
404 settings.setValue(
"fUseUPnP", value.toBool());
407 settings.setValue(
"fUseNatpmp", value.toBool());
416 if (settings.value(
"fUseProxy") != value) {
417 settings.setValue(
"fUseProxy", value.toBool());
423 if (!ip_port.is_set || ip_port.ip != value.toString()) {
424 ip_port.ip = value.toString();
432 if (!ip_port.is_set || ip_port.port != value.toString()) {
433 ip_port.port = value.toString();
442 if (settings.value(
"fUseSeparateProxyTor") != value) {
443 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
449 if (!ip_port.is_set || ip_port.ip != value.toString()) {
450 ip_port.ip = value.toString();
458 if (!ip_port.is_set || ip_port.port != value.toString()) {
459 ip_port.port = value.toString();
468 if (settings.value(
"bSpendZeroConfChange") != value) {
469 settings.setValue(
"bSpendZeroConfChange", value);
474 if (settings.value(
"external_signer_path") != value.toString()) {
475 settings.setValue(
"external_signer_path", value.toString());
495 if (settings.value(
"language") != value) {
496 settings.setValue(
"language", value);
511 if (settings.value(
"bPrune") != value) {
512 settings.setValue(
"bPrune", value);
517 if (settings.value(
"nPruneSize") != value) {
518 settings.setValue(
"nPruneSize", value);
523 if (settings.value(
"nDatabaseCache") != value) {
524 settings.setValue(
"nDatabaseCache", value);
529 if (settings.value(
"nThreadsScriptVerif") != value) {
530 settings.setValue(
"nThreadsScriptVerif", value);
535 if (settings.value(
"fListen") != value) {
536 settings.setValue(
"fListen", value);
541 if (settings.value(
"server") != value) {
542 settings.setValue(
"server", value);
551 Q_EMIT dataChanged(index, index);
571 return settings.setValue(
"fRestartRequired", fRequired);
577 return settings.value(
"fRestartRequired",
false).toBool();
585 static const char strSettingsVersionKey[] =
"nSettingsVersion";
586 int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0;
592 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") && settings.value(
"nDatabaseCache").toLongLong() == 100)
600 if (settings.contains(
"addrProxy") && settings.value(
"addrProxy").toString().endsWith(
"%2")) {
606 if (settings.contains(
"addrSeparateProxyTor") && settings.value(
"addrSeparateProxyTor").toString().endsWith(
"%2")) {
void ForceSetArg(const std::string &strArg, const std::string &strValue)
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QString strOverriddenByCommandLine
bool m_use_embedded_monospaced_font
bool isRestartRequired() const
void Init(bool resetSettings=false)
bool fCoinControlFeatures
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
OptionsModel(QObject *parent=nullptr, bool resetSettings=false)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool m_sub_fee_from_amount
void SetPruneTargetGB(int prune_target_gb, bool force=false)
@ UseEmbeddedMonospacedFont
void SetPruneEnabled(bool prune, bool force=false)
void displayUnitChanged(int unit)
void showTrayIconChanged(bool)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void addOverriddenOption(const std::string &option)
void useEmbeddedMonospacedFontChanged(bool)
void setRestartRequired(bool fRequired)
Path class wrapper to prepare application code for transition from boost::filesystem library to std::...
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
static constexpr int DEFAULT_PRUNE_TARGET_GB
static constexpr bool DEFAULT_NATPMP
static constexpr bool DEFAULT_UPNP
QString getDefaultDataDirectory()
Determine default data directory for operating system.
QString boostPathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
bool SetStartOnSystemStartup(bool fAutoStart)
bool GetStartOnSystemStartup()
QStringList SplitSkipEmptyParts(const QString &string, const SeparatorType &separator)
Splits the string into substrings wherever separator occurs, and returns the list of those strings.
static const bool DEFAULT_LISTEN
-listen default
static void CopySettings(QSettings &dst, const QSettings &src)
Helper function to copy contents from one QSettings to another.
static const QString GetDefaultProxyAddress()
static ProxySetting GetProxySetting(QSettings &settings, const QString &name)
static void SetProxySetting(QSettings &settings, const QString &name, const ProxySetting &ip_port)
static void BackupSettings(const fs::path &filename, const QSettings &src)
Back up a QSettings to an ini-formatted file.
const char * DEFAULT_GUI_PROXY_HOST
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static const int64_t nDefaultDbCache
-dbcache default (MiB)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)