diff options
author | Mitch Curtis <mitch.curtis@digia.com> | 2014-02-07 12:45:15 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-12 10:34:50 +0100 |
commit | 8730085fe4ce124cefaa563b42f433cbd31a3860 (patch) | |
tree | e4b12dfc4da0bef1d68c278080b0d84bfdb3a1d7 /src/quick/items/qquickrectangle.cpp | |
parent | 6c840c70d61c3ae277b60a024a086215c743e5b3 (diff) |
Expose Qt Quick gradient conversion code privately.
Rectangle is currently the only item that supports gradients, but other
items have been introduced (within Qt Quick Enterprise Controls) which
need QQuickGradient => QLinearGradient conversion, and it doesn't make
sense to duplicate the gradient stop conversion code.
The QQuickGradient and QQuickGradientStop classes need to be privately
exported so that modules that use private Qt API can use the classes
with quick-private.
Change-Id: I8b130ff5384d9481d3f29510b3de61f7d8f775e2
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/quick/items/qquickrectangle.cpp')
-rw-r--r-- | src/quick/items/qquickrectangle.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index 48f79a2192..e50f772e89 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -255,6 +255,18 @@ QQmlListProperty<QQuickGradientStop> QQuickGradient::stops() return QQmlListProperty<QQuickGradientStop>(this, m_stops); } +QGradientStops QQuickGradient::gradientStops() const +{ + QGradientStops stops; + for (int i = 0; i < m_stops.size(); ++i){ + int j = 0; + while (j < stops.size() && stops.at(j).first < m_stops[i]->position()) + j++; + stops.insert(j, QGradientStop(m_stops.at(i)->position(), m_stops.at(i)->color())); + } + return stops; +} + void QQuickGradient::doUpdate() { emit updated(); @@ -480,13 +492,7 @@ QSGNode *QQuickRectangle::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData QGradientStops stops; if (d->gradient) { - QList<QQuickGradientStop *> qxstops = d->gradient->m_stops; - for (int i = 0; i < qxstops.size(); ++i){ - int j = 0; - while (j < stops.size() && stops.at(j).first < qxstops[i]->position()) - j++; - stops.insert(j, QGradientStop(qxstops.at(i)->position(), qxstops.at(i)->color())); - } + stops = d->gradient->gradientStops(); } rectangle->setGradientStops(stops); |