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(
"fUseNatpmp")) {
155 settings.value(
"fUseNatpmp").toBool())) {
159 if (!settings.contains(
"fListen")) {
166 if (!settings.contains(
"fUseProxy")) {
167 settings.setValue(
"fUseProxy",
false);
169 if (!settings.contains(
"addrProxy")) {
173 if (settings.value(
"fUseProxy").toBool() &&
175 "-proxy", settings.value(
"addrProxy").toString().toStdString())) {
177 }
else if (!settings.value(
"fUseProxy").toBool() &&
182 if (!settings.contains(
"fUseSeparateProxyTor")) {
183 settings.setValue(
"fUseSeparateProxyTor",
false);
185 if (!settings.contains(
"addrSeparateProxyTor")) {
189 if (settings.value(
"fUseSeparateProxyTor").toBool() &&
192 settings.value(
"addrSeparateProxyTor").toString().toStdString())) {
194 }
else if (!settings.value(
"fUseSeparateProxyTor").toBool() &&
200 if (!settings.contains(
"language")) {
201 settings.setValue(
"language",
"");
204 "-lang", settings.value(
"language").toString().toStdString())) {
208 language = settings.value(
"language").toString();
216 for (
const QString &key : src.allKeys()) {
217 dst.setValue(key, src.value(key));
223 qInfo() <<
"Backing up GUI settings to"
238 dataDir = settings.value(
"strDataDir", dataDir).toString();
244 settings.setValue(
"strDataDir", dataDir);
247 settings.setValue(
"fReset",
true);
270 if (!settings.contains(
name)) {
274 QStringList ip_port =
276 if (ip_port.size() == 2) {
277 return {
true, ip_port.at(0), ip_port.at(1)};
285 settings.setValue(
name, ip_port.
ip +
":" + ip_port.
port);
289 return QString(
"%1:%2")
296 settings.setValue(
"bPrune", prune);
297 const int64_t prune_target_mib =
299 std::string prune_val = prune ?
ToString(prune_target_mib) :
"0";
310 const bool prune = prune_target_gb > 0;
313 settings.setValue(
"nPruneSize", prune_target_gb);
320 if (role == Qt::EditRole) {
322 switch (index.row()) {
330 return settings.value(
"fUseNatpmp");
336 return settings.value(
"fUseProxy",
false);
344 return settings.value(
"fUseSeparateProxyTor",
false);
352 return settings.value(
"bSpendZeroConfChange");
359 return settings.value(
"language");
363 return settings.value(
"bPrune");
365 return settings.value(
"nPruneSize");
367 return settings.value(
"nDatabaseCache");
369 return settings.value(
"nThreadsScriptVerif");
371 return settings.value(
"fListen");
382 bool successful =
true;
383 if (role == Qt::EditRole) {
385 switch (index.row()) {
399 settings.setValue(
"fUseNatpmp", value.toBool());
408 if (settings.value(
"fUseProxy") != value) {
409 settings.setValue(
"fUseProxy", value.toBool());
415 if (!ip_port.is_set || ip_port.ip != value.toString()) {
416 ip_port.ip = value.toString();
423 if (!ip_port.is_set || ip_port.port != value.toString()) {
424 ip_port.port = value.toString();
432 if (settings.value(
"fUseSeparateProxyTor") != value) {
433 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
440 if (!ip_port.is_set || ip_port.ip != value.toString()) {
441 ip_port.ip = value.toString();
449 if (!ip_port.is_set || ip_port.port != value.toString()) {
450 ip_port.port = value.toString();
458 if (settings.value(
"bSpendZeroConfChange") != value) {
459 settings.setValue(
"bSpendZeroConfChange", value);
470 settings.setValue(
"strThirdPartyTxUrls",
476 if (settings.value(
"language") != value) {
477 settings.setValue(
"language", value);
487 if (settings.value(
"bPrune") != value) {
488 settings.setValue(
"bPrune", value);
493 if (settings.value(
"nPruneSize") != value) {
494 settings.setValue(
"nPruneSize", value);
499 if (settings.value(
"nDatabaseCache") != value) {
500 settings.setValue(
"nDatabaseCache", value);
505 if (settings.value(
"nThreadsScriptVerif") != value) {
506 settings.setValue(
"nThreadsScriptVerif", value);
511 if (settings.value(
"fListen") != value) {
512 settings.setValue(
"fListen", value);
521 Q_EMIT dataChanged(index, index);
529 if (!value.isNull()) {
543 proxy.setType(QNetworkProxy::Socks5Proxy);
550 proxy.setType(QNetworkProxy::NoProxy);
559 return settings.setValue(
"fRestartRequired", fRequired);
564 return settings.value(
"fRestartRequired",
false).toBool();
572 static const char strSettingsVersionKey[] =
"nSettingsVersion";
573 int settingsVersion = settings.contains(strSettingsVersionKey)
574 ? settings.value(strSettingsVersionKey).toInt()
580 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") &&
581 settings.value(
"nDatabaseCache").toLongLong() == 100) {
590 if (settings.contains(
"addrProxy") &&
591 settings.value(
"addrProxy").toString().endsWith(
"%2")) {
597 if (settings.contains(
"addrSeparateProxyTor") &&
598 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
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)