|
|
@ -34,8 +34,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : |
|
|
|
QDialog(parent), |
|
|
|
QDialog(parent), |
|
|
|
ui(new Ui::OptionsDialog), |
|
|
|
ui(new Ui::OptionsDialog), |
|
|
|
model(0), |
|
|
|
model(0), |
|
|
|
mapper(0), |
|
|
|
mapper(0) |
|
|
|
fProxyIpsValid(true) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->setupUi(this); |
|
|
|
ui->setupUi(this); |
|
|
|
|
|
|
|
|
|
|
@ -60,12 +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())); |
|
|
|
ui->proxyIp->installEventFilter(this); |
|
|
|
|
|
|
|
ui->proxyIpTor->installEventFilter(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Window elements init */ |
|
|
|
/* Window elements init */ |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
#ifdef Q_OS_MAC |
|
|
@ -119,7 +117,12 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : |
|
|
|
mapper->setOrientation(Qt::Vertical); |
|
|
|
mapper->setOrientation(Qt::Vertical); |
|
|
|
|
|
|
|
|
|
|
|
/* setup/change UI elements when proxy IPs are invalid/valid */ |
|
|
|
/* setup/change UI elements when proxy IPs are invalid/valid */ |
|
|
|
connect(this, SIGNAL(proxyIpChecks(QValidatedLineEdit *, int)), this, SLOT(doProxyIpChecks(QValidatedLineEdit *, int))); |
|
|
|
ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent)); |
|
|
|
|
|
|
|
ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent)); |
|
|
|
|
|
|
|
connect(ui->proxyIp, SIGNAL(validationDidChange(QValidatedLineEdit *)), this, SLOT(updateProxyValidationState())); |
|
|
|
|
|
|
|
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() |
|
|
@ -200,18 +203,6 @@ void OptionsDialog::setMapper() |
|
|
|
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); |
|
|
|
mapper->addMapping(ui->thirdPartyTxUrls, OptionsModel::ThirdPartyTxUrls); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::enableOkButton() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */ |
|
|
|
|
|
|
|
if(fProxyIpsValid) |
|
|
|
|
|
|
|
setOkButtonState(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::disableOkButton() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setOkButtonState(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::setOkButtonState(bool fState) |
|
|
|
void OptionsDialog::setOkButtonState(bool fState) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ui->okButton->setEnabled(fState); |
|
|
|
ui->okButton->setEnabled(fState); |
|
|
@ -269,24 +260,20 @@ void OptionsDialog::clearStatusLabel() |
|
|
|
ui->statusLabel->clear(); |
|
|
|
ui->statusLabel->clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort) |
|
|
|
void OptionsDialog::updateProxyValidationState() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_UNUSED(nProxyPort); |
|
|
|
QValidatedLineEdit *pUiProxyIp = ui->proxyIp; |
|
|
|
|
|
|
|
QValidatedLineEdit *otherProxyWidget = (pUiProxyIp == ui->proxyIpTor) ? ui->proxyIp : ui->proxyIpTor; |
|
|
|
CService addrProxy; |
|
|
|
if (pUiProxyIp->isValid() && (!ui->proxyPort->isEnabled() || ui->proxyPort->text().toInt() > 0) && (!ui->proxyPortTor->isEnabled() || ui->proxyPortTor->text().toInt() > 0)) |
|
|
|
|
|
|
|
|
|
|
|
/* Check for a valid IPv4 / IPv6 address */ |
|
|
|
|
|
|
|
if (!(fProxyIpsValid = LookupNumeric(pUiProxyIp->text().toStdString().c_str(), addrProxy))) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
disableOkButton(); |
|
|
|
setOkButtonState(otherProxyWidget->isValid()); //only enable ok button if both proxys are valid
|
|
|
|
pUiProxyIp->setValid(false); |
|
|
|
ui->statusLabel->clear(); |
|
|
|
ui->statusLabel->setStyleSheet("QLabel { color: red; }"); |
|
|
|
|
|
|
|
ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
enableOkButton(); |
|
|
|
setOkButtonState(false); |
|
|
|
ui->statusLabel->clear(); |
|
|
|
ui->statusLabel->setStyleSheet("QLabel { color: red; }"); |
|
|
|
|
|
|
|
ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -312,18 +299,18 @@ void OptionsDialog::updateDefaultProxyNets() |
|
|
|
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) : ui->proxyReachTor->setChecked(false); |
|
|
|
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) : ui->proxyReachTor->setChecked(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool OptionsDialog::eventFilter(QObject *object, QEvent *event) |
|
|
|
ProxyAddressValidator::ProxyAddressValidator(QObject *parent) : |
|
|
|
|
|
|
|
QValidator(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(event->type() == QEvent::FocusOut) |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
if(object == ui->proxyIp) |
|
|
|
QValidator::State ProxyAddressValidator::validate(QString &input, int &pos) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_EMIT proxyIpChecks(ui->proxyIp, ui->proxyPort->text().toInt()); |
|
|
|
Q_UNUSED(pos); |
|
|
|
} |
|
|
|
// Validate the proxy
|
|
|
|
else if(object == ui->proxyIpTor) |
|
|
|
proxyType addrProxy = proxyType(CService(input.toStdString(), 9050), true); |
|
|
|
{ |
|
|
|
if (addrProxy.IsValid()) |
|
|
|
Q_EMIT proxyIpChecks(ui->proxyIpTor, ui->proxyPortTor->text().toInt()); |
|
|
|
return QValidator::Acceptable; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return QValidator::Invalid; |
|
|
|
return QDialog::eventFilter(object, event); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|