Bitcoin ABC  0.26.3
P2P Digital Currency
optionsmodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #if defined(HAVE_CONFIG_H)
6 #include <config/bitcoin-config.h>
7 #endif
8 
9 #include <qt/optionsmodel.h>
10 
11 #include <interfaces/node.h>
12 #include <mapport.h>
13 #include <net.h>
14 #include <netbase.h>
15 #include <qt/bitcoinunits.h>
16 #include <qt/guiconstants.h>
17 #include <qt/guiutil.h>
18 #include <txdb.h> // for -dbcache defaults
19 #include <util/string.h>
20 #include <validation.h> // For DEFAULT_SCRIPTCHECK_THREADS
21 
22 #include <QDebug> // needed by qInfo()
23 #ifdef ENABLE_BIP70
24 #include <QNetworkProxy>
25 #endif
26 #include <QSettings>
27 #include <QStringList>
28 
29 const char *DEFAULT_GUI_PROXY_HOST = "127.0.0.1";
30 
31 static const QString GetDefaultProxyAddress();
32 
33 OptionsModel::OptionsModel(QObject *parent, bool resetSettings)
34  : QAbstractListModel(parent) {
35  Init(resetSettings);
36 }
37 
38 void OptionsModel::addOverriddenOption(const std::string &option) {
40  QString::fromStdString(option) + "=" +
41  QString::fromStdString(gArgs.GetArg(option, "")) + " ";
42 }
43 
44 // Writes all missing QSettings with their default values
45 void OptionsModel::Init(bool resetSettings) {
46  if (resetSettings) {
47  Reset();
48  }
49 
51 
52  QSettings settings;
53 
54  // Ensure restart flag is unset on client startup
55  setRestartRequired(false);
56 
57  // These are Qt-only settings:
58 
59  // Window
60  if (!settings.contains("fHideTrayIcon")) {
61  settings.setValue("fHideTrayIcon", false);
62  }
63  fHideTrayIcon = settings.value("fHideTrayIcon").toBool();
65 
66  if (!settings.contains("fMinimizeToTray")) {
67  settings.setValue("fMinimizeToTray", false);
68  }
70  settings.value("fMinimizeToTray").toBool() && !fHideTrayIcon;
71 
72  if (!settings.contains("fMinimizeOnClose")) {
73  settings.setValue("fMinimizeOnClose", false);
74  }
75  fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool();
76 
77  // Display
78  if (!settings.contains("nDisplayUnit")) {
79  settings.setValue("nDisplayUnit", BitcoinUnits::base);
80  }
81  nDisplayUnit = settings.value("nDisplayUnit").toInt();
82 
83  if (!settings.contains("strThirdPartyTxUrls")) {
84  settings.setValue("strThirdPartyTxUrls", "");
85  }
86  strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
87 
88  if (!settings.contains("fCoinControlFeatures")) {
89  settings.setValue("fCoinControlFeatures", false);
90  }
92  settings.value("fCoinControlFeatures", false).toBool();
93 
94  // These are shared with the core or have a command-line parameter
95  // and we want command-line parameters to overwrite the GUI settings.
96  //
97  // If setting doesn't exist create it with defaults.
98  //
99  // If gArgs.SoftSetArg() or gArgs.SoftSetBoolArg() return false we were
100  // overridden
101  // by command-line and show this in the UI.
102 
103  // Main
104  if (!settings.contains("bPrune")) {
105  settings.setValue("bPrune", false);
106  }
107  if (!settings.contains("nPruneSize")) {
108  settings.setValue("nPruneSize", DEFAULT_PRUNE_TARGET_GB);
109  }
110  SetPruneEnabled(settings.value("bPrune").toBool());
111 
112  if (!settings.contains("nDatabaseCache")) {
113  settings.setValue("nDatabaseCache", (qint64)DEFAULT_DB_CACHE_MB);
114  }
115  if (!gArgs.SoftSetArg(
116  "-dbcache",
117  settings.value("nDatabaseCache").toString().toStdString())) {
118  addOverriddenOption("-dbcache");
119  }
120 
121  if (!settings.contains("nThreadsScriptVerif")) {
122  settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
123  }
124  if (!gArgs.SoftSetArg(
125  "-par",
126  settings.value("nThreadsScriptVerif").toString().toStdString())) {
127  addOverriddenOption("-par");
128  }
129 
130  if (!settings.contains("strDataDir")) {
131  settings.setValue("strDataDir", GUIUtil::getDefaultDataDirectory());
132  }
133 
134 // Wallet
135 #ifdef ENABLE_WALLET
136  if (!settings.contains("bSpendZeroConfChange")) {
137  settings.setValue("bSpendZeroConfChange", true);
138  }
139  if (!gArgs.SoftSetBoolArg(
140  "-spendzeroconfchange",
141  settings.value("bSpendZeroConfChange").toBool())) {
142  addOverriddenOption("-spendzeroconfchange");
143  }
144 #endif
145 
146  // Network
147  if (!settings.contains("fUseUPnP")) {
148  settings.setValue("fUseUPnP", DEFAULT_UPNP);
149  }
150  if (!gArgs.SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool())) {
151  addOverriddenOption("-upnp");
152  }
153 
154  if (!settings.contains("fUseNatpmp")) {
155  settings.setValue("fUseNatpmp", DEFAULT_NATPMP);
156  }
157  if (!gArgs.SoftSetBoolArg("-natpmp",
158  settings.value("fUseNatpmp").toBool())) {
159  addOverriddenOption("-natpmp");
160  }
161 
162  if (!settings.contains("fListen")) {
163  settings.setValue("fListen", DEFAULT_LISTEN);
164  }
165  if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool())) {
166  addOverriddenOption("-listen");
167  }
168 
169  if (!settings.contains("fUseProxy")) {
170  settings.setValue("fUseProxy", false);
171  }
172  if (!settings.contains("addrProxy")) {
173  settings.setValue("addrProxy", GetDefaultProxyAddress());
174  }
175  // Only try to set -proxy, if user has enabled fUseProxy
176  if (settings.value("fUseProxy").toBool() &&
177  !gArgs.SoftSetArg(
178  "-proxy", settings.value("addrProxy").toString().toStdString())) {
179  addOverriddenOption("-proxy");
180  } else if (!settings.value("fUseProxy").toBool() &&
181  !gArgs.GetArg("-proxy", "").empty()) {
182  addOverriddenOption("-proxy");
183  }
184 
185  if (!settings.contains("fUseSeparateProxyTor")) {
186  settings.setValue("fUseSeparateProxyTor", false);
187  }
188  if (!settings.contains("addrSeparateProxyTor")) {
189  settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
190  }
191  // Only try to set -onion, if user has enabled fUseSeparateProxyTor
192  if (settings.value("fUseSeparateProxyTor").toBool() &&
193  !gArgs.SoftSetArg(
194  "-onion",
195  settings.value("addrSeparateProxyTor").toString().toStdString())) {
196  addOverriddenOption("-onion");
197  } else if (!settings.value("fUseSeparateProxyTor").toBool() &&
198  !gArgs.GetArg("-onion", "").empty()) {
199  addOverriddenOption("-onion");
200  }
201 
202  // Display
203  if (!settings.contains("language")) {
204  settings.setValue("language", "");
205  }
206  if (!gArgs.SoftSetArg(
207  "-lang", settings.value("language").toString().toStdString())) {
208  addOverriddenOption("-lang");
209  }
210 
211  language = settings.value("language").toString();
212 }
213 
218 static void CopySettings(QSettings &dst, const QSettings &src) {
219  for (const QString &key : src.allKeys()) {
220  dst.setValue(key, src.value(key));
221  }
222 }
223 
225 static void BackupSettings(const fs::path &filename, const QSettings &src) {
226  qInfo() << "Backing up GUI settings to"
227  << GUIUtil::boostPathToQString(filename);
228  QSettings dst(GUIUtil::boostPathToQString(filename), QSettings::IniFormat);
229  dst.clear();
230  CopySettings(dst, src);
231 }
232 
234  QSettings settings;
235 
236  // Backup old settings to chain-specific datadir for troubleshooting
237  BackupSettings(gArgs.GetDataDirNet() / "guisettings.ini.bak", settings);
238 
239  // Save the strDataDir setting
240  QString dataDir = GUIUtil::getDefaultDataDirectory();
241  dataDir = settings.value("strDataDir", dataDir).toString();
242 
243  // Remove all entries from our QSettings object
244  settings.clear();
245 
246  // Set strDataDir
247  settings.setValue("strDataDir", dataDir);
248 
249  // Set that this was reset
250  settings.setValue("fReset", true);
251 
252  // default setting for OptionsModel::StartAtStartup - disabled
255  }
256 }
257 
258 int OptionsModel::rowCount(const QModelIndex &parent) const {
259  return OptionIDRowCount;
260 }
261 
262 struct ProxySetting {
263  bool is_set;
264  QString ip;
265  QString port;
266 };
267 
268 static ProxySetting GetProxySetting(QSettings &settings, const QString &name) {
269  static const ProxySetting default_val = {
270  false, DEFAULT_GUI_PROXY_HOST,
271  QString("%1").arg(DEFAULT_GUI_PROXY_PORT)};
272  // Handle the case that the setting is not set at all
273  if (!settings.contains(name)) {
274  return default_val;
275  }
276  // contains IP at index 0 and port at index 1
277  QStringList ip_port =
278  GUIUtil::splitSkipEmptyParts(settings.value(name).toString(), ":");
279  if (ip_port.size() == 2) {
280  return {true, ip_port.at(0), ip_port.at(1)};
281  } else { // Invalid: return default
282  return default_val;
283  }
284 }
285 
286 static void SetProxySetting(QSettings &settings, const QString &name,
287  const ProxySetting &ip_port) {
288  settings.setValue(name, ip_port.ip + ":" + ip_port.port);
289 }
290 
291 static const QString GetDefaultProxyAddress() {
292  return QString("%1:%2")
295 }
296 
297 void OptionsModel::SetPruneEnabled(bool prune, bool force) {
298  QSettings settings;
299  settings.setValue("bPrune", prune);
300  const int64_t prune_target_mib =
301  PruneGBtoMiB(settings.value("nPruneSize").toInt());
302  std::string prune_val = prune ? ToString(prune_target_mib) : "0";
303  if (force) {
304  gArgs.ForceSetArg("-prune", prune_val);
305  return;
306  }
307  if (!gArgs.SoftSetArg("-prune", prune_val)) {
308  addOverriddenOption("-prune");
309  }
310 }
311 
312 void OptionsModel::SetPruneTargetGB(int prune_target_gb, bool force) {
313  const bool prune = prune_target_gb > 0;
314  if (prune) {
315  QSettings settings;
316  settings.setValue("nPruneSize", prune_target_gb);
317  }
318  SetPruneEnabled(prune, force);
319 }
320 
321 // read QSettings values and return them
322 QVariant OptionsModel::data(const QModelIndex &index, int role) const {
323  if (role == Qt::EditRole) {
324  QSettings settings;
325  switch (index.row()) {
326  case StartAtStartup:
328  case HideTrayIcon:
329  return fHideTrayIcon;
330  case MinimizeToTray:
331  return fMinimizeToTray;
332  case MapPortUPnP:
333 #ifdef USE_UPNP
334  return settings.value("fUseUPnP");
335 #else
336  return false;
337 #endif // USE_UPNP
338  case MapPortNatpmp:
339 #ifdef USE_NATPMP
340  return settings.value("fUseNatpmp");
341 #else
342  return false;
343 #endif // USE_NATPMP
344  case MinimizeOnClose:
345  return fMinimizeOnClose;
346 
347  // default proxy
348  case ProxyUse:
349  return settings.value("fUseProxy", false);
350  case ProxyIP:
351  return GetProxySetting(settings, "addrProxy").ip;
352  case ProxyPort:
353  return GetProxySetting(settings, "addrProxy").port;
354 
355  // separate Tor proxy
356  case ProxyUseTor:
357  return settings.value("fUseSeparateProxyTor", false);
358  case ProxyIPTor:
359  return GetProxySetting(settings, "addrSeparateProxyTor").ip;
360  case ProxyPortTor:
361  return GetProxySetting(settings, "addrSeparateProxyTor").port;
362 
363 #ifdef ENABLE_WALLET
364  case SpendZeroConfChange:
365  return settings.value("bSpendZeroConfChange");
366 #endif
367  case DisplayUnit:
368  return nDisplayUnit;
369  case ThirdPartyTxUrls:
370  return strThirdPartyTxUrls;
371  case Language:
372  return settings.value("language");
373  case CoinControlFeatures:
374  return fCoinControlFeatures;
375  case Prune:
376  return settings.value("bPrune");
377  case PruneSize:
378  return settings.value("nPruneSize");
379  case DatabaseCache:
380  return settings.value("nDatabaseCache");
381  case ThreadsScriptVerif:
382  return settings.value("nThreadsScriptVerif");
383  case Listen:
384  return settings.value("fListen");
385  default:
386  return QVariant();
387  }
388  }
389  return QVariant();
390 }
391 
392 // write QSettings values
393 bool OptionsModel::setData(const QModelIndex &index, const QVariant &value,
394  int role) {
395  bool successful = true; /* set to false on parse error */
396  if (role == Qt::EditRole) {
397  QSettings settings;
398  switch (index.row()) {
399  case StartAtStartup:
400  successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
401  break;
402  case HideTrayIcon:
403  fHideTrayIcon = value.toBool();
404  settings.setValue("fHideTrayIcon", fHideTrayIcon);
406  break;
407  case MinimizeToTray:
408  fMinimizeToTray = value.toBool();
409  settings.setValue("fMinimizeToTray", fMinimizeToTray);
410  break;
411  case MapPortUPnP: // core option - can be changed on-the-fly
412  settings.setValue("fUseUPnP", value.toBool());
413  break;
414  case MapPortNatpmp: // core option - can be changed on-the-fly
415  settings.setValue("fUseNatpmp", value.toBool());
416  break;
417  case MinimizeOnClose:
418  fMinimizeOnClose = value.toBool();
419  settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
420  break;
421 
422  // default proxy
423  case ProxyUse:
424  if (settings.value("fUseProxy") != value) {
425  settings.setValue("fUseProxy", value.toBool());
426  setRestartRequired(true);
427  }
428  break;
429  case ProxyIP: {
430  auto ip_port = GetProxySetting(settings, "addrProxy");
431  if (!ip_port.is_set || ip_port.ip != value.toString()) {
432  ip_port.ip = value.toString();
433  SetProxySetting(settings, "addrProxy", ip_port);
434  setRestartRequired(true);
435  }
436  } break;
437  case ProxyPort: {
438  auto ip_port = GetProxySetting(settings, "addrProxy");
439  if (!ip_port.is_set || ip_port.port != value.toString()) {
440  ip_port.port = value.toString();
441  SetProxySetting(settings, "addrProxy", ip_port);
442  setRestartRequired(true);
443  }
444  } break;
445 
446  // separate Tor proxy
447  case ProxyUseTor:
448  if (settings.value("fUseSeparateProxyTor") != value) {
449  settings.setValue("fUseSeparateProxyTor", value.toBool());
450  setRestartRequired(true);
451  }
452  break;
453  case ProxyIPTor: {
454  auto ip_port =
455  GetProxySetting(settings, "addrSeparateProxyTor");
456  if (!ip_port.is_set || ip_port.ip != value.toString()) {
457  ip_port.ip = value.toString();
458  SetProxySetting(settings, "addrSeparateProxyTor", ip_port);
459  setRestartRequired(true);
460  }
461  } break;
462  case ProxyPortTor: {
463  auto ip_port =
464  GetProxySetting(settings, "addrSeparateProxyTor");
465  if (!ip_port.is_set || ip_port.port != value.toString()) {
466  ip_port.port = value.toString();
467  SetProxySetting(settings, "addrSeparateProxyTor", ip_port);
468  setRestartRequired(true);
469  }
470  } break;
471 
472 #ifdef ENABLE_WALLET
473  case SpendZeroConfChange:
474  if (settings.value("bSpendZeroConfChange") != value) {
475  settings.setValue("bSpendZeroConfChange", value);
476  setRestartRequired(true);
477  }
478  break;
479 #endif
480  case DisplayUnit:
481  setDisplayUnit(value);
482  break;
483  case ThirdPartyTxUrls:
484  if (strThirdPartyTxUrls != value.toString()) {
485  strThirdPartyTxUrls = value.toString();
486  settings.setValue("strThirdPartyTxUrls",
488  setRestartRequired(true);
489  }
490  break;
491  case Language:
492  if (settings.value("language") != value) {
493  settings.setValue("language", value);
494  setRestartRequired(true);
495  }
496  break;
497  case CoinControlFeatures:
498  fCoinControlFeatures = value.toBool();
499  settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
501  break;
502  case Prune:
503  if (settings.value("bPrune") != value) {
504  settings.setValue("bPrune", value);
505  setRestartRequired(true);
506  }
507  break;
508  case PruneSize:
509  if (settings.value("nPruneSize") != value) {
510  settings.setValue("nPruneSize", value);
511  setRestartRequired(true);
512  }
513  break;
514  case DatabaseCache:
515  if (settings.value("nDatabaseCache") != value) {
516  settings.setValue("nDatabaseCache", value);
517  setRestartRequired(true);
518  }
519  break;
520  case ThreadsScriptVerif:
521  if (settings.value("nThreadsScriptVerif") != value) {
522  settings.setValue("nThreadsScriptVerif", value);
523  setRestartRequired(true);
524  }
525  break;
526  case Listen:
527  if (settings.value("fListen") != value) {
528  settings.setValue("fListen", value);
529  setRestartRequired(true);
530  }
531  break;
532  default:
533  break;
534  }
535  }
536 
537  Q_EMIT dataChanged(index, index);
538 
539  return successful;
540 }
541 
544 void OptionsModel::setDisplayUnit(const QVariant &value) {
545  if (!value.isNull()) {
546  QSettings settings;
547  nDisplayUnit = value.toInt();
548  settings.setValue("nDisplayUnit", nDisplayUnit);
550  }
551 }
552 
553 #ifdef ENABLE_BIP70
554 bool OptionsModel::getProxySettings(QNetworkProxy &proxy) const {
555  // Directly query current base proxy, because
556  // GUI settings can be overridden with -proxy.
557  proxyType curProxy;
558  if (node().getProxy(NET_IPV4, curProxy)) {
559  proxy.setType(QNetworkProxy::Socks5Proxy);
560  proxy.setHostName(QString::fromStdString(curProxy.proxy.ToStringIP()));
561  proxy.setPort(curProxy.proxy.GetPort());
562 
563  return true;
564  } else {
565  proxy.setType(QNetworkProxy::NoProxy);
566  }
567 
568  return false;
569 }
570 #endif
571 
572 void OptionsModel::setRestartRequired(bool fRequired) {
573  QSettings settings;
574  return settings.setValue("fRestartRequired", fRequired);
575 }
576 
578  QSettings settings;
579  return settings.value("fRestartRequired", false).toBool();
580 }
581 
583  // Migration of default values
584  // Check if the QSettings container was already loaded with this client
585  // version
586  QSettings settings;
587  static const char strSettingsVersionKey[] = "nSettingsVersion";
588  int settingsVersion = settings.contains(strSettingsVersionKey)
589  ? settings.value(strSettingsVersionKey).toInt()
590  : 0;
591  if (settingsVersion < CLIENT_VERSION) {
592  // -dbcache was bumped from 100 to 300 in 0.13
593  // see https://github.com/bitcoin/bitcoin/pull/8273
594  // force people to upgrade to the new value if they are using 100MB
595  if (settingsVersion < 130000 && settings.contains("nDatabaseCache") &&
596  settings.value("nDatabaseCache").toLongLong() == 100) {
597  settings.setValue("nDatabaseCache", (qint64)DEFAULT_DB_CACHE_MB);
598  }
599 
600  settings.setValue(strSettingsVersionKey, CLIENT_VERSION);
601  }
602 
603  // Overwrite the 'addrProxy' setting in case it has been set to an illegal
604  // default value (see issue #12623; PR #12650).
605  if (settings.contains("addrProxy") &&
606  settings.value("addrProxy").toString().endsWith("%2")) {
607  settings.setValue("addrProxy", GetDefaultProxyAddress());
608  }
609 
610  // Overwrite the 'addrSeparateProxyTor' setting in case it has been set to
611  // an illegal default value (see issue #12623; PR #12650).
612  if (settings.contains("addrSeparateProxyTor") &&
613  settings.value("addrSeparateProxyTor").toString().endsWith("%2")) {
614  settings.setValue("addrSeparateProxyTor", GetDefaultProxyAddress());
615  }
616 }
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: system.cpp:705
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
Definition: system.cpp:687
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: system.h:268
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: system.cpp:602
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
Definition: system.cpp:697
std::string ToStringIP() const
Definition: netaddress.cpp:628
uint16_t GetPort() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QString strOverriddenByCommandLine
Definition: optionsmodel.h:133
bool getProxySettings(QNetworkProxy &proxy) const
bool isRestartRequired() const
void Init(bool resetSettings=false)
bool fCoinControlFeatures
Definition: optionsmodel.h:131
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
Definition: optionsmodel.h:130
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 fHideTrayIcon
Definition: optionsmodel.h:125
bool fMinimizeToTray
Definition: optionsmodel.h:126
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
interfaces::Node & node() const
Definition: optionsmodel.h:113
void checkAndMigrate()
QString language
Definition: optionsmodel.h:128
void addOverriddenOption(const std::string &option)
bool fMinimizeOnClose
Definition: optionsmodel.h:127
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:...
Definition: fs.h:29
CService proxy
Definition: netbase.h:40
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
Definition: clientversion.h:38
static constexpr int DEFAULT_PRUNE_TARGET_GB
Definition: guiconstants.h:53
static constexpr bool DEFAULT_NATPMP
Definition: mapport.h:17
static constexpr bool DEFAULT_UPNP
Definition: mapport.h:11
QString getDefaultDataDirectory()
Determine default data directory for operating system.
Definition: guiutil.cpp:287
QString boostPathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
Definition: guiutil.cpp:783
bool SetStartOnSystemStartup(bool fAutoStart)
Definition: guiutil.cpp:768
bool GetStartOnSystemStartup()
Definition: guiutil.cpp:765
QStringList splitSkipEmptyParts(const QString &s, const QString &separator)
Definition: guiutil.cpp:446
static const bool DEFAULT_LISTEN
-listen default
Definition: net.h:87
@ NET_IPV4
IPv4.
Definition: netaddress.h:50
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.
Definition: optionsmodel.h:38
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
Definition: optionsmodel.h:24
const char * name
Definition: rest.cpp:47
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:87
ArgsManager gArgs
Definition: system.cpp:79
static constexpr int64_t DEFAULT_DB_CACHE_MB
-dbcache default (MiB)
Definition: txdb.h:39
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
Definition: validation.h:82