Create the OSM QtLocation plugin only once

Just loading that plugin already triggers an HTTP request, so lets only
do that when really needed and even more importantly, not for every single
location delegate again.
This commit is contained in:
Volker Krause
2023-06-08 18:14:07 +02:00
parent 105be518c7
commit 7c75a2fd06
4 changed files with 24 additions and 11 deletions

View File

@@ -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<Emoji>();

View File

@@ -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)

View File

@@ -0,0 +1,21 @@
// SPDX-FileCopyrightText: 2021 Tobias Fella <fella@posteo.de>
// 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/"
}
}
}

View File

@@ -126,5 +126,6 @@
<file alias="InvitationView.qml">qml/Component/InvitationView.qml</file>
<file alias="AvatarTabButton.qml">qml/Component/AvatarTabButton.qml</file>
<file alias="SpaceDrawer.qml">qml/Page/RoomList/SpaceDrawer.qml</file>
<file alias="OsmLocationPlugin.qml">qml/Component/Timeline/OsmLocationPlugin.qml</file>
</qresource>
</RCC>