diff options
author | Alex Wilson <alex.wilson@nokia.com> | 2012-05-02 12:03:01 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-03 05:18:28 +0200 |
commit | 523ebec5dca356e7ddf24792d9f6d2994a57599a (patch) | |
tree | 8d7a50ea76eb1505ee5790265b8e368ea928dff1 /src/imports/location/qdeclarativegeomapquickitem.cpp | |
parent | c2d17a1b05f8d1b7a83e2601656afe5db501dcdd (diff) | |
download | qtlocation-523ebec5dca356e7ddf24792d9f6d2994a57599a.tar.gz |
Fade map items away at zoomLevel < 3 (invisible at 2.0)
Task-number: QTBUG-25393
Change-Id: I6820f72281392a83ba37b673cc2ecf5099563325
Reviewed-by: Ian Chen <ian.1.chen@nokia.com>
Reviewed-by: Thomas Lowe <thomas.lowe@nokia.com>
Reviewed-by: Alex Wilson <alex.wilson@nokia.com>
Diffstat (limited to 'src/imports/location/qdeclarativegeomapquickitem.cpp')
-rw-r--r-- | src/imports/location/qdeclarativegeomapquickitem.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp index f4dc1f1b..1d517c6b 100644 --- a/src/imports/location/qdeclarativegeomapquickitem.cpp +++ b/src/imports/location/qdeclarativegeomapquickitem.cpp @@ -43,6 +43,7 @@ #include "qdeclarativegeomapmousearea_p.h" #include "qdeclarativecoordinate_p.h" #include <QtQml/qqmlinfo.h> +#include <QtQuick/QSGOpacityNode> #include <QDebug> #include <cmath> @@ -138,6 +139,13 @@ QT_BEGIN_NAMESPACE and (possibly) scaling of the original item, as well as a transformation from longitude and latitude to screen position. + \section2 Limitations + + \bold{Note:} Due to an implementation detail, items placed inside a + MapQuickItem will have a \c{parent} item which is not the MapQuickItem. + Refer to the MapQuickItem by its \c{id}, and avoid the use of \c{anchor} + in the \c{sourceItem}. + \section2 Example Usage The following snippet shows a MapQuickItem containing an Image element, @@ -160,6 +168,9 @@ QDeclarativeGeoMapQuickItem::QDeclarativeGeoMapQuickItem(QQuickItem *parent) mapAndSourceItemSet_(false) { setFlag(ItemHasContents, true); + opacityContainer_ = new QQuickItem(this); + opacityContainer_->setParentItem(this); + opacityContainer_->setFlag(ItemHasContents, true); } QDeclarativeGeoMapQuickItem::~QDeclarativeGeoMapQuickItem() {} @@ -273,7 +284,8 @@ void QDeclarativeGeoMapQuickItem::afterChildrenChanged() foreach (QQuickItem *i, kids) { if (i->flags() & QQuickItem::ItemHasContents && !qobject_cast<QDeclarativeGeoMapMouseArea*>(i) - && sourceItem_.data() != i) { + && sourceItem_.data() != i + && opacityContainer_ != i) { if (!printedWarning) { qmlInfo(this) << "Use the sourceItem property for the contained item, direct children are not supported"; printedWarning = true; @@ -356,7 +368,7 @@ void QDeclarativeGeoMapQuickItem::updateMapItem() if (!mapAndSourceItemSet_ && quickMap() && map() && sourceItem_) { mapAndSourceItemSet_ = true; - sourceItem_.data()->setParentItem(this); + sourceItem_.data()->setParentItem(opacityContainer_); sourceItem_.data()->setTransformOrigin(QQuickItem::TopLeft); connect(sourceItem_.data(), SIGNAL(xChanged()), this, SLOT(updateMapItem())); @@ -368,6 +380,8 @@ void QDeclarativeGeoMapQuickItem::updateMapItem() this, SLOT(updateMapItem())); } + opacityContainer_->setOpacity(zoomLevelOpacity()); + sourceItem_.data()->setScale(scaleFactor()); sourceItem_.data()->setPos(QPointF(0,0)); setWidth(sourceItem_.data()->width()); |