OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
state.hpp
Go to the documentation of this file.
1 #ifndef CSM_PREFS_STATE_H
2 #define CSM_PREFS_STATE_H
3 
4 #include <map>
5 #include <string>
6 
7 #include <QObject>
8 #include <QMutex>
9 
10 #ifndef Q_MOC_RUN
12 #endif
13 
15 
16 #include "category.hpp"
17 #include "setting.hpp"
18 #include "enumsetting.hpp"
19 #include "shortcutmanager.hpp"
20 
21 class QColor;
22 
23 namespace CSMPrefs
24 {
25  class IntSetting;
26  class DoubleSetting;
27  class BoolSetting;
28  class ColourSetting;
29  class ShortcutSetting;
30  class ModifierSetting;
31 
36  class State : public QObject
37  {
38  Q_OBJECT
39 
40  static State *sThis;
41 
42  public:
43 
44  typedef std::map<std::string, Category> Collection;
45  typedef Collection::iterator Iterator;
46 
47  private:
48 
49  const std::string mConfigFile;
55  QMutex mMutex;
56 
57  // not implemented
58  State (const State&);
59  State& operator= (const State&);
60 
61  private:
62 
63  void load();
64 
65  void declare();
66 
67  void declareCategory (const std::string& key);
68 
69  IntSetting& declareInt (const std::string& key, const std::string& label, int default_);
70  DoubleSetting& declareDouble (const std::string& key, const std::string& label, double default_);
71 
72  BoolSetting& declareBool (const std::string& key, const std::string& label, bool default_);
73 
74  EnumSetting& declareEnum (const std::string& key, const std::string& label, EnumValue default_);
75 
76  ColourSetting& declareColour (const std::string& key, const std::string& label, QColor default_);
77 
78  ShortcutSetting& declareShortcut (const std::string& key, const std::string& label,
79  const QKeySequence& default_);
80 
81  ModifierSetting& declareModifier(const std::string& key, const std::string& label, int modifier_);
82 
83  void declareSeparator();
84 
85  void declareSubcategory(const std::string& label);
86 
87  void setDefault (const std::string& key, const std::string& default_);
88 
89  public:
90 
91  State (const Files::ConfigurationManager& configurationManager);
92 
93  ~State();
94 
95  void save();
96 
97  Iterator begin();
98 
99  Iterator end();
100 
102 
103  Category& operator[](const std::string& key);
104 
105  void update (const Setting& setting);
106 
107  static State& get();
108 
109  signals:
110 
111  void settingChanged (const CSMPrefs::Setting *setting);
112  };
113 
114  // convenience function
115  State& get();
116 }
117 
118 #endif
Collection mCategories
Definition: state.hpp:53
void declare()
Definition: state.cpp:37
void declareSeparator()
Definition: state.cpp:489
void update(const Setting &setting)
Definition: state.cpp:571
static const struct @2 signals[]
const Files::ConfigurationManager & mConfigurationManager
Definition: state.hpp:50
Collection::iterator Iterator
Definition: state.hpp:45
Definition: coloursetting.hpp:10
ShortcutSetting & declareShortcut(const std::string &key, const std::string &label, const QKeySequence &default_)
Definition: state.cpp:445
void load()
Definition: state.cpp:17
std::map< std::string, Category > Collection
Definition: state.hpp:44
const std::string mConfigFile
Definition: state.hpp:49
DoubleSetting & declareDouble(const std::string &key, const std::string &label, double default_)
Definition: state.cpp:367
Settings::Manager mSettings
Definition: state.hpp:52
Definition: doublesetting.hpp:8
void declareSubcategory(const std::string &label)
Definition: state.cpp:500
Definition: category.hpp:12
State & operator=(const State &)
Definition: configurationmanager.hpp:20
Category & operator[](const std::string &key)
Definition: state.cpp:561
static State * sThis
Definition: state.hpp:40
void settingChanged(const CSMPrefs::Setting *setting)
Definition: boolsetting.hpp:8
~State()
Definition: state.cpp:535
Definition: enumsetting.hpp:10
void setDefault(const std::string &key, const std::string &default_)
Definition: state.cpp:511
QMutex mMutex
Definition: state.hpp:55
void save()
Definition: state.cpp:540
State(const State &)
User settings state.
Definition: state.hpp:36
Definition: modifiersetting.hpp:13
BoolSetting & declareBool(const std::string &key, const std::string &label, bool default_)
Definition: state.cpp:388
Definition: setting.hpp:22
Definition: intsetting.hpp:8
Definition: shortcutsetting.hpp:13
Iterator begin()
Definition: state.cpp:546
Definition: enumsetting.hpp:31
Class used to track and update shortcuts/sequences.
Definition: shortcutmanager.hpp:16
Iterator end()
Definition: state.cpp:551
Settings management (can change during runtime)
Definition: settings.hpp:17
EnumSetting & declareEnum(const std::string &key, const std::string &label, EnumValue default_)
Definition: state.cpp:407
ShortcutManager mShortcutManager
Definition: state.hpp:51
ModifierSetting & declareModifier(const std::string &key, const std::string &label, int modifier_)
Definition: state.cpp:467
ColourSetting & declareColour(const std::string &key, const std::string &label, QColor default_)
Definition: state.cpp:426
Iterator mCurrentCategory
Definition: state.hpp:54
IntSetting & declareInt(const std::string &key, const std::string &label, int default_)
Definition: state.cpp:346
void declareCategory(const std::string &key)
Definition: state.cpp:331
ShortcutManager & getShortcutManager()
Definition: state.cpp:556