diff options
Diffstat (limited to 'src/quick/util')
36 files changed, 503 insertions, 90 deletions
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h index 7bad9d50c4..b86533eb3f 100644 --- a/src/quick/util/qquickanimation_p.h +++ b/src/quick/util/qquickanimation_p.h @@ -81,6 +81,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAbstractAnimation : public QObject, public QQ Q_CLASSINFO("DefaultMethod", "start()") QML_NAMED_ELEMENT(Animation) + QML_ADDED_IN_VERSION(2, 0) QML_UNCREATABLE("Animation is an abstract class") public: @@ -129,7 +130,7 @@ Q_SIGNALS: void pausedChanged(bool); void alwaysRunToEndChanged(bool); void loopCountChanged(int); - Q_REVISION(12) void finished(); + Q_REVISION(2, 12) void finished(); public Q_SLOTS: void restart(); @@ -169,6 +170,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimati Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) QML_NAMED_ELEMENT(PauseAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPauseAnimation(QObject *parent=nullptr); @@ -196,6 +198,7 @@ class QQuickScriptAction : public QQuickAbstractAnimation Q_PROPERTY(QQmlScriptString script READ script WRITE setScript) Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName) QML_NAMED_ELEMENT(ScriptAction) + QML_ADDED_IN_VERSION(2, 0) public: QQuickScriptAction(QObject *parent=nullptr); @@ -227,6 +230,7 @@ class QQuickPropertyAction : public QQuickAbstractAnimation Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) QML_NAMED_ELEMENT(PropertyAction) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPropertyAction(QObject *parent=nullptr); @@ -276,6 +280,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnim Q_PROPERTY(QQmlListProperty<QObject> targets READ targets) Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude) QML_NAMED_ELEMENT(PropertyAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPropertyAnimation(QObject *parent=nullptr); @@ -332,6 +337,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimati Q_PROPERTY(QColor from READ from WRITE setFrom) Q_PROPERTY(QColor to READ to WRITE setTo) QML_NAMED_ELEMENT(ColorAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickColorAnimation(QObject *parent=nullptr); @@ -352,6 +358,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimat Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) QML_NAMED_ELEMENT(NumberAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickNumberAnimation(QObject *parent=nullptr); @@ -378,6 +385,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnim Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged) Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged) QML_NAMED_ELEMENT(Vector3dAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickVector3dAnimation(QObject *parent=nullptr); @@ -400,6 +408,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnim Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) QML_NAMED_ELEMENT(RotationAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickRotationAnimation(QObject *parent=nullptr); @@ -445,6 +454,7 @@ class QQuickSequentialAnimation : public QQuickAnimationGroup Q_OBJECT Q_DECLARE_PRIVATE(QQuickAnimationGroup) QML_NAMED_ELEMENT(SequentialAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickSequentialAnimation(QObject *parent=nullptr); @@ -463,6 +473,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGro Q_OBJECT Q_DECLARE_PRIVATE(QQuickAnimationGroup) QML_NAMED_ELEMENT(ParallelAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickParallelAnimation(QObject *parent=nullptr); diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h index da6df6038a..de308735ef 100644 --- a/src/quick/util/qquickanimationcontroller_p.h +++ b/src/quick/util/qquickanimationcontroller_p.h @@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlP Q_DECLARE_PRIVATE(QQuickAnimationController) Q_CLASSINFO("DefaultProperty", "animation") QML_NAMED_ELEMENT(AnimationController) + QML_ADDED_IN_VERSION(2, 0) Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged) Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged) diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h index 9f7aaafcb0..0bcf4c40a4 100644 --- a/src/quick/util/qquickanimator_p.h +++ b/src/quick/util/qquickanimator_p.h @@ -70,7 +70,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnimator : public QQuickAbstractAnimation Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) QML_NAMED_ELEMENT(Animator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) QML_UNCREATABLE("Animator is an abstract class") public: @@ -114,7 +114,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator { Q_OBJECT QML_NAMED_ELEMENT(ScaleAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: QQuickScaleAnimator(QObject *parent = nullptr); protected: @@ -126,7 +126,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator { Q_OBJECT QML_NAMED_ELEMENT(XAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: QQuickXAnimator(QObject *parent = nullptr); protected: @@ -138,7 +138,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator { Q_OBJECT QML_NAMED_ELEMENT(YAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: QQuickYAnimator(QObject *parent = nullptr); protected: @@ -150,7 +150,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator { Q_OBJECT QML_NAMED_ELEMENT(OpacityAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: QQuickOpacityAnimator(QObject *parent = nullptr); protected: @@ -165,7 +165,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimator : public QQuickAnimator Q_DECLARE_PRIVATE(QQuickRotationAnimator) Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) QML_NAMED_ELEMENT(RotationAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; @@ -192,7 +192,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator Q_DECLARE_PRIVATE(QQuickUniformAnimator) Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged) QML_NAMED_ELEMENT(UniformAnimator) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) public: QQuickUniformAnimator(QObject *parent = nullptr); diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 0112a4b337..7b6b8bc878 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -48,6 +48,7 @@ # include <private/qquickopenglshadereffectnode_p.h> # include <private/qquickopenglshadereffect_p.h> # include <private/qquickshadereffect_p.h> +# include <QOpenGLContext> #endif #include <private/qanimationgroupjob_p.h> diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h index b0eb6fa604..a740067bf3 100644 --- a/src/quick/util/qquickapplication_p.h +++ b/src/quick/util/qquickapplication_p.h @@ -72,6 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged) QML_NAMED_ELEMENT(Application) + QML_ADDED_IN_VERSION(2, 0) QML_UNCREATABLE("Application is an abstract class.") public: diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp index eee8562a2a..ceda5589b2 100644 --- a/src/quick/util/qquickbehavior.cpp +++ b/src/quick/util/qquickbehavior.cpp @@ -185,6 +185,80 @@ QVariant QQuickBehavior::targetValue() const return d->targetValue; } +/*! + \readonly + \qmlpropertygroup QtQuick::Behavior::targetProperty + \qmlproperty string QtQuick::Behavior::targetProperty.name + \qmlproperty Object QtQuick::Behavior::targetProperty.object + + \table + \header + \li Property + \li Description + \row + \li name + \li This property holds the name of the property being controlled by this Behavior. + \row + \li object + \li This property holds the object of the property being controlled by this Behavior. + \endtable + + This property can be used to define custom behaviors based on the name or the object of + the property being controlled. + + The following example defines a Behavior fading out and fading in its target object + when the property it controls changes: + \qml + // FadeBehavior.qml + import QtQuick 2.15 + + Behavior { + id: root + property Item fadeTarget: targetProperty.object + SequentialAnimation { + NumberAnimation { + target: root.fadeTarget + property: "opacity" + to: 0 + easing.type: Easing.InQuad + } + PropertyAction { } // actually change the controlled property between the 2 other animations + NumberAnimation { + target: root.fadeTarget + property: "opacity" + to: 1 + easing.type: Easing.OutQuad + } + } + } + \endqml + + This can be used to animate a text when it changes: + \qml + import QtQuick 2.15 + + Text { + id: root + property int counter + text: counter + FadeBehavior on text {} + Timer { + running: true + repeat: true + interval: 1000 + onTriggered: ++root.counter + } + } + \endqml + + \since QtQuick 2.15 +*/ +QQmlProperty QQuickBehavior::targetProperty() const +{ + Q_D(const QQuickBehavior); + return d->property; +} + void QQuickBehavior::write(const QVariant &value) { Q_D(QQuickBehavior); @@ -265,6 +339,8 @@ void QQuickBehavior::setTarget(const QQmlProperty &property) if (finalizedIdx < 0) finalizedIdx = metaObject()->indexOfSlot("componentFinalized()"); engPriv->registerFinalizeCallback(this, finalizedIdx); + + Q_EMIT targetPropertyChanged(); } void QQuickBehavior::componentFinalized() diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h index fa9cf6d6bc..1ce687ac44 100644 --- a/src/quick/util/qquickbehavior_p.h +++ b/src/quick/util/qquickbehavior_p.h @@ -69,9 +69,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropert Q_CLASSINFO("DefaultProperty", "animation") Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION 13) + Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION(2, 13)) + Q_PROPERTY(QQmlProperty targetProperty READ targetProperty NOTIFY targetPropertyChanged REVISION(2, 15)) Q_CLASSINFO("DeferredPropertyNames", "animation") QML_NAMED_ELEMENT(Behavior) + QML_ADDED_IN_VERSION(2, 0) public: QQuickBehavior(QObject *parent=nullptr); @@ -88,9 +90,12 @@ public: QVariant targetValue() const; + QQmlProperty targetProperty() const; + Q_SIGNALS: void enabledChanged(); void targetValueChanged(); + void targetPropertyChanged(); private Q_SLOTS: void componentFinalized(); diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp index addf8b0c18..63aba04c34 100644 --- a/src/quick/util/qquickfontloader.cpp +++ b/src/quick/util/qquickfontloader.cpp @@ -121,7 +121,7 @@ void QQuickFontObject::replyFinished() } redirectCount = 0; - if (!reply->networkError()) { + if (!reply->error()) { id = QFontDatabase::addApplicationFontFromData(reply->readAll()); if (id != -1) emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QQuickFontLoader::Ready); diff --git a/src/quick/util/qquickfontloader_p.h b/src/quick/util/qquickfontloader_p.h index c0247cee3a..8d831dac4d 100644 --- a/src/quick/util/qquickfontloader_p.h +++ b/src/quick/util/qquickfontloader_p.h @@ -68,6 +68,7 @@ class Q_AUTOTEST_EXPORT QQuickFontLoader : public QObject Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) QML_NAMED_ELEMENT(FontLoader) + QML_ADDED_IN_VERSION(2, 0) public: enum Status { Null = 0, Ready, Loading, Error }; diff --git a/src/quick/util/qquickfontmetrics_p.h b/src/quick/util/qquickfontmetrics_p.h index ee6d679649..59f4aa8355 100644 --- a/src/quick/util/qquickfontmetrics_p.h +++ b/src/quick/util/qquickfontmetrics_p.h @@ -80,7 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickFontMetrics : public QObject Q_PROPERTY(qreal strikeOutPosition READ strikeOutPosition NOTIFY fontChanged) Q_PROPERTY(qreal lineWidth READ lineWidth NOTIFY fontChanged) QML_NAMED_ELEMENT(FontMetrics) - QML_ADDED_IN_MINOR_VERSION(4) + QML_ADDED_IN_VERSION(2, 4) public: explicit QQuickFontMetrics(QObject *parent = nullptr); ~QQuickFontMetrics(); diff --git a/src/quick/util/qquickforeignutils_p.h b/src/quick/util/qquickforeignutils_p.h index 7e51bc4f82..9802420780 100644 --- a/src/quick/util/qquickforeignutils_p.h +++ b/src/quick/util/qquickforeignutils_p.h @@ -73,6 +73,7 @@ struct QValidatorForeign Q_GADGET QML_FOREIGN(QValidator) QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) }; struct QRegExpValidatorForeign @@ -80,6 +81,7 @@ struct QRegExpValidatorForeign Q_GADGET QML_FOREIGN(QRegExpValidator) QML_NAMED_ELEMENT(RegExpValidator) + QML_ADDED_IN_VERSION(2, 0) }; #if QT_CONFIG(regularexpression) @@ -88,7 +90,7 @@ struct QRegularExpressionValidatorForeign Q_GADGET QML_FOREIGN(QRegularExpressionValidator) QML_NAMED_ELEMENT(RegularExpressionValidator) - QML_ADDED_IN_MINOR_VERSION(14) + QML_ADDED_IN_VERSION(2, 14) }; #endif // QT_CONFIG(regularexpression) @@ -100,6 +102,7 @@ struct QInputMethodForeign Q_GADGET QML_FOREIGN(QInputMethod) QML_NAMED_ELEMENT(InputMethod) + QML_ADDED_IN_VERSION(2, 0) QML_UNCREATABLE("InputMethod is an abstract class.") }; #endif // QT_CONFIG(im) @@ -110,7 +113,7 @@ struct QKeySequenceForeign Q_GADGET QML_FOREIGN(QKeySequence) QML_NAMED_ELEMENT(StandardKey) - QML_ADDED_IN_MINOR_VERSION(2) + QML_ADDED_IN_VERSION(2, 2) QML_UNCREATABLE("Cannot create an instance of StandardKey.") }; #endif // QT_CONFIG(shortcut) diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp index 85bc78dee8..3ea2f88712 100644 --- a/src/quick/util/qquickglobal.cpp +++ b/src/quick/util/qquickglobal.cpp @@ -273,6 +273,52 @@ public: return QMatrix4x4(); } + static QColorSpace colorSpaceFromObject(const QV4::Value &object, QV4::ExecutionEngine *v4, bool *ok) + { + if (ok) + *ok = false; + QColorSpace retn; + QV4::Scope scope(v4); + QV4::ScopedObject obj(scope, object); + if (!obj) { + if (ok) + *ok = false; + return retn; + } + + QV4::ScopedString s(scope); + + QV4::ScopedValue vName(scope, obj->get((s = v4->newString(QStringLiteral("namedColorSpace"))))); + if (vName->isInt32()) { + if (ok) + *ok = true; + return QColorSpace((QColorSpace::NamedColorSpace)vName->toInt32()); + } + + QV4::ScopedValue vPri(scope, obj->get((s = v4->newString(QStringLiteral("primaries"))))); + QV4::ScopedValue vTra(scope, obj->get((s = v4->newString(QStringLiteral("transferFunction"))))); + if (!vPri->isInt32() || !vTra->isInt32()) { + if (ok) + *ok = false; + return retn; + } + + QColorSpace::Primaries pri = static_cast<QColorSpace::Primaries>(vPri->integerValue()); + QColorSpace::TransferFunction tra = static_cast<QColorSpace::TransferFunction>(vTra->integerValue()); + float gamma = 0.0f; + if (tra == QColorSpace::TransferFunction::Gamma) { + QV4::ScopedValue vGam(scope, obj->get((s = v4->newString(QStringLiteral("gamma"))))); + if (!vGam->isNumber()) { + if (ok) + *ok = false; + return retn; + } + gamma = vGam->toNumber(); + } + if (ok) *ok = true; + return QColorSpace(pri, tra, gamma); + } + static QFont fontFromObject(const QV4::Value &object, QV4::ExecutionEngine *v4, bool *ok) { if (ok) @@ -402,6 +448,8 @@ public: switch (type) { case QMetaType::QColor: return &QQuickColorValueType::staticMetaObject; + case QMetaType::QColorSpace: + return &QQuickColorSpaceValueType::staticMetaObject; case QMetaType::QFont: return &QQuickFontValueType::staticMetaObject; case QMetaType::QVector2D: @@ -427,6 +475,9 @@ public: case QMetaType::QColor: dst.setValue<QColor>(QColor()); return true; + case QMetaType::QColorSpace: + dst.setValue<QColorSpace>(QColorSpace()); + return true; case QMetaType::QFont: dst.setValue<QFont>(QFont()); return true; @@ -647,6 +698,9 @@ public: #endif bool ok = false; switch (type) { + case QMetaType::QColorSpace: + *v = QVariant::fromValue(colorSpaceFromObject(object, v4, &ok)); + break; case QMetaType::QFont: *v = QVariant::fromValue(fontFromObject(object, v4, &ok)); break; @@ -669,6 +723,8 @@ public: switch (type) { case QMetaType::QColor: return typedEqual<QColor>(lhs, rhs); + case QMetaType::QColorSpace: + return typedEqual<QColorSpace>(lhs, rhs); case QMetaType::QFont: return typedEqual<QFont>(lhs, rhs); case QMetaType::QVector2D: @@ -732,6 +788,8 @@ public: switch (dstType) { case QMetaType::QColor: return typedRead<QColor>(src, dstType, dst); + case QMetaType::QColorSpace: + return typedRead<QColorSpace>(src, dstType, dst); case QMetaType::QFont: return typedRead<QFont>(src, dstType, dst); case QMetaType::QVector2D: @@ -766,6 +824,8 @@ public: switch (type) { case QMetaType::QColor: return typedWrite<QColor>(src, dst); + case QMetaType::QColorSpace: + return typedWrite<QColorSpace>(src, dst); case QMetaType::QFont: return typedWrite<QFont>(src, dst); case QMetaType::QVector2D: diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index db82b2d807..80873e2ad5 100644 --- a/src/quick/util/qquickimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -43,6 +43,7 @@ #include "qquickpixmapcache_p.h" #include <QtQuick/private/qsgcontext_p.h> #include <private/qqmlglobal_p.h> +#include <QtGui/qcolorspace.h> QT_BEGIN_NAMESPACE @@ -510,6 +511,7 @@ public: { } + QColorSpace targetColorSpace; QQuickImageProviderOptions::AutoTransform autoTransform = QQuickImageProviderOptions::UsePluginDefaultTransform; bool preserveAspectRatioCrop = false; bool preserveAspectRatioFit = false; @@ -558,7 +560,8 @@ bool QQuickImageProviderOptions::operator==(const QQuickImageProviderOptions &ot { return d->autoTransform == other.d->autoTransform && d->preserveAspectRatioCrop == other.d->preserveAspectRatioCrop && - d->preserveAspectRatioFit == other.d->preserveAspectRatioFit; + d->preserveAspectRatioFit == other.d->preserveAspectRatioFit && + d->targetColorSpace == other.d->targetColorSpace; } /*! @@ -602,6 +605,19 @@ void QQuickImageProviderOptions::setPreserveAspectRatioFit(bool preserveAspectRa d->preserveAspectRatioFit = preserveAspectRatioFit; } +/*! + Returns the color space the image provider should return the image in. +*/ +QColorSpace QQuickImageProviderOptions::targetColorSpace() const +{ + return d->targetColorSpace; +} + +void QQuickImageProviderOptions::setTargetColorSpace(const QColorSpace &colorSpace) +{ + d->targetColorSpace = colorSpace; +} + QQuickImageProviderWithOptions::QQuickImageProviderWithOptions(ImageType type, Flags flags) : QQuickAsyncImageProvider() { diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp index 375d0265e8..74ee52b1d3 100644 --- a/src/quick/util/qquickpath.cpp +++ b/src/quick/util/qquickpath.cpp @@ -2827,11 +2827,11 @@ void QQuickPathText::updatePath() const if (!_path.isEmpty()) return; - _path.addText(_x, _y, _font, _text); + _path.addText(0.0, 0.0, _font, _text); // Account for distance from baseline to top, since addText() takes baseline position QRectF brect = _path.boundingRect(); - _path.translate(0.0, -brect.y()); + _path.translate(_x, _y - brect.y()); } void QQuickPathText::addToPath(QPainterPath &path) diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index 159c46d13c..8660537587 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -79,6 +79,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathElement : public QObject { Q_OBJECT QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathElement(QObject *parent=nullptr) : QObject(parent) {} Q_SIGNALS: @@ -92,6 +93,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) QML_NAMED_ELEMENT(PathAttribute) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent) {} @@ -120,6 +122,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged) Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged) QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) public: QQuickCurve(QObject *parent=nullptr) : QQuickPathElement(parent) {} @@ -158,6 +161,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve { Q_OBJECT QML_NAMED_ELEMENT(PathLine) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathLine(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -168,7 +172,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMove : public QQuickCurve { Q_OBJECT QML_NAMED_ELEMENT(PathMove) - QML_ADDED_IN_MINOR_VERSION(9) + QML_ADDED_IN_VERSION(2, 9) public: QQuickPathMove(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -185,6 +189,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged) QML_NAMED_ELEMENT(PathQuad) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -230,6 +235,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged) Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged) QML_NAMED_ELEMENT(PathCubic) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -288,6 +294,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve { Q_OBJECT QML_NAMED_ELEMENT(PathCurve) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathCatmullRomCurve(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -301,8 +308,9 @@ 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 9) + Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION(2, 9)) QML_NAMED_ELEMENT(PathArc) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathArc(QObject *parent=nullptr) @@ -333,7 +341,7 @@ Q_SIGNALS: void radiusYChanged(); void useLargeArcChanged(); void directionChanged(); - Q_REVISION(9) void xAxisRotationChanged(); + Q_REVISION(2, 9) void xAxisRotationChanged(); private: qreal _radiusX = 0; @@ -355,7 +363,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve Q_PROPERTY(bool moveToStart READ moveToStart WRITE setMoveToStart NOTIFY moveToStartChanged) QML_NAMED_ELEMENT(PathAngleArc) - QML_ADDED_IN_MINOR_VERSION(11) + QML_ADDED_IN_VERSION(2, 11) public: QQuickPathAngleArc(QObject *parent=nullptr) @@ -408,6 +416,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve Q_OBJECT Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) QML_NAMED_ELEMENT(PathSvg) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathSvg(QObject *parent=nullptr) : QQuickCurve(parent) {} @@ -428,6 +437,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement Q_OBJECT Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) QML_NAMED_ELEMENT(PathPercent) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent) {} @@ -447,7 +457,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPolyline : public QQuickCurve Q_PROPERTY(QPointF start READ start NOTIFY startChanged) Q_PROPERTY(QVariant path READ path WRITE setPath NOTIFY pathChanged) QML_NAMED_ELEMENT(PathPolyline) - QML_ADDED_IN_MINOR_VERSION(14) + QML_ADDED_IN_VERSION(2, 14) public: QQuickPathPolyline(QObject *parent=nullptr); @@ -471,7 +481,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMultiline : public QQuickCurve Q_PROPERTY(QPointF start READ start NOTIFY startChanged) Q_PROPERTY(QVariant paths READ paths WRITE setPaths NOTIFY pathsChanged) QML_NAMED_ELEMENT(PathMultiline) - QML_ADDED_IN_MINOR_VERSION(14) + QML_ADDED_IN_VERSION(2, 14) public: QQuickPathMultiline(QObject *parent=nullptr); @@ -512,9 +522,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPath : public QObject, public QQmlParserStatu Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged) Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged) Q_PROPERTY(bool closed READ isClosed NOTIFY changed) - Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION 14) + Q_PROPERTY(QSizeF scale READ scale WRITE setScale NOTIFY scaleChanged REVISION(2, 14)) Q_CLASSINFO("DefaultProperty", "pathElements") QML_NAMED_ELEMENT(Path) + QML_ADDED_IN_VERSION(2, 0) Q_INTERFACES(QQmlParserStatus) public: QQuickPath(QObject *parent=nullptr); @@ -535,7 +546,7 @@ public: QPainterPath path() const; QStringList attributes() const; qreal attributeAt(const QString &, qreal) const; - Q_REVISION(14) Q_INVOKABLE QPointF pointAtPercent(qreal t) const; + Q_REVISION(2, 14) Q_INVOKABLE QPointF pointAtPercent(qreal t) const; QPointF sequentialPointAt(qreal p, qreal *angle = nullptr) const; void invalidateSequentialHistory() const; @@ -546,7 +557,7 @@ Q_SIGNALS: void changed(); void startXChanged(); void startYChanged(); - Q_REVISION(14) void scaleChanged(); + Q_REVISION(2, 14) void scaleChanged(); protected: QQuickPath(QQuickPathPrivate &dd, QObject *parent = nullptr); @@ -609,7 +620,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathText : public QQuickPathElement Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) QML_NAMED_ELEMENT(PathText) - QML_ADDED_IN_MINOR_VERSION(15) + QML_ADDED_IN_VERSION(2, 15) public: QQuickPathText(QObject *parent=nullptr) : QQuickPathElement(parent) { diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h index 440ea06841..70fb0935e8 100644 --- a/src/quick/util/qquickpathinterpolator_p.h +++ b/src/quick/util/qquickpathinterpolator_p.h @@ -70,6 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickPathInterpolator : public QObject Q_PROPERTY(qreal y READ y NOTIFY yChanged) Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged) QML_NAMED_ELEMENT(PathInterpolator) + QML_ADDED_IN_VERSION(2, 0) public: explicit QQuickPathInterpolator(QObject *parent = nullptr); diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index d47719389b..d96ebe70b2 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -86,6 +86,8 @@ QT_BEGIN_NAMESPACE const QLatin1String QQuickPixmap::itemGrabberScheme = QLatin1String("itemgrabber"); +Q_LOGGING_CATEGORY(lcImg, "qt.quick.image") + #ifndef QT_NO_DEBUG static const bool qsg_leak_check = !qEnvironmentVariableIsEmpty("QML_LEAK_CHECK"); #endif @@ -137,6 +139,7 @@ public: QQuickPixmapData *data; QQmlEngine *engineForReader; // always access reader inside readerMutex + QRect requestRegion; QSize requestSize; QUrl url; @@ -240,9 +243,10 @@ public: class QQuickPixmapData { public: - QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &s, const QQuickImageProviderOptions &po, const QString &e) + QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &rs, + const QQuickImageProviderOptions &po, const QString &e) : refCount(1), frameCount(1), frame(0), inCache(false), pixmapStatus(QQuickPixmap::Error), - url(u), errorString(e), requestSize(s), + url(u), errorString(e), requestRegion(r), requestSize(rs), providerOptions(po), appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform), textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) @@ -250,9 +254,10 @@ public: declarativePixmaps.insert(pixmap); } - QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1) + QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, const QRect &r, const QSize &s, const QQuickImageProviderOptions &po, + QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1) : refCount(1), frameCount(frameCount), frame(frame), inCache(false), pixmapStatus(QQuickPixmap::Loading), - url(u), requestSize(r), + url(u), requestRegion(r), requestSize(s), providerOptions(po), appliedTransform(aTransform), textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) @@ -261,9 +266,10 @@ public: } QQuickPixmapData(QQuickPixmap *pixmap, const QUrl &u, QQuickTextureFactory *texture, - const QSize &s, const QSize &r, const QQuickImageProviderOptions &po, QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1) + const QSize &s, const QRect &r, const QSize &rs, const QQuickImageProviderOptions &po, + QQuickImageProviderOptions::AutoTransform aTransform, int frame=0, int frameCount=1) : refCount(1), frameCount(frameCount), frame(frame), inCache(false), pixmapStatus(QQuickPixmap::Ready), - url(u), implicitSize(s), requestSize(r), + url(u), implicitSize(s), requestRegion(r), requestSize(rs), providerOptions(po), appliedTransform(aTransform), textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr) @@ -308,9 +314,11 @@ public: QUrl url; QString errorString; QSize implicitSize; + QRect requestRegion; QSize requestSize; QQuickImageProviderOptions providerOptions; QQuickImageProviderOptions::AutoTransform appliedTransform; + QColorSpace targetColorSpace; QQuickTextureFactory *textureFactory; @@ -399,7 +407,7 @@ static void maybeRemoveAlpha(QImage *image) } static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, int *frameCount, - const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, + const QRect &requestRegion, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, QQuickImageProviderOptions::AutoTransform *appliedTransform = nullptr, int frame = 0) { QImageReader imgio(dev); @@ -417,14 +425,25 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e QSize scSize = QQuickImageProviderWithOptions::loadSize(imgio.size(), requestSize, imgio.format(), providerOptions); if (scSize.isValid()) imgio.setScaledSize(scSize); + if (!requestRegion.isNull()) + imgio.setScaledClipRect(requestRegion); + const QSize originalSize = imgio.size(); + qCDebug(lcImg) << url << "frame" << frame << "of" << imgio.imageCount() + << "requestRegion" << requestRegion << "QImageReader size" << originalSize << "-> scSize" << scSize; if (impsize) - *impsize = imgio.size(); + *impsize = originalSize; if (imgio.read(image)) { maybeRemoveAlpha(image); if (impsize && impsize->width() < 0) *impsize = image->size(); + if (providerOptions.targetColorSpace().isValid()) { + if (image->colorSpace().isValid()) + image->convertToColorSpace(providerOptions.targetColorSpace()); + else + image->setColorSpace(providerOptions.targetColorSpace()); + } return true; } else { if (errorString) @@ -559,7 +578,7 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError; QString errorString; QSize readSize; - if (reply->networkError()) { + if (reply->error()) { error = QQuickPixmapReply::Loading; errorString = reply->errorString(); } else { @@ -568,7 +587,8 @@ void QQuickPixmapReader::networkRequestDone(QNetworkReply *reply) buff.open(QIODevice::ReadOnly); int frameCount; int const frame = job->data ? job->data->frame : 0; - if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, &frameCount, job->requestSize, job->providerOptions, nullptr, frame)) + if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, &frameCount, + job->requestRegion, job->requestSize, job->providerOptions, nullptr, frame)) error = QQuickPixmapReply::Decoding; else if (job->data) job->data->frameCount = frameCount; @@ -884,7 +904,8 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u } else { int frameCount; int const frame = runningJob->data ? runningJob->data->frame : 0; - if ( !readImage(url, &f, &image, &errorStr, &readSize, &frameCount, runningJob->requestSize, runningJob->providerOptions, nullptr, frame)) { + if (!readImage(url, &f, &image, &errorStr, &readSize, &frameCount, runningJob->requestRegion, runningJob->requestSize, + runningJob->providerOptions, nullptr, frame)) { errorCode = QQuickPixmapReply::Loading; if (f.fileName() != localFile) errorStr += QString::fromLatin1(" (%1)").arg(f.fileName()); @@ -997,6 +1018,7 @@ class QQuickPixmapKey { public: const QUrl *url; + const QRect *region; const QSize *size; int frame; QQuickImageProviderOptions options; @@ -1004,12 +1026,20 @@ public: inline bool operator==(const QQuickPixmapKey &lhs, const QQuickPixmapKey &rhs) { - return *lhs.size == *rhs.size && *lhs.url == *rhs.url && lhs.options == rhs.options && lhs.frame == rhs.frame; + return *lhs.url == *rhs.url && + *lhs.region == *rhs.region && + *lhs.size == *rhs.size && + lhs.frame == rhs.frame && + lhs.options == rhs.options; } inline uint qHash(const QQuickPixmapKey &key) { - return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.frame*23) ^ (key.options.autoTransform() * 0x5c5c5c5c); + return qHash(*key.url) ^ (key.size->width()*7) ^ (key.size->height()*17) ^ (key.frame*23) ^ + (key.region->x()*29) ^ (key.region->y()*31) ^ (key.options.autoTransform() * 0x5c5c5c5c); + // key.region.width() and height() are not included, because the hash function should be simple, + // and they are more likely to be held constant for some batches of images + // (e.g. tiles, or repeatedly cropping to the same viewport at different positions). } class QQuickPixmapStore : public QObject @@ -1176,7 +1206,8 @@ void QQuickPixmap::purgeCache() } QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d) -: data(d), engineForReader(nullptr), requestSize(d->requestSize), url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0) + : data(d), engineForReader(nullptr), requestRegion(d->requestRegion), requestSize(d->requestSize), + url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0) { if (finishedIndex == -1) { finishedIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::finished).methodIndex(); @@ -1271,7 +1302,7 @@ void QQuickPixmapData::release() void QQuickPixmapData::addToCache() { if (!inCache) { - QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions }; + QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions }; pixmapStore()->m_cache.insert(key, this); inCache = true; PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>( @@ -1282,7 +1313,7 @@ void QQuickPixmapData::addToCache() void QQuickPixmapData::removeFromCache() { if (inCache) { - QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions }; + QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions }; pixmapStore()->m_cache.remove(key); inCache = false; PIXMAP_PROFILE(pixmapCountChanged<QQuickProfiler::PixmapCacheCountChanged>( @@ -1290,7 +1321,9 @@ void QQuickPixmapData::removeFromCache() } } -static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, const QSize &requestSize, const QQuickImageProviderOptions &providerOptions, int frame, bool *ok) +static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, QQmlEngine *engine, const QUrl &url, + const QRect &requestRegion, const QSize &requestSize, + const QQuickImageProviderOptions &providerOptions, int frame, bool *ok) { if (url.scheme() == QLatin1String("image")) { QSize readSize; @@ -1305,7 +1338,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q switch (imageType) { case QQuickImageProvider::Invalid: - return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions, + return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions, QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString())); case QQuickImageProvider::Texture: { @@ -1313,7 +1346,8 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q : provider->requestTexture(imageId(url), &readSize, requestSize); if (texture) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); + return new QQuickPixmapData(declarativePixmap, url, texture, readSize, requestRegion, requestSize, + providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); } break; } @@ -1324,7 +1358,9 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q : provider->requestImage(imageId(url), &readSize, requestSize); if (!image.isNull()) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); + return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), + readSize, requestRegion, requestSize, providerOptions, + QQuickImageProviderOptions::UsePluginDefaultTransform, frame); } break; } @@ -1334,7 +1370,9 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q : provider->requestPixmap(imageId(url), &readSize, requestSize); if (!pixmap.isNull()) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()), readSize, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); + return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(pixmap.toImage()), + readSize, requestRegion, requestSize, providerOptions, + QQuickImageProviderOptions::UsePluginDefaultTransform, frame); } break; } @@ -1346,7 +1384,7 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q } // provider has bad image type, or provider returned null image - return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions, + return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions, QQuickPixmap::tr("Failed to get image from provider: %1").arg(url.toString())); } @@ -1364,7 +1402,8 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q QQuickTextureFactory *factory = texReader.read(); if (factory) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); + return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestRegion, requestSize, + providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame); } else { errorString = QQuickPixmap::tr("Error decoding: %1").arg(url.toString()); if (f.fileName() != localFile) @@ -1374,9 +1413,10 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q QImage image; QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform(); int frameCount; - if (readImage(url, &f, &image, &errorString, &readSize, &frameCount, requestSize, providerOptions, &appliedTransform, frame)) { + if (readImage(url, &f, &image, &errorString, &readSize, &frameCount, requestRegion, requestSize, providerOptions, &appliedTransform, frame)) { *ok = true; - return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform, frame, frameCount); + return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestRegion, requestSize, + providerOptions, appliedTransform, frame, frameCount); } else if (f.fileName() != localFile) { errorString += QString::fromLatin1(" (%1)").arg(f.fileName()); } @@ -1384,12 +1424,13 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q } else { errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString()); } - return new QQuickPixmapData(declarativePixmap, url, requestSize, providerOptions, errorString); + return new QQuickPixmapData(declarativePixmap, url, requestRegion, requestSize, providerOptions, errorString); } struct QQuickPixmapNull { QUrl url; + QRect region; QSize size; }; Q_GLOBAL_STATIC(QQuickPixmapNull, nullPixmap); @@ -1405,15 +1446,16 @@ QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url) load(engine, url); } -QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QSize &size) +QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QRect ®ion, const QSize &size) : d(nullptr) { - load(engine, url, size); + load(engine, url, region, size); } QQuickPixmap::QQuickPixmap(const QUrl &url, const QImage &image) { - d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QSize(), QQuickImageProviderOptions(), QQuickImageProviderOptions::UsePluginDefaultTransform); + d = new QQuickPixmapData(this, url, new QQuickDefaultTextureFactory(image), image.size(), QRect(), QSize(), + QQuickImageProviderOptions(), QQuickImageProviderOptions::UsePluginDefaultTransform); d->addToCache(); } @@ -1486,6 +1528,14 @@ const QSize &QQuickPixmap::requestSize() const return nullPixmap()->size; } +const QRect &QQuickPixmap::requestRegion() const +{ + if (d) + return d->requestRegion; + else + return nullPixmap()->region; +} + QQuickImageProviderOptions::AutoTransform QQuickPixmap::autoTransform() const { if (d) @@ -1561,25 +1611,26 @@ QRect QQuickPixmap::rect() const void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url) { - load(engine, url, QSize(), QQuickPixmap::Cache); + load(engine, url, QRect(), QSize(), QQuickPixmap::Cache); } void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, QQuickPixmap::Options options) { - load(engine, url, QSize(), options); + load(engine, url, QRect(), QSize(), options); } -void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &size) +void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize) { - load(engine, url, size, QQuickPixmap::Cache); + load(engine, url, requestRegion, requestSize, QQuickPixmap::Cache); } -void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options) +void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options) { - load(engine, url, requestSize, options, QQuickImageProviderOptions()); + load(engine, url, requestRegion, requestSize, options, QQuickImageProviderOptions()); } -void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &requestSize, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame, int frameCount) +void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QRect &requestRegion, const QSize &requestSize, + QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame, int frameCount) { if (d) { d->declarativePixmaps.remove(this); @@ -1587,7 +1638,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques d = nullptr; } - QQuickPixmapKey key = { &url, &requestSize, frame, providerOptions }; + QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, providerOptions }; QQuickPixmapStore *store = pixmapStore(); QHash<QQuickPixmapKey, QQuickPixmapData *>::Iterator iter = store->m_cache.end(); @@ -1596,10 +1647,11 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques // cached version. Unless it's an itemgrabber url, since the cache is used to pass // the result between QQuickItemGrabResult and QQuickImage. if (url.scheme() == itemGrabberScheme) { - QSize dummy; - if (requestSize != dummy) + QRect dummyRegion; + QSize dummySize; + if (requestSize != dummySize) qWarning() << "Ignoring sourceSize request for image url that came from grabToImage. Use the targetSize parameter of the grabToImage() function instead."; - const QQuickPixmapKey grabberKey = { &url, &dummy, 0, QQuickImageProviderOptions() }; + const QQuickPixmapKey grabberKey = { &url, &dummyRegion, &dummySize, 0, QQuickImageProviderOptions() }; iter = store->m_cache.find(grabberKey); } else if (options & QQuickPixmap::Cache) iter = store->m_cache.find(key); @@ -1621,7 +1673,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques if (!(options & QQuickPixmap::Asynchronous)) { bool ok = false; PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingStarted>(url)); - d = createPixmapDataSync(this, engine, url, requestSize, providerOptions, frame, &ok); + d = createPixmapDataSync(this, engine, url, requestRegion, requestSize, providerOptions, frame, &ok); if (ok) { PIXMAP_PROFILE(pixmapLoadingFinished(url, QSize(width(), height()))); if (options & QQuickPixmap::Cache) @@ -1638,7 +1690,8 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques return; - d = new QQuickPixmapData(this, url, requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform, frame, frameCount); + d = new QQuickPixmapData(this, url, requestRegion, requestSize, providerOptions, + QQuickImageProviderOptions::UsePluginDefaultTransform, frame, frameCount); if (options & QQuickPixmap::Cache) d->addToCache(); @@ -1672,9 +1725,10 @@ void QQuickPixmap::clear(QObject *obj) } } -bool QQuickPixmap::isCached(const QUrl &url, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options) +bool QQuickPixmap::isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize, + const int frame, const QQuickImageProviderOptions &options) { - QQuickPixmapKey key = { &url, &requestSize, frame, options }; + QQuickPixmapKey key = { &url, &requestRegion, &requestSize, frame, options }; QQuickPixmapStore *store = pixmapStore(); return store->m_cache.contains(key); @@ -1720,6 +1774,13 @@ bool QQuickPixmap::connectDownloadProgress(QObject *object, int method) return QMetaObject::connect(d->reply, QQuickPixmapReply::downloadProgressIndex, object, method); } +QColorSpace QQuickPixmap::colorSpace() const +{ + if (!d || !d->textureFactory) + return QColorSpace(); + return d->textureFactory->image().colorSpace(); +} + QT_END_NAMESPACE #include <qquickpixmapcache.moc> diff --git a/src/quick/util/qquickpixmapcache_p.h b/src/quick/util/qquickpixmapcache_p.h index c4f4d1a101..87724d6210 100644 --- a/src/quick/util/qquickpixmapcache_p.h +++ b/src/quick/util/qquickpixmapcache_p.h @@ -117,6 +117,9 @@ public: bool preserveAspectRatioFit() const; void setPreserveAspectRatioFit(bool preserveAspectRatioFit); + QColorSpace targetColorSpace() const; + void setTargetColorSpace(const QColorSpace &colorSpace); + private: QSharedDataPointer<QQuickImageProviderOptionsPrivate> d; }; @@ -127,7 +130,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPixmap public: QQuickPixmap(); QQuickPixmap(QQmlEngine *, const QUrl &); - QQuickPixmap(QQmlEngine *, const QUrl &, const QSize &); + QQuickPixmap(QQmlEngine *, const QUrl &, const QRect ®ion, const QSize &); QQuickPixmap(const QUrl &, const QImage &image); ~QQuickPixmap(); @@ -148,6 +151,7 @@ public: QString error() const; const QUrl &url() const; const QSize &implicitSize() const; + const QRect &requestRegion() const; const QSize &requestSize() const; QQuickImageProviderOptions::AutoTransform autoTransform() const; int frameCount() const; @@ -155,6 +159,8 @@ public: void setImage(const QImage &); void setPixmap(const QQuickPixmap &other); + QColorSpace colorSpace() const; + QQuickTextureFactory *textureFactory() const; QRect rect() const; @@ -163,9 +169,10 @@ public: void load(QQmlEngine *, const QUrl &); void load(QQmlEngine *, const QUrl &, QQuickPixmap::Options options); - void load(QQmlEngine *, const QUrl &, const QSize &); - void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options); - void load(QQmlEngine *, const QUrl &, const QSize &, QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1); + void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize); + void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options); + void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize, + QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1); void clear(); void clear(QObject *); @@ -176,7 +183,8 @@ public: bool connectDownloadProgress(QObject *, int); static void purgeCache(); - static bool isCached(const QUrl &url, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options); + static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize, + const int frame, const QQuickImageProviderOptions &options); static const QLatin1String itemGrabberScheme; diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h index 27a00420af..ff48de96c6 100644 --- a/src/quick/util/qquickpropertychanges_p.h +++ b/src/quick/util/qquickpropertychanges_p.h @@ -66,6 +66,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyChanges : public QQuickStateOperation Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit) QML_NAMED_ELEMENT(PropertyChanges) + QML_ADDED_IN_VERSION(2, 0) public: QQuickPropertyChanges(); diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h index 0e66a38e75..67dab928b7 100644 --- a/src/quick/util/qquickshortcut_p.h +++ b/src/quick/util/qquickshortcut_p.h @@ -67,14 +67,14 @@ class QQuickShortcut : public QObject, public QQmlParserStatus Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QVariant sequence READ sequence WRITE setSequence NOTIFY sequenceChanged FINAL) - Q_PROPERTY(QVariantList sequences READ sequences WRITE setSequences NOTIFY sequencesChanged FINAL REVISION 9) - Q_PROPERTY(QString nativeText READ nativeText NOTIFY sequenceChanged FINAL REVISION 6) - Q_PROPERTY(QString portableText READ portableText NOTIFY sequenceChanged FINAL REVISION 6) + Q_PROPERTY(QVariantList sequences READ sequences WRITE setSequences NOTIFY sequencesChanged FINAL REVISION(2, 9)) + Q_PROPERTY(QString nativeText READ nativeText NOTIFY sequenceChanged FINAL REVISION(2, 6)) + Q_PROPERTY(QString portableText READ portableText NOTIFY sequenceChanged FINAL REVISION(2, 6)) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL) Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL) QML_NAMED_ELEMENT(Shortcut) - QML_ADDED_IN_MINOR_VERSION(5) + QML_ADDED_IN_VERSION(2, 5) public: explicit QQuickShortcut(QObject *parent = nullptr); @@ -100,7 +100,7 @@ public: Q_SIGNALS: void sequenceChanged(); - Q_REVISION(9) void sequencesChanged(); + Q_REVISION(2, 9) void sequencesChanged(); void enabledChanged(); void autoRepeatChanged(); void contextChanged(); diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h index d7e637446d..4a53a4406f 100644 --- a/src/quick/util/qquicksmoothedanimation_p.h +++ b/src/quick/util/qquicksmoothedanimation_p.h @@ -69,6 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickSmoothedAnimation : public QQuickNumberAnimation Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged) Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged) QML_NAMED_ELEMENT(SmoothedAnimation) + QML_ADDED_IN_VERSION(2, 0) public: enum ReversingMode { Eased, Immediate, Sync }; diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h index 771b746622..c09806e0ec 100644 --- a/src/quick/util/qquickspringanimation_p.h +++ b/src/quick/util/qquickspringanimation_p.h @@ -72,6 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickSpringAnimation : public QQuickNumberAnimation Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged) QML_NAMED_ELEMENT(SpringAnimation) + QML_ADDED_IN_VERSION(2, 0) public: QQuickSpringAnimation(QObject *parent=nullptr); diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp index c106528f45..71ab1f4d62 100644 --- a/src/quick/util/qquickstate.cpp +++ b/src/quick/util/qquickstate.cpp @@ -267,9 +267,13 @@ void QQuickState::setExtends(const QString &extends) QQmlListProperty<QQuickStateOperation> QQuickState::changes() { Q_D(QQuickState); - return QQmlListProperty<QQuickStateOperation>(this, &d->operations, QQuickStatePrivate::operations_append, - QQuickStatePrivate::operations_count, QQuickStatePrivate::operations_at, - QQuickStatePrivate::operations_clear); + return QQmlListProperty<QQuickStateOperation>(this, &d->operations, + QQuickStatePrivate::operations_append, + QQuickStatePrivate::operations_count, + QQuickStatePrivate::operations_at, + QQuickStatePrivate::operations_clear, + QQuickStatePrivate::operations_replace, + QQuickStatePrivate::operations_removeLast); } int QQuickState::operationCount() const diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h index af49bb1c2f..ee9aa92bbd 100644 --- a/src/quick/util/qquickstate_p.h +++ b/src/quick/util/qquickstate_p.h @@ -126,6 +126,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateOperation : public QObject { Q_OBJECT QML_ANONYMOUS + QML_ADDED_IN_VERSION(2, 0) public: QQuickStateOperation(QObject *parent = nullptr) : QObject(parent) {} @@ -159,6 +160,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickState : public QObject Q_CLASSINFO("DefaultProperty", "changes") Q_CLASSINFO("DeferredPropertyNames", "changes") QML_NAMED_ELEMENT(State) + QML_ADDED_IN_VERSION(2, 0) public: QQuickState(QObject *parent=nullptr); diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h index 2fa5321165..ae4ed291b5 100644 --- a/src/quick/util/qquickstate_p_p.h +++ b/src/quick/util/qquickstate_p_p.h @@ -244,6 +244,23 @@ public: QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); return list->at(index); } + static void operations_replace(QQmlListProperty<QQuickStateOperation> *prop, int index, + QQuickStateOperation *op) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + auto &guard = list->at(index); + if (guard.object() == op) { + op->setState(qobject_cast<QQuickState*>(prop->object)); + } else { + list->at(index)->setState(nullptr); + op->setState(qobject_cast<QQuickState*>(prop->object)); + list->replace(index, OperationGuard(op, list)); + } + } + static void operations_removeLast(QQmlListProperty<QQuickStateOperation> *prop) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + list->last()->setState(nullptr); + list->removeLast(); + } QQuickTransitionManager transitionManager; diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h index 931baaca4e..62f4910606 100644 --- a/src/quick/util/qquickstatechangescript_p.h +++ b/src/quick/util/qquickstatechangescript_p.h @@ -65,6 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickStateChangeScript : public QQuickStateOperation, p Q_PROPERTY(QQmlScriptString script READ script WRITE setScript) Q_PROPERTY(QString name READ name WRITE setName) QML_NAMED_ELEMENT(StateChangeScript) + QML_ADDED_IN_VERSION(2, 0) public: QQuickStateChangeScript(QObject *parent=nullptr); diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index 46e7d62fc1..2109aafc10 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -70,6 +70,8 @@ public: static int count_state(QQmlListProperty<QQuickState> *list); static QQuickState *at_state(QQmlListProperty<QQuickState> *list, int index); static void clear_states(QQmlListProperty<QQuickState> *list); + static void replace_states(QQmlListProperty<QQuickState> *list, int index, QQuickState *state); + static void removeLast_states(QQmlListProperty<QQuickState> *list); static void append_transition(QQmlListProperty<QQuickTransition> *list, QQuickTransition *state); static int count_transitions(QQmlListProperty<QQuickTransition> *list); @@ -163,10 +165,13 @@ QList<QQuickState *> QQuickStateGroup::states() const QQmlListProperty<QQuickState> QQuickStateGroup::statesProperty() { Q_D(QQuickStateGroup); - return QQmlListProperty<QQuickState>(this, &d->states, &QQuickStateGroupPrivate::append_state, - &QQuickStateGroupPrivate::count_state, - &QQuickStateGroupPrivate::at_state, - &QQuickStateGroupPrivate::clear_states); + return QQmlListProperty<QQuickState>(this, &d->states, + &QQuickStateGroupPrivate::append_state, + &QQuickStateGroupPrivate::count_state, + &QQuickStateGroupPrivate::at_state, + &QQuickStateGroupPrivate::clear_states, + &QQuickStateGroupPrivate::replace_states, + &QQuickStateGroupPrivate::removeLast_states); } void QQuickStateGroupPrivate::append_state(QQmlListProperty<QQuickState> *list, QQuickState *state) @@ -201,6 +206,29 @@ void QQuickStateGroupPrivate::clear_states(QQmlListProperty<QQuickState> *list) _this->d_func()->states.clear(); } +void QQuickStateGroupPrivate::replace_states(QQmlListProperty<QQuickState> *list, int index, QQuickState *state) +{ + auto *self = qobject_cast<QQuickStateGroup *>(list->object); + auto *d = self->d_func(); + auto *oldState = d->states.at(index); + if (oldState != state) { + oldState->setStateGroup(nullptr); + state->setStateGroup(self); + d->states.replace(index, state); + if (d->currentState == oldState->name()) + d->setCurrentStateInternal(state->name(), true); + } +} + +void QQuickStateGroupPrivate::removeLast_states(QQmlListProperty<QQuickState> *list) +{ + auto *d = qobject_cast<QQuickStateGroup *>(list->object)->d_func(); + if (d->currentState == d->states.last()->name()) + d->setCurrentStateInternal(d->states.length() > 1 ? d->states.first()->name() : QString(), true); + d->states.last()->setStateGroup(nullptr); + d->states.removeLast(); +} + /*! \qmlproperty list<Transition> QtQuick::StateGroup::transitions This property holds a list of transitions defined by the state group. diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h index 11a0c5f442..c3d66fd824 100644 --- a/src/quick/util/qquickstategroup_p.h +++ b/src/quick/util/qquickstategroup_p.h @@ -66,6 +66,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateGroup : public QObject, public QQmlParse Q_PROPERTY(QQmlListProperty<QQuickState> states READ statesProperty DESIGNABLE false) Q_PROPERTY(QQmlListProperty<QQuickTransition> transitions READ transitionsProperty DESIGNABLE false) QML_NAMED_ELEMENT(StateGroup) + QML_ADDED_IN_VERSION(2, 0) public: QQuickStateGroup(QObject * = nullptr); diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp index 08d06c66ab..660852ba83 100644 --- a/src/quick/util/qquickstyledtext.cpp +++ b/src/quick/util/qquickstyledtext.cpp @@ -706,7 +706,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri // to avoid a relayout later on. QUrl url = baseUrl.resolved(image->url); if (url.isLocalFile()) { - image->pix = new QQuickPixmap(context->engine(), url, image->size); + image->pix = new QQuickPixmap(context->engine(), url, QRect(), image->size); if (image->pix && image->pix->isReady()) { image->size = image->pix->implicitSize(); } else { diff --git a/src/quick/util/qquicksystempalette_p.h b/src/quick/util/qquicksystempalette_p.h index c6d9fc2604..43d7277bea 100644 --- a/src/quick/util/qquicksystempalette_p.h +++ b/src/quick/util/qquicksystempalette_p.h @@ -80,6 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickSystemPalette : public QObject Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged) Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) QML_NAMED_ELEMENT(SystemPalette) + QML_ADDED_IN_VERSION(2, 0) public: QQuickSystemPalette(QObject *parent=nullptr); diff --git a/src/quick/util/qquicktextmetrics_p.h b/src/quick/util/qquicktextmetrics_p.h index a1d64e3d0a..33c64073c2 100644 --- a/src/quick/util/qquicktextmetrics_p.h +++ b/src/quick/util/qquicktextmetrics_p.h @@ -75,7 +75,7 @@ class Q_AUTOTEST_EXPORT QQuickTextMetrics : public QObject Q_PROPERTY(Qt::TextElideMode elide READ elide WRITE setElide NOTIFY elideChanged FINAL) Q_PROPERTY(qreal elideWidth READ elideWidth WRITE setElideWidth NOTIFY elideWidthChanged FINAL) QML_NAMED_ELEMENT(TextMetrics) - QML_ADDED_IN_MINOR_VERSION(4) + QML_ADDED_IN_VERSION(2, 4) public: explicit QQuickTextMetrics(QObject *parent = 0); diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h index abb5369b7b..fc5bd15ed1 100644 --- a/src/quick/util/qquicktimeline_p_p.h +++ b/src/quick/util/qquicktimeline_p_p.h @@ -52,6 +52,7 @@ // #include <QtCore/QObject> +#include <private/qtquickglobal_p.h> #include "private/qabstractanimationjob_p.h" QT_BEGIN_NAMESPACE @@ -61,7 +62,7 @@ class QQuickTimeLineValue; class QQuickTimeLineCallback; struct QQuickTimeLinePrivate; class QQuickTimeLineObject; -class Q_AUTOTEST_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob +class Q_QUICK_PRIVATE_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob { Q_OBJECT public: diff --git a/src/quick/util/qquicktransition_p.h b/src/quick/util/qquicktransition_p.h index 6e45143126..bfb7d75821 100644 --- a/src/quick/util/qquicktransition_p.h +++ b/src/quick/util/qquicktransition_p.h @@ -104,6 +104,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTransition : public QObject Q_CLASSINFO("DefaultProperty", "animations") Q_CLASSINFO("DeferredPropertyNames", "animations") QML_NAMED_ELEMENT(Transition) + QML_ADDED_IN_VERSION(2, 0) public: QQuickTransition(QObject *parent=nullptr); diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h index a0dc2cd5ba..029737e10b 100644 --- a/src/quick/util/qquickvalidator_p.h +++ b/src/quick/util/qquickvalidator_p.h @@ -62,6 +62,7 @@ class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator Q_OBJECT Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged) QML_NAMED_ELEMENT(IntValidator) + QML_ADDED_IN_VERSION(2, 0) public: QQuickIntValidator(QObject *parent = nullptr); @@ -78,6 +79,7 @@ class Q_AUTOTEST_EXPORT QQuickDoubleValidator : public QDoubleValidator Q_OBJECT Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged) QML_NAMED_ELEMENT(DoubleValidator) + QML_ADDED_IN_VERSION(2, 0) public: QQuickDoubleValidator(QObject *parent = nullptr); diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp index f9cd28cb24..517ed5da38 100644 --- a/src/quick/util/qquickvaluetypes.cpp +++ b/src/quick/util/qquickvaluetypes.cpp @@ -41,6 +41,7 @@ #include <qtquickglobal.h> #include <private/qqmlvaluetype_p.h> +#include <private/qcolorspace_p.h> #include <private/qfont_p.h> @@ -784,6 +785,47 @@ void QQuickFontValueType::setPreferShaping(bool enable) v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() | QFont::PreferNoShaping)); } +QQuickColorSpaceValueType::NamedColorSpace QQuickColorSpaceValueType::namedColorSpace() const noexcept +{ + if (const auto *p = QColorSpacePrivate::get(v)) + return (QQuickColorSpaceValueType::NamedColorSpace)p->namedColorSpace; + return QQuickColorSpaceValueType::Unknown; +} +void QQuickColorSpaceValueType::setNamedColorSpace(QQuickColorSpaceValueType::NamedColorSpace namedColorSpace) +{ + v = { (QColorSpace::NamedColorSpace)namedColorSpace }; +} + +QQuickColorSpaceValueType::Primaries QQuickColorSpaceValueType::primaries() const noexcept +{ + return (QQuickColorSpaceValueType::Primaries)v.primaries(); +} + +void QQuickColorSpaceValueType::setPrimaries(QQuickColorSpaceValueType::Primaries primariesId) +{ + v.setPrimaries((QColorSpace::Primaries)primariesId); +} + +QQuickColorSpaceValueType::TransferFunction QQuickColorSpaceValueType::transferFunction() const noexcept +{ + return (QQuickColorSpaceValueType::TransferFunction)v.transferFunction(); +} + +void QQuickColorSpaceValueType::setTransferFunction(QQuickColorSpaceValueType::TransferFunction transferFunction) +{ + v.setTransferFunction((QColorSpace::TransferFunction)transferFunction, v.gamma()); +} + +float QQuickColorSpaceValueType::gamma() const noexcept +{ + return v.gamma(); +} + +void QQuickColorSpaceValueType::setGamma(float gamma) +{ + v.setTransferFunction(v.transferFunction(), gamma); +} + 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 91a5ea83e5..ccd9eefe47 100644 --- a/src/quick/util/qquickvaluetypes_p.h +++ b/src/quick/util/qquickvaluetypes_p.h @@ -56,6 +56,7 @@ #include <private/qqmlvaluetype_p.h> #include <QtGui/QColor> +#include <QtGui/QColorSpace> #include <QtGui/QVector2D> #include <QtGui/QVector3D> #include <QtGui/QVector4D> @@ -329,6 +330,7 @@ class QQuickFontValueType Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL) QML_NAMED_ELEMENT(Font) + QML_ADDED_IN_VERSION(2, 0) QML_UNCREATABLE("Element is not creatable.") public: @@ -408,6 +410,58 @@ public: void setPreferShaping(bool b); }; +class QQuickColorSpaceValueType +{ + QColorSpace v; + Q_GADGET + + Q_PROPERTY(NamedColorSpace namedColorSpace READ namedColorSpace WRITE setNamedColorSpace FINAL) + Q_PROPERTY(Primaries primaries READ primaries WRITE setPrimaries FINAL) + Q_PROPERTY(TransferFunction transferFunction READ transferFunction WRITE setTransferFunction FINAL) + Q_PROPERTY(float gamma READ gamma WRITE setGamma FINAL) + + QML_NAMED_ELEMENT(ColorSpace) + QML_ADDED_IN_VERSION(2, 15) + Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") + +public: + enum NamedColorSpace { + Unknown = 0, + SRgb, + SRgbLinear, + AdobeRgb, + DisplayP3, + ProPhotoRgb + }; + Q_ENUM(NamedColorSpace) + + enum class Primaries { + Custom = 0, + SRgb, + AdobeRgb, + DciP3D65, + ProPhotoRgb + }; + Q_ENUM(Primaries) + enum class TransferFunction { + Custom = 0, + Linear, + Gamma, + SRgb, + ProPhotoRgb + }; + Q_ENUM(TransferFunction) + + NamedColorSpace namedColorSpace() const noexcept; + void setNamedColorSpace(NamedColorSpace namedColorSpace); + Primaries primaries() const noexcept; + void setPrimaries(Primaries primariesId); + TransferFunction transferFunction() const noexcept; + void setTransferFunction(TransferFunction transferFunction); + float gamma() const noexcept; + void setGamma(float gamma); +}; + QT_END_NAMESPACE #endif // QQUICKVALUETYPES_P_H |