|
Albert
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
6#define EXPAND_STRINGIZE(s) STRINGIZE(s)
36#define ALBERT_PROPERTY_BASE(type, name, defaultValue, settings) \
37 public: static type name##_default(){ return defaultValue; }; \
38 protected: void store_##name() { settings()->setValue(EXPAND_STRINGIZE(name), name()); } \
39 protected: void restore_##name(const auto &s = nullptr) { \
40 if (s) set_##name##_(s->value(EXPAND_STRINGIZE(name), name##_default()).template value<type>()); \
41 else set_##name##_(settings()->value(EXPAND_STRINGIZE(name), name##_default()).template value<type>()); \
43 public: void reset_##name() { set_##name##_(name##_default()); settings()->remove(EXPAND_STRINGIZE(name)); } \
44 Q_SIGNAL void name##_changed(type); \
45 Q_PROPERTY(type name READ name WRITE set_##name RESET reset_##name NOTIFY name##_changed USER true) \
46 public: void set_##name(type val) { if (val != name()){ set_##name##_(val); store_##name(); emit name##_changed(val); } }
54#define ALBERT_PLUGIN_PROPERTY_BASE(type, name, defaultValue) \
55 ALBERT_PROPERTY_BASE(type, name, defaultValue, PluginInstance::settings)
77#define ALBERT_PROPERTY_GETSET(type, name, defaultValue, settings) \
78 ALBERT_PROPERTY_BASE(type, name, defaultValue, settings) \
79 public: type name() const; \
80 private: void set_##name##_(type);
88#define ALBERT_PLUGIN_PROPERTY_GETSET(type, name, defaultValue) \
89 ALBERT_PROPERTY_GETSET(type, name, defaultValue, PluginInstance::settings)
107#define ALBERT_PROPERTY_MEMBER(type, name, member, defaultValue, settings) \
108 ALBERT_PROPERTY_BASE(type, name, defaultValue, settings) \
109 public: type name() const { return member; } \
110 private: void set_##name##_(type val) { member=val; }
117#define ALBERT_PLUGIN_PROPERTY_MEMBER(type, name, member, defaultValue) \
118 ALBERT_PROPERTY_MEMBER(type, name, member, defaultValue, PluginInstance::settings)
134#define ALBERT_PROPERTY(type, name, defaultValue, settings) \
135 ALBERT_PROPERTY_MEMBER(type, name, name##_, defaultValue, settings) \
136 protected: type name##_{name##_default()};
143#define ALBERT_PLUGIN_PROPERTY(type, name, defaultValue) \
144 ALBERT_PROPERTY(type, name, defaultValue, PluginInstance::settings)
158#define ALBERT_PROPERTY_CONNECT_CHECKBOX(object, name, checkbox) \
159 checkbox->setChecked(object->name()); \
160 connect(object, &std::remove_pointer<decltype(object)>::type::name##_changed, \
161 checkbox, &QCheckBox::setChecked); \
162 connect(checkbox, &QCheckBox::toggled, \
163 object, &std::remove_pointer<decltype(object)>::type::set_##name);
174#define ALBERT_PROPERTY_CONNECT_SPINBOX(object, name, spinbox) \
175 spinbox->setValue(object->name()); \
176 connect(object, &std::remove_pointer<decltype(object)>::type::name##_changed, \
177 spinbox, &QSpinBox::setValue); \
178 connect(spinbox, &QSpinBox::valueChanged, \
179 object, &std::remove_pointer<decltype(object)>::type::set_##name);