aboutsummaryrefslogtreecommitdiff
path: root/src/qt/optionsdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/optionsdialog.cpp')
-rw-r--r--src/qt/optionsdialog.cpp132
1 files changed, 64 insertions, 68 deletions
diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp
index 0a569d16f4..d024e3b7aa 100644
--- a/src/qt/optionsdialog.cpp
+++ b/src/qt/optionsdialog.cpp
@@ -10,6 +10,7 @@
#include "ui_optionsdialog.h"
#include "bitcoinunits.h"
+#include "guiutil.h"
#include "monitoreddatamapper.h"
#include "optionsmodel.h"
@@ -19,17 +20,20 @@
#include <QIntValidator>
#include <QLocale>
#include <QMessageBox>
+#include <QTimer>
OptionsDialog::OptionsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OptionsDialog),
model(0),
mapper(0),
- fRestartWarningDisplayed_Proxy(false),
- fRestartWarningDisplayed_Lang(false),
fProxyIpValid(true)
{
ui->setupUi(this);
+ GUIUtil::restoreWindowGeometry("nOptionsDialogWindow", this->size(), this);
+
+ /* Main elements init */
+ ui->databaseCache->setMaximum(sizeof(void*) > 4 ? 4096 : 1024);
/* Network elements init */
#ifndef USE_UPNP
@@ -40,6 +44,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
ui->proxyPort->setEnabled(false);
ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));
+ /** SOCKS version is only selectable for default proxy and is always 5 for IPv6 and Tor */
ui->socksVersion->setEnabled(false);
ui->socksVersion->addItem("5", 5);
ui->socksVersion->addItem("4", 4);
@@ -95,16 +100,13 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
mapper->setOrientation(Qt::Vertical);
- /* enable apply button when data modified */
- connect(mapper, SIGNAL(viewModified()), this, SLOT(enableApplyButton()));
- /* disable apply button when new data loaded */
- connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableApplyButton()));
/* setup/change UI elements when proxy IP is invalid/valid */
- connect(this, SIGNAL(proxyIpValid(QValidatedLineEdit *, bool)), this, SLOT(handleProxyIpValid(QValidatedLineEdit *, bool)));
+ connect(this, SIGNAL(proxyIpChecks(QValidatedLineEdit *, int)), this, SLOT(doProxyIpChecks(QValidatedLineEdit *, int)));
}
OptionsDialog::~OptionsDialog()
{
+ GUIUtil::saveWindowGeometry("nOptionsDialogWindow", this);
delete ui;
}
@@ -114,6 +116,15 @@ void OptionsDialog::setModel(OptionsModel *model)
if(model)
{
+ /* check if client restart is needed and show persistent message */
+ if (model->isRestartRequired())
+ showRestartWarning(true);
+
+ QString strLabel = model->getOverriddenByCommandLine();
+ if (strLabel.isEmpty())
+ strLabel = tr("none");
+ ui->overriddenByCommandLineLabel->setText(strLabel);
+
connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
mapper->setModel(model);
@@ -124,11 +135,15 @@ void OptionsDialog::setModel(OptionsModel *model)
/* update the display unit, to not use the default ("BTC") */
updateDisplayUnit();
- /* warn only when language selection changes by user action (placed here so init via mapper doesn't trigger this) */
- connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning_Lang()));
+ /* warn when one of the following settings changes by user action (placed here so init via mapper doesn't trigger them) */
- /* disable apply button after settings are loaded as there is nothing to save */
- disableApplyButton();
+ /* Main */
+ connect(ui->databaseCache, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
+ connect(ui->threadsScriptVerif, SIGNAL(valueChanged(int)), this, SLOT(showRestartWarning()));
+ /* Network */
+ connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
+ /* Display */
+ connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
}
void OptionsDialog::setMapper()
@@ -136,6 +151,8 @@ void OptionsDialog::setMapper()
/* Main */
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
+ mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
+ mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
/* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
@@ -158,31 +175,20 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
}
-void OptionsDialog::enableApplyButton()
-{
- ui->applyButton->setEnabled(true);
-}
-
-void OptionsDialog::disableApplyButton()
-{
- ui->applyButton->setEnabled(false);
-}
-
-void OptionsDialog::enableSaveButtons()
+void OptionsDialog::enableOkButton()
{
- /* prevent enabling of the save buttons when data modified, if there is an invalid proxy address present */
+ /* prevent enabling of the OK button when data modified, if there is an invalid proxy address present */
if(fProxyIpValid)
- setSaveButtonState(true);
+ setOkButtonState(true);
}
-void OptionsDialog::disableSaveButtons()
+void OptionsDialog::disableOkButton()
{
- setSaveButtonState(false);
+ setOkButtonState(false);
}
-void OptionsDialog::setSaveButtonState(bool fState)
+void OptionsDialog::setOkButtonState(bool fState)
{
- ui->applyButton->setEnabled(fState);
ui->okButton->setEnabled(fState);
}
@@ -192,24 +198,15 @@ void OptionsDialog::on_resetButton_clicked()
{
// confirmation dialog
QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"),
- tr("Some settings may require a client restart to take effect.") + "<br><br>" + tr("Do you want to proceed?"),
+ tr("Client restart required to activate changes.") + "<br><br>" + tr("Client will be shutdown, do you want to proceed?"),
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
if(btnRetVal == QMessageBox::Cancel)
return;
- disableApplyButton();
-
- /* disable restart warning messages display */
- fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = true;
-
- /* reset all options and save the default values (QSettings) */
+ /* reset all options and close Bitcoin-Qt */
model->Reset();
- mapper->toFirst();
- mapper->submit();
-
- /* re-enable restart warning messages display */
- fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = false;
+ QApplication::quit();
}
}
@@ -224,28 +221,26 @@ void OptionsDialog::on_cancelButton_clicked()
reject();
}
-void OptionsDialog::on_applyButton_clicked()
+void OptionsDialog::showRestartWarning(bool fPersistent)
{
- mapper->submit();
- disableApplyButton();
-}
+ ui->statusLabel->setStyleSheet("QLabel { color: red; }");
-void OptionsDialog::showRestartWarning_Proxy()
-{
- if(!fRestartWarningDisplayed_Proxy)
+ if(fPersistent)
+ {
+ ui->statusLabel->setText(tr("Client restart required to activate changes."));
+ }
+ else
{
- QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok);
- fRestartWarningDisplayed_Proxy = true;
+ ui->statusLabel->setText(tr("This change would require a client restart."));
+ // clear non-persistent status label after 10 seconds
+ // Todo: should perhaps be a class attribute, if we extend the use of statusLabel
+ QTimer::singleShot(10000, this, SLOT(clearStatusLabel()));
}
}
-void OptionsDialog::showRestartWarning_Lang()
+void OptionsDialog::clearStatusLabel()
{
- if(!fRestartWarningDisplayed_Lang)
- {
- QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Bitcoin."), QMessageBox::Ok);
- fRestartWarningDisplayed_Lang = true;
- }
+ ui->statusLabel->clear();
}
void OptionsDialog::updateDisplayUnit()
@@ -257,22 +252,25 @@ void OptionsDialog::updateDisplayUnit()
}
}
-void OptionsDialog::handleProxyIpValid(QValidatedLineEdit *object, bool fState)
+void OptionsDialog::doProxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort)
{
- // this is used in a check before re-enabling the save buttons
- fProxyIpValid = fState;
+ Q_UNUSED(nProxyPort);
- if(fProxyIpValid)
+ const std::string strAddrProxy = pUiProxyIp->text().toStdString();
+ CService addrProxy;
+
+ /* Check for a valid IPv4 / IPv6 address */
+ if (!(fProxyIpValid = LookupNumeric(strAddrProxy.c_str(), addrProxy)))
{
- enableSaveButtons();
- ui->statusLabel->clear();
+ disableOkButton();
+ pUiProxyIp->setValid(false);
+ ui->statusLabel->setStyleSheet("QLabel { color: red; }");
+ ui->statusLabel->setText(tr("The supplied proxy address is invalid."));
}
else
{
- disableSaveButtons();
- object->setValid(fProxyIpValid);
- ui->statusLabel->setStyleSheet("QLabel { color: red; }");
- ui->statusLabel->setText(tr("The supplied proxy address is invalid."));
+ enableOkButton();
+ ui->statusLabel->clear();
}
}
@@ -282,9 +280,7 @@ bool OptionsDialog::eventFilter(QObject *object, QEvent *event)
{
if(object == ui->proxyIp)
{
- 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));
+ emit proxyIpChecks(ui->proxyIp, ui->proxyPort->text().toInt());
}
}
return QDialog::eventFilter(object, event);