5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
21#include <validation.h>
25#include <QNetworkProxy>
35 : QAbstractListModel(parent) {
41 QString::fromStdString(option) +
"=" +
42 QString::fromStdString(
gArgs.
GetArg(option,
"")) +
" ";
61 if (!settings.contains(
"fHideTrayIcon")) {
62 settings.setValue(
"fHideTrayIcon",
false);
67 if (!settings.contains(
"fMinimizeToTray")) {
68 settings.setValue(
"fMinimizeToTray",
false);
73 if (!settings.contains(
"fMinimizeOnClose")) {
74 settings.setValue(
"fMinimizeOnClose",
false);
79 if (!settings.contains(
"nDisplayUnit")) {
84 if (!settings.contains(
"strThirdPartyTxUrls")) {
85 settings.setValue(
"strThirdPartyTxUrls",
"");
89 if (!settings.contains(
"fCoinControlFeatures")) {
90 settings.setValue(
"fCoinControlFeatures",
false);
93 settings.value(
"fCoinControlFeatures",
false).toBool();
105 if (!settings.contains(
"bPrune")) {
106 settings.setValue(
"bPrune",
false);
108 if (!settings.contains(
"nPruneSize")) {
113 if (!settings.contains(
"nDatabaseCache")) {
118 settings.value(
"nDatabaseCache").toString().toStdString())) {
122 if (!settings.contains(
"nThreadsScriptVerif")) {
127 settings.value(
"nThreadsScriptVerif").toString().toStdString())) {
131 if (!settings.contains(
"strDataDir")) {
137 if (!settings.contains(
"bSpendZeroConfChange")) {
138 settings.setValue(
"bSpendZeroConfChange",
true);
141 "-spendzeroconfchange",
142 settings.value(
"bSpendZeroConfChange").toBool())) {
148 if (!settings.contains(
"fUseUPnP")) {
155 if (!settings.contains(
"fUseNatpmp")) {
159 settings.value(
"fUseNatpmp").toBool())) {
163 if (!settings.contains(
"fListen")) {
170 if (!settings.contains(
"fUseProxy")) {
171 settings.setValue(
"fUseProxy",
false);
173 if (!settings.contains(
"addrProxy")) {
177 if (settings.value(
"fUseProxy").toBool() &&
179 "-proxy", settings.value(
"addrProxy").toString().toStdString())) {
181 }
else if (!settings.value(
"fUseProxy").toBool() &&
186 if (!settings.contains(
"fUseSeparateProxyTor")) {
187 settings.setValue(
"fUseSeparateProxyTor",
false);
189 if (!settings.contains(
"addrSeparateProxyTor")) {
193 if (settings.value(
"fUseSeparateProxyTor").toBool() &&
196 settings.value(
"addrSeparateProxyTor").toString().toStdString())) {
198 }
else if (!settings.value(
"fUseSeparateProxyTor").toBool() &&
204 if (!settings.contains(
"language")) {
205 settings.setValue(
"language",
"");
208 "-lang", settings.value(
"language").toString().toStdString())) {
212 language = settings.value(
"language").toString();
220 for (
const QString &key : src.allKeys()) {
221 dst.setValue(key, src.value(key));
227 qInfo() <<
"Backing up GUI settings to"
242 dataDir = settings.value(
"strDataDir", dataDir).toString();
248 settings.setValue(
"strDataDir", dataDir);
251 settings.setValue(
"fReset",
true);
274 if (!settings.contains(
name)) {
278 QStringList ip_port =
280 if (ip_port.size() == 2) {
281 return {
true, ip_port.at(0), ip_port.at(1)};
289 settings.setValue(
name, ip_port.
ip +
":" + ip_port.
port);
293 return QString(
"%1:%2")
300 settings.setValue(
"bPrune", prune);
301 const int64_t prune_target_mib =
303 std::string prune_val = prune ?
ToString(prune_target_mib) :
"0";
314 const bool prune = prune_target_gb > 0;
317 settings.setValue(
"nPruneSize", prune_target_gb);
324 if (role == Qt::EditRole) {
326 switch (index.row()) {
335 return settings.value(
"fUseUPnP");
341 return settings.value(
"fUseNatpmp");
350 return settings.value(
"fUseProxy",
false);
358 return settings.value(
"fUseSeparateProxyTor",
false);
366 return settings.value(
"bSpendZeroConfChange");
373 return settings.value(
"language");
377 return settings.value(
"bPrune");
379 return settings.value(
"nPruneSize");
381 return settings.value(
"nDatabaseCache");
383 return settings.value(
"nThreadsScriptVerif");
385 return settings.value(
"fListen");
396 bool successful =
true;
397 if (role == Qt::EditRole) {
399 switch (index.row()) {
413 settings.setValue(
"fUseUPnP", value.toBool());
416 settings.setValue(
"fUseNatpmp", value.toBool());
425 if (settings.value(
"fUseProxy") != value) {
426 settings.setValue(
"fUseProxy", value.toBool());
432 if (!ip_port.is_set || ip_port.ip != value.toString()) {
433 ip_port.ip = value.toString();
440 if (!ip_port.is_set || ip_port.port != value.toString()) {
441 ip_port.port = value.toString();
449 if (settings.value(
"fUseSeparateProxyTor") != value) {
450 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
457 if (!ip_port.is_set || ip_port.ip != value.toString()) {
458 ip_port.ip = value.toString();
466 if (!ip_port.is_set || ip_port.port != value.toString()) {
467 ip_port.port = value.toString();
475 if (settings.value(
"bSpendZeroConfChange") != value) {
476 settings.setValue(
"bSpendZeroConfChange", value);
487 settings.setValue(
"strThirdPartyTxUrls",
493 if (settings.value(
"language") != value) {
494 settings.setValue(
"language", value);
504 if (settings.value(
"bPrune") != value) {
505 settings.setValue(
"bPrune", value);
510 if (settings.value(
"nPruneSize") != value) {
511 settings.setValue(
"nPruneSize", value);
516 if (settings.value(
"nDatabaseCache") != value) {
517 settings.setValue(
"nDatabaseCache", value);
522 if (settings.value(
"nThreadsScriptVerif") != value) {
523 settings.setValue(
"nThreadsScriptVerif", value);
528 if (settings.value(
"fListen") != value) {
529 settings.setValue(
"fListen", value);
538 Q_EMIT dataChanged(index, index);
546 if (!value.isNull()) {
560 proxy.setType(QNetworkProxy::Socks5Proxy);
561 proxy.setHostName(QString::fromStdString(curProxy.
proxy.
ToStringIP()));
566 proxy.setType(QNetworkProxy::NoProxy);
575 return settings.setValue(
"fRestartRequired", fRequired);
580 return settings.value(
"fRestartRequired",
false).toBool();
588 static const char strSettingsVersionKey[] =
"nSettingsVersion";
589 int settingsVersion = settings.contains(strSettingsVersionKey)
590 ? settings.value(strSettingsVersionKey).toInt()
596 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") &&
597 settings.value(
"nDatabaseCache").toLongLong() == 100) {
606 if (settings.contains(
"addrProxy") &&
607 settings.value(
"addrProxy").toString().endsWith(
"%2")) {
613 if (settings.contains(
"addrSeparateProxyTor") &&
614 settings.value(
"addrSeparateProxyTor").toString().endsWith(
"%2")) {
void ForceSetArg(const std::string &strArg, const std::string &strValue)
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
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.
std::string ToStringIP() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QString strOverriddenByCommandLine
bool getProxySettings(QNetworkProxy &proxy) const
bool isRestartRequired() const
void Init(bool resetSettings=false)
bool fCoinControlFeatures
interfaces::Node & node() const
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
void SetPruneTargetGB(int prune_target_gb, bool force=false)
void SetPruneEnabled(bool prune, bool force=false)
void displayUnitChanged(int unit)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void addOverriddenOption(const std::string &option)
void setRestartRequired(bool fRequired)
void hideTrayIconChanged(bool)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static constexpr 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 &s, const QString &separator)
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 constexpr int64_t DEFAULT_DB_CACHE_MB
-dbcache default (MiB)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)