summaryrefslogtreecommitdiffhomepage
path: root/options/metatype.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-08 23:29:49 +0200
commitfa1801471c2708ed8266ec7b99bd4cec886ccc1b (patch)
treeaa56218c2c7e4939aaf11a2046b0f12760326545 /options/metatype.cpp
parent90940a774eab876c38d5cef981b4be5bae67a462 (diff)
options: fix 2 issues
1. Calling valueChanged didn't invoke machinery in value<t>, only base_value aka value_. There's a fast path in value<t>::type() despite the pessimization. 2. Split global scope stuff into options::globals from the options::globals stuff 3. Adjust usages
Diffstat (limited to 'options/metatype.cpp')
-rw-r--r--options/metatype.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/options/metatype.cpp b/options/metatype.cpp
index 0fa33933..e54970c0 100644
--- a/options/metatype.cpp
+++ b/options/metatype.cpp
@@ -1,3 +1,31 @@
-#include "defs.hpp"
+#include <QMetaType>
+
+namespace options::detail {
+
+template<typename t>
+int declare_metatype_for_type(const char* str)
+{
+ qRegisterMetaType<t>(str);
+ qRegisterMetaTypeStreamOperators<t>();
+
+ return -1;
+}
+
+} // ns options::detail
+
+#define OPENTRACK_DEFINE_METATYPE2(t, ctr) \
+ OPENTRACK_DEFINE_METATYPE3(t, ctr)
+
+#define OPENTRACK_DEFINE_METATYPE3(t, ctr) \
+ OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr)
+
+#define OPENTRACK_DEFINE_METATYPE4(t, sym) \
+ static class sym { \
+ static const int dribble; \
+ } sym ## _singleton; \
+ const int sym :: dribble = ::options::detail::declare_metatype_for_type<t>(#t)
+
+#define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__)
+
#define OPENTRACK_METATYPE_(x) OPENTRACK_DEFINE_METATYPE(x)
#include "metatype.hpp"