From 1da4f91cc88000a4d4922b345264a3ef9752ed8a Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Sat, 12 Aug 2017 03:58:26 +0300 Subject: 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 --- mobile-widgets/qml/MapWidget.qml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 27df978ba..7109b9dc3 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -5,17 +5,9 @@ import QtPositioning 5.3 import org.subsurfacedivelog.mobile 1.0 Item { + id: rootItem property int nSelectedDives: 0 - Plugin { - id: mapPlugin - name: "googlemaps" - Component.onCompleted: { - if (availableServiceProviders.indexOf(name) === -1) - console.warn("MapWidget.qml: cannot find a plugin with the name '" + name + "'") - } - } - MapWidgetHelper { id: mapHelper map: map @@ -23,15 +15,19 @@ Item { onSelectedDivesChanged: nSelectedDives = list.length onEditModeChanged: editMessage.isVisible = editMode === true ? 1 : 0 onCoordinatesChanged: {} + Component.onCompleted: { + map.plugin = Qt.createQmlObject(pluginObject, rootItem) + map.mapType = { "STREET": map.supportedMapTypes[0], "SATELLITE": map.supportedMapTypes[1] } + map.activeMapType = map.mapType.SATELLITE + } } Map { id: map anchors.fill: parent - plugin: mapPlugin zoomLevel: 1 - readonly property var mapType: { "STREET": supportedMapTypes[0], "SATELLITE": supportedMapTypes[1] } + property var mapType readonly property var defaultCenter: QtPositioning.coordinate(0, 0) readonly property real defaultZoomIn: 12.0 readonly property real defaultZoomOut: 1.0 @@ -42,7 +38,6 @@ Item { property real newZoomOut: 1.0 property var clickCoord: QtPositioning.coordinate(0, 0) - Component.onCompleted: activeMapType = mapType.SATELLITE onZoomLevelChanged: mapHelper.calculateSmallCircleRadius(map.center) MapItemView { -- cgit v1.2.3-70-g09d2