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) +
"=" +
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();
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")) {
208 "-lang",
settings.value(
"language").toString().toStdString())) {
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);
324 if (role == Qt::EditRole) {
326 switch (index.row()) {
341 return settings.value(
"fUseNatpmp");
350 return settings.value(
"fUseProxy",
false);
358 return settings.value(
"fUseSeparateProxyTor",
false);
366 return settings.value(
"bSpendZeroConfChange");
379 return settings.value(
"nPruneSize");
381 return settings.value(
"nDatabaseCache");
383 return settings.value(
"nThreadsScriptVerif");
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());
441 ip_port.port = value.toString();
449 if (
settings.value(
"fUseSeparateProxyTor") != value) {
450 settings.setValue(
"fUseSeparateProxyTor", value.toBool());
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) {
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);
546 if (!value.isNull()) {
560 proxy.setType(QNetworkProxy::Socks5Proxy);
561 proxy.setHostName(QString::fromStdString(
curProxy.proxy.ToStringIP()));
562 proxy.setPort(
curProxy.proxy.GetPort());
566 proxy.setType(QNetworkProxy::NoProxy);
580 return settings.value(
"fRestartRequired",
false).toBool();
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.
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
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static std::string ToString(const CService &ip)
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)