2020-01-14 16:17:38 -03:00
|
|
|
// Copyright (c) 2011-2020 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 12:20:43 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#ifndef BITCOIN_QT_OPTIONSMODEL_H
|
|
|
|
#define BITCOIN_QT_OPTIONSMODEL_H
|
2011-05-31 16:24:53 -04:00
|
|
|
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <amount.h>
|
2019-12-29 18:04:02 -03:00
|
|
|
#include <cstdint>
|
2019-11-12 08:23:09 -03:00
|
|
|
#include <qt/guiconstants.h>
|
2014-04-22 19:46:19 -03:00
|
|
|
|
2011-05-31 16:24:53 -04:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
2018-08-23 14:42:31 -03:00
|
|
|
#include <assert.h>
|
|
|
|
|
2018-04-07 04:42:02 -03:00
|
|
|
namespace interfaces {
|
2017-04-17 15:23:14 -03:00
|
|
|
class Node;
|
|
|
|
}
|
|
|
|
|
2017-12-01 08:08:31 -03:00
|
|
|
extern const char *DEFAULT_GUI_PROXY_HOST;
|
2019-12-29 18:04:02 -03:00
|
|
|
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
|
2017-12-01 08:08:31 -03:00
|
|
|
|
2019-11-12 08:23:09 -03:00
|
|
|
/**
|
|
|
|
* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.
|
|
|
|
*/
|
|
|
|
static inline int PruneMiBtoGB(int64_t mib) { return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES; }
|
|
|
|
|
2019-11-12 07:14:52 -03:00
|
|
|
/**
|
|
|
|
* Convert displayed prune target GB to configured MiB. Round down so roundtrip GB -> MiB -> GB conversion is stable.
|
|
|
|
*/
|
|
|
|
static inline int64_t PruneGBtoMiB(int gb) { return gb * GB_BYTES / 1024 / 1024; }
|
|
|
|
|
2012-05-13 10:09:14 -04:00
|
|
|
/** Interface from Qt to configuration data structure for Bitcoin client.
|
|
|
|
To Qt, the options are presented as a list with the different options
|
2011-06-05 08:19:57 -04:00
|
|
|
laid out vertically.
|
|
|
|
This can be changed to a tree once the settings become sufficiently
|
|
|
|
complex.
|
|
|
|
*/
|
2011-05-31 16:24:53 -04:00
|
|
|
class OptionsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-07-09 07:40:22 -04:00
|
|
|
|
2011-05-31 16:24:53 -04:00
|
|
|
public:
|
2018-08-23 14:42:31 -03:00
|
|
|
explicit OptionsModel(QObject *parent = nullptr, bool resetSettings = false);
|
2011-05-31 16:24:53 -04:00
|
|
|
|
|
|
|
enum OptionID {
|
2013-11-16 13:37:31 -03:00
|
|
|
StartAtStartup, // bool
|
2020-10-24 18:34:41 -03:00
|
|
|
ShowTrayIcon, // bool
|
2013-11-16 13:37:31 -03:00
|
|
|
MinimizeToTray, // bool
|
|
|
|
MapPortUPnP, // bool
|
2020-02-22 21:12:19 -03:00
|
|
|
MapPortNatpmp, // bool
|
2013-11-16 13:37:31 -03:00
|
|
|
MinimizeOnClose, // bool
|
|
|
|
ProxyUse, // bool
|
|
|
|
ProxyIP, // QString
|
|
|
|
ProxyPort, // int
|
2014-07-25 12:20:40 -04:00
|
|
|
ProxyUseTor, // bool
|
|
|
|
ProxyIPTor, // QString
|
|
|
|
ProxyPortTor, // int
|
2013-11-16 13:37:31 -03:00
|
|
|
DisplayUnit, // BitcoinUnits::Unit
|
2014-04-24 17:21:45 -03:00
|
|
|
ThirdPartyTxUrls, // QString
|
2013-11-16 13:37:31 -03:00
|
|
|
Language, // QString
|
2021-02-21 15:58:19 -03:00
|
|
|
UseEmbeddedMonospacedFont, // bool
|
2013-11-16 13:37:31 -03:00
|
|
|
CoinControlFeatures, // bool
|
2021-07-29 12:27:57 -04:00
|
|
|
SubFeeFromAmount, // bool
|
2013-12-03 05:10:10 -03:00
|
|
|
ThreadsScriptVerif, // int
|
2018-05-15 06:46:19 -04:00
|
|
|
Prune, // bool
|
|
|
|
PruneSize, // int
|
2013-12-03 05:10:10 -03:00
|
|
|
DatabaseCache, // int
|
2019-09-16 13:51:24 -03:00
|
|
|
ExternalSignerPath, // QString
|
2014-02-15 06:38:06 -03:00
|
|
|
SpendZeroConfChange, // bool
|
2014-05-29 07:02:22 -04:00
|
|
|
Listen, // bool
|
2012-04-17 18:03:24 -03:00
|
|
|
OptionIDRowCount,
|
2011-05-31 16:24:53 -04:00
|
|
|
};
|
|
|
|
|
2015-11-13 12:27:42 -03:00
|
|
|
void Init(bool resetSettings = false);
|
2012-08-18 09:54:39 -04:00
|
|
|
void Reset();
|
2012-02-16 23:09:41 -03:00
|
|
|
|
2020-03-14 03:49:59 -03:00
|
|
|
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
|
|
|
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
|
2014-06-07 02:20:22 -04:00
|
|
|
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
|
|
|
|
void setDisplayUnit(const QVariant &value);
|
2011-05-31 16:24:53 -04:00
|
|
|
|
2011-06-01 03:34:12 -04:00
|
|
|
/* Explicit getters */
|
2020-10-24 18:34:41 -03:00
|
|
|
bool getShowTrayIcon() const { return m_show_tray_icon; }
|
2017-03-09 09:34:54 -03:00
|
|
|
bool getMinimizeToTray() const { return fMinimizeToTray; }
|
|
|
|
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
|
|
|
|
int getDisplayUnit() const { return nDisplayUnit; }
|
|
|
|
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
|
2021-02-21 15:58:19 -03:00
|
|
|
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
|
2017-03-09 09:34:54 -03:00
|
|
|
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
2021-07-29 12:27:57 -04:00
|
|
|
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
|
2013-12-03 05:10:10 -03:00
|
|
|
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
|
|
|
|
2019-08-24 16:31:14 -04:00
|
|
|
/* Explicit setters */
|
2019-11-12 07:09:10 -03:00
|
|
|
void SetPruneEnabled(bool prune, bool force = false);
|
|
|
|
void SetPruneTargetGB(int prune_target_gb, bool force = false);
|
2019-08-24 16:31:14 -04:00
|
|
|
|
2013-12-03 05:10:10 -03:00
|
|
|
/* Restart flag helper */
|
|
|
|
void setRestartRequired(bool fRequired);
|
2017-03-09 09:34:54 -03:00
|
|
|
bool isRestartRequired() const;
|
2012-07-09 07:40:22 -04:00
|
|
|
|
2018-08-23 14:42:31 -03:00
|
|
|
interfaces::Node& node() const { assert(m_node); return *m_node; }
|
|
|
|
void setNode(interfaces::Node& node) { assert(!m_node); m_node = &node; }
|
2017-04-17 17:43:47 -03:00
|
|
|
|
2011-06-26 13:23:24 -04:00
|
|
|
private:
|
2018-08-23 14:42:31 -03:00
|
|
|
interfaces::Node* m_node = nullptr;
|
2013-12-03 05:10:10 -03:00
|
|
|
/* Qt-only settings */
|
2020-10-24 18:34:41 -03:00
|
|
|
bool m_show_tray_icon;
|
2012-02-16 23:09:41 -03:00
|
|
|
bool fMinimizeToTray;
|
|
|
|
bool fMinimizeOnClose;
|
2012-05-08 17:03:41 -04:00
|
|
|
QString language;
|
2013-12-03 05:10:10 -03:00
|
|
|
int nDisplayUnit;
|
2014-04-24 17:21:45 -03:00
|
|
|
QString strThirdPartyTxUrls;
|
2021-02-21 15:58:19 -03:00
|
|
|
bool m_use_embedded_monospaced_font;
|
2013-08-12 11:03:03 -04:00
|
|
|
bool fCoinControlFeatures;
|
2021-07-29 12:27:57 -04:00
|
|
|
bool m_sub_fee_from_amount;
|
2016-11-28 05:19:05 -03:00
|
|
|
/* settings that were overridden by command-line */
|
2013-12-03 05:10:10 -03:00
|
|
|
QString strOverriddenByCommandLine;
|
2012-07-09 07:40:22 -04:00
|
|
|
|
2016-07-26 08:01:36 -04:00
|
|
|
// Add option to list of GUI options overridden through command line/config file
|
2014-03-14 03:22:59 -03:00
|
|
|
void addOverriddenOption(const std::string &option);
|
|
|
|
|
2016-07-26 08:01:36 -04:00
|
|
|
// Check settings version and upgrade default values if required
|
|
|
|
void checkAndMigrate();
|
2015-07-14 08:59:05 -03:00
|
|
|
Q_SIGNALS:
|
2011-07-29 08:36:35 -04:00
|
|
|
void displayUnitChanged(int unit);
|
2013-08-12 11:03:03 -04:00
|
|
|
void coinControlFeaturesChanged(bool);
|
2020-10-24 18:34:41 -03:00
|
|
|
void showTrayIconChanged(bool);
|
2021-02-21 15:58:19 -03:00
|
|
|
void useEmbeddedMonospacedFontChanged(bool);
|
2011-05-31 16:24:53 -04:00
|
|
|
};
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#endif // BITCOIN_QT_OPTIONSMODEL_H
|