5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
22#include <validation.h>
26#include <QNetworkProxy>
38 : QAbstractListModel(parent) {
44 QString::fromStdString(option) +
"=" +
45 QString::fromStdString(
gArgs.
GetArg(option,
"")) +
" ";
64 if (!settings.contains(
"fHideTrayIcon")) {
65 settings.setValue(
"fHideTrayIcon",
false);
70 if (!settings.contains(
"fMinimizeToTray")) {
71 settings.setValue(
"fMinimizeToTray",
false);
76 if (!settings.contains(
"fMinimizeOnClose")) {
77 settings.setValue(
"fMinimizeOnClose",
false);
82 if (!settings.contains(
"nDisplayUnit")) {
87 if (!settings.contains(
"strThirdPartyTxUrls")) {
88 settings.setValue(
"strThirdPartyTxUrls",
"");
92 if (!settings.contains(
"fCoinControlFeatures")) {
93 settings.setValue(
"fCoinControlFeatures",
false);
96 settings.value(
"fCoinControlFeatures",
false).toBool();
108 if (!settings.contains(
"bPrune")) {
109 settings.setValue(
"bPrune",
false);
111 if (!settings.contains(
"nPruneSize")) {
116 if (!settings.contains(
"nDatabaseCache")) {
121 settings.value(
"nDatabaseCache").toString().toStdString())) {
125 if (!settings.contains(
"nThreadsScriptVerif")) {
130 settings.value(
"nThreadsScriptVerif").toString().toStdString())) {
134 if (!settings.contains(
"strDataDir")) {
140 if (!settings.contains(
"bSpendZeroConfChange")) {
141 settings.setValue(
"bSpendZeroConfChange",
true);
144 "-spendzeroconfchange",
145 settings.value(
"bSpendZeroConfChange").toBool())) {
151 if (!settings.contains(
"fUseUPnP")) {
158 if (!settings.contains(
"fUseNatpmp")) {
162 settings.value(
"fUseNatpmp").toBool())) {
166 if (!settings.contains(
"fListen")) {
173 if (!settings.contains(
"fUseProxy")) {
174 settings.setValue(
"fUseProxy",
false);
176 if (!settings.contains(
"addrProxy")) {
180 if (settings.value(
"fUseProxy").toBool() &&
182 "-proxy", settings.value(
"addrProxy").toString().toStdString())) {
184 }
else if (!settings.value(
"fUseProxy").toBool() &&
189 if (!settings.contains(
"fUseSeparateProxyTor")) {
190 settings.setValue(
"fUseSeparateProxyTor",
false);
192 if (!settings.contains(
"addrSeparateProxyTor")) {
196 if (settings.value(
"fUseSeparateProxyTor").toBool() &&
199 settings.value(
"addrSeparateProxyTor").toString().toStdString())) {
201 }
else if (!settings.value(
"fUseSeparateProxyTor").toBool() &&
207 if (!settings.contains(
"language")) {
208 settings.setValue(
"language",
"");
211 "-lang", settings.value(
"language").toString().toStdString())) {
215 language = settings.value(
"language").toString();
223 for (
const QString &key : src.allKeys()) {
224 dst.setValue(key, src.value(key));
230 qInfo() <<
"Backing up GUI settings to"
245 dataDir = settings.value(
"strDataDir", dataDir).toString();
251 settings.setValue(
"strDataDir", dataDir);
254 settings.setValue(
"fReset",
true);
277 if (!settings.contains(
name)) {
281 QStringList ip_port =
283 if (ip_port.size() == 2) {
284 return {
true, ip_port.at(0), ip_port.at(1)};
292 settings.setValue(
name, ip_port.
ip +
":" + ip_port.
port);
296 return QString(
"%1:%2")
303 settings.setValue(
"bPrune", prune);
304 const int64_t prune_target_mib =
306 std::string prune_val = prune ?
ToString(prune_target_mib) :
"0";
317 const bool prune = prune_target_gb > 0;
320 settings.setValue(
"nPruneSize", prune_target_gb);
327 if (role == Qt::EditRole) {
329 switch (index.row()) {
338 return settings.value(
"fUseUPnP");
344 return settings.value(
"fUseNatpmp");
353 return settings.value(
"fUseProxy",
false);
361 return settings.value(
"fUseSeparateProxyTor",
false);
369 return settings.value(
"bSpendZeroConfChange");
376 return settings.value(
"language");
380 return settings.value(
"bPrune");
382 return settings.value(
"nPruneSize");
384 return settings.value(
"nDatabaseCache");
386 return settings.value(
"nThreadsScriptVerif");
388 return settings.value(
"fListen");
399 bool successful =
true;
400 if (role == Qt::EditRole) {
402 switch (index.row()) {
416 settings.setValue(
"fUseUPnP", value.toBool());
419 settings.setValue(
"fUseNatpmp", value.toBool());
428 if (settings.value(
"fUseProxy") != value) {
429 settings.setValue(
"fUseProxy", value.toBool());
435 if (!ip_port.is_set || ip_port.ip != value.toString()) {
436 ip_port.ip = value.toString();
443 if (!ip_port.is_set || ip_port.port != value.toString()) {
444 ip_port.port = value.toString();
452 if (settings.value(
"fUseSeparateProxyTor") != value) {
453 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
460 if (!ip_port.is_set || ip_port.ip != value.toString()) {
461 ip_port.ip = value.toString();
469 if (!ip_port.is_set || ip_port.port != value.toString()) {
470 ip_port.port = value.toString();
478 if (settings.value(
"bSpendZeroConfChange") != value) {
479 settings.setValue(
"bSpendZeroConfChange", value);
490 settings.setValue(
"strThirdPartyTxUrls",
496 if (settings.value(
"language") != value) {
497 settings.setValue(
"language", value);
507 if (settings.value(
"bPrune") != value) {
508 settings.setValue(
"bPrune", value);
513 if (settings.value(
"nPruneSize") != value) {
514 settings.setValue(
"nPruneSize", value);
519 if (settings.value(
"nDatabaseCache") != value) {
520 settings.setValue(
"nDatabaseCache", value);
525 if (settings.value(
"nThreadsScriptVerif") != value) {
526 settings.setValue(
"nThreadsScriptVerif", value);
531 if (settings.value(
"fListen") != value) {
532 settings.setValue(
"fListen", value);
541 Q_EMIT dataChanged(index, index);
549 if (!value.isNull()) {
563 proxy.setType(QNetworkProxy::Socks5Proxy);
570 proxy.setType(QNetworkProxy::NoProxy);
579 return settings.setValue(
"fRestartRequired", fRequired);
584 return settings.value(
"fRestartRequired",
false).toBool();
592 static const char strSettingsVersionKey[] =
"nSettingsVersion";
593 int settingsVersion = settings.contains(strSettingsVersionKey)
594 ? settings.value(strSettingsVersionKey).toInt()
600 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") &&
601 settings.value(
"nDatabaseCache").toLongLong() == 100) {
610 if (settings.contains(
"addrProxy") &&
611 settings.value(
"addrProxy").toString().endsWith(
"%2")) {
617 if (settings.contains(
"addrSeparateProxyTor") &&
618 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 ToStringAddr() 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)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static const bool DEFAULT_LISTEN
-listen default
static constexpr size_t DEFAULT_DB_CACHE
-dbcache default (bytes)
static void CopySettings(QSettings &dst, const QSettings &src)
Helper function to copy contents from one QSettings to another.
static 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
static std::string ToString(const CService &ip)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)