1 {% from "macros.tmpl" import license %}
4 #ifndef SettingsMacros_h
5 #define SettingsMacros_h
7 #define SETTINGS_GETTERS_AND_SETTERS \
8 {% for setting in settings %}
9 {{setting.type|to_passing_type}} {{setting.name}}() const { return m_{{setting.name}}; } \
10 void set{{setting.name|upper_first}}({{setting.type|to_passing_type}} {{setting.name}}); \
12 void setFromStrings(const String& name, const String& value);
13 // End of SETTINGS_GETTERS_AND_SETTERS.
15 #define SETTINGS_MEMBER_VARIABLES \
16 {% for setting in settings if setting.type != 'bool' %}
17 {{setting.type}} m_{{setting.name}}; \
19 {% for setting in settings if setting.type == 'bool' %}
20 bool m_{{setting.name}} : 1; \
22 // End of SETTINGS_MEMBER_VARIABLES.
24 #define SETTINGS_INITIALIZER_LIST \
25 {% for setting in settings if setting.initial and setting.type != 'bool' %}
26 , m_{{setting.name}}({{setting.initial}}) \
28 {% for setting in settings if setting.initial and setting.type == 'bool' %}
29 , m_{{setting.name}}({{setting.initial}}) \
31 // End of SETTINGS_INITIALIZER_LIST.
33 #define SETTINGS_SETTER_BODIES \
34 {% for setting in settings %}
35 void Settings::set{{setting.name|upper_first}}({{setting.type|to_passing_type}} {{setting.name}}) \
37 if (m_{{setting.name}} == {{setting.name}}) \
39 m_{{setting.name}} = {{setting.name}}; \
40 {% if setting.invalidate %}
41 invalidate(SettingsDelegate::{{setting.invalidate}}Change); \
45 void Settings::setFromStrings(const String& name, const String& value) \
47 {% for setting in settings %}
48 if (equalIgnoringCase(name, "{{setting.name}}")) { \
49 set{{setting.name|upper_first}}( \
50 {% if setting.type == 'String' %}
52 {% elif setting.type == 'bool' %}
53 value.isEmpty() || equalIgnoringCase(value, "true") \
54 {% elif setting.type == 'int' %}
56 {% elif setting.type == 'float' %}
58 {% elif setting.type == 'double' %}
61 static_cast<{{setting.type}}>(value.toInt()) \
68 // End of SETTINGS_SETTER_BODIES.
70 #endif // SettingsMacros_h