@@ -35,7 +35,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
3535 ui(new Ui::OptionsDialog),
3636 model(0 ),
3737 mapper(0 ),
38- fProxyIpValid (true )
38+ fProxyIpsValid (true )
3939{
4040 ui->setupUi (this );
4141
@@ -54,10 +54,18 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
5454 ui->proxyPort ->setEnabled (false );
5555 ui->proxyPort ->setValidator (new QIntValidator (1 , 65535 , this ));
5656
57+ ui->proxyIpTor ->setEnabled (false );
58+ ui->proxyPortTor ->setEnabled (false );
59+ ui->proxyPortTor ->setValidator (new QIntValidator (1 , 65535 , this ));
60+
5761 connect (ui->connectSocks , SIGNAL (toggled (bool )), ui->proxyIp , SLOT (setEnabled (bool )));
5862 connect (ui->connectSocks , SIGNAL (toggled (bool )), ui->proxyPort , SLOT (setEnabled (bool )));
5963
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+
6067 ui->proxyIp ->installEventFilter (this );
68+ ui->proxyIpTor ->installEventFilter (this );
6169
6270 /* Window elements init */
6371#ifdef Q_OS_MAC
@@ -110,7 +118,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
110118 mapper->setSubmitPolicy (QDataWidgetMapper::ManualSubmit);
111119 mapper->setOrientation (Qt::Vertical);
112120
113- /* setup/change UI elements when proxy IP is invalid/valid */
121+ /* setup/change UI elements when proxy IPs are invalid/valid */
114122 connect (this , SIGNAL (proxyIpChecks (QValidatedLineEdit *, int )), this , SLOT (doProxyIpChecks (QValidatedLineEdit *, int )));
115123}
116124
@@ -137,6 +145,8 @@ void OptionsDialog::setModel(OptionsModel *model)
137145 mapper->setModel (model);
138146 setMapper ();
139147 mapper->toFirst ();
148+
149+ updateDefaultProxyNets ();
140150 }
141151
142152 /* 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)
149159 /* Network */
150160 connect (ui->allowIncoming , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
151161 connect (ui->connectSocks , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
162+ connect (ui->connectSocksTor , SIGNAL (clicked (bool )), this , SLOT (showRestartWarning ()));
152163 /* Display */
153164 connect (ui->lang , SIGNAL (valueChanged ()), this , SLOT (showRestartWarning ()));
154165 connect (ui->thirdPartyTxUrls , SIGNAL (textChanged (const QString &)), this , SLOT (showRestartWarning ()));
@@ -173,6 +184,10 @@ void OptionsDialog::setMapper()
173184 mapper->addMapping (ui->proxyIp , OptionsModel::ProxyIP);
174185 mapper->addMapping (ui->proxyPort , OptionsModel::ProxyPort);
175186
187+ mapper->addMapping (ui->connectSocksTor , OptionsModel::ProxyUseTor);
188+ mapper->addMapping (ui->proxyIpTor , OptionsModel::ProxyIPTor);
189+ mapper->addMapping (ui->proxyPortTor , OptionsModel::ProxyPortTor);
190+
176191 /* Window */
177192#ifndef Q_OS_MAC
178193 mapper->addMapping (ui->minimizeToTray , OptionsModel::MinimizeToTray);
@@ -188,7 +203,7 @@ void OptionsDialog::setMapper()
188203void OptionsDialog::enableOkButton ()
189204{
190205 /* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */
191- if (fProxyIpValid )
206+ if (fProxyIpsValid )
192207 setOkButtonState (true );
193208}
194209
@@ -224,6 +239,7 @@ void OptionsDialog::on_okButton_clicked()
224239{
225240 mapper->submit ();
226241 accept ();
242+ updateDefaultProxyNets ();
227243}
228244
229245void OptionsDialog::on_cancelButton_clicked ()
@@ -257,11 +273,10 @@ void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPo
257273{
258274 Q_UNUSED (nProxyPort);
259275
260- const std::string strAddrProxy = pUiProxyIp->text ().toStdString ();
261276 CService addrProxy;
262277
263278 /* 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)))
265280 {
266281 disableOkButton ();
267282 pUiProxyIp->setValid (false );
@@ -275,6 +290,28 @@ void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPo
275290 }
276291}
277292
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+
278315bool OptionsDialog::eventFilter (QObject *object, QEvent *event)
279316{
280317 if (event->type () == QEvent::FocusOut)
@@ -283,6 +320,10 @@ bool OptionsDialog::eventFilter(QObject *object, QEvent *event)
283320 {
284321 Q_EMIT proxyIpChecks (ui->proxyIp , ui->proxyPort ->text ().toInt ());
285322 }
323+ else if (object == ui->proxyIpTor )
324+ {
325+ Q_EMIT proxyIpChecks (ui->proxyIpTor , ui->proxyPortTor ->text ().toInt ());
326+ }
286327 }
287328 return QDialog::eventFilter (object, event);
288329}
0 commit comments