aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-07-22 13:43:43 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2013-07-22 13:43:43 +0200
commit3a6f5735ee723ff998114314c5ccdf6609667f6f (patch)
tree9c877dd1e35972fa336cea8a61986594f168b49c /src/quick
parent000b6330d4ca7165ff241b21ee728ed28d82fba1 (diff)
parent17ded06804576dfde1b19f82f168f7ceb09ec92c (diff)
Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into wip/v4
Conflicts: src/quick/items/context2d/qquickcontext2d.cpp tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro Change-Id: I36a4fd28b3156839aecd70039a3ba566bf19a0bc
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/doc/images/qml-item-canvas-clip-complex.pngbin0 -> 70000 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-scaley.pngbin0 -> 1080 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-skewx.pngbin0 -> 1857 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-skewy.pngbin0 -> 2654 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-translate.pngbin0 -> 1269 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas-translatey.pngbin0 -> 1666 bytes
-rw-r--r--src/quick/doc/images/qml-item-canvas.arc.png (renamed from src/quick/doc/images/qml-item-canvas-arcTo2.png)bin6532 -> 6532 bytes
-rw-r--r--src/quick/doc/qtquick.qdocconf4
-rw-r--r--src/quick/doc/src/concepts/effects/topic.qdoc2
-rw-r--r--src/quick/doc/src/whatsnew.qdoc3
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp5
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp329
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp7
-rw-r--r--src/quick/items/qquickevents.cpp20
-rw-r--r--src/quick/items/qquickevents_p_p.h3
-rw-r--r--src/quick/items/qquickflickable.cpp4
-rw-r--r--src/quick/items/qquickgridview.cpp27
-rw-r--r--src/quick/items/qquickitem.cpp10
-rw-r--r--src/quick/items/qquickitem.h2
-rw-r--r--src/quick/items/qquickitemview.cpp27
-rw-r--r--src/quick/items/qquickitemview_p_p.h4
-rw-r--r--src/quick/items/qquicklistview.cpp29
-rw-r--r--src/quick/items/qquicktext.cpp4
-rw-r--r--src/quick/items/qquicktextdocument.cpp18
-rw-r--r--src/quick/items/qquicktextdocument.h18
-rw-r--r--src/quick/items/qquicktextedit.cpp53
-rw-r--r--src/quick/items/qquicktextedit_p_p.h5
-rw-r--r--src/quick/items/qquickwindow.cpp12
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.h1
-rw-r--r--src/quick/scenegraph/qsgcontext.cpp9
-rw-r--r--src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp6
-rw-r--r--src/quick/scenegraph/util/qsgsimplematerial.cpp18
-rw-r--r--src/quick/scenegraph/util/qsgtexture.cpp3
-rw-r--r--src/quick/util/qquickapplication.cpp10
-rw-r--r--src/quick/util/qquickutilmodule.cpp6
36 files changed, 449 insertions, 191 deletions
diff --git a/src/quick/doc/images/qml-item-canvas-clip-complex.png b/src/quick/doc/images/qml-item-canvas-clip-complex.png
new file mode 100644
index 0000000000..cb582bad41
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-clip-complex.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-scaley.png b/src/quick/doc/images/qml-item-canvas-scaley.png
new file mode 100644
index 0000000000..61462b9adc
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-scaley.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-skewx.png b/src/quick/doc/images/qml-item-canvas-skewx.png
new file mode 100644
index 0000000000..c9bcb6715c
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-skewx.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-skewy.png b/src/quick/doc/images/qml-item-canvas-skewy.png
new file mode 100644
index 0000000000..594ac842a4
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-skewy.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-translate.png b/src/quick/doc/images/qml-item-canvas-translate.png
new file mode 100644
index 0000000000..7bb3ae7560
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-translate.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-translatey.png b/src/quick/doc/images/qml-item-canvas-translatey.png
new file mode 100644
index 0000000000..9196bf5919
--- /dev/null
+++ b/src/quick/doc/images/qml-item-canvas-translatey.png
Binary files differ
diff --git a/src/quick/doc/images/qml-item-canvas-arcTo2.png b/src/quick/doc/images/qml-item-canvas.arc.png
index 5f9d32d8d3..5f9d32d8d3 100644
--- a/src/quick/doc/images/qml-item-canvas-arcTo2.png
+++ b/src/quick/doc/images/qml-item-canvas.arc.png
Binary files differ
diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf
index 30861d9b2e..8f769871a5 100644
--- a/src/quick/doc/qtquick.qdocconf
+++ b/src/quick/doc/qtquick.qdocconf
@@ -63,3 +63,7 @@ sourcedirs += ../../plugins
excludedirs += ../../imports/dialogs \
../../imports/models \
../../../examples/quick/dialogs
+
+navigation.landingpage = "Qt Quick"
+navigation.cppclassespage = "Qt Quick C++ Classes"
+navigation.qmltypespage = "Qt Quick QML Types"
diff --git a/src/quick/doc/src/concepts/effects/topic.qdoc b/src/quick/doc/src/concepts/effects/topic.qdoc
index 42b0291e44..bf713c2259 100644
--- a/src/quick/doc/src/concepts/effects/topic.qdoc
+++ b/src/quick/doc/src/concepts/effects/topic.qdoc
@@ -35,7 +35,7 @@
Visually appealing user-interfaces are more engaging than lacklustre ones.
That said, the designer must bear in mind that visual effects simply provide
-a useful way to subtlely communicate to the user (for example, which visual
+a useful way to subtly communicate to the user (for example, which visual
item is active, or how focus is being transferred). Over-use of visual
effects can actually detract from the user-experience.
diff --git a/src/quick/doc/src/whatsnew.qdoc b/src/quick/doc/src/whatsnew.qdoc
index 973d41dca2..26d88699bc 100644
--- a/src/quick/doc/src/whatsnew.qdoc
+++ b/src/quick/doc/src/whatsnew.qdoc
@@ -38,7 +38,8 @@ features introduced by the new import and new classes in Qt 5.1:
\li New render loop for windows for smoother animations.
\li New \l Window properties: activeFocusItem, minimumWidth, minimumHeight,
maximumWidth, maximumHeight, visibility, contentOrientation, and opacity.
-\li New \l Item property: activeFocusOnTab.
+\li New \l Screen attached properties: name, desktopAvailableWidth,
+ desktopAvailableHeight, logicalPixelDensity
\li New \l Grid properties: horizontalAlignment, verticalAlignment, and
effectiveHorizontalAlignment.
\li New \l TextEdit properties: selectByKeyboard and textDocument
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 9c4cef1fe1..55fb8b7fc5 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -630,8 +630,11 @@ void QQuickCanvasItem::itemChange(QQuickItem::ItemChange change, const QQuickIte
return;
Q_D(QQuickCanvasItem);
- if (d->available)
+ if (d->available) {
+ if (d->dirtyAttributes & QQuickItemPrivate::ContentUpdateMask)
+ requestPaint();
return;
+ }
if (value.window== 0)
return;
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index ca8b947756..d59e65dfd4 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -198,31 +198,153 @@ QColor qt_color_from_string(const QV4::Value &name)
return QColor();
}
-QFont qt_font_from_string(const QString& fontString) {
- QFont font;
- // ### this is simplified and incomplete
- // ### TODO:get code from Qt webkit
- const QStringList tokens = fontString.split(QLatin1Char(' '));
- foreach (const QString &token, tokens) {
- if (token == QStringLiteral("italic"))
- font.setItalic(true);
- else if (token == QStringLiteral("bold"))
- font.setBold(true);
- else if (token.endsWith(QStringLiteral("px"))) {
- QString number = token;
- number.remove(QLatin1String("px"));
- bool ok = false;
- float pixelSize = number.trimmed().toFloat(&ok);
- if (ok)
- font.setPixelSize(int(pixelSize));
- } else
- font.setFamily(token);
- }
-
- return font;
+static bool qSetFontSizeFromToken(QFont &font, const QString &fontSizeToken)
+{
+ const QString trimmedToken = fontSizeToken.trimmed();
+ QString unit = trimmedToken.right(2);
+ QString value = trimmedToken.left(fontSizeToken.size() - 2);
+ bool ok = false;
+ float size = value.trimmed().toFloat(&ok);
+ if (ok) {
+ int intSize = int(size);
+ if (unit.compare(QLatin1String("px")) == 0) {
+ font.setPixelSize(intSize);
+ return true;
+ } else if (unit.compare(QLatin1String("pt")) == 0) {
+ font.setPointSize(intSize);
+ return true;
+ }
+ }
+ qWarning().nospace() << "Context2D: A font size of " << fontSizeToken << " is invalid.";
+ return false;
+}
+
+static bool qSetFontFamilyFromToken(QFont &font, const QString &fontFamilyToken)
+{
+ const QString trimmedToken = fontFamilyToken.trimmed();
+ QFontDatabase fontDatabase;
+ if (fontDatabase.hasFamily(trimmedToken)) {
+ font.setFamily(trimmedToken);
+ return true;
+ } else {
+ // Can't find a family matching this name; if it's a generic family,
+ // try searching for the default family for it by using style hints.
+ QFont tmp;
+ int styleHint = -1;
+ if (fontFamilyToken.compare(QLatin1String("serif")) == 0) {
+ styleHint = QFont::Serif;
+ } else if (fontFamilyToken.compare(QLatin1String("sans-serif")) == 0) {
+ styleHint = QFont::SansSerif;
+ } else if (fontFamilyToken.compare(QLatin1String("cursive")) == 0) {
+ styleHint = QFont::Cursive;
+ } else if (fontFamilyToken.compare(QLatin1String("monospace")) == 0) {
+ styleHint = QFont::Monospace;
+ } else if (fontFamilyToken.compare(QLatin1String("fantasy")) == 0) {
+ styleHint = QFont::Fantasy;
+ }
+ if (styleHint != -1) {
+ tmp.setStyleHint(static_cast<QFont::StyleHint>(styleHint));
+ font.setFamily(tmp.defaultFamily());
+ return true;
+ }
+ }
+ qWarning().nospace() << "Context2D: The font family " << fontFamilyToken << " is invalid.";
+ return false;
}
+enum FontToken
+{
+ NoTokens = 0x00,
+ FontStyle = 0x01,
+ FontVariant = 0x02,
+ FontWeight = 0x04
+};
+#define Q_TRY_SET_TOKEN(token, value, setStatement) \
+if (!(usedTokens & token)) { \
+ usedTokens |= token; \
+ setStatement; \
+} else { \
+ qWarning().nospace() << "Context2D: Duplicate token " << QLatin1String(value) << " found in font string."; \
+ return currentFont; \
+}
+
+/*!
+ Parses a font string based on the CSS shorthand font property.
+
+ See: http://www.w3.org/TR/css3-fonts/#font-prop
+*/
+static QFont qt_font_from_string(const QString& fontString, const QFont &currentFont) {
+ const QStringList tokens = fontString.split(QLatin1Char(' '));
+ if (tokens.size() < 2) {
+ qWarning().nospace() << "Context2D: Insufficent amount of tokens in font string.";
+ return currentFont;
+ }
+
+ QFont newFont;
+ QStringList remainingTokens = tokens;
+ int usedTokens = NoTokens;
+ // Optional properties can be in any order, but font-size and font-family must be last.
+ while (remainingTokens.size() > 2) {
+ const QString token = remainingTokens.takeFirst();
+ if (token.compare(QLatin1String("normal")) == 0) {
+ if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
+ // Could be font-style, font-variant or font-weight.
+ if (!(usedTokens & FontStyle)) {
+ // QFont::StyleNormal is the default for QFont::style.
+ usedTokens = usedTokens | FontStyle;
+ } else if (!(usedTokens & FontVariant)) {
+ // QFont::MixedCase is the default for QFont::capitalization.
+ usedTokens |= FontVariant;
+ } else if (!(usedTokens & FontWeight)) {
+ // QFont::Normal is the default for QFont::weight.
+ usedTokens |= FontWeight;
+ }
+ } else {
+ qWarning().nospace() << "Context2D: Duplicate token \"normal\" found in font string.";
+ return currentFont;
+ }
+ } else if (token.compare(QLatin1String("bold")) == 0) {
+ Q_TRY_SET_TOKEN(FontWeight, "bold", newFont.setBold(true))
+ } else if (token.compare(QLatin1String("italic")) == 0) {
+ Q_TRY_SET_TOKEN(FontStyle, "italic", newFont.setStyle(QFont::StyleItalic))
+ } else if (token.compare(QLatin1String("oblique")) == 0) {
+ Q_TRY_SET_TOKEN(FontStyle, "oblique", newFont.setStyle(QFont::StyleOblique))
+ } else if (token.compare(QLatin1String("small-caps")) == 0) {
+ Q_TRY_SET_TOKEN(FontVariant, "small-caps", newFont.setCapitalization(QFont::SmallCaps))
+ } else {
+ bool conversionOk = false;
+ int weight = token.toInt(&conversionOk);
+ if (conversionOk) {
+ if (weight >= 0 && weight <= 99) {
+ Q_TRY_SET_TOKEN(FontWeight, "<font-weight>", newFont.setWeight(weight))
+ continue;
+ } else {
+ qWarning().nospace() << "Context2D: Invalid font weight " << weight << " found in font string; "
+ << "must be between 0 and 99, inclusive.";
+ return currentFont;
+ }
+ }
+ // The token is invalid or in the wrong place/order in the font string.
+ qWarning().nospace() << "Context2D: Invalid or misplaced token " << token << " found in font string.";
+ return currentFont;
+ }
+ }
+ if (remainingTokens.size() == 2) {
+ // Order must be: font-size font-family.
+ if (!qSetFontSizeFromToken(newFont, remainingTokens.first())) {
+ return currentFont;
+ }
+ if (!qSetFontFamilyFromToken(newFont, remainingTokens.last())) {
+ return currentFont;
+ }
+ return newFont;
+ } else {
+ qWarning().nospace() << "Context2D: Missing font-size and/or font-family tokens in font string.";
+ return currentFont;
+ }
+ return newFont;
+}
class QQuickContext2DEngineData : public QV8Engine::Deletable
{
@@ -781,17 +903,19 @@ QV4::Value QQuickJSContext2DPrototype::method_save(QV4::SimpleCallContext *ctx)
// transformations
/*!
\qmlmethod object QtQuick2::Context2D::rotate(real angle)
- Rotate the canvas around the current origin by \c angle in radians and clockwise direction.
+ Rotate the canvas around the current origin by \a angle in radians and clockwise direction.
+
\code
ctx.rotate(Math.PI/2);
\endcode
+
\image qml-item-canvas-rotate.png
The rotation transformation matrix is as follows:
\image qml-item-canvas-math-rotate.png
- where the \c angle of rotation is in radians.
+ where the \a angle of rotation is in radians.
*/
QV4::Value QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallContext *ctx)
@@ -806,17 +930,20 @@ QV4::Value QQuickJSContext2DPrototype::method_rotate(QV4::SimpleCallContext *ctx
/*!
\qmlmethod object QtQuick2::Context2D::scale(real x, real y)
+
Increases or decreases the size of each unit in the canvas grid by multiplying the scale factors
to the current tranform matrix.
- Where \c x is the scale factor in the horizontal direction and \c y is the scale factor in the
+ \a x is the scale factor in the horizontal direction and \a y is the scale factor in the
vertical direction.
- The following code doubles the horizontal size of an object drawn on the canvas and half its
+
+ The following code doubles the horizontal size of an object drawn on the canvas and halves its
vertical size:
+
\code
ctx.scale(2.0, 0.5);
\endcode
- \image qml-item-canvas-scale.png
+ \image qml-item-canvas-scale.png
*/
QV4::Value QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallContext *ctx)
{
@@ -845,15 +972,15 @@ QV4::Value QQuickJSContext2DPrototype::method_scale(QV4::SimpleCallContext *ctx)
\li \c{a} is the scale factor in the horizontal (x) direction
\image qml-item-canvas-scalex.png
\li \c{c} is the skew factor in the x direction
- \image qml-item-canvas-canvas-skewx.png
+ \image qml-item-canvas-skewx.png
\li \c{e} is the translation in the x direction
- \image qml-item-canvas-canvas-translate.png
+ \image qml-item-canvas-translate.png
\li \c{b} is the skew factor in the y (vertical) direction
- \image qml-item-canvas-canvas-skewy.png
+ \image qml-item-canvas-skewy.png
\li \c{d} is the scale factor in the y direction
- \image qml-item-canvas-canvas-scaley.png
+ \image qml-item-canvas-scaley.png
\li \c{f} is the translation in the y direction
- \image qml-item-canvas-canvas-translatey.png
+ \image qml-item-canvas-translatey.png
\li the last row remains constant
\endlist
The scale factors and skew factors are multiples; \c{e} and \c{f} are
@@ -881,8 +1008,9 @@ QV4::Value QQuickJSContext2DPrototype::method_setTransform(QV4::SimpleCallContex
/*!
\qmlmethod object QtQuick2::Context2D::transform(real a, real b, real c, real d, real e, real f)
+
This method is very similar to setTransform(), but instead of replacing the old
- tranform matrix, this method applies the given tranform matrix to the current matrix by mulitplying to it.
+ transform matrix, this method applies the given tranform matrix to the current matrix by multiplying to it.
The setTransform(a, b, c, d, e, f) method actually resets the current transform to the identity matrix,
and then invokes the transform(a, b, c, d, e, f) method with the same arguments.
@@ -908,10 +1036,10 @@ QV4::Value QQuickJSContext2DPrototype::method_transform(QV4::SimpleCallContext *
/*!
\qmlmethod object QtQuick2::Context2D::translate(real x, real y)
- Translates the origin of the canvas to point (\c x, \c y).
- \c x is the horizontal distance that the origin is translated, in coordinate space units,
- \c y is the vertical distance that the origin is translated, in coordinate space units.
+ Translates the origin of the canvas by a horizontal distance of \a x,
+ and a vertical distance of \a y, in coordinate space units.
+
Translating the origin enables you to draw patterns of different objects on the canvas
without having to measure the coordinates manually for each shape.
*/
@@ -929,7 +1057,9 @@ QV4::Value QQuickJSContext2DPrototype::method_translate(QV4::SimpleCallContext *
/*!
\qmlmethod object QtQuick2::Context2D::resetTransform()
- Reset the transformation matrix to default value.
+
+ Reset the transformation matrix to the default value (equivalent to calling
+ setTransform(\c 1, \c 0, \c 0, \c 1, \c 0, \c 0)).
\sa transform(), setTransform(), reset()
*/
@@ -945,8 +1075,10 @@ QV4::Value QQuickJSContext2DPrototype::method_resetTransform(QV4::SimpleCallCont
/*!
- \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv )
- Shear the transformation matrix with \a sh in horizontal direction and \a sv in vertical direction.
+ \qmlmethod object QtQuick2::Context2D::shear(real sh, real sv)
+
+ Shears the transformation matrix by \a sh in the horizontal direction and
+ \a sv in the vertical direction.
*/
QV4::Value QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallContext *ctx)
{
@@ -962,9 +1094,10 @@ QV4::Value QQuickJSContext2DPrototype::method_shear(QV4::SimpleCallContext *ctx)
/*!
\qmlproperty real QtQuick2::Context2D::globalAlpha
+
Holds the current alpha value applied to rendering operations.
- The value must be in the range from 0.0 (fully transparent) to 1.0 (fully opque).
- The default value is 1.0.
+ The value must be in the range from \c 0.0 (fully transparent) to \c 1.0 (fully opaque).
+ The default value is \c 1.0.
*/
QV4::Value QQuickJSContext2D::method_get_globalAlpha(QV4::SimpleCallContext *ctx)
{
@@ -1826,12 +1959,25 @@ QV4::Value QQuickJSContext2DPrototype::method_strokeRect(QV4::SimpleCallContext
// Complex shapes (paths) API
/*!
- \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)
- Adds an arc to the current subpath that lies on the circumference of the circle whose center is at the point (\c x,\cy) and whose radius is \c radius.
- \image qml-item-canvas-arcTo2.png
- \sa arcTo,
- {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C 2d context standard for arc}
- */
+ \qmlmethod object QtQuick2::Context2D::arc(real x, real y, real radius,
+ real startAngle, real endAngle, bool anticlockwise)
+
+ Adds an arc to the current subpath that lies on the circumference of the
+ circle whose center is at the point (\a x, \a y) and whose radius is
+ \a radius.
+
+ Both \c startAngle and \c endAngle are measured from the x-axis in radians.
+
+ \image qml-item-canvas-arc.png
+
+ \image qml-item-canvas-startAngle.png
+
+ The \a anticlockwise parameter is \c true for each arc in the figure above
+ because they are all drawn in the anticlockwise direction.
+
+ \sa arcTo, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C's 2D
+ Context Standard for arc()}
+*/
QV4::Value QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx)
{
QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
@@ -1860,25 +2006,28 @@ QV4::Value QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx)
}
/*!
- \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2, real y2, real radius)
+ \qmlmethod object QtQuick2::Context2D::arcTo(real x1, real y1, real x2,
+ real y2, real radius)
+
+ Adds an arc with the given control points and radius to the current subpath,
+ connected to the previous point by a straight line. To draw an arc, you
+ begin with the same steps you followed to create a line:
- Adds an arc with the given control points and radius to the current subpath, connected to the previous point by a straight line.
- To draw an arc, you begin with the same steps your followed to create a line:
\list
- \li Call the context.beginPath() method to set a new path.
- \li Call the context.moveTo(\c x, \c y) method to set your starting position on the canvas at the point (\c x,\c y).
- \li To draw an arc or circle, call the context.arcTo(\c x1, \c y1, \c x2, \c y2,\c radius) method.
- This adds an arc with starting point (\c x1,\c y1), ending point (\c x2, \c y2), and radius \c radius to the current subpath and connects
- it to the previous subpath by a straight line.
+ \li Call the beginPath() method to set a new path.
+ \li Call the moveTo(\c x, \c y) method to set your starting position on the
+ canvas at the point (\c x, \c y).
+ \li To draw an arc or circle, call the arcTo(\a x1, \a y1, \a x2, \a y2,
+ \a radius) method. This adds an arc with starting point (\a x1, \a y1),
+ ending point (\a x2, \a y2), and \a radius to the current subpath and
+ connects it to the previous subpath by a straight line.
\endlist
+
\image qml-item-canvas-arcTo.png
- Both startAngle and endAngle are measured from the x axis in units of radians.
- \image qml-item-canvas-startAngle.png
- The anticlockwise has the value TRUE for each arc in the figure above because they are all drawn in the counterclockwise direction.
- \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C 2d
- context standard for arcTo}
- */
+ \sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C's 2D
+ Context Standard for arcTo()}
+*/
QV4::Value QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallContext *ctx)
{
QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>();
@@ -1975,7 +2124,7 @@ QV4::Value QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::SimpleCallConte
The new shape displays. The following shows how a clipping path can
modify how an image displays:
- \image qml-canvas-clip-complex.png
+ \image qml-item-canvas-clip-complex.png
\sa beginPath()
\sa closePath()
\sa stroke()
@@ -2232,13 +2381,28 @@ QV4::Value QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::SimpleCallCont
V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
}
-// text
+
/*!
- \qmlproperty string QtQuick2::Context2D::font
- Holds the current font settings.
+ \qmlproperty string QtQuick2::Context2D::font
+ Holds the current font settings.
+
+ A subset of the
+ \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+ is supported:
+
+ \list
+ \li font-style (optional):
+ normal | italic | oblique
+ \li font-variant (optional): normal | small-caps
+ \li font-weight (optional): normal | bold | 0 ... 99
+ \li font-size: Npx | Npt (where N is a positive number)
+ \li font-family: See \l {http://www.w3.org/TR/CSS2/fonts.html#propdef-font-family}
+ \endlist
+
+ Note that font-size and font-family are mandatory and must be in the order
+ they are shown in above.
- The default font value is "10px sans-serif".
- See \l {http://www.w3.org/TR/2dcontext/#dom-context-2d-font}{w3C 2d context standard for font}
+ The default font value is "10px sans-serif".
*/
QV4::Value QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ctx)
{
@@ -2254,7 +2418,7 @@ QV4::Value QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ctx)
CHECK_CONTEXT_SETTER(r)
QString fs = ctx->argument(0).toQString();
- QFont font = qt_font_from_string(fs);
+ QFont font = qt_font_from_string(fs, r->context->state.font);
if (font != r->context->state.font) {
r->context->state.font = font;
}
@@ -2504,7 +2668,7 @@ QV4::Value QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCallContext
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}
*/
/*!
- \qmlmethod QtQuick2::Context2D::drawImage(variant image, real sx, real sy, real sw, sh, real dx, real dy, real dw, dh)
+ \qmlmethod QtQuick2::Context2D::drawImage(variant image, real sx, real sy, real sw, real sh, real dx, real dy, real dw, real dh)
This is an overloaded function.
Draws the given item as \a image from source point (\a sx, \a sy) and source width \a sw, source height \a sh
onto the canvas at point (\a dx, \a dy) and with width \a dw, height \a dh.
@@ -2784,20 +2948,25 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q
}
}
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
- Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
- */
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(real sw, real sh)
+
+ Creates a CanvasImageData object with the given dimensions(\a sw, \a sh).
+*/
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
- Creates a CanvasImageData object with the same dimensions as the argument.
- */
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(CanvasImageData imageData)
+
+ Creates a CanvasImageData object with the same dimensions as the argument.
+*/
/*!
- \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
- Creates a CanvasImageData object with the given image loaded from \a imageUrl.
- Note:The \a imageUrl must be already loaded before this function call, if not, an empty
- CanvasImageData obect will be returned.
+ \qmlmethod CanvasImageData QtQuick2::Context2D::createImageData(Url imageUrl)
+
+ Creates a CanvasImageData object with the given image loaded from \a imageUrl.
+
+ \note The \a imageUrl must be already loaded before this function call,
+ otherwise an empty CanvasImageData obect will be returned.
- \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(), QtQuick2::Canvas::isImageLoaded
+ \sa Canvas::loadImage(), QtQuick2::Canvas::unloadImage(),
+ QtQuick2::Canvas::isImageLoaded
*/
QV4::Value QQuickJSContext2DPrototype::method_createImageData(QV4::SimpleCallContext *ctx)
{
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index f09e9bb90e..c7c66d6fdd 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -377,8 +377,6 @@ QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) :
, m_pauseOffset(0)
{
setFlag(ItemHasContents);
- connect(this, SIGNAL(runningChanged(bool)),
- this, SLOT(update()));
connect(this, SIGNAL(widthChanged()),
this, SLOT(sizeVertices()));
connect(this, SIGNAL(heightChanged()),
@@ -660,7 +658,10 @@ void QQuickAnimatedSprite::prepareNextFrame()
}
if (m_loops > 0 && m_curLoop >= m_loops) {
frameAt = 0;
- m_running = false;
+ if (m_running) {
+ m_running = false;
+ emit runningChanged(false);
+ }
}
} else {
frameAt = m_curFrame;
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 50c5697487..6ee5e6d046 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -147,6 +147,26 @@ Item {
\endqml
*/
+/*!
+ \qmlmethod bool QtQuick2::KeyEvent::matches(StandardKey key)
+ \since QtQuick 2.2
+
+ Returns \c true if the key event matches the given standard \a key; otherwise returns \c false.
+
+ \qml
+ Item {
+ focus: true
+ Keys.onPressed: {
+ if (event.matches(StandardKey.Undo))
+ myModel.undo();
+ else if (event.matches(StandardKey.Redo))
+ myModel.redo();
+ }
+ }
+ \endqml
+
+ \sa QKeySequence::StandardKey
+*/
/*!
\qmltype MouseEvent
diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h
index 6f1b152ad3..f14e035857 100644
--- a/src/quick/items/qquickevents_p_p.h
+++ b/src/quick/items/qquickevents_p_p.h
@@ -59,6 +59,7 @@
#include <QtCore/qobject.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qevent.h>
+#include <QtGui/qkeysequence.h>
QT_BEGIN_NAMESPACE
@@ -89,6 +90,8 @@ public:
bool isAccepted() { return event.isAccepted(); }
void setAccepted(bool accepted) { event.setAccepted(accepted); }
+ Q_REVISION(2) Q_INVOKABLE bool matches(QKeySequence::StandardKey key) const { return event.matches(key); }
+
private:
QKeyEvent event;
};
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index e6b39d5380..75d509129b 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -2384,7 +2384,7 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
}
// emit moving signals
- bool wasMoving = d->hData.moving || d->vData.moving;
+ bool wasMoving = isMoving();
if (hMovementEnding && d->hData.moving
&& (!d->pressed && !d->stealMouse)) {
d->hData.moving = false;
@@ -2397,7 +2397,7 @@ void QQuickFlickable::movementEnding(bool hMovementEnding, bool vMovementEnding)
d->vMoved = false;
emit movingVerticallyChanged();
}
- if (wasMoving && (!d->hData.moving || !d->vData.moving)) {
+ if (wasMoving && !isMoving()) {
emit movingChanged();
emit movementEnded();
}
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index bc71a1c064..37276d5603 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -65,19 +65,8 @@ QT_BEGIN_NAMESPACE
class FxGridItemSG : public FxViewItem
{
public:
- FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxGridItemSG(QQuickItem *i, QQuickGridView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickGridViewAttached*>(qmlAttachedPropertiesObject<QQuickGridView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxGridItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
qreal position() const {
@@ -470,7 +459,7 @@ FxViewItem *QQuickGridViewPrivate::newViewItem(int modelIndex, QQuickItem *item)
{
Q_Q(QQuickGridView);
Q_UNUSED(modelIndex);
- return new FxGridItemSG(item, q, false, false);
+ return new FxGridItemSG(item, q, false);
}
void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item)
@@ -478,8 +467,7 @@ void QQuickGridViewPrivate::initializeViewItem(FxViewItem *item)
QQuickItemViewPrivate::initializeViewItem(item);
// need to track current items that are animating
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(true);
}
bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer)
@@ -739,7 +727,8 @@ void QQuickGridViewPrivate::createHighlight()
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true, true);
+ FxGridItemSG *newHighlight = new FxGridItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight)
resetHighlightPosition();
highlightXAnimator = new QSmoothedAnimation;
@@ -817,7 +806,8 @@ void QQuickGridViewPrivate::updateFooter()
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxGridItemSG(item, q, true, true);
+ footer = new FxGridItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
@@ -861,7 +851,8 @@ void QQuickGridViewPrivate::updateHeader()
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxGridItemSG(item, q, true, true);
+ header = new FxGridItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index d0417c80f3..ce23b99e8c 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -3068,9 +3068,9 @@ void QQuickItemPrivate::_q_resourceObjectDeleted(QObject *object)
relationship with other items.
Margins apply to top, bottom, left, right, and fill anchors.
- The \c anchors.margins property can be used to set all of the various margins at once, to the same value.
+ The \l anchors.margins property can be used to set all of the various margins at once, to the same value.
It will not override a specific margin that has been previously set; to clear an explicit margin
- set it's value to \c undefined.
+ set its value to \c undefined.
Note that margins are anchor-specific and are not applied if an item does not
use anchors.
@@ -3117,14 +3117,14 @@ void QQuickItemPrivate::_q_resourceObjectDeleted(QObject *object)
\endqml
\endtable
- \c anchors.fill provides a convenient way for one item to have the
+ \l anchors.fill provides a convenient way for one item to have the
same geometry as another item, and is equivalent to connecting all
four directional anchors.
To clear an anchor value, set it to \c undefined.
- \c anchors.alignWhenCentered (default true) forces centered anchors to align to a
- whole pixel, i.e. if the item being centered has an odd width/height the item
+ \l anchors.alignWhenCentered (default \c true) forces centered anchors to align to a
+ whole pixel; if the item being centered has an odd \l width or \l height, the item
will be positioned on a whole pixel rather than being placed on a half-pixel.
This ensures the item is painted crisply. There are cases where this is not
desirable, for example when rotating the item jitters may be apparent as the
diff --git a/src/quick/items/qquickitem.h b/src/quick/items/qquickitem.h
index 6ad121fffa..c11f65affd 100644
--- a/src/quick/items/qquickitem.h
+++ b/src/quick/items/qquickitem.h
@@ -324,7 +324,7 @@ public:
Q_INVOKABLE void mapToItem(QQmlV4Function*) const;
Q_INVOKABLE void forceActiveFocus();
Q_INVOKABLE void forceActiveFocus(Qt::FocusReason reason);
- Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
+ Q_REVISION(1) Q_INVOKABLE QQuickItem *nextItemInFocusChain(bool forward = true);
Q_INVOKABLE QQuickItem *childAt(qreal x, qreal y) const;
#ifndef QT_NO_IM
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index a6dabee7ba..f8f622a1b9 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -51,13 +51,14 @@ QT_BEGIN_NAMESPACE
#define QML_VIEW_DEFAULTCACHEBUFFER 320
#endif
-FxViewItem::FxViewItem(QQuickItem *i, bool own, bool trackGeometry)
+FxViewItem::FxViewItem(QQuickItem *i, QQuickItemView *v, bool own)
: item(i)
+ , view(v)
, transitionableItem(0)
, attached(0)
, ownItem(own)
, releaseAfterTransition(false)
- , trackGeom(trackGeometry)
+ , trackGeom(false)
{
}
@@ -96,6 +97,23 @@ void FxViewItem::setVisible(bool visible)
QQuickItemPrivate::get(item)->setCulled(!visible);
}
+void FxViewItem::trackGeometry(bool track)
+{
+ if (track) {
+ if (!trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = true;
+ }
+ } else {
+ if (trackGeom) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
+ trackGeom = false;
+ }
+ }
+}
+
QQuickItemViewTransitioner::TransitionType FxViewItem::scheduledTransitionType() const
{
return transitionableItem ? transitionableItem->nextTransitionType : QQuickItemViewTransitioner::NoTransition;
@@ -2131,6 +2149,7 @@ void QQuickItemViewPrivate::prepareRemoveTransitions(QHash<QQmlChangeSet::MoveKe
bool isRemove = it.key().moveId < 0;
if (isRemove) {
FxViewItem *item = *it;
+ item->trackGeometry(false);
item->releaseAfterTransition = true;
releasePendingTransition.append(item);
item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::RemoveTransition, true);
@@ -2272,8 +2291,8 @@ bool QQuickItemViewPrivate::releaseItem(FxViewItem *item)
return true;
if (trackedItem == item)
trackedItem = 0;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
+ item->trackGeometry(false);
+
QQmlInstanceModel::ReleaseFlags flags = model->release(item->item);
if (flags == 0) {
// item was not destroyed, and we no longer reference it.
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 6b734eab92..7e3d064ca3 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
class FxViewItem
{
public:
- FxViewItem(QQuickItem *, bool own, bool trackGeometry);
+ FxViewItem(QQuickItem *, QQuickItemView *, bool own);
virtual ~FxViewItem();
qreal itemX() const;
@@ -64,6 +64,7 @@ public:
void moveTo(const QPointF &pos, bool immediate);
void setVisible(bool visible);
+ void trackGeometry(bool track);
QQuickItemViewTransitioner::TransitionType scheduledTransitionType() const;
bool transitionScheduledOrRunning() const;
@@ -83,6 +84,7 @@ public:
virtual bool contains(qreal x, qreal y) const = 0;
QQuickItem *item;
+ QQuickItemView *view;
QQuickItemViewTransitionableItem *transitionableItem;
QQuickItemViewAttached *attached;
int index;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 4d42c9ece1..f0e39c5e5a 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -244,19 +244,8 @@ void QQuickViewSection::setLabelPositioning(int l)
class FxListItemSG : public FxViewItem
{
public:
- FxListItemSG(QQuickItem *i, QQuickListView *v, bool own, bool trackGeometry) : FxViewItem(i, own, trackGeometry), view(v) {
+ FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, v, own), view(v) {
attached = static_cast<QQuickListViewAttached*>(qmlAttachedPropertiesObject<QQuickListView>(item));
- if (trackGeometry) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->addItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
- }
-
- ~FxListItemSG() {
- if (trackGeom) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->removeItemChangeListener(QQuickItemViewPrivate::get(view), QQuickItemPrivate::Geometry);
- }
}
inline QQuickItem *section() const {
@@ -570,7 +559,7 @@ FxViewItem *QQuickListViewPrivate::newViewItem(int modelIndex, QQuickItem *item)
{
Q_Q(QQuickListView);
- FxListItemSG *listItem = new FxListItemSG(item, q, false, false);
+ FxListItemSG *listItem = new FxListItemSG(item, q, false);
listItem->index = modelIndex;
// initialise attached properties
@@ -598,8 +587,8 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item)
{
QQuickItemViewPrivate::initializeViewItem(item);
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item);
- itemPrivate->addItemChangeListener(this, QQuickItemPrivate::Geometry);
+ // need to track current items that are animating
+ item->trackGeometry(true);
if (sectionCriteria && sectionCriteria->delegate()) {
if (QString::compare(item->attached->m_prevSection, item->attached->m_section, Qt::CaseInsensitive))
@@ -876,7 +865,8 @@ void QQuickListViewPrivate::createHighlight()
if (currentItem) {
QQuickItem *item = createHighlightItem();
if (item) {
- FxListItemSG *newHighlight = new FxListItemSG(item, q, true, true);
+ FxListItemSG *newHighlight = new FxListItemSG(item, q, true);
+ newHighlight->trackGeometry(true);
if (autoHighlight) {
newHighlight->setSize(static_cast<FxListItemSG*>(currentItem)->itemSize());
@@ -1299,7 +1289,8 @@ void QQuickListViewPrivate::updateFooter()
QQuickItem *item = createComponentItem(footerComponent, 1.0);
if (!item)
return;
- footer = new FxListItemSG(item, q, true, true);
+ footer = new FxListItemSG(item, q, true);
+ footer->trackGeometry(true);
created = true;
}
@@ -1329,7 +1320,8 @@ void QQuickListViewPrivate::updateHeader()
QQuickItem *item = createComponentItem(headerComponent, 1.0);
if (!item)
return;
- header = new FxListItemSG(item, q, true, true);
+ header = new FxListItemSG(item, q, true);
+ header->trackGeometry(true);
created = true;
}
@@ -2330,6 +2322,7 @@ void QQuickListView::setSnapMode(SnapMode mode)
if (d->snapMode != mode) {
d->snapMode = mode;
emit snapModeChanged();
+ d->fixupPosition();
}
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 37a0c8e407..e7284f870b 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1794,6 +1794,10 @@ void QQuickText::setVAlign(VAlignment align)
return;
d->vAlign = align;
+
+ if (isComponentComplete())
+ d->updateLayout();
+
emit verticalAlignmentChanged(align);
}
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index e29e48c5d0..4b4958e122 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -47,6 +47,24 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QQuickTextDocument
+ \since 5.1
+ \brief The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit
+ \inmodule QtQuick
+
+ This class provides access to the QTextDocument of QQuickTextEdit elements.
+ This is provided to allow usage of the \l{Rich Text Processing} functionalities of Qt.
+ You are not allowed to modify the document, but it can be used to output content, for example with \l{QTextDocumentWriter}),
+ or provide additional formatting, for example with \l{QSyntaxHighlighter}.
+
+ The class has to be used from C++ directly, using the property of the \l TextEdit.
+
+ Warning: The QTextDocument provided is used internally by \l {Qt Quick} elements to provide text manipulation primitives.
+ You are not allowed to perform any modification of the internal state of the QTextDocument. If you do, the element
+ in question may stop functioning or crash.
+*/
+
class QQuickTextDocumentPrivate : public QObjectPrivate
{
public:
diff --git a/src/quick/items/qquicktextdocument.h b/src/quick/items/qquicktextdocument.h
index 7c22c01d5a..7c87dfd1e7 100644
--- a/src/quick/items/qquicktextdocument.h
+++ b/src/quick/items/qquicktextdocument.h
@@ -47,24 +47,6 @@
QT_BEGIN_NAMESPACE
-/*!
- \class QQuickTextDocument
- \since 5.1
- \brief The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit
- \inmodule QtQuick
-
- This class provides access to the QTextDocument of QQuickTextEdit elements.
- This is provided to allow usage of the \l{Rich Text Processing} functionalities of Qt.
- You are not allowed to modify the document, but it can be used to output content, for example with \l{QTextDocumentWriter}),
- or provide additional formatting, for example with \l{QSyntaxHighlighter}.
-
- The class has to be used from C++ directly, using the property of the \l TextEdit.
-
- Warning: The QTextDocument provided is used internally by \l {Qt Quick} elements to provide text manipulation primitives.
- You are not allowed to perform any modification of the internal state of the QTextDocument. If you do, the element
- in question may stop functioning or crash.
-*/
-
class QQuickTextDocumentPrivate;
class Q_QUICK_EXPORT QQuickTextDocument : public QObject
{
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 6e2262831d..6ee05700ae 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -135,6 +135,37 @@ namespace {
return format(pos);
}
};
+
+ class RootNode : public QSGTransformNode
+ {
+ public:
+ RootNode() : cursorNode(0), frameDecorationsNode(0)
+ { }
+
+ void resetFrameDecorations(QQuickTextNode* newNode)
+ {
+ if (frameDecorationsNode) {
+ removeChildNode(frameDecorationsNode);
+ delete frameDecorationsNode;
+ }
+ frameDecorationsNode = newNode;
+ newNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ void resetCursorNode(QSGSimpleRectNode* newNode)
+ {
+ if (cursorNode)
+ removeChildNode(cursorNode);
+ delete cursorNode;
+ cursorNode = newNode;
+ appendChildNode(cursorNode);
+ cursorNode->setFlag(QSGNode::OwnedByParent);
+ }
+
+ QSGSimpleRectNode *cursorNode;
+ QQuickTextNode* frameDecorationsNode;
+
+ };
}
QQuickTextEdit::QQuickTextEdit(QQuickItem *parent)
@@ -1737,7 +1768,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
d->updateType = QQuickTextEditPrivate::UpdateNone;
- QSGTransformNode *rootNode = static_cast<QSGTransformNode *>(oldNode);
+ RootNode *rootNode = static_cast<RootNode *>(oldNode);
TextNodeIterator nodeIterator = d->textNodeMap.begin();
while (nodeIterator != d->textNodeMap.end() && !(*nodeIterator)->dirty())
++nodeIterator;
@@ -1746,7 +1777,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if (!oldNode || nodeIterator < d->textNodeMap.end()) {
if (!oldNode)
- rootNode = new QSGTransformNode;
+ rootNode = new RootNode;
int firstDirtyPos = 0;
if (nodeIterator != d->textNodeMap.end()) {
@@ -1760,11 +1791,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
// FIXME: the text decorations could probably be handled separately (only updated for affected textFrames)
- if (d->frameDecorationsNode) {
- rootNode->removeChildNode(d->frameDecorationsNode);
- delete d->frameDecorationsNode;
- }
- d->frameDecorationsNode = d->createTextNode();
+ rootNode->resetFrameDecorations(d->createTextNode());
QQuickTextNode *node = 0;
@@ -1780,7 +1807,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
while (!frames.isEmpty()) {
QTextFrame *textFrame = frames.takeFirst();
frames.append(textFrame->childFrames());
- d->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
+ rootNode->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
if (textFrame->lastPosition() < firstDirtyPos || (firstCleanNode && textFrame->firstPosition() >= firstCleanNode->startPos()))
@@ -1843,9 +1870,9 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
}
d->addCurrentTextNodeToRoot(rootNode, node, nodeIterator, nodeStart);
}
- d->frameDecorationsNode->m_engine->addToSceneGraph(d->frameDecorationsNode, QQuickText::Normal, QColor());
+ rootNode->frameDecorationsNode->m_engine->addToSceneGraph(rootNode->frameDecorationsNode, QQuickText::Normal, QColor());
// Now prepend the frame decorations since we want them rendered first, with the text nodes and cursor in front.
- rootNode->prependChildNode(d->frameDecorationsNode);
+ rootNode->prependChildNode(rootNode->frameDecorationsNode);
Q_ASSERT(nodeIterator == d->textNodeMap.end() || (*nodeIterator) == firstCleanNode);
// Update the position of the subsequent text blocks.
@@ -1871,11 +1898,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
QColor color = (!d->cursorVisible || !d->control->cursorOn())
? QColor(0, 0, 0, 0)
: d->color;
- if (d->cursorNode)
- rootNode->removeChildNode(d->cursorNode);
- delete d->cursorNode;
- d->cursorNode = new QSGSimpleRectNode(cursorRectangle(), color);
- rootNode->appendChildNode(d->cursorNode);
+ rootNode->resetCursorNode(new QSGSimpleRectNode(cursorRectangle(), color));
}
return rootNode;
diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h
index ec3cf1cec5..331e5bb13f 100644
--- a/src/quick/items/qquicktextedit_p_p.h
+++ b/src/quick/items/qquicktextedit_p_p.h
@@ -93,8 +93,7 @@ public:
QQuickTextEditPrivate()
: color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF))
, textMargin(0.0), xoff(0), yoff(0), font(sourceFont), cursorComponent(0), cursorItem(0), document(0), control(0)
- , quickDocument(0), frameDecorationsNode(0), cursorNode(0)
- , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
+ , quickDocument(0), lastSelectionStart(0), lastSelectionEnd(0), lineCount(0)
, hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop)
, format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap)
, renderType(QQuickTextEdit::QtRendering)
@@ -156,8 +155,6 @@ public:
QQuickTextControl *control;
QQuickTextDocument *quickDocument;
QList<Node*> textNodeMap;
- QQuickTextNode *frameDecorationsNode;
- QSGSimpleRectNode *cursorNode;
int lastSelectionStart;
int lastSelectionEnd;
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index cf2526e5a7..c34bad5430 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -3196,6 +3196,18 @@ void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha)
Requests the window to be activated, i.e. receive keyboard focus.
*/
+/*!
+ \qmlmethod QtQuick2::Window::alert(int msec)
+ \since QtQuick 2.1
+
+ Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the
+ default), then the alert is shown indefinitely until the window becomes
+ active again.
+
+ In alert state, the window indicates that it demands attention, for example by
+ flashing or bouncing the taskbar entry.
+*/
+
#include "moc_qquickwindow.cpp"
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 9346236db9..c0794d0d69 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -556,7 +556,6 @@ static void qt_print_material_count()
QSGMaterial::QSGMaterial()
: m_flags(0)
- , m_reserved(0)
{
#ifndef QT_NO_DEBUG
if (qsg_leak_check) {
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.h b/src/quick/scenegraph/coreapi/qsgmaterial.h
index 20ab21ad28..ee8889deac 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.h
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.h
@@ -133,7 +133,6 @@ public:
void setFlag(Flags flags, bool on = true);
private:
- friend class QSGContext;
Flags m_flags;
void *m_reserved;
Q_DISABLE_COPY(QSGMaterial)
diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp
index 866d678412..a142a23c67 100644
--- a/src/quick/scenegraph/qsgcontext.cpp
+++ b/src/quick/scenegraph/qsgcontext.cpp
@@ -507,16 +507,10 @@ QSGDepthStencilBufferManager *QSGContext::depthStencilBufferManager()
QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
{
Q_D(QSGContext);
-
- if (material->m_reserved)
- return reinterpret_cast<QSGMaterialShader *>(material->m_reserved);
-
QSGMaterialType *type = material->type();
QSGMaterialShader *shader = d->materials.value(type);
- if (shader) {
- material->m_reserved = shader;
+ if (shader)
return shader;
- }
#ifndef QSG_NO_RENDER_TIMING
if (qsg_render_timing || QQmlProfilerService::enabled)
@@ -524,7 +518,6 @@ QSGMaterialShader *QSGContext::prepareMaterial(QSGMaterial *material)
#endif
shader = material->createShader();
- material->m_reserved = shader;
shader->compile();
shader->initialize();
d->materials[type] = shader;
diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
index bdbce6165b..3556a4ebe5 100644
--- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
+++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp
@@ -219,7 +219,7 @@ QSGMaterialShader *QSGDistanceFieldTextMaterial::createShader() const
bool QSGDistanceFieldTextMaterial::updateTextureSize()
{
if (!m_texture)
- m_texture = m_glyph_cache->glyphTexture(-1); // invalid texture
+ m_texture = m_glyph_cache->glyphTexture(0); // invalid texture
if (m_texture->size != m_size) {
m_size = m_texture->size;
@@ -240,8 +240,8 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const
}
if (m_color != other->m_color)
return &m_color < &other->m_color ? -1 : 1;
- int t0 = m_texture ? m_texture->textureId : -1;
- int t1 = other->m_texture ? other->m_texture->textureId : -1;
+ int t0 = m_texture ? m_texture->textureId : 0;
+ int t1 = other->m_texture ? other->m_texture->textureId : 0;
return t0 - t1;
}
diff --git a/src/quick/scenegraph/util/qsgsimplematerial.cpp b/src/quick/scenegraph/util/qsgsimplematerial.cpp
index ee7a272fbe..35ad56a44b 100644
--- a/src/quick/scenegraph/util/qsgsimplematerial.cpp
+++ b/src/quick/scenegraph/util/qsgsimplematerial.cpp
@@ -180,17 +180,29 @@
/*!
\fn void QSGSimpleMaterialShader::resolveUniforms()
- \internal
+
+ Reimplement this function to resolve the location of named uniforms
+ in the shader program.
+
+ This function is called when the material shader is initialized.
*/
/*!
\fn const char *QSGSimpleMaterialShader::uniformMatrixName() const
- \internal
+
+ Reimplement this function to give a different name to the uniform for
+ item transformation. The default value is \c qt_Matrix.
+
*/
/*!
\fn const char *QSGSimpleMaterialShader::uniformOpacityName() const
- \internal
+
+ Reimplement this function to give a different name to the uniform for
+ item opacity. The default value is \c qt_Opacity.
+
+ If the shader program does not implement the item opacity, the
+ implemented function should return a null pointer.
*/
/*!
diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp
index a69f43f8d6..f17aa59e3e 100644
--- a/src/quick/scenegraph/util/qsgtexture.cpp
+++ b/src/quick/scenegraph/util/qsgtexture.cpp
@@ -222,7 +222,7 @@ static void qt_debug_remove_texture(QSGTexture* texture)
\section1 Texture Atlasses
- Some scene graph backens use texture atlasses, grouping multiple
+ Some scene graph backends use texture atlasses, grouping multiple
small textures into one large texture. If this is the case, the
function isAtlasTexture() will return true. Atlasses are used to
aid the rendering algorithm to do better sorting which increases
@@ -528,6 +528,7 @@ QSGPlainTexture::QSGPlainTexture()
, m_texture_id(0)
, m_has_alpha(false)
, m_has_mipmaps(false)
+ , m_dirty_texture(false)
, m_dirty_bind_options(false)
, m_owns_texture(true)
, m_mipmaps_generated(false)
diff --git a/src/quick/util/qquickapplication.cpp b/src/quick/util/qquickapplication.cpp
index bc8b724a00..2de28a9509 100644
--- a/src/quick/util/qquickapplication.cpp
+++ b/src/quick/util/qquickapplication.cpp
@@ -103,9 +103,15 @@ bool QQuickApplication::eventFilter(QObject *, QEvent *event)
{
Q_D(QQuickApplication);
if ((event->type() == QEvent::ApplicationActivate) ||
- (event->type() == QEvent::ApplicationDeactivate)) {
+ (event->type() == QEvent::ApplicationDeactivate) ||
+ (event->type() == QEvent::ApplicationStateChange)) {
bool wasActive = d->isActive;
- d->isActive = (event->type() == QEvent::ApplicationActivate);
+ if (event->type() == QEvent::ApplicationStateChange) {
+ QApplicationStateChangeEvent * e= static_cast<QApplicationStateChangeEvent*>(event);
+ d->isActive = e->applicationState() == Qt::ApplicationActive;
+ } else {
+ d->isActive = (event->type() == QEvent::ApplicationActivate);
+ }
if (d->isActive != wasActive) {
emit activeChanged();
}
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index a45ec4ef15..fdf8314145 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -58,6 +58,9 @@
#include <private/qquickanimationcontroller_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/QInputMethod>
+#include <QtGui/QKeySequence>
+
+Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void QQuickUtilModule::defineModule()
{
@@ -91,4 +94,7 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickStateOperation>();
qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser);
+
+ qRegisterMetaType<QKeySequence::StandardKey>();
+ qmlRegisterUncreatableType<QKeySequence, 2>("QtQuick", 2, 2, "StandardKey", QStringLiteral("Cannot create an instance of StandardKey."));
}