5 #if defined(HAVE_CONFIG_H) 23 #include <validation.h> 27 #include <QLatin1Char> 29 #include <QStringList> 59 default:
throw std::logic_error(
strprintf(
"GUI option %i has no corresponding node setting.", option));
87 assert(!prune_enabled || prune_size_gb >= 1);
111 return std::max(1, prune_size.toInt());
120 static std::string
ProxyString(
bool is_set, QString
ip, QString port);
128 if (std::holds_alternative<FontChoiceAbstract>(f)) {
179 if (!settings.contains(
"fHideTrayIcon")) {
180 settings.setValue(
"fHideTrayIcon",
false);
185 if (!settings.contains(
"fMinimizeToTray"))
186 settings.setValue(
"fMinimizeToTray",
false);
189 if (!settings.contains(
"fMinimizeOnClose"))
190 settings.setValue(
"fMinimizeOnClose",
false);
194 if (!settings.contains(
"DisplayBitcoinUnit")) {
195 settings.setValue(
"DisplayBitcoinUnit", QVariant::fromValue(
BitcoinUnit::BTC));
197 QVariant unit = settings.value(
"DisplayBitcoinUnit");
205 if (!settings.contains(
"strThirdPartyTxUrls"))
206 settings.setValue(
"strThirdPartyTxUrls",
"");
209 if (!settings.contains(
"fCoinControlFeatures"))
210 settings.setValue(
"fCoinControlFeatures",
false);
213 if (!settings.contains(
"enable_psbt_controls")) {
214 settings.setValue(
"enable_psbt_controls",
false);
226 }
catch (
const std::exception& e) {
229 error.original =
strprintf(
"Could not read setting \"%s\", %s.", setting, e.what());
230 error.translated = tr(
"Could not read setting \"%1\", %2.").arg(QString::fromStdString(setting), e.what()).toStdString();
238 if (!settings.contains(
"strDataDir"))
243 if (!settings.contains(
"SubFeeFromAmount")) {
244 settings.setValue(
"SubFeeFromAmount",
false);
250 if (settings.contains(
"FontForMoney")) {
252 }
else if (settings.contains(
"UseEmbeddedMonospacedFont")) {
253 if (settings.value(
"UseEmbeddedMonospacedFont").toBool()) {
261 m_mask_values = settings.value(
"mask_values",
false).toBool();
271 for (
const QString& key : src.allKeys()) {
272 dst.setValue(key, src.value(key));
297 dataDir = settings.value(
"strDataDir", dataDir).toString();
303 settings.setValue(
"strDataDir", dataDir);
306 settings.setValue(
"fReset",
true);
322 if (proxy.isEmpty()) {
327 if (ip_port.size() == 2) {
328 return {
true, ip_port.at(0), ip_port.at(1)};
341 return is_set ? QString(
ip +
":" + port).toStdString() :
"";
378 if(role == Qt::EditRole)
388 bool successful =
true;
389 if(role == Qt::EditRole)
394 Q_EMIT dataChanged(index, index);
435 }
else if (suffix.empty()) {
446 }
else if (suffix.empty()) {
472 return settings.value(
"enable_psbt_controls");
477 suffix.empty() ?
getOption(option,
"-prev") :
497 if (std::holds_alternative<FontChoiceAbstract>(fc)) {
499 f.setWeight(QFont::Bold);
501 f = std::get<QFont>(fc);
513 auto changed = [&] {
return value.isValid() && value !=
getOption(option, suffix); };
516 bool successful =
true;
534 update(value.toBool());
540 update(value.toBool());
552 if (suffix.empty() && !value.toBool())
setOption(option,
true,
"-prev");
582 if (suffix.empty() && !value.toBool())
setOption(option,
true,
"-prev");
612 update(value.toBool());
618 update(value.toString().toStdString());
639 update(value.toString().toStdString());
645 const auto& new_font = value.value<
FontChoice>();
663 if (suffix.empty() && !value.toBool())
setOption(option,
true,
"-prev");
681 update(static_cast<int64_t>(value.toLongLong()));
687 update(static_cast<int64_t>(value.toLongLong()));
694 update(value.toBool());
721 return settings.setValue(
"fRestartRequired", fRequired);
727 return settings.value(
"fRestartRequired",
false).toBool();
740 static const char strSettingsVersionKey[] =
"nSettingsVersion";
741 int settingsVersion = settings.contains(strSettingsVersionKey) ? settings.value(strSettingsVersionKey).toInt() : 0;
747 if (settingsVersion < 130000 && settings.contains(
"nDatabaseCache") && settings.value(
"nDatabaseCache").toLongLong() == 100)
755 if (settings.contains(
"addrProxy") && settings.value(
"addrProxy").toString().endsWith(
"%2")) {
761 if (settings.contains(
"addrSeparateProxyTor") && settings.value(
"addrSeparateProxyTor").toString().endsWith(
"%2")) {
766 auto migrate_setting = [&](
OptionID option,
const QString& qt_name) {
767 if (!settings.contains(qt_name))
return;
768 QVariant value = settings.value(qt_name);
782 settings.remove(qt_name);
793 migrate_setting(
Listen,
"fListen");
794 migrate_setting(
Server,
"server");
795 migrate_setting(
PruneSize,
"nPruneSize");
796 migrate_setting(
Prune,
"bPrune");
797 migrate_setting(
ProxyIP,
"addrProxy");
798 migrate_setting(
ProxyUse,
"fUseProxy");
799 migrate_setting(
ProxyIPTor,
"addrSeparateProxyTor");
800 migrate_setting(
ProxyUseTor,
"fUseSeparateProxyTor");
801 migrate_setting(
Language,
"language");
virtual common::SettingsValue getPersistentSetting(const std::string &name)=0
Return setting value from <datadir>/settings.json or bitcoin.conf.
static std::string ProxyString(bool is_set, QString ip, QString port)
static void UpdateRwSetting(interfaces::Node &node, OptionsModel::OptionID option, const std::string &suffix, const common::SettingsValue &value)
Call node.updateRwSetting() with Bitcoin 22.x workaround.
static const char * SettingName(OptionsModel::OptionID option)
Map GUI option ID to node setting name.
virtual void resetSettings()=0
Clear all settings in <datadir>/settings.json and store a backup of previous settings in <datadir>/se...
static constexpr int DEFAULT_PRUNE_TARGET_GB
static void BackupSettings(const fs::path &filename, const QSettings &src)
Back up a QSettings to an ini-formatted file.
void addOverriddenOption(const std::string &option)
bool hasSigner()
Whether -signer was set or not.
static common::SettingsValue PruneSetting(bool prune_enabled, int prune_size_gb)
Convert enabled/size values to bitcoin -prune setting.
static int ParsePruneSizeGB(const QVariant &prune_size)
Parse pruning size value provided by user in GUI or loaded from QSettings (windows registry key or qt...
static void CopySettings(QSettings &dst, const QSettings &src)
Helper function to copy contents from one QSettings to another.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
static const bool DEFAULT_LISTEN
-listen default
void SetPruneTargetGB(int prune_target_gb)
static const FontChoice UseBestSystemFont
BitcoinUnit m_display_bitcoin_unit
bool GetStartOnSystemStartup()
void coinControlFeaturesChanged(bool)
QFont fixedPitchFont(bool use_embedded_font)
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
const std::string & getValStr() const
std::variant< FontChoiceAbstract, QFont > FontChoice
static QString FontChoiceToString(const OptionsModel::FontChoice &)
static int PruneSizeGB(const common::SettingsValue &prune_setting)
Get pruning size value to show in GUI from bitcoin -prune setting.
bool Init(bilingual_str &error)
bool isRestartRequired() const
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
interfaces::Node & node() const
static constexpr bool DEFAULT_UPNP
bool setOption(OptionID option, const QVariant &value, const std::string &suffix="")
static FontChoice FontChoiceFromString(const QString &)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void displayUnitChanged(BitcoinUnit unit)
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
std::optional< std::string > SettingToString(const common::SettingsValue &value)
static constexpr int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
QVariant getOption(OptionID option, const std::string &suffix="") const
std::optional< bool > SettingToBool(const common::SettingsValue &value)
static bool PruneEnabled(const common::SettingsValue &prune_setting)
Get pruning enabled value to show in GUI from bitcoin -prune setting.
const char * DEFAULT_GUI_PROXY_HOST
static const int64_t nDefaultDbCache
-dbcache default (MiB)
static CService ip(uint32_t i)
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
static const QLatin1String fontchoice_str_best_system
bool fCoinControlFeatures
bool m_enable_psbt_controls
static const QString fontchoice_str_custom_prefix
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
virtual void initParameterInteraction()=0
Init parameter interaction.
QStringList SplitSkipEmptyParts(const QString &string, const SeparatorType &separator)
Splits the string into substrings wherever separator occurs, and returns the list of those strings...
static QFont getFontForChoice(const FontChoice &fc)
static constexpr bool DEFAULT_NATPMP
void setRestartRequired(bool fRequired)
bool error(const char *fmt, const Args &... args)
QString strThirdPartyTxUrls
QFont getFontForMoney() const
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
static ProxySetting ParseProxyString(const std::string &proxy)
static const QLatin1String fontchoice_str_embedded
bool m_sub_fee_from_amount
bool SetStartOnSystemStartup(bool fAutoStart)
std::optional< int64_t > SettingToInt(const common::SettingsValue &value)
OptionsModel(interfaces::Node &node, QObject *parent=nullptr)
void fontForMoneyChanged(const QFont &)
virtual void forceSetting(const std::string &name, const common::SettingsValue &value)=0
Force a setting value to be applied, overriding any other configuration source, but not being persist...
static QString GetDefaultProxyAddress()
QString getDefaultDataDirectory()
Determine default data directory for operating system.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
virtual void mapPort(bool use_upnp, bool use_natpmp)=0
Map port.
Top-level interface for a bitcoin node (bitcoind process).
void setDisplayUnit(const QVariant &new_unit)
Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal.
QString PathToQString(const fs::path &path)
Convert OS specific boost path to QString through UTF-8.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QString strOverriddenByCommandLine
void showTrayIconChanged(bool)