diff options
author | Bramastyo Harimukti <bramastyo.harimukti.santoso@pelagicore.com> | 2018-06-08 15:44:37 +0200 |
---|---|---|
committer | Bramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com> | 2018-06-11 13:40:21 +0000 |
commit | a0a5c3c337c436e669c43b39cbb00643a65de72b (patch) | |
tree | 3a0247700b036aa3d27c33f3a521715d47db9ec1 | |
parent | ae14e9e7b16050ac3c8a6d6974f82c6770ca3654 (diff) |
[mapapp] update to not use install_prefix
- when neptune 3 is run without installing, map cache won't be found.
Hence, using the actual map source path is a better way to get the
map cache.
Change-Id: I5d7709fd0318b9912463c81190f37072e6bbadd3
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r-- | apps/com.pelagicore.map/Main.qml | 10 | ||||
-rw-r--r-- | plugins/com.pelagicore.map/com.pelagicore.map.pro | 2 | ||||
-rw-r--r-- | plugins/com.pelagicore.map/mapshelper.cpp | 21 | ||||
-rw-r--r-- | plugins/com.pelagicore.map/mapshelper.h | 16 |
4 files changed, 36 insertions, 13 deletions
diff --git a/apps/com.pelagicore.map/Main.qml b/apps/com.pelagicore.map/Main.qml index 7da77549..2237473d 100644 --- a/apps/com.pelagicore.map/Main.qml +++ b/apps/com.pelagicore.map/Main.qml @@ -43,7 +43,15 @@ import "helpers" QtObject { // used for copying the offline DB - readonly property var _mapsHelper: MapsHelper {} + readonly property var _mapsHelper: MapsHelper { + appPath: Qt.resolvedUrl("./") + + onAppPathChanged: { + if (appPath !== "") { + initMap(); + } + } + } property var mainWindow: PrimaryWindow { id: mainWindow diff --git a/plugins/com.pelagicore.map/com.pelagicore.map.pro b/plugins/com.pelagicore.map/com.pelagicore.map.pro index eaa34543..ad99c9e5 100644 --- a/plugins/com.pelagicore.map/com.pelagicore.map.pro +++ b/plugins/com.pelagicore.map/com.pelagicore.map.pro @@ -12,5 +12,3 @@ SOURCES += \ HEADERS += \ mapshelper.h \ - -DEFINES += "INSTALL_PATH=$$clean_path($$INSTALL_PREFIX/neptune3/)" diff --git a/plugins/com.pelagicore.map/mapshelper.cpp b/plugins/com.pelagicore.map/mapshelper.cpp index 3b2584f5..d5057700 100644 --- a/plugins/com.pelagicore.map/mapshelper.cpp +++ b/plugins/com.pelagicore.map/mapshelper.cpp @@ -43,11 +43,23 @@ MapsHelper::MapsHelper(QObject *parent) { } -void MapsHelper::classBegin() +void MapsHelper::setAppPath(const QString &appPath) +{ + if (m_appPath != appPath) { + m_appPath = appPath; + emit appPathChanged(); + } +} + +QString MapsHelper::appPath() const +{ + return m_appPath; +} + +void MapsHelper::initMap() { // copy mapboxgl offline DB - const QString prefix = STR(INSTALL_PATH) + QStringLiteral("apps/com.pelagicore.map/"); - const QString sourceFile = prefix + QStringLiteral("maps/mapboxgl.db"); + const QString sourceFile = m_appPath + QStringLiteral("maps/mapboxgl.db"); const QString destDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); const QString destFile = destDir + QStringLiteral("/mapboxgl.db"); QDir dir; @@ -56,6 +68,3 @@ void MapsHelper::classBegin() QFile::copy(sourceFile, destFile); } -void MapsHelper::componentComplete() -{ -} diff --git a/plugins/com.pelagicore.map/mapshelper.h b/plugins/com.pelagicore.map/mapshelper.h index 7c80759d..e58da57a 100644 --- a/plugins/com.pelagicore.map/mapshelper.h +++ b/plugins/com.pelagicore.map/mapshelper.h @@ -34,16 +34,24 @@ #include <QObject> #include <QQmlParserStatus> -class MapsHelper : public QObject, public QQmlParserStatus +class MapsHelper : public QObject { Q_OBJECT - Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(QString appPath READ appPath WRITE setAppPath NOTIFY appPathChanged) public: explicit MapsHelper(QObject *parent = nullptr); ~MapsHelper() = default; + void setAppPath(const QString &appPath); + QString appPath() const; + + Q_INVOKABLE void initMap(); + +signals: + void appPathChanged(); + protected: - void classBegin() override; - void componentComplete() override; + QString m_appPath; }; |