Skip to content

Commit

Permalink
Make MapLibre QML module namespace independent of QtLocation (maplibr…
Browse files Browse the repository at this point in the history
…e#130)

* Make MapLibre QML module namespace independent of QtLocation

* Revert copyright year change

* fix

---------

Co-authored-by: Bart Louwers <[email protected]>
  • Loading branch information
ntadej and louwers authored May 5, 2024
1 parent 3abb20c commit 01c8ca5
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 50 deletions.
2 changes: 1 addition & 1 deletion examples/quick/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import QtQuick.Window 6.5
import QtLocation 6.5
import QtPositioning 6.5

import QtLocation.MapLibre 3.0
import MapLibre 3.0

Window {
id: window
Expand Down
7 changes: 5 additions & 2 deletions src/location/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ function(qmaplibre_location_setup_plugins target)
get_target_property(_ImportedLocationQml QMapLibre::PluginQml IMPORTED_LOCATION_${_Configuration})
get_filename_component(_ImportedLocationPathQml ${_ImportedLocationQml} DIRECTORY)
get_filename_component(_ImportedLocationPathQml ${_ImportedLocationPathQml} DIRECTORY)
get_filename_component(_ImportedLocationPathQml ${_ImportedLocationPathQml} DIRECTORY)

get_property(_targetName TARGET ${target} PROPERTY OUTPUT_NAME)
if(NOT _targetName)
set(_targetName ${target})
endif()
get_property(_targetDestination TARGET ${target} PROPERTY RUNTIME_OUTPUT_DIRECTORY)
if(_targetDestination)
set(_targetDestination "${_targetDestination}/")
endif()

get_target_property(_targetTypeCore QMapLibre::Core TYPE)
if(_targetTypeCore STREQUAL STATIC_LIBRARY)
Expand All @@ -46,7 +49,7 @@ function(qmaplibre_location_setup_plugins target)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
file(
COPY "${_ImportedLocationGeoServices}"
DESTINATION "${_targetName}.app/Contents/PlugIns/geoservices"
DESTINATION "${_targetDestination}${_targetName}.app/Contents/PlugIns/geoservices"
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
install(
Expand Down
40 changes: 20 additions & 20 deletions src/location/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,41 @@ if(COMMAND qt_add_qml_module)
qt_add_qml_module(
${MLN_QT_QML_PLUGIN}
STATIC
URI QtLocation.MapLibre
URI MapLibre
VERSION ${PROJECT_VERSION}
PLUGIN_TARGET ${MLN_QT_QML_PLUGIN}
NO_PLUGIN_OPTIONAL
NO_GENERATE_QMLDIR
CLASS_NAME QtLocationMapLibreQmlModule
CLASS_NAME MapLibreQmlModule
RESOURCE_PREFIX "/"
OUTPUT_DIRECTORY "QtLocation/MapLibre"
OUTPUT_DIRECTORY "MapLibre"
OUTPUT_TARGETS QmlPluginOutputTargets
SOURCES ${Plugin_Sources}
)
else()
qt_add_qml_module(
${MLN_QT_QML_PLUGIN}
URI QtLocation.MapLibre
URI MapLibre
VERSION ${PROJECT_VERSION}
PLUGIN_TARGET ${MLN_QT_QML_PLUGIN}
NO_PLUGIN_OPTIONAL
NO_GENERATE_QMLDIR
CLASS_NAME QtLocationMapLibreQmlModule
CLASS_NAME MapLibreQmlModule
RESOURCE_PREFIX "/"
OUTPUT_DIRECTORY "QtLocation/MapLibre"
OUTPUT_DIRECTORY "MapLibre"
OUTPUT_TARGETS QmlPluginOutputTargets
SOURCES ${Plugin_Sources}
)
endif()
set_target_properties(
${MLN_QT_QML_PLUGIN}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre>
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre>
LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/MapLibre>
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/MapLibre>
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/qmldir.in"
"${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir"
"${CMAKE_CURRENT_BINARY_DIR}/MapLibre/qmldir"
@ONLY
)
else()
Expand Down Expand Up @@ -168,12 +168,12 @@ else()
${MLN_QT_QML_PLUGIN}
PROPERTIES
AUTOMOC ON
LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre>
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre>
LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/MapLibre>
RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/MapLibre>
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/legacy/qmldir.in"
"${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir"
"${CMAKE_CURRENT_BINARY_DIR}/MapLibre/qmldir"
@ONLY
)
endif()
Expand Down Expand Up @@ -212,21 +212,21 @@ install(
install(
TARGETS ${MLN_QT_QML_PLUGIN} ${QmlPluginOutputTargets}
EXPORT ${MLN_QT_NAME}LocationPluginQmlTargets
ARCHIVE DESTINATION "qml/QtLocation/MapLibre"
LIBRARY DESTINATION "qml/QtLocation/MapLibre"
OBJECTS DESTINATION "qml/QtLocation/MapLibre"
RUNTIME DESTINATION "qml/QtLocation/MapLibre"
ARCHIVE DESTINATION "qml/MapLibre"
LIBRARY DESTINATION "qml/MapLibre"
OBJECTS DESTINATION "qml/MapLibre"
RUNTIME DESTINATION "qml/MapLibre"
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/qmldir"
DESTINATION "qml/QtLocation/MapLibre"
"${CMAKE_CURRENT_BINARY_DIR}/MapLibre/qmldir"
DESTINATION "qml/MapLibre"
)

if(COMMAND qt_add_qml_module)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/QtLocation/MapLibre/${MLN_QT_QML_PLUGIN}.qmltypes"
DESTINATION "qml/QtLocation/MapLibre"
"${CMAKE_CURRENT_BINARY_DIR}/MapLibre/${MLN_QT_QML_PLUGIN}.qmltypes"
DESTINATION "qml/MapLibre"
)
endif()
8 changes: 4 additions & 4 deletions src/location/plugins/legacy/qml_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

#include <QtQml/qqmlextensionplugin.h>

extern void qml_register_types_QtLocation_MapLibre();
extern void qml_register_types_MapLibre();

class QtLocationMapLibreQmlModule : public QQmlEngineExtensionPlugin {
class MapLibreQmlModule : public QQmlEngineExtensionPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)

public:
QtLocationMapLibreQmlModule(QObject *parent = nullptr)
MapLibreQmlModule(QObject *parent = nullptr)
: QQmlEngineExtensionPlugin(parent) {
volatile auto registration = &qml_register_types_QtLocation_MapLibre;
volatile auto registration = &qml_register_types_MapLibre;
Q_UNUSED(registration)
}
};
Expand Down
18 changes: 9 additions & 9 deletions src/location/plugins/legacy/qml_registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#else
#define Q_QMLTYPE_EXPORT
#endif
Q_QMLTYPE_EXPORT void qml_register_types_QtLocation_MapLibre() {
qmlRegisterTypesAndRevisions<MapLibreStyleAttached>("QtLocation.MapLibre", 3);
qmlRegisterTypesAndRevisions<MapLibreStyleProperties>("QtLocation.MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeLayerParameter>("QtLocation.MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeSourceParameter>("QtLocation.MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeStyle>("QtLocation.MapLibre", 3);
qmlRegisterAnonymousType<QQuickItem>("QtLocation.MapLibre", 3);
qmlRegisterModule("QtLocation.MapLibre", 3, 0);
Q_QMLTYPE_EXPORT void qml_register_types_MapLibre() {
qmlRegisterTypesAndRevisions<MapLibreStyleAttached>("MapLibre", 3);
qmlRegisterTypesAndRevisions<MapLibreStyleProperties>("MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeLayerParameter>("MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeSourceParameter>("MapLibre", 3);
qmlRegisterTypesAndRevisions<QMapLibre::DeclarativeStyle>("MapLibre", 3);
qmlRegisterAnonymousType<QQuickItem>("MapLibre", 3);
qmlRegisterModule("MapLibre", 3, 0);
}

static const QQmlModuleRegistration registration("QtLocation.MapLibre", 3, qml_register_types_QtLocation_MapLibre);
static const QQmlModuleRegistration registration("MapLibre", 3, qml_register_types_MapLibre);
6 changes: 3 additions & 3 deletions src/location/plugins/legacy/qmldir.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module QtLocation.MapLibre
module MapLibre
linktarget @MLN_QT_QML_PLUGIN@
plugin @MLN_QT_QML_PLUGIN@
classname QtLocationMapLibreQmlModule
prefer :/QtLocation/MapLibre/
classname MapLibreQmlModule
prefer :/MapLibre/
6 changes: 3 additions & 3 deletions src/location/plugins/qmldir.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module QtLocation.MapLibre
module MapLibre
linktarget QMapLibre::PluginQml
plugin @MLN_QT_QML_PLUGIN@
classname QtLocationMapLibreQmlModule
classname MapLibreQmlModule
typeinfo @[email protected]
prefer :/QtLocation/MapLibre/
prefer :/MapLibre/
3 changes: 2 additions & 1 deletion test/qml/qt5/tst_map.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import QtQuick 2.15
import QtLocation 5.15
import QtLocation.MapLibre 3.0
import QtPositioning 5.15

import MapLibre 3.0

import QtTest 1.0

Rectangle {
Expand Down
7 changes: 4 additions & 3 deletions test/qml/qt5/tst_style_parameters.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import QtQuick 2.15
import QtLocation 5.15
import QtLocation.MapLibre 3.0
import QtPositioning 5.15

import MapLibre 3.0

import QtTest 1.0

Item {
Expand Down Expand Up @@ -119,7 +120,7 @@ Item {
let url = "https://s2maps-tiles.eu/wms?service=wms&bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:900913&width=256&height=256&layers=s2cloudless-2021_3857"

let sourceParam = Qt.createQmlObject(`
import QtLocation.MapLibre 3.0
import MapLibre 3.0
SourceParameter {
styleId: "tileSource"
Expand All @@ -134,7 +135,7 @@ Item {
style.addParameter(sourceParam)

let layerParam = Qt.createQmlObject(`
import QtLocation.MapLibre 3.0
import MapLibre 3.0
LayerParameter {
styleId: "tileLayer"
Expand Down
3 changes: 2 additions & 1 deletion test/qml/qt6/tst_map.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import QtQuick 2.15
import QtLocation 6.5
import QtLocation.MapLibre 3.0
import QtPositioning 5.15

import MapLibre 3.0

import QtTest 1.0

Item {
Expand Down
7 changes: 4 additions & 3 deletions test/qml/qt6/tst_style_parameters.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import QtQuick 2.15
import QtLocation 6.5
import QtLocation.MapLibre 3.0
import QtPositioning 6.5

import MapLibre 3.0

import QtTest 1.0

Item {
Expand Down Expand Up @@ -119,7 +120,7 @@ Item {
let url = "https://s2maps-tiles.eu/wms?service=wms&bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:900913&width=256&height=256&layers=s2cloudless-2021_3857"

let sourceParam = Qt.createQmlObject(`
import QtLocation.MapLibre 3.0
import MapLibre 3.0
SourceParameter {
styleId: "tileSource"
Expand All @@ -134,7 +135,7 @@ Item {
style.addParameter(sourceParam)

let layerParam = Qt.createQmlObject(`
import QtLocation.MapLibre 3.0
import MapLibre 3.0
LayerParameter {
styleId: "tileLayer"
Expand Down

0 comments on commit 01c8ca5

Please sign in to comment.