2018-07-27 00:36:45 +02:00
|
|
|
// Copyright (c) 2011-2018 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_QT_OPTIONSMODEL_H
|
|
|
|
#define BITCOIN_QT_OPTIONSMODEL_H
|
2011-05-31 22:24:53 +02:00
|
|
|
|
2017-11-10 01:57:53 +01:00
|
|
|
#include <amount.h>
|
2014-04-23 00:46:19 +02:00
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
2018-04-07 09:42:02 +02:00
|
|
|
namespace interfaces {
|
2017-04-17 20:23:14 +02:00
|
|
|
class Node;
|
|
|
|
}
|
|
|
|
|
2013-12-20 18:47:49 +01:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QNetworkProxy;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2017-12-01 12:08:31 +01:00
|
|
|
extern const char *DEFAULT_GUI_PROXY_HOST;
|
|
|
|
static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050;
|
|
|
|
|
2012-05-13 16:09:14 +02: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 14:19:57 +02:00
|
|
|
laid out vertically.
|
|
|
|
This can be changed to a tree once the settings become sufficiently
|
|
|
|
complex.
|
|
|
|
*/
|
2011-05-31 22:24:53 +02:00
|
|
|
class OptionsModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-07-09 13:40:22 +02:00
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
public:
|
2018-04-07 09:42:02 +02:00
|
|
|
explicit OptionsModel(interfaces::Node& node, QObject *parent = 0, bool resetSettings = false);
|
2011-05-31 22:24:53 +02:00
|
|
|
|
|
|
|
enum OptionID {
|
2013-11-16 17:37:31 +01:00
|
|
|
StartAtStartup, // bool
|
2016-05-12 04:28:02 +02:00
|
|
|
HideTrayIcon, // bool
|
2013-11-16 17:37:31 +01:00
|
|
|
MinimizeToTray, // bool
|
|
|
|
MapPortUPnP, // bool
|
|
|
|
MinimizeOnClose, // bool
|
|
|
|
ProxyUse, // bool
|
|
|
|
ProxyIP, // QString
|
|
|
|
ProxyPort, // int
|
2014-07-25 18:20:40 +02:00
|
|
|
ProxyUseTor, // bool
|
|
|
|
ProxyIPTor, // QString
|
|
|
|
ProxyPortTor, // int
|
2013-11-16 17:37:31 +01:00
|
|
|
DisplayUnit, // BitcoinUnits::Unit
|
2014-04-24 22:21:45 +02:00
|
|
|
ThirdPartyTxUrls, // QString
|
2013-11-16 17:37:31 +01:00
|
|
|
Language, // QString
|
|
|
|
CoinControlFeatures, // bool
|
2013-12-03 09:10:10 +01:00
|
|
|
ThreadsScriptVerif, // int
|
2018-05-15 12:46:19 +02:00
|
|
|
Prune, // bool
|
|
|
|
PruneSize, // int
|
2013-12-03 09:10:10 +01:00
|
|
|
DatabaseCache, // int
|
2014-02-15 10:38:06 +01:00
|
|
|
SpendZeroConfChange, // bool
|
2014-05-29 13:02:22 +02:00
|
|
|
Listen, // bool
|
2012-04-17 23:03:24 +02:00
|
|
|
OptionIDRowCount,
|
2011-05-31 22:24:53 +02:00
|
|
|
};
|
|
|
|
|
2015-11-13 16:27:42 +01:00
|
|
|
void Init(bool resetSettings = false);
|
2012-08-18 15:54:39 +02:00
|
|
|
void Reset();
|
2012-02-17 03:09:41 +01:00
|
|
|
|
2011-05-31 22:24:53 +02:00
|
|
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
|
|
|
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
|
2014-06-07 08:20:22 +02:00
|
|
|
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
|
|
|
|
void setDisplayUnit(const QVariant &value);
|
2011-05-31 22:24:53 +02:00
|
|
|
|
2011-06-01 09:34:12 +02:00
|
|
|
/* Explicit getters */
|
2017-03-09 13:34:54 +01:00
|
|
|
bool getHideTrayIcon() const { return fHideTrayIcon; }
|
|
|
|
bool getMinimizeToTray() const { return fMinimizeToTray; }
|
|
|
|
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
|
|
|
|
int getDisplayUnit() const { return nDisplayUnit; }
|
|
|
|
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
|
2013-12-20 18:47:49 +01:00
|
|
|
bool getProxySettings(QNetworkProxy& proxy) const;
|
2017-03-09 13:34:54 +01:00
|
|
|
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
|
2013-12-03 09:10:10 +01:00
|
|
|
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
|
|
|
|
|
|
|
|
/* Restart flag helper */
|
|
|
|
void setRestartRequired(bool fRequired);
|
2017-03-09 13:34:54 +01:00
|
|
|
bool isRestartRequired() const;
|
2012-07-09 13:40:22 +02:00
|
|
|
|
2018-04-07 09:42:02 +02:00
|
|
|
interfaces::Node& node() const { return m_node; }
|
2017-04-17 22:43:47 +02:00
|
|
|
|
2011-06-26 19:23:24 +02:00
|
|
|
private:
|
2018-04-07 09:42:02 +02:00
|
|
|
interfaces::Node& m_node;
|
2013-12-03 09:10:10 +01:00
|
|
|
/* Qt-only settings */
|
2016-05-12 04:28:02 +02:00
|
|
|
bool fHideTrayIcon;
|
2012-02-17 03:09:41 +01:00
|
|
|
bool fMinimizeToTray;
|
|
|
|
bool fMinimizeOnClose;
|
2012-05-08 23:03:41 +02:00
|
|
|
QString language;
|
2013-12-03 09:10:10 +01:00
|
|
|
int nDisplayUnit;
|
2014-04-24 22:21:45 +02:00
|
|
|
QString strThirdPartyTxUrls;
|
2013-08-12 17:03:03 +02:00
|
|
|
bool fCoinControlFeatures;
|
2016-11-28 09:19:05 +01:00
|
|
|
/* settings that were overridden by command-line */
|
2013-12-03 09:10:10 +01:00
|
|
|
QString strOverriddenByCommandLine;
|
2012-07-09 13:40:22 +02:00
|
|
|
|
2016-07-26 14:01:36 +02:00
|
|
|
// Add option to list of GUI options overridden through command line/config file
|
2014-03-14 07:22:59 +01:00
|
|
|
void addOverriddenOption(const std::string &option);
|
|
|
|
|
2016-07-26 14:01:36 +02:00
|
|
|
// Check settings version and upgrade default values if required
|
|
|
|
void checkAndMigrate();
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_SIGNALS:
|
2011-07-29 14:36:35 +02:00
|
|
|
void displayUnitChanged(int unit);
|
2013-08-12 17:03:03 +02:00
|
|
|
void coinControlFeaturesChanged(bool);
|
2016-05-12 04:28:02 +02:00
|
|
|
void hideTrayIconChanged(bool);
|
2011-05-31 22:24:53 +02:00
|
|
|
};
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_QT_OPTIONSMODEL_H
|