Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MapLibre QML module namespace independent of QtLocation #130

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/quick/main.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: MIT

Expand All @@ -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
4 changes: 2 additions & 2 deletions src/location/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ 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)

get_target_property(_targetTypeCore QMapLibre::Core TYPE)
if(_targetTypeCore STREQUAL STATIC_LIBRARY)
Expand All @@ -46,7 +46,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()
10 changes: 5 additions & 5 deletions src/location/plugins/legacy/qml_module.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

#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
20 changes: 10 additions & 10 deletions src/location/plugins/legacy/qml_registration.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

Expand All @@ -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/
5 changes: 3 additions & 2 deletions test/qml/qt5/tst_map.qml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

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
9 changes: 5 additions & 4 deletions test/qml/qt5/tst_style_parameters.qml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

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
5 changes: 3 additions & 2 deletions test/qml/qt6/tst_map.qml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

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
9 changes: 5 additions & 4 deletions test/qml/qt6/tst_style_parameters.qml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright (C) 2023 MapLibre contributors
// Copyright (C) 2024 MapLibre contributors

louwers marked this conversation as resolved.
Show resolved Hide resolved
// SPDX-License-Identifier: BSD-2-Clause

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
Loading