summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2020-01-19 12:25:17 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-20 09:49:49 -0800
commit13b2b9f19c3f9ecb41565c5eab07d590071dede6 (patch)
treef937ac09e6862b2dceec2b12cb25e8b9e8764054
parent75fe59b0da4d15c2e63c070f6f561805af86e5d9 (diff)
downloadsubsurface-13b2b9f19c3f9ecb41565c5eab07d590071dede6.tar.gz
core/settings: allow signals to be strongly typed in C++
Register enums to allow them to be used in signal handlers instead of int. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/settings/qPref.cpp17
-rw-r--r--tests/testqPrefUnits.cpp2
2 files changed, 19 insertions, 0 deletions
diff --git a/core/settings/qPref.cpp b/core/settings/qPref.cpp
index 640300f96..522a74c6d 100644
--- a/core/settings/qPref.cpp
+++ b/core/settings/qPref.cpp
@@ -49,6 +49,15 @@ void qPref::loadSync(bool doSync)
Q_DECLARE_METATYPE(deco_mode);
Q_DECLARE_METATYPE(def_file_behavior);
Q_DECLARE_METATYPE(taxonomy_category);
+Q_DECLARE_METATYPE(units::DURATION);
+Q_DECLARE_METATYPE(units::LENGTH);
+Q_DECLARE_METATYPE(units::PRESSURE);
+Q_DECLARE_METATYPE(units::TEMPERATURE);
+Q_DECLARE_METATYPE(unit_system_values);
+Q_DECLARE_METATYPE(units::TIME);
+Q_DECLARE_METATYPE(units::VOLUME);
+Q_DECLARE_METATYPE(units::WEIGHT);
+
void qPref::registerQML(QQmlEngine *engine)
{
if (engine) {
@@ -77,4 +86,12 @@ void qPref::registerQML(QQmlEngine *engine)
qRegisterMetaType<deco_mode>();
qRegisterMetaType<def_file_behavior>();
qRegisterMetaType<taxonomy_category>();
+ qRegisterMetaType<units::DURATION>();
+ qRegisterMetaType<units::LENGTH>();
+ qRegisterMetaType<units::PRESSURE>();
+ qRegisterMetaType<units::TEMPERATURE>();
+ qRegisterMetaType<unit_system_values>();
+ qRegisterMetaType<units::TIME>();
+ qRegisterMetaType<units::VOLUME>();
+ qRegisterMetaType<units::WEIGHT>();
}
diff --git a/tests/testqPrefUnits.cpp b/tests/testqPrefUnits.cpp
index b2ead5c9e..c5635732b 100644
--- a/tests/testqPrefUnits.cpp
+++ b/tests/testqPrefUnits.cpp
@@ -3,6 +3,7 @@
#include "core/pref.h"
#include "core/qthelper.h"
+#include "core/settings/qPref.h"
#include "core/settings/qPrefUnit.h"
#include <QTest>
@@ -13,6 +14,7 @@ void TestQPrefUnits::initTestCase()
QCoreApplication::setOrganizationName("Subsurface");
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
QCoreApplication::setApplicationName("SubsurfaceTestQPrefUnits");
+ qPref::registerQML(NULL);
}
void TestQPrefUnits::test_struct_get()