diff options
author | Martin Jones <martin.jones@nokia.com> | 2012-07-03 15:04:19 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-03 07:27:22 +0200 |
commit | f39c22ecec295d44eb1604e0a5dd5400093f0322 (patch) | |
tree | 836c1f2d9abe90bf6214e19301dd518a65201f8b /src/quick/items/qquickrectangle.cpp | |
parent | e1b3ad7c831023c3e336414a16b69773adea4e26 (diff) |
Allow resetting a Rectangle gradient.
If a gradient and a color are set on a rectangle, the gradient is used.
This means that if you wish to override the gradient on a component with
a color, you have to unset the gradient.
Also remove the unused QQuickGradient::gradient() method.
Task-number: QTBUG-23238
Change-Id: Ibd43cfe1bd4b867e4f6103f1d0dc0ed6176ab5c1
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/quick/items/qquickrectangle.cpp')
-rw-r--r-- | src/quick/items/qquickrectangle.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index 3137ba93fd..608fd94ac1 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -240,13 +240,12 @@ void QQuickGradientStop::updateGradient() To set the gradient stops, define them as children of the Gradient element. */ QQuickGradient::QQuickGradient(QObject *parent) -: QObject(parent), m_gradient(0) +: QObject(parent) { } QQuickGradient::~QQuickGradient() { - delete m_gradient; } QQmlListProperty<QQuickGradientStop> QQuickGradient::stops() @@ -254,24 +253,8 @@ QQmlListProperty<QQuickGradientStop> QQuickGradient::stops() return QQmlListProperty<QQuickGradientStop>(this, m_stops); } -const QGradient *QQuickGradient::gradient() const -{ - if (!m_gradient && !m_stops.isEmpty()) { - m_gradient = new QLinearGradient(0,0,0,1.0); - for (int i = 0; i < m_stops.count(); ++i) { - const QQuickGradientStop *stop = m_stops.at(i); - m_gradient->setCoordinateMode(QGradient::ObjectBoundingMode); - m_gradient->setColorAt(stop->position(), stop->color()); - } - } - - return m_gradient; -} - void QQuickGradient::doUpdate() { - delete m_gradient; - m_gradient = 0; emit updated(); } @@ -426,6 +409,11 @@ void QQuickRectangle::setGradient(QQuickGradient *gradient) update(); } +void QQuickRectangle::resetGradient() +{ + setGradient(0); +} + /*! \qmlproperty real QtQuick2::Rectangle::radius This property holds the corner radius used to draw a rounded rectangle. |