diff --git a/src/main.cpp b/src/main.cpp index 243cad6a9..c95ffabb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -283,6 +283,7 @@ int main(int argc, char *argv[]) qmlRegisterSingletonType("org.kde.neochat", 1, 0, "About", [](QQmlEngine *engine, QJSEngine *) -> QJSValue { return engine->toScriptValue(KAboutData::applicationData()); }); + qmlRegisterSingletonType(QUrl("qrc:/OsmLocationPlugin.qml"), "org.kde.neochat", 1, 0, "OsmLocationPlugin"); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qRegisterMetaTypeStreamOperators(); diff --git a/src/qml/Component/Timeline/LocationDelegate.qml b/src/qml/Component/Timeline/LocationDelegate.qml index 1970d3b6f..b792ab902 100644 --- a/src/qml/Component/Timeline/LocationDelegate.qml +++ b/src/qml/Component/Timeline/LocationDelegate.qml @@ -47,18 +47,8 @@ TimelineContainer { center: QtPositioning.coordinate(root.latitude, root.longitude) zoomLevel: 15 - 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/" - } - } + plugin: OsmLocationPlugin.plugin onCopyrightLinkActivated: Qt.openUrlExternally(link) diff --git a/src/qml/Component/Timeline/OsmLocationPlugin.qml b/src/qml/Component/Timeline/OsmLocationPlugin.qml new file mode 100644 index 000000000..0b37a8fcf --- /dev/null +++ b/src/qml/Component/Timeline/OsmLocationPlugin.qml @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: 2021 Tobias Fella +// SPDX-License-Identifier: GPL-2.0-or-later + +pragma Singleton + +import QtQuick 2.15 +import QtLocation 5.15 + +QtObject { + property var 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/" + } + } +} diff --git a/src/res.qrc b/src/res.qrc index 95d291adb..578b30961 100644 --- a/src/res.qrc +++ b/src/res.qrc @@ -126,5 +126,6 @@ qml/Component/InvitationView.qml qml/Component/AvatarTabButton.qml qml/Page/RoomList/SpaceDrawer.qml + qml/Component/Timeline/OsmLocationPlugin.qml