diff options
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoingui.cpp | 29 | ||||
-rw-r--r-- | src/qt/bitcoingui.h | 2 | ||||
-rw-r--r-- | src/qt/optionsdialog.cpp | 78 | ||||
-rw-r--r-- | src/qt/optionsdialog.h | 4 |
4 files changed, 58 insertions, 55 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 7b0e6f3bc0..afb829e08a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -501,6 +501,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) return; } + QString strStatusBarWarnings = clientModel->getStatusBarWarnings(); QString tooltip; if(count < nTotalBlocks) @@ -508,7 +509,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) int nRemainingBlocks = nTotalBlocks - count; float nPercentageDone = count / (nTotalBlocks * 0.01f); - if (clientModel->getStatusBarWarnings() == "") + if (strStatusBarWarnings.isEmpty()) { progressBarLabel->setText(tr("Synchronizing with network...")); progressBarLabel->setVisible(true); @@ -517,30 +518,28 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) progressBar->setValue(count); progressBar->setVisible(true); } - else - { - progressBarLabel->setText(clientModel->getStatusBarWarnings()); - progressBarLabel->setVisible(true); - progressBar->setVisible(false); - } + tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2); } else { - if (clientModel->getStatusBarWarnings() == "") + if (strStatusBarWarnings.isEmpty()) progressBarLabel->setVisible(false); - else - { - progressBarLabel->setText(clientModel->getStatusBarWarnings()); - progressBarLabel->setVisible(true); - } + progressBar->setVisible(false); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); } - QDateTime now = QDateTime::currentDateTime(); + // Override progressBarLabel text and hide progressBar, when we have warnings to display + if (!strStatusBarWarnings.isEmpty()) + { + progressBarLabel->setText(strStatusBarWarnings); + progressBarLabel->setVisible(true); + progressBar->setVisible(false); + } + QDateTime lastBlockDate = clientModel->getLastBlockDate(); - int secs = lastBlockDate.secsTo(now); + int secs = lastBlockDate.secsTo(QDateTime::currentDateTime()); QString text; // Represent time from last generated block in human readable text diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 9e0cd0c190..adc75b0481 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -112,7 +112,7 @@ public slots: /** Set number of connections shown in the UI */ void setNumConnections(int count); /** Set number of blocks shown in the UI */ - void setNumBlocks(int count, int countOfPeers); + void setNumBlocks(int count, int nTotalBlocks); /** Set the encryption status as shown in the UI. @param[in] status current encryption status @see WalletModel::EncryptionStatus diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 5f39c7814d..6bb7eaec2e 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -1,26 +1,17 @@ #include "optionsdialog.h" #include "ui_optionsdialog.h" -#include "bitcoinamountfield.h" #include "bitcoinunits.h" #include "monitoreddatamapper.h" #include "netbase.h" #include "optionsmodel.h" -#include "qvalidatedlineedit.h" -#include "qvaluecombobox.h" -#include <QCheckBox> #include <QDir> #include <QIntValidator> -#include <QLabel> -#include <QLineEdit> #include <QLocale> #include <QMessageBox> -#include <QPushButton> #include <QRegExp> #include <QRegExpValidator> -#include <QTabWidget> -#include <QWidget> OptionsDialog::OptionsDialog(QWidget *parent) : QDialog(parent), @@ -38,18 +29,19 @@ OptionsDialog::OptionsDialog(QWidget *parent) : ui->mapPortUpnp->setEnabled(false); #endif + ui->proxyIp->setEnabled(false); + ui->proxyPort->setEnabled(false); + ui->proxyPort->setValidator(new QIntValidator(1, 65535, this)); + ui->socksVersion->setEnabled(false); ui->socksVersion->addItem("5", 5); ui->socksVersion->addItem("4", 4); ui->socksVersion->setCurrentIndex(0); - ui->proxyIp->setEnabled(false); - ui->proxyPort->setEnabled(false); - ui->proxyPort->setValidator(new QIntValidator(0, 65535, this)); - - connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, 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->socksVersion, SLOT(setEnabled(bool))); + connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy())); ui->proxyIp->installEventFilter(this); @@ -90,9 +82,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) : ui->unit->setModel(new BitcoinUnits(this)); - connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy())); - connect(ui->lang, SIGNAL(activated(int)), this, SLOT(showRestartWarning_Lang())); - /* Widget-to-option mapper */ mapper = new MonitoredDataMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); @@ -102,8 +91,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) : connect(mapper, SIGNAL(viewModified()), this, SLOT(enableSaveButtons())); /* disable save buttons when new data loaded */ connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableSaveButtons())); - /* disable/enable save buttons when proxy IP is invalid/valid */ - connect(this, SIGNAL(proxyIpValid(bool)), this, SLOT(setSaveButtonState(bool))); + /* setup/change UI elements when proxy IP is invalid/valid */ + connect(this, SIGNAL(proxyIpValid(QValidatedLineEdit *, bool)), this, SLOT(handleProxyIpValid(QValidatedLineEdit *, bool))); } OptionsDialog::~OptionsDialog() @@ -124,8 +113,11 @@ void OptionsDialog::setModel(OptionsModel *model) mapper->toFirst(); } - // update the display unit, to not use the default ("BTC") + /* update the display unit, to not use the default ("BTC") */ updateDisplayUnit(); + + /* warn only when language selection changes (placed here so init of ui->lang via mapper doesn't trigger this) */ + connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning_Lang())); } void OptionsDialog::setMapper() @@ -137,10 +129,11 @@ void OptionsDialog::setMapper() /* Network */ mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); + mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); - mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion); mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); + mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion); /* Window */ #ifndef Q_WS_MAC @@ -156,7 +149,7 @@ void OptionsDialog::setMapper() void OptionsDialog::enableSaveButtons() { - // prevent enabling of the save buttons when data modified, if there is an invalid proxy address present + /* prevent enabling of the save buttons when data modified, if there is an invalid proxy address present */ if(fProxyIpValid) setSaveButtonState(true); } @@ -211,30 +204,39 @@ void OptionsDialog::updateDisplayUnit() { if(model) { - // Update transactionFee with the current unit + /* Update transactionFee with the current unit */ ui->transactionFee->setDisplayUnit(model->getDisplayUnit()); } } +void OptionsDialog::handleProxyIpValid(QValidatedLineEdit *object, bool fState) +{ + // this is used in a check before re-enabling the save buttons + fProxyIpValid = fState; + + if(fProxyIpValid) + { + enableSaveButtons(); + ui->statusLabel->clear(); + } + else + { + disableSaveButtons(); + object->setValid(fProxyIpValid); + ui->statusLabel->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); + } +} + bool OptionsDialog::eventFilter(QObject *object, QEvent *event) { - if(object == ui->proxyIp && event->type() == QEvent::FocusOut) + if(event->type() == QEvent::FocusOut) { - // Check proxyIP for a valid IPv4/IPv6 address - CService addr; - if(!LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr)) - { - ui->proxyIp->setValid(false); - fProxyIpValid = false; - ui->statusLabel->setStyleSheet("QLabel { color: red; }"); - ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); - emit proxyIpValid(false); - } - else + if(object == ui->proxyIp) { - fProxyIpValid = true; - ui->statusLabel->clear(); - emit proxyIpValid(true); + CService addr; + /* Check proxyIp for a valid IPv4/IPv6 address and emit the proxyIpValid signal */ + emit proxyIpValid(ui->proxyIp, LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr)); } } return QDialog::eventFilter(object, event); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 7e91c96475..9e91000b63 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -8,6 +8,7 @@ class OptionsDialog; } class OptionsModel; class MonitoredDataMapper; +class QValidatedLineEdit; /** Preferences dialog. */ class OptionsDialog : public QDialog @@ -38,9 +39,10 @@ private slots: void showRestartWarning_Proxy(); void showRestartWarning_Lang(); void updateDisplayUnit(); + void handleProxyIpValid(QValidatedLineEdit *object, bool fState); signals: - void proxyIpValid(bool fValid); + void proxyIpValid(QValidatedLineEdit *object, bool fValid); private: Ui::OptionsDialog *ui; |