summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorShyamnath Premnadh <Shyamnath.Premnadh@qt.io>2023-05-12 16:48:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-06-15 11:23:57 +0000
commit6b59ecb11918154ff187f49c8884cd924e04d3cf (patch)
tree92a11f5ed6314cd695e680fb4c6ccbc171d842d0 /examples
parent5afecaa68ec575cfd9c0415169ba43d79dd88fad (diff)
mapviewer example: QML revamp
- replace load() with loadFromModule() - rename mapviewer.qml to Main.qml - update Main.qml to use the new MapViewer module Task-number: QTBUG-60643 Change-Id: I8be536badcb40008149d70db345370c47ef299e5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit c252ae7abf81a07649c05cafc76324179ea8a18e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/location/mapviewer/CMakeLists.txt89
-rw-r--r--examples/location/mapviewer/Main.qml (renamed from examples/location/mapviewer/mapviewer.qml)4
-rw-r--r--examples/location/mapviewer/main.cpp5
-rw-r--r--examples/location/mapviewer/mapviewer.pro19
-rw-r--r--examples/location/mapviewer/mapviewer.qrc33
-rw-r--r--examples/location/mapviewer/qmldir27
6 files changed, 81 insertions, 96 deletions
diff --git a/examples/location/mapviewer/CMakeLists.txt b/examples/location/mapviewer/CMakeLists.txt
index e7cea469..92f1615d 100644
--- a/examples/location/mapviewer/CMakeLists.txt
+++ b/examples/location/mapviewer/CMakeLists.txt
@@ -5,27 +5,20 @@ project(qml_location_mapviewer LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/location/mapviewer")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Qml)
-find_package(Qt6 COMPONENTS Network)
-find_package(Qt6 COMPONENTS Quick)
-find_package(Qt6 COMPONENTS Positioning)
-find_package(Qt6 COMPONENTS Location)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Network Quick Positioning Location)
+
+qt_standard_project_setup(REQUIRES 6.5)
qt_add_executable(qml_location_mapviewer WIN32 MACOSX_BUNDLE
main.cpp
)
+
target_link_libraries(qml_location_mapviewer PUBLIC
Qt::Core
Qt::Gui
@@ -36,45 +29,41 @@ target_link_libraries(qml_location_mapviewer PUBLIC
Qt::Quick
)
-# Resources:
-set(mapviewer_resource_files
- "forms/Geocode.qml"
- "forms/GeocodeForm.ui.qml"
- "forms/Locale.qml"
- "forms/LocaleForm.ui.qml"
- "forms/Message.qml"
- "forms/MessageForm.ui.qml"
- "forms/ReverseGeocode.qml"
- "forms/ReverseGeocodeForm.ui.qml"
- "forms/RouteAddress.qml"
- "forms/RouteAddressForm.ui.qml"
- "forms/RouteCoordinate.qml"
- "forms/RouteCoordinateForm.ui.qml"
- "forms/RouteList.qml"
- "forms/RouteListDelegate.qml"
- "forms/RouteListHeader.qml"
- "helper.js"
- "map/MapComponent.qml"
- "map/MapSliders.qml"
- "map/Marker.qml"
- "map/MiniMap.qml"
- "mapviewer.qml"
- "menus/ItemPopupMenu.qml"
- "menus/MainMenu.qml"
- "menus/MapPopupMenu.qml"
- "menus/MarkerPopupMenu.qml"
- "resources/marker.png"
- "resources/marker_blue.png"
- "resources/scale.png"
- "resources/scale_end.png"
-)
-
-qt6_add_resources(qml_location_mapviewer "mapviewer"
- PREFIX
- "/"
- FILES
- ${mapviewer_resource_files}
-)
+qt_add_qml_module(qml_location_mapviewer
+ URI MapViewer
+ VERSION 1.0
+ QML_FILES
+ "forms/Geocode.qml"
+ "forms/GeocodeForm.ui.qml"
+ "forms/Locale.qml"
+ "forms/LocaleForm.ui.qml"
+ "forms/Message.qml"
+ "forms/MessageForm.ui.qml"
+ "forms/ReverseGeocode.qml"
+ "forms/ReverseGeocodeForm.ui.qml"
+ "forms/RouteAddress.qml"
+ "forms/RouteAddressForm.ui.qml"
+ "forms/RouteCoordinate.qml"
+ "forms/RouteCoordinateForm.ui.qml"
+ "forms/RouteList.qml"
+ "forms/RouteListDelegate.qml"
+ "forms/RouteListHeader.qml"
+ "helper.js"
+ "map/MapComponent.qml"
+ "map/MapSliders.qml"
+ "map/Marker.qml"
+ "map/MiniMap.qml"
+ "Main.qml"
+ "menus/ItemPopupMenu.qml"
+ "menus/MainMenu.qml"
+ "menus/MapPopupMenu.qml"
+ "menus/MarkerPopupMenu.qml"
+ RESOURCES
+ "resources/marker.png"
+ "resources/marker_blue.png"
+ "resources/scale.png"
+ "resources/scale_end.png"
+ )
if(QT_FEATURE_geoservices_maplibregl)
target_link_libraries(qml_location_mapviewer PUBLIC
diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/Main.qml
index 4e93d9e4..65bfa6d6 100644
--- a/examples/location/mapviewer/mapviewer.qml
+++ b/examples/location/mapviewer/Main.qml
@@ -5,9 +5,7 @@ import QtQuick
import QtQuick.Controls
import QtLocation
import QtPositioning
-import "map"
-import "menus"
-import "helper.js" as Helper
+import MapViewer
ApplicationWindow {
id: appWindow
diff --git a/examples/location/mapviewer/main.cpp b/examples/location/mapviewer/main.cpp
index 8cb804b7..cf660c11 100644
--- a/examples/location/mapviewer/main.cpp
+++ b/examples/location/mapviewer/main.cpp
@@ -71,10 +71,7 @@ int main(int argc, char *argv[])
#else
engine.rootContext()->setContextProperty("supportsSsl", false);
#endif
- engine.addImportPath(u":/imports"_s);
- engine.load(QUrl(u"qrc:///mapviewer.qml"_s));
- QObject::connect(&engine, &QQmlApplicationEngine::quit,
- qApp, QCoreApplication::quit);
+ engine.loadFromModule("MapViewer", "Main");
auto *item = engine.rootObjects().value(0);
if (item == nullptr)
diff --git a/examples/location/mapviewer/mapviewer.pro b/examples/location/mapviewer/mapviewer.pro
index 4118aa87..9a680ac6 100644
--- a/examples/location/mapviewer/mapviewer.pro
+++ b/examples/location/mapviewer/mapviewer.pro
@@ -7,10 +7,9 @@ SOURCES += main.cpp
# Workaround for QTBUG-38735
QT_FOR_CONFIG += location-private
-RESOURCES += \
- mapviewer.qrc
-
-OTHER_FILES +=mapviewer.qml \
+qml_resources.files = \
+ qmldir \
+ Main.qml \
helper.js \
map/MapComponent.qml \
map/MapSliders.qml \
@@ -19,7 +18,7 @@ OTHER_FILES +=mapviewer.qml \
menus/ItemPopupMenu.qml \
menus/MainMenu.qml \
menus/MapPopupMenu.qml \
- menus/MarkerPopupMenu \
+ menus/MarkerPopupMenu.qml \
forms/Geocode.qml \
forms/GeocodeForm.ui.qml\
forms/Message.qml \
@@ -34,7 +33,15 @@ OTHER_FILES +=mapviewer.qml \
forms/RouteCoordinateForm.ui.qml \
forms/RouteList.qml \
forms/RouteListDelegate.qml \
- forms/RouteListHeader.qml
+ forms/RouteListHeader.qml \
+ resources/marker.png \
+ resources/marker_blue.png \
+ resources/scale.png \
+ resources/scale_end.png
+
+qml_resources.prefix = /qt/qml/MapViewer
+
+RESOURCES = qml_resources
target.path = $$[QT_INSTALL_EXAMPLES]/location/mapviewer
INSTALLS += target
diff --git a/examples/location/mapviewer/mapviewer.qrc b/examples/location/mapviewer/mapviewer.qrc
deleted file mode 100644
index 42c0d5b3..00000000
--- a/examples/location/mapviewer/mapviewer.qrc
+++ /dev/null
@@ -1,33 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>mapviewer.qml</file>
- <file>map/MapComponent.qml</file>
- <file>map/MapSliders.qml</file>
- <file>map/Marker.qml</file>
- <file>map/MiniMap.qml</file>
- <file>forms/Message.qml</file>
- <file>forms/MessageForm.ui.qml</file>
- <file>forms/Geocode.qml</file>
- <file>forms/GeocodeForm.ui.qml</file>
- <file>forms/ReverseGeocode.qml</file>
- <file>forms/ReverseGeocodeForm.ui.qml</file>
- <file>forms/RouteCoordinate.qml</file>
- <file>forms/RouteCoordinateForm.ui.qml</file>
- <file>forms/RouteAddress.qml</file>
- <file>forms/RouteAddressForm.ui.qml</file>
- <file>forms/Locale.qml</file>
- <file>forms/LocaleForm.ui.qml</file>
- <file>forms/RouteList.qml</file>
- <file>forms/RouteListDelegate.qml</file>
- <file>forms/RouteListHeader.qml</file>
- <file>menus/MainMenu.qml</file>
- <file>menus/MapPopupMenu.qml</file>
- <file>menus/MarkerPopupMenu.qml</file>
- <file>menus/ItemPopupMenu.qml</file>
- <file>helper.js</file>
- <file>resources/scale_end.png</file>
- <file>resources/scale.png</file>
- <file>resources/marker.png</file>
- <file>resources/marker_blue.png</file>
- </qresource>
-</RCC>
diff --git a/examples/location/mapviewer/qmldir b/examples/location/mapviewer/qmldir
new file mode 100644
index 00000000..e6cddbe6
--- /dev/null
+++ b/examples/location/mapviewer/qmldir
@@ -0,0 +1,27 @@
+module MapViewer
+prefer :/qt/qml/MapViewer/
+Main 1.0 Main.qml
+Helper 1.0 helper.js
+MapComponent 1.0 map/MapComponent.qml
+MapSliders 1.0 map/MapSliders.qml
+Marker 1.0 map/Marker.qml
+MiniMap 1.0 map/MiniMap.qml
+ItemPopupMenu 1.0 menus/ItemPopupMenu.qml
+MainMenu 1.0 menus/MainMenu.qml
+MapPopupMenu 1.0 menus/MapPopupMenu.qml
+MarkerPopupMenu 1.0 menus/MarkerPopupMenu.qml
+Geocode 1.0 forms/Geocode.qml
+GeocodeForm 1.0 forms/GeocodeForm.ui.qml
+Message 1.0 forms/Message.qml
+MessageForm 1.0 forms/MessageForm.ui.qml
+ReverseGeocode 1.0 forms/ReverseGeocode.qml
+ReverseGeocodeForm 1.0 forms/ReverseGeocodeForm.ui.qml
+RouteCoordinate 1.0 forms/RouteCoordinate.qml
+Locale 1.0 forms/Locale.qml
+LocaleForm 1.0 forms/LocaleForm.ui.qml
+RouteAddress 1.0 forms/RouteAddress.qml
+RouteAddressForm 1.0 forms/RouteAddressForm.ui.qml
+RouteCoordinateForm 1.0 forms/RouteCoordinateForm.ui.qml
+RouteList 1.0 forms/RouteList.qml
+RouteListDelegate 1.0 forms/RouteListDelegate.qml
+RouteListHeader 1.0 forms/RouteListHeader.qml