1 // Copyright (c) 2011-2015 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 "amount.h" 9 10 #include <QAbstractListModel> 11 12 QT_BEGIN_NAMESPACE 13 class QNetworkProxy; 14 QT_END_NAMESPACE 15 16 /** Interface from Qt to configuration data structure for Bitcoin client. 17 To Qt, the options are presented as a list with the different options 18 laid out vertically. 19 This can be changed to a tree once the settings become sufficiently 20 complex. 21 */ 22 class OptionsModel : public QAbstractListModel 23 { 24 Q_OBJECT 25 26 public: 27 explicit OptionsModel(QObject *parent = 0, bool resetSettings = false); 28 29 enum OptionID { 30 StartAtStartup, // bool 31 HideTrayIcon, // bool 32 MinimizeToTray, // bool 33 MapPortUPnP, // bool 34 MinimizeOnClose, // bool 35 ProxyUse, // bool 36 ProxyIP, // QString 37 ProxyPort, // int 38 ProxyUseTor, // bool 39 ProxyIPTor, // QString 40 ProxyPortTor, // int 41 DisplayUnit, // BitcoinUnits::Unit 42 ThirdPartyTxUrls, // QString 43 Language, // QString 44 CoinControlFeatures, // bool 45 ThreadsScriptVerif, // int 46 DatabaseCache, // int 47 SpendZeroConfChange, // bool 48 Listen, // bool 49 OptionIDRowCount, 50 }; 51 52 void Init(bool resetSettings = false); 53 void Reset(); 54 55 int rowCount(const QModelIndex & parent = QModelIndex()) const; 56 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; 57 bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); 58 /** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */ 59 void setDisplayUnit(const QVariant &value); 60 61 /* Explicit getters */ getHideTrayIcon()62 bool getHideTrayIcon() { return fHideTrayIcon; } getMinimizeToTray()63 bool getMinimizeToTray() { return fMinimizeToTray; } getMinimizeOnClose()64 bool getMinimizeOnClose() { return fMinimizeOnClose; } getDisplayUnit()65 int getDisplayUnit() { return nDisplayUnit; } getThirdPartyTxUrls()66 QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; } 67 bool getProxySettings(QNetworkProxy& proxy) const; getCoinControlFeatures()68 bool getCoinControlFeatures() { return fCoinControlFeatures; } getOverriddenByCommandLine()69 const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } 70 71 /* Restart flag helper */ 72 void setRestartRequired(bool fRequired); 73 bool isRestartRequired(); 74 75 private: 76 /* Qt-only settings */ 77 bool fHideTrayIcon; 78 bool fMinimizeToTray; 79 bool fMinimizeOnClose; 80 QString language; 81 int nDisplayUnit; 82 QString strThirdPartyTxUrls; 83 bool fCoinControlFeatures; 84 /* settings that were overriden by command-line */ 85 QString strOverriddenByCommandLine; 86 87 // Add option to list of GUI options overridden through command line/config file 88 void addOverriddenOption(const std::string &option); 89 90 // Check settings version and upgrade default values if required 91 void checkAndMigrate(); 92 Q_SIGNALS: 93 void displayUnitChanged(int unit); 94 void coinControlFeaturesChanged(bool); 95 void hideTrayIconChanged(bool); 96 }; 97 98 #endif // BITCOIN_QT_OPTIONSMODEL_H 99