summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Meyer <dev@meh.at>2015-11-17 12:43:53 +0100
committerHarald Meyer <dev@meh.at>2015-11-22 10:40:20 +0000
commit3395b0c6697516bdf239619303a69c2c8a711288 (patch)
treead4e030938b5dc769834c85211637c7b1bb902e3
parent689e755efcb72bdc4b8891af1d9a5fc227e22f8f (diff)
downloadqtlocation-3395b0c6697516bdf239619303a69c2c8a711288.tar.gz
Add support for custom map background color
This update adds the property "color" to the QDeclarativeGeoMap which holds the background color of the map element. Change-Id: Iacb31c2d030b22fef4c068df14de020ed10438a1 Reviewed-by: Michal Klocek <michal.klocek@theqtcompany.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp29
-rw-r--r--src/imports/location/qdeclarativegeomap_p.h7
2 files changed, 34 insertions, 2 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index e290487e..06d6ad91 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -181,6 +181,7 @@ QDeclarativeGeoMap::QDeclarativeGeoMap(QQuickItem *parent)
m_zoomLevel(8.0),
m_componentCompleted(false),
m_mappingManagerInitialized(false),
+ m_color(QColor::fromRgbF(0.9, 0.9, 0.9)),
m_pendingFitViewport(false)
{
setAcceptHoverEvents(false);
@@ -417,9 +418,11 @@ QSGNode *QDeclarativeGeoMap::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeDa
QSGSimpleRectNode *root = static_cast<QSGSimpleRectNode *>(oldNode);
if (!root)
- root = new QSGSimpleRectNode(boundingRect(), QColor::fromRgbF(0.9, 0.9, 0.9));
- else
+ root = new QSGSimpleRectNode(boundingRect(), m_color);
+ else {
root->setRect(boundingRect());
+ root->setColor(m_color);
+ }
QSGNode *content = root->childCount() ? root->firstChild() : 0;
content = m_map->updateSceneGraph(content, window());
@@ -737,6 +740,28 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const
return QGeoRectangle(tl, br);
}
+
+/*!
+ \qmlproperty color QtLocation::Map::color
+
+ This property holds the background color of the map element.
+
+ \since 5.6
+*/
+void QDeclarativeGeoMap::setColor(const QColor &color)
+{
+ if (color != m_color) {
+ m_color = color;
+ update();
+ emit colorChanged(m_color);
+ }
+}
+
+QColor QDeclarativeGeoMap::color() const
+{
+ return m_color;
+}
+
void QDeclarativeGeoMap::fitViewportToGeoShape()
{
if (!m_map) return;
diff --git a/src/imports/location/qdeclarativegeomap_p.h b/src/imports/location/qdeclarativegeomap_p.h
index 8ee58556..47a6fe0b 100644
--- a/src/imports/location/qdeclarativegeomap_p.h
+++ b/src/imports/location/qdeclarativegeomap_p.h
@@ -55,6 +55,7 @@
#include <QtQuick/QQuickItem>
#include <QtCore/QPointer>
#include <QtCore/QMutex>
+#include <QtGui/QColor>
#include <QtPositioning/qgeoshape.h>
QT_BEGIN_NAMESPACE
@@ -79,6 +80,7 @@ class QDeclarativeGeoMap : public QQuickItem
Q_PROPERTY(QGeoServiceProvider::Error error READ error NOTIFY errorChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
Q_PROPERTY(QGeoShape visibleRegion READ visibleRegion WRITE setVisibleRegion)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -107,6 +109,9 @@ public:
void setVisibleRegion(const QGeoShape &shape);
QGeoShape visibleRegion() const;
+ void setColor(const QColor &color);
+ QColor color() const;
+
QQmlListProperty<QDeclarativeGeoMapType> supportedMapTypes();
Q_INVOKABLE void removeMapItem(QDeclarativeGeoMapItemBase *item);
@@ -142,6 +147,7 @@ Q_SIGNALS:
void mapItemsChanged();
void errorChanged();
void copyrightLinkActivated(const QString &link);
+ void colorChanged(const QColor &color);
protected:
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE ;
@@ -194,6 +200,7 @@ private:
bool m_componentCompleted;
bool m_mappingManagerInitialized;
QGeoShape m_region;
+ QColor m_color;
bool m_pendingFitViewport;
friend class QDeclarativeGeoMapItem;