11
11
#include < qt/bitcoinunits.h>
12
12
#include < qt/guiutil.h>
13
13
14
- #include < init .h>
14
+ #include < interface/node .h>
15
15
#include < validation.h> // For DEFAULT_SCRIPTCHECK_THREADS
16
16
#include < net.h>
17
17
#include < netbase.h>
18
18
#include < txdb.h> // for -dbcache defaults
19
19
#include < qt/intro.h>
20
20
21
- #ifdef ENABLE_WALLET
22
- #include < wallet/wallet.h>
23
- #include < wallet/walletdb.h>
24
- #endif
25
-
26
21
#include < QNetworkProxy>
27
22
#include < QSettings>
28
23
#include < QStringList>
29
24
30
25
const char *DEFAULT_GUI_PROXY_HOST = " 127.0.0.1" ;
31
26
32
- OptionsModel::OptionsModel (QObject *parent, bool resetSettings) :
33
- QAbstractListModel(parent)
27
+ OptionsModel::OptionsModel (interface::Node& node, QObject *parent, bool resetSettings) :
28
+ QAbstractListModel(parent), m_node(node)
34
29
{
35
30
Init (resetSettings);
36
31
}
@@ -93,12 +88,12 @@ void OptionsModel::Init(bool resetSettings)
93
88
// Main
94
89
if (!settings.contains (" nDatabaseCache" ))
95
90
settings.setValue (" nDatabaseCache" , (qint64)nDefaultDbCache);
96
- if (!gArgs . SoftSetArg (" -dbcache" , settings.value (" nDatabaseCache" ).toString ().toStdString ()))
91
+ if (!m_node. softSetArg (" -dbcache" , settings.value (" nDatabaseCache" ).toString ().toStdString ()))
97
92
addOverriddenOption (" -dbcache" );
98
93
99
94
if (!settings.contains (" nThreadsScriptVerif" ))
100
95
settings.setValue (" nThreadsScriptVerif" , DEFAULT_SCRIPTCHECK_THREADS);
101
- if (!gArgs . SoftSetArg (" -par" , settings.value (" nThreadsScriptVerif" ).toString ().toStdString ()))
96
+ if (!m_node. softSetArg (" -par" , settings.value (" nThreadsScriptVerif" ).toString ().toStdString ()))
102
97
addOverriddenOption (" -par" );
103
98
104
99
if (!settings.contains (" strDataDir" ))
@@ -108,27 +103,27 @@ void OptionsModel::Init(bool resetSettings)
108
103
#ifdef ENABLE_WALLET
109
104
if (!settings.contains (" bSpendZeroConfChange" ))
110
105
settings.setValue (" bSpendZeroConfChange" , true );
111
- if (!gArgs . SoftSetBoolArg (" -spendzeroconfchange" , settings.value (" bSpendZeroConfChange" ).toBool ()))
106
+ if (!m_node. softSetBoolArg (" -spendzeroconfchange" , settings.value (" bSpendZeroConfChange" ).toBool ()))
112
107
addOverriddenOption (" -spendzeroconfchange" );
113
108
#endif
114
109
115
110
// Network
116
111
if (!settings.contains (" fUseUPnP" ))
117
112
settings.setValue (" fUseUPnP" , DEFAULT_UPNP);
118
- if (!gArgs . SoftSetBoolArg (" -upnp" , settings.value (" fUseUPnP" ).toBool ()))
113
+ if (!m_node. softSetBoolArg (" -upnp" , settings.value (" fUseUPnP" ).toBool ()))
119
114
addOverriddenOption (" -upnp" );
120
115
121
116
if (!settings.contains (" fListen" ))
122
117
settings.setValue (" fListen" , DEFAULT_LISTEN);
123
- if (!gArgs . SoftSetBoolArg (" -listen" , settings.value (" fListen" ).toBool ()))
118
+ if (!m_node. softSetBoolArg (" -listen" , settings.value (" fListen" ).toBool ()))
124
119
addOverriddenOption (" -listen" );
125
120
126
121
if (!settings.contains (" fUseProxy" ))
127
122
settings.setValue (" fUseProxy" , false );
128
123
if (!settings.contains (" addrProxy" ))
129
124
settings.setValue (" addrProxy" , QString (" %1:%2" ).arg (DEFAULT_GUI_PROXY_HOST, DEFAULT_GUI_PROXY_PORT));
130
125
// Only try to set -proxy, if user has enabled fUseProxy
131
- if (settings.value (" fUseProxy" ).toBool () && !gArgs . SoftSetArg (" -proxy" , settings.value (" addrProxy" ).toString ().toStdString ()))
126
+ if (settings.value (" fUseProxy" ).toBool () && !m_node. softSetArg (" -proxy" , settings.value (" addrProxy" ).toString ().toStdString ()))
132
127
addOverriddenOption (" -proxy" );
133
128
else if (!settings.value (" fUseProxy" ).toBool () && !gArgs .GetArg (" -proxy" , " " ).empty ())
134
129
addOverriddenOption (" -proxy" );
@@ -138,15 +133,15 @@ void OptionsModel::Init(bool resetSettings)
138
133
if (!settings.contains (" addrSeparateProxyTor" ))
139
134
settings.setValue (" addrSeparateProxyTor" , QString (" %1:%2" ).arg (DEFAULT_GUI_PROXY_HOST, DEFAULT_GUI_PROXY_PORT));
140
135
// Only try to set -onion, if user has enabled fUseSeparateProxyTor
141
- if (settings.value (" fUseSeparateProxyTor" ).toBool () && !gArgs . SoftSetArg (" -onion" , settings.value (" addrSeparateProxyTor" ).toString ().toStdString ()))
136
+ if (settings.value (" fUseSeparateProxyTor" ).toBool () && !m_node. softSetArg (" -onion" , settings.value (" addrSeparateProxyTor" ).toString ().toStdString ()))
142
137
addOverriddenOption (" -onion" );
143
138
else if (!settings.value (" fUseSeparateProxyTor" ).toBool () && !gArgs .GetArg (" -onion" , " " ).empty ())
144
139
addOverriddenOption (" -onion" );
145
140
146
141
// Display
147
142
if (!settings.contains (" language" ))
148
143
settings.setValue (" language" , " " );
149
- if (!gArgs . SoftSetArg (" -lang" , settings.value (" language" ).toString ().toStdString ()))
144
+ if (!m_node. softSetArg (" -lang" , settings.value (" language" ).toString ().toStdString ()))
150
145
addOverriddenOption (" -lang" );
151
146
152
147
language = settings.value (" language" ).toString ();
@@ -315,12 +310,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
315
310
break ;
316
311
case MapPortUPnP: // core option - can be changed on-the-fly
317
312
settings.setValue (" fUseUPnP" , value.toBool ());
318
- if (value.toBool ()) {
319
- StartMapPort ();
320
- } else {
321
- InterruptMapPort ();
322
- StopMapPort ();
323
- }
313
+ m_node.mapPort (value.toBool ());
324
314
break ;
325
315
case MinimizeOnClose:
326
316
fMinimizeOnClose = value.toBool ();
@@ -453,7 +443,7 @@ bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
453
443
// Directly query current base proxy, because
454
444
// GUI settings can be overridden with -proxy.
455
445
proxyType curProxy;
456
- if (GetProxy (NET_IPV4, curProxy)) {
446
+ if (m_node. getProxy (NET_IPV4, curProxy)) {
457
447
proxy.setType (QNetworkProxy::Socks5Proxy);
458
448
proxy.setHostName (QString::fromStdString (curProxy.proxy .ToStringIP ()));
459
449
proxy.setPort (curProxy.proxy .GetPort ());
0 commit comments