diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-03-30 21:48:29 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-03-30 13:54:12 -0700 |
commit | 53b216b228165db4a31d122f09e4d481d8ef321b (patch) | |
tree | 1b6a1bcfed7f6e57792121b613c7af337ce44521 | |
parent | 2db6b16a708a7dedaca15566f6e898a3ee2035f1 (diff) | |
download | subsurface-53b216b228165db4a31d122f09e4d481d8ef321b.tar.gz |
cleanup: move initialization of QMLInterface
QMLInterface was initialized in the register_qml_types function.
Therein, it was in an if branch that tested whether the passed-in
engine argument was not NULL. However, on mobile this could never
be NULL. Let's just move the initialization out of that function.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | subsurface-helper.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp index 96e984520..e87b30574 100644 --- a/subsurface-helper.cpp +++ b/subsurface-helper.cpp @@ -80,6 +80,10 @@ void run_ui() QScreen *appScreen = QApplication::screens().at(0); int availableScreenWidth = appScreen->availableSize().width(); QQmlApplicationEngine engine; + QQmlContext *ctxt = engine.rootContext(); + + // Register qml interface classes + QMLInterface::setup(ctxt); register_qml_types(&engine); KirigamiPlugin::getInstance().registerTypes(); #if defined(__APPLE__) && !defined(Q_OS_IOS) @@ -101,7 +105,6 @@ void run_ui() gpsSortModel->setDynamicSortFilter(true); gpsSortModel->setSortRole(GpsListModel::GpsWhenRole); gpsSortModel->sort(0, Qt::DescendingOrder); - QQmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("gpsModel", gpsSortModel); ctxt->setContextProperty("vendorList", vendorList); ctxt->setContextProperty("swipeModel", MobileModels::instance()->swipeModel()); @@ -195,13 +198,6 @@ void register_qml_types(QQmlEngine *engine) int rc; #ifdef SUBSURFACE_MOBILE - if (engine != NULL) { - QQmlContext *ct = engine->rootContext(); - - // Register qml interface classes - QMLInterface::setup(ct); - } - REGISTER_TYPE(QMLManager, "QMLManager"); REGISTER_TYPE(QMLProfile, "QMLProfile"); REGISTER_TYPE(DiveImportedModel, "DCImportModel"); |