Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
optionsmodel.h
Go to the documentation of this file.
1// Copyright (c) 2011-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_QT_OPTIONSMODEL_H
6#define BITCOIN_QT_OPTIONSMODEL_H
7
8#include <cstdint>
9#include <qt/bitcoinunits.h>
10#include <qt/guiconstants.h>
11#include <util/byte_units.h>
12
13#include <QAbstractListModel>
14#include <QFont>
15
16#include <cassert>
17#include <variant>
18
19struct bilingual_str;
20namespace interfaces {
21class Node;
22}
23
24extern const char *DEFAULT_GUI_PROXY_HOST;
25inline constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
26
30static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1_MiB + GB_BYTES - 1) / GB_BYTES; }
31
35static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1_MiB; }
36
43class OptionsModel : public QAbstractListModel
44{
46
47public:
48 explicit OptionsModel(interfaces::Node& node, QObject *parent = nullptr);
49
50 enum OptionID {
52 ShowTrayIcon, // bool
56 ProxyUse, // bool
57 ProxyIP, // QString
58 ProxyPort, // int
59 ProxyUseTor, // bool
60 ProxyIPTor, // QString
62 DisplayUnit, // BitcoinUnit
63 ThirdPartyTxUrls, // QString
64 Language, // QString
65 FontForMoney, // FontChoice
69 Prune, // bool
70 PruneSize, // int
74 Listen, // bool
75 Server, // bool
77 MaskValues, // bool
79 };
80
85 typedef std::variant<FontChoiceAbstract, QFont> FontChoice;
87 static QFont getFontForChoice(const FontChoice& fc);
88
89 bool Init(bilingual_str& error);
90 void Reset();
91
92 int rowCount(const QModelIndex & parent = QModelIndex()) const override;
93 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
94 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
95 QVariant getOption(OptionID option, const std::string& suffix="") const;
96 bool setOption(OptionID option, const QVariant& value, const std::string& suffix="");
98 void setDisplayUnit(const QVariant& new_unit);
99
100 /* Explicit getters */
101 bool getShowTrayIcon() const { return m_show_tray_icon; }
102 bool getMinimizeToTray() const { return fMinimizeToTray; }
103 bool getMinimizeOnClose() const { return fMinimizeOnClose; }
106 QFont getFontForMoney() const;
111
113 bool hasSigner();
114
115 /* Explicit setters */
117
118 /* Restart flag helper */
119 void setRestartRequired(bool fRequired);
120 bool isRestartRequired() const;
121
122 interfaces::Node& node() const { return m_node; }
123
124private:
126 /* Qt-only settings */
138
139 /* settings that were overridden by command-line */
141
144
145 // Add option to list of GUI options overridden through command line/config file
146 void addOverriddenOption(const std::string &option);
147
148 // Check settings version and upgrade default values if required
149 void checkAndMigrate();
150
156};
157
159
160#endif // BITCOIN_QT_OPTIONSMODEL_H
Unit
Bitcoin units.
Definition init.h:13
Interface from Qt to configuration data structure for Bitcoin client.
BitcoinUnit m_display_bitcoin_unit
QString strOverriddenByCommandLine
std::variant< FontChoiceAbstract, QFont > FontChoice
bool isRestartRequired() const
QFont getFontForMoney() const
bool getCoinControlFeatures() const
bool fCoinControlFeatures
bool getEnablePSBTControls() const
interfaces::Node & node() const
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
bool getSubFeeFromAmount() const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
bool m_sub_fee_from_amount
bool setOption(OptionID option, const QVariant &value, const std::string &suffix="")
interfaces::Node & m_node
void displayUnitChanged(BitcoinUnit unit)
void SetPruneTargetGB(int prune_target_gb)
void showTrayIconChanged(bool)
bool getMinimizeToTray() const
BitcoinUnit getDisplayUnit() const
bool getShowTrayIcon() const
bool hasSigner()
Whether -signer was set or not.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
const QString & getOverriddenByCommandLine()
bool m_enable_psbt_controls
QVariant getOption(OptionID option, const std::string &suffix="") const
bool getMinimizeOnClose() const
void setDisplayUnit(const QVariant &new_unit)
Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal.
FontChoice m_font_money
static FontChoice FontChoiceFromString(const QString &)
static QFont getFontForChoice(const FontChoice &fc)
QString getThirdPartyTxUrls() const
void checkAndMigrate()
void fontForMoneyChanged(const QFont &)
QString language
static QString FontChoiceToString(const OptionsModel::FontChoice &)
void addOverriddenOption(const std::string &option)
static const FontChoice UseBestSystemFont
bool fMinimizeOnClose
void setRestartRequired(bool fRequired)
bool m_show_tray_icon
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:66
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
constexpr uint64_t GB_BYTES
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
constexpr uint16_t DEFAULT_GUI_PROXY_PORT
const char * DEFAULT_GUI_PROXY_HOST
Bilingual messages:
Definition translation.h:24
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82