From d5b554a7dc9204e65b1bfc3408d2d126d5ec2981 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 17 Sep 2009 09:41:42 +1000 Subject: Rect cleanup. --- src/declarative/fx/qfxrect.cpp | 11 ++++++++--- src/declarative/fx/qfxrect.h | 16 ++++++++++------ src/declarative/fx/qfxrect_p.h | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index fbd7ee8..7d6340f 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -69,14 +69,17 @@ void QFxPen::setColor(const QColor &c) { _color = c; _valid = _color.alpha() ? true : false; - emit updated(); + emit penChanged(); } void QFxPen::setWidth(int w) { + if (_width == w) + return; + _width = w; _valid = (_width < 1) ? false : true; - emit updated(); + emit penChanged(); } @@ -293,6 +296,7 @@ void QFxRect::setRadius(qreal radius) d->radius = radius; d->rectImage = QPixmap(); update(); + emit radiusChanged(); } /*! @@ -326,6 +330,7 @@ void QFxRect::setColor(const QColor &c) d->color = c; d->rectImage = QPixmap(); update(); + emit colorChanged(); } void QFxRect::generateRoundedRect() @@ -395,7 +400,7 @@ void QFxRect::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) void QFxRect::drawRect(QPainter &p) { Q_D(QFxRect); - if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) { + if (d->gradient && d->gradient->gradient()) { // XXX This path is still slower than the image path // Image path won't work for gradients though bool oldAA = p.testRenderHint(QPainter::Antialiasing); diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index 439cc65..e5bb8d3 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -55,8 +55,8 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject { Q_OBJECT - Q_PROPERTY(int width READ width WRITE setWidth) - Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged) public: QFxPen(QObject *parent=0) : QObject(parent), _width(1), _color("#000000"), _valid(false) @@ -71,7 +71,7 @@ public: bool isValid() { return _valid; }; Q_SIGNALS: - void updated(); + void penChanged(); private: int _width; @@ -135,10 +135,10 @@ class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem { Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QFxGradient *gradient READ gradient WRITE setGradient) - Q_PROPERTY(QFxPen * border READ border) - Q_PROPERTY(qreal radius READ radius WRITE setRadius) + Q_PROPERTY(QFxPen * border READ border CONSTANT) + Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) public: QFxRect(QFxItem *parent=0); @@ -157,6 +157,10 @@ public: void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); +Q_SIGNALS: + void colorChanged(); + void radiusChanged(); + private Q_SLOTS: void doUpdate(); diff --git a/src/declarative/fx/qfxrect_p.h b/src/declarative/fx/qfxrect_p.h index 8eb074a..c055b76 100644 --- a/src/declarative/fx/qfxrect_p.h +++ b/src/declarative/fx/qfxrect_p.h @@ -85,7 +85,7 @@ public: if (!pen) { Q_Q(QFxRect); pen = new QFxPen; - QObject::connect(pen, SIGNAL(updated()), q, SLOT(doUpdate())); + QObject::connect(pen, SIGNAL(penChanged()), q, SLOT(doUpdate())); } return pen; } -- cgit v0.12