diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-19 14:23:16 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-08-19 14:23:16 (GMT) |
commit | eb277fd3e9e1b1a3f2fdb0ae18f92f608c584816 (patch) | |
tree | 32c92e3875068bef6879f316d714135861c84593 /src/gui | |
parent | 1c9a28ea64cc53e61a64644dc5a4ff121b475bc5 (diff) | |
download | Qt-eb277fd3e9e1b1a3f2fdb0ae18f92f608c584816.zip Qt-eb277fd3e9e1b1a3f2fdb0ae18f92f608c584816.tar.gz Qt-eb277fd3e9e1b1a3f2fdb0ae18f92f608c584816.tar.bz2 |
Add Q_PROPERTY to all qgraphics effects.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 27 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect.h | 25 |
2 files changed, 50 insertions, 2 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index c1f8f06..ba13b25 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -271,6 +271,7 @@ bool QGraphicsEffect::isEnabled() const Q_D(const QGraphicsEffect); return d->isEnabled; } + void QGraphicsEffect::setEnabled(bool enable) { Q_D(QGraphicsEffect); @@ -278,9 +279,9 @@ void QGraphicsEffect::setEnabled(bool enable) return; d->isEnabled = enable; - if (d->source) d->source->update(); + emit enabledChanged(enable); } /*! @@ -367,7 +368,11 @@ QColor QGraphicsColorizeEffect::color() const void QGraphicsColorizeEffect::setColor(const QColor &c) { Q_D(QGraphicsColorizeEffect); + if (d->filter->color() == c) + return; + d->filter->setColor(c); + emit colorChanged(c); } void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) @@ -407,7 +412,11 @@ int QGraphicsPixelizeEffect::pixelSize() const void QGraphicsPixelizeEffect::setPixelSize(int size) { Q_D(QGraphicsPixelizeEffect); + if (d->pixelSize == size) + return; + d->pixelSize = size; + emit pixelSizeChanged(size); } static inline void pixelize(QImage *image, int pixelSize) @@ -544,8 +553,12 @@ int QGraphicsBlurEffect::blurRadius() const void QGraphicsBlurEffect::setBlurRadius(int radius) { Q_D(QGraphicsBlurEffect); + if (d->filter->radius() == radius) + return; + d->filter->setRadius(radius); updateBoundingRect(); + emit blurRadiusChanged(radius); } QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const @@ -596,8 +609,12 @@ QPointF QGraphicsShadowEffect::shadowOffset() const void QGraphicsShadowEffect::setShadowOffset(const QPointF &ofs) { Q_D(QGraphicsShadowEffect); + if (d->offset == ofs) + return; + d->offset = ofs; updateBoundingRect(); + emit shadowOffsetChanged(ofs); } int QGraphicsShadowEffect::blurRadius() const @@ -609,8 +626,12 @@ int QGraphicsShadowEffect::blurRadius() const void QGraphicsShadowEffect::setBlurRadius(int blurRadius) { Q_D(QGraphicsShadowEffect); + if (d->radius == blurRadius) + return; + d->radius = blurRadius; updateBoundingRect(); + emit blurRadiusChanged(blurRadius); } qreal QGraphicsShadowEffect::opacity() const @@ -622,7 +643,11 @@ qreal QGraphicsShadowEffect::opacity() const void QGraphicsShadowEffect::setOpacity(qreal opacity) { Q_D(QGraphicsShadowEffect); + if (qFuzzyCompare(d->alpha, opacity)) + return; + d->alpha = opacity; + emit opacityChanged(opacity); } QRectF QGraphicsShadowEffect::boundingRectFor(const QRectF &rect) const diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 19399d3..0692cda 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -95,7 +95,7 @@ class Q_GUI_EXPORT QGraphicsEffect : public QObject { Q_OBJECT Q_FLAGS(ChangeFlags) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) public: enum ChangeFlag { SourceAttached = 0x1, @@ -116,6 +116,9 @@ public: bool isEnabled() const; +Q_SIGNALS: + void enabledChanged(bool enabled); + public Q_SLOTS: void setEnabled(bool enable); // ### add update() slot @@ -153,6 +156,7 @@ private: class QGraphicsColorizeEffectPrivate; class Q_GUI_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect { Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: QGraphicsColorizeEffect(); ~QGraphicsColorizeEffect(); @@ -160,6 +164,9 @@ public: QColor color() const; void setColor(const QColor &c); +Q_SIGNALS: + void colorChanged(const QColor &color); + protected: void draw(QPainter *painter, QGraphicsEffectSource *source); @@ -171,6 +178,7 @@ private: class QGraphicsPixelizeEffectPrivate; class Q_GUI_EXPORT QGraphicsPixelizeEffect: public QGraphicsEffect { Q_OBJECT + Q_PROPERTY(int pixelSize READ pixelSize WRITE setPixelSize NOTIFY pixelSizeChanged) public: QGraphicsPixelizeEffect(); ~QGraphicsPixelizeEffect(); @@ -178,6 +186,9 @@ public: int pixelSize() const; void setPixelSize(int pixelSize); +Q_SIGNALS: + void pixelSizeChanged(int pixelSize); + protected: void draw(QPainter *painter, QGraphicsEffectSource *source); @@ -189,6 +200,7 @@ private: class QGraphicsBlurEffectPrivate; class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT + Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) public: QGraphicsBlurEffect(); ~QGraphicsBlurEffect(); @@ -196,6 +208,9 @@ public: int blurRadius() const; void setBlurRadius(int blurRadius); +Q_SIGNALS: + void blurRadiusChanged(int blurRadius); + protected: QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *painter, QGraphicsEffectSource *source); @@ -208,6 +223,9 @@ private: class QGraphicsShadowEffectPrivate; class Q_GUI_EXPORT QGraphicsShadowEffect: public QGraphicsEffect { Q_OBJECT + Q_PROPERTY(QPointF shadowOffset READ shadowOffset WRITE setShadowOffset NOTIFY shadowOffsetChanged) + Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) + Q_PROPERTY(int opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) public: QGraphicsShadowEffect(); ~QGraphicsShadowEffect(); @@ -225,6 +243,11 @@ public: qreal opacity() const; void setOpacity(qreal opacity); +Q_SIGNALS: + void shadowOffsetChanged(const QPointF &offset); + void blurRadiusChanged(int blurRadius); + void opacityChanged(int opacity); + protected: QRectF boundingRectFor(const QRectF &rect) const; void draw(QPainter *painter, QGraphicsEffectSource *source); |