5 #if defined(HAVE_CONFIG_H)
10 #include <qt/forms/ui_optionsdialog.h>
19 #include <validation.h>
26 #include <QDataWidgetMapper>
28 #include <QIntValidator>
30 #include <QMessageBox>
31 #include <QSystemTrayIcon>
45 ui->pruneWarning->setVisible(
false);
46 ui->pruneWarning->setStyleSheet(
"QLabel { color: red; }");
48 ui->pruneSize->setEnabled(
false);
49 connect(
ui->prune, &QPushButton::toggled,
ui->pruneSize, &QWidget::setEnabled);
53 ui->mapPortUpnp->setEnabled(
false);
56 ui->mapPortNatpmp->setEnabled(
false);
59 ui->proxyIp->setEnabled(
false);
60 ui->proxyPort->setEnabled(
false);
61 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
63 ui->proxyIpTor->setEnabled(
false);
64 ui->proxyPortTor->setEnabled(
false);
65 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
67 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp, &QWidget::setEnabled);
68 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort, &QWidget::setEnabled);
71 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor, &QWidget::setEnabled);
72 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor, &QWidget::setEnabled);
78 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
80 ui->bitcoinAtStartup->setVisible(
false);
81 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
82 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
87 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
88 ui->thirdPartyTxUrlsLabel->setVisible(
false);
89 ui->thirdPartyTxUrls->setVisible(
false);
92 #ifdef ENABLE_EXTERNAL_SIGNER
93 ui->externalSignerPath->setToolTip(
ui->externalSignerPath->toolTip().arg(
PACKAGE_NAME));
96 ui->externalSignerPath->setToolTip(tr(
"Compiled without external signing support (required for external signing)"));
97 ui->externalSignerPath->setEnabled(
false);
100 QDir translations(
":translations");
102 ui->bitcoinAtStartup->setToolTip(
ui->bitcoinAtStartup->toolTip().arg(
PACKAGE_NAME));
103 ui->bitcoinAtStartup->setText(
ui->bitcoinAtStartup->text().arg(
PACKAGE_NAME));
105 ui->openBitcoinConfButton->setToolTip(
ui->openBitcoinConfButton->toolTip().arg(
PACKAGE_NAME));
108 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"), QVariant(
""));
109 for (
const QString &langStr : translations.entryList())
111 QLocale locale(langStr);
114 if(langStr.contains(
"_"))
117 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") + locale.nativeCountryName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
122 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
128 mapper =
new QDataWidgetMapper(
this);
129 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
130 mapper->setOrientation(Qt::Vertical);
134 mapper->setItemDelegate(delegate);
144 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
145 ui->showTrayIcon->setChecked(
false);
146 ui->showTrayIcon->setEnabled(
false);
147 ui->minimizeToTray->setChecked(
false);
148 ui->minimizeToTray->setEnabled(
false);
152 ui->embeddedFont_radioButton->setText(
ui->embeddedFont_radioButton->text().arg(QFontInfo(embedded_font).family()));
153 embedded_font.setWeight(QFont::Bold);
154 ui->embeddedFont_label_1->setFont(embedded_font);
155 ui->embeddedFont_label_9->setFont(embedded_font);
158 ui->systemFont_radioButton->setText(
ui->systemFont_radioButton->text().arg(QFontInfo(system_font).family()));
159 system_font.setWeight(QFont::Bold);
160 ui->systemFont_label_1->setFont(system_font);
161 ui->systemFont_label_9->setFont(system_font);
163 ui->systemFont_radioButton->setChecked(
true);
180 this->
model = _model;
190 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
193 if (strLabel.isEmpty())
194 strLabel = tr(
"none");
195 ui->overriddenByCommandLineLabel->setText(strLabel);
211 connect(
ui->externalSignerPath, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
222 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
227 QWidget *tab_widget =
nullptr;
228 if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget =
ui->tabNetwork;
229 if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget =
ui->tabMain;
230 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
231 ui->tabWidget->setCurrentWidget(tab_widget);
267 if (QSystemTrayIcon::isSystemTrayAvailable()) {
283 ui->okButton->setEnabled(fState);
292 QString reset_dialog_text = tr(
"Client restart required to activate changes.") +
"<br><br>";
296 reset_dialog_text.append(tr(
"Current settings will be backed up at \"%1\".").arg(
m_client_model->
dataDir()) +
"<br><br>");
299 reset_dialog_text.append(tr(
"Client will be shut down. Do you want to proceed?"));
301 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm options reset"),
302 reset_dialog_text, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
304 if (btnRetVal == QMessageBox::Cancel)
316 QMessageBox config_msgbox(
this);
317 config_msgbox.setIcon(QMessageBox::Information);
319 config_msgbox.setWindowTitle(tr(
"Configuration options"));
322 config_msgbox.setText(tr(
"The configuration file is used to specify advanced user options which override GUI settings. "
323 "Additionally, any command-line options will override this configuration file."));
325 QPushButton* open_button = config_msgbox.addButton(tr(
"Continue"), QMessageBox::ActionRole);
326 config_msgbox.addButton(tr(
"Cancel"), QMessageBox::RejectRole);
327 open_button->setDefault(
true);
329 config_msgbox.exec();
331 if (config_msgbox.clickedButton() != open_button)
return;
335 QMessageBox::critical(
this, tr(
"Error"), tr(
"The configuration file could not be opened."));
352 if (state == Qt::Checked) {
353 ui->minimizeToTray->setEnabled(
true);
355 ui->minimizeToTray->setChecked(
false);
356 ui->minimizeToTray->setEnabled(
false);
362 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
367 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
371 ui->statusLabel->setText(tr(
"Client restart required to activate changes."));
375 ui->statusLabel->setText(tr(
"This change would require a client restart."));
384 ui->statusLabel->clear();
394 if (pUiProxyIp->
isValid() && (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) && (!
ui->proxyPortTor->isEnabled() ||
ui->proxyPortTor->text().toInt() > 0))
402 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
403 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
410 std::string strProxy;
411 QString strDefaultProxyGUI;
415 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
416 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv4->setChecked(
true) :
ui->proxyReachIPv4->setChecked(
false);
420 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
421 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv6->setChecked(
true) :
ui->proxyReachIPv6->setChecked(
false);
425 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
426 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachTor->setChecked(
true) :
ui->proxyReachTor->setChecked(
false);
441 return QValidator::Acceptable;
443 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
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.
bool isRestartRequired() const
@ UseEmbeddedMonospacedFont
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
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.
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)
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
static const int64_t nMinDbCache
min. -dbcache (MiB)
static const int64_t nMaxDbCache
max. -dbcache (MiB)
int GetNumCores()
Return the number of cores available on the current system.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.