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>
This commit is contained in:
jan Iversen 2020-01-19 12:25:17 +01:00 committed by Dirk Hohndel
parent 75fe59b0da
commit 13b2b9f19c
2 changed files with 19 additions and 0 deletions

View file

@ -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>();
}

View file

@ -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()