25#include <QApplication>
26#include <QDataWidgetMapper>
29#include <QIntValidator>
32#include <QSystemTrayIcon>
38 for (i = cb->count(); --i >= 0; ) {
39 QVariant item_data = cb->itemData(i);
48 QSignalBlocker block_currentindexchanged_signal(cb);
49 cb->insertItem(0, QFontInfo(chosen_font).family(), QVariant::fromValue(fc));
53 cb->setCurrentIndex(i);
63 cb->addItem(QObject::tr(
"Custom…"));
65 const auto& on_font_choice_changed = [cb, preview](
int index) {
66 static int previous_index = -1;
67 QVariant item_data = cb->itemData(index);
75 cb->setCurrentIndex(previous_index);
83 previous_index = index;
85 QObject::connect(cb, QOverload<int>::of(&QComboBox::currentIndexChanged), on_font_choice_changed);
86 on_font_choice_changed(cb->currentIndex());
90 : QDialog(parent,
GUIUtil::dialog_flags | Qt::WindowMaximizeButtonHint),
118 ui->
proxyPort->setValidator(
new QIntValidator(1, 65535,
this));
122 ui->
proxyPortTor->setValidator(
new QIntValidator(1, 65535,
this));
149#ifdef ENABLE_EXTERNAL_SIGNER
153 ui->
externalSignerPath->setToolTip(tr(
"Compiled without external signing support (required for external signing)"));
157 QDir translations(
":translations");
165 ui->
lang->addItem(QString(
"(") + tr(
"default") + QString(
")"), QVariant(
""));
166 for (
const QString &langStr : translations.entryList())
168 QLocale locale(langStr);
171 if(langStr.contains(
"_"))
174 ui->
lang->addItem(locale.nativeLanguageName() + QString(
" - ") + locale.nativeCountryName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
179 ui->
lang->addItem(locale.nativeLanguageName() + QString(
" (") + langStr + QString(
")"), QVariant(langStr));
185 mapper =
new QDataWidgetMapper(
this);
186 mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
187 mapper->setOrientation(Qt::Vertical);
191 mapper->setItemDelegate(delegate);
201 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
225 this->
model = _model;
235 ui->
pruneSize->setRange(nMinDiskSpace, std::numeric_limits<int>::max());
238 if (strLabel.isEmpty())
239 strLabel = tr(
"none");
270 connect(
ui->
thirdPartyTxUrls, &QLineEdit::textChanged, [
this]{ showRestartWarning(); });
275 QWidget *tab_widget =
nullptr;
278 if (tab_widget &&
ui->
tabWidget->currentWidget() != tab_widget) {
315 if (QSystemTrayIcon::isSystemTrayAvailable()) {
339 QString reset_dialog_text = tr(
"Client restart required to activate changes.") +
"<br><br>";
343 reset_dialog_text.append(tr(
"Current settings will be backed up at \"%1\".").arg(
m_client_model->
dataDir()) +
"<br><br>");
346 reset_dialog_text.append(tr(
"Client will be shut down. Do you want to proceed?"));
348 QMessageBox::StandardButton btnRetVal = QMessageBox::question(
this, tr(
"Confirm options reset"),
349 reset_dialog_text, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
351 if (btnRetVal == QMessageBox::Cancel)
363 QMessageBox config_msgbox(
this);
364 config_msgbox.setIcon(QMessageBox::Information);
366 config_msgbox.setWindowTitle(tr(
"Configuration options"));
369 config_msgbox.setText(tr(
"The configuration file is used to specify advanced user options which override GUI settings. "
370 "Additionally, any command-line options will override this configuration file."));
372 QPushButton* open_button = config_msgbox.addButton(tr(
"Continue"), QMessageBox::ActionRole);
373 config_msgbox.addButton(tr(
"Cancel"), QMessageBox::RejectRole);
374 open_button->setDefault(
true);
376 config_msgbox.exec();
378 if (config_msgbox.clickedButton() != open_button)
return;
382 QMessageBox::critical(
this, tr(
"Error"), tr(
"The configuration file could not be opened."));
401 if (state == Qt::Checked) {
420 ui->
statusLabel->setText(tr(
"Client restart required to activate changes."));
424 ui->
statusLabel->setText(tr(
"This change would require a client restart."));
452 ui->
statusLabel->setText(tr(
"The supplied proxy address is invalid."));
458 std::string proxyIpText{
ui->
proxyIp->text().toStdString()};
460 const std::optional<CNetAddr> ui_proxy_netaddr{
LookupHost(proxyIpText,
false)};
487 std::string hostname;
488 if (!
SplitHostPort(input.toStdString(), port, hostname) || port != 0)
return QValidator::Invalid;
493 return QValidator::Acceptable;
495 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.
std::string ToStringAddrPort() 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.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool isRestartRequired() const
interfaces::Node & node() const
std::variant< FontChoiceAbstract, QFont > FontChoice
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
const QString & getOverriddenByCommandLine()
static QFont getFontForChoice(const FontChoice &fc)
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)
void setEnabled(bool enabled)
void setCheckValidator(const QValidator *v)
QVBoxLayout * verticalLayout
QLabel * overriddenByCommandLineLabel
QSpinBox * threadsScriptVerif
QCheckBox * connectSocksTor
QCheckBox * minimizeToTray
void setupUi(QDialog *OptionsDialog)
QCheckBox * bitcoinAtStartup
QVBoxLayout * verticalLayout_Main
QLineEdit * externalSignerPath
QLabel * moneyFont_preview
QCheckBox * subFeeFromAmount
QPushButton * openBitcoinConfButton
QCheckBox * coinControlFeatures
QValidatedLineEdit * proxyIpTor
QCheckBox * allowIncoming
QLineEdit * thirdPartyTxUrls
QSpacerItem * horizontalSpacer_0_Main
QCheckBox * spendZeroConfChange
QCheckBox * mapPortNatpmp
QCheckBox * proxyReachIPv4
QCheckBox * proxyReachIPv6
QCheckBox * proxyReachTor
QValidatedLineEdit * proxyIp
QCheckBox * m_enable_psbt_controls
QCheckBox * minimizeOnClose
QLabel * thirdPartyTxUrlsLabel
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)
@ 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)
bool SplitHostPort(std::string_view in, uint16_t &portOut, std::string &hostOut)
Splits socket address string into host string and port value.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES