diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df98789bd..20813f6d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -174,6 +174,10 @@ add_library(neochat STATIC sharehandler.h ) +set_source_files_properties(qml/OsmLocationPlugin.qml PROPERTIES + QT_QML_SINGLETON_TYPE TRUE +) + qt_add_qml_module(neochat URI org.kde.neochat NO_PLUGIN OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat QML_FILES diff --git a/src/qml/FullScreenMap.qml b/src/qml/FullScreenMap.qml index c89911b40..9bb4e2c4b 100644 --- a/src/qml/FullScreenMap.qml +++ b/src/qml/FullScreenMap.qml @@ -47,10 +47,12 @@ ApplicationWindow { isLive: true heading: NaN visible: !isNaN(root.latitude) && !isNaN(root.longitude) + Component.onCompleted: mapView.map.addMapItem(this) } MapItemView { model: root.liveLocationModel delegate: LocationMapItem {} + Component.onCompleted: mapView.map.addMapItemView(this) } Connections { diff --git a/src/qml/LocationChooser.qml b/src/qml/LocationChooser.qml index 5804132d5..c5faf8e21 100644 --- a/src/qml/LocationChooser.qml +++ b/src/qml/LocationChooser.qml @@ -35,52 +35,25 @@ Components.AbstractMaximizeComponent { content: MapView { id: mapView - map.plugin: Plugin { - name: "osm" - PluginParameter { - name: "osm.useragent" - value: Application.name + "/" + Application.version + " (kde-devel@kde.org)" - } - PluginParameter { - name: "osm.mapping.providersrepository.address" - value: "https://autoconfig.kde.org/qtlocation/" - } - } + map.plugin: OsmLocationPlugin.plugin MouseArea { anchors.fill: parent onClicked: { root.location = mapView.map.toCoordinate(Qt.point(mouseX, mouseY), false); + mapView.map.addMapItem(mapView.locationMapItem); } } - MapQuickItem { - id: point - - visible: root.location - anchorPoint.x: sourceItem.width / 2 - anchorPoint.y: sourceItem.height * 0.85 - coordinate: root.location - autoFadeIn: false - - sourceItem: Kirigami.Icon { - width: height - height: Kirigami.Units.iconSizes.huge - source: "gps" - isMask: true - color: Kirigami.Theme.highlightColor - - Kirigami.Icon { - anchors.centerIn: parent - anchors.verticalCenterOffset: -parent.height / 8 - width: height - height: parent.height / 3 + 1 - source: "pin" - isMask: true - color: Kirigami.Theme.highlightColor - } - } + readonly property LocationMapItem locationMapItem: LocationMapItem { + latitude: root.location.latitude + longitude: root.location.longitude + isLive: false + heading: NaN + asset: null + author: null } + Connections { target: mapView.map function onCopyrightLinkActivated() { diff --git a/src/qml/LocationsPage.qml b/src/qml/LocationsPage.qml index 2ec892bf4..d0386e9f6 100644 --- a/src/qml/LocationsPage.qml +++ b/src/qml/LocationsPage.qml @@ -29,17 +29,22 @@ Kirigami.Page { map.zoomLevel: LocationHelper.zoomToFit(LocationHelper.unite(locationsModel.boundingBox, liveLocationsModel.boundingBox), mapView.width, mapView.height) MapItemView { + Component.onCompleted: mapView.map.addMapItemView(this) + anchors.fill: parent + model: LocationsModel { id: locationsModel room: root.room } delegate: LocationMapItem { - isLive: true + isLive: false heading: NaN } } MapItemView { + Component.onCompleted: mapView.map.addMapItemView(this) + anchors.fill: parent model: LiveLocationsModel { id: liveLocationsModel room: root.room @@ -49,7 +54,7 @@ Kirigami.Page { Kirigami.PlaceholderMessage { text: i18n("There are no locations shared in this room.") - visible: mapView.mapItems.length === 0 + visible: mapView.map.mapItems.length === 0 anchors.centerIn: parent } Connections { diff --git a/src/qml/OsmLocationPlugin.qml b/src/qml/OsmLocationPlugin.qml index 3073bc327..5b0824047 100644 --- a/src/qml/OsmLocationPlugin.qml +++ b/src/qml/OsmLocationPlugin.qml @@ -7,11 +7,14 @@ import QtQuick import QtLocation QtObject { + id: root + + property string userAgent: Application.name + "/" + Application.version + " (kde-devel@kde.org)" property var plugin: Plugin { name: "osm" PluginParameter { name: "osm.useragent" - value: Application.name + "/" + Application.version + " (kde-devel@kde.org)" + value: root.userAgent } PluginParameter { name: "osm.mapping.providersrepository.address" diff --git a/src/timeline/LocationComponent.qml b/src/timeline/LocationComponent.qml index ec1ef1e5a..d97f03965 100644 --- a/src/timeline/LocationComponent.qml +++ b/src/timeline/LocationComponent.qml @@ -76,7 +76,7 @@ ColumnLayout { map.plugin: OsmLocationPlugin.plugin - LocationMapItem { + readonly property LocationMapItem locationMapItem: LocationMapItem { latitude: root.latitude longitude: root.longitude asset: root.asset @@ -85,6 +85,8 @@ ColumnLayout { heading: NaN } + Component.onCompleted: map.addMapItem(locationMapItem) + TapHandler { acceptedButtons: Qt.LeftButton onTapped: {