@@ -59,6 +59,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(paren
5959 connect (ui->connectSocks , SIGNAL (toggled (bool )), ui->proxyPort , SLOT (setEnabled (bool )));
6060
6161 ui->proxyIp ->installEventFilter (this );
62+ ui->proxyPort ->installEventFilter (this );
6263
6364/* Window elements init */
6465#ifdef Q_OS_MAC
@@ -142,7 +143,7 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) : QDialog(paren
142143 mapper->setOrientation (Qt::Vertical);
143144
144145 /* setup/change UI elements when proxy IP is invalid/valid */
145- connect (this , SIGNAL (proxyIpChecks (QValidatedLineEdit*, int )), this , SLOT (doProxyIpChecks (QValidatedLineEdit*, int )));
146+ connect (this , SIGNAL (proxyIpChecks (QValidatedLineEdit*, QLineEdit* )), this , SLOT (doProxyIpChecks (QValidatedLineEdit*, QLineEdit* )));
146147}
147148
148149OptionsDialog::~OptionsDialog ()
@@ -299,30 +300,44 @@ void OptionsDialog::clearStatusLabel()
299300 ui->statusLabel ->clear ();
300301}
301302
302- void OptionsDialog::doProxyIpChecks (QValidatedLineEdit* pUiProxyIp, int nProxyPort )
303+ void OptionsDialog::doProxyIpChecks (QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort )
303304{
304- Q_UNUSED (nProxyPort);
305-
306305 const std::string strAddrProxy = pUiProxyIp->text ().toStdString ();
307306 CService addrProxy;
308307
309- /* Check for a valid IPv4 / IPv6 address */
308+ // Check for a valid IPv4 / IPv6 address
310309 if (!(fProxyIpValid = LookupNumeric (strAddrProxy.c_str (), addrProxy))) {
311310 disableOkButton ();
312311 pUiProxyIp->setValid (false );
313312 ui->statusLabel ->setStyleSheet (" QLabel { color: red; }" );
314313 ui->statusLabel ->setText (tr (" The supplied proxy address is invalid." ));
315- } else {
316- enableOkButton ();
317- ui->statusLabel ->clear ();
314+ return ;
315+ }
316+ // Check proxy port
317+ if (!pUiProxyPort->hasAcceptableInput ()){
318+ disableOkButton ();
319+ ui->statusLabel ->setStyleSheet (" QLabel { color: red; }" );
320+ ui->statusLabel ->setText (tr (" The supplied proxy port is invalid." ));
321+ return ;
318322 }
323+
324+ proxyType checkProxy = proxyType (addrProxy);
325+ if (!checkProxy.IsValid ()) {
326+ disableOkButton ();
327+ ui->statusLabel ->setStyleSheet (" QLabel { color: red; }" );
328+ ui->statusLabel ->setText (tr (" The supplied proxy settings are invalid." ));
329+ return ;
330+ }
331+
332+ enableOkButton ();
333+ ui->statusLabel ->clear ();
319334}
320335
321336bool OptionsDialog::eventFilter (QObject* object, QEvent* event)
322337{
323338 if (event->type () == QEvent::FocusOut) {
324- if (object == ui->proxyIp ) {
325- emit proxyIpChecks (ui->proxyIp , ui->proxyPort -> text (). toInt () );
339+ if (object == ui->proxyIp || object == ui-> proxyPort ) {
340+ emit proxyIpChecks (ui->proxyIp , ui->proxyPort );
326341 }
327342 }
328343 return QDialog::eventFilter (object, event);
0 commit comments