diff options
Diffstat (limited to 'src/quick/util')
30 files changed, 423 insertions, 195 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index 741a583803..206b92eb81 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -1202,7 +1202,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti { for (int ii = 0; ii < actions.count(); ++ii) { const QQuickStateAction &action = actions.at(ii); - QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } } virtual void debugAction(QDebug d, int indentLevel) const { @@ -2535,7 +2535,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v) QQuickStateAction &action = actions[ii]; if (v == 1.) { - QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } else { if (!fromSourced && !fromDefined) { action.fromValue = action.property.read(); @@ -2551,7 +2551,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v) } } if (interpolator) - QQmlPropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } if (deleted) return; @@ -2643,7 +2643,7 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA } if (!successfullyCreatedDefaultProperty) { - foreach (const QString &errorMessage, errorMessages) + for (const QString &errorMessage : qAsConst(errorMessages)) qmlInfo(this) << errorMessage; } } diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp index abae6321b0..5d2af0f940 100644 --- a/src/quick/util/qquickanimator.cpp +++ b/src/quick/util/qquickanimator.cpp @@ -503,6 +503,7 @@ QQuickRotationAnimator::RotationDirection QQuickRotationAnimator::direction() co return d->direction; } +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) /*! \qmltype UniformAnimator \instantiates QQuickUniformAnimator @@ -580,5 +581,6 @@ QQuickAnimatorJob *QQuickUniformAnimator::createJob() const job->setUniform(u.toLatin1()); return job; } +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h index c23aa0a7e9..0fc900c5ac 100644 --- a/src/quick/util/qquickanimator_p.h +++ b/src/quick/util/qquickanimator_p.h @@ -170,6 +170,7 @@ protected: QString propertyName() const { return QStringLiteral("rotation"); } }; +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) class QQuickUniformAnimatorPrivate; class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator { @@ -190,6 +191,7 @@ protected: QQuickAnimatorJob *createJob() const; QString propertyName() const; }; +#endif QT_END_NAMESPACE @@ -199,6 +201,7 @@ QML_DECLARE_TYPE(QQuickYAnimator) QML_DECLARE_TYPE(QQuickScaleAnimator) QML_DECLARE_TYPE(QQuickRotationAnimator) QML_DECLARE_TYPE(QQuickOpacityAnimator) +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) QML_DECLARE_TYPE(QQuickUniformAnimator) - +#endif #endif // QQUICKANIMATOR_P_H diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp index 3fc7d87840..6d8167413e 100644 --- a/src/quick/util/qquickanimatorcontroller.cpp +++ b/src/quick/util/qquickanimatorcontroller.cpp @@ -69,14 +69,14 @@ QQuickAnimatorController::~QQuickAnimatorController() { // The proxy job might already have been deleted, in which case we // need to avoid calling functions on them. Then delete the job. - foreach (QAbstractAnimationJob *job, m_deleting) { + for (QAbstractAnimationJob *job : qAsConst(m_deleting)) { m_starting.take(job); m_stopping.take(job); m_animatorRoots.take(job); delete job; } - foreach (QQuickAnimatorProxyJob *proxy, m_animatorRoots) + for (QQuickAnimatorProxyJob *proxy : qAsConst(m_animatorRoots)) proxy->controllerWasDeleted(); for (auto it = m_animatorRoots.keyBegin(), end = m_animatorRoots.keyEnd(); it != end; ++it) delete *it; @@ -171,7 +171,7 @@ static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorC void QQuickAnimatorController::beforeNodeSync() { - foreach (QAbstractAnimationJob *job, m_deleting) { + for (QAbstractAnimationJob *job : qAsConst(m_deleting)) { m_starting.take(job); m_stopping.take(job); m_animatorRoots.take(job); @@ -182,7 +182,7 @@ void QQuickAnimatorController::beforeNodeSync() if (m_starting.size()) m_window->update(); - foreach (QQuickAnimatorProxyJob *proxy, m_starting) { + for (QQuickAnimatorProxyJob *proxy : qAsConst(m_starting)) { QAbstractAnimationJob *job = proxy->job(); job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion); qquick_initialize_helper(job, this, true); @@ -192,7 +192,7 @@ void QQuickAnimatorController::beforeNodeSync() } m_starting.clear(); - foreach (QQuickAnimatorProxyJob *proxy, m_stopping) { + for (QQuickAnimatorProxyJob *proxy : qAsConst(m_stopping)) { QAbstractAnimationJob *job = proxy->job(); job->stop(); } @@ -208,7 +208,7 @@ void QQuickAnimatorController::beforeNodeSync() m_nodesAreInvalid = false; } - foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) { + for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) { if (!job->target()) continue; else if (m_deletedSinceLastFrame.contains(job->target())) @@ -218,7 +218,7 @@ void QQuickAnimatorController::beforeNodeSync() xform->transformHelper()->sync(); } } - foreach (QQuickItem *wiped, m_deletedSinceLastFrame) { + for (QQuickItem *wiped : qAsConst(m_deletedSinceLastFrame)) { QQuickTransformAnimatorJob::Helper *helper = m_transforms.take(wiped); // Helper will now already have been reset in all animators referencing it. delete helper; @@ -229,7 +229,7 @@ void QQuickAnimatorController::beforeNodeSync() void QQuickAnimatorController::afterNodeSync() { - foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) { + for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) { if (job->target()) job->afterNodeSync(); } @@ -249,10 +249,10 @@ void QQuickAnimatorController::stopProxyJobs() // to be outside the lock. It is also safe because deletion of // proxies happens on the GUI thread, where this code is also executing. lock(); - QSet<QQuickAnimatorProxyJob *> jobs = m_proxiesToStop; + const QSet<QQuickAnimatorProxyJob *> jobs = m_proxiesToStop; m_proxiesToStop.clear(); unlock(); - foreach (QQuickAnimatorProxyJob *p, jobs) + for (QQuickAnimatorProxyJob *p : jobs) p->stop(); } @@ -265,7 +265,7 @@ void QQuickAnimatorController::animationFinished(QAbstractAnimationJob *job) * needed in any case. */ if (!m_deleting.contains(job)) { - QQuickAnimatorProxyJob *proxy = m_animatorRoots[job]; + QQuickAnimatorProxyJob *proxy = m_animatorRoots.value(job); if (proxy) { m_window->update(); m_proxiesToStop << proxy; diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 8d5ecadab5..1176cf1ff7 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -43,8 +43,10 @@ #include "qquickanimator_p_p.h" #include <private/qquickwindow_p.h> #include <private/qquickitem_p.h> -#include <private/qquickshadereffectnode_p.h> - +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) +# include <private/qquickopenglshadereffectnode_p.h> +# include <private/qquickopenglshadereffect_p.h> +#endif #include <private/qanimationgroupjob_p.h> #include <qcoreapplication.h> @@ -173,7 +175,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window) } else if (!m_controller && m_job) { m_controller = QQuickWindowPrivate::get(window)->animationController; - if (window->openglContext()) + if (window->isSceneGraphInitialized()) readyToAnimate(); else connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized())); @@ -327,11 +329,13 @@ void QQuickTransformAnimatorJob::Helper::sync() | QQuickItemPrivate::Size; QQuickItemPrivate *d = QQuickItemPrivate::get(item); +#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 quint32 dirty = mask & d->dirtyAttributes; @@ -390,7 +394,6 @@ void QQuickXAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); m_value = m_from + (m_to - m_from) * progress(time); m_helper->dx = m_value; @@ -407,7 +410,6 @@ void QQuickYAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); m_value = m_from + (m_to - m_from) * progress(time); m_helper->dy = m_value; @@ -423,11 +425,13 @@ void QQuickOpacityAnimatorJob::initialize(QQuickAnimatorController *controller) { QQuickAnimatorJob::initialize(controller); 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_opacityNode = d->opacityNode(); if (!m_opacityNode) { @@ -477,7 +481,6 @@ void QQuickOpacityAnimatorJob::updateCurrentTime(int time) { if (!m_controller || !m_opacityNode) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); m_value = m_from + (m_to - m_from) * progress(time); m_opacityNode->setOpacity(m_value); @@ -493,7 +496,6 @@ void QQuickScaleAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); m_value = m_from + (m_to - m_from) * progress(time); m_helper->scale = m_value; @@ -513,7 +515,6 @@ void QQuickRotationAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); float t = progress(time); @@ -546,6 +547,7 @@ void QQuickRotationAnimatorJob::writeBack() m_target->setRotation(value()); } +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) QQuickUniformAnimatorJob::QQuickUniformAnimatorJob() : m_node(0) , m_uniformIndex(-1) @@ -556,7 +558,7 @@ QQuickUniformAnimatorJob::QQuickUniformAnimatorJob() void QQuickUniformAnimatorJob::setTarget(QQuickItem *target) { - if (qobject_cast<QQuickShaderEffect *>(target) != 0) + if (qobject_cast<QQuickOpenGLShaderEffect *>(target) != 0) m_target = target; } @@ -569,14 +571,14 @@ void QQuickUniformAnimatorJob::nodeWasDestroyed() void QQuickUniformAnimatorJob::afterNodeSync() { - m_node = static_cast<QQuickShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode); + m_node = static_cast<QQuickOpenGLShaderEffectNode *>(QQuickItemPrivate::get(m_target)->paintNode); if (m_node && m_uniformIndex == -1 && m_uniformType == -1) { - QQuickShaderEffectMaterial *material = - static_cast<QQuickShaderEffectMaterial *>(m_node->material()); + QQuickOpenGLShaderEffectMaterial *material = + static_cast<QQuickOpenGLShaderEffectMaterial *>(m_node->material()); bool found = false; - for (int t=0; !found && t<QQuickShaderEffectMaterialKey::ShaderTypeCount; ++t) { - const QVector<QQuickShaderEffectMaterial::UniformData> &uniforms = material->uniforms[t]; + for (int t=0; !found && t<QQuickOpenGLShaderEffectMaterialKey::ShaderTypeCount; ++t) { + const QVector<QQuickOpenGLShaderEffectMaterial::UniformData> &uniforms = material->uniforms[t]; for (int i=0; i<uniforms.size(); ++i) { if (uniforms.at(i).name == m_uniform) { m_uniformIndex = i; @@ -594,15 +596,14 @@ void QQuickUniformAnimatorJob::updateCurrentTime(int time) { if (!m_controller) return; - Q_ASSERT(!m_controller->m_window->openglContext() || m_controller->m_window->openglContext()->thread() == QThread::currentThread()); if (!m_node || m_uniformIndex == -1 || m_uniformType == -1) return; m_value = m_from + (m_to - m_from) * progress(time); - QQuickShaderEffectMaterial *material = - static_cast<QQuickShaderEffectMaterial *>(m_node->material()); + QQuickOpenGLShaderEffectMaterial *material = + static_cast<QQuickOpenGLShaderEffectMaterial *>(m_node->material()); material->uniforms[m_uniformType][m_uniformIndex].value = m_value; // As we're not touching the nodes, we need to explicitly mark it dirty. // Otherwise, the renderer will abort repainting if this was the only @@ -615,5 +616,6 @@ void QQuickUniformAnimatorJob::writeBack() if (m_target) m_target->setProperty(m_uniform, value()); } +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h index 2b910d3737..64e849d322 100644 --- a/src/quick/util/qquickanimatorjob_p.h +++ b/src/quick/util/qquickanimatorjob_p.h @@ -68,7 +68,7 @@ class QQuickAbstractAnimation; class QQuickAnimatorController; class QQuickAnimatorProxyJobPrivate; -class QQuickShaderEffectNode; +class QQuickOpenGLShaderEffectNode; class QSGOpacityNode; @@ -277,7 +277,7 @@ public: private: QSGOpacityNode *m_opacityNode; }; - +#ifndef QT_NO_OPENGL class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimatorJob : public QQuickAnimatorJob { public: @@ -296,11 +296,12 @@ public: private: QByteArray m_uniform; - QQuickShaderEffectNode *m_node; + QQuickOpenGLShaderEffectNode *m_node; int m_uniformIndex : 8; int m_uniformType : 8; }; +#endif QT_END_NAMESPACE diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp index a4e2f0eb0e..5c26b23ff7 100644 --- a/src/quick/util/qquickapplication.cpp +++ b/src/quick/util/qquickapplication.cpp @@ -90,4 +90,9 @@ Qt::ApplicationState QQuickApplication::state() const return QGuiApplication::applicationState(); } +QFont QQuickApplication::font() const +{ + return QGuiApplication::font(); +} + QT_END_NAMESPACE diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h index 971c9a203a..091cb094ed 100644 --- a/src/quick/util/qquickapplication_p.h +++ b/src/quick/util/qquickapplication_p.h @@ -52,6 +52,7 @@ // #include <QtCore/QObject> +#include <QtGui/QFont> #include <qqml.h> #include <QtQml/private/qqmlglobal_p.h> #include <private/qtquickglobal_p.h> @@ -66,6 +67,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) Q_PROPERTY(bool supportsMultipleWindows READ supportsMultipleWindows CONSTANT) Q_PROPERTY(Qt::ApplicationState state READ state NOTIFY stateChanged) + Q_PROPERTY(QFont font READ font CONSTANT) public: explicit QQuickApplication(QObject *parent = 0); @@ -74,6 +76,7 @@ public: Qt::LayoutDirection layoutDirection() const; bool supportsMultipleWindows() const; Qt::ApplicationState state() const; + QFont font() const; Q_SIGNALS: void activeChanged(); diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index 147380037d..1d3ee2c4be 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -180,7 +180,7 @@ void QQuickBehavior::write(const QVariant &value) if (!d->animation || bypass) { if (d->animationInstance) d->animationInstance->stop(); - QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); d->targetValue = value; return; } @@ -206,7 +206,7 @@ void QQuickBehavior::write(const QVariant &value) // is needed (value has not changed). If the Behavior was already // running, let it continue as normal to ensure correct behavior and state. if (!behaviorActive && d->targetValue == currentValue) { - QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); return; } @@ -234,7 +234,7 @@ void QQuickBehavior::write(const QVariant &value) d->blockRunningChanged = false; } if (!after.contains(d->property)) - QQmlPropertyPrivate::write(d->property, value, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } void QQuickBehavior::setTarget(const QQmlProperty &property) diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp index 64fd458ef0..d13291c30a 100644 --- a/src/quick/util/qquickfontloader.cpp +++ b/src/quick/util/qquickfontloader.cpp @@ -45,14 +45,18 @@ #include <QStringList> #include <QUrl> #include <QDebug> -#include <QNetworkRequest> -#include <QNetworkReply> + #include <QFontDatabase> #include <private/qobject_p.h> #include <qqmlinfo.h> #include <qqmlfile.h> +#if QT_CONFIG(qml_network) +#include <QNetworkRequest> +#include <QNetworkReply> +#endif + #include <QtCore/QCoreApplication> QT_BEGIN_NAMESPACE @@ -66,28 +70,37 @@ Q_OBJECT public: explicit QQuickFontObject(int _id = -1); +#if QT_CONFIG(qml_network) void download(const QUrl &url, QNetworkAccessManager *manager); Q_SIGNALS: void fontDownloaded(const QString&, QQuickFontLoader::Status); +private: + int redirectCount; + QNetworkReply *reply; + private Q_SLOTS: void replyFinished(); +#endif // qml_network public: int id; -private: - QNetworkReply *reply; - int redirectCount; - Q_DISABLE_COPY(QQuickFontObject) }; QQuickFontObject::QQuickFontObject(int _id) - : QObject(0), id(_id), reply(0), redirectCount(0) {} + : QObject(0) +#if QT_CONFIG(qml_network) + ,redirectCount(0), reply(0) +#endif + ,id(_id) +{ +} +#if QT_CONFIG(qml_network) void QQuickFontObject::download(const QUrl &url, QNetworkAccessManager *manager) { QNetworkRequest req(url); @@ -128,7 +141,7 @@ void QQuickFontObject::replyFinished() reply = 0; } } - +#endif // qml_network class QQuickFontLoaderPrivate : public QObjectPrivate { @@ -251,10 +264,11 @@ void QQuickFontLoader::setSource(const QUrl &url) updateFontInfo(QString(), Error); } } else { - updateFontInfo(QFontDatabase::applicationFontFamilies(fontLoaderFonts()->map[d->url]->id).at(0), Ready); + updateFontInfo(QFontDatabase::applicationFontFamilies(fontLoaderFonts()->map.value(d->url)->id).at(0), Ready); } } else { if (!fontLoaderFonts()->map.contains(d->url)) { +#if QT_CONFIG(qml_network) QQuickFontObject *fo = new QQuickFontObject; fontLoaderFonts()->map[d->url] = fo; fo->download(d->url, qmlEngine(this)->networkAccessManager()); @@ -262,13 +276,20 @@ void QQuickFontLoader::setSource(const QUrl &url) emit statusChanged(); QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)), this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status))); +#else +// Silently fail if compiled with no_network +#endif } else { - QQuickFontObject *fo = fontLoaderFonts()->map[d->url]; + QQuickFontObject *fo = fontLoaderFonts()->map.value(d->url); if (fo->id == -1) { +#if QT_CONFIG(qml_network) d->status = Loading; emit statusChanged(); QObject::connect(fo, SIGNAL(fontDownloaded(QString,QQuickFontLoader::Status)), this, SLOT(updateFontInfo(QString,QQuickFontLoader::Status))); +#else +// Silently fail if compiled with no_network +#endif } else updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready); diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index be4c968ab2..7692cc79f9 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -301,6 +301,7 @@ public: QV4::ScopedValue vundl(scope, obj->get((s = v4->newString(QStringLiteral("underline"))))); 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"))))); // pull out the values, set ok to true if at least one valid field is given. if (vbold->isBoolean()) { @@ -351,6 +352,10 @@ public: retn.setWordSpacing(vwspac->asDouble()); if (ok) *ok = true; } + if (vhint->isInt32()) { + retn.setHintingPreference(static_cast<QFont::HintingPreference>(vhint->integerValue())); + if (ok) *ok = true; + } return retn; } diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 6b491a433c..25a4433a9b 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -358,7 +358,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en bool usesPercent = false; int index = 0; - foreach (QQuickPathElement *pathElement, d->_pathElements) { + for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) { if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) { QQuickPathData data; data.index = index; @@ -382,7 +382,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en } // Fixup end points - const AttributePoint &last = attributePoints.last(); + const AttributePoint &last = attributePoints.constLast(); for (int ii = 0; ii < attributes.count(); ++ii) { if (!last.values.contains(attributes.at(ii))) endpoint(attributePoints, attributes.at(ii)); @@ -407,11 +407,11 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en } attributePoints[ii].origpercent /= length; attributePoints[ii].percent = point.values.value(percentString); - prevorigpercent = attributePoints[ii].origpercent; - prevpercent = attributePoints[ii].percent; + prevorigpercent = attributePoints.at(ii).origpercent; + prevpercent = attributePoints.at(ii).percent; } else { attributePoints[ii].origpercent /= length; - attributePoints[ii].percent = attributePoints[ii].origpercent; + attributePoints[ii].percent = attributePoints.at(ii).origpercent; } } @@ -432,17 +432,17 @@ void QQuickPath::classBegin() void QQuickPath::disconnectPathElements() { - Q_D(QQuickPath); + Q_D(const QQuickPath); - foreach (QQuickPathElement *pathElement, d->_pathElements) + for (QQuickPathElement *pathElement : d->_pathElements) disconnect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); } void QQuickPath::connectPathElements() { - Q_D(QQuickPath); + Q_D(const QQuickPath); - foreach (QQuickPathElement *pathElement, d->_pathElements) + for (QQuickPathElement *pathElement : d->_pathElements) connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); } @@ -453,7 +453,7 @@ void QQuickPath::gatherAttributes() QSet<QString> attributes; // First gather up all the attributes - foreach (QQuickPathElement *pathElement, d->_pathElements) { + for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) { if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) d->_pathCurves.append(curve); else if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement)) @@ -488,7 +488,7 @@ QStringList QQuickPath::attributes() const QSet<QString> attrs; // First gather up all the attributes - foreach (QQuickPathElement *pathElement, d->_pathElements) { + for (QQuickPathElement *pathElement : d->_pathElements) { if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement)) attrs.insert(attribute->name()); diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index e2c99de44e..457f69d20f 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -51,10 +51,15 @@ // We mean it. // +#include <private/qtquickglobal_p.h> + +QT_REQUIRE_CONFIG(quick_path); + #include <qqml.h> #include <private/qqmlnullablevalue_p.h> #include <private/qbezier_p.h> +#include <private/qtquickglobal_p.h> #include <QtCore/QObject> #include <QtGui/QPainterPath> @@ -69,7 +74,7 @@ struct QQuickPathData QList<QQuickCurve*> curves; }; -class Q_AUTOTEST_EXPORT QQuickPathElement : public QObject +class Q_QUICK_PRIVATE_EXPORT QQuickPathElement : public QObject { Q_OBJECT public: @@ -78,7 +83,7 @@ Q_SIGNALS: void changed(); }; -class Q_AUTOTEST_EXPORT QQuickPathAttribute : public QQuickPathElement +class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement { Q_OBJECT @@ -103,7 +108,7 @@ private: qreal _value; }; -class Q_AUTOTEST_EXPORT QQuickCurve : public QQuickPathElement +class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement { Q_OBJECT @@ -145,7 +150,7 @@ private: QQmlNullableValue<qreal> _relativeY; }; -class Q_AUTOTEST_EXPORT QQuickPathLine : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve { Q_OBJECT public: @@ -154,7 +159,7 @@ public: void addToPath(QPainterPath &path, const QQuickPathData &); }; -class Q_AUTOTEST_EXPORT QQuickPathQuad : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve { Q_OBJECT @@ -194,7 +199,7 @@ private: QQmlNullableValue<qreal> _relativeControlY; }; -class Q_AUTOTEST_EXPORT QQuickPathCubic : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve { Q_OBJECT @@ -260,7 +265,7 @@ private: QQmlNullableValue<qreal> _relativeControl2Y; }; -class Q_AUTOTEST_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve { Q_OBJECT public: @@ -269,7 +274,7 @@ public: void addToPath(QPainterPath &path, const QQuickPathData &); }; -class Q_AUTOTEST_EXPORT QQuickPathArc : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve { Q_OBJECT Q_PROPERTY(qreal radiusX READ radiusX WRITE setRadiusX NOTIFY radiusXChanged) @@ -311,7 +316,7 @@ private: ArcDirection _direction; }; -class Q_AUTOTEST_EXPORT QQuickPathSvg : public QQuickCurve +class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve { Q_OBJECT Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) @@ -330,7 +335,7 @@ private: QString _path; }; -class Q_AUTOTEST_EXPORT QQuickPathPercent : public QQuickPathElement +class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement { Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) @@ -359,7 +364,7 @@ struct QQuickCachedBezier }; class QQuickPathPrivate; -class Q_AUTOTEST_EXPORT QQuickPath : public QObject, public QQmlParserStatus +class Q_QUICK_PRIVATE_EXPORT QQuickPath : public QObject, public QQmlParserStatus { Q_OBJECT diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h index 3e4ccc7eb6..1dc3c1c47a 100644 --- a/src/quick/util/qquickpath_p_p.h +++ b/src/quick/util/qquickpath_p_p.h @@ -51,6 +51,10 @@ // We mean it. // +#include <private/qtquickglobal_p.h> + +QT_REQUIRE_CONFIG(quick_path); + #include "qquickpath_p.h" #include <qqml.h> diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h index ce18190977..0fdb1a444f 100644 --- a/src/quick/util/qquickpathinterpolator_p.h +++ b/src/quick/util/qquickpathinterpolator_p.h @@ -51,6 +51,10 @@ // We mean it. // +#include <private/qtquickglobal_p.h> + +QT_REQUIRE_CONFIG(quick_path); + #include <qqml.h> #include <QObject> diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 50b867125e..96b88636fe 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qquickpixmapcache_p.h" -#include <qqmlnetworkaccessmanagerfactory.h> #include <qquickimageprovider.h> #include <qqmlengine.h> @@ -55,7 +54,6 @@ #include <QCoreApplication> #include <QImageReader> #include <QHash> -#include <QNetworkReply> #include <QPixmapCache> #include <QFile> #include <QThread> @@ -66,10 +64,15 @@ #include <QWaitCondition> #include <QtCore/qdebug.h> #include <private/qobject_p.h> -#include <QSslError> #include <QQmlFile> #include <QMetaMethod> +#if QT_CONFIG(qml_network) +#include <qqmlnetworkaccessmanagerfactory.h> +#include <QNetworkReply> +#include <QSslError> +#endif + #include <private/qquickprofiler_p.h> #define IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT 8 @@ -203,7 +206,9 @@ private: friend class QQuickPixmapReaderThreadObject; void processJobs(); void processJob(QQuickPixmapReply *, const QUrl &, const QString &, AutoTransform, QQuickImageProvider::ImageType, QQuickImageProvider *); +#if QT_CONFIG(qml_network) void networkRequestDone(QNetworkReply *); +#endif void asyncResponseFinished(QQuickImageResponse *); QList<QQuickPixmapReply*> jobs; @@ -215,10 +220,11 @@ private: QQuickPixmapReaderThreadObject *threadObject; QWaitCondition waitCondition; +#if QT_CONFIG(qml_network) QNetworkAccessManager *networkAccessManager(); QNetworkAccessManager *accessManager; - QHash<QNetworkReply*,QQuickPixmapReply*> networkJobs; +#endif QHash<QQuickImageResponse*,QQuickPixmapReply*> asyncResponses; static int replyDownloadProgress; @@ -343,6 +349,7 @@ QQuickPixmapReply::Event::~Event() delete textureFactory; } +#if QT_CONFIG(qml_network) QNetworkAccessManager *QQuickPixmapReader::networkAccessManager() { if (!accessManager) { @@ -351,6 +358,7 @@ QNetworkAccessManager *QQuickPixmapReader::networkAccessManager() } return accessManager; } +#endif static void maybeRemoveAlpha(QImage *image) { @@ -421,7 +429,10 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e } QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng) -: QThread(eng), engine(eng), threadObject(0), accessManager(0) +: QThread(eng), engine(eng), threadObject(0) +#if QT_CONFIG(qml_network) +, accessManager(0) +#endif { eventLoopQuitHack = new QObject; eventLoopQuitHack->moveToThread(this); @@ -437,19 +448,27 @@ QQuickPixmapReader::~QQuickPixmapReader() mutex.lock(); // manually cancel all outstanding jobs. - foreach (QQuickPixmapReply *reply, jobs) { + for (QQuickPixmapReply *reply : qAsConst(jobs)) { if (reply->data && reply->data->reply == reply) reply->data->reply = 0; delete reply; } jobs.clear(); - QList<QQuickPixmapReply*> activeJobs = networkJobs.values() + asyncResponses.values(); - foreach (QQuickPixmapReply *reply, activeJobs ) { +#if QT_CONFIG(qml_network) + + const auto cancelJob = [this](QQuickPixmapReply *reply) { if (reply->loading) { cancelled.append(reply); reply->data = 0; } - } + }; + + for (auto *reply : qAsConst(networkJobs)) + cancelJob(reply); + + for (auto *reply : qAsConst(asyncResponses)) + cancelJob(reply); +#endif if (threadObject) threadObject->processJobs(); mutex.unlock(); @@ -457,6 +476,7 @@ QQuickPixmapReader::~QQuickPixmapReader() wait(); } +#if QT_CONFIG(qml_network) void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) { QQuickPixmapReply *job = networkJobs.take(reply); @@ -506,6 +526,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) // kick off event loop again incase we have dropped below max request count threadObject->processJobs(); } +#endif // qml_network void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response) { @@ -556,8 +577,10 @@ bool QQuickPixmapReaderThreadObject::event(QEvent *e) void QQuickPixmapReaderThreadObject::networkRequestDone() { +#if QT_CONFIG(qml_network) QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reader->networkRequestDone(reply); +#endif } void QQuickPixmapReaderThreadObject::asyncResponseFinished() @@ -576,6 +599,7 @@ void QQuickPixmapReader::processJobs() // Clean cancelled jobs if (!cancelled.isEmpty()) { +#if QT_CONFIG(qml_network) for (int i = 0; i < cancelled.count(); ++i) { QQuickPixmapReply *job = cancelled.at(i); QNetworkReply *reply = networkJobs.key(job, 0); @@ -597,13 +621,14 @@ void QQuickPixmapReader::processJobs() job->deleteLater(); } cancelled.clear(); +#endif } if (!jobs.isEmpty()) { // Find a job we can use bool usableJob = false; for (int i = jobs.count() - 1; !usableJob && i >= 0; i--) { - QQuickPixmapReply *job = jobs[i]; + QQuickPixmapReply *job = jobs.at(i); const QUrl url = job->url; QString localFile; QQuickImageProvider::ImageType imageType = QQuickImageProvider::Invalid; @@ -617,7 +642,11 @@ void QQuickPixmapReader::processJobs() usableJob = true; } else { localFile = QQmlFile::urlToLocalFileOrQrc(url); - usableJob = !localFile.isEmpty() || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT; + usableJob = !localFile.isEmpty() +#if QT_CONFIG(qml_network) + || networkJobs.count() < IMAGEREQUEST_MAX_NETWORK_REQUEST_COUNT +#endif + ; } @@ -742,6 +771,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u runningJob->postReply(errorCode, errorStr, readSize, QQuickTextureFactory::textureFactoryForImage(image)); mutex.unlock(); } else { +#if QT_CONFIG(qml_network) // Network resource QNetworkRequest req(url); req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); @@ -751,6 +781,9 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone); networkJobs.insert(reply, runningJob); +#else +// Silently fail if compiled with no_network +#endif } } } @@ -807,11 +840,13 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply) void QQuickPixmapReader::run() { if (replyDownloadProgress == -1) { +#if QT_CONFIG(qml_network) replyDownloadProgress = QMetaMethod::fromSignal(&QNetworkReply::downloadProgress).methodIndex(); replyFinished = QMetaMethod::fromSignal(&QNetworkReply::finished).methodIndex(); - downloadProgress = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex(); const QMetaObject *ir = &QQuickPixmapReaderThreadObject::staticMetaObject; threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()"); +#endif + downloadProgress = QMetaMethod::fromSignal(&QQuickPixmapReply::downloadProgress).methodIndex(); } mutex.lock(); @@ -886,15 +921,13 @@ QQuickPixmapStore::~QQuickPixmapStore() #ifndef QT_NO_DEBUG int leakedPixmaps = 0; #endif - QList<QQuickPixmapData*> cachedData = m_cache.values(); - // Prevent unreferencePixmap() from assuming it needs to kick // off the cache expiry timer, as we're shrinking the cache // manually below after releasing all the pixmaps. m_timerId = -2; // unreference all (leaked) pixmaps - foreach (QQuickPixmapData* pixmap, cachedData) { + for (auto *pixmap : qAsConst(m_cache)) { int currRefCount = pixmap->refCount; if (currRefCount) { #ifndef QT_NO_DEBUG diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp index f8d090cc2c..841a1c9bcf 100644 --- a/src/quick/util/qquickprofiler.cpp +++ b/src/quick/util/qquickprofiler.cpp @@ -70,7 +70,7 @@ void QQuickProfiler::registerAnimationCallback() class CallbackRegistrationHelper : public QObject { Q_OBJECT -public slots: +public: void registerAnimationTimerCallback() { QQuickProfiler::registerAnimationCallback(); @@ -86,7 +86,12 @@ QQuickProfiler::QQuickProfiler(QObject *parent) : QObject(parent) m_timer.start(); CallbackRegistrationHelper *helper = new CallbackRegistrationHelper; // will delete itself helper->moveToThread(QCoreApplication::instance()->thread()); - QMetaObject::invokeMethod(helper, "registerAnimationTimerCallback", Qt::QueuedConnection); + + // Queue the signal to have the animation timer registration run in the right thread; + QObject signalSource; + connect(&signalSource, &QObject::destroyed, + helper, &CallbackRegistrationHelper::registerAnimationTimerCallback, + Qt::QueuedConnection); } QQuickProfiler::~QQuickProfiler() @@ -110,8 +115,9 @@ void QQuickProfiler::stopProfilingImpl() m_data.clear(); } -void QQuickProfiler::reportDataImpl() +void QQuickProfiler::reportDataImpl(bool trackLocations) { + Q_UNUSED(trackLocations); QMutexLocker lock(&m_dataMutex); emit dataReady(m_data); m_data.clear(); diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h index b58d4f47c1..66ed212722 100644 --- a/src/quick/util/qquickprofiler_p.h +++ b/src/quick/util/qquickprofiler_p.h @@ -62,52 +62,22 @@ QT_BEGIN_NAMESPACE +#ifdef QT_NO_QML_DEBUGGER + +#define Q_QUICK_PROFILE_IF_ENABLED(feature, Code) + +struct QQuickProfiler { + static void registerAnimationCallback() {} +}; + +#else + #define Q_QUICK_PROFILE_IF_ENABLED(feature, Code)\ if (QQuickProfiler::featuresEnabled & (1 << feature)) {\ Code;\ } else\ (void)0 -#define Q_QUICK_PROFILE(feature, Method)\ - Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method) - -#define Q_QUICK_SG_PROFILE_START(Type)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::startSceneGraphFrame<Type>())) - -#define Q_QUICK_SG_PROFILE_RECORD(Type)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::recordSceneGraphTimestamp<Type>())) - -#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>())) - -#define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::startSceneGraphFrame<Type1, Type2>())) - -#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>())) - -#define Q_QUICK_SG_PROFILE_REPORT(Type)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame<Type, false>())) - -#define Q_QUICK_SG_PROFILE_END(Type)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame<Type, true>())) - -#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ - (QQuickProfiler::reportSceneGraphFrame<Type, true>(Payload))) - - -#define Q_QUICK_INPUT_PROFILE(Type, DetailType, A, B)\ - Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileInputEvents,\ - (QQuickProfiler::inputEvent<Type, DetailType>(A, B))) - // This struct is somewhat dangerous to use: // You can save values either with 32 or 64 bit precision. toByteArrays will // guess the precision from messageType. If you state the wrong messageType @@ -319,17 +289,15 @@ public: qint64 timestamp() { return m_timer.nsecsElapsed(); } - static quint64 featuresEnabled; - static bool profilingSceneGraph() - { - return featuresEnabled & (1 << QQuickProfiler::ProfileSceneGraph); - } static void initialize(QObject *parent); virtual ~QQuickProfiler(); +signals: + void dataReady(const QVector<QQuickProfilerData> &data); + protected: friend class QQuickProfilerAdapter; @@ -347,16 +315,54 @@ protected: m_data.append(message); } -signals: - void dataReady(const QVector<QQuickProfilerData> &data); - -protected slots: void startProfilingImpl(quint64 features); void stopProfilingImpl(); - void reportDataImpl(); + void reportDataImpl(bool trackLocations); void setTimer(const QElapsedTimer &t); }; +#endif // QT_NO_QML_DEBUGGER + +#define Q_QUICK_PROFILE(feature, Method)\ + Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method) + +#define Q_QUICK_SG_PROFILE_START(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::startSceneGraphFrame<Type>())) + +#define Q_QUICK_SG_PROFILE_RECORD(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::recordSceneGraphTimestamp<Type>())) + +#define Q_QUICK_SG_PROFILE_SKIP(Type, Skip)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::skipSceneGraphTimestamps<Type, Skip>())) + +#define Q_QUICK_SG_PROFILE_START_SYNCHRONIZED(Type1, Type2)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::startSceneGraphFrame<Type1, Type2>())) + +#define Q_QUICK_SG_PROFILE_SWITCH(Type1, Type2) \ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type1, true, Type2>())) + +#define Q_QUICK_SG_PROFILE_REPORT(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, false>())) + +#define Q_QUICK_SG_PROFILE_END(Type)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, true>())) + +#define Q_QUICK_SG_PROFILE_END_WITH_PAYLOAD(Type, Payload)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileSceneGraph,\ + (QQuickProfiler::reportSceneGraphFrame<Type, true>(Payload))) + + +#define Q_QUICK_INPUT_PROFILE(Type, DetailType, A, B)\ + Q_QUICK_PROFILE_IF_ENABLED(QQuickProfiler::ProfileInputEvents,\ + (QQuickProfiler::inputEvent<Type, DetailType>(A, B))) + QT_END_NAMESPACE #endif diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp index 0119aecb7e..37a910876e 100644 --- a/src/quick/util/qquickpropertychanges.cpp +++ b/src/quick/util/qquickpropertychanges.cpp @@ -46,7 +46,6 @@ #include <private/qqmlcustomparser_p.h> #include <qqmlexpression.h> #include <private/qqmlbinding_p.h> -#include <private/qqmlcompiler_p.h> #include <qqmlcontext.h> #include <private/qqmlproperty_p.h> #include <private/qqmlcontext_p.h> @@ -202,7 +201,7 @@ public: QPointer<QObject> object; QList<const QV4::CompiledData::Binding *> bindings; - QQmlRefPointer<QQmlCompiledData> cdata; + QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit; bool decoded : 1; bool restore : 1; @@ -257,8 +256,8 @@ void QQuickPropertyChangesPrivate::decode() if (decoded) return; - foreach (const QV4::CompiledData::Binding *binding, bindings) - decodeBinding(QString(), cdata->compilationUnit->data, binding); + for (const QV4::CompiledData::Binding *binding : qAsConst(bindings)) + decodeBinding(QString(), compilationUnit->data, binding); bindings.clear(); @@ -288,7 +287,7 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix, QQuickReplaceSignalHandler *handler = new QQuickReplaceSignalHandler; handler->property = prop; handler->expression.take(new QQmlBoundSignalExpression(object, QQmlPropertyPrivate::get(prop)->signalIndex(), - QQmlContextData::get(qmlContext(q)), object, cdata->compilationUnit->runtimeFunctions[binding->value.compiledScriptIndex])); + QQmlContextData::get(qmlContext(q)), object, compilationUnit->runtimeFunctions.at(binding->value.compiledScriptIndex))); signalReplacements << handler; return; } @@ -338,12 +337,12 @@ void QQuickPropertyChangesParser::verifyBindings(const QV4::CompiledData::Unit * verifyList(qmlUnit, props.at(ii)); } -void QQuickPropertyChangesParser::applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings) +void QQuickPropertyChangesParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) { QQuickPropertyChangesPrivate *p = static_cast<QQuickPropertyChangesPrivate *>(QObjectPrivate::get(obj)); p->bindings = bindings; - p->cdata = cdata; + p->compilationUnit = compilationUnit; p->decoded = false; } @@ -456,12 +455,14 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions() QQmlBinding *newBinding = 0; if (e.id != QQmlBinding::Invalid) { QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->cdata->compilationUnit->runtimeFunctions[e.id])); - newBinding = new QQmlBinding(function, object(), context); + QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, object(), d->compilationUnit->runtimeFunctions.at(e.id))); + newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, + function, object(), context); } // QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0; if (!newBinding) - newBinding = new QQmlBinding(e.expression, object(), context, e.url.toString(), e.line, e.column); + newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core, + e.expression, object(), context, e.url.toString(), e.line, e.column); if (d->isExplicit) { // in this case, we don't want to assign a binding, per se, @@ -596,7 +597,7 @@ void QQuickPropertyChanges::changeValue(const QString &name, const QVariant &val state()->addEntryToRevertList(action); QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(action.property); if (oldBinding) - oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + oldBinding->setEnabled(false, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); d->property(name).write(value); } } @@ -625,9 +626,12 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString if (entry.name == name) { entry.expression = expression; if (state() && state()->isStateActive()) { - QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this)); - newBinding->setTarget(d->property(name)); - QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + auto prop = d->property(name); + QQmlBinding *newBinding = QQmlBinding::create( + &QQmlPropertyPrivate::get(prop)->core, expression, object(), + qmlContext(this)); + newBinding->setTarget(prop); + QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); } return; } @@ -640,13 +644,16 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString if (hadValue) { QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(d->property(name)); if (oldBinding) { - oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + oldBinding->setEnabled(false, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); state()->changeBindingInRevertList(object(), name, oldBinding); } - QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this)); - newBinding->setTarget(d->property(name)); - QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + auto prop = d->property(name); + QQmlBinding *newBinding = QQmlBinding::create( + &QQmlPropertyPrivate::get(prop)->core, expression, object(), + qmlContext(this)); + newBinding->setTarget(prop); + QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); } else { QQuickStateAction action; action.restore = restoreEntryValues(); @@ -655,7 +662,9 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString action.specifiedObject = object(); action.specifiedProperty = name; - QQmlBinding *newBinding = new QQmlBinding(expression, object(), qmlContext(this)); + QQmlBinding *newBinding = QQmlBinding::create( + &QQmlPropertyPrivate::get(action.property)->core, expression, + object(), qmlContext(this)); if (d->isExplicit) { // don't assign the binding, merely evaluate the expression. // XXX TODO: add a static QQmlJavaScriptExpression::evaluate(QString) @@ -670,9 +679,9 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString state()->addEntryToRevertList(action); QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(action.property); if (oldBinding) - oldBinding->setEnabled(false, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + oldBinding->setEnabled(false, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); - QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyPrivate::DontRemoveBinding | QQmlPropertyPrivate::BypassInterceptor); + QQmlPropertyPrivate::setBinding(newBinding, QQmlPropertyPrivate::None, QQmlPropertyData::DontRemoveBinding | QQmlPropertyData::BypassInterceptor); } } } diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h index 9d086b7688..0537750338 100644 --- a/src/quick/util/qquickpropertychanges_p.h +++ b/src/quick/util/qquickpropertychanges_p.h @@ -104,7 +104,7 @@ public: void verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding); virtual void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props); - virtual void applyBindings(QObject *obj, QQmlCompiledData *cdata, const QList<const QV4::CompiledData::Binding *> &bindings); + virtual void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings); }; diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp index b7eadf5e30..e7beee8ed3 100644 --- a/src/quick/util/qquicksmoothedanimation.cpp +++ b/src/quick/util/qquicksmoothedanimation.cpp @@ -254,8 +254,8 @@ void QSmoothedAnimation::updateCurrentTime(int t) qreal value = easeFollow(time_seconds); value *= (invert? -1.0: 1.0); QQmlPropertyPrivate::write(target, initialValue + value, - QQmlPropertyPrivate::BypassInterceptor - | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyData::BypassInterceptor + | QQmlPropertyData::DontRemoveBinding); } void QSmoothedAnimation::init() @@ -287,8 +287,8 @@ void QSmoothedAnimation::init() break; case QQuickSmoothedAnimation::Sync: QQmlPropertyPrivate::write(target, to, - QQmlPropertyPrivate::BypassInterceptor - | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyData::BypassInterceptor + | QQmlPropertyData::DontRemoveBinding); trackVelocity = 0; stop(); return; @@ -304,8 +304,8 @@ void QSmoothedAnimation::init() if (!recalc()) { QQmlPropertyPrivate::write(target, to, - QQmlPropertyPrivate::BypassInterceptor - | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyData::BypassInterceptor + | QQmlPropertyData::DontRemoveBinding); stop(); return; } @@ -377,9 +377,8 @@ QQuickSmoothedAnimation::~QQuickSmoothedAnimation() } QQuickSmoothedAnimationPrivate::QQuickSmoothedAnimationPrivate() - : anim(0) + : anim(new QSmoothedAnimation) { - anim = new QSmoothedAnimation; } QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate() @@ -393,7 +392,7 @@ QQuickSmoothedAnimationPrivate::~QQuickSmoothedAnimationPrivate() void QQuickSmoothedAnimationPrivate::updateRunningAnimations() { - foreach(QSmoothedAnimation* ease, activeAnimations.values()){ + for (QSmoothedAnimation *ease : qAsConst(activeAnimations)) { ease->maximumEasingTime = anim->maximumEasingTime; ease->reversingMode = anim->reversingMode; ease->velocity = anim->velocity; @@ -410,7 +409,7 @@ QAbstractAnimationJob* QQuickSmoothedAnimation::transition(QQuickStateActions &a Q_UNUSED(direction); Q_D(QQuickSmoothedAnimation); - QQuickStateActions dataActions = QQuickPropertyAnimation::createTransitionActions(actions, modified, defaultTarget); + const QQuickStateActions dataActions = QQuickPropertyAnimation::createTransitionActions(actions, modified, defaultTarget); QContinuingAnimationGroupJob *wrapperGroup = new QContinuingAnimationGroupJob(); @@ -445,7 +444,8 @@ QAbstractAnimationJob* QQuickSmoothedAnimation::transition(QQuickStateActions &a anims.insert(ease); } - foreach (QSmoothedAnimation *ease, d->activeAnimations.values()){ + const auto copy = d->activeAnimations; + for (QSmoothedAnimation *ease : copy) { if (!anims.contains(ease)) { ease->clearTemplate(); d->activeAnimations.remove(ease->target); diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp index df077350e9..294122150a 100644 --- a/src/quick/util/qquickspringanimation.cpp +++ b/src/quick/util/qquickspringanimation.cpp @@ -301,8 +301,8 @@ void QSpringAnimation::updateCurrentTime(int time) qreal old_to = to; QQmlPropertyPrivate::write(target, currentValue, - QQmlPropertyPrivate::BypassInterceptor | - QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyData::BypassInterceptor | + QQmlPropertyData::DontRemoveBinding); if (stopped && old_to == to) { // do not stop if we got restarted if (animationTemplate) @@ -585,7 +585,8 @@ QAbstractAnimationJob* QQuickSpringAnimation::transition(QQuickStateActions &act animation->restart(); anims.insert(animation); } - foreach (QSpringAnimation *anim, d->activeAnimations.values()){ + const auto copy = d->activeAnimations; + for (QSpringAnimation *anim : copy) { if (!anims.contains(anim)) { anim->clearTemplate(); d->activeAnimations.remove(anim->target); diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp index 947a5b6e4e..2d3934cce8 100644 --- a/src/quick/util/qquickstate.cpp +++ b/src/quick/util/qquickstate.cpp @@ -334,7 +334,7 @@ QQuickStatePrivate::generateActionList() const } } - foreach(QQuickStateOperation *op, operations) + for (QQuickStateOperation *op : operations) applyList << op->actions(); inState = false; @@ -676,7 +676,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert) #ifndef QT_NO_DEBUG_STREAM // Output for debugging if (stateChangeDebug()) { - foreach(const QQuickStateAction &action, applyList) { + for (const QQuickStateAction &action : qAsConst(applyList)) { if (action.event) qWarning() << " QQuickStateAction event:" << action.event->type(); else diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index c163b401fb..200f243a1b 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -44,7 +44,6 @@ #include <private/qqmlbinding_p.h> #include <private/qqmlglobal_p.h> -#include <QtCore/qstringbuilder.h> #include <QtCore/qstringlist.h> #include <QtCore/qdebug.h> #include <QtCore/qvector.h> @@ -306,7 +305,7 @@ void QQuickStateGroup::componentComplete() for (int ii = 0; ii < d->states.count(); ++ii) { QQuickState *state = d->states.at(ii); if (!state->isNamed()) - state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); + state->setName(QLatin1String("anonymousState") + QString::number(++d->unnamedCount)); } if (d->updateAutoState()) { diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp index 74baa3bfda..b3f0caa2b3 100644 --- a/src/quick/util/qquicktimeline.cpp +++ b/src/quick/util/qquicktimeline.cpp @@ -154,7 +154,7 @@ void QQuickTimeLinePrivate::add(QQuickTimeLineObject &g, const Op &o) } if (!iter->ops.isEmpty() && o.type == Op::Pause && - iter->ops.last().type == Op::Pause) { + iter->ops.constLast().type == Op::Pause) { iter->ops.last().length += o.length; iter->length += o.length; } else { diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp index 55abb0a207..714e6d62b6 100644 --- a/src/quick/util/qquicktransitionmanager.cpp +++ b/src/quick/util/qquicktransitionmanager.cpp @@ -106,7 +106,7 @@ void QQuickTransitionManager::complete() void QQuickTransitionManagerPrivate::applyBindings() { - foreach(const QQuickStateAction &action, bindingsList) { + for (const QQuickStateAction &action : qAsConst(bindingsList)) { if (action.toBinding) { QQmlPropertyPrivate::setBinding(action.toBinding.data()); } else if (action.event) { @@ -133,7 +133,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, QQuickStateOperation::ActionList applyList = list; // Determine which actions are binding changes and disable any current bindings - foreach(const QQuickStateAction &action, applyList) { + for (const QQuickStateAction &action : qAsConst(applyList)) { if (action.toBinding) d->bindingsList << action; if (action.fromBinding) @@ -159,9 +159,9 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, for (int ii = 0; ii < applyList.size(); ++ii) { const QQuickStateAction &action = applyList.at(ii); if (action.toBinding) { - QQmlPropertyPrivate::setBinding(action.toBinding.data(), QQmlPropertyPrivate::None, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::setBinding(action.toBinding.data(), QQmlPropertyPrivate::None, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } else if (!action.event) { - QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(action.property, action.toValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } else if (action.event->isReversable()) { if (action.reverseEvent) action.event->reverse(); @@ -184,7 +184,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, } // Revert back to the original values - foreach(const QQuickStateAction &action, applyList) { + for (const QQuickStateAction &action : qAsConst(applyList)) { if (action.event) { if (action.event->isReversable()) { action.event->clearBindings(); @@ -197,7 +197,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, if (action.toBinding) QQmlPropertyPrivate::removeBinding(action.property); // Make sure this is disabled during the transition - QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyPrivate::BypassInterceptor | QQmlPropertyPrivate::DontRemoveBinding); + QQmlPropertyPrivate::write(action.property, action.fromValue, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding); } } @@ -239,7 +239,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, // be applied immediately. We skip applying bindings, as they are all // applied at the end in applyBindings() to avoid any nastiness mid // transition - foreach(const QQuickStateAction &action, applyList) { + for (const QQuickStateAction &action : qAsConst(applyList)) { if (action.event && !action.event->changesBindings()) { if (action.event->isReversable() && action.reverseEvent) action.event->reverse(); @@ -251,7 +251,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list, } #ifndef QT_NO_DEBUG_STREAM if (stateChangeDebug()) { - foreach(const QQuickStateAction &action, applyList) { + for (const QQuickStateAction &action : qAsConst(applyList)) { if (action.event) qWarning() << " No transition for event:" << action.event->type(); else diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp index f5d11c6230..7e2973a78b 100644 --- a/src/quick/util/qquickutilmodule.cpp +++ b/src/quick/util/qquickutilmodule.cpp @@ -107,8 +107,9 @@ void QQuickUtilModule::defineModule() qmlRegisterType<QQuickScaleAnimator>("QtQuick", 2, 2, "ScaleAnimator"); qmlRegisterType<QQuickRotationAnimator>("QtQuick", 2, 2, "RotationAnimator"); qmlRegisterType<QQuickOpacityAnimator>("QtQuick", 2, 2, "OpacityAnimator"); +#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) qmlRegisterType<QQuickUniformAnimator>("QtQuick", 2, 2, "UniformAnimator"); - +#endif qmlRegisterType<QQuickStateOperation>(); qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser); diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp index 416a325238..e673df0451 100644 --- a/src/quick/util/qquickvaluetypes.cpp +++ b/src/quick/util/qquickvaluetypes.cpp @@ -80,6 +80,36 @@ qreal QQuickColorValueType::a() const return v.alphaF(); } +qreal QQuickColorValueType::hsvHue() const +{ + return v.hsvHueF(); +} + +qreal QQuickColorValueType::hsvSaturation() const +{ + return v.hsvSaturationF(); +} + +qreal QQuickColorValueType::hsvValue() const +{ + return v.valueF(); +} + +qreal QQuickColorValueType::hslHue() const +{ + return v.hslHueF(); +} + +qreal QQuickColorValueType::hslSaturation() const +{ + return v.hslSaturationF(); +} + +qreal QQuickColorValueType::hslLightness() const +{ + return v.lightnessF(); +} + void QQuickColorValueType::setR(qreal r) { v.setRedF(r); @@ -100,6 +130,48 @@ void QQuickColorValueType::setA(qreal a) v.setAlphaF(a); } +void QQuickColorValueType::setHsvHue(qreal hsvHue) +{ + qreal hue, saturation, value, alpha; + v.getHsvF(&hue, &saturation, &value, &alpha); + v.setHsvF(hsvHue, saturation, value, alpha); +} + +void QQuickColorValueType::setHsvSaturation(qreal hsvSaturation) +{ + qreal hue, saturation, value, alpha; + v.getHsvF(&hue, &saturation, &value, &alpha); + v.setHsvF(hue, hsvSaturation, value, alpha); +} + +void QQuickColorValueType::setHsvValue(qreal hsvValue) +{ + qreal hue, saturation, value, alpha; + v.getHsvF(&hue, &saturation, &value, &alpha); + v.setHsvF(hue, saturation, hsvValue, alpha); +} + +void QQuickColorValueType::setHslHue(qreal hslHue) +{ + qreal hue, saturation, lightness, alpha; + v.getHslF(&hue, &saturation, &lightness, &alpha); + v.setHslF(hslHue, saturation, lightness, alpha); +} + +void QQuickColorValueType::setHslSaturation(qreal hslSaturation) +{ + qreal hue, saturation, lightness, alpha; + v.getHslF(&hue, &saturation, &lightness, &alpha); + v.setHslF(hue, hslSaturation, lightness, alpha); +} + +void QQuickColorValueType::setHslLightness(qreal hslLightness) +{ + qreal hue, saturation, lightness, alpha; + v.getHslF(&hue, &saturation, &lightness, &alpha); + v.setHslF(hue, saturation, hslLightness, alpha); +} + QString QQuickVector2DValueType::toString() const { return QString(QLatin1String("QVector2D(%1, %2)")).arg(v.x()).arg(v.y()); @@ -676,4 +748,14 @@ void QQuickFontValueType::setWordSpacing(qreal size) v.setWordSpacing(size); } +QQuickFontValueType::HintingPreference QQuickFontValueType::hintingPreference() const +{ + return QQuickFontValueType::HintingPreference(v.hintingPreference()); +} + +void QQuickFontValueType::setHintingPreference(QQuickFontValueType::HintingPreference hintingPreference) +{ + v.setHintingPreference(QFont::HintingPreference(hintingPreference)); +} + QT_END_NAMESPACE diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h index 80b9ce3109..4a1598ec5c 100644 --- a/src/quick/util/qquickvaluetypes_p.h +++ b/src/quick/util/qquickvaluetypes_p.h @@ -78,6 +78,12 @@ class QQuickColorValueType Q_PROPERTY(qreal g READ g WRITE setG FINAL) Q_PROPERTY(qreal b READ b WRITE setB FINAL) Q_PROPERTY(qreal a READ a WRITE setA FINAL) + Q_PROPERTY(qreal hsvHue READ hsvHue WRITE setHsvHue FINAL) + Q_PROPERTY(qreal hsvSaturation READ hsvSaturation WRITE setHsvSaturation FINAL) + Q_PROPERTY(qreal hsvValue READ hsvValue WRITE setHsvValue FINAL) + Q_PROPERTY(qreal hslHue READ hslHue WRITE setHslHue FINAL) + Q_PROPERTY(qreal hslSaturation READ hslSaturation WRITE setHslSaturation FINAL) + Q_PROPERTY(qreal hslLightness READ hslLightness WRITE setHslLightness FINAL) Q_GADGET public: Q_INVOKABLE QString toString() const; @@ -86,10 +92,22 @@ public: qreal g() const; qreal b() const; qreal a() const; + qreal hsvHue() const; + qreal hsvSaturation() const; + qreal hsvValue() const; + qreal hslHue() const; + qreal hslSaturation() const; + qreal hslLightness() const; void setR(qreal); void setG(qreal); void setB(qreal); void setA(qreal); + void setHsvHue(qreal); + void setHsvSaturation(qreal); + void setHsvValue(qreal); + void setHslHue(qreal); + void setHslSaturation(qreal); + void setHslLightness(qreal); }; class QQuickVector2DValueType @@ -304,6 +322,7 @@ class QQuickFontValueType Q_PROPERTY(Capitalization capitalization READ capitalization WRITE setCapitalization FINAL) 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) public: enum FontWeight { Thin = QFont::Thin, @@ -323,6 +342,14 @@ public: Capitalize = QFont::Capitalize }; Q_ENUM(Capitalization) + enum HintingPreference { + PreferDefaultHinting = QFont::PreferDefaultHinting, + PreferNoHinting = QFont::PreferNoHinting, + PreferVerticalHinting = QFont::PreferVerticalHinting, + PreferFullHinting = QFont::PreferFullHinting + }; + Q_ENUM(HintingPreference) + Q_INVOKABLE QString toString() const; QString family() const; @@ -363,6 +390,9 @@ public: qreal wordSpacing() const; void setWordSpacing(qreal spacing); + + HintingPreference hintingPreference() const; + void setHintingPreference(HintingPreference); }; QT_END_NAMESPACE diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri index ffb31ae75e..1ef1018a31 100644 --- a/src/quick/util/util.pri +++ b/src/quick/util/util.pri @@ -17,8 +17,6 @@ SOURCES += \ $$PWD/qquickbehavior.cpp \ $$PWD/qquickfontloader.cpp \ $$PWD/qquickstyledtext.cpp \ - $$PWD/qquickpath.cpp \ - $$PWD/qquickpathinterpolator.cpp \ $$PWD/qquickimageprovider.cpp \ $$PWD/qquicksvgparser.cpp \ $$PWD/qquickvaluetypes.cpp \ @@ -26,12 +24,13 @@ SOURCES += \ $$PWD/qquickanimator.cpp \ $$PWD/qquickanimatorjob.cpp \ $$PWD/qquickanimatorcontroller.cpp \ - $$PWD/qquickprofiler.cpp \ $$PWD/qquickfontmetrics.cpp \ $$PWD/qquicktextmetrics.cpp \ $$PWD/qquickshortcut.cpp \ $$PWD/qquickvalidator.cpp +!contains(QT_CONFIG, no-qml-debug): SOURCES += $$PWD/qquickprofiler.cpp + HEADERS += \ $$PWD/qquickapplication_p.h\ $$PWD/qquickutilmodule_p.h\ @@ -54,9 +53,6 @@ HEADERS += \ $$PWD/qquickbehavior_p.h \ $$PWD/qquickfontloader_p.h \ $$PWD/qquickstyledtext_p.h \ - $$PWD/qquickpath_p.h \ - $$PWD/qquickpath_p_p.h \ - $$PWD/qquickpathinterpolator_p.h \ $$PWD/qquickimageprovider.h \ $$PWD/qquicksvgparser_p.h \ $$PWD/qquickvaluetypes_p.h \ @@ -69,3 +65,13 @@ HEADERS += \ $$PWD/qquicktextmetrics_p.h \ $$PWD/qquickshortcut_p.h \ $$PWD/qquickvalidator_p.h + +qtConfig(quick-path) { + SOURCES += \ + $$PWD/qquickpath.cpp \ + $$PWD/qquickpathinterpolator.cpp + HEADERS += \ + $$PWD/qquickpath_p.h \ + $$PWD/qquickpath_p_p.h \ + $$PWD/qquickpathinterpolator_p.h +} |