diff options
author | jan Iversen <jani@apache.org> | 2018-09-04 11:18:43 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-09-11 17:22:58 -0700 |
commit | d0edc296360e7653a4c8b672cfb136581c4a10f0 (patch) | |
tree | 6d42fcee2174770cd1e0c8edd892540553ee40b6 /subsurface-helper.cpp | |
parent | a71afd31ee66edf45c8970dcbd6514d7c4b5e9f0 (diff) | |
download | subsurface-d0edc296360e7653a4c8b672cfb136581c4a10f0.tar.gz |
core,tests: change qml register function
In order to address the C++ object directy in qml, a different
registration is needed.
qmlRegisterType, registers the C++ class, allowing qml code to inherit
from it and make qml objects. This is needed for graphical elemnets
like profile and map
setContentProperty, registers the C++ object, thus allowing signals to be
catched.
Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'subsurface-helper.cpp')
-rw-r--r-- | subsurface-helper.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 38601ddf3..f261f3e1f 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -35,7 +35,6 @@ static void register_meta_types(); void init_ui() { init_qt_late(); - register_qml_types(); register_meta_types(); #ifndef SUBSURFACE_MOBILE PluginManager::instance().loadPlugins(); @@ -60,11 +59,15 @@ double get_screen_dpi() return mydesk->physicalDpiX(); } +// Forward declaration +static void register_qml_types(QQmlEngine *); + void run_ui() { #ifdef SUBSURFACE_MOBILE QQmlApplicationEngine engine; + register_qml_types(&engine); LOG_STP("run_ui qml engine started"); KirigamiPlugin::getInstance().registerTypes(); #if defined(__APPLE__) && !defined(Q_OS_IOS) @@ -135,6 +138,7 @@ void run_ui() qml_window->show(); LOG_STP("run_ui running exec"); #else + register_qml_types(NULL); MainWindow::instance()->show(); #endif // SUBSURFACE_MOBILE qApp->exec(); @@ -152,16 +156,14 @@ static void register_meta_types() if (rc < 0) \ qWarning() << "ERROR: Cannot register " << useQML << ", QML will not work!!"; -void register_qml_types() +void register_qml_types(QQmlEngine *engine) { - int rc; - - (void)rc; - // register qPref* - qPref::instance()->registerQML(); + qPref::instance()->registerQML(engine); #ifndef SUBSURFACE_TEST_DATA + int rc; + #ifdef SUBSURFACE_MOBILE REGISTER_TYPE(QMLManager, "QMLManager"); REGISTER_TYPE(QMLPrefs, "QMLPrefs"); |