diff options
author | axis <qt-info@nokia.com> | 2009-04-24 14:03:55 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-04-27 07:09:01 (GMT) |
commit | e74c8dc65e2feffb9a55d00aee5ca634fba41df8 (patch) | |
tree | 3a131f9235fb6a455793178d8313655e4fd0036e /src/svg | |
parent | 8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (diff) | |
parent | 211bea9838bcc2acd7f54b65468fe1be2d81b1e0 (diff) | |
download | Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.zip Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.gz Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Configure.exe recompiled with MSVC6.
Conflicts:
configure.exe
examples/network/network.pro
src/gui/dialogs/qfiledialog_p.h
src/gui/dialogs/qfilesystemmodel_p.h
src/gui/kernel/qapplication.cpp
tests/auto/_Categories/qmake.txt
tests/auto/qfile/test/test.pro
tests/auto/qfile/tst_qfile.cpp
tests/auto/qlibrary/tst_qlibrary.cpp
tests/auto/qline/tst_qline.cpp
tests/auto/qstyle/tst_qstyle.cpp
tests/auto/qtextstream/tst_qtextstream.cpp
tests/auto/qtranslator/qtranslator.pro
tests/auto/qwaitcondition/tst_qwaitcondition.cpp
translations/qt_ja_JP.ts
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvggenerator.cpp | 29 | ||||
-rw-r--r-- | src/svg/qsvghandler.cpp | 18 | ||||
-rw-r--r-- | src/svg/qsvgstyle.cpp | 12 | ||||
-rw-r--r-- | src/svg/qsvgstyle_p.h | 11 | ||||
-rw-r--r-- | src/svg/qsvgwidget.cpp | 16 |
5 files changed, 56 insertions, 30 deletions
diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index f7b2ae8..e822da5 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -516,7 +516,34 @@ public: \brief The QSvgGenerator class provides a paint device that is used to create SVG drawings. \reentrant - \sa QSvgRenderer, QSvgWidget + This paint device represents a Scalable Vector Graphics (SVG) drawing. Like QPrinter, it is + designed as a write-only device that generates output in a specific format. + + To write an SVG file, you first need to configure the output by setting the \l fileName + or \l outputDevice properties. It is usually necessary to specify the size of the drawing + by setting the \l size property, and in some cases where the drawing will be included in + another, the \l viewBox property also needs to be set. + + \snippet examples/painting/svggenerator/window.cpp configure SVG generator + + Other meta-data can be specified by setting the \a title, \a description and \a resolution + properties. + + As with other QPaintDevice subclasses, a QPainter object is used to paint onto an instance + of this class: + + \snippet examples/painting/svggenerator/window.cpp begin painting + \dots + \snippet examples/painting/svggenerator/window.cpp end painting + + Painting is performed in the same way as for any other paint device. However, + it is necessary to use the QPainter::begin() and \l{QPainter::}{end()} to + explicitly begin and end painting on the device. + + The \l{SVG Generator Example} shows how the same painting commands can be used + for painting a widget and writing an SVG file. + + \sa QSvgRenderer, QSvgWidget, {About SVG} */ /*! diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 56dab5f..433a3ad 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2587,10 +2587,12 @@ static void parseBaseGradient(QSvgNode *node, if (prop && prop->type() == QSvgStyleProperty::GRADIENT) { QSvgGradientStyle *inherited = static_cast<QSvgGradientStyle*>(prop); - if (!inherited->stopLink().isEmpty()) + if (!inherited->stopLink().isEmpty()) { gradProp->setStopLink(inherited->stopLink(), handler->document()); - else + } else { grad->setStops(inherited->qgradient()->stops()); + gradProp->setGradientStopsSet(inherited->gradientStopsSet()); + } matrix = inherited->qmatrix(); } else { @@ -2649,7 +2651,6 @@ static QSvgStyleProperty *createLinearGradientNode(QSvgNode *node, } QLinearGradient *grad = new QLinearGradient(nx1, ny1, nx2, ny2); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); parseBaseGradient(node, attributes, prop, handler); @@ -2783,7 +2784,6 @@ static QSvgStyleProperty *createRadialGradientNode(QSvgNode *node, nfy = toDouble(fy); QRadialGradient *grad = new QRadialGradient(ncx, ncy, nr, nfx, nfy); - grad->setColorAt(qQNaN(), QColor()); grad->setInterpolationMode(QGradient::ComponentInterpolation); QSvgGradientStyle *prop = new QSvgGradientStyle(grad); @@ -2929,12 +2929,9 @@ static bool parseStopNode(QSvgStyleProperty *parent, QGradient *grad = style->qgradient(); offset = qMin(qreal(1), qMax(qreal(0), offset)); // Clamp to range [0, 1] - QGradientStops stops = grad->stops(); - // Check if the gradient is marked as empty (marked with one single stop at NaN). - if ((stops.size() == 1) && qIsNaN(stops.at(0).first)) { - stops.clear(); - grad->setStops(stops); - } else { + QGradientStops stops; + if (style->gradientStopsSet()) { + stops = grad->stops(); // If the stop offset equals the one previously added, add an epsilon to make it greater. if (offset <= stops.back().first) offset = stops.back().first + FLT_EPSILON; @@ -2950,6 +2947,7 @@ static bool parseStopNode(QSvgStyleProperty *parent, } grad->setColorAt(offset, color); + style->setGradientStopsSet(true); if (!colorOK) style->addResolve(offset); return true; diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 389f68f..bd0804c 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -231,7 +231,7 @@ void QSvgSolidColorStyle::revert(QPainter *p, QSvgExtraStates &) } QSvgGradientStyle::QSvgGradientStyle(QGradient *grad) - : m_gradient(grad) + : m_gradient(grad), m_gradientStopsSet(false) { } @@ -256,14 +256,13 @@ void QSvgGradientStyle::apply(QPainter *p, const QRectF &/*rect*/, QSvgNode *, Q } // If the gradient is marked as empty, insert transparent black - QGradientStops stops = m_gradient->stops(); - if (stops.size() == 1 && qIsNaN(stops.at(0).first)) + if (!m_gradientStopsSet) { m_gradient->setStops(QGradientStops() << QGradientStop(0.0, QColor(0, 0, 0, 0))); - - QGradient gradient = *m_gradient; + m_gradientStopsSet = true; + } QBrush brush; - brush = QBrush(gradient); + brush = QBrush(*m_gradient); if (!m_matrix.isIdentity()) brush.setMatrix(m_matrix); @@ -809,6 +808,7 @@ void QSvgGradientStyle::resolveStops() static_cast<QSvgGradientStyle*>(prop); st->resolveStops(); m_gradient->setStops(st->qgradient()->stops()); + m_gradientStopsSet = st->gradientStopsSet(); } } m_link = QString(); diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index ff4058b..058ba35 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -376,6 +376,16 @@ public: } void addResolve(qreal offset); + + bool gradientStopsSet() const + { + return m_gradientStopsSet; + } + + void setGradientStopsSet(bool set) + { + m_gradientStopsSet = set; + } private: QGradient *m_gradient; QList<qreal> m_resolvePoints; @@ -386,6 +396,7 @@ private: QSvgTinyDocument *m_doc; QString m_link; + bool m_gradientStopsSet; }; class QSvgTransformStyle : public QSvgStyleProperty diff --git a/src/svg/qsvgwidget.cpp b/src/svg/qsvgwidget.cpp index a4200ca..ac8595f 100644 --- a/src/svg/qsvgwidget.cpp +++ b/src/svg/qsvgwidget.cpp @@ -83,18 +83,6 @@ class QSvgWidgetPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSvgWidget) public: - QSvgWidgetPrivate() - : QWidgetPrivate() - { - Q_Q(QSvgWidget); - renderer = new QSvgRenderer(q); - } - QSvgWidgetPrivate(const QString &file) - : QWidgetPrivate() - { - Q_Q(QSvgWidget); - renderer = new QSvgRenderer(file, q); - } QSvgRenderer *renderer; }; @@ -104,6 +92,7 @@ public: QSvgWidget::QSvgWidget(QWidget *parent) : QWidget(*new QSvgWidgetPrivate, parent, 0) { + d_func()->renderer = new QSvgRenderer(this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); } @@ -113,8 +102,9 @@ QSvgWidget::QSvgWidget(QWidget *parent) of the specified \a file. */ QSvgWidget::QSvgWidget(const QString &file, QWidget *parent) - : QWidget(*new QSvgWidgetPrivate(file), parent, 0) + : QWidget(*new QSvgWidgetPrivate, parent, 0) { + d_func()->renderer = new QSvgRenderer(file, this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); } |