From ea961edec84bf31b2bb3de0f9c1901147be14991 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 8 Apr 2022 14:31:02 -1000 Subject: [PATCH] Qt6: first steps towards map support There is an initial build of the C++ classes that seems to work, but the QML integration is still missing. Still, progress is being made. Unfortunately with Qt6 we can't forward declare the MapLocationModel class (one of the operators needs to be able to determine the size of the class), so we need to include the header file. Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 20 ++++++++++++++++++++ map-widget/qmlmapwidgethelper.h | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03ee7fa61..65ad7e226 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,6 +192,26 @@ if(QT_VERSION_MAJOR STREQUAL "6") # QtWebKit doesn't work with Qt6, so no printing, no manual set(NO_PRINTING ON) set(NO_USERMANUAL ON) + + # as of Qt 6.3 by default QtLocation isn't included, but one can + # build the module from source; so let's look if the user has installed + # it (or if a newer version is out that includes it, anyway) + find_package(Qt6 COMPONENTS Location) + if(Qt6Location_FOUND) + message(STATUS "Found Qt6Location") + LIST(APPEND QT_EXTRA_COMPONENTS Location) + add_definitions(-DMAP_SUPPORT) + set(MAPSUPPORT ON) + + # at least on macOS something goes sideways and we fail to load the + # QML files with a weird error about Qml.WorkerScript missing + # linking Subsurface against that component appears enough to hack + # around that, but that feels... wrong + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + find_package(Qt6 COMPONENTS QmlWorkerScript) + LIST(APPEND SUBSURFACE_LINK_LIBRARIES Qt6::QmlWorkerScript) + endif() + endif() else() # as mentioned above, since some variables appear to fail to populate # on some platforms, simply run this again the 'old' way diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index 2306ee9e8..e093ffa54 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -12,7 +12,7 @@ Q_IMPORT_PLUGIN(QGeoServiceProviderFactoryGooglemaps) #endif -class MapLocationModel; +#include "qt-models/maplocationmodel.h" class MapLocation; struct dive_site;