5 #if defined(HAVE_CONFIG_H)
10 #include <qt/forms/ui_optionsdialog.h>
26 #include <QApplication>
27 #include <QDataWidgetMapper>
29 #include <QFontDialog>
30 #include <QIntValidator>
32 #include <QMessageBox>
33 #include <QSystemTrayIcon>
39 for (i = cb->count(); --i >= 0; ) {
40 QVariant item_data = cb->itemData(i);
49 QSignalBlocker block_currentindexchanged_signal(cb);
50 cb->insertItem(0, QFontInfo(chosen_font).family(), QVariant::fromValue(fc));
54 cb->setCurrentIndex(i);
64 cb->addItem(QObject::tr(
"Custom…"));
66 const auto& on_font_choice_changed = [cb, preview](
int index) {
67 static int previous_index = -1;
68 QVariant item_data = cb->itemData(index);
76 cb->setCurrentIndex(previous_index);
84 previous_index = index;
86 QObject::connect(cb, QOverload<int>::of(&QComboBox::currentIndexChanged), on_font_choice_changed);
87 on_font_choice_changed(cb->currentIndex());
101 ui->pruneWarning->setVisible(
false);
102 ui->pruneWarning->setStyleSheet(
"QLabel { color: red; }");
104 ui->pruneSize->setEnabled(
false);
105 connect(
ui->prune, &QPushButton::toggled,
ui->pruneSize, &QWidget::setEnabled);
109 ui->mapPortUpnp->setEnabled(
false);
112 ui->mapPortNatpmp->setEnabled(
false);
115 ui->proxyIp->setEnabled(
false);
116 ui->proxyPort->setEnabled(
false);
117 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
119 ui->proxyIpTor->setEnabled(
false);
120 ui->proxyPortTor->setEnabled(
false);
121 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
123 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp, &QWidget::setEnabled);
124 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort, &QWidget::setEnabled);
127 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor, &QWidget::setEnabled);
128 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor, &QWidget::setEnabled);
134 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
136 ui->bitcoinAtStartup->setVisible(
false);
137 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
138 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
143 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
144 ui->thirdPartyTxUrlsLabel->setVisible(
false);
145 ui->thirdPartyTxUrls->setVisible(
false);
148 #ifdef ENABLE_EXTERNAL_SIGNER
149 ui->externalSignerPath->setToolTip(
ui->externalSignerPath->toolTip().arg(
PACKAGE_NAME));
152 ui->externalSignerPath->setToolTip(tr(
"Compiled without external signing support (required for external signing)"));
153 ui->externalSignerPath->setEnabled(
false);
156 QDir translations(
":translations");
158 ui->bitcoinAtStartup->setToolTip(
ui->bitcoinAtStartup->toolTip().arg(
PACKAGE_NAME));
159 ui->bitcoinAtStartup->setText(
ui->bitcoinAtStartup->text().arg(
PACKAGE_NAME));
161 ui->openBitcoinConfButton->setToolTip(
ui->openBitcoinConfButton->toolTip().arg(
PACKAGE_NAME));
164 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"), QVariant(
""));
165 for (
const QString &langStr : translations.entryList())
167 QLocale locale(langStr);
170 if(langStr.contains(
"_"))
173 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") + locale.nativeCountryName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
178 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
184 mapper =
new QDataWidgetMapper(
this);
185 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
186 mapper->setOrientation(Qt::Vertical);
190 mapper->setItemDelegate(delegate);
200 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
201 ui->showTrayIcon->setChecked(
false);
202 ui->showTrayIcon->setEnabled(
false);
203 ui->minimizeToTray->setChecked(
false);
204 ui->minimizeToTray->setEnabled(
false);
224 this->
model = _model;
234 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
237 if (strLabel.isEmpty())
238 strLabel = tr(
"none");
239 ui->overriddenByCommandLineLabel->setText(strLabel);
258 connect(
ui->externalSignerPath, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
269 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
274 QWidget *tab_widget =
nullptr;
275 if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget =
ui->tabNetwork;
276 if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget =
ui->tabMain;
277 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
278 ui->tabWidget->setCurrentWidget(tab_widget);
314 if (QSystemTrayIcon::isSystemTrayAvailable()) {
329 ui->okButton->setEnabled(fState);
338 QString reset_dialog_text = tr(
"Client restart required to activate changes.") +
"<br><br>";
342 reset_dialog_text.append(tr(
"Current settings will be backed up at \"%1\".").arg(
m_client_model->
dataDir()) +
"<br><br>");
345 reset_dialog_text.append(tr(
"Client will be shut down. Do you want to proceed?"));
347 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm options reset"),
348 reset_dialog_text, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
350 if (btnRetVal == QMessageBox::Cancel)
362 QMessageBox config_msgbox(
this);
363 config_msgbox.setIcon(QMessageBox::Information);
365 config_msgbox.setWindowTitle(tr(
"Configuration options"));
368 config_msgbox.setText(tr(
"The configuration file is used to specify advanced user options which override GUI settings. "
369 "Additionally, any command-line options will override this configuration file."));
371 QPushButton* open_button = config_msgbox.addButton(tr(
"Continue"), QMessageBox::ActionRole);
372 config_msgbox.addButton(tr(
"Cancel"), QMessageBox::RejectRole);
373 open_button->setDefault(
true);
375 config_msgbox.exec();
377 if (config_msgbox.clickedButton() != open_button)
return;
381 QMessageBox::critical(
this, tr(
"Error"), tr(
"The configuration file could not be opened."));
400 if (state == Qt::Checked) {
401 ui->minimizeToTray->setEnabled(
true);
403 ui->minimizeToTray->setChecked(
false);
404 ui->minimizeToTray->setEnabled(
false);
410 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
415 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
419 ui->statusLabel->setText(tr(
"Client restart required to activate changes."));
423 ui->statusLabel->setText(tr(
"This change would require a client restart."));
432 ui->statusLabel->clear();
442 if (pUiProxyIp->
isValid() && (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) && (!
ui->proxyPortTor->isEnabled() ||
ui->proxyPortTor->text().toInt() > 0))
450 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
451 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
457 std::string proxyIpText{
ui->proxyIp->text().toStdString()};
459 const std::optional<CNetAddr> ui_proxy_netaddr{
LookupHost(proxyIpText,
false)};
460 const CService ui_proxy{ui_proxy_netaddr.value_or(
CNetAddr{}),
ui->proxyPort->text().toUShort()};
461 proxyIpText = ui_proxy.ToStringAddrPort();
468 ui->proxyReachIPv4->setChecked(has_proxy && proxy.
ToString() == proxyIpText);
471 ui->proxyReachIPv6->setChecked(has_proxy && proxy.
ToString() == proxyIpText);
474 ui->proxyReachTor->setChecked(has_proxy && proxy.
ToString() == proxyIpText);
489 return QValidator::Acceptable;
491 return QValidator::Invalid;
static constexpr int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
Bitcoin unit definitions.
A combination of a network address (CNetAddr) and a (TCP) port.
Model for Bitcoin network client.
void setModel(OptionsModel *model)
void setCurrentTab(OptionsDialog::Tab tab)
void on_showTrayIcon_stateChanged(int state)
void on_okButton_clicked()
void on_openBitcoinConfButton_clicked()
void updateDefaultProxyNets()
void updateProxyValidationState()
void togglePruneWarning(bool enabled)
void showRestartWarning(bool fPersistent=false)
ClientModel * m_client_model
void on_resetButton_clicked()
OptionsDialog(QWidget *parent, bool enableWallet)
QDataWidgetMapper * mapper
void setClientModel(ClientModel *client_model)
void on_cancelButton_clicked()
void setOkButtonState(bool fState)
Interface from Qt to configuration data structure for Bitcoin client.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
std::variant< FontChoiceAbstract, QFont > FontChoice
bool isRestartRequired() const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
static QFont getFontForChoice(const FontChoice &fc)
const QString & getOverriddenByCommandLine()
interfaces::Node & node() const
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)
virtual bool getProxy(Network net, Proxy &proxy_info)=0
Get proxy.
int GetNumCores()
Return the number of cores available on the current system.
static constexpr uint64_t GB_BYTES
Utility functions used by the Bitcoin Qt UI.
QFont fixedPitchFont(bool use_embedded_font)
void handleCloseWindowShortcut(QWidget *w)
constexpr auto dialog_flags
@ 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.
void setupFontOptions(QComboBox *cb, QLabel *preview)
int setFontChoice(QComboBox *cb, const OptionsModel::FontChoice &fc)
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
static const int64_t nMinDbCache
min. -dbcache (MiB)
static const int64_t nMaxDbCache
max. -dbcache (MiB)
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES