summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-29 01:32:39 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-29 01:32:39 (GMT)
commit9f95bd8f6e6ccf3575216285b29f2a42dcfd328d (patch)
tree4cc4a0be670927a3e613ab1b790ebd241b9dfcc8
parent3824fa64f8f8d24db34e3ce1c8d5c7d21cb624b7 (diff)
downloadQt-9f95bd8f6e6ccf3575216285b29f2a42dcfd328d.zip
Qt-9f95bd8f6e6ccf3575216285b29f2a42dcfd328d.tar.gz
Qt-9f95bd8f6e6ccf3575216285b29f2a42dcfd328d.tar.bz2
Update in reaction to GradientStops changing.
-rw-r--r--src/declarative/fx/qfxrect.cpp17
-rw-r--r--src/declarative/fx/qfxrect.h14
2 files changed, 29 insertions, 2 deletions
diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp
index b10594e..9718344 100644
--- a/src/declarative/fx/qfxrect.cpp
+++ b/src/declarative/fx/qfxrect.cpp
@@ -133,6 +133,12 @@ void QFxPen::setWidth(int w)
Sets a \e color at a \e position in a gradient.
*/
+void QFxGradientStop::updateGradient()
+{
+ if (QFxGradient *grad = qobject_cast<QFxGradient*>(parent()))
+ grad->doUpdate();
+}
+
/*!
\qmlclass Gradient QFxGradient
\brief The Gradient item defines a gradient fill.
@@ -171,6 +177,13 @@ const QGradient *QFxGradient::gradient() const
return m_gradient;
}
+void QFxGradient::doUpdate()
+{
+ delete m_gradient;
+ m_gradient = 0;
+ emit updated();
+}
+
QML_DEFINE_TYPE(QFxRect,Rect)
/*!
@@ -310,7 +323,11 @@ void QFxRect::setGradient(QFxGradient *gradient)
Q_D(QFxRect);
if (d->gradient == gradient)
return;
+ if (d->gradient)
+ disconnect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
d->gradient = gradient;
+ if (d->gradient)
+ connect(d->gradient, SIGNAL(updated()), this, SLOT(doUpdate()));
update();
}
diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h
index 864b1cd..c279a1c 100644
--- a/src/declarative/fx/qfxrect.h
+++ b/src/declarative/fx/qfxrect.h
@@ -90,10 +90,13 @@ public:
QFxGradientStop(QObject *parent=0) : QObject(parent) {}
qreal position() const { return m_position; }
- void setPosition(qreal position) { m_position = position; }
+ void setPosition(qreal position) { m_position = position; updateGradient(); }
QColor color() const { return m_color; }
- void setColor(const QColor &color) { m_color = color; }
+ void setColor(const QColor &color) { m_color = color; updateGradient(); }
+
+private:
+ void updateGradient();
private:
qreal m_position;
@@ -116,9 +119,16 @@ public:
const QGradient *gradient() const;
+Q_SIGNALS:
+ void updated();
+
+private:
+ void doUpdate();
+
private:
QList<QFxGradientStop *> m_stops;
mutable QGradient *m_gradient;
+ friend class QFxGradientStop;
};
QML_DECLARE_TYPE(QFxGradient)