25 #include <QApplication> 26 #include <QDataWidgetMapper> 28 #include <QFontDialog> 29 #include <QIntValidator> 31 #include <QMessageBox> 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());
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;
276 if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget =
ui->
tabNetwork;
277 if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget =
ui->
tabMain;
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)};
462 proxyIpText = ui_proxy.ToStringAddrPort();
487 std::string hostname;
488 if (!
SplitHostPort(input.toStdString(), port, hostname) || port != 0)
return QValidator::Invalid;
493 return QValidator::Acceptable;
495 return QValidator::Invalid;
QCheckBox * spendZeroConfChange
QCheckBox * proxyReachIPv6
QVBoxLayout * verticalLayout
OptionsDialog(QWidget *parent, bool enableWallet)
Bitcoin unit definitions.
Proxy address widget validator, checks for a valid proxy address.
QSpinBox * threadsScriptVerif
QPushButton * openBitcoinConfButton
Utility functions used by the Bitcoin Qt UI.
bool IsUnixSocketPath(const std::string &name)
Check if a string is a valid UNIX domain socket path.
void setupUi(QDialog *OptionsDialog)
void setupFontOptions(QComboBox *cb, QLabel *preview)
void setClientModel(ClientModel *client_model)
bool SplitHostPort(std::string_view in, uint16_t &portOut, std::string &hostOut)
Splits socket address string into host string and port value.
State validate(QString &input, int &pos) const override
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setOkButtonState(bool fState)
QCheckBox * m_enable_psbt_controls
int setFontChoice(QComboBox *cb, const OptionsModel::FontChoice &fc)
const QString & getOverriddenByCommandLine()
static const int64_t nMinDbCache
min. -dbcache (MiB)
QFont fixedPitchFont(bool use_embedded_font)
QCheckBox * minimizeToTray
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.
std::variant< FontChoiceAbstract, QFont > FontChoice
constexpr auto dialog_flags
void togglePruneWarning(bool enabled)
bool isRestartRequired() const
interfaces::Node & node() const
std::string ToString() const
void on_openBitcoinConfButton_clicked()
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.
void handleCloseWindowShortcut(QWidget *w)
A combination of a network address (CNetAddr) and a (TCP) port.
QCheckBox * allowIncoming
void validationDidChange(QValidatedLineEdit *validatedLineEdit)
void setModel(OptionsModel *model)
virtual bool getProxy(Network net, Proxy &proxy_info)=0
Get proxy.
QDataWidgetMapper * mapper
ClientModel * m_client_model
void on_okButton_clicked()
void updateDefaultProxyNets()
QCheckBox * proxyReachIPv4
void setCurrentTab(OptionsDialog::Tab tab)
QLabel * moneyFont_preview
Model for Bitcoin network client.
QCheckBox * connectSocksTor
static constexpr int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
QLabel * overriddenByCommandLineLabel
QCheckBox * subFeeFromAmount
QValidatedLineEdit * proxyIpTor
static QFont getFontForChoice(const FontChoice &fc)
QCheckBox * minimizeOnClose
QLineEdit * thirdPartyTxUrls
Interface from Qt to configuration data structure for Bitcoin client.
void on_showTrayIcon_stateChanged(int state)
QSpacerItem * horizontalSpacer_0_Main
QLabel * thirdPartyTxUrlsLabel
QCheckBox * bitcoinAtStartup
QCheckBox * proxyReachTor
static const int64_t nMaxDbCache
max. -dbcache (MiB)
QVBoxLayout * verticalLayout_Main
void showRestartWarning(bool fPersistent=false)
void setCheckValidator(const QValidator *v)
void setEnabled(bool enabled)
void on_cancelButton_clicked()
QValidatedLineEdit * proxyIp
QCheckBox * mapPortNatpmp
void updateProxyValidationState()
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
QCheckBox * coinControlFeatures
QLineEdit * externalSignerPath
int GetNumCores()
Return the number of cores available on the current system.
ProxyAddressValidator(QObject *parent)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override