diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/fx/qfxpainteditem.cpp | 29 | ||||
-rw-r--r-- | src/declarative/fx/qfxpainteditem.h | 7 | ||||
-rw-r--r-- | src/declarative/fx/qfxpainteditem_p.h | 3 |
3 files changed, 37 insertions, 2 deletions
diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 37eea9a..65589f2 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -303,7 +303,8 @@ void QFxPaintedItem::paintGLContents(GLPainter &p) for (int i = 0; i < rects.count(); ++i) { const QRect &r = rects.at(i); QPixmap img(r.size()); - img.fill(Qt::transparent); + if (d->fillColor.isValid()) + img.fill(d->fillColor); { QPainter qp(&img); qp.translate(-r.x(),-r.y()); @@ -383,4 +384,30 @@ void QFxPaintedItem::setCacheSize(int pixels) d->max_imagecache_size = pixels; } +/*! + \property QFxPaintedItem::fillColor + + The color to be used to fill the item prior to calling drawContents(). + By default, this is Qt::transparent. + + Performance improvements can be achieved if subclasses call this with either an + invalid color (QColor()), or an appropriate solid color. +*/ +void QFxPaintedItem::setFillColor(const QColor& c) +{ + Q_D(QFxPaintedItem); + if (d->fillColor == c) + return; + d->fillColor = c; + emit fillColorChanged(); + update(); +} + +QColor QFxPaintedItem::fillColor() const +{ + Q_D(const QFxPaintedItem); + return d->fillColor; +} + + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index b7db2d9..6cb8fe7 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) + Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) public: @@ -80,11 +81,17 @@ public: int cacheSize() const; void setCacheSize(int pixels); + QColor fillColor() const; + void setFillColor(const QColor&); + protected: QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent); virtual void drawContents(QPainter *p, const QRect &) = 0; +Q_SIGNALS: + void fillColorChanged(); + protected Q_SLOTS: void dirtyCache(const QRect &); void clearCache(); diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index 21ac556..4e953a0 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -68,7 +68,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate public: QFxPaintedItemPrivate() - : max_imagecache_size(100000), smooth(false) + : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent) { } @@ -89,6 +89,7 @@ public: int max_imagecache_size; bool smooth; QSize contentsSize; + QColor fillColor; }; QT_END_NAMESPACE |