Browse Source

[Qt] don't allow to store invalid proxy ports

0.13
Jonas Schnelli 9 years ago
parent
commit
2a8e8c2e37
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 13
      src/qt/optionsdialog.cpp
  2. 2
      src/qt/optionsdialog.h

13
src/qt/optionsdialog.cpp

@ -59,9 +59,11 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool))); connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool))); connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));
connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, SLOT(setEnabled(bool))); connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyIpTor, SLOT(setEnabled(bool)));
connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, SLOT(setEnabled(bool))); connect(ui->connectSocksTor, SIGNAL(toggled(bool)), ui->proxyPortTor, SLOT(setEnabled(bool)));
connect(ui->connectSocksTor, SIGNAL(toggled(bool)), this, SLOT(updateProxyValidationState()));
/* Window elements init */ /* Window elements init */
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
@ -117,8 +119,10 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
/* setup/change UI elements when proxy IPs are invalid/valid */ /* setup/change UI elements when proxy IPs are invalid/valid */
ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent)); ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent));
ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent)); ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent));
connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState(QValidatedLineEdit *))); connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState()));
connect(ui->proxyIpTor, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState(QValidatedLineEdit *))); connect(ui->proxyIpTor, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState()));
connect(ui->proxyPort, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
connect(ui->proxyPortTor, SIGNAL(textChanged(const QString&)), this, SLOT(updateProxyValidationState()));
} }
OptionsDialog::~OptionsDialog() OptionsDialog::~OptionsDialog()
@ -256,10 +260,11 @@ void OptionsDialog::clearStatusLabel()
ui->statusLabel->clear(); ui->statusLabel->clear();
} }
void OptionsDialog::updateProxyValidationState(QValidatedLineEdit *pUiProxyIp) void OptionsDialog::updateProxyValidationState()
{ {
QValidatedLineEdit *pUiProxyIp = ui->proxyIp;
QValidatedLineEdit *otherProxyWidget = (pUiProxyIp == ui->proxyIpTor) ? ui->proxyIp : ui->proxyIpTor; QValidatedLineEdit *otherProxyWidget = (pUiProxyIp == ui->proxyIpTor) ? ui->proxyIp : ui->proxyIpTor;
if (pUiProxyIp->isValid()) if (pUiProxyIp->isValid() && (!ui->proxyPort->isEnabled() || ui->proxyPort->text().toInt() > 0) && (!ui->proxyPortTor->isEnabled() || ui->proxyPortTor->text().toInt() > 0))
{ {
setOkButtonState(otherProxyWidget->isValid()); //only enable ok button if both proxys are valid setOkButtonState(otherProxyWidget->isValid()); //only enable ok button if both proxys are valid
ui->statusLabel->clear(); ui->statusLabel->clear();

2
src/qt/optionsdialog.h

@ -52,7 +52,7 @@ private Q_SLOTS:
void showRestartWarning(bool fPersistent = false); void showRestartWarning(bool fPersistent = false);
void clearStatusLabel(); void clearStatusLabel();
void updateProxyValidationState(QValidatedLineEdit *pUiProxyIp); void updateProxyValidationState();
/* query the networks, for which the default proxy is used */ /* query the networks, for which the default proxy is used */
void updateDefaultProxyNets(); void updateDefaultProxyNets();

Loading…
Cancel
Save