35 #define extern_cfg(T, NAME) extern Config::T##Type NAME; |
35 #define extern_cfg(T, NAME) extern Config::T##Type NAME; |
36 |
36 |
37 // ========================================================= |
37 // ========================================================= |
38 class Config |
38 class Config |
39 { |
39 { |
40 PROPERTY (private, QString, name, setName, STOCK_WRITE) |
40 PROPERTY (private, String, name, setName, STOCK_WRITE) |
41 |
41 |
42 public: |
42 public: |
43 enum Type |
43 enum Type |
44 { |
44 { |
45 EIntType, |
45 EIntType, |
50 EListType, |
50 EListType, |
51 EVertexType, |
51 EVertexType, |
52 }; |
52 }; |
53 |
53 |
54 using IntType = int; |
54 using IntType = int; |
55 using StringType = QString; |
55 using StringType = String; |
56 using FloatType = float; |
56 using FloatType = float; |
57 using BoolType = bool; |
57 using BoolType = bool; |
58 using KeySequenceType = QKeySequence; |
58 using KeySequenceType = QKeySequence; |
59 using ListType = QList<QVariant>; |
59 using ListType = QList<QVariant>; |
60 using VertexType = Vertex; |
60 using VertexType = Vertex; |
61 |
61 |
62 Config (QString name); |
62 Config (String name); |
63 |
63 |
64 virtual QVariant getDefaultAsVariant() const = 0; |
64 virtual QVariant getDefaultAsVariant() const = 0; |
65 virtual Type getType() const = 0; |
65 virtual Type getType() const = 0; |
66 virtual bool isDefault() const = 0; |
66 virtual bool isDefault() const = 0; |
67 virtual void loadFromVariant (const QVariant& val) = 0; |
67 virtual void loadFromVariant (const QVariant& val) = 0; |
70 |
70 |
71 // ------------------------------------------ |
71 // ------------------------------------------ |
72 static bool load(); |
72 static bool load(); |
73 static bool save(); |
73 static bool save(); |
74 static void reset(); |
74 static void reset(); |
75 static QString dirpath(); |
75 static String dirpath(); |
76 static QString filepath (QString file); |
76 static String filepath (String file); |
77 |
77 |
78 protected: |
78 protected: |
79 static void addToArray (Config* ptr); |
79 static void addToArray (Config* ptr); |
80 }; |
80 }; |
81 |
81 |
82 // ============================================================================= |
82 // ============================================================================= |
83 #define IMPLEMENT_CONFIG(NAME) \ |
83 #define IMPLEMENT_CONFIG(NAME) \ |
84 public: \ |
84 public: \ |
85 using ValueType = Config::NAME##Type; \ |
85 using ValueType = Config::NAME##Type; \ |
86 \ |
86 \ |
87 NAME##Config (ValueType* valueptr, QString name, ValueType def) : \ |
87 NAME##Config (ValueType* valueptr, String name, ValueType def) : \ |
88 Config (name), \ |
88 Config (name), \ |
89 m_valueptr (valueptr), \ |
89 m_valueptr (valueptr), \ |
90 m_default (def) \ |
90 m_default (def) \ |
91 { \ |
91 { \ |
92 Config::addToArray (this); \ |
92 Config::addToArray (this); \ |