diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | core/qt-gui.h | 1 | ||||
-rw-r--r-- | subsurface-helper.cpp | 57 | ||||
-rw-r--r-- | subsurface-mobile-helper.cpp | 39 |
4 files changed, 61 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 034c89c17..87c9db4e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -291,6 +291,7 @@ if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "MobileExecutable") mobile-widgets/qml/kirigami/src/libkirigami/tabletmodewatcher.cpp subsurface-mobile-main.cpp subsurface-mobile-helper.cpp + subsurface-helper.cpp profile-widget/qmlprofile.cpp map-widget/qmlmapwidgethelper.cpp ) @@ -315,6 +316,7 @@ elseif(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable") set(SUBSURFACE_APP subsurface-desktop-main.cpp subsurface-desktop-helper.cpp + subsurface-helper.cpp ) source_group("Subsurface App" FILES ${SUBSURFACE_APP}) if(ANDROID) diff --git a/core/qt-gui.h b/core/qt-gui.h index 9bfe0e001..a1e608122 100644 --- a/core/qt-gui.h +++ b/core/qt-gui.h @@ -6,6 +6,7 @@ void init_qt_late(); void init_ui(); void run_ui(); +void register_qml_types(); void exit_ui(); void set_non_bt_addresses(); diff --git a/subsurface-helper.cpp b/subsurface-helper.cpp new file mode 100644 index 000000000..161cdff76 --- /dev/null +++ b/subsurface-helper.cpp @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <QQmlEngine> +#include <QDebug> +#include <QQuickItem> + +#include "core/qt-gui.h" +#include "core/settings/qPref.h" +#ifdef SUBSURFACE_MOBILE +#include "mobile-widgets/qmlmanager.h" +#include "mobile-widgets/qmlprefs.h" +#include "qt-models/divelistmodel.h" +#include "qt-models/gpslistmodel.h" +#include "profile-widget/qmlprofile.h" +#include "core/downloadfromdcthread.h" +#include "qt-models/diveimportedmodel.h" +#include "map-widget/qmlmapwidgethelper.h" +#include "qt-models/maplocationmodel.h" +#endif + +void register_qml_types() +{ + int rc; + rc = qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs"); + if (rc < 0) + qDebug() << "ERROR: Cannot register Prefs (class qPref), QML will not work!!"; + rc = qmlRegisterType<qPrefDisplay>("org.subsurfacedivelog.mobile", 1, 0, "SsrfDisplayPrefs"); + if (rc < 0) + qDebug() << "ERROR: Cannot register DisplayPrefs (class qPrefDisplay), QML will not work!!"; + +#ifdef SUBSURFACE_MOBILE + rc = qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); + if (rc < 0) + qDebug() << "ERROR: Cannot register QMLManager, QML will not work!!"; + rc = qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs"); + if (rc < 0) + qDebug() << "ERROR: Cannot register QMLPrefs, QML will not work!!"; + rc = qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile"); + if (rc < 0) + qDebug() << "ERROR: Cannot register QMLProfile, QML will not work!!"; + rc = qmlRegisterType<DownloadThread>("org.subsurfacedivelog.mobile", 1, 0, "DCDownloadThread"); + if (rc < 0) + qDebug() << "ERROR: Cannot register DCDownloadThread, QML will not work!!"; + rc = qmlRegisterType<DiveImportedModel>("org.subsurfacedivelog.mobile", 1, 0, "DCImportModel"); + if (rc < 0) + qDebug() << "ERROR: Cannot register DCImportModel, QML will not work!!"; + + rc = qmlRegisterType<MapWidgetHelper>("org.subsurfacedivelog.mobile", 1, 0, "MapWidgetHelper"); + if (rc < 0) + qDebug() << "ERROR: Cannot register MapWidgetHelper, QML will not work!!"; + rc = qmlRegisterType<MapLocationModel>("org.subsurfacedivelog.mobile", 1, 0, "MapLocationModel"); + if (rc < 0) + qDebug() << "ERROR: Cannot register MapLocationModel, QML will not work!!"; + rc = qmlRegisterType<MapLocation>("org.subsurfacedivelog.mobile", 1, 0, "MapLocation"); + if (rc < 0) + qDebug() << "ERROR: Cannot register MapLocation, QML will not work!!"; +#endif +} diff --git a/subsurface-mobile-helper.cpp b/subsurface-mobile-helper.cpp index 5d7fe6c35..fc0431ef9 100644 --- a/subsurface-mobile-helper.cpp +++ b/subsurface-mobile-helper.cpp @@ -17,16 +17,8 @@ #include <QQmlContext> #include <QSortFilterProxyModel> #include "mobile-widgets/qmlmanager.h" -#include "mobile-widgets/qmlprefs.h" -#include "qt-models/divelistmodel.h" #include "qt-models/gpslistmodel.h" -#include "profile-widget/qmlprofile.h" -#include "core/downloadfromdcthread.h" -#include "core/connectionlistmodel.h" -#include "qt-models/diveimportedmodel.h" #include "qt-models/messagehandlermodel.h" -#include "map-widget/qmlmapwidgethelper.h" -#include "qt-models/maplocationmodel.h" #include "core/settings/qPref.h" #include "mobile-widgets/qml/kirigami/src/kirigamiplugin.h" @@ -55,37 +47,8 @@ void init_ui() void run_ui() { - int rc; LOG_STP("run_ui starting"); - rc = qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs"); - if (rc < 0) - qDebug() << "ERROR: Cannot register Prefs (class qPref), QML will not work!!"; - rc = qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager"); - if (rc < 0) - qDebug() << "ERROR: Cannot register QMLManager, QML will not work!!"; - rc = qmlRegisterType<QMLPrefs>("org.subsurfacedivelog.mobile", 1, 0, "QMLPrefs"); - if (rc < 0) - qDebug() << "ERROR: Cannot register QMLPrefs, QML will not work!!"; - rc = qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile"); - if (rc < 0) - qDebug() << "ERROR: Cannot register QMLProfile, QML will not work!!"; - - rc = qmlRegisterType<DownloadThread>("org.subsurfacedivelog.mobile", 1, 0, "DCDownloadThread"); - if (rc < 0) - qDebug() << "ERROR: Cannot register DCDownloadThread, QML will not work!!"; - rc = qmlRegisterType<DiveImportedModel>("org.subsurfacedivelog.mobile", 1, 0, "DCImportModel"); - if (rc < 0) - qDebug() << "ERROR: Cannot register DCImportModel, QML will not work!!"; - - rc = qmlRegisterType<MapWidgetHelper>("org.subsurfacedivelog.mobile", 1, 0, "MapWidgetHelper"); - if (rc < 0) - qDebug() << "ERROR: Cannot register MapWidgetHelper, QML will not work!!"; - rc = qmlRegisterType<MapLocationModel>("org.subsurfacedivelog.mobile", 1, 0, "MapLocationModel"); - if (rc < 0) - qDebug() << "ERROR: Cannot register MapLocationModel, QML will not work!!"; - rc = qmlRegisterType<MapLocation>("org.subsurfacedivelog.mobile", 1, 0, "MapLocation"); - if (rc < 0) - qDebug() << "ERROR: Cannot register MapLocation, QML will not work!!"; + register_qml_types(); QQmlApplicationEngine engine; LOG_STP("run_ui qml engine started"); |