From 93cd4420fc5d84c983ce13826423ed71a505cadd Mon Sep 17 00:00:00 2001 From: Eduardo Paz Date: Wed, 27 Oct 2021 15:30:12 +0200 Subject: [PATCH] PS-1039 - Mapbox attribution displayed --- res/logo.png | Bin 0 -> 2749 bytes res/mapbox.qrc | 5 +++++ src/GeoTiledMappingManagerEngine.cpp | 25 ++++++++++++++++++++++++- src/GeoTiledMappingManagerEngine.h | 8 ++++++++ test_package/CMakeLists.txt | 4 +++- 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 res/logo.png create mode 100644 res/mapbox.qrc diff --git a/res/logo.png b/res/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..9d6e90ef57f3bc13c5ad6c75251f5acddc7985e1 GIT binary patch literal 2749 zcmV;u3PSaXP)t zK~z}7?O1zIRM#2*?Jm2xsH?kc6qIN{KqNtkiR*)iEgIrT*iJP8wko~=Uub5k)bx+0 zb*9O*w&SCUwIrrWePKx>F+_z3DTMgIAdf5{aF=D*y$e?tSRU?!d-wE@oV6=O>U5fp zGtD=12kyDwIo~mP`v5}FH>sXd8eH?JZpO%)E zzfGPzc@2QDrwqVwtya6Gx3~9ZZf@=`0le~E8Sr~ zusM&5*K(>Sc-IaL43tfnFd;ZFFmODzC8N5|QTFH?>z^1vF@V@}=gw({gXeO&`rmoy zoxFYf_OafvprD|S3kwSuFIu$dbpV((YgXKmBS#vuva;?0xJuRh0mK7P0N|;OF%+nF z0B!)`)cz2F761)&^HTuK0WitC4FC@SjHPRJ(F7*~FaTfz1)I=sw?{bVGytpU{|*36 z0PfIt8GvX2ApoRwY!E;*wHZQfbpyBsU_P};05D#j@tWfdf$hLW+xv6BvfsylK;>sJ6DYRENXy^LzL1ZGHFMcQpVK zeZYrYF841fDOu9p-MzEFzdz^t_3PTm$jF5N7EthBO-f37sj;!~jlsdeJp%&+ITaNZ z%Y%c1=K+YUtgL*^VzF$|YPGWfyq1xX5oNVnw_dz>F^)O`7UkvT?HwN9Zr;3kf(Bt7 z0G-8Rd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>I-(e-IA4+bt5w~b5eYK zd~!!eM{RU;bU{Z)$Asm}m#<1qO>HSCD2NpUxO?c(A)_D&PM@nG8@^e&T#lTaoM~-s zZE4xr*%@N7SmqNm?|tyW2OMoO001$Y&92VQ&L)OoZ1f6y7={_>?CfkZ8jTOU*IKXF zvkb#ja~vlCFfU%b`0|-EXYzTT7p7029^KZ~*1T)it^*9iR5vy@K2mq5r>F1ZIF6e> zefsR)-d^k8y?g(Vk&#gkpv`DBIvIwk-oJl;-la>IE~wS&Ah}#VuBxi4c)@}N?^~_b zRsbcZPoFkuwc6j_xpU`cP*70VxN+mu<>loU=gysblwlaRPN$pAFwD)2jEs*R4u|8d zx86E$Fc@mqu3Z}jAk-T}RumT(FI%xAf>FF7wXCMGr0JU_Em&m&)0aw!X1}KSc@hK*v0L-L&1Au<2696ET zuFp{-{W5^b)L#2Trmj#ZR$DBVD^FSndmp`CUqES!@;fLqAlD#xWsZ_3^hw-O} z98IK@IFBasC(!wqIuZaZeSLim@$vDe@7}#z|D=`shE<6V|z^-ibLo8cc%KyHf@?ZJ3Bi#K0ZEFrBY1 + + logo.png + + diff --git a/src/GeoTiledMappingManagerEngine.cpp b/src/GeoTiledMappingManagerEngine.cpp index 7a86db1..f773c95 100644 --- a/src/GeoTiledMappingManagerEngine.cpp +++ b/src/GeoTiledMappingManagerEngine.cpp @@ -168,10 +168,33 @@ GeoTiledMappingManagerEngine::GeoTiledMappingManagerEngine(const QVariantMap& pa QGeoMap* GeoTiledMappingManagerEngine::createMap() { - return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new QGeoTiledMap(this, 0); + return m_noMapTiles ? new NoGeoTiledMap(this, 0) : new CustomGeoTiledMap(this, 0); } QSGNode* NoGeoTiledMap::updateSceneGraph(QSGNode*, QQuickWindow*) { return nullptr; } + +CustomGeoTiledMap::CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent) : + QGeoTiledMap(engine, parent) { + setCopyrightVisible(true); +} + +QString CustomGeoTiledMap::copyrightsStyleSheet() const +{ + return QStringLiteral("* { vertical-align: middle; font-weight: normal }"); +} + +void CustomGeoTiledMap::evaluateCopyrights(const QSet &visibleTiles) { + Q_UNUSED(visibleTiles); + + QString copyrightsHtmlFinal("© Mapbox " + "© OpenStreetMap " + "Improve this map"); + + copyrightsHtmlFinal = "
" + + copyrightsHtmlFinal + "
"; + + emit copyrightsChanged(copyrightsHtmlFinal); +} diff --git a/src/GeoTiledMappingManagerEngine.h b/src/GeoTiledMappingManagerEngine.h index ef294c2..d2dc568 100644 --- a/src/GeoTiledMappingManagerEngine.h +++ b/src/GeoTiledMappingManagerEngine.h @@ -11,6 +11,14 @@ class NoGeoTiledMap : public QGeoTiledMap QSGNode* updateSceneGraph(QSGNode*, QQuickWindow* window) override; }; +class CustomGeoTiledMap: public QGeoTiledMap { +public: + CustomGeoTiledMap(GeoTiledMappingManagerEngine *engine, QObject *parent); + virtual ~CustomGeoTiledMap() = default; + QString copyrightsStyleSheet() const override; + virtual void evaluateCopyrights(const QSet &visibleTiles) override; +}; + class GeoTiledMappingManagerEngine : public QGeoTiledMappingManagerEngine { Q_OBJECT diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt index 5624073..7741a0f 100644 --- a/test_package/CMakeLists.txt +++ b/test_package/CMakeLists.txt @@ -17,7 +17,9 @@ find_package(Qt5 COMPONENTS REQUIRED QUIET) find_package(QtBasemapPlugin REQUIRED QUIET) -add_executable(example example.cpp) +qt5_add_resources(IMAGES_RCC "res/mapbox.qrc") + +add_executable(example example.cpp ${IMAGES_RCC}) get_property(MAP_PLUGIN TARGET qtgeoservices_basemap_pix4d PROPERTY IMPORTED_LOCATION_RELEASE) message(STATUS "Map plugin path ${MAP_PLUGIN}")