2 #include <score/command/SettingsCommand.hpp>
4 #include <ossia/detail/for_each_in_tuple.hpp>
9 #include <score_lib_base_export.h>
18 using QObject::QObject;
22 template <
typename Parameter>
26 using parameter_type = Parameter;
27 using model_type =
typename Parameter::model_type;
28 using data_type =
typename Parameter::param_type;
29 using argument_type =
typename boost::call_traits<data_type>::param_type;
37 #if !defined(__EMSCRIPTEN__)
38 template <
typename T,
typename Model>
39 void setupDefaultSettings(QSettings& set,
const T& tuple, Model& model)
41 ossia::for_each_in_tuple(tuple, [&](
auto& e) {
42 using type = std::remove_reference_t<decltype(e)>;
43 using data_type =
typename type::data_type;
44 using param_type =
typename type::parameter_type;
48 if(!set.contains(e.key))
50 set.setValue(e.key, QVariant::fromValue(e.def));
51 (model.*param_type::init)(e.def);
56 auto val = set.value(e.key).template value<data_type>();
57 (model.*param_type::init)(val);
62 template <
typename T,
typename Model>
63 void setupDefaultSettings(QSettings&,
const T& tuple, Model& model)
65 ossia::for_each_in_tuple(tuple, [&](
auto& e) {
66 using type = std::remove_reference_t<decltype(e)>;
67 using data_type =
typename type::data_type;
68 using param_type =
typename type::parameter_type;
69 (model.*param_type::set)(e.def);
75 #define SETTINGS_PARAMETER_IMPL(Name) const score::sp<Model::p_##Name> Name
77 #define SCORE_SETTINGS_COMMAND(ModelType, Name) \
78 struct Set##ModelType##Name final \
79 : public score::SettingsCommand<ModelType::p_##Name> \
81 static constexpr const bool is_deferred = false; \
82 SCORE_SETTINGS_COMMAND_DECL(Set##ModelType##Name) \
85 #define SCORE_SETTINGS_PARAMETER(ModelType, Name) SCORE_SETTINGS_COMMAND(ModelType, Name)
87 #define SCORE_SETTINGS_DEFERRED_COMMAND(ModelType, Name) \
88 struct Set##ModelType##Name final \
89 : public score::SettingsCommand<ModelType::p_##Name> \
91 static constexpr const bool is_deferred = true; \
92 SCORE_SETTINGS_COMMAND_DECL(Set##ModelType##Name) \
95 #define SCORE_SETTINGS_DEFERRED_PARAMETER(ModelType, Name) \
96 SCORE_SETTINGS_DEFERRED_COMMAND(ModelType, Name)
98 #define SCORE_SETTINGS_PROPERTY(Type, Name) \
100 Type, Name, &W_ThisType::get##Name, &W_ThisType::set##Name, W_Notify, \
101 &W_ThisType::Name##Changed) \
104 using param_type = Type; \
105 using model_type = W_ThisType; \
106 static const constexpr auto name = #Name; \
107 static const constexpr auto get = &W_ThisType::get##Name; \
108 static const constexpr auto set = &W_ThisType::set##Name; \
109 static const constexpr auto notify = &W_ThisType::Name##Changed; \
110 static const constexpr auto init = &W_ThisType::init##Name; \
113 #define SCORE_SETTINGS_PARAMETER_HPP(Export, Type, Name) \
115 Type get##Name() const; \
116 void init##Name(Type); \
117 void set##Name(Type); \
118 void Name##Changed(Type arg) E_SIGNAL2(Export##S, Export, Name##Changed, arg); \
119 SCORE_SETTINGS_PROPERTY(Type, Name) \
122 #if !defined(__EMSCRIPTEN__)
123 #define SCORE_SETTINGS_PARAMETER_CPP(Type, ModelType, Name) \
124 Type ModelType::get##Name() const \
129 void ModelType::init##Name(Type val) \
133 Name##Changed(val); \
135 void ModelType::set##Name(Type val) \
137 if(val == m_##Name) \
143 s.setValue(Parameters::Name.key, QVariant::fromValue(m_##Name)); \
144 Name##Changed(val); \
147 #define SCORE_SETTINGS_PARAMETER_CPP(Type, ModelType, Name) \
148 Type ModelType::get##Name() const \
153 void ModelType::init##Name(Type val) \
156 Name##Changed(val); \
158 void ModelType::set##Name(Type val) \
160 if(val == m_##Name) \
163 init##Name(std::move(val)); \
167 #define SCORE_PROJECTSETTINGS_PARAMETER_CPP(Type, ModelType, Name) \
168 Type ModelType::get##Name() const \
173 void ModelType::init##Name(Type val) \
176 Name##Changed(val); \
178 void ModelType::set##Name(Type val) \
180 if(val == m_##Name) \
183 init##Name(std::move(val)); \
Definition: SettingsDelegateModel.hpp:16
Base toolkit upon which the software is built.
Definition: Application.cpp:90