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>
27 #include <QSystemTrayIcon>
43 ui->pruneWarning->setVisible(
false);
44 ui->pruneWarning->setStyleSheet(
"QLabel { color: red; }");
46 ui->pruneSize->setEnabled(
false);
47 connect(
ui->prune, &QPushButton::toggled,
ui->pruneSize, &QWidget::setEnabled);
51 ui->mapPortUpnp->setEnabled(
false);
54 ui->proxyIp->setEnabled(
false);
55 ui->proxyPort->setEnabled(
false);
56 ui->proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
58 ui->proxyIpTor->setEnabled(
false);
59 ui->proxyPortTor->setEnabled(
false);
60 ui->proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
62 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyIp, &QWidget::setEnabled);
63 connect(
ui->connectSocks, &QPushButton::toggled,
ui->proxyPort, &QWidget::setEnabled);
66 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyIpTor, &QWidget::setEnabled);
67 connect(
ui->connectSocksTor, &QPushButton::toggled,
ui->proxyPortTor, &QWidget::setEnabled);
73 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWindow));
75 ui->bitcoinAtStartup->setVisible(
false);
76 ui->verticalLayout_Main->removeWidget(
ui->bitcoinAtStartup);
77 ui->verticalLayout_Main->removeItem(
ui->horizontalSpacer_0_Main);
82 ui->tabWidget->removeTab(
ui->tabWidget->indexOf(
ui->tabWallet));
83 ui->thirdPartyTxUrlsLabel->setVisible(
false);
84 ui->thirdPartyTxUrls->setVisible(
false);
88 QDir translations(
":translations");
90 ui->bitcoinAtStartup->setToolTip(
ui->bitcoinAtStartup->toolTip().arg(
PACKAGE_NAME));
91 ui->bitcoinAtStartup->setText(
ui->bitcoinAtStartup->text().arg(
PACKAGE_NAME));
93 ui->openBitcoinConfButton->setToolTip(
ui->openBitcoinConfButton->toolTip().arg(
PACKAGE_NAME));
96 ui->lang->addItem(QString(
"(") + tr(
"default") + QString(
")"), QVariant(
""));
97 for (
const QString &langStr : translations.entryList())
99 QLocale locale(langStr);
102 if(langStr.contains(
"_"))
105 ui->lang->addItem(locale.nativeLanguageName() + QString(
" - ") + locale.nativeCountryName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
110 ui->lang->addItem(locale.nativeLanguageName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
116 mapper =
new QDataWidgetMapper(
this);
117 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
118 mapper->setOrientation(Qt::Vertical);
122 mapper->setItemDelegate(delegate);
132 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
133 ui->hideTrayIcon->setChecked(
true);
134 ui->hideTrayIcon->setEnabled(
false);
135 ui->minimizeToTray->setChecked(
false);
136 ui->minimizeToTray->setEnabled(
false);
149 this->
model = _model;
159 ui->pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
162 if (strLabel.isEmpty())
163 strLabel = tr(
"none");
164 ui->overriddenByCommandLineLabel->setText(strLabel);
189 connect(
ui->thirdPartyTxUrls, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
194 QWidget *tab_widget =
nullptr;
195 if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget =
ui->tabNetwork;
196 if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget =
ui->tabMain;
197 if (tab_widget &&
ui->tabWidget->currentWidget() != tab_widget) {
198 ui->tabWidget->setCurrentWidget(tab_widget);
229 if (QSystemTrayIcon::isSystemTrayAvailable()) {
244 ui->okButton->setEnabled(fState);
252 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm options reset"),
253 tr(
"Client restart required to activate changes.") +
"<br><br>" + tr(
"Client will be shut down. Do you want to proceed?"),
254 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
256 if(btnRetVal == QMessageBox::Cancel)
261 QApplication::quit();
268 QMessageBox::information(
this, tr(
"Configuration options"),
269 tr(
"The configuration file is used to specify advanced user options which override GUI settings. "
270 "Additionally, any command-line options will override this configuration file."));
274 QMessageBox::critical(
this, tr(
"Error"), tr(
"The configuration file could not be opened."));
293 ui->minimizeToTray->setChecked(
false);
294 ui->minimizeToTray->setEnabled(
false);
298 ui->minimizeToTray->setEnabled(
true);
304 ui->pruneWarning->setVisible(!
ui->pruneWarning->isVisible());
309 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
313 ui->statusLabel->setText(tr(
"Client restart required to activate changes."));
317 ui->statusLabel->setText(tr(
"This change would require a client restart."));
326 ui->statusLabel->clear();
336 if (pUiProxyIp->
isValid() && (!
ui->proxyPort->isEnabled() ||
ui->proxyPort->text().toInt() > 0) && (!
ui->proxyPortTor->isEnabled() ||
ui->proxyPortTor->text().toInt() > 0))
344 ui->statusLabel->setStyleSheet(
"QLabel { color: red; }");
345 ui->statusLabel->setText(tr(
"The supplied proxy address is invalid."));
352 std::string strProxy;
353 QString strDefaultProxyGUI;
357 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
358 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv4->setChecked(
true) :
ui->proxyReachIPv4->setChecked(
false);
362 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
363 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachIPv6->setChecked(
true) :
ui->proxyReachIPv6->setChecked(
false);
367 strDefaultProxyGUI =
ui->proxyIp->text() +
":" +
ui->proxyPort->text();
368 (strProxy == strDefaultProxyGUI.toStdString()) ?
ui->proxyReachTor->setChecked(
true) :
ui->proxyReachTor->setChecked(
false);
383 return QValidator::Acceptable;
385 return QValidator::Invalid;
OptionsDialog(QWidget *parent, bool enableWallet)
Bitcoin unit definitions.
Proxy address widget validator, checks for a valid proxy address.
CService LookupNumeric(const std::string &name, int portDefault)
Resolve a service string with a numeric IP to its first corresponding service.
int GetNumCores()
Return the number of cores available on the current system.
std::string ToStringIP() const
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)
static constexpr uint64_t GB_BYTES
void on_resetButton_clicked()
bool isRestartRequired() const
Line edit that can be marked as "invalid" to show input validation feedback.
State
The various states a (txhash,peer) pair can be in.
void togglePruneWarning(bool enabled)
void on_openBitcoinConfButton_clicked()
void handleCloseWindowShortcut(QWidget *w)
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)
void on_hideTrayIcon_stateChanged(int fState)
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
interfaces::Node & node() const
Interface from Qt to configuration data structure for Bitcoin client.
static const int64_t nMaxDbCache
max. -dbcache (MiB)
void showRestartWarning(bool fPersistent=false)
void on_cancelButton_clicked()
std::string ToStringPort() const
void updateProxyValidationState()
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
ProxyAddressValidator(QObject *parent)
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.