diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-08-12 03:58:26 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-08-24 13:11:39 -0700 |
commit | 1da4f91cc88000a4d4922b345264a3ef9752ed8a (patch) | |
tree | 9453af90c85ec8caa08feab1fe1eda72249b4f6a /mobile-widgets/qmlmapwidgethelper.cpp | |
parent | fb151df883273bd01a1c56e30fe92575fa74fea1 (diff) | |
download | subsurface-1da4f91cc88000a4d4922b345264a3ef9752ed8a.tar.gz |
mapwidgethelper: use dynamic creation of the Plugin object
The googlemaps plugin is about to support tile language
via the PluginParameter 'googlemaps.maps.language'.
To be able to pass the subsurface UI language (obtained
from the uiLanguage() helper) the Plugin has to be created
dynamically, only *after* the MapWidgetHelper is created.
MapWidgetHelper::pluginObject() now provides a QString which
contains the Plugin object and also include the uiLanguage
ISO value.
This string is used in mapwidget.qml as:
map.plugin = Qt.createQmlObject(pluginObject, rootItem)
This creates the Plugin object dynamically with the proper
UI language string, but also requires a couple of small changes:
- move the declaration of map.mapType after the
Qt.createQmlObject() call
- assign map.activeMapType after map.mapType has a value
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qmlmapwidgethelper.cpp')
-rw-r--r-- | mobile-widgets/qmlmapwidgethelper.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp index 9cc452642..569bd9f68 100644 --- a/mobile-widgets/qmlmapwidgethelper.cpp +++ b/mobile-widgets/qmlmapwidgethelper.cpp @@ -8,6 +8,7 @@ #include "qmlmapwidgethelper.h" #include "core/dive.h" #include "core/divesite.h" +#include "core/helpers.h" #include "qt-models/maplocationmodel.h" #define MIN_DISTANCE_BETWEEN_DIVE_SITES_M 50.0 @@ -238,3 +239,23 @@ void MapWidgetHelper::setEditMode(bool editMode) } emit editModeChanged(); } + +QString MapWidgetHelper::pluginObject() +{ + QString str; + str += "import QtQuick 2.0;"; + str += "import QtLocation 5.3;"; + str += "Plugin {"; + str += " id: mapPlugin;"; + str += " name: 'googlemaps';"; + str += " PluginParameter { name: 'googlemaps.maps.language'; value: '%lang%' }"; + str += " Component.onCompleted: {"; + str += " if (availableServiceProviders.indexOf(name) === -1) {"; + str += " console.warn('MapWidget.qml: cannot find a plugin named: ' + name);"; + str += " }"; + str += " }"; + str += "}"; + QString lang = uiLanguage(NULL).replace('_', '-'); + str.replace("%lang%", lang); + return str; +} |