5 #if defined(HAVE_CONFIG_H) 10 #include <qt/forms/ui_optionsdialog.h> 18 #include <validation.h> 22 #include <QDataWidgetMapper> 24 #include <QIntValidator> 26 #include <QMessageBox> 28 #include <QSystemTrayIcon> 44 ui->pruneWarning->setVisible(
false);
45 ui->pruneWarning->setStyleSheet(
"QLabel { color: red; }");
47 ui->pruneSize->setEnabled(
false);
48 connect(
ui->prune, &QPushButton::toggled,
ui->pruneSize, &QWidget::setEnabled);
52 ui->mapPortUpnp->setEnabled(
false);
55 ui->mapPortNatpmp->setEnabled(
false);
57 connect(
this, &QDialog::accepted, [
this](){
59 model->
node().
mapPort(settings.value(
"fUseUPnP").toBool(), settings.value(
"fUseNatpmp").toBool());
62 ui->proxyIp->setEnabled(
false);
63 ui->proxyPort->setEnabled(
false);
64 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
66 ui->proxyIpTor->setEnabled(
false);
67 ui->proxyPortTor->setEnabled(
false);
68 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
70 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp, &QWidget::setEnabled);
71 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort, &QWidget::setEnabled);
74 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor, &QWidget::setEnabled);
75 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor, &QWidget::setEnabled);
81 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
83 ui->bitcoinAtStartup->setVisible(
false);
84 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
85 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
90 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
91 ui->thirdPartyTxUrlsLabel->setVisible(
false);
92 ui->thirdPartyTxUrls->setVisible(
false);
95 #ifndef ENABLE_EXTERNAL_SIGNER 97 ui->externalSignerPath->setToolTip(tr(
"Compiled without external signing support (required for external signing)"));
98 ui->externalSignerPath->setEnabled(
false);
101 QDir translations(
":translations");
103 ui->bitcoinAtStartup->setToolTip(
ui->bitcoinAtStartup->toolTip().arg(
PACKAGE_NAME));
104 ui->bitcoinAtStartup->setText(
ui->bitcoinAtStartup->text().arg(
PACKAGE_NAME));
106 ui->openBitcoinConfButton->setToolTip(
ui->openBitcoinConfButton->toolTip().arg(
PACKAGE_NAME));
109 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"), QVariant(
""));
110 for (
const QString &langStr : translations.entryList())
112 QLocale locale(langStr);
115 if(langStr.contains(
"_"))
118 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") + locale.nativeCountryName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
123 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
129 mapper =
new QDataWidgetMapper(
this);
130 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
131 mapper->setOrientation(Qt::Vertical);
135 mapper->setItemDelegate(delegate);
145 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
146 ui->showTrayIcon->setChecked(
false);
147 ui->showTrayIcon->setEnabled(
false);
148 ui->minimizeToTray->setChecked(
false);
149 ui->minimizeToTray->setEnabled(
false);
153 ui->embeddedFont_radioButton->setText(
ui->embeddedFont_radioButton->text().arg(QFontInfo(embedded_font).family()));
154 embedded_font.setWeight(QFont::Bold);
155 ui->embeddedFont_label_1->setFont(embedded_font);
156 ui->embeddedFont_label_9->setFont(embedded_font);
159 ui->systemFont_radioButton->setText(
ui->systemFont_radioButton->text().arg(QFontInfo(system_font).family()));
160 system_font.setWeight(QFont::Bold);
161 ui->systemFont_label_1->setFont(system_font);
162 ui->systemFont_label_9->setFont(system_font);
164 ui->systemFont_radioButton->setChecked(
true);
176 this->
model = _model;
186 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
189 if (strLabel.isEmpty())
190 strLabel = tr(
"none");
191 ui->overriddenByCommandLineLabel->setText(strLabel);
207 connect(
ui->externalSignerPath, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
217 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
222 QWidget *tab_widget =
nullptr;
223 if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget =
ui->tabNetwork;
224 if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget =
ui->tabMain;
225 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
226 ui->tabWidget->setCurrentWidget(tab_widget);
259 if (QSystemTrayIcon::isSystemTrayAvailable()) {
275 ui->okButton->setEnabled(fState);
283 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm options reset"),
284 tr(
"Client restart required to activate changes.") +
"<br><br>" + tr(
"Client will be shut down. Do you want to proceed?"),
285 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
287 if(btnRetVal == QMessageBox::Cancel)
292 QApplication::quit();
299 QMessageBox::information(
this, tr(
"Configuration options"),
300 tr(
"The configuration file is used to specify advanced user options which override GUI settings. " 301 "Additionally, any command-line options will override this configuration file."));
305 QMessageBox::critical(
this, tr(
"Error"), tr(
"The configuration file could not be opened."));
322 if (state == Qt::Checked) {
323 ui->minimizeToTray->setEnabled(
true);
325 ui->minimizeToTray->setChecked(
false);
326 ui->minimizeToTray->setEnabled(
false);
332 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
337 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
341 ui->statusLabel->setText(tr(
"Client restart required to activate changes."));
345 ui->statusLabel->setText(tr(
"This change would require a client restart."));
354 ui->statusLabel->clear();
364 if (pUiProxyIp->
isValid() && (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) && (!
ui->proxyPortTor->isEnabled() ||
ui->proxyPortTor->text().toInt() > 0))
372 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
373 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
380 std::string strProxy;
381 QString strDefaultProxyGUI;
385 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
386 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv4->setChecked(
true) :
ui->proxyReachIPv4->setChecked(
false);
390 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
391 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv6->setChecked(
true) :
ui->proxyReachIPv6->setChecked(
false);
395 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
396 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachTor->setChecked(
true) :
ui->proxyReachTor->setChecked(
false);
411 return QValidator::Acceptable;
413 return QValidator::Invalid;
std::string ToStringPort() const
OptionsDialog(QWidget *parent, bool enableWallet)
Bitcoin unit definitions.
Proxy address widget validator, checks for a valid proxy address.
Utility functions used by the Bitcoin Qt UI.
int GetNumCores()
Return the number of cores available on the current system.
State validate(QString &input, int &pos) const override
virtual bool getProxy(Network net, proxyType &proxy_info)=0
Get proxy.
void setOkButtonState(bool fState)
const QString & getOverriddenByCommandLine()
static const int64_t nMinDbCache
min. -dbcache (MiB)
QFont fixedPitchFont(bool use_embedded_font)
static constexpr uint64_t GB_BYTES
void on_resetButton_clicked()
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.
Line edit that can be marked as "invalid" to show input validation feedback.
State
The various states a (txhash,peer) pair can be in.
constexpr auto dialog_flags
void togglePruneWarning(bool enabled)
bool isRestartRequired() const
interfaces::Node & node() const
void on_openBitcoinConfButton_clicked()
void handleCloseWindowShortcut(QWidget *w)
std::string ToStringIP() const
A combination of a network address (CNetAddr) and a (TCP) port.
void validationDidChange(QValidatedLineEdit *validatedLineEdit)
void setModel(OptionsModel *model)
QDataWidgetMapper * mapper
void on_okButton_clicked()
void updateDefaultProxyNets()
void setCurrentTab(OptionsDialog::Tab tab)
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
Interface from Qt to configuration data structure for Bitcoin client.
void on_showTrayIcon_stateChanged(int state)
static const int64_t nMaxDbCache
max. -dbcache (MiB)
void showRestartWarning(bool fPersistent=false)
void on_cancelButton_clicked()
void updateProxyValidationState()
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
virtual void mapPort(bool use_upnp, bool use_natpmp)=0
Map port.
ProxyAddressValidator(QObject *parent)
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.