5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
9#include <qt/forms/ui_optionsdialog.h>
19#include <validation.h>
21#include <QDataWidgetMapper>
23#include <QIntValidator>
27#include <QSystemTrayIcon>
40 ui->pruneWarning->setVisible(
false);
41 ui->pruneWarning->setStyleSheet(
"QLabel { color: red; }");
43 ui->pruneSize->setEnabled(
false);
44 connect(
ui->prune, &QPushButton::toggled,
ui->pruneSize,
45 &QWidget::setEnabled);
49 ui->mapPortUpnp->setEnabled(
false);
52 ui->mapPortNatpmp->setEnabled(
false);
54 connect(
this, &QDialog::accepted, [
this]() {
56 model->
node().mapPort(settings.value(
"fUseUPnP").toBool(),
57 settings.value(
"fUseNatpmp").toBool());
60 ui->proxyIp->setEnabled(
false);
61 ui->proxyPort->setEnabled(
false);
62 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
64 ui->proxyIpTor->setEnabled(
false);
65 ui->proxyPortTor->setEnabled(
false);
66 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
68 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp,
69 &QWidget::setEnabled);
70 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort,
71 &QWidget::setEnabled);
72 connect(
ui->connectSocks, &QPushButton::toggled,
this,
75 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor,
76 &QWidget::setEnabled);
77 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor,
78 &QWidget::setEnabled);
79 connect(
ui->connectSocksTor, &QPushButton::toggled,
this,
85 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
87 ui->bitcoinAtStartup->setVisible(
false);
88 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
89 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
94 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
95 ui->thirdPartyTxUrlsLabel->setVisible(
false);
96 ui->thirdPartyTxUrls->setVisible(
false);
100 QDir translations(
":translations");
102 ui->bitcoinAtStartup->setToolTip(
103 ui->bitcoinAtStartup->toolTip().arg(PACKAGE_NAME));
104 ui->bitcoinAtStartup->setText(
105 ui->bitcoinAtStartup->text().arg(PACKAGE_NAME));
107 ui->openBitcoinConfButton->setToolTip(
108 ui->openBitcoinConfButton->toolTip().arg(PACKAGE_NAME));
110 ui->lang->setToolTip(
ui->lang->toolTip().arg(PACKAGE_NAME));
111 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"),
113 for (
const QString &langStr : translations.entryList()) {
114 QLocale locale(langStr);
117 if (langStr.contains(
"_")) {
120 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") +
121 locale.nativeCountryName() + QString(
" (") +
122 langStr + QString(
")"),
127 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") +
128 langStr + QString(
")"),
135 mapper =
new QDataWidgetMapper(
this);
136 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
137 mapper->setOrientation(Qt::Vertical);
141 &OptionsDialog::reject);
142 mapper->setItemDelegate(delegate);
151 connect(
ui->proxyPort, &QLineEdit::textChanged,
this,
153 connect(
ui->proxyPortTor, &QLineEdit::textChanged,
this,
157 ui->thirdPartyTxUrls->setCheckValidator(
162 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
163 ui->hideTrayIcon->setChecked(
true);
164 ui->hideTrayIcon->setEnabled(
false);
165 ui->minimizeToTray->setChecked(
false);
166 ui->minimizeToTray->setEnabled(
false);
177 this->
model = _model;
186 static constexpr uint64_t nMinDiskSpace =
191 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
194 if (strLabel.isEmpty()) {
195 strLabel = tr(
"none");
197 ui->overriddenByCommandLineLabel->setText(strLabel);
210 connect(
ui->prune, &QCheckBox::clicked,
this,
212 connect(
ui->prune, &QCheckBox::clicked,
this,
214 connect(
ui->pruneSize,
215 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
217 connect(
ui->databaseCache,
218 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
220 connect(
ui->threadsScriptVerif,
221 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
224 connect(
ui->spendZeroConfChange, &QCheckBox::clicked,
this,
227 connect(
ui->allowIncoming, &QCheckBox::clicked,
this,
229 connect(
ui->connectSocks, &QCheckBox::clicked,
this,
231 connect(
ui->connectSocksTor, &QCheckBox::clicked,
this,
237 [
this] { showRestartWarning(); });
238 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged,
239 [
this] { showRestartWarning(); });
243 QWidget *tab_widget =
nullptr;
244 if (tab == OptionsDialog::Tab::TAB_NETWORK) {
245 tab_widget =
ui->tabNetwork;
247 if (tab == OptionsDialog::Tab::TAB_MAIN) {
248 tab_widget =
ui->tabMain;
250 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
251 ui->tabWidget->setCurrentWidget(tab_widget);
258 mapper->addMapping(
ui->threadsScriptVerif,
265 mapper->addMapping(
ui->spendZeroConfChange,
267 mapper->addMapping(
ui->coinControlFeatures,
285 if (QSystemTrayIcon::isSystemTrayAvailable()) {
299 ui->okButton->setEnabled(fState);
305 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
306 this, tr(
"Confirm options reset"),
307 tr(
"Client restart required to activate changes.") +
"<br><br>" +
308 tr(
"Client will be shut down. Do you want to proceed?"),
309 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
311 if (btnRetVal == QMessageBox::Cancel) {
317 QApplication::quit();
323 QMessageBox::information(
324 this, tr(
"Configuration options"),
325 tr(
"The configuration file is used to specify advanced user options "
326 "which override GUI settings. Additionally, any command-line "
327 "options will override this configuration file."));
331 QMessageBox::critical(
333 tr(
"The configuration file could not be opened."));
349 ui->minimizeToTray->setChecked(
false);
350 ui->minimizeToTray->setEnabled(
false);
352 ui->minimizeToTray->setEnabled(
true);
357 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
361 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
364 ui->statusLabel->setText(
365 tr(
"Client restart required to activate changes."));
367 ui->statusLabel->setText(
368 tr(
"This change would require a client restart."));
377 ui->statusLabel->clear();
386 (pUiProxyIp ==
ui->proxyIpTor) ?
ui->proxyIp :
ui->proxyIpTor;
388 (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) &&
389 (!
ui->proxyPortTor->isEnabled() ||
390 ui->proxyPortTor->text().toInt() > 0)) {
396 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
397 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
403 std::string strProxy;
404 QString strDefaultProxyGUI;
408 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
409 (strProxy == strDefaultProxyGUI.toStdString())
410 ?
ui->proxyReachIPv4->setChecked(
true)
411 :
ui->proxyReachIPv4->setChecked(
false);
415 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
416 (strProxy == strDefaultProxyGUI.toStdString())
417 ?
ui->proxyReachIPv6->setChecked(
true)
418 :
ui->proxyReachIPv6->setChecked(
false);
422 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
423 (strProxy == strDefaultProxyGUI.toStdString())
424 ?
ui->proxyReachTor->setChecked(
true)
425 :
ui->proxyReachTor->setChecked(
false);
429 : QValidator(parent) {}
438 return QValidator::Acceptable;
441 return QValidator::Invalid;
446 if (thirdPartyTxUrls->
isValid()) {
452 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
453 ui->statusLabel->setText(
454 tr(
"The third party transaction URLs should start with https://."));
459 : QValidator(parent) {}
466 if (input.isEmpty() || input.startsWith(
"https://")) {
467 return QValidator::Acceptable;
470 return QValidator::Invalid;
Bitcoin unit definitions.
std::string ToStringIP() const
A combination of a network address (CNetAddr) and a (TCP) port.
std::string ToStringPort() const
void setModel(OptionsModel *model)
void setCurrentTab(OptionsDialog::Tab tab)
void on_okButton_clicked()
void on_openBitcoinConfButton_clicked()
void updateDefaultProxyNets()
void updateProxyValidationState()
void togglePruneWarning(bool enabled)
void on_hideTrayIcon_stateChanged(int fState)
void showRestartWarning(bool fPersistent=false)
void updateThirdPartyTxUrlsState()
void on_resetButton_clicked()
OptionsDialog(QWidget *parent, bool enableWallet)
QDataWidgetMapper * mapper
void on_cancelButton_clicked()
void setOkButtonState(bool fState)
Interface from Qt to configuration data structure for Bitcoin client.
bool isRestartRequired() const
interfaces::Node & node() const
const QString & getOverriddenByCommandLine()
Proxy address widget validator, checks for a valid proxy address.
ProxyAddressValidator(QObject *parent)
State validate(QString &input, int &pos) const override
Line edit that can be marked as "invalid" to show input validation feedback.
void validationDidChange(QValidatedLineEdit *validatedLineEdit)
Third party tx URL validator, checks for an https link.
ThirdPartyTxUrlsValidator(QObject *parent)
State validate(QString &input, int &pos) const override
virtual bool getProxy(Network net, proxyType &proxy_info)=0
Get proxy.
static constexpr uint64_t GB_BYTES
void handleCloseWindowShortcut(QWidget *w)
@ NET_ONION
TOR (v2 or v3)
CService LookupNumeric(const std::string &name, uint16_t portDefault, DNSLookupFn dns_lookup_function)
Resolve a service string with a numeric IP to its first corresponding service.
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
int GetNumCores()
Return the number of cores available on the current system.
static constexpr int64_t MAX_DB_CACHE_MB
max. -dbcache (MiB)
static constexpr int64_t MIN_DB_CACHE_MB
min. -dbcache (MiB)
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev?...
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.