diff options
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickanimatorjob.cpp | 25 | ||||
-rw-r--r-- | src/quick/util/qquickanimatorjob_p.h | 1 | ||||
-rw-r--r-- | src/quick/util/qquickglobal.cpp | 44 | ||||
-rw-r--r-- | src/quick/util/qquickimageprovider.cpp | 14 | ||||
-rw-r--r-- | src/quick/util/qquickpath.cpp | 187 | ||||
-rw-r--r-- | src/quick/util/qquickpath_p.h | 19 | ||||
-rw-r--r-- | src/quick/util/qquickpath_p_p.h | 2 | ||||
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 49 | ||||
-rw-r--r-- | src/quick/util/qquicksvgparser.cpp | 8 | ||||
-rw-r--r-- | src/quick/util/qquicksvgparser_p.h | 7 | ||||
-rw-r--r-- | src/quick/util/qquickvaluetypes.cpp | 23 | ||||
-rw-r--r-- | src/quick/util/qquickvaluetypes_p.h | 8 |
12 files changed, 326 insertions, 61 deletions
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 50fb7090d1..43c8eb302a 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -325,8 +325,10 @@ void QQuickTransformAnimatorJob::preSync() m_helper = nullptr; } - if (!m_target) + if (!m_target) { + invalidate(); return; + } if (!m_helper) { m_helper = qquick_transform_animatorjob_helper_store()->acquire(m_target); @@ -346,27 +348,6 @@ void QQuickTransformAnimatorJob::preSync() m_helper->sync(); } -void QQuickTransformAnimatorJob::postSync() -{ - Q_ASSERT((m_helper != nullptr) == (m_target != nullptr)); // If there is a target, there should also be a helper, ref: preSync - Q_ASSERT(!m_helper || m_helper->item == m_target); // If there is a helper, it should point to our target - - if (!m_target || !m_helper) { - invalidate(); - return; - } - - QQuickItemPrivate *d = QQuickItemPrivate::get(m_target); -#if QT_CONFIG(quick_shadereffect) - if (d->extra.isAllocated() - && d->extra->layer - && d->extra->layer->enabled()) { - d = QQuickItemPrivate::get(d->extra->layer->m_effectSource); - } -#endif - m_helper->node = d->itemNode(); -} - void QQuickTransformAnimatorJob::invalidate() { if (m_helper) diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index a3ced4c21b..777da2ee6c 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -235,7 +235,6 @@ public: protected: QQuickTransformAnimatorJob(); - void postSync() override; void invalidate() override; Helper *m_helper; diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 5ba849c57f..14ead56740 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QQuickColorProvider : public QQmlColorProvider { public: - QVariant colorFromString(const QString &s, bool *ok) + QVariant colorFromString(const QString &s, bool *ok) override { QColor c(s); if (c.isValid()) { @@ -73,7 +73,7 @@ public: return QVariant(); } - unsigned rgbaFromString(const QString &s, bool *ok) + unsigned rgbaFromString(const QString &s, bool *ok) override { QColor c(s); if (c.isValid()) { @@ -95,36 +95,36 @@ public: return QString(); } - QVariant fromRgbF(double r, double g, double b, double a) + QVariant fromRgbF(double r, double g, double b, double a) override { return QVariant(QColor::fromRgbF(r, g, b, a)); } - QVariant fromHslF(double h, double s, double l, double a) + QVariant fromHslF(double h, double s, double l, double a) override { return QVariant(QColor::fromHslF(h, s, l, a)); } - QVariant fromHsvF(double h, double s, double v, double a) + QVariant fromHsvF(double h, double s, double v, double a) override { return QVariant(QColor::fromHsvF(h, s, v, a)); } - QVariant lighter(const QVariant &var, qreal factor) + QVariant lighter(const QVariant &var, qreal factor) override { QColor color = var.value<QColor>(); color = color.lighter(int(qRound(factor*100.))); return QVariant::fromValue(color); } - QVariant darker(const QVariant &var, qreal factor) + QVariant darker(const QVariant &var, qreal factor) override { QColor color = var.value<QColor>(); color = color.darker(int(qRound(factor*100.))); return QVariant::fromValue(color); } - QVariant tint(const QVariant &baseVar, const QVariant &tintVar) + QVariant tint(const QVariant &baseVar, const QVariant &tintVar) override { QColor tintColor = tintVar.value<QColor>(); @@ -302,6 +302,8 @@ public: QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight"))))); QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing"))))); QV4::ScopedValue vhint(scope, obj->get((s = v4->newString(QStringLiteral("hintingPreference"))))); + QV4::ScopedValue vkerning(scope, obj->get((s = v4->newString(QStringLiteral("kerning"))))); + QV4::ScopedValue vshaping(scope, obj->get((s = v4->newString(QStringLiteral("preferShaping"))))); // pull out the values, set ok to true if at least one valid field is given. if (vbold->isBoolean()) { @@ -356,6 +358,17 @@ public: retn.setHintingPreference(static_cast<QFont::HintingPreference>(vhint->integerValue())); if (ok) *ok = true; } + if (vkerning->isBoolean()) { + retn.setKerning(vkerning->booleanValue()); + if (ok) *ok = true; + } + if (vshaping->isBoolean()) { + bool enable = vshaping->booleanValue(); + if (enable) + retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() & ~QFont::PreferNoShaping)); + else + retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() | QFont::PreferNoShaping)); + } return retn; } @@ -778,13 +791,13 @@ public: class QQuickGuiProvider : public QQmlGuiProvider { public: - QQuickApplication *application(QObject *parent) + QQuickApplication *application(QObject *parent) override { return new QQuickApplication(parent); } #if QT_CONFIG(im) - QInputMethod *inputMethod() + QInputMethod *inputMethod() override { QInputMethod *im = qGuiApp->inputMethod(); QQmlEngine::setObjectOwnership(im, QQmlEngine::CppOwnership); @@ -792,20 +805,20 @@ public: } #endif - QStyleHints *styleHints() + QStyleHints *styleHints() override { QStyleHints *sh = qGuiApp->styleHints(); QQmlEngine::setObjectOwnership(sh, QQmlEngine::CppOwnership); return sh; } - QStringList fontFamilies() + QStringList fontFamilies() override { QFontDatabase database; return database.families(); } - bool openUrlExternally(QUrl &url) + bool openUrlExternally(QUrl &url) override { #ifndef QT_NO_DESKTOPSERVICES return QDesktopServices::openUrl(url); @@ -814,6 +827,11 @@ public: return false; #endif } + + QString pluginName() const override + { + return QGuiApplication::platformName(); + } }; diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index 4eab5608b1..6ee5b95dc7 100644 --- a/src/quick/util/qquickimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -183,7 +183,12 @@ QString QQuickImageResponse::errorString() const It may be reimplemented to cancel a request in the provider side, however, it is not mandatory. - A cancelled QQuickImageResponse still needs to emit finished(). + A cancelled QQuickImageResponse still needs to emit finished() so that the + engine may clean up the QQuickImageResponse. + + \note finished() should not be emitted until the response is complete, + regardless of whether or not cancel() was called. If it is called prematurely, + the engine may destroy the response while it is still active, leading to a crash. */ void QQuickImageResponse::cancel() { @@ -192,7 +197,12 @@ void QQuickImageResponse::cancel() /*! \fn void QQuickImageResponse::finished() - Signals that the job execution has finished (be it successfully, because an error happened or because it was cancelled). + Signals that the job execution has finished (be it successfully, because an + error happened or because it was cancelled). + + \note Emission of this signal must be the final action the response performs: + once the signal is received, the response will subsequently be destroyed by + the engine. */ /*! diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 8abb9377a6..b19eec6fb3 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE \instantiates QQuickPath \inqmlmodule QtQuick \ingroup qtquick-animation-paths - \brief Defines a path for use by \l PathView + \brief Defines a path for use by \l PathView and \l Shape A Path is composed of one or more path segments - PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg. @@ -79,13 +79,88 @@ QT_BEGIN_NAMESPACE PathAttribute allows named attributes with values to be defined along the path. - \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg + Path and the other types for specifying path elements are shared between + \l PathView and \l Shape. The following table provides an overview of the + applicability of the various path elements: + + \table + \header + \li Element + \li PathView + \li Shape + \li Shape, GL_NV_path_rendering + \li Shape, software + \row + \li PathMove + \li N/A + \li Yes + \li Yes + \li Yes + \row + \li PathLine + \li Yes + \li Yes + \li Yes + \li Yes + \row + \li PathQuad + \li Yes + \li Yes + \li Yes + \li Yes + \row + \li PathCubic + \li Yes + \li Yes + \li Yes + \li Yes + \row + \li PathArc + \li Yes + \li Yes + \li Yes + \li Yes + \row + \li PathSvg + \li Yes + \li Yes + \li Yes + \li Yes + \row + \li PathAttribute + \li Yes + \li N/A + \li N/A + \li N/A + \row + \li PathPercent + \li Yes + \li N/A + \li N/A + \li N/A + \row + \li PathCurve + \li Yes + \li No + \li No + \li No + \endtable + + \note Path is a non-visual type; it does not display anything on its own. + To draw a path, use \l Shape. + + \sa PathView, Shape, PathAttribute, PathPercent, PathLine, PathMove, PathQuad, PathCubic, PathArc, PathCurve, PathSvg */ QQuickPath::QQuickPath(QObject *parent) : QObject(*(new QQuickPathPrivate), parent) { } +QQuickPath::QQuickPath(QQuickPathPrivate &dd, QObject *parent) + : QObject(dd, parent) +{ +} + QQuickPath::~QQuickPath() { } @@ -1003,7 +1078,7 @@ void QQuickPathAttribute::setValue(qreal value) } \endqml - \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg + \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg, PathMove */ /*! @@ -1046,6 +1121,64 @@ void QQuickPathLine::addToPath(QPainterPath &path, const QQuickPathData &data) /****************************************************************************/ /*! + \qmltype PathMove + \instantiates QQuickPathMove + \inqmlmodule QtQuick + \ingroup qtquick-animation-paths + \brief Moves the Path's position + + The example below creates a path consisting of two horizontal lines with + some empty space between them. All three segments have a width of 100: + + \qml + Path { + startX: 0; startY: 100 + PathLine { relativeX: 100; y: 100 } + PathMove { relativeX: 100; y: 100 } + PathLine { relativeX: 100; y: 100 } + } + \endqml + + \note PathMove should not be used in a Path associated with a PathView. Use + PathLine instead. For ShapePath however it is important to distinguish + between the operations of drawing a straight line and moving the path + position without drawing anything. + + \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg, PathLine +*/ + +/*! + \qmlproperty real QtQuick::PathMove::x + \qmlproperty real QtQuick::PathMove::y + + Defines the position to move to. + + \sa relativeX, relativeY +*/ + +/*! + \qmlproperty real QtQuick::PathMove::relativeX + \qmlproperty real QtQuick::PathMove::relativeY + + Defines the position to move to relative to its start. + + If both a relative and absolute end position are specified for a single axis, the relative + position will be used. + + Relative and absolute positions can be mixed, for example it is valid to set a relative x + and an absolute y. + + \sa x, y +*/ + +void QQuickPathMove::addToPath(QPainterPath &path, const QQuickPathData &data) +{ + path.moveTo(positionForCurve(data, path.currentPosition())); +} + +/****************************************************************************/ + +/*! \qmltype PathQuad \instantiates QQuickPathQuad \inqmlmodule QtQuick @@ -1641,6 +1774,7 @@ void QQuickPathArc::setRadiusX(qreal radius) _radiusX = radius; emit radiusXChanged(); + emit changed(); } qreal QQuickPathArc::radiusY() const @@ -1655,6 +1789,7 @@ void QQuickPathArc::setRadiusY(qreal radius) _radiusY = radius; emit radiusYChanged(); + emit changed(); } /*! @@ -1688,6 +1823,7 @@ void QQuickPathArc::setUseLargeArc(bool largeArc) _useLargeArc = largeArc; emit useLargeArcChanged(); + emit changed(); } /*! @@ -1719,6 +1855,43 @@ void QQuickPathArc::setDirection(ArcDirection direction) _direction = direction; emit directionChanged(); + emit changed(); +} + +/*! + \qmlproperty real QtQuick::PathArc::xAxisRotation + + Defines the rotation of the arc, in degrees. The default value is 0. + + An arc is a section of circles or ellipses. Given the radius and the start + and end points, there are two ellipses that connect the points. This + property defines the rotation of the X axis of these ellipses. + + \note The value is only useful when the x and y radius differ, meaning the + arc is a section of ellipses. + + The following QML demonstrates how different radius values can be used to change + the shape of the arc: + \table + \row + \li \image declarative-arcrotation.png + \li \snippet qml/path/arcrotation.qml 0 + \endtable +*/ + +qreal QQuickPathArc::xAxisRotation() const +{ + return _xAxisRotation; +} + +void QQuickPathArc::setXAxisRotation(qreal rotation) +{ + if (_xAxisRotation == rotation) + return; + + _xAxisRotation = rotation; + emit xAxisRotationChanged(); + emit changed(); } void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data) @@ -1728,7 +1901,7 @@ void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data) QQuickSvgParser::pathArc(path, _radiusX, _radiusY, - 0, //xAxisRotation + _xAxisRotation, _useLargeArc, _direction == Clockwise ? 1 : 0, endPoint.x(), @@ -1758,6 +1931,11 @@ void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data) \endqml \endtable + \note Mixing PathSvg with other type of elements is not always supported. + For example, when \l Shape is backed by \c{GL_NV_path_rendering}, a + ShapePath can contain one or more PathSvg elements, or one or more other + type of elements, but not both. + \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathCurve */ @@ -1782,6 +1960,7 @@ void QQuickPathSvg::setPath(const QString &path) _path = path; emit pathChanged(); + emit changed(); } void QQuickPathSvg::addToPath(QPainterPath &path, const QQuickPathData &) diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index c0a96cad4f..b7fde5c272 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -159,6 +159,15 @@ public: void addToPath(QPainterPath &path, const QQuickPathData &) override; }; +class Q_QUICK_PRIVATE_EXPORT QQuickPathMove : public QQuickCurve +{ + Q_OBJECT +public: + QQuickPathMove(QObject *parent=0) : QQuickCurve(parent) {} + + void addToPath(QPainterPath &path, const QQuickPathData &) override; +}; + class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve { Q_OBJECT @@ -281,10 +290,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve Q_PROPERTY(qreal radiusY READ radiusY WRITE setRadiusY NOTIFY radiusYChanged) Q_PROPERTY(bool useLargeArc READ useLargeArc WRITE setUseLargeArc NOTIFY useLargeArcChanged) Q_PROPERTY(ArcDirection direction READ direction WRITE setDirection NOTIFY directionChanged) + Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION 2) public: QQuickPathArc(QObject *parent=0) - : QQuickCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise) {} + : QQuickCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise), _xAxisRotation(0) {} enum ArcDirection { Clockwise, Counterclockwise }; Q_ENUM(ArcDirection) @@ -301,6 +311,9 @@ public: ArcDirection direction() const; void setDirection(ArcDirection direction); + qreal xAxisRotation() const; + void setXAxisRotation(qreal rotation); + void addToPath(QPainterPath &path, const QQuickPathData &) override; Q_SIGNALS: @@ -308,12 +321,14 @@ Q_SIGNALS: void radiusYChanged(); void useLargeArcChanged(); void directionChanged(); + Q_REVISION(2) void xAxisRotationChanged(); private: qreal _radiusX; qreal _radiusY; bool _useLargeArc; ArcDirection _direction; + qreal _xAxisRotation; }; class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve @@ -404,6 +419,7 @@ Q_SIGNALS: void startYChanged(); protected: + QQuickPath(QQuickPathPrivate &dd, QObject *parent = nullptr); void componentComplete() override; void classBegin() override; void disconnectPathElements(); @@ -458,6 +474,7 @@ QML_DECLARE_TYPE(QQuickPathElement) QML_DECLARE_TYPE(QQuickPathAttribute) QML_DECLARE_TYPE(QQuickCurve) QML_DECLARE_TYPE(QQuickPathLine) +QML_DECLARE_TYPE(QQuickPathMove) QML_DECLARE_TYPE(QQuickPathQuad) QML_DECLARE_TYPE(QQuickPathCubic) QML_DECLARE_TYPE(QQuickPathCatmullRomCurve) diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h index 1dc3c1c47a..8ce85dbf0f 100644 --- a/src/quick/util/qquickpath_p_p.h +++ b/src/quick/util/qquickpath_p_p.h @@ -64,7 +64,7 @@ QT_REQUIRE_CONFIG(quick_path); QT_BEGIN_NAMESPACE -class QQuickPathPrivate : public QObjectPrivate +class Q_QUICK_PRIVATE_EXPORT QQuickPathPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QQuickPath) diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 882482ad31..e218b84fff 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -49,6 +49,7 @@ #include <qpa/qplatformintegration.h> #include <QtQuick/private/qsgtexture_p.h> +#include <QtQuick/private/qsgtexturereader_p.h> #include <QQuickWindow> #include <QCoreApplication> @@ -162,7 +163,7 @@ Q_SIGNALS: void downloadProgress(qint64, qint64); protected: - bool event(QEvent *event); + bool event(QEvent *event) override; private: Q_DISABLE_COPY(QQuickPixmapReply) @@ -200,7 +201,7 @@ public: static QQuickPixmapReader *existingInstance(QQmlEngine *engine); protected: - void run(); + void run() override; private: friend class QQuickPixmapReaderThreadObject; @@ -771,8 +772,26 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u QFile f(localFile); QSize readSize; if (f.open(QIODevice::ReadOnly)) { - if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, runningJob->providerOptions)) - errorCode = QQuickPixmapReply::Loading; + + // for now, purely use suffix information to determine whether we are working with a compressed texture + QByteArray suffix = QFileInfo(f).suffix().toLower().toLatin1(); + if (QSGTextureReader::isTexture(&f, suffix)) { + QQuickTextureFactory *factory = QSGTextureReader::read(&f, suffix); + if (factory) { + readSize = factory->textureSize(); + } else { + errorStr = QQuickPixmap::tr("Error decoding: %1").arg(url.toString()); + errorCode = QQuickPixmapReply::Decoding; + } + mutex.lock(); + if (!cancelled.contains(runningJob)) + runningJob->postReply(errorCode, errorStr, readSize, factory); + mutex.unlock(); + return; + } else { + if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, runningJob->providerOptions)) + errorCode = QQuickPixmapReply::Loading; + } } else { errorStr = QQuickPixmap::tr("Cannot open: %1").arg(url.toString()); errorCode = QQuickPixmapReply::Loading; @@ -1233,11 +1252,23 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q QString errorString; if (f.open(QIODevice::ReadOnly)) { - QImage image; - QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform(); - if (readImage(url, &f, &image, &errorString, &readSize, requestSize, providerOptions, &appliedTransform)) { - *ok = true; - return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform); + // for now, purely use suffix information to determine whether we are working with a compressed texture + QByteArray suffix = QFileInfo(f).suffix().toLower().toLatin1(); + if (QSGTextureReader::isTexture(&f, suffix)) { + QQuickTextureFactory *factory = QSGTextureReader::read(&f, suffix); + if (factory) { + *ok = true; + return new QQuickPixmapData(declarativePixmap, factory); + } else { + errorString = QQuickPixmap::tr("Error decoding: %1").arg(url.toString()); + } + } else { + QImage image; + QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform(); + if (readImage(url, &f, &image, &errorString, &readSize, requestSize, providerOptions, &appliedTransform)) { + *ok = true; + return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform); + } } } else { errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString()); diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp index 310b600965..086c6d0b28 100644 --- a/src/quick/util/qquicksvgparser.cpp +++ b/src/quick/util/qquicksvgparser.cpp @@ -45,8 +45,6 @@ QT_BEGIN_NAMESPACE -static const double Q_PI = 3.14159265358979323846; // pi - //copied from Qt SVG (qsvghandler.cpp). Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok); // '0' is 0x30 and '9' is 0x39 @@ -253,11 +251,11 @@ void QQuickSvgParser::pathArc(QPainterPath &path, th_arc = th1 - th0; if (th_arc < 0 && sweep_flag) - th_arc += 2 * Q_PI; + th_arc += 2 * M_PI; else if (th_arc > 0 && !sweep_flag) - th_arc -= 2 * Q_PI; + th_arc -= 2 * M_PI; - n_segs = qCeil(qAbs(th_arc / (Q_PI * 0.5 + 0.001))); + n_segs = qCeil(qAbs(th_arc / (M_PI * 0.5 + 0.001))); for (i = 0; i < n_segs; i++) { pathArcSegment(path, xc, yc, diff --git a/src/quick/util/qquicksvgparser_p.h b/src/quick/util/qquicksvgparser_p.h index 44b0d1b6dd..1777b99bf4 100644 --- a/src/quick/util/qquicksvgparser_p.h +++ b/src/quick/util/qquicksvgparser_p.h @@ -51,6 +51,7 @@ // We mean it. // +#include <private/qtquickglobal_p.h> #include <QtCore/qstring.h> #include <QtGui/qpainterpath.h> @@ -59,9 +60,9 @@ QT_BEGIN_NAMESPACE namespace QQuickSvgParser { bool parsePathDataFast(const QString &dataStr, QPainterPath &path); - void pathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, - int large_arc_flag, int sweep_flag, qreal x, qreal y, qreal curx, - qreal cury); + Q_QUICK_PRIVATE_EXPORT void pathArc(QPainterPath &path, qreal rx, qreal ry, qreal x_axis_rotation, + int large_arc_flag, int sweep_flag, qreal x, qreal y, qreal curx, + qreal cury); } QT_END_NAMESPACE diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp index 4d34c6d661..e4a03f3b52 100644 --- a/src/quick/util/qquickvaluetypes.cpp +++ b/src/quick/util/qquickvaluetypes.cpp @@ -757,6 +757,29 @@ void QQuickFontValueType::setHintingPreference(QQuickFontValueType::HintingPrefe v.setHintingPreference(QFont::HintingPreference(hintingPreference)); } +bool QQuickFontValueType::kerning() const +{ + return v.kerning(); +} + +void QQuickFontValueType::setKerning(bool b) +{ + v.setKerning(b); +} + +bool QQuickFontValueType::preferShaping() const +{ + return (v.styleStrategy() & QFont::PreferNoShaping) == 0; +} + +void QQuickFontValueType::setPreferShaping(bool enable) +{ + if (enable) + v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() & ~QFont::PreferNoShaping)); + else + v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() | QFont::PreferNoShaping)); +} + QT_END_NAMESPACE #include "moc_qquickvaluetypes_p.cpp" diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h index 4a1598ec5c..5a9af970e8 100644 --- a/src/quick/util/qquickvaluetypes_p.h +++ b/src/quick/util/qquickvaluetypes_p.h @@ -323,6 +323,8 @@ class QQuickFontValueType Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing FINAL) Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing FINAL) Q_PROPERTY(HintingPreference hintingPreference READ hintingPreference WRITE setHintingPreference FINAL) + Q_PROPERTY(bool kerning READ kerning WRITE setKerning FINAL) + Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL) public: enum FontWeight { Thin = QFont::Thin, @@ -393,6 +395,12 @@ public: HintingPreference hintingPreference() const; void setHintingPreference(HintingPreference); + + bool kerning() const; + void setKerning(bool b); + + bool preferShaping() const; + void setPreferShaping(bool b); }; QT_END_NAMESPACE |