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>
37 std::numeric_limits<int>::max());
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);
48 connect(
this, &QDialog::accepted, [
this]() {
50 model->
node().mapPort(settings.value(
"fUseNatpmp").toBool());
52 ui->proxyIp->setEnabled(
false);
53 ui->proxyPort->setEnabled(
false);
54 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
56 ui->proxyIpTor->setEnabled(
false);
57 ui->proxyPortTor->setEnabled(
false);
58 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
60 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp,
61 &QWidget::setEnabled);
62 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort,
63 &QWidget::setEnabled);
64 connect(
ui->connectSocks, &QPushButton::toggled,
this,
67 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor,
68 &QWidget::setEnabled);
69 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor,
70 &QWidget::setEnabled);
71 connect(
ui->connectSocksTor, &QPushButton::toggled,
this,
77 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
79 ui->bitcoinAtStartup->setVisible(
false);
80 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
81 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
86 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
87 ui->thirdPartyTxUrlsLabel->setVisible(
false);
88 ui->thirdPartyTxUrls->setVisible(
false);
92 QDir translations(
":translations");
94 ui->bitcoinAtStartup->setToolTip(
95 ui->bitcoinAtStartup->toolTip().arg(PACKAGE_NAME));
96 ui->bitcoinAtStartup->setText(
97 ui->bitcoinAtStartup->text().arg(PACKAGE_NAME));
99 ui->openBitcoinConfButton->setToolTip(
100 ui->openBitcoinConfButton->toolTip().arg(PACKAGE_NAME));
102 ui->lang->setToolTip(
ui->lang->toolTip().arg(PACKAGE_NAME));
103 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"),
105 for (
const QString &langStr : translations.entryList()) {
106 QLocale locale(langStr);
109 if (langStr.contains(
"_")) {
115 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") +
116#
if (QT_VERSION >= QT_VERSION_CHECK(6, 2, 0))
117 locale.nativeTerritoryName() +
119 locale.nativeCountryName() +
121 QString(
" (") + langStr + QString(
")"),
126 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") +
127 langStr + QString(
")"),
134 mapper =
new QDataWidgetMapper(
this);
135 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
136 mapper->setOrientation(Qt::Vertical);
140 &OptionsDialog::reject);
141 mapper->setItemDelegate(delegate);
150 connect(
ui->proxyPort, &QLineEdit::textChanged,
this,
152 connect(
ui->proxyPortTor, &QLineEdit::textChanged,
this,
156 ui->thirdPartyTxUrls->setCheckValidator(
161 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
162 ui->hideTrayIcon->setChecked(
true);
163 ui->hideTrayIcon->setEnabled(
false);
164 ui->minimizeToTray->setChecked(
false);
165 ui->minimizeToTray->setEnabled(
false);
176 this->
model = _model;
185 static constexpr uint64_t nMinDiskSpace =
190 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
193 if (strLabel.isEmpty()) {
194 strLabel = tr(
"none");
196 ui->overriddenByCommandLineLabel->setText(strLabel);
209 connect(
ui->prune, &QCheckBox::clicked,
this,
211 connect(
ui->prune, &QCheckBox::clicked,
this,
213 connect(
ui->pruneSize,
214 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
216 connect(
ui->databaseCache,
217 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
219 connect(
ui->threadsScriptVerif,
220 static_cast<void (QSpinBox::*)(
int)
>(&QSpinBox::valueChanged),
this,
223 connect(
ui->spendZeroConfChange, &QCheckBox::clicked,
this,
226 connect(
ui->allowIncoming, &QCheckBox::clicked,
this,
228 connect(
ui->connectSocks, &QCheckBox::clicked,
this,
230 connect(
ui->connectSocksTor, &QCheckBox::clicked,
this,
236 [
this] { showRestartWarning(); });
237 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged,
238 [
this] { showRestartWarning(); });
242 QWidget *tab_widget =
nullptr;
243 if (tab == OptionsDialog::Tab::TAB_NETWORK) {
244 tab_widget =
ui->tabNetwork;
246 if (tab == OptionsDialog::Tab::TAB_MAIN) {
247 tab_widget =
ui->tabMain;
249 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
250 ui->tabWidget->setCurrentWidget(tab_widget);
257 mapper->addMapping(
ui->threadsScriptVerif,
264 mapper->addMapping(
ui->spendZeroConfChange,
266 mapper->addMapping(
ui->coinControlFeatures,
283 if (QSystemTrayIcon::isSystemTrayAvailable()) {
297 ui->okButton->setEnabled(fState);
303 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
304 this, tr(
"Confirm options reset"),
305 tr(
"Client restart required to activate changes.") +
"<br><br>" +
306 tr(
"Client will be shut down. Do you want to proceed?"),
307 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
309 if (btnRetVal == QMessageBox::Cancel) {
322 QMessageBox::information(
323 this, tr(
"Configuration options"),
324 tr(
"The configuration file is used to specify advanced user options "
325 "which override GUI settings. Additionally, any command-line "
326 "options will override this configuration file."));
330 QMessageBox::critical(
332 tr(
"The configuration file could not be opened."));
348 ui->minimizeToTray->setChecked(
false);
349 ui->minimizeToTray->setEnabled(
false);
351 ui->minimizeToTray->setEnabled(
true);
356 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
360 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
363 ui->statusLabel->setText(
364 tr(
"Client restart required to activate changes."));
366 ui->statusLabel->setText(
367 tr(
"This change would require a client restart."));
376 ui->statusLabel->clear();
385 (pUiProxyIp ==
ui->proxyIpTor) ?
ui->proxyIp :
ui->proxyIpTor;
387 (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) &&
388 (!
ui->proxyPortTor->isEnabled() ||
389 ui->proxyPortTor->text().toInt() > 0)) {
395 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
396 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
401 std::string proxyIpText{
ui->proxyIp->text().toStdString()};
403 const std::optional<CNetAddr> ui_proxy_netaddr{
406 ui->proxyPort->text().toUShort()};
407 proxyIpText = ui_proxy.ToStringAddrPort();
414 ui->proxyReachIPv4->setChecked(has_proxy &&
418 ui->proxyReachIPv6->setChecked(has_proxy &&
422 ui->proxyReachTor->setChecked(has_proxy && proxy.
ToString() == proxyIpText);
426 : QValidator(parent) {}
435 return QValidator::Acceptable;
438 return QValidator::Invalid;
443 if (thirdPartyTxUrls->
isValid()) {
449 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
450 ui->statusLabel->setText(
451 tr(
"The third party transaction URLs should start with https://."));
456 : QValidator(parent) {}
463 if (input.isEmpty() || input.startsWith(
"https://")) {
464 return QValidator::Acceptable;
467 return QValidator::Invalid;
Bitcoin unit definitions.
A combination of a network address (CNetAddr) and a (TCP) port.
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
std::string ToString() const
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, Proxy &proxy_info)=0
Get proxy.
static constexpr uint64_t GB_BYTES
void handleCloseWindowShortcut(QWidget *w)
@ NET_ONION
TOR (v2 or v3)
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function)
Resolve a host string to its corresponding network addresses.
bool IsUnixSocketPath(const std::string &name)
Check if a string is a valid UNIX domain socket path.
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 size_t MIN_DB_CACHE
min. -dbcache (bytes)
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
int GetNumCores()
Return the number of cores available on the current system.
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.