@@ -35,7 +35,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
35
35
ui(new Ui::OptionsDialog),
36
36
model(0 ),
37
37
mapper(0 ),
38
- fProxyIpValid (true )
38
+ fProxyIpsValid (true )
39
39
{
40
40
ui->setupUi (this );
41
41
@@ -54,10 +54,18 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
54
54
ui->proxyPort ->setEnabled (false );
55
55
ui->proxyPort ->setValidator (new QIntValidator (1 , 65535 , this ));
56
56
57
+ ui->proxyIpTor ->setEnabled (false );
58
+ ui->proxyPortTor ->setEnabled (false );
59
+ ui->proxyPortTor ->setValidator (new QIntValidator (1 , 65535 , this ));
60
+
57
61
connect (ui->connectSocks , SIGNAL (toggled (bool )), ui->proxyIp , SLOT (setEnabled (bool )));
58
62
connect (ui->connectSocks , SIGNAL (toggled (bool )), ui->proxyPort , SLOT (setEnabled (bool )));
59
63
64
+ connect (ui->connectSocksTor , SIGNAL (toggled (bool )), ui->proxyIpTor , SLOT (setEnabled (bool )));
65
+ connect (ui->connectSocksTor , SIGNAL (toggled (bool )), ui->proxyPortTor , SLOT (setEnabled (bool )));
66
+
60
67
ui->proxyIp ->installEventFilter (this );
68
+ ui->proxyIpTor ->installEventFilter (this );
61
69
62
70
/* Window elements init */
63
71
#ifdef Q_OS_MAC
@@ -110,7 +118,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
110
118
mapper->setSubmitPolicy (QDataWidgetMapper::ManualSubmit);
111
119
mapper->setOrientation (Qt::Vertical);
112
120
113
- /* setup/change UI elements when proxy IP is invalid/valid */
121
+ /* setup/change UI elements when proxy IPs are invalid/valid */
114
122
connect (this , SIGNAL (proxyIpChecks (QValidatedLineEdit *, int )), this , SLOT (doProxyIpChecks (QValidatedLineEdit *, int )));
115
123
}
116
124
@@ -137,6 +145,8 @@ void OptionsDialog::setModel(OptionsModel *model)
137
145
mapper->setModel (model);
138
146
setMapper ();
139
147
mapper->toFirst ();
148
+
149
+ updateDefaultProxyNets ();
140
150
}
141
151
142
152
/* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
@@ -149,6 +159,7 @@ void OptionsDialog::setModel(OptionsModel *model)
149
159
/* Network */
150
160
connect (ui->allowIncoming , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
151
161
connect (ui->connectSocks , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
162
+ connect (ui->connectSocksTor , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
152
163
/* Display */
153
164
connect (ui->lang , SIGNAL (valueChanged ()), this , SLOT (showRestartWarning ()));
154
165
connect (ui->thirdPartyTxUrls , SIGNAL (textChanged (const QString &)), this , SLOT (showRestartWarning ()));
@@ -173,6 +184,10 @@ void OptionsDialog::setMapper()
173
184
mapper->addMapping (ui->proxyIp , OptionsModel::ProxyIP);
174
185
mapper->addMapping (ui->proxyPort , OptionsModel::ProxyPort);
175
186
187
+ mapper->addMapping (ui->connectSocksTor , OptionsModel::ProxyUseTor);
188
+ mapper->addMapping (ui->proxyIpTor , OptionsModel::ProxyIPTor);
189
+ mapper->addMapping (ui->proxyPortTor , OptionsModel::ProxyPortTor);
190
+
176
191
/* Window */
177
192
#ifndef Q_OS_MAC
178
193
mapper->addMapping (ui->minimizeToTray , OptionsModel::MinimizeToTray);
@@ -188,7 +203,7 @@ void OptionsDialog::setMapper()
188
203
void OptionsDialog::enableOkButton ()
189
204
{
190
205
/* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */
191
- if (fProxyIpValid )
206
+ if (fProxyIpsValid )
192
207
setOkButtonState (true );
193
208
}
194
209
@@ -224,6 +239,7 @@ void OptionsDialog::on_okButton_clicked()
224
239
{
225
240
mapper->submit ();
226
241
accept ();
242
+ updateDefaultProxyNets ();
227
243
}
228
244
229
245
void OptionsDialog::on_cancelButton_clicked ()
@@ -257,11 +273,10 @@ void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPo
257
273
{
258
274
Q_UNUSED (nProxyPort);
259
275
260
- const std::string strAddrProxy = pUiProxyIp->text ().toStdString ();
261
276
CService addrProxy;
262
277
263
278
/* Check for a valid IPv4 / IPv6 address */
264
- if (!(fProxyIpValid = LookupNumeric (strAddrProxy .c_str (), addrProxy)))
279
+ if (!(fProxyIpsValid = LookupNumeric (pUiProxyIp-> text (). toStdString () .c_str (), addrProxy)))
265
280
{
266
281
disableOkButton ();
267
282
pUiProxyIp->setValid (false );
@@ -275,6 +290,28 @@ void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPo
275
290
}
276
291
}
277
292
293
+ void OptionsDialog::updateDefaultProxyNets ()
294
+ {
295
+ proxyType proxy;
296
+ std::string strProxy;
297
+ QString strDefaultProxyGUI;
298
+
299
+ GetProxy (NET_IPV4, proxy);
300
+ strProxy = proxy.proxy .ToStringIP () + " :" + proxy.proxy .ToStringPort ();
301
+ strDefaultProxyGUI = ui->proxyIp ->text () + " :" + ui->proxyPort ->text ();
302
+ (strProxy == strDefaultProxyGUI.toStdString ()) ? ui->proxyReachIPv4 ->setChecked (true ) : ui->proxyReachIPv4 ->setChecked (false );
303
+
304
+ GetProxy (NET_IPV6, proxy);
305
+ strProxy = proxy.proxy .ToStringIP () + " :" + proxy.proxy .ToStringPort ();
306
+ strDefaultProxyGUI = ui->proxyIp ->text () + " :" + ui->proxyPort ->text ();
307
+ (strProxy == strDefaultProxyGUI.toStdString ()) ? ui->proxyReachIPv6 ->setChecked (true ) : ui->proxyReachIPv6 ->setChecked (false );
308
+
309
+ GetProxy (NET_TOR, proxy);
310
+ strProxy = proxy.proxy .ToStringIP () + " :" + proxy.proxy .ToStringPort ();
311
+ strDefaultProxyGUI = ui->proxyIp ->text () + " :" + ui->proxyPort ->text ();
312
+ (strProxy == strDefaultProxyGUI.toStdString ()) ? ui->proxyReachTor ->setChecked (true ) : ui->proxyReachTor ->setChecked (false );
313
+ }
314
+
278
315
bool OptionsDialog::eventFilter (QObject *object, QEvent *event)
279
316
{
280
317
if (event->type () == QEvent::FocusOut)
@@ -283,6 +320,10 @@ bool OptionsDialog::eventFilter(QObject *object, QEvent *event)
283
320
{
284
321
Q_EMIT proxyIpChecks (ui->proxyIp , ui->proxyPort ->text ().toInt ());
285
322
}
323
+ else if (object == ui->proxyIpTor )
324
+ {
325
+ Q_EMIT proxyIpChecks (ui->proxyIpTor , ui->proxyPortTor ->text ().toInt ());
326
+ }
286
327
}
287
328
return QDialog::eventFilter (object, event);
288
329
}
0 commit comments