5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
23#include <validation.h>
27#include <QNetworkProxy>
39 : QAbstractListModel(parent) {
45 QString::fromStdString(option) +
"=" +
46 QString::fromStdString(
gArgs.
GetArg(option,
"")) +
" ";
65 if (!settings.contains(
"fHideTrayIcon")) {
66 settings.setValue(
"fHideTrayIcon",
false);
71 if (!settings.contains(
"fMinimizeToTray")) {
72 settings.setValue(
"fMinimizeToTray",
false);
77 if (!settings.contains(
"fMinimizeOnClose")) {
78 settings.setValue(
"fMinimizeOnClose",
false);
83 if (!settings.contains(
"nDisplayUnit")) {
88 if (!settings.contains(
"strThirdPartyTxUrls")) {
89 settings.setValue(
"strThirdPartyTxUrls",
"");
93 if (!settings.contains(
"fCoinControlFeatures")) {
94 settings.setValue(
"fCoinControlFeatures",
false);
97 settings.value(
"fCoinControlFeatures",
false).toBool();
109 if (!settings.contains(
"bPrune")) {
110 settings.setValue(
"bPrune",
false);
112 if (!settings.contains(
"nPruneSize")) {
117 if (!settings.contains(
"nDatabaseCache")) {
122 settings.value(
"nDatabaseCache").toString().toStdString())) {
126 if (!settings.contains(
"nThreadsScriptVerif")) {
131 settings.value(
"nThreadsScriptVerif").toString().toStdString())) {
135 if (!settings.contains(
"strDataDir")) {
141 if (!settings.contains(
"bSpendZeroConfChange")) {
142 settings.setValue(
"bSpendZeroConfChange",
true);
145 "-spendzeroconfchange",
146 settings.value(
"bSpendZeroConfChange").toBool())) {
152 if (!settings.contains(
"fUseNatpmp")) {
156 settings.value(
"fUseNatpmp").toBool())) {
160 if (!settings.contains(
"fListen")) {
167 if (!settings.contains(
"fUseProxy")) {
168 settings.setValue(
"fUseProxy",
false);
170 if (!settings.contains(
"addrProxy")) {
174 if (settings.value(
"fUseProxy").toBool() &&
176 "-proxy", settings.value(
"addrProxy").toString().toStdString())) {
178 }
else if (!settings.value(
"fUseProxy").toBool() &&
183 if (!settings.contains(
"fUseSeparateProxyTor")) {
184 settings.setValue(
"fUseSeparateProxyTor",
false);
186 if (!settings.contains(
"addrSeparateProxyTor")) {
190 if (settings.value(
"fUseSeparateProxyTor").toBool() &&
193 settings.value(
"addrSeparateProxyTor").toString().toStdString())) {
195 }
else if (!settings.value(
"fUseSeparateProxyTor").toBool() &&
201 if (!settings.contains(
"language")) {
202 settings.setValue(
"language",
"");
205 "-lang", settings.value(
"language").toString().toStdString())) {
209 language = settings.value(
"language").toString();
217 for (
const QString &key : src.allKeys()) {
218 dst.setValue(key, src.value(key));
224 qInfo() <<
"Backing up GUI settings to"
239 dataDir = settings.value(
"strDataDir", dataDir).toString();
245 settings.setValue(
"strDataDir", dataDir);
248 settings.setValue(
"fReset",
true);
271 if (!settings.contains(
name)) {
275 QStringList ip_port =
277 if (ip_port.size() == 2) {
278 return {
true, ip_port.at(0), ip_port.at(1)};
286 settings.setValue(
name, ip_port.
ip +
":" + ip_port.
port);
290 return QString(
"%1:%2")
297 settings.setValue(
"bPrune", prune);
298 const int64_t prune_target_mib =
300 std::string prune_val = prune ?
ToString(prune_target_mib) :
"0";
311 const bool prune = prune_target_gb > 0;
314 settings.setValue(
"nPruneSize", prune_target_gb);
321 if (role == Qt::EditRole) {
323 switch (index.row()) {
331 return settings.value(
"fUseNatpmp");
337 return settings.value(
"fUseProxy",
false);
345 return settings.value(
"fUseSeparateProxyTor",
false);
353 return settings.value(
"bSpendZeroConfChange");
360 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");
383 bool successful =
true;
384 if (role == Qt::EditRole) {
386 switch (index.row()) {
400 settings.setValue(
"fUseNatpmp", value.toBool());
409 if (settings.value(
"fUseProxy") != value) {
410 settings.setValue(
"fUseProxy", value.toBool());
416 if (!ip_port.is_set || ip_port.ip != value.toString()) {
417 ip_port.ip = value.toString();
424 if (!ip_port.is_set || ip_port.port != value.toString()) {
425 ip_port.port = value.toString();
433 if (settings.value(
"fUseSeparateProxyTor") != value) {
434 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
441 if (!ip_port.is_set || ip_port.ip != value.toString()) {
442 ip_port.ip = value.toString();
450 if (!ip_port.is_set || ip_port.port != value.toString()) {
451 ip_port.port = value.toString();
459 if (settings.value(
"bSpendZeroConfChange") != value) {
460 settings.setValue(
"bSpendZeroConfChange", value);
471 settings.setValue(
"strThirdPartyTxUrls",
477 if (settings.value(
"language") != value) {
478 settings.setValue(
"language", value);
488 if (settings.value(
"bPrune") != value) {
489 settings.setValue(
"bPrune", value);
494 if (settings.value(
"nPruneSize") != value) {
495 settings.setValue(
"nPruneSize", value);
500 if (settings.value(
"nDatabaseCache") != value) {
501 settings.setValue(
"nDatabaseCache", value);
506 if (settings.value(
"nThreadsScriptVerif") != value) {
507 settings.setValue(
"nThreadsScriptVerif", value);
512 if (settings.value(
"fListen") != value) {
513 settings.setValue(
"fListen", value);
522 Q_EMIT dataChanged(index, index);
530 if (!value.isNull()) {
544 proxy.setType(QNetworkProxy::Socks5Proxy);
551 proxy.setType(QNetworkProxy::NoProxy);
560 return settings.setValue(
"fRestartRequired", fRequired);
565 return settings.value(
"fRestartRequired",
false).toBool();
573 static const char strSettingsVersionKey[] =
"nSettingsVersion";
574 int settingsVersion = settings.contains(strSettingsVersionKey)
575 ? settings.value(strSettingsVersionKey).toInt()
581 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") &&
582 settings.value(
"nDatabaseCache").toLongLong() == 100) {
591 if (settings.contains(
"addrProxy") &&
592 settings.value(
"addrProxy").toString().endsWith(
"%2")) {
598 if (settings.contains(
"addrSeparateProxyTor") &&
599 settings.value(
"addrSeparateProxyTor").toString().endsWith(
"%2")) {
static constexpr int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
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
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)