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 From fc3e138a26f9add4def111e8f6305f1aa674fa05 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 17 Sep 2009 09:48:08 +1000 Subject: Experiment with reset functions for width and height. --- src/declarative/fx/qfxitem.cpp | 14 ++++++++++++++ src/declarative/fx/qfxitem.h | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index c7e807c..dd51aa6 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2688,6 +2688,13 @@ void QFxItem::setWidth(qreal w) QRectF(x(), y(), oldWidth, height())); } +void QFxItem::resetWidth() +{ + Q_D(QFxItem); + d->widthValid = false; + setImplicitWidth(implicitWidth()); +} + qreal QFxItem::implicitWidth() const { Q_D(const QFxItem); @@ -2740,6 +2747,13 @@ void QFxItem::setHeight(qreal h) QRectF(x(), y(), width(), oldHeight)); } +void QFxItem::resetHeight() +{ + Q_D(QFxItem); + d->heightValid = false; + setImplicitHeight(implicitHeight()); +} + qreal QFxItem::implicitHeight() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 9d2113f..b309cb3 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -75,8 +75,8 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QmlList* states READ states DESIGNABLE false) Q_PROPERTY(QmlList* transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) - Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged RESET resetWidth FINAL) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged RESET resetHeight FINAL) Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) @@ -134,10 +134,12 @@ public: qreal width() const; void setWidth(qreal); + void resetWidth(); qreal implicitWidth() const; qreal height() const; void setHeight(qreal); + void resetHeight(); qreal implicitHeight() const; TransformOrigin transformOrigin() const; -- cgit v0.12