You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

optionsmodel.h 3.3KB

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