diff options
9 files changed, 82 insertions, 3 deletions
diff --git a/src/imports/location/location.cpp b/src/imports/location/location.cpp index fccb628d..40dffd5d 100644 --- a/src/imports/location/location.cpp +++ b/src/imports/location/location.cpp @@ -203,6 +203,8 @@ public: minor = 14; qmlRegisterType<QDeclarativeGeoMap, 14>(uri, major, minor, "Map"); + qmlRegisterUncreatableType<QDeclarativeGeoMapItemBase, 14>(uri, major, minor, "GeoMapItemBase", + QStringLiteral("GeoMapItemBase is not intended instantiable by developer.")); // Register the latest Qt version as QML type version qmlRegisterModule(uri, QT_VERSION_MAJOR, QT_VERSION_MINOR); diff --git a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp index b3496816..846fccbf 100644 --- a/src/location/declarativemaps/qdeclarativecirclemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativecirclemapitem.cpp @@ -128,6 +128,17 @@ QT_BEGIN_NAMESPACE \image api-mapcircle.png */ +/*! + \qmlproperty bool QtLocation::MapCircle::autoFadeIn + + This property holds whether the item automatically fades in when zooming into the map + starting from very low zoom levels. By default this is \c true. + Setting this property to \c false causes the map item to always have the opacity specified + with the \l QtQuick::Item::opacity property, which is 1.0 by default. + + \since 5.14 +*/ + static const int CircleSamples = 128; struct Vertex diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp index 162dcac4..9a2ae50b 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitembase.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitembase.cpp @@ -208,14 +208,31 @@ void QDeclarativeGeoMapItemBase::setPositionOnMap(const QGeoCoordinate &coordina setPosition(topLeft); } +bool QDeclarativeGeoMapItemBase::autoFadeIn() const +{ + return m_autoFadeIn; +} + static const double opacityRampMin = 1.5; static const double opacityRampMax = 2.5; + +void QDeclarativeGeoMapItemBase::setAutoFadeIn(bool fadeIn) +{ + if (fadeIn == m_autoFadeIn) + return; + m_autoFadeIn = fadeIn; + if (quickMap_ && quickMap_->zoomLevel() < opacityRampMax) + polishAndUpdate(); +} + /*! \internal */ float QDeclarativeGeoMapItemBase::zoomLevelOpacity() const { - if (quickMap_->zoomLevel() > opacityRampMax) + if (!m_autoFadeIn) // Consider skipping the opacity node instead. + return 1.0; + else if (quickMap_->zoomLevel() > opacityRampMax) return 1.0; else if (quickMap_->zoomLevel() > opacityRampMin) return quickMap_->zoomLevel() - opacityRampMin; diff --git a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h index 23fd1da6..38a118e5 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitembase_p.h +++ b/src/location/declarativemaps/qdeclarativegeomapitembase_p.h @@ -84,6 +84,7 @@ class Q_LOCATION_PRIVATE_EXPORT QDeclarativeGeoMapItemBase : public QQuickItem Q_OBJECT Q_PROPERTY(QGeoShape geoShape READ geoShape WRITE setGeoShape STORED false ) + Q_PROPERTY(bool autoFadeIn READ autoFadeIn WRITE setAutoFadeIn REVISION 14) public: explicit QDeclarativeGeoMapItemBase(QQuickItem *parent = 0); virtual ~QDeclarativeGeoMapItemBase(); @@ -96,6 +97,9 @@ public: virtual const QGeoShape &geoShape() const = 0; virtual void setGeoShape(const QGeoShape &shape) = 0; + bool autoFadeIn() const; + void setAutoFadeIn(bool fadeIn); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); virtual QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *); @@ -135,6 +139,7 @@ private: QDeclarativeGeoMapItemGroup *parentGroup_; QScopedPointer<QDeclarativeGeoMapItemTransitionManager> m_transitionManager; + bool m_autoFadeIn = true; friend class QDeclarativeGeoMap; friend class QDeclarativeGeoMapItemView; diff --git a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp index f7409788..ccca309b 100644 --- a/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapquickitem.cpp @@ -115,6 +115,17 @@ QT_BEGIN_NAMESPACE \image api-mapquickitem.png */ +/*! + \qmlproperty bool QtLocation::MapQuickItem::autoFadeIn + + This property holds whether the item automatically fades in when zooming into the map + starting from very low zoom levels. By default this is \c true. + Setting this property to \c false causes the map item to always have the opacity specified + with the \l QtQuick::Item::opacity property, which is 1.0 by default. + + \since 5.14 +*/ + QMapQuickItemMatrix4x4::QMapQuickItemMatrix4x4(QObject *parent) : QQuickTransform(parent) { } void QMapQuickItemMatrix4x4::setMatrix(const QMatrix4x4 &matrix) diff --git a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp index fcfa14a5..7a3873a4 100644 --- a/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolygonmapitem.cpp @@ -135,6 +135,17 @@ QT_BEGIN_NAMESPACE \image api-mappolygon.png */ +/*! + \qmlproperty bool QtLocation::MapPolygon::autoFadeIn + + This property holds whether the item automatically fades in when zooming into the map + starting from very low zoom levels. By default this is \c true. + Setting this property to \c false causes the map item to always have the opacity specified + with the \l QtQuick::Item::opacity property, which is 1.0 by default. + + \since 5.14 +*/ + QGeoMapPolygonGeometry::QGeoMapPolygonGeometry() : assumeSimple_(false) { diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index 63146fbc..5ca612db 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -297,6 +297,17 @@ static QList<QList<QDoubleVector2D> > clipLine( \image api-mappolyline.png */ +/*! + \qmlproperty bool QtLocation::MapPolyline::autoFadeIn + + This property holds whether the item automatically fades in when zooming into the map + starting from very low zoom levels. By default this is \c true. + Setting this property to \c false causes the map item to always have the opacity specified + with the \l QtQuick::Item::opacity property, which is 1.0 by default. + + \since 5.14 +*/ + QDeclarativeMapLineProperties::QDeclarativeMapLineProperties(QObject *parent) : QObject(parent), width_(1.0), diff --git a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp index 74f95734..fd4109a7 100644 --- a/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativerectanglemapitem.cpp @@ -114,6 +114,17 @@ QT_BEGIN_NAMESPACE \image api-maprectangle.png */ +/*! + \qmlproperty bool QtLocation::MapRectangle::autoFadeIn + + This property holds whether the item automatically fades in when zooming into the map + starting from very low zoom levels. By default this is \c true. + Setting this property to \c false causes the map item to always have the opacity specified + with the \l QtQuick::Item::opacity property, which is 1.0 by default. + + \since 5.14 +*/ + QDeclarativeRectangleMapItem::QDeclarativeRectangleMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), border_(this), color_(Qt::transparent), dirtyMaterial_(true), updatingGeometry_(false) diff --git a/src/location/declarativemaps/qquickgeomapgesturearea.cpp b/src/location/declarativemaps/qquickgeomapgesturearea.cpp index 13315917..a33db67a 100644 --- a/src/location/declarativemaps/qquickgeomapgesturearea.cpp +++ b/src/location/declarativemaps/qquickgeomapgesturearea.cpp @@ -999,8 +999,8 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event) return; } - const QGeoCoordinate &wheelGeoPos = m_declarativeMap->toCoordinate(event->posF(), false); - const QPointF &preZoomPoint = event->posF(); + const QGeoCoordinate &wheelGeoPos = m_declarativeMap->toCoordinate(event->position(), false); + const QPointF &preZoomPoint = event->position(); // Not using AltModifier as, for some reason, it causes angleDelta to be 0 if (event->modifiers() & Qt::ShiftModifier && rotationEnabled()) { |