aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items')
-rwxr-xr-xsrc/quick/items/checksync.pl106
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp80
-rw-r--r--src/quick/items/context2d/qquickcanvasitem_p.h4
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp1297
-rw-r--r--src/quick/items/context2d/qquickcontext2d_p.h18
-rw-r--r--src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h4
-rw-r--r--src/quick/items/context2d/qquickcontext2dtexture_p.h16
-rw-r--r--src/quick/items/context2d/qquickcontext2dtile_p.h8
-rw-r--r--src/quick/items/qquickaccessibleattached_p.h2
-rw-r--r--src/quick/items/qquickanchors.cpp38
-rw-r--r--src/quick/items/qquickanchors_p_p.h4
-rw-r--r--src/quick/items/qquickanimatedimage.cpp4
-rw-r--r--src/quick/items/qquickanimatedsprite.cpp2
-rw-r--r--src/quick/items/qquickborderimage.cpp2
-rw-r--r--src/quick/items/qquickdrag.cpp12
-rw-r--r--src/quick/items/qquickdrag_p.h4
-rw-r--r--src/quick/items/qquickdroparea.cpp2
-rw-r--r--src/quick/items/qquickdroparea_p.h2
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickflickable.cpp90
-rw-r--r--src/quick/items/qquickflickable_p.h14
-rw-r--r--src/quick/items/qquickflickable_p_p.h9
-rw-r--r--src/quick/items/qquickflickablebehavior_p.h12
-rw-r--r--src/quick/items/qquickflipable.cpp6
-rw-r--r--src/quick/items/qquickflipable_p.h2
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp4
-rw-r--r--src/quick/items/qquickgridview.cpp121
-rw-r--r--src/quick/items/qquickgridview_p.h12
-rw-r--r--src/quick/items/qquickimage.cpp15
-rw-r--r--src/quick/items/qquickimagebase.cpp15
-rw-r--r--src/quick/items/qquickimagebase_p_p.h3
-rw-r--r--src/quick/items/qquickitem.cpp82
-rw-r--r--src/quick/items/qquickitem_p.h8
-rw-r--r--src/quick/items/qquickitemanimation.cpp14
-rw-r--r--src/quick/items/qquickitemanimation_p_p.h4
-rw-r--r--src/quick/items/qquickitemgrabresult.cpp34
-rw-r--r--src/quick/items/qquickitemgrabresult.h7
-rw-r--r--src/quick/items/qquickitemsmodule.cpp12
-rw-r--r--src/quick/items/qquickitemview.cpp129
-rw-r--r--src/quick/items/qquickitemview_p.h24
-rw-r--r--src/quick/items/qquickitemview_p_p.h16
-rw-r--r--src/quick/items/qquickitemviewtransition.cpp4
-rw-r--r--src/quick/items/qquickitemviewtransition_p.h2
-rw-r--r--src/quick/items/qquicklistview.cpp214
-rw-r--r--src/quick/items/qquicklistview_p.h16
-rw-r--r--src/quick/items/qquickloader.cpp2
-rw-r--r--src/quick/items/qquickloader_p_p.h2
-rw-r--r--src/quick/items/qquickmousearea.cpp50
-rw-r--r--src/quick/items/qquickmousearea_p.h6
-rw-r--r--src/quick/items/qquickmousearea_p_p.h1
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp73
-rw-r--r--src/quick/items/qquickmultipointtoucharea_p.h19
-rw-r--r--src/quick/items/qquickopenglshadereffect.cpp16
-rw-r--r--src/quick/items/qquickopenglshadereffect_p.h1
-rw-r--r--src/quick/items/qquickopenglshadereffectnode.cpp10
-rw-r--r--src/quick/items/qquickpainteditem.cpp2
-rw-r--r--src/quick/items/qquickpathview.cpp107
-rw-r--r--src/quick/items/qquickpathview_p.h20
-rw-r--r--src/quick/items/qquickpathview_p_p.h4
-rw-r--r--src/quick/items/qquickpositioners.cpp101
-rw-r--r--src/quick/items/qquickpositioners_p.h3
-rw-r--r--src/quick/items/qquickrepeater.cpp2
-rw-r--r--src/quick/items/qquickscreen.cpp195
-rw-r--r--src/quick/items/qquickscreen_p.h48
-rw-r--r--src/quick/items/qquickshadereffectmesh.cpp17
-rw-r--r--src/quick/items/qquickshadereffectmesh_p.h2
-rw-r--r--src/quick/items/qquickshadereffectsource.cpp2
-rw-r--r--src/quick/items/qquickspriteengine.cpp14
-rw-r--r--src/quick/items/qquickspriteengine_p.h10
-rw-r--r--src/quick/items/qquickspritesequence.cpp2
-rw-r--r--src/quick/items/qquickstateoperations.cpp16
-rw-r--r--src/quick/items/qquickstateoperations_p.h4
-rw-r--r--src/quick/items/qquicktext.cpp105
-rw-r--r--src/quick/items/qquicktext_p.h8
-rw-r--r--src/quick/items/qquicktext_p_p.h1
-rw-r--r--src/quick/items/qquicktextcontrol.cpp4
-rw-r--r--src/quick/items/qquicktextcontrol_p.h6
-rw-r--r--src/quick/items/qquicktextdocument.cpp4
-rw-r--r--src/quick/items/qquicktextdocument_p.h8
-rw-r--r--src/quick/items/qquicktextedit.cpp4
-rw-r--r--src/quick/items/qquicktextinput.cpp66
-rw-r--r--src/quick/items/qquicktextinput_p.h1
-rw-r--r--src/quick/items/qquicktextutil.cpp4
-rw-r--r--src/quick/items/qquickview.cpp2
-rw-r--r--src/quick/items/qquickview.h16
-rw-r--r--src/quick/items/qquickview_p.h2
-rw-r--r--src/quick/items/qquickwindow.cpp41
-rw-r--r--src/quick/items/qquickwindow.h1
-rw-r--r--src/quick/items/qquickwindow_p.h4
-rw-r--r--src/quick/items/qquickwindowmodule.cpp18
-rw-r--r--src/quick/items/qquickwindowmodule_p.h5
91 files changed, 2036 insertions, 1469 deletions
diff --git a/src/quick/items/checksync.pl b/src/quick/items/checksync.pl
deleted file mode 100755
index c9771bb10c..0000000000
--- a/src/quick/items/checksync.pl
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the Declarative module of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU Lesser General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU Lesser
-## General Public License version 3 as published by the Free Software
-## Foundation and appearing in the file LICENSE.LGPL3 included in the
-## packaging of this file. Please review the following information to
-## ensure the GNU Lesser General Public License version 3 requirements
-## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 2.0 or (at your option) the GNU General
-## Public license version 3 or any later version approved by the KDE Free
-## Qt Foundation. The licenses are as published by the Free Software
-## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-2.0.html and
-## https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-use strict;
-use warnings;
-
-die "Usage: $0 <QML directory>" if (@ARGV != 1);
-
-my @excludes;
-open (SYNCEXCLUDES, "<", "syncexcludes");
-while (<SYNCEXCLUDES>) {
- if (/^([a-zA-Z0-9\._]+)/) {
- my $exclude = $1;
- push (@excludes, $exclude);
- }
-}
-
-my $portdir = ".";
-my $qmldir = $ARGV[0];
-
-opendir (PORTDIR, $portdir) or die "Cannot open port directory";
-opendir (QMLDIR, $qmldir) or die "Cannot open QML directory";
-
-my @portfiles = readdir(PORTDIR);
-my @qmlfiles = readdir(QMLDIR);
-
-closedir(PORTDIR);
-closedir(QMLDIR);
-
-foreach my $qmlfile (@qmlfiles) {
- if ($qmlfile =~ /^qdeclarative.*\.cpp$/ or $qmlfile =~ /qdeclarative.*\.h$/) {
-
- if (grep { $_ eq $qmlfile} @excludes) {
- next;
- }
-
- my $portfile = $qmlfile;
- $portfile =~ s/^qdeclarative/qsg/;
-
- if (grep { $_ eq $portfile} @portfiles) {
-
- open (PORTFILE, "<", "$portdir/$portfile") or die("Cannot open $portdir/$portfile for reading");
-
- my $firstline = <PORTFILE>;
-
- close (PORTFILE);
-
- if ($firstline and $firstline =~ /^\/\/ Commit: ([a-z0-9]+)/) {
- my $sha1 = $1;
- my $commitSha1 = "";
-
- my $output = `cd $qmldir; git log $qmlfile | head -n 1`;
- if ($output =~ /commit ([a-z0-9]+)/) {
- $commitSha1 = $1;
- }
-
- if ($commitSha1 eq $sha1) {
- print ("$portfile: OK\n");
- } else {
- print ("$portfile: OUT OF DATE\n");
- }
- } else {
- print ("$portfile: OUT OF DATE\n");
- }
- } else {
- print ("$portfile: MISSING\n");
- }
- }
-}
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 28e9173bf7..1167f408f5 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -354,7 +354,7 @@ void QQuickCanvasItem::setContextType(const QString &contextType)
return;
if (d->context) {
- qmlInfo(this) << "Canvas already initialized with a different context type";
+ qmlWarning(this) << "Canvas already initialized with a different context type";
return;
}
@@ -517,7 +517,7 @@ void QQuickCanvasItem::setRenderTarget(QQuickCanvasItem::RenderTarget target)
Q_D(QQuickCanvasItem);
if (d->renderTarget != target) {
if (d->context) {
- qmlInfo(this) << "Canvas:renderTarget not changeble once context is active.";
+ qmlWarning(this) << "Canvas:renderTarget not changeble once context is active.";
return;
}
@@ -561,7 +561,7 @@ void QQuickCanvasItem::setRenderStrategy(QQuickCanvasItem::RenderStrategy strate
Q_D(QQuickCanvasItem);
if (d->renderStrategy != strategy) {
if (d->context) {
- qmlInfo(this) << "Canvas:renderStrategy not changeable once context is active.";
+ qmlWarning(this) << "Canvas:renderStrategy not changeable once context is active.";
return;
}
d->renderStrategy = strategy;
@@ -640,6 +640,17 @@ void QQuickCanvasItem::releaseResources()
}
}
+bool QQuickCanvasItem::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::PolishRequest:
+ polish();
+ return true;
+ default:
+ return QQuickItem::event(event);
+ }
+}
+
void QQuickCanvasItem::invalidateSceneGraph()
{
Q_D(QQuickCanvasItem);
@@ -651,6 +662,12 @@ void QQuickCanvasItem::invalidateSceneGraph()
d->textureProvider = 0;
}
+void QQuickCanvasItem::schedulePolish()
+{
+ auto polishRequestEvent = new QEvent(QEvent::PolishRequest);
+ QCoreApplication::postEvent(this, polishRequestEvent);
+}
+
void QQuickCanvasItem::componentComplete()
{
QQuickItem::componentComplete();
@@ -839,13 +856,13 @@ void QQuickCanvasItem::getContext(QQmlV4Function *args)
QV4::Scope scope(args->v4engine());
QV4::ScopedString str(scope, (*args)[0]);
if (!str) {
- qmlInfo(this) << "getContext should be called with a string naming the required context type";
+ qmlWarning(this) << "getContext should be called with a string naming the required context type";
args->setReturnValue(QV4::Encode::null());
return;
}
if (!d->available) {
- qmlInfo(this) << "Unable to use getContext() at this time, please wait for available: true";
+ qmlWarning(this) << "Unable to use getContext() at this time, please wait for available: true";
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -858,7 +875,7 @@ void QQuickCanvasItem::getContext(QQmlV4Function *args)
return;
}
- qmlInfo(this) << "Canvas already initialized with a different context type";
+ qmlWarning(this) << "Canvas already initialized with a different context type";
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -881,7 +898,7 @@ void QQuickCanvasItem::requestAnimationFrame(QQmlV4Function *args)
QV4::Scope scope(args->v4engine());
QV4::ScopedFunctionObject f(scope, (*args)[0]);
if (!f) {
- qmlInfo(this) << "requestAnimationFrame should be called with an animation callback function";
+ qmlWarning(this) << "requestAnimationFrame should be called with an animation callback function";
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -892,8 +909,9 @@ void QQuickCanvasItem::requestAnimationFrame(QQmlV4Function *args)
d->animationCallbacks.insert(++id, QV4::PersistentValue(scope.engine, f->asReturnedValue()));
+ // QTBUG-55778: Calling polish directly here can lead to a polish loop
if (isVisible())
- polish();
+ schedulePolish();
args->setReturnValue(QV4::Encode(id));
}
@@ -909,7 +927,7 @@ void QQuickCanvasItem::cancelRequestAnimationFrame(QQmlV4Function *args)
QV4::Scope scope(args->v4engine());
QV4::ScopedValue v(scope, (*args)[0]);
if (!v->isInteger()) {
- qmlInfo(this) << "cancelRequestAnimationFrame should be called with an animation callback id";
+ qmlWarning(this) << "cancelRequestAnimationFrame should be called with an animation callback id";
args->setReturnValue(QV4::Encode::null());
return;
}
@@ -1094,6 +1112,27 @@ QImage QQuickCanvasItem::toImage(const QRectF& rect) const
return QImage();
}
+static const char* mimeToType(const QString &mime)
+{
+ const QLatin1String imagePrefix("image/");
+ if (!mime.startsWith(imagePrefix))
+ return nullptr;
+ const QStringRef mimeExt = mime.midRef(imagePrefix.size());
+ if (mimeExt == QLatin1String("png"))
+ return "png";
+ else if (mimeExt == QLatin1String("bmp"))
+ return "bmp";
+ else if (mimeExt == QLatin1String("jpeg"))
+ return "jpeg";
+ else if (mimeExt == QLatin1String("x-portable-pixmap"))
+ return "ppm";
+ else if (mimeExt == QLatin1String("tiff"))
+ return "tiff";
+ else if (mimeExt == QLatin1String("xpm"))
+ return "xpm";
+ return nullptr;
+}
+
/*!
\qmlmethod string QtQuick::Canvas::toDataURL(string mimeType)
@@ -1111,27 +1150,14 @@ QString QQuickCanvasItem::toDataURL(const QString& mimeType) const
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
- QString mime = mimeType.toLower();
- QString type;
- if (mime == QLatin1String("image/png")) {
- type = QStringLiteral("PNG");
- } else if (mime == QLatin1String("image/bmp"))
- type = QStringLiteral("BMP");
- else if (mime == QLatin1String("image/jpeg"))
- type = QStringLiteral("JPEG");
- else if (mime == QLatin1String("image/x-portable-pixmap"))
- type = QStringLiteral("PPM");
- else if (mime == QLatin1String("image/tiff"))
- type = QStringLiteral("TIFF");
- else if (mime == QLatin1String("image/xpm"))
- type = QStringLiteral("XPM");
- else
+ const QString mime = mimeType.toLower();
+ const char* type = mimeToType(mime);
+ if (!type)
return QStringLiteral("data:,");
- image.save(&buffer, type.toLatin1());
+ image.save(&buffer, type);
buffer.close();
- QString dataUrl = QStringLiteral("data:%1;base64,%2");
- return dataUrl.arg(mime).arg(QLatin1String(ba.toBase64().constData()));
+ return QLatin1String("data:") + mime + QLatin1String(";base64,") + QLatin1String(ba.toBase64().constData());
}
return QStringLiteral("data:,");
}
diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h
index 8196debef1..217ae9bb69 100644
--- a/src/quick/items/context2d/qquickcanvasitem_p.h
+++ b/src/quick/items/context2d/qquickcanvasitem_p.h
@@ -182,6 +182,7 @@ private Q_SLOTS:
void sceneGraphInitialized();
void checkAnimationCallbacks();
void invalidateSceneGraph();
+ void schedulePolish();
protected:
void componentComplete() Q_DECL_OVERRIDE;
@@ -190,12 +191,13 @@ protected:
QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) Q_DECL_OVERRIDE;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
void releaseResources() Q_DECL_OVERRIDE;
+ bool event(QEvent *event) Q_DECL_OVERRIDE;
private:
Q_DECLARE_PRIVATE(QQuickCanvasItem)
Q_INVOKABLE void delayedCreate();
bool createContext(const QString &contextType);
void initializeContext(QQuickCanvasContext *context, const QVariantMap &args = QVariantMap());
- QRect tiledRect(const QRectF &window, const QSize &tileSize);
+ static QRect tiledRect(const QRectF &window, const QSize &tileSize);
bool isPaintConnected();
};
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index bcaedd67b4..e25cc5ccbe 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -129,10 +129,10 @@ Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
#define DEGREES(t) ((t) * 180.0 / M_PI)
#define CHECK_CONTEXT(r) if (!r || !r->d()->context || !r->d()->context->bufferValid()) \
- V4THROW_ERROR("Not a Context2D object");
+ THROW_GENERIC_ERROR("Not a Context2D object");
#define CHECK_CONTEXT_SETTER(r) if (!r || !r->d()->context || !r->d()->context->bufferValid()) \
- V4THROW_ERROR("Not a Context2D object");
+ THROW_GENERIC_ERROR("Not a Context2D object");
#define qClamp(val, min, max) qMin(qMax(val, min), max)
#define CHECK_RGBA(c) (c == '-' || c == '.' || (c >=0 && c <= 9))
QColor qt_color_from_string(const QV4::Value &name)
@@ -537,45 +537,45 @@ struct QQuickJSContext2D : public QV4::Object
{
V4_OBJECT2(QQuickJSContext2D, QV4::Object)
- static QV4::ReturnedValue method_get_globalAlpha(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_globalAlpha(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_globalCompositeOperation(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_globalCompositeOperation(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_fillStyle(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_fillStyle(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_fillRule(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_fillRule(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_strokeStyle(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_strokeStyle(QV4::CallContext *ctx);
-
- static QV4::ReturnedValue method_get_lineCap(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_lineCap(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_lineJoin(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_lineJoin(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_lineWidth(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_lineWidth(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_miterLimit(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_miterLimit(QV4::CallContext *ctx);
-
- static QV4::ReturnedValue method_get_shadowBlur(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_shadowBlur(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_shadowColor(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_shadowColor(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_shadowOffsetX(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_shadowOffsetX(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_shadowOffsetY(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_shadowOffsetY(QV4::CallContext *ctx);
+ static void method_get_globalAlpha(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_globalAlpha(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_globalCompositeOperation(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_globalCompositeOperation(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_fillStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_fillStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_fillRule(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_fillRule(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_strokeStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_strokeStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+
+ static void method_get_lineCap(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_lineCap(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_lineJoin(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_lineJoin(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_lineWidth(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_lineWidth(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_miterLimit(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_miterLimit(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+
+ static void method_get_shadowBlur(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_shadowBlur(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_shadowColor(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_shadowColor(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_shadowOffsetX(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_shadowOffsetX(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_shadowOffsetY(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_shadowOffsetY(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
// should these two be on the proto?
- static QV4::ReturnedValue method_get_path(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_path(QV4::CallContext *ctx);
-
- static QV4::ReturnedValue method_get_font(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_font(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_textAlign(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_textAlign(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_textBaseline(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_set_textBaseline(QV4::CallContext *ctx);
+ static void method_get_path(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_path(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+
+ static void method_get_font(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_font(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_textAlign(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_textAlign(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_textBaseline(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_set_textBaseline(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
};
DEFINE_OBJECT_VTABLE(QQuickJSContext2D);
@@ -638,50 +638,50 @@ public:
return o->d();
}
- static QV4::ReturnedValue method_get_canvas(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_restore(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_reset(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_save(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_rotate(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_scale(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_translate(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_setTransform(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_transform(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_resetTransform(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_shear(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_createLinearGradient(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_createRadialGradient(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_createConicalGradient(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_createPattern(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_clearRect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_fillRect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_strokeRect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_arc(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_arcTo(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_beginPath(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_bezierCurveTo(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_clip(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_closePath(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_fill(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_lineTo(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_moveTo(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_quadraticCurveTo(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_rect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_roundedRect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_ellipse(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_text(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_stroke(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_isPointInPath(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_drawFocusRing(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_setCaretSelectionRect(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_caretBlinkRate(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_fillText(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_strokeText(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_measureText(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_drawImage(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_createImageData(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_getImageData(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_putImageData(QV4::CallContext *ctx);
+ static void method_get_canvas(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_restore(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_reset(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_save(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_rotate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_scale(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_translate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_setTransform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_transform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_resetTransform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_shear(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_createLinearGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_createRadialGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_createConicalGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_createPattern(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_clearRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_fillRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_strokeRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_arc(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_arcTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_beginPath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_bezierCurveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_clip(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_closePath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_fill(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_lineTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_moveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_quadraticCurveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_rect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_roundedRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_ellipse(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_text(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_stroke(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_isPointInPath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_drawFocusRing(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_setCaretSelectionRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_caretBlinkRate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_fillText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_strokeText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_measureText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_drawImage(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_createImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_getImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_putImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
};
@@ -693,7 +693,7 @@ struct QQuickContext2DStyle : public QV4::Object
V4_OBJECT2(QQuickContext2DStyle, QV4::Object)
V4_NEEDS_DESTROY
- static QV4::ReturnedValue gradient_proto_addColorStop(QV4::CallContext *ctx);
+ static void gradient_proto_addColorStop(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
};
@@ -903,7 +903,7 @@ struct QQuickJSContext2DPixelData : public QV4::Object
static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty);
static void putIndexed(QV4::Managed *m, uint index, const QV4::Value &value);
- static QV4::ReturnedValue proto_get_length(QV4::CallContext *ctx);
+ static void proto_get_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
};
void QV4::Heap::QQuickJSContext2DPixelData::init()
@@ -921,9 +921,9 @@ struct QQuickJSContext2DImageData : public QV4::Object
{
V4_OBJECT2(QQuickJSContext2DImageData, QV4::Object)
- static QV4::ReturnedValue method_get_width(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_height(QV4::CallContext *ctx);
- static QV4::ReturnedValue method_get_data(QV4::CallContext *ctx);
+ static void method_get_width(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_height(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
+ static void method_get_data(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData);
static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *engine) {
static_cast<QQuickJSContext2DImageData::Data *>(that)->pixelData.mark(engine);
@@ -975,13 +975,12 @@ static QV4::ReturnedValue qt_create_image_data(qreal w, qreal h, QV4::ExecutionE
This property is read only.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_get_canvas(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_get_canvas(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return QV4::QObjectWrapper::wrap(scope.engine, r->d()->context->canvas());
+ scope.result = QV4::QObjectWrapper::wrap(scope.engine, r->d()->context->canvas());
}
/*!
@@ -990,29 +989,27 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_get_canvas(QV4::CallContex
\sa save()
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_restore(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_restore(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->popState();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject.asReturnedValue();
}
/*!
\qmlmethod object QtQuick::Context2D::reset()
Resets the context state and properties to the default values.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_reset(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_reset(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->reset();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject.asReturnedValue();
}
/*!
@@ -1045,15 +1042,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_reset(QV4::CallContext *ct
The current path is NOT part of the drawing state. The path can be reset by
invoking the beginPath() method.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_save(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_save(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->pushState();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
}
// transformations
@@ -1074,15 +1070,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_save(QV4::CallContext *ctx
where the \a angle of rotation is in radians.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_rotate(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_rotate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 1)
- r->d()->context->rotate(ctx->args()[0].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 1)
+ r->d()->context->rotate(callData->args[0].toNumber());
+ scope.result = callData->thisObject;
}
/*!
@@ -1102,16 +1097,16 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rotate(QV4::CallContext *c
\image qml-item-canvas-scale.png
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_scale(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 2)
- r->d()->context->scale(ctx->args()[0].toNumber(), ctx->args()[1].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 2)
+ r->d()->context->scale(callData->args[0].toNumber(), callData->args[1].toNumber());
+ scope.result = callData->thisObject;
+
}
/*!
@@ -1148,22 +1143,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(QV4::CallContext *ct
\sa transform()
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_setTransform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 6)
- r->d()->context->setTransform( ctx->args()[0].toNumber()
- , ctx->args()[1].toNumber()
- , ctx->args()[2].toNumber()
- , ctx->args()[3].toNumber()
- , ctx->args()[4].toNumber()
- , ctx->args()[5].toNumber());
+ if (callData->argc >= 6)
+ r->d()->context->setTransform( callData->args[0].toNumber()
+ , callData->args[1].toNumber()
+ , callData->args[2].toNumber()
+ , callData->args[3].toNumber()
+ , callData->args[4].toNumber()
+ , callData->args[5].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -1177,21 +1172,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(QV4::CallCont
\sa setTransform()
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_transform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 6)
- r->d()->context->transform( ctx->args()[0].toNumber()
- , ctx->args()[1].toNumber()
- , ctx->args()[2].toNumber()
- , ctx->args()[3].toNumber()
- , ctx->args()[4].toNumber()
- , ctx->args()[5].toNumber());
+ if (callData->argc >= 6)
+ r->d()->context->transform( callData->args[0].toNumber()
+ , callData->args[1].toNumber()
+ , callData->args[2].toNumber()
+ , callData->args[3].toNumber()
+ , callData->args[4].toNumber()
+ , callData->args[5].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -1203,15 +1198,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_transform(QV4::CallContext
Translating the origin enables you to draw patterns of different objects on the canvas
without having to measure the coordinates manually for each shape.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_translate(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_translate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 2)
- r->d()->context->translate(ctx->args()[0].toNumber(), ctx->args()[1].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 2)
+ r->d()->context->translate(callData->args[0].toNumber(), callData->args[1].toNumber());
+ scope.result = callData->thisObject;
+
}
@@ -1223,15 +1218,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_translate(QV4::CallContext
\sa transform(), setTransform(), reset()
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_resetTransform(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_resetTransform(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
r->d()->context->setTransform(1, 0, 0, 1, 0, 0);
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
@@ -1241,16 +1236,16 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_resetTransform(QV4::CallCo
Shears the transformation matrix by \a sh in the horizontal direction and
\a sv in the vertical direction.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_shear(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 2)
- r->d()->context->shear(ctx->args()[0].toNumber(), ctx->args()[1].toNumber());
+ if (callData->argc >= 2)
+ r->d()->context->shear(callData->args[0].toNumber(), callData->args[1].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
// compositing
@@ -1261,31 +1256,30 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_shear(QV4::CallContext *ct
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::ReturnedValue QQuickJSContext2D::method_get_globalAlpha(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_globalAlpha(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.globalAlpha);
+ scope.result = QV4::Encode(r->d()->context->state.globalAlpha);
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_globalAlpha(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- double globalAlpha = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan();
+ double globalAlpha = callData->argc ? callData->args[0].toNumber() : qt_qnan();
+
+ scope.result = QV4::Encode::undefined();
if (!qt_is_finite(globalAlpha))
- return QV4::Encode::undefined();
+ return;
if (globalAlpha >= 0.0 && globalAlpha <= 1.0 && r->d()->context->state.globalAlpha != globalAlpha) {
r->d()->context->state.globalAlpha = globalAlpha;
r->d()->context->buffer()->setGlobalAlpha(r->d()->context->state.globalAlpha);
}
- return QV4::Encode::undefined();
}
/*!
@@ -1314,34 +1308,33 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalAlpha(QV4::CallContext *c
extension composition modes are provided as "vendorName-operationName" syntax, for example: QPainter::CompositionMode_Exclusion is provided as
"qt-exclusion".
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_globalCompositeOperation(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_globalCompositeOperation(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return QV4::Encode(scope.engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation)));
+ scope.result = scope.engine->newString(qt_composite_mode_to_string(r->d()->context->state.globalCompositeOperation));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_globalCompositeOperation(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- if (!ctx->argc())
- return ctx->engine()->throwTypeError();
+ if (!callData->argc)
+ THROW_TYPE_ERROR();
- QString mode = ctx->args()[0].toQString();
+ scope.result = QV4::Encode::undefined();
+
+ QString mode = callData->args[0].toQString();
QPainter::CompositionMode cm = qt_composite_mode_from_string(mode);
if (cm == QPainter::CompositionMode_SourceOver && mode != QLatin1String("source-over"))
- return QV4::Encode::undefined();
+ return;
if (cm != r->d()->context->state.globalCompositeOperation) {
r->d()->context->state.globalCompositeOperation = cm;
r->d()->context->buffer()->setGlobalCompositeOperation(cm);
}
- return QV4::Encode::undefined();
}
// colors and styles
@@ -1367,34 +1360,32 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_globalCompositeOperation(QV4::C
\sa createPattern()
\sa strokeStyle
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_fillStyle(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_fillStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
QColor color = r->d()->context->state.fillStyle.color();
if (color.isValid()) {
if (color.alpha() == 255)
- return QV4::Encode(scope.engine->newString(color.name()));
+ RETURN_RESULT(scope.engine->newString(color.name()));
QString alphaString = QString::number(color.alphaF(), 'f');
while (alphaString.endsWith(QLatin1Char('0')))
alphaString.chop(1);
if (alphaString.endsWith(QLatin1Char('.')))
alphaString += QLatin1Char('0');
QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);
- return QV4::Encode(scope.engine->newString(str));
+ RETURN_RESULT(scope.engine->newString(str));
}
- return r->d()->context->m_fillStyle.value();
+ scope.result = r->d()->context->m_fillStyle.value();
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_fillStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, ctx->argument(0));
+ QV4::ScopedValue value(scope, callData->argument(0));
if (value->as<Object>()) {
QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
@@ -1420,7 +1411,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(QV4::CallContext *ctx
r->d()->context->m_fillStyle.set(scope.engine, value);
}
}
- return QV4::Encode::undefined();
+ scope.result = QV4::Encode::undefined();
}
/*!
\qmlproperty enumeration QtQuick::Context2D::fillRule
@@ -1434,22 +1425,20 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillStyle(QV4::CallContext *ctx
\sa fillStyle
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_fillRule(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_fillRule(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- return scope.engine->fromVariant(r->d()->context->state.fillRule);
+ scope.result = scope.engine->fromVariant(r->d()->context->state.fillRule);
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_fillRule(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, ctx->argument(0));
+ QV4::ScopedValue value(scope, callData->argument(0));
if ((value->isString() && value->toQString() == QLatin1String("WindingFill"))
|| (value->isInt32() && value->integerValue() == Qt::WindingFill)) {
@@ -1461,7 +1450,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(QV4::CallContext *ctx)
//error
}
r->d()->context->m_path.setFillRule(r->d()->context->state.fillRule);
- return QV4::Encode::undefined();
+ scope.result = QV4::Encode::undefined();
}
/*!
\qmlproperty variant QtQuick::Context2D::strokeStyle
@@ -1476,34 +1465,32 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_fillRule(QV4::CallContext *ctx)
\sa createPattern()
\sa fillStyle
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_strokeStyle(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_strokeStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
QColor color = r->d()->context->state.strokeStyle.color();
if (color.isValid()) {
if (color.alpha() == 255)
- return QV4::Encode(scope.engine->newString(color.name()));
+ RETURN_RESULT(scope.engine->newString(color.name()));
QString alphaString = QString::number(color.alphaF(), 'f');
while (alphaString.endsWith(QLatin1Char('0')))
alphaString.chop(1);
if (alphaString.endsWith(QLatin1Char('.')))
alphaString += QLatin1Char('0');
QString str = QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString);
- return QV4::Encode(scope.engine->newString(str));
+ RETURN_RESULT(scope.engine->newString(str));
}
- return r->d()->context->m_strokeStyle.value();
+ scope.result = r->d()->context->m_strokeStyle.value();
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_strokeStyle(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, ctx->argument(0));
+ QV4::ScopedValue value(scope, callData->argument(0));
if (value->as<Object>()) {
QColor color = scope.engine->toVariant(value, qMetaTypeId<QColor>()).value<QColor>();
@@ -1530,7 +1517,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::CallContext *c
r->d()->context->m_strokeStyle.set(scope.engine, value);
}
}
- return QV4::Encode::undefined();
+ scope.result = QV4::Encode::undefined();
}
/*!
@@ -1550,23 +1537,22 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::CallContext *c
\sa strokeStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_createLinearGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4) {
- qreal x0 = ctx->args()[0].toNumber();
- qreal y0 = ctx->args()[1].toNumber();
- qreal x1 = ctx->args()[2].toNumber();
- qreal y1 = ctx->args()[3].toNumber();
+ if (callData->argc >= 4) {
+ qreal x0 = callData->args[0].toNumber();
+ qreal y0 = callData->args[1].toNumber();
+ qreal x1 = callData->args[2].toNumber();
+ qreal y1 = callData->args[3].toNumber();
if (!qt_is_finite(x0)
|| !qt_is_finite(y0)
|| !qt_is_finite(x1)
|| !qt_is_finite(y1)) {
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createLinearGradient(): Incorrect arguments")
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createLinearGradient(): Incorrect arguments")
}
QQuickContext2DEngineData *ed = engineData(scope.engine);
@@ -1574,10 +1560,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4::
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p);
*gradient->d()->brush = QLinearGradient(x0, y0, x1, y1);
- return gradient.asReturnedValue();
+ RETURN_RESULT(gradient);
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -1593,19 +1580,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4::
\sa strokeStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_createRadialGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 6) {
- qreal x0 = ctx->args()[0].toNumber();
- qreal y0 = ctx->args()[1].toNumber();
- qreal r0 = ctx->args()[2].toNumber();
- qreal x1 = ctx->args()[3].toNumber();
- qreal y1 = ctx->args()[4].toNumber();
- qreal r1 = ctx->args()[5].toNumber();
+ if (callData->argc >= 6) {
+ qreal x0 = callData->args[0].toNumber();
+ qreal y0 = callData->args[1].toNumber();
+ qreal r0 = callData->args[2].toNumber();
+ qreal x1 = callData->args[3].toNumber();
+ qreal y1 = callData->args[4].toNumber();
+ qreal r1 = callData->args[5].toNumber();
if (!qt_is_finite(x0)
|| !qt_is_finite(y0)
@@ -1613,11 +1599,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::
|| !qt_is_finite(r0)
|| !qt_is_finite(r1)
|| !qt_is_finite(y1)) {
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createRadialGradient(): Incorrect arguments")
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createRadialGradient(): Incorrect arguments")
}
if (r0 < 0 || r1 < 0)
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createRadialGradient(): Incorrect arguments")
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createRadialGradient(): Incorrect arguments")
QQuickContext2DEngineData *ed = engineData(scope.engine);
@@ -1625,10 +1611,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p);
*gradient->d()->brush = QRadialGradient(QPointF(x1, y1), r0+r1, QPointF(x0, y0));
- return gradient.asReturnedValue();
+ RETURN_RESULT(gradient);
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -1644,22 +1631,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::
\sa strokeStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_createConicalGradient(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 3) {
- qreal x = ctx->args()[0].toNumber();
- qreal y = ctx->args()[1].toNumber();
- qreal angle = DEGREES(ctx->args()[2].toNumber());
+ if (callData->argc >= 3) {
+ qreal x = callData->args[0].toNumber();
+ qreal y = callData->args[1].toNumber();
+ qreal angle = DEGREES(callData->args[2].toNumber());
if (!qt_is_finite(x) || !qt_is_finite(y)) {
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createConicalGradient(): Incorrect arguments");
}
if (!qt_is_finite(angle)) {
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createConicalGradient(): Incorrect arguments");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createConicalGradient(): Incorrect arguments");
}
QQuickContext2DEngineData *ed = engineData(scope.engine);
@@ -1668,10 +1654,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4:
QV4::ScopedObject p(scope, ed->gradientProto.value());
gradient->setPrototype(p);
*gradient->d()->brush = QConicalGradient(x, y, angle);
- return gradient.asReturnedValue();
+ RETURN_RESULT(gradient);
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
\qmlmethod variant QtQuick::Context2D::createPattern(color color, enumeration patternMode)
@@ -1716,18 +1703,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4:
\sa strokeStyle
\sa fillStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_createPattern(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 2) {
+ if (callData->argc >= 2) {
QV4::Scoped<QQuickContext2DStyle> pattern(scope, scope.engine->memoryManager->allocObject<QQuickContext2DStyle>());
- QColor color = scope.engine->toVariant(ctx->args()[0], qMetaTypeId<QColor>()).value<QColor>();
+ QColor color = scope.engine->toVariant(callData->args[0], qMetaTypeId<QColor>()).value<QColor>();
if (color.isValid()) {
- int patternMode = ctx->args()[1].toInt32();
+ int patternMode = callData->args[1].toInt32();
Qt::BrushStyle style = Qt::SolidPattern;
if (patternMode >= 0 && patternMode < Qt::LinearGradientPattern) {
style = static_cast<Qt::BrushStyle>(patternMode);
@@ -1736,20 +1722,20 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon
} else {
QImage patternTexture;
- if (const QV4::Object *o = ctx->args()[0].as<Object>()) {
+ if (const QV4::Object *o = callData->args[0].as<Object>()) {
QV4::ScopedString s(scope, scope.engine->newString(QStringLiteral("data")));
QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(s));
if (!!pixelData) {
patternTexture = *pixelData->d()->image;
}
} else {
- patternTexture = r->d()->context->createPixmap(QUrl(ctx->args()[0].toQStringNoThrow()))->image();
+ patternTexture = r->d()->context->createPixmap(QUrl(callData->args[0].toQStringNoThrow()))->image();
}
if (!patternTexture.isNull()) {
pattern->d()->brush->setTextureImage(patternTexture);
- QString repetition = ctx->args()[1].toQStringNoThrow();
+ QString repetition = callData->args[1].toQStringNoThrow();
if (repetition == QLatin1String("repeat") || repetition.isEmpty()) {
pattern->d()->patternRepeatX = true;
pattern->d()->patternRepeatY = true;
@@ -1769,10 +1755,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon
}
}
- return pattern.asReturnedValue();
+ RETURN_RESULT(pattern);
}
- return QV4::Encode::undefined();
+ scope.result = QV4::Encode::undefined();
}
// line styles
@@ -1787,31 +1773,29 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::CallCon
\endlist
Other values are ignored.
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_lineCap(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_lineCap(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.lineCap) {
case Qt::RoundCap:
- return QV4::Encode(scope.engine->newString(QStringLiteral("round")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("round")));
case Qt::SquareCap:
- return QV4::Encode(scope.engine->newString(QStringLiteral("square")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("square")));
case Qt::FlatCap:
default:
break;
}
- return QV4::Encode(scope.engine->newString(QStringLiteral("butt")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("butt")));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_lineCap(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QString lineCap = ctx->args()[0].toQString();
+ QString lineCap = callData->args[0].toQString();
Qt::PenCapStyle cap;
if (lineCap == QLatin1String("round"))
cap = Qt::RoundCap;
@@ -1820,13 +1804,13 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(QV4::CallContext *ctx)
else if (lineCap == QLatin1String("square"))
cap = Qt::SquareCap;
else
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
if (cap != r->d()->context->state.lineCap) {
r->d()->context->state.lineCap = cap;
r->d()->context->buffer()->setLineCap(cap);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
@@ -1843,34 +1827,32 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineCap(QV4::CallContext *ctx)
\endlist
Other values are ignored.
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_lineJoin(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_lineJoin(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.lineJoin) {
case Qt::RoundJoin:
- return QV4::Encode(scope.engine->newString(QStringLiteral("round")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("round")));
case Qt::BevelJoin:
- return QV4::Encode(scope.engine->newString(QStringLiteral("bevel")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("bevel")));
case Qt::MiterJoin:
default:
break;
}
- return QV4::Encode(scope.engine->newString(QStringLiteral("miter")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("miter")));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_lineJoin(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- if (!ctx->argc())
- return ctx->engine()->throwTypeError();
+ if (!callData->argc)
+ THROW_TYPE_ERROR();
- QString lineJoin = ctx->args()[0].toQString();
+ QString lineJoin = callData->args[0].toQString();
Qt::PenJoinStyle join;
if (lineJoin == QLatin1String("round"))
join = Qt::RoundJoin;
@@ -1879,41 +1861,39 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineJoin(QV4::CallContext *ctx)
else if (lineJoin == QLatin1String("miter"))
join = Qt::SvgMiterJoin;
else
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
if (join != r->d()->context->state.lineJoin) {
r->d()->context->state.lineJoin = join;
r->d()->context->buffer()->setLineJoin(join);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
\qmlproperty real QtQuick::Context2D::lineWidth
Holds the current line width. Values that are not finite values greater than zero are ignored.
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_lineWidth(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_lineWidth(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.lineWidth);
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.lineWidth));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_lineWidth(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_lineWidth(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal w = ctx->argc() ? ctx->args()[0].toNumber() : -1;
+ qreal w = callData->argc ? callData->args[0].toNumber() : -1;
if (w > 0 && qt_is_finite(w) && w != r->d()->context->state.lineWidth) {
r->d()->context->state.lineWidth = w;
r->d()->context->buffer()->setLineWidth(w);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
@@ -1921,28 +1901,26 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_lineWidth(QV4::CallContext *ctx
Holds the current miter limit ratio.
The default miter limit value is 10.0.
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_miterLimit(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_miterLimit(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.miterLimit);
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.miterLimit));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_miterLimit(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal ml = ctx->argc() ? ctx->args()[0].toNumber() : -1;
+ qreal ml = callData->argc ? callData->args[0].toNumber() : -1;
if (ml > 0 && qt_is_finite(ml) && ml != r->d()->context->state.miterLimit) {
r->d()->context->state.miterLimit = ml;
r->d()->context->buffer()->setMiterLimit(ml);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
// shadows
@@ -1950,58 +1928,54 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_miterLimit(QV4::CallContext *ct
\qmlproperty real QtQuick::Context2D::shadowBlur
Holds the current level of blur applied to shadows
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_shadowBlur(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_shadowBlur(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.shadowBlur);
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowBlur));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_shadowBlur(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_shadowBlur(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal blur = ctx->argc() ? ctx->args()[0].toNumber() : -1;
+ qreal blur = callData->argc ? callData->args[0].toNumber() : -1;
if (blur > 0 && qt_is_finite(blur) && blur != r->d()->context->state.shadowBlur) {
r->d()->context->state.shadowBlur = blur;
r->d()->context->buffer()->setShadowBlur(blur);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
\qmlproperty string QtQuick::Context2D::shadowColor
Holds the current shadow color.
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_shadowColor(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_shadowColor(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(scope.engine->newString(r->d()->context->state.shadowColor.name()));
+ RETURN_RESULT(scope.engine->newString(r->d()->context->state.shadowColor.name()));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_shadowColor(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_shadowColor(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
QColor color;
- if (ctx->argc())
- color = qt_color_from_string(ctx->args()[0]);
+ if (callData->argc)
+ color = qt_color_from_string(callData->args[0]);
if (color.isValid() && color != r->d()->context->state.shadowColor) {
r->d()->context->state.shadowColor = color;
r->d()->context->buffer()->setShadowColor(color);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
@@ -2011,27 +1985,25 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowColor(QV4::CallContext *c
\sa shadowOffsetY
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetX(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_shadowOffsetX(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.shadowOffsetX);
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowOffsetX));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_shadowOffsetX(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal offsetX = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan();
+ qreal offsetX = callData->argc ? callData->args[0].toNumber() : qt_qnan();
if (qt_is_finite(offsetX) && offsetX != r->d()->context->state.shadowOffsetX) {
r->d()->context->state.shadowOffsetX = offsetX;
r->d()->context->buffer()->setShadowOffsetX(offsetX);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
\qmlproperty qreal QtQuick::Context2D::shadowOffsetY
@@ -2039,45 +2011,41 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetX(QV4::CallContext
\sa shadowOffsetX
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_shadowOffsetY(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_shadowOffsetY(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(r->d()->context->state.shadowOffsetY);
+ RETURN_RESULT(QV4::Encode(r->d()->context->state.shadowOffsetY));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_shadowOffsetY(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_shadowOffsetY(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- qreal offsetY = ctx->argc() ? ctx->args()[0].toNumber() : qt_qnan();
+ qreal offsetY = callData->argc ? callData->args[0].toNumber() : qt_qnan();
if (qt_is_finite(offsetY) && offsetY != r->d()->context->state.shadowOffsetY) {
r->d()->context->state.shadowOffsetY = offsetY;
r->d()->context->buffer()->setShadowOffsetY(offsetY);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
-QV4::ReturnedValue QQuickJSContext2D::method_get_path(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_path(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return r->d()->context->m_v4path.value();
+ scope.result = r->d()->context->m_v4path.value();
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_path(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedValue value(scope, ctx->argument(0));
+ QV4::ScopedValue value(scope, callData->argument(0));
r->d()->context->beginPath();
QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, value);
if (!!qobjectWrapper) {
@@ -2088,7 +2056,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::CallContext *ctx)
QQuickSvgParser::parsePathDataFast(path, r->d()->context->m_path);
}
r->d()->context->m_v4path.set(scope.engine, value);
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
//rects
@@ -2096,20 +2064,20 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(QV4::CallContext *ctx)
\qmlmethod object QtQuick::Context2D::clearRect(real x, real y, real w, real h)
Clears all pixels on the canvas in the given rectangle to transparent black.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_clearRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4)
- r->d()->context->clearRect(ctx->args()[0].toNumber(),
- ctx->args()[1].toNumber(),
- ctx->args()[2].toNumber(),
- ctx->args()[3].toNumber());
+ if (callData->argc >= 4)
+ r->d()->context->clearRect(callData->args[0].toNumber(),
+ callData->args[1].toNumber(),
+ callData->args[2].toNumber(),
+ callData->args[3].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
/*!
\qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h)
@@ -2117,15 +2085,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(QV4::CallContext
\sa fillStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_fillRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4)
- r->d()->context->fillRect(ctx->args()[0].toNumber(), ctx->args()[1].toNumber(), ctx->args()[2].toNumber(), ctx->args()[3].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 4)
+ r->d()->context->fillRect(callData->args[0].toNumber(), callData->args[1].toNumber(), callData->args[2].toNumber(), callData->args[3].toNumber());
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2138,16 +2106,16 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(QV4::CallContext
\sa lineJoin
\sa miterLimit
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_strokeRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4)
- r->d()->context->strokeRect(ctx->args()[0].toNumber(), ctx->args()[1].toNumber(), ctx->args()[2].toNumber(), ctx->args()[3].toNumber());
+ if (callData->argc >= 4)
+ r->d()->context->strokeRect(callData->args[0].toNumber(), callData->args[1].toNumber(), callData->args[2].toNumber(), callData->args[3].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
// Complex shapes (paths) API
@@ -2171,32 +2139,32 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(QV4::CallContex
\sa arcTo, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arc}{W3C's 2D
Context Standard for arc()}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_arc(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 5) {
+ if (callData->argc >= 5) {
bool antiClockwise = false;
- if (ctx->argc() == 6)
- antiClockwise = ctx->args()[5].toBoolean();
+ if (callData->argc == 6)
+ antiClockwise = callData->args[5].toBoolean();
- qreal radius = ctx->args()[2].toNumber();
+ qreal radius = callData->args[2].toNumber();
if (qt_is_finite(radius) && radius < 0)
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
- r->d()->context->arc(ctx->args()[0].toNumber(),
- ctx->args()[1].toNumber(),
+ r->d()->context->arc(callData->args[0].toNumber(),
+ callData->args[1].toNumber(),
radius,
- ctx->args()[3].toNumber(),
- ctx->args()[4].toNumber(),
+ callData->args[3].toNumber(),
+ callData->args[4].toNumber(),
antiClockwise);
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2222,26 +2190,26 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::CallContext *ctx)
\sa arc, {http://www.w3.org/TR/2dcontext/#dom-context-2d-arcto}{W3C's 2D
Context Standard for arcTo()}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_arcTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 5) {
- qreal radius = ctx->args()[4].toNumber();
+ if (callData->argc >= 5) {
+ qreal radius = callData->args[4].toNumber();
if (qt_is_finite(radius) && radius < 0)
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "Incorrect argument radius");
- r->d()->context->arcTo(ctx->args()[0].toNumber(),
- ctx->args()[1].toNumber(),
- ctx->args()[2].toNumber(),
- ctx->args()[3].toNumber(),
+ r->d()->context->arcTo(callData->args[0].toNumber(),
+ callData->args[1].toNumber(),
+ callData->args[2].toNumber(),
+ callData->args[3].toNumber(),
radius);
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2249,15 +2217,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::CallContext *ct
Resets the current path to a new path.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_beginPath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->beginPath();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2279,28 +2247,26 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::CallContext
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-beziercurveto}{W3C 2d context standard for bezierCurveTo}
\sa {http://www.openrise.com/lab/FlowerPower/}{The beautiful flower demo by using bezierCurveTo}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_bezierCurveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
+ scope.result = callData->thisObject;
- if (ctx->argc() >= 6) {
- qreal cp1x = ctx->args()[0].toNumber();
- qreal cp1y = ctx->args()[1].toNumber();
- qreal cp2x = ctx->args()[2].toNumber();
- qreal cp2y = ctx->args()[3].toNumber();
- qreal x = ctx->args()[4].toNumber();
- qreal y = ctx->args()[5].toNumber();
+ if (callData->argc >= 6) {
+ qreal cp1x = callData->args[0].toNumber();
+ qreal cp1y = callData->args[1].toNumber();
+ qreal cp2x = callData->args[2].toNumber();
+ qreal cp2y = callData->args[3].toNumber();
+ qreal x = callData->args[4].toNumber();
+ qreal y = callData->args[5].toNumber();
if (!qt_is_finite(cp1x) || !qt_is_finite(cp1y) || !qt_is_finite(cp2x) || !qt_is_finite(cp2y) || !qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
+ return;
r->d()->context->bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
}
-
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -2327,14 +2293,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::CallCon
\sa fill()
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-clip}{W3C 2d context standard for clip}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_clip(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->clip();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
}
/*!
@@ -2344,16 +2309,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::CallContext *ctx
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-closepath}{W3C 2d context standard for closePath}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_closePath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->closePath();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
}
/*!
@@ -2365,13 +2329,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::CallContext
\sa fillStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_fill(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r);
r->d()->context->fill();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
}
/*!
@@ -2379,24 +2342,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::CallContext *ctx
Draws a line from the current position to the point (x, y).
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_lineTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
+ scope.result = callData->thisObject;
- if (ctx->argc() >= 2) {
- qreal x = ctx->args()[0].toNumber();
- qreal y = ctx->args()[1].toNumber();
+ if (callData->argc >= 2) {
+ qreal x = callData->args[0].toNumber();
+ qreal y = callData->args[1].toNumber();
if (!qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
+ return;
r->d()->context->lineTo(x, y);
}
-
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -2404,21 +2365,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::CallContext *c
Creates a new subpath with the given point.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_moveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 2) {
- qreal x = ctx->args()[0].toNumber();
- qreal y = ctx->args()[1].toNumber();
+ scope.result = callData->thisObject;
+
+ if (callData->argc >= 2) {
+ qreal x = callData->args[0].toNumber();
+ qreal y = callData->args[1].toNumber();
if (!qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
+ return;
r->d()->context->moveTo(x, y);
}
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -2428,25 +2389,24 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::CallContext *c
See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4) {
- qreal cpx = ctx->args()[0].toNumber();
- qreal cpy = ctx->args()[1].toNumber();
- qreal x = ctx->args()[2].toNumber();
- qreal y = ctx->args()[3].toNumber();
+ scope.result = callData->thisObject;
+
+ if (callData->argc >= 4) {
+ qreal cpx = callData->args[0].toNumber();
+ qreal cpy = callData->args[1].toNumber();
+ qreal x = callData->args[2].toNumber();
+ qreal y = callData->args[3].toNumber();
if (!qt_is_finite(cpx) || !qt_is_finite(cpy) || !qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
+ return;
r->d()->context->quadraticCurveTo(cpx, cpy, x, y);
}
-
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -2454,15 +2414,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::Call
Adds a rectangle at position (\c x, \c y), with the given width \c w and height \c h, as a closed subpath.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_rect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4)
- r->d()->context->rect(ctx->args()[0].toNumber(), ctx->args()[1].toNumber(), ctx->args()[2].toNumber(), ctx->args()[3].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 4)
+ r->d()->context->rect(callData->args[0].toNumber(), callData->args[1].toNumber(), callData->args[2].toNumber(), callData->args[3].toNumber());
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2471,20 +2431,20 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::CallContext *ctx
Adds the given rectangle rect with rounded corners to the path. The \c xRadius and \c yRadius arguments specify the radius of the
ellipses defining the corners of the rounded rectangle.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_roundedRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 6)
- r->d()->context->roundedRect(ctx->args()[0].toNumber()
- , ctx->args()[1].toNumber()
- , ctx->args()[2].toNumber()
- , ctx->args()[3].toNumber()
- , ctx->args()[4].toNumber()
- , ctx->args()[5].toNumber());
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 6)
+ r->d()->context->roundedRect(callData->args[0].toNumber()
+ , callData->args[1].toNumber()
+ , callData->args[2].toNumber()
+ , callData->args[3].toNumber()
+ , callData->args[4].toNumber()
+ , callData->args[5].toNumber());
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2495,17 +2455,17 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::CallConte
The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_ellipse(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4)
- r->d()->context->ellipse(ctx->args()[0].toNumber(), ctx->args()[1].toNumber(), ctx->args()[2].toNumber(), ctx->args()[3].toNumber());
+ if (callData->argc >= 4)
+ r->d()->context->ellipse(callData->args[0].toNumber(), callData->args[1].toNumber(), callData->args[2].toNumber(), callData->args[3].toNumber());
+
+ scope.result = callData->thisObject;
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -2514,21 +2474,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::CallContext *
Adds the given \c text to the path as a set of closed subpaths created from the current context font supplied.
The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (\c x, \c y).
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_text(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 3) {
- qreal x = ctx->args()[1].toNumber();
- qreal y = ctx->args()[2].toNumber();
+ scope.result = callData->thisObject;
+
+ if (callData->argc >= 3) {
+ qreal x = callData->args[1].toNumber();
+ qreal y = callData->args[2].toNumber();
if (!qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
- r->d()->context->text(ctx->args()[0].toQStringNoThrow(), x, y);
+ return;
+ r->d()->context->text(callData->args[0].toQStringNoThrow(), x, y);
}
- return ctx->thisObject().asReturnedValue();
+
}
/*!
@@ -2540,14 +2501,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::CallContext *ctx
\sa strokeStyle
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_stroke(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
r->d()->context->stroke();
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2557,37 +2518,30 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(QV4::CallContext *c
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath}{W3C 2d context standard for isPointInPath}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_isPointInPath(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
bool pointInPath = false;
- if (ctx->argc() >= 2)
- pointInPath = r->d()->context->isPointInPath(ctx->args()[0].toNumber(), ctx->args()[1].toNumber());
- return QV4::Primitive::fromBoolean(pointInPath).asReturnedValue();
+ if (callData->argc >= 2)
+ pointInPath = r->d()->context->isPointInPath(callData->args[0].toNumber(), callData->args[1].toNumber());
+ scope.result = QV4::Primitive::fromBoolean(pointInPath).asReturnedValue();
}
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawFocusRing(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_drawFocusRing(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *)
{
- QV4::Scope scope(ctx);
-
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported");
}
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_setCaretSelectionRect(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_setCaretSelectionRect(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *)
{
- QV4::Scope scope(ctx);
-
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported");
}
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_caretBlinkRate(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *)
{
- QV4::Scope scope(ctx);
-
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported");
}
/*!
@@ -2613,29 +2567,27 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::CallCo
The default font value is "10px sans-serif".
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_font(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- return QV4::Encode(scope.engine->newString(r->d()->context->state.font.toString()));
+ RETURN_RESULT(scope.engine->newString(r->d()->context->state.font.toString()));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_font(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, ctx->argument(0), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, callData->argument(0), QV4::ScopedString::Convert);
if (scope.engine->hasException)
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
QFont font = qt_font_from_string(s->toQString(), r->d()->context->state.font);
if (font != r->d()->context->state.font) {
r->d()->context->state.font = font;
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
@@ -2652,37 +2604,35 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::CallContext *ctx)
\endlist
Other values are ignored. The default value is "start".
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_textAlign(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.textAlign) {
case QQuickContext2D::End:
- return QV4::Encode(scope.engine->newString(QStringLiteral("end")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("end")));
case QQuickContext2D::Left:
- return QV4::Encode(scope.engine->newString(QStringLiteral("left")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("left")));
case QQuickContext2D::Right:
- return QV4::Encode(scope.engine->newString(QStringLiteral("right")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("right")));
case QQuickContext2D::Center:
- return QV4::Encode(scope.engine->newString(QStringLiteral("center")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("center")));
case QQuickContext2D::Start:
default:
break;
}
- return QV4::Encode(scope.engine->newString(QStringLiteral("start")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("start")));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_textAlign(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, ctx->argument(0), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, callData->argument(0), QV4::ScopedString::Convert);
if (scope.engine->hasException)
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
QString textAlign = s->toQString();
QQuickContext2D::TextAlignType ta;
@@ -2697,12 +2647,12 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::CallContext *ctx
else if (textAlign == QLatin1String("center"))
ta = QQuickContext2D::Center;
else
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
if (ta != r->d()->context->state.textAlign)
r->d()->context->state.textAlign = ta;
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
@@ -2720,36 +2670,34 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::CallContext *ctx
\endlist
Other values are ignored. The default value is "alphabetic".
*/
-QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_get_textBaseline(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
switch (r->d()->context->state.textBaseline) {
case QQuickContext2D::Hanging:
- return QV4::Encode(scope.engine->newString(QStringLiteral("hanging")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("hanging")));
case QQuickContext2D::Top:
- return QV4::Encode(scope.engine->newString(QStringLiteral("top")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("top")));
case QQuickContext2D::Bottom:
- return QV4::Encode(scope.engine->newString(QStringLiteral("bottom")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("bottom")));
case QQuickContext2D::Middle:
- return QV4::Encode(scope.engine->newString(QStringLiteral("middle")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("middle")));
case QQuickContext2D::Alphabetic:
default:
break;
}
- return QV4::Encode(scope.engine->newString(QStringLiteral("alphabetic")));
+ RETURN_RESULT(scope.engine->newString(QStringLiteral("alphabetic")));
}
-QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::CallContext *ctx)
+void QQuickJSContext2D::method_set_textBaseline(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT_SETTER(r)
- QV4::ScopedString s(scope, ctx->argument(0), QV4::ScopedString::Convert);
+ QV4::ScopedString s(scope, callData->argument(0), QV4::ScopedString::Convert);
if (scope.engine->hasException)
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
QString textBaseline = s->toQString();
QQuickContext2D::TextBaseLineType tb;
@@ -2764,12 +2712,12 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::CallContext *
else if (textBaseline == QLatin1String("middle"))
tb = QQuickContext2D::Middle;
else
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
if (tb != r->d()->context->state.textBaseline)
r->d()->context->state.textBaseline = tb;
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
@@ -2780,21 +2728,21 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::CallContext *
\sa textBaseline
\sa strokeText
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_fillText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 3) {
- qreal x = ctx->args()[1].toNumber();
- qreal y = ctx->args()[2].toNumber();
+ scope.result = callData->thisObject;
+
+ if (callData->argc >= 3) {
+ qreal x = callData->args[1].toNumber();
+ qreal y = callData->args[2].toNumber();
if (!qt_is_finite(x) || !qt_is_finite(y))
- return ctx->thisObject().asReturnedValue();
- QPainterPath textPath = r->d()->context->createTextGlyphs(x, y, ctx->args()[0].toQStringNoThrow());
+ return;
+ QPainterPath textPath = r->d()->context->createTextGlyphs(x, y, callData->args[0].toQStringNoThrow());
r->d()->context->buffer()->fill(textPath);
}
- return ctx->thisObject().asReturnedValue();
}
/*!
\qmlmethod object QtQuick::Context2D::strokeText(text, x, y)
@@ -2804,15 +2752,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::CallContext
\sa textBaseline
\sa fillText
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_strokeText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 3)
- r->d()->context->drawText(ctx->args()[0].toQStringNoThrow(), ctx->args()[1].toNumber(), ctx->args()[2].toNumber(), false);
- return ctx->thisObject().asReturnedValue();
+ if (callData->argc >= 3)
+ r->d()->context->drawText(callData->args[0].toQStringNoThrow(), callData->args[1].toNumber(), callData->args[2].toNumber(), false);
+ scope.result = callData->thisObject;
+
}
/*!
@@ -2821,21 +2769,20 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::CallContex
Returns an object with a \c width property, whose value is equivalent to
calling \l {QFontMetrics::width()} with the given \a text in the current font.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_measureText(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
- if (ctx->argc() >= 1) {
+ if (callData->argc >= 1) {
QFontMetrics fm(r->d()->context->state.font);
- uint width = fm.width(ctx->args()[0].toQStringNoThrow());
+ uint width = fm.width(callData->args[0].toQStringNoThrow());
QV4::ScopedObject tm(scope, scope.engine->newObject());
tm->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("width"))).getPointer(),
QV4::ScopedValue(scope, QV4::Primitive::fromDouble(width)));
- return tm.asReturnedValue();
+ RETURN_RESULT(tm);
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
// drawing images
@@ -2897,28 +2844,29 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::CallConte
\sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-drawimage}{W3C 2d context standard for drawImage}
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_drawImage(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject);
CHECK_CONTEXT(r)
+ scope.result = callData->thisObject;
+
qreal sx, sy, sw, sh, dx, dy, dw, dh;
- if (!ctx->argc())
- return ctx->thisObject().asReturnedValue();
+ if (!callData->argc)
+ return;
//FIXME:This function should be moved to QQuickContext2D::drawImage(...)
if (!r->d()->context->state.invertibleCTM)
- return ctx->thisObject().asReturnedValue();
+ return;
QQmlRefPointer<QQuickCanvasPixmap> pixmap;
- QV4::ScopedValue arg(scope, ctx->args()[0]);
+ QV4::ScopedValue arg(scope, callData->args[0]);
if (arg->isString()) {
QUrl url(arg->toQString());
if (!url.isValid())
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
pixmap = r->d()->context->createPixmap(url);
} else if (arg->isObject()) {
@@ -2931,7 +2879,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
if (!img.isNull())
pixmap.adopt(new QQuickCanvasPixmap(img));
} else {
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
}
} else {
QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, arg);
@@ -2940,44 +2888,44 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
if (pix && !pix->d()->image->isNull()) {
pixmap.adopt(new QQuickCanvasPixmap(*pix->d()->image));
} else {
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
}
} else {
QUrl url(arg->toQStringNoThrow());
if (url.isValid())
pixmap = r->d()->context->createPixmap(url);
else
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
}
}
} else {
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "drawImage(), type mismatch");
}
if (pixmap.isNull() || !pixmap->isValid())
- return ctx->thisObject().asReturnedValue();
-
- if (ctx->argc() >= 9) {
- sx = ctx->args()[1].toNumber();
- sy = ctx->args()[2].toNumber();
- sw = ctx->args()[3].toNumber();
- sh = ctx->args()[4].toNumber();
- dx = ctx->args()[5].toNumber();
- dy = ctx->args()[6].toNumber();
- dw = ctx->args()[7].toNumber();
- dh = ctx->args()[8].toNumber();
- } else if (ctx->argc() >= 5) {
+ return;
+
+ if (callData->argc >= 9) {
+ sx = callData->args[1].toNumber();
+ sy = callData->args[2].toNumber();
+ sw = callData->args[3].toNumber();
+ sh = callData->args[4].toNumber();
+ dx = callData->args[5].toNumber();
+ dy = callData->args[6].toNumber();
+ dw = callData->args[7].toNumber();
+ dh = callData->args[8].toNumber();
+ } else if (callData->argc >= 5) {
sx = 0;
sy = 0;
sw = pixmap->width();
sh = pixmap->height();
- dx = ctx->args()[1].toNumber();
- dy = ctx->args()[2].toNumber();
- dw = ctx->args()[3].toNumber();
- dh = ctx->args()[4].toNumber();
- } else if (ctx->argc() >= 3) {
- dx = ctx->args()[1].toNumber();
- dy = ctx->args()[2].toNumber();
+ dx = callData->args[1].toNumber();
+ dy = callData->args[2].toNumber();
+ dw = callData->args[3].toNumber();
+ dh = callData->args[4].toNumber();
+ } else if (callData->argc >= 3) {
+ dx = callData->args[1].toNumber();
+ dy = callData->args[2].toNumber();
sx = 0;
sy = 0;
sw = pixmap->width();
@@ -2985,7 +2933,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
dw = sw;
dh = sh;
} else {
- return ctx->thisObject().asReturnedValue();
+ return;
}
if (!qt_is_finite(sx)
@@ -2996,7 +2944,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
|| !qt_is_finite(dy)
|| !qt_is_finite(dw)
|| !qt_is_finite(dh))
- return ctx->thisObject().asReturnedValue();
+ return;
if (sx < 0
|| sy < 0
@@ -3005,12 +2953,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
|| sx + sw > pixmap->width()
|| sy + sh > pixmap->height()
|| sx + sw < 0 || sy + sh < 0) {
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "drawImage(), index size error");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "drawImage(), index size error");
}
r->d()->context->buffer()->drawPixmap(pixmap, QRectF(sx, sy, sw, sh), QRectF(dx, dy, dw, dh));
-
- return ctx->thisObject().asReturnedValue();
}
// pixel manipulation
@@ -3037,45 +2983,40 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::CallContext
\qmlproperty int QtQuick::CanvasImageData::width
Holds the actual width dimension of the data in the ImageData object, in device pixels.
*/
-QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::CallContext *ctx)
+void QQuickJSContext2DImageData::method_get_width(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, callData->thisObject);
if (!imageData)
- return ctx->engine()->throwTypeError();
+ THROW_TYPE_ERROR();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
- if (!r)
- return QV4::Encode(0);
- return QV4::Encode(r->d()->image->width());
+ int width = r ? r->d()->image->width() : 0;
+ scope.result = QV4::Encode(width);
}
/*!
\qmlproperty int QtQuick::CanvasImageData::height
Holds the actual height dimension of the data in the ImageData object, in device pixels.
*/
-QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::CallContext *ctx)
+void QQuickJSContext2DImageData::method_get_height(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, callData->thisObject);
if (!imageData)
- return ctx->engine()->throwTypeError();
+ THROW_TYPE_ERROR();
QV4::Scoped<QQuickJSContext2DPixelData> r(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
- if (!r)
- return QV4::Encode(0);
- return QV4::Encode(r->d()->image->height());
+ int height = r ? r->d()->image->height() : 0;
+ scope.result = QV4::Encode(height);
}
/*!
\qmlproperty object QtQuick::CanvasImageData::data
Holds the one-dimensional array containing the data in RGBA order, as integers in the range 0 to 255.
*/
-QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::CallContext *ctx)
+void QQuickJSContext2DImageData::method_get_data(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, ctx->thisObject());
+ QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, callData->thisObject);
if (!imageData)
- return ctx->engine()->throwTypeError();
- return imageData->d()->pixelData.asReturnedValue();
+ THROW_TYPE_ERROR();
+ scope.result = imageData->d()->pixelData;
}
/*!
@@ -3096,14 +3037,13 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::CallContext
The length attribute of a CanvasPixelArray object must return this h×w×4 number value.
This property is read only.
*/
-QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext *ctx)
+void QQuickJSContext2DPixelData::proto_get_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2DPixelData> r(scope, ctx->thisObject().as<QQuickJSContext2DPixelData>());
+ QV4::Scoped<QQuickJSContext2DPixelData> r(scope, callData->thisObject.as<QQuickJSContext2DPixelData>());
if (!r || r->d()->image->isNull())
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
- return QV4::Encode(r->d()->image->width() * r->d()->image->height() * 4);
+ RETURN_RESULT(QV4::Encode(r->d()->image->width() * r->d()->image->height() * 4));
}
QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
@@ -3192,108 +3132,107 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q
\sa Canvas::loadImage(), QtQuick::Canvas::unloadImage(),
QtQuick::Canvas::isImageLoaded
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_createImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() == 1) {
- QV4::ScopedValue arg0(scope, ctx->args()[0]);
+ if (callData->argc == 1) {
+ QV4::ScopedValue arg0(scope, callData->args[0]);
QV4::Scoped<QQuickJSContext2DImageData> imgData(scope, arg0);
if (!!imgData) {
QV4::Scoped<QQuickJSContext2DPixelData> pa(scope, imgData->d()->pixelData.as<QQuickJSContext2DPixelData>());
if (pa) {
qreal w = pa->d()->image->width();
qreal h = pa->d()->image->height();
- return qt_create_image_data(w, h, scope.engine, QImage());
+ RETURN_RESULT(qt_create_image_data(w, h, scope.engine, QImage()));
}
} else if (arg0->isString()) {
QImage image = r->d()->context->createPixmap(QUrl(arg0->toQStringNoThrow()))->image();
- return qt_create_image_data(image.width(), image.height(), scope.engine, image);
+ RETURN_RESULT(qt_create_image_data(image.width(), image.height(), scope.engine, image));
}
- } else if (ctx->argc() == 2) {
- qreal w = ctx->args()[0].toNumber();
- qreal h = ctx->args()[1].toNumber();
+ } else if (callData->argc == 2) {
+ qreal w = callData->args[0].toNumber();
+ qreal h = callData->args[1].toNumber();
if (!qt_is_finite(w) || !qt_is_finite(h))
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "createImageData(): invalid arguments");
if (w > 0 && h > 0)
- return qt_create_image_data(w, h, scope.engine, QImage());
+ RETURN_RESULT(qt_create_image_data(w, h, scope.engine, QImage()));
else
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "createImageData(): invalid arguments");
}
- return QV4::Encode::undefined();
+ RETURN_UNDEFINED();
}
/*!
\qmlmethod CanvasImageData QtQuick::Context2D::getImageData(real sx, real sy, real sw, real sh)
Returns an CanvasImageData object containing the image data for the given rectangle of the canvas.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_getImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() >= 4) {
- qreal x = ctx->args()[0].toNumber();
- qreal y = ctx->args()[1].toNumber();
- qreal w = ctx->args()[2].toNumber();
- qreal h = ctx->args()[3].toNumber();
+ if (callData->argc >= 4) {
+ qreal x = callData->args[0].toNumber();
+ qreal y = callData->args[1].toNumber();
+ qreal w = callData->args[2].toNumber();
+ qreal h = callData->args[3].toNumber();
if (!qt_is_finite(x) || !qt_is_finite(y) || !qt_is_finite(w) || !qt_is_finite(h))
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "getImageData(): Invalid arguments");
if (w <= 0 || h <= 0)
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "getImageData(): Invalid arguments");
QImage image = r->d()->context->canvas()->toImage(QRectF(x, y, w, h));
- return qt_create_image_data(w, h, scope.engine, image);
+ RETURN_RESULT(qt_create_image_data(w, h, scope.engine, image));
}
- return QV4::Encode::null();
+ scope.result = QV4::Encode::null();
}
/*!
\qmlmethod object QtQuick::Context2D::putImageData(CanvasImageData imageData, real dx, real dy, real dirtyX, real dirtyY, real dirtyWidth, real dirtyHeight)
Paints the data from the given ImageData object onto the canvas. If a dirty rectangle (\a dirtyX, \a dirtyY, \a dirtyWidth, \a dirtyHeight) is provided, only the pixels from that rectangle are painted.
*/
-QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallContext *ctx)
+void QQuickJSContext2DPrototype::method_putImageData(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickJSContext2D> r(scope, ctx->thisObject().as<QQuickJSContext2D>());
+ QV4::Scoped<QQuickJSContext2D> r(scope, callData->thisObject.as<QQuickJSContext2D>());
CHECK_CONTEXT(r)
- if (ctx->argc() < 7)
- return QV4::Encode::undefined();
+ if (callData->argc < 7)
+ RETURN_UNDEFINED();
- QV4::ScopedValue arg0(scope, ctx->args()[0]);
+ QV4::ScopedValue arg0(scope, callData->args[0]);
if (!arg0->isObject())
- V4THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch");
+ THROW_DOM(DOMEXCEPTION_TYPE_MISMATCH_ERR, "Context2D::putImageData, the image data type mismatch");
- qreal dx = ctx->args()[1].toNumber();
- qreal dy = ctx->args()[2].toNumber();
+ qreal dx = callData->args[1].toNumber();
+ qreal dy = callData->args[2].toNumber();
qreal w, h, dirtyX, dirtyY, dirtyWidth, dirtyHeight;
if (!qt_is_finite(dx) || !qt_is_finite(dy))
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
+
+ scope.result = callData->thisObject;
QV4::Scoped<QQuickJSContext2DImageData> imageData(scope, arg0);
if (!imageData)
- return ctx->thisObject().asReturnedValue();
+ return;
QV4::Scoped<QQuickJSContext2DPixelData> pixelArray(scope, imageData->d()->pixelData.as<QQuickJSContext2DPixelData>());
if (pixelArray) {
w = pixelArray->d()->image->width();
h = pixelArray->d()->image->height();
- if (ctx->argc() == 7) {
- dirtyX = ctx->args()[3].toNumber();
- dirtyY = ctx->args()[4].toNumber();
- dirtyWidth = ctx->args()[5].toNumber();
- dirtyHeight = ctx->args()[6].toNumber();
+ if (callData->argc == 7) {
+ dirtyX = callData->args[3].toNumber();
+ dirtyY = callData->args[4].toNumber();
+ dirtyWidth = callData->args[5].toNumber();
+ dirtyHeight = callData->args[6].toNumber();
if (!qt_is_finite(dirtyX) || !qt_is_finite(dirtyY) || !qt_is_finite(dirtyWidth) || !qt_is_finite(dirtyHeight))
- V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
+ THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "putImageData() : Invalid arguments");
if (dirtyWidth < 0) {
@@ -3325,7 +3264,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallCont
}
if (dirtyWidth <=0 || dirtyHeight <= 0)
- return ctx->thisObject().asReturnedValue();
+ return;
} else {
dirtyX = 0;
dirtyY = 0;
@@ -3336,7 +3275,6 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallCont
QImage image = pixelArray->d()->image->copy(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
r->d()->context->buffer()->drawImage(image, QRectF(dirtyX, dirtyY, dirtyWidth, dirtyHeight), QRectF(dx, dy, dirtyWidth, dirtyHeight));
}
- return ctx->thisObject().asReturnedValue();
}
/*!
@@ -3359,39 +3297,38 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::CallCont
gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1');
\endcode
*/
-QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(QV4::CallContext *ctx)
+void QQuickContext2DStyle::gradient_proto_addColorStop(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData)
{
- QV4::Scope scope(ctx);
- QV4::Scoped<QQuickContext2DStyle> style(scope, ctx->thisObject().as<QQuickContext2DStyle>());
+ QV4::Scoped<QQuickContext2DStyle> style(scope, callData->thisObject.as<QQuickContext2DStyle>());
if (!style)
- V4THROW_ERROR("Not a CanvasGradient object");
+ THROW_GENERIC_ERROR("Not a CanvasGradient object");
- if (ctx->argc() == 2) {
+ if (callData->argc == 2) {
if (!style->d()->brush->gradient())
- V4THROW_ERROR("Not a valid CanvasGradient object, can't get the gradient information");
+ THROW_GENERIC_ERROR("Not a valid CanvasGradient object, can't get the gradient information");
QGradient gradient = *(style->d()->brush->gradient());
- qreal pos = ctx->args()[0].toNumber();
+ qreal pos = callData->args[0].toNumber();
QColor color;
- if (ctx->args()[1].as<Object>()) {
- color = scope.engine->toVariant(ctx->args()[1], qMetaTypeId<QColor>()).value<QColor>();
+ if (callData->args[1].as<Object>()) {
+ color = scope.engine->toVariant(callData->args[1], qMetaTypeId<QColor>()).value<QColor>();
} else {
- color = qt_color_from_string(ctx->args()[1]);
+ color = qt_color_from_string(callData->args[1]);
}
if (pos < 0.0 || pos > 1.0 || !qt_is_finite(pos)) {
- V4THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range");
+ THROW_DOM(DOMEXCEPTION_INDEX_SIZE_ERR, "CanvasGradient: parameter offset out of range");
}
if (color.isValid()) {
gradient.setColorAt(pos, color);
} else {
- V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "CanvasGradient: parameter color is not a valid color string");
+ THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "CanvasGradient: parameter color is not a valid color string");
}
*style->d()->brush = gradient;
}
- return ctx->thisObject().asReturnedValue();
+ scope.result = callData->thisObject;
}
void QQuickContext2D::scale(qreal x, qreal y)
diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h
index e897263b6f..334bf08329 100644
--- a/src/quick/items/context2d/qquickcontext2d_p.h
+++ b/src/quick/items/context2d/qquickcontext2d_p.h
@@ -184,17 +184,17 @@ public:
QQuickContext2D(QObject *parent = 0);
~QQuickContext2D();
- QStringList contextNames() const;
- void init(QQuickCanvasItem *canvasItem, const QVariantMap &args);
- void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing);
- void flush();
+ QStringList contextNames() const override;
+ void init(QQuickCanvasItem *canvasItem, const QVariantMap &args) override;
+ void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing) override;
+ void flush() override;
void sync();
QThread *thread() const { return m_thread; }
QQuickContext2DTexture *texture() const;
- QImage toImage(const QRectF& bounds);
+ QImage toImage(const QRectF& bounds) override;
- QV4::ReturnedValue v4value() const;
- void setV4Engine(QV4::ExecutionEngine *eng);
+ QV4::ReturnedValue v4value() const override;
+ void setV4Engine(QV4::ExecutionEngine *eng) override;
QQuickCanvasItem* canvas() const { return m_canvas; }
QQuickContext2DCommandBuffer* buffer() const { return m_buffer; }
@@ -243,8 +243,8 @@ public:
QPainterPath createTextGlyphs(qreal x, qreal y, const QString& text);
QQmlRefPointer<QQuickCanvasPixmap> createPixmap(const QUrl& url);
- QOpenGLContext *glContext() { return m_glContext; }
- QSurface *surface() { return m_surface.data(); }
+ QOpenGLContext *glContext() const { return m_glContext; }
+ QSurface *surface() const { return m_surface.data(); }
void setGrabbedImage(const QImage& grab);
State state;
diff --git a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
index 3663e49f10..2a1ac7304e 100644
--- a/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
+++ b/src/quick/items/context2d/qquickcontext2dcommandbuffer_p.h
@@ -71,7 +71,7 @@ public:
void reset();
void clear();
- inline int size() {return commands.size();}
+ inline int size() const { return commands.size(); }
inline bool isEmpty() const {return commands.isEmpty(); }
inline bool hasNext() const {return cmdIdx < commands.size(); }
inline QQuickContext2D::PaintCommand takeNextCommand() { return commands.at(cmdIdx++); }
@@ -249,7 +249,7 @@ public:
void replay(QPainter* painter, QQuickContext2D::State& state, const QVector2D &scaleFactor);
private:
- QPen makePen(const QQuickContext2D::State& state);
+ static QPen makePen(const QQuickContext2D::State& state);
void setPainterState(QPainter* painter, const QQuickContext2D::State& state, const QPen& pen);
int cmdIdx;
int intIdx;
diff --git a/src/quick/items/context2d/qquickcontext2dtexture_p.h b/src/quick/items/context2d/qquickcontext2dtexture_p.h
index 04d7b40ab7..97135816a2 100644
--- a/src/quick/items/context2d/qquickcontext2dtexture_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtexture_p.h
@@ -124,7 +124,7 @@ public:
// Called during sync() on the scene graph thread while GUI is blocked.
virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) = 0;
- bool event(QEvent *e);
+ bool event(QEvent *e) override;
#if QT_CONFIG(opengl)
void initializeOpenGL(QOpenGLContext *gl, QOffscreenSurface *s) {
m_gl = gl;
@@ -225,17 +225,17 @@ public:
QQuickContext2DImageTexture();
~QQuickContext2DImageTexture();
- virtual QQuickCanvasItem::RenderTarget renderTarget() const;
+ QQuickCanvasItem::RenderTarget renderTarget() const override;
- virtual QQuickContext2DTile* createTile() const;
- virtual QPaintDevice* beginPainting();
- virtual void endPainting();
- virtual void compositeTile(QQuickContext2DTile* tile);
+ QQuickContext2DTile* createTile() const override;
+ QPaintDevice* beginPainting() override;
+ void endPainting() override;
+ void compositeTile(QQuickContext2DTile* tile) override;
- virtual QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window);
+ QSGTexture *textureForNextFrame(QSGTexture *lastFrame, QQuickWindow *window) override;
public Q_SLOTS:
- virtual void grabImage(const QRectF& region = QRectF());
+ void grabImage(const QRectF& region = QRectF()) override;
private:
QImage m_image;
diff --git a/src/quick/items/context2d/qquickcontext2dtile_p.h b/src/quick/items/context2d/qquickcontext2dtile_p.h
index e7eed7b086..d5255edcfc 100644
--- a/src/quick/items/context2d/qquickcontext2dtile_p.h
+++ b/src/quick/items/context2d/qquickcontext2dtile_p.h
@@ -93,12 +93,12 @@ class QQuickContext2DFBOTile : public QQuickContext2DTile
public:
QQuickContext2DFBOTile();
~QQuickContext2DFBOTile();
- virtual void setRect(const QRect& r);
+ virtual void setRect(const QRect& r) override;
QOpenGLFramebufferObject* fbo() const {return m_fbo;}
- void drawFinished();
+ void drawFinished() override;
protected:
- void aboutToDraw();
+ void aboutToDraw() override;
private:
@@ -110,7 +110,7 @@ class QQuickContext2DImageTile : public QQuickContext2DTile
public:
QQuickContext2DImageTile();
~QQuickContext2DImageTile();
- void setRect(const QRect& r);
+ void setRect(const QRect& r) override;
const QImage& image() const {return m_image;}
private:
QImage m_image;
diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h
index c8538745cc..215a1e5db6 100644
--- a/src/quick/items/qquickaccessibleattached_p.h
+++ b/src/quick/items/qquickaccessibleattached_p.h
@@ -203,7 +203,7 @@ public:
return object;
}
- QAccessible::State state() { return m_state; }
+ QAccessible::State state() const { return m_state; }
bool ignored() const;
bool doAction(const QString &actionName);
void availableActions(QStringList *actions) const;
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp
index a069f1ece3..c0bec7d716 100644
--- a/src/quick/items/qquickanchors.cpp
+++ b/src/quick/items/qquickanchors.cpp
@@ -214,7 +214,7 @@ void QQuickAnchorsPrivate::fillChanged()
--updatingFill;
} else {
// ### Make this certain :)
- qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on fill.");
+ qmlWarning(item) << QQuickAnchors::tr("Possible anchor loop detected on fill.");
}
}
@@ -243,7 +243,7 @@ void QQuickAnchorsPrivate::centerInChanged()
--updatingCenterIn;
} else {
// ### Make this certain :)
- qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on centerIn.");
+ qmlWarning(item) << QQuickAnchors::tr("Possible anchor loop detected on centerIn.");
}
}
@@ -285,7 +285,7 @@ void QQuickAnchorsPrivate::clearItem(QQuickItem *item)
}
}
-QQuickGeometryChange QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem)
+QQuickGeometryChange QQuickAnchorsPrivate::calculateDependency(QQuickItem *controlItem) const
{
QQuickGeometryChange dependency;
@@ -529,7 +529,7 @@ void QQuickAnchors::setFill(QQuickItem *f)
return;
}
if (f != readParentItem(d->item) && readParentItem(f) != readParentItem(d->item)){
- qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
+ qmlWarning(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
return;
}
QQuickItem *oldFill = d->fill;
@@ -565,7 +565,7 @@ void QQuickAnchors::setCenterIn(QQuickItem* c)
return;
}
if (c != readParentItem(d->item) && readParentItem(c) != readParentItem(d->item)){
- qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
+ qmlWarning(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling.");
return;
}
QQuickItem *oldCI = d->centerIn;
@@ -588,7 +588,7 @@ bool QQuickAnchorsPrivate::calcStretch(QQuickItem *edge1Item,
qreal offset1,
qreal offset2,
QQuickAnchors::Anchor line,
- qreal &stretch)
+ qreal &stretch) const
{
bool edge1IsParent = (edge1Item == readParentItem(item));
bool edge2IsParent = (edge2Item == readParentItem(item));
@@ -619,7 +619,7 @@ void QQuickAnchorsPrivate::updateVerticalAnchors()
if (Q_UNLIKELY(updatingVerticalAnchor > 1)) {
// ### Make this certain :)
- qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor.");
+ qmlWarning(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor.");
return;
}
@@ -794,7 +794,7 @@ void QQuickAnchorsPrivate::updateHorizontalAnchors()
--updatingHorizontalAnchor;
} else {
// ### Make this certain :)
- qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on horizontal anchor.");
+ qmlWarning(item) << QQuickAnchors::tr("Possible anchor loop detected on horizontal anchor.");
}
}
@@ -1329,7 +1329,7 @@ bool QQuickAnchorsPrivate::checkHValid() const
if (usedAnchors & QQuickAnchors::LeftAnchor &&
usedAnchors & QQuickAnchors::RightAnchor &&
usedAnchors & QQuickAnchors::HCenterAnchor) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot specify left, right, and horizontalCenter anchors at the same time.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot specify left, right, and horizontalCenter anchors at the same time.");
return false;
}
@@ -1339,17 +1339,17 @@ bool QQuickAnchorsPrivate::checkHValid() const
bool QQuickAnchorsPrivate::checkHAnchorValid(QQuickAnchorLine anchor) const
{
if (!anchor.item) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to a null item.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor to a null item.");
return false;
} else if (anchor.anchorLine & QQuickAnchors::Vertical_Mask) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor a horizontal edge to a vertical edge.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor a horizontal edge to a vertical edge.");
return false;
} else if (anchor.item != readParentItem(item)
&& readParentItem(anchor.item) != readParentItem(item)) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
return false;
} else if (anchor.item == item) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor item to self.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor item to self.");
return false;
}
@@ -1361,13 +1361,13 @@ bool QQuickAnchorsPrivate::checkVValid() const
if (usedAnchors & QQuickAnchors::TopAnchor &&
usedAnchors & QQuickAnchors::BottomAnchor &&
usedAnchors & QQuickAnchors::VCenterAnchor) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot specify top, bottom, and verticalCenter anchors at the same time.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot specify top, bottom, and verticalCenter anchors at the same time.");
return false;
} else if (usedAnchors & QQuickAnchors::BaselineAnchor &&
(usedAnchors & QQuickAnchors::TopAnchor ||
usedAnchors & QQuickAnchors::BottomAnchor ||
usedAnchors & QQuickAnchors::VCenterAnchor)) {
- qmlInfo(item) << QQuickAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors.");
+ qmlWarning(item) << QQuickAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors.");
return false;
}
@@ -1377,17 +1377,17 @@ bool QQuickAnchorsPrivate::checkVValid() const
bool QQuickAnchorsPrivate::checkVAnchorValid(QQuickAnchorLine anchor) const
{
if (!anchor.item) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to a null item.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor to a null item.");
return false;
} else if (anchor.anchorLine & QQuickAnchors::Horizontal_Mask) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor a vertical edge to a horizontal edge.");
return false;
} else if (anchor.item != readParentItem(item)
&& readParentItem(anchor.item) != readParentItem(item)) {
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor to an item that isn't a parent or sibling.");
return false;
} else if (anchor.item == item){
- qmlInfo(item) << QQuickAnchors::tr("Cannot anchor item to self.");
+ qmlWarning(item) << QQuickAnchors::tr("Cannot anchor item to self.");
return false;
}
diff --git a/src/quick/items/qquickanchors_p_p.h b/src/quick/items/qquickanchors_p_p.h
index 0373b1f824..906f607302 100644
--- a/src/quick/items/qquickanchors_p_p.h
+++ b/src/quick/items/qquickanchors_p_p.h
@@ -124,7 +124,7 @@ public:
void clearItem(QQuickItem *);
- QQuickGeometryChange calculateDependency(QQuickItem *);
+ QQuickGeometryChange calculateDependency(QQuickItem *) const;
void addDepend(QQuickItem *);
void remDepend(QQuickItem *);
bool isItemComplete() const;
@@ -150,7 +150,7 @@ public:
bool checkVAnchorValid(QQuickAnchorLine anchor) const;
bool calcStretch(QQuickItem *edge1Item, QQuickAnchors::Anchor edge1Line,
QQuickItem *edge2Item, QQuickAnchors::Anchor edge2Line,
- qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch);
+ qreal offset1, qreal offset2, QQuickAnchors::Anchor line, qreal &stretch) const;
bool isMirrored() const;
void updateHorizontalAnchors();
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp
index 81c649dbd5..22ea4774be 100644
--- a/src/quick/items/qquickanimatedimage.cpp
+++ b/src/quick/items/qquickanimatedimage.cpp
@@ -67,7 +67,7 @@ QQuickPixmap* QQuickAnimatedImagePrivate::infoForCurrentFrame(QQmlEngine *engine
.arg(current));
}
if (!requestedUrl.isEmpty()) {
- if (QQuickPixmap::isCached(requestedUrl, QSize()))
+ if (QQuickPixmap::isCached(requestedUrl, QSize(), QQuickImageProviderOptions()))
pixmap = new QQuickPixmap(engine, requestedUrl);
else
pixmap = new QQuickPixmap(requestedUrl, _movie->currentImage());
@@ -371,7 +371,7 @@ void QQuickAnimatedImage::movieRequestFinished()
#endif
if (!d->_movie->isValid()) {
- qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString();
+ qmlWarning(this) << "Error Reading Animated Image File " << d->url.toString();
delete d->_movie;
d->_movie = 0;
d->setImage(QImage());
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp
index 8aeef4ef4a..76c2146ddb 100644
--- a/src/quick/items/qquickanimatedsprite.cpp
+++ b/src/quick/items/qquickanimatedsprite.cpp
@@ -626,7 +626,7 @@ QSGSpriteNode* QQuickAnimatedSprite::initNode()
Q_D(QQuickAnimatedSprite);
if (!d->m_spriteEngine) {
- qmlInfo(this) << "No sprite engine...";
+ qmlWarning(this) << "No sprite engine...";
return nullptr;
} else if (d->m_spriteEngine->status() == QQuickPixmap::Null) {
d->m_spriteEngine->startAssemblingImage();
diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp
index 67b99bfbc6..28d834f9e2 100644
--- a/src/quick/items/qquickborderimage.cpp
+++ b/src/quick/items/qquickborderimage.cpp
@@ -515,7 +515,7 @@ void QQuickBorderImage::requestFinished()
QSize impsize = d->pix.implicitSize();
if (d->pix.isError()) {
d->status = Error;
- qmlInfo(this) << d->pix.error();
+ qmlWarning(this) << d->pix.error();
if (d->progress != 0) {
d->progress = 0;
emit progressChanged(d->progress);
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 7a112e840a..e5969eed7f 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -307,7 +307,7 @@ void QQuickDragAttached::setActive(bool active)
Q_D(QQuickDragAttached);
if (d->active != active) {
if (d->inEvent)
- qmlInfo(this) << "active cannot be changed from within a drag event handler";
+ qmlWarning(this) << "active cannot be changed from within a drag event handler";
else if (active) {
if (d->dragType == QQuickDrag::Internal) {
d->start(d->supportedActions);
@@ -629,7 +629,7 @@ void QQuickDragAttached::start(QQmlV4Function *args)
{
Q_D(QQuickDragAttached);
if (d->inEvent) {
- qmlInfo(this) << "start() cannot be called from within a drag event handler";
+ qmlWarning(this) << "start() cannot be called from within a drag event handler";
return;
}
@@ -675,7 +675,7 @@ int QQuickDragAttached::drop()
Qt::DropAction acceptedAction = Qt::IgnoreAction;
if (d->inEvent) {
- qmlInfo(this) << "drop() cannot be called from within a drag event handler";
+ qmlWarning(this) << "drop() cannot be called from within a drag event handler";
return acceptedAction;
}
@@ -722,7 +722,7 @@ void QQuickDragAttached::cancel()
Q_D(QQuickDragAttached);
if (d->inEvent) {
- qmlInfo(this) << "cancel() cannot be called from within a drag event handler";
+ qmlWarning(this) << "cancel() cannot be called from within a drag event handler";
return;
}
@@ -809,12 +809,12 @@ void QQuickDragAttached::startDrag(QQmlV4Function *args)
Q_D(QQuickDragAttached);
if (d->inEvent) {
- qmlInfo(this) << "startDrag() cannot be called from within a drag event handler";
+ qmlWarning(this) << "startDrag() cannot be called from within a drag event handler";
return;
}
if (!d->active) {
- qmlInfo(this) << "startDrag() drag must be active";
+ qmlWarning(this) << "startDrag() drag must be active";
return;
}
diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h
index cc6318a4a3..357f72b3e7 100644
--- a/src/quick/items/qquickdrag_p.h
+++ b/src/quick/items/qquickdrag_p.h
@@ -77,7 +77,7 @@ class QQuickDragGrabber
QIntrusiveListNode node;
protected:
- void objectDestroyed(QQuickItem *) { delete this; }
+ void objectDestroyed(QQuickItem *) override { delete this; }
};
typedef QIntrusiveList<Item, &Item::node> ItemList;
@@ -290,7 +290,7 @@ public:
Q_INVOKABLE int drop();
- bool event(QEvent *event);
+ bool event(QEvent *event) override;
public Q_SLOTS:
void start(QQmlV4Function *);
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 84c44c6541..b314390915 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -513,7 +513,7 @@ void QQuickDropArea::dropEvent(QDropEvent *event)
easily be translated into a QByteArray. \a format should be one contained in the \l formats property.
*/
-QObject *QQuickDropEvent::source()
+QObject *QQuickDropEvent::source() const
{
if (const QQuickDragMimeData *dragMime = qobject_cast<const QQuickDragMimeData *>(event->mimeData()))
return dragMime->source();
diff --git a/src/quick/items/qquickdroparea_p.h b/src/quick/items/qquickdroparea_p.h
index ccde2bcd19..0c4c072db7 100644
--- a/src/quick/items/qquickdroparea_p.h
+++ b/src/quick/items/qquickdroparea_p.h
@@ -86,7 +86,7 @@ public:
qreal x() const { return event->pos().x(); }
qreal y() const { return event->pos().y(); }
- QObject *source();
+ QObject *source() const;
Qt::DropActions supportedActions() const { return event->possibleActions(); }
Qt::DropActions proposedAction() const { return event->proposedAction(); }
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 70d95ccdf8..b6c45c40a8 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -946,7 +946,7 @@ Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickEventPoint *eve
dbg << "QQuickEventPoint(valid:" << event->isValid() << " accepted:" << event->isAccepted()
<< " state:";
QtDebugUtils::formatQEnum(dbg, event->state());
- dbg << " scenePos:" << event->scenePos() << " id:" << event->pointId()
+ dbg << " scenePos:" << event->scenePos() << " id:" << hex << event->pointId() << dec
<< " timeHeld:" << event->timeHeld() << ')';
return dbg;
}
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 537367b3a3..d97c731157 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -277,7 +277,7 @@ void QQuickFlickablePrivate::init()
Returns the amount to overshoot by given a velocity.
Will be roughly in range 0 - size/4
*/
-qreal QQuickFlickablePrivate::overShootDistance(qreal size)
+qreal QQuickFlickablePrivate::overShootDistance(qreal size) const
{
if (maxVelocity <= 0)
return 0.0;
@@ -874,9 +874,9 @@ bool QQuickFlickable::isAtYBeginning() const
}
\endcode
*/
-QQuickItem *QQuickFlickable::contentItem()
+QQuickItem *QQuickFlickable::contentItem() const
{
- Q_D(QQuickFlickable);
+ Q_D(const QQuickFlickable);
return d->contentItem;
}
@@ -951,7 +951,7 @@ void QQuickFlickable::setPixelAligned(bool align)
}
}
-qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event)
+qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
return event->timestamp();
@@ -960,7 +960,7 @@ qint64 QQuickFlickablePrivate::computeCurrentTime(QInputEvent *event)
return timer.elapsed();
}
-qreal QQuickFlickablePrivate::devicePixelRatio()
+qreal QQuickFlickablePrivate::devicePixelRatio() const
{
return (window ? window->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
}
@@ -1570,12 +1570,52 @@ void QQuickFlickablePrivate::replayDelayedPress()
//XXX pixelAligned ignores the global position of the Flickable, i.e. assumes Flickable itself is pixel aligned.
void QQuickFlickablePrivate::setViewportX(qreal x)
{
- contentItem->setX(pixelAligned ? -Round(-x) : x);
+ Q_Q(QQuickFlickable);
+ if (pixelAligned)
+ x = -Round(-x);
+
+ contentItem->setX(x);
+ if (contentItem->x() != x)
+ return; // reentered
+
+ const qreal maxX = q->maxXExtent();
+ const qreal minX = q->minXExtent();
+
+ qreal overshoot = 0.0;
+ if (x <= maxX)
+ overshoot = maxX - x;
+ else if (x >= minX)
+ overshoot = minX - x;
+
+ if (overshoot != hData.overshoot) {
+ hData.overshoot = overshoot;
+ emit q->horizontalOvershootChanged();
+ }
}
void QQuickFlickablePrivate::setViewportY(qreal y)
{
- contentItem->setY(pixelAligned ? -Round(-y) : y);
+ Q_Q(QQuickFlickable);
+ if (pixelAligned)
+ y = -Round(-y);
+
+ contentItem->setY(y);
+ if (contentItem->y() != y)
+ return; // reentered
+
+ const qreal maxY = q->maxYExtent();
+ const qreal minY = q->minYExtent();
+
+ qreal overshoot = 0.0;
+ if (y <= maxY)
+ overshoot = maxY - y;
+ else if (y >= minY)
+ overshoot = minY - y;
+
+ if (overshoot != vData.overshoot) {
+ vData.overshoot = overshoot;
+ emit q->verticalOvershootChanged();
+ }
}
void QQuickFlickable::timerEvent(QTimerEvent *event)
@@ -1841,6 +1881,8 @@ QQmlListProperty<QQuickItem> QQuickFlickable::flickableChildren()
beyond the boundary of the Flickable, and can overshoot the
boundary when flicked.
\endlist
+
+ \sa horizontalOvershoot, verticalOvershoot
*/
QQuickFlickable::BoundsBehavior QQuickFlickable::boundsBehavior() const
{
@@ -2641,4 +2683,38 @@ void QQuickFlickablePrivate::updateVelocity()
emit q->verticalVelocityChanged();
}
+/*!
+ \qmlproperty real QtQuick::Flickable::horizontalOvershoot
+ \since 5.9
+
+ This property holds the horizontal overshoot, that is, the horizontal distance by
+ which the contents has been dragged or flicked past the bounds of the flickable.
+ The value is negative when the content is dragged or flicked beyond the beginning,
+ and positive when beyond the end; \c 0.0 otherwise.
+
+ \sa verticalOvershoot, boundsBehavior
+*/
+qreal QQuickFlickable::horizontalOvershoot() const
+{
+ Q_D(const QQuickFlickable);
+ return d->hData.overshoot;
+}
+
+/*!
+ \qmlproperty real QtQuick::Flickable::verticalOvershoot
+ \since 5.9
+
+ This property holds the vertical overshoot, that is, the vertical distance by
+ which the contents has been dragged or flicked past the bounds of the flickable.
+ The value is negative when the content is dragged or flicked beyond the beginning,
+ and positive when beyond the end; \c 0.0 otherwise.
+
+ \sa horizontalOvershoot, boundsBehavior
+*/
+qreal QQuickFlickable::verticalOvershoot() const
+{
+ Q_D(const QQuickFlickable);
+ return d->vData.overshoot;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickflickable_p.h b/src/quick/items/qquickflickable_p.h
index 62733bda1c..52cade1472 100644
--- a/src/quick/items/qquickflickable_p.h
+++ b/src/quick/items/qquickflickable_p.h
@@ -106,12 +106,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickFlickable : public QQuickItem
Q_PROPERTY(bool pixelAligned READ pixelAligned WRITE setPixelAligned NOTIFY pixelAlignedChanged)
+ Q_PROPERTY(qreal horizontalOvershoot READ horizontalOvershoot NOTIFY horizontalOvershootChanged REVISION 9)
+ Q_PROPERTY(qreal verticalOvershoot READ verticalOvershoot NOTIFY verticalOvershootChanged REVISION 9)
+
Q_PROPERTY(QQmlListProperty<QObject> flickableData READ flickableData)
Q_PROPERTY(QQmlListProperty<QQuickItem> flickableChildren READ flickableChildren)
Q_CLASSINFO("DefaultProperty", "flickableData")
- Q_FLAGS(BoundsBehavior)
-
public:
QQuickFlickable(QQuickItem *parent=0);
~QQuickFlickable();
@@ -126,6 +127,7 @@ public:
DragAndOvershootBounds = DragOverBounds | OvershootBounds
};
Q_DECLARE_FLAGS(BoundsBehavior, BoundsBehaviorFlag)
+ Q_FLAG(BoundsBehavior)
BoundsBehavior boundsBehavior() const;
void setBoundsBehavior(BoundsBehavior);
@@ -190,7 +192,7 @@ public:
bool isAtYEnd() const;
bool isAtYBeginning() const;
- QQuickItem *contentItem();
+ QQuickItem *contentItem() const;
enum FlickableDirection { AutoFlickDirection=0x0, HorizontalFlick=0x1, VerticalFlick=0x2, HorizontalAndVerticalFlick=0x3,
AutoFlickIfNeeded=0xc };
@@ -201,6 +203,9 @@ public:
bool pixelAligned() const;
void setPixelAligned(bool align);
+ qreal horizontalOvershoot() const;
+ qreal verticalOvershoot() const;
+
Q_INVOKABLE void resizeContent(qreal w, qreal h, QPointF center);
Q_INVOKABLE void returnToBounds();
Q_INVOKABLE void flick(qreal xVelocity, qreal yVelocity);
@@ -243,6 +248,8 @@ Q_SIGNALS:
void dragStarted();
void dragEnded();
void pixelAlignedChanged();
+ Q_REVISION(9) void horizontalOvershootChanged();
+ Q_REVISION(9) void verticalOvershootChanged();
protected:
bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE;
@@ -286,6 +293,7 @@ protected:
private:
Q_DISABLE_COPY(QQuickFlickable)
Q_DECLARE_PRIVATE(QQuickFlickable)
+ friend class QQuickFlickableContentItem;
friend class QQuickFlickableVisibleArea;
friend class QQuickFlickableReboundTransition;
};
diff --git a/src/quick/items/qquickflickable_p_p.h b/src/quick/items/qquickflickable_p_p.h
index ac1e39d829..1ceff22dfc 100644
--- a/src/quick/items/qquickflickable_p_p.h
+++ b/src/quick/items/qquickflickable_p_p.h
@@ -101,7 +101,7 @@ public:
: move(fp, func)
, transitionToBounds(0)
, viewSize(-1), lastPos(0), previousDragDelta(0), velocity(0), startMargin(0), endMargin(0)
- , origin(0)
+ , origin(0), overshoot(0)
, transitionTo(0)
, continuousFlickVelocity(0), velocityTime(), vTime(0)
, smoothVelocity(fp), atEnd(false), atBeginning(true)
@@ -148,6 +148,7 @@ public:
qreal startMargin;
qreal endMargin;
qreal origin;
+ qreal overshoot;
qreal transitionTo;
qreal continuousFlickVelocity;
QElapsedTimer velocityTime;
@@ -192,7 +193,7 @@ public:
void setViewportX(qreal x);
void setViewportY(qreal y);
- qreal overShootDistance(qreal size);
+ qreal overShootDistance(qreal size) const;
void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) Q_DECL_OVERRIDE;
@@ -260,8 +261,8 @@ public:
const QVector2D &deltas, bool overThreshold, bool momentum,
bool velocitySensitiveOverBounds, const QVector2D &velocity);
- qint64 computeCurrentTime(QInputEvent *event);
- qreal devicePixelRatio();
+ qint64 computeCurrentTime(QInputEvent *event) const;
+ qreal devicePixelRatio() const;
// flickableData property
static void data_append(QQmlListProperty<QObject> *, QObject *);
diff --git a/src/quick/items/qquickflickablebehavior_p.h b/src/quick/items/qquickflickablebehavior_p.h
index 3377728d3f..ae7fe71359 100644
--- a/src/quick/items/qquickflickablebehavior_p.h
+++ b/src/quick/items/qquickflickablebehavior_p.h
@@ -75,20 +75,12 @@
// The default maximum velocity of a flick.
#ifndef QML_FLICK_DEFAULTMAXVELOCITY
-#ifdef Q_OS_BLACKBERRY
-#define QML_FLICK_DEFAULTMAXVELOCITY 10000
-#else
-#define QML_FLICK_DEFAULTMAXVELOCITY 2500
-#endif
+# define QML_FLICK_DEFAULTMAXVELOCITY 2500
#endif
// The default deceleration of a flick.
#ifndef QML_FLICK_DEFAULTDECELERATION
-#ifdef Q_OS_BLACKBERRY
-#define QML_FLICK_DEFAULTDECELERATION 5000
-#else
-#define QML_FLICK_DEFAULTDECELERATION 1500
-#endif
+# define QML_FLICK_DEFAULTDECELERATION 1500
#endif
// How much faster to decelerate when overshooting
diff --git a/src/quick/items/qquickflipable.cpp b/src/quick/items/qquickflipable.cpp
index 342e6c07b8..f452893528 100644
--- a/src/quick/items/qquickflipable.cpp
+++ b/src/quick/items/qquickflipable.cpp
@@ -143,7 +143,7 @@ QQuickFlipable::~QQuickFlipable()
The front and back sides of the flipable.
*/
-QQuickItem *QQuickFlipable::front()
+QQuickItem *QQuickFlipable::front() const
{
Q_D(const QQuickFlipable);
return d->front;
@@ -153,7 +153,7 @@ void QQuickFlipable::setFront(QQuickItem *front)
{
Q_D(QQuickFlipable);
if (d->front) {
- qmlInfo(this) << tr("front is a write-once property");
+ qmlWarning(this) << tr("front is a write-once property");
return;
}
d->front = front;
@@ -175,7 +175,7 @@ void QQuickFlipable::setBack(QQuickItem *back)
{
Q_D(QQuickFlipable);
if (d->back) {
- qmlInfo(this) << tr("back is a write-once property");
+ qmlWarning(this) << tr("back is a write-once property");
return;
}
if (back == 0)
diff --git a/src/quick/items/qquickflipable_p.h b/src/quick/items/qquickflipable_p.h
index 17a74d1f7a..a76977d4ac 100644
--- a/src/quick/items/qquickflipable_p.h
+++ b/src/quick/items/qquickflipable_p.h
@@ -77,7 +77,7 @@ public:
QQuickFlipable(QQuickItem *parent=0);
~QQuickFlipable();
- QQuickItem *front();
+ QQuickItem *front() const;
void setFront(QQuickItem *);
QQuickItem *back();
diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp
index 9714f39663..2f8d71fc11 100644
--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -510,9 +510,9 @@ void QQuickGenericShaderEffect::updateShaderVars(Shader shaderType)
QSGShaderEffectNode::VariableData &vd(m_shaders[shaderType].varData[i]);
const bool isSpecial = v.name.startsWith("qt_"); // special names not mapped to properties
if (isSpecial) {
- if (v.name == QByteArrayLiteral("qt_Opacity"))
+ if (v.name == "qt_Opacity")
vd.specialType = QSGShaderEffectNode::VariableData::Opacity;
- else if (v.name == QByteArrayLiteral("qt_Matrix"))
+ else if (v.name == "qt_Matrix")
vd.specialType = QSGShaderEffectNode::VariableData::Matrix;
else if (v.name.startsWith("qt_SubRect_"))
vd.specialType = QSGShaderEffectNode::VariableData::SubRect;
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index 14ea43f123..e6a7a0acd0 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -66,19 +66,19 @@ public:
{
}
- qreal position() const Q_DECL_OVERRIDE {
+ qreal position() const override {
return rowPos();
}
- qreal endPosition() const Q_DECL_OVERRIDE {
+ qreal endPosition() const override {
return endRowPos();
}
- qreal size() const Q_DECL_OVERRIDE {
+ qreal size() const override {
return view->flow() == QQuickGridView::FlowLeftToRight ? view->cellHeight() : view->cellWidth();
}
- qreal sectionSize() const Q_DECL_OVERRIDE {
+ qreal sectionSize() const override {
return 0.0;
}
@@ -122,7 +122,7 @@ public:
void setPosition(qreal col, qreal row, bool immediate = false) {
moveTo(pointForPosition(col, row), immediate);
}
- bool contains(qreal x, qreal y) const Q_DECL_OVERRIDE {
+ bool contains(qreal x, qreal y) const override {
return (x >= itemX() && x < itemX() + view->cellWidth() &&
y >= itemY() && y < itemY() + view->cellHeight());
}
@@ -159,13 +159,13 @@ class QQuickGridViewPrivate : public QQuickItemViewPrivate
Q_DECLARE_PUBLIC(QQuickGridView)
public:
- Qt::Orientation layoutOrientation() const Q_DECL_OVERRIDE;
- bool isContentFlowReversed() const Q_DECL_OVERRIDE;
+ Qt::Orientation layoutOrientation() const override;
+ bool isContentFlowReversed() const override;
- qreal positionAt(int index) const Q_DECL_OVERRIDE;
- qreal endPositionAt(int index) const Q_DECL_OVERRIDE;
- qreal originPosition() const Q_DECL_OVERRIDE;
- qreal lastPosition() const Q_DECL_OVERRIDE;
+ qreal positionAt(int index) const override;
+ qreal endPositionAt(int index) const override;
+ qreal originPosition() const override;
+ qreal lastPosition() const override;
qreal rowSize() const;
qreal colSize() const;
@@ -179,43 +179,43 @@ public:
void resetColumns();
- bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) Q_DECL_OVERRIDE;
- bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) Q_DECL_OVERRIDE;
+ bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override;
+ bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override;
void removeItem(FxViewItem *item);
- FxViewItem *newViewItem(int index, QQuickItem *item) Q_DECL_OVERRIDE;
- void initializeViewItem(FxViewItem *item) Q_DECL_OVERRIDE;
- void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) Q_DECL_OVERRIDE;
- void repositionPackageItemAt(QQuickItem *item, int index) Q_DECL_OVERRIDE;
- void resetFirstItemPosition(qreal pos = 0.0) Q_DECL_OVERRIDE;
- void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) Q_DECL_OVERRIDE;
-
- void createHighlight() Q_DECL_OVERRIDE;
- void updateHighlight() Q_DECL_OVERRIDE;
- void resetHighlightPosition() Q_DECL_OVERRIDE;
-
- void setPosition(qreal pos) Q_DECL_OVERRIDE;
- void layoutVisibleItems(int fromModelIndex = 0) Q_DECL_OVERRIDE;
- bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) Q_DECL_OVERRIDE;
- void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) Q_DECL_OVERRIDE;
- bool needsRefillForAddedOrRemovedIndex(int index) const Q_DECL_OVERRIDE;
-
- qreal headerSize() const Q_DECL_OVERRIDE;
- qreal footerSize() const Q_DECL_OVERRIDE;
- bool showHeaderForIndex(int index) const Q_DECL_OVERRIDE;
- bool showFooterForIndex(int index) const Q_DECL_OVERRIDE;
- void updateHeader() Q_DECL_OVERRIDE;
- void updateFooter() Q_DECL_OVERRIDE;
-
- void changedVisibleIndex(int newIndex) Q_DECL_OVERRIDE;
- void initializeCurrentItem() Q_DECL_OVERRIDE;
-
- void updateViewport() Q_DECL_OVERRIDE;
- void fixupPosition() Q_DECL_OVERRIDE;
- void fixup(AxisData &data, qreal minExtent, qreal maxExtent) Q_DECL_OVERRIDE;
+ FxViewItem *newViewItem(int index, QQuickItem *item) override;
+ void initializeViewItem(FxViewItem *item) override;
+ void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override;
+ void repositionPackageItemAt(QQuickItem *item, int index) override;
+ void resetFirstItemPosition(qreal pos = 0.0) override;
+ void adjustFirstItem(qreal forwards, qreal backwards, int changeBeforeVisible) override;
+
+ void createHighlight() override;
+ void updateHighlight() override;
+ void resetHighlightPosition() override;
+
+ void setPosition(qreal pos) override;
+ void layoutVisibleItems(int fromModelIndex = 0) override;
+ bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) override;
+ void translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) override;
+ bool needsRefillForAddedOrRemovedIndex(int index) const override;
+
+ qreal headerSize() const override;
+ qreal footerSize() const override;
+ bool showHeaderForIndex(int index) const override;
+ bool showFooterForIndex(int index) const override;
+ void updateHeader() override;
+ void updateFooter() override;
+
+ void changedVisibleIndex(int newIndex) override;
+ void initializeCurrentItem() override;
+
+ void updateViewport() override;
+ void fixupPosition() override;
+ void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override;
bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) Q_DECL_OVERRIDE;
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) override;
QQuickGridView::Flow flow;
qreal cellWidth;
@@ -383,8 +383,7 @@ qreal QQuickGridViewPrivate::snapPosAt(qreal pos) const
FxViewItem *QQuickGridViewPrivate::snapItemAt(qreal pos) const
{
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : visibleItems) {
if (item->index == -1)
continue;
qreal itemTop = item->position();
@@ -397,16 +396,16 @@ FxViewItem *QQuickGridViewPrivate::snapItemAt(qreal pos) const
int QQuickGridViewPrivate::snapIndex() const
{
int index = currentIndex;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxGridItemSG *item = static_cast<FxGridItemSG*>(visibleItems.at(i));
+ for (FxViewItem *item : visibleItems) {
if (item->index == -1)
continue;
qreal itemTop = item->position();
FxGridItemSG *hItem = static_cast<FxGridItemSG*>(highlight);
if (itemTop >= hItem->rowPos()-rowSize()/2 && itemTop < hItem->rowPos()+rowSize()/2) {
- index = item->index;
- if (item->colPos() >= hItem->colPos()-colSize()/2 && item->colPos() < hItem->colPos()+colSize()/2)
- return item->index;
+ FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(item);
+ index = gridItem->index;
+ if (gridItem->colPos() >= hItem->colPos()-colSize()/2 && gridItem->colPos() < hItem->colPos()+colSize()/2)
+ return gridItem->index;
}
}
return index;
@@ -496,8 +495,8 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal
// We've jumped more than a page. Estimate which items are now
// visible and fill from there.
int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns;
- for (int i = 0; i < visibleItems.count(); ++i)
- releaseItem(visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(visibleItems))
+ releaseItem(item);
visibleItems.clear();
modelIndex += count;
if (modelIndex >= model->count())
@@ -2055,9 +2054,9 @@ void QQuickGridView::viewportMoved(Qt::Orientations orient)
// Set visibility of items to eliminate cost of items outside the visible area.
qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- FxGridItemSG *item = static_cast<FxGridItemSG*>(d->visibleItems.at(i));
- QQuickItemPrivate::get(item->item)->setCulled(item->rowPos() + d->rowSize() < from || item->rowPos() > to);
+ for (FxViewItem *item : qAsConst(d->visibleItems)) {
+ FxGridItemSG *gridItem = static_cast<FxGridItemSG*>(item);
+ QQuickItemPrivate::get(gridItem->item)->setCulled(gridItem->rowPos() + d->rowSize() < from || gridItem->rowPos() > to);
}
if (d->currentItem) {
FxGridItemSG *item = static_cast<FxGridItemSG*>(d->currentItem);
@@ -2357,8 +2356,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
if (modelIndex <= visibleIndex) {
// Insert before visible items
visibleIndex += count;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex)
item->index += count;
}
@@ -2391,8 +2389,7 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
// Update the indexes of the following visible items.
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex) {
item->index += count;
if (change.isMove())
@@ -2535,8 +2532,10 @@ void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
countItemsRemoved -= removalResult.countChangeAfterVisibleItems;
- for (int i=markerItemIndex+1; i<visibleItems.count() && visibleItems.at(i)->position() < viewEndPos; i++) {
+ for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
FxGridItemSG *gridItem = static_cast<FxGridItemSG *>(visibleItems.at(i));
+ if (gridItem->position() >= viewEndPos)
+ break;
if (!gridItem->transitionScheduledOrRunning()) {
qreal origRowPos = gridItem->colPos();
qreal origColPos = gridItem->rowPos();
diff --git a/src/quick/items/qquickgridview_p.h b/src/quick/items/qquickgridview_p.h
index aaf6e4a75b..5c6da2b433 100644
--- a/src/quick/items/qquickgridview_p.h
+++ b/src/quick/items/qquickgridview_p.h
@@ -84,8 +84,8 @@ public:
QQuickGridView(QQuickItem *parent=0);
~QQuickGridView();
- void setHighlightFollowsCurrentItem(bool) Q_DECL_OVERRIDE;
- void setHighlightMoveDuration(int) Q_DECL_OVERRIDE;
+ void setHighlightFollowsCurrentItem(bool) override;
+ void setHighlightMoveDuration(int) override;
Flow flow() const;
void setFlow(Flow);
@@ -117,10 +117,10 @@ Q_SIGNALS:
void snapModeChanged();
protected:
- void viewportMoved(Qt::Orientations) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void initItem(int index, QObject *item) Q_DECL_OVERRIDE;
+ void viewportMoved(Qt::Orientations) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ void initItem(int index, QObject *item) override;
};
class QQuickGridViewAttached : public QQuickItemViewAttached
diff --git a/src/quick/items/qquickimage.cpp b/src/quick/items/qquickimage.cpp
index e36c070248..f71a2fbdbd 100644
--- a/src/quick/items/qquickimage.cpp
+++ b/src/quick/items/qquickimage.cpp
@@ -69,7 +69,7 @@ public:
emit textureChanged();
}
- QSGTexture *texture() const {
+ QSGTexture *texture() const override {
if (m_texture) {
m_texture->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest);
m_texture->setMipmapFiltering(m_mipmap ? QSGTexture::Linear : QSGTexture::None);
@@ -304,6 +304,15 @@ void QQuickImage::setFillMode(FillMode mode)
if (d->fillMode == mode)
return;
d->fillMode = mode;
+ if ((mode == PreserveAspectCrop) != d->providerOptions.preserveAspectRatioCrop()) {
+ d->providerOptions.setPreserveAspectRatioCrop(mode == PreserveAspectCrop);
+ if (isComponentComplete())
+ load();
+ } else if ((mode == PreserveAspectFit) != d->providerOptions.preserveAspectRatioFit()) {
+ d->providerOptions.setPreserveAspectRatioFit(mode == PreserveAspectFit);
+ if (isComponentComplete())
+ load();
+ }
update();
updatePaintedGeometry();
emit fillModeChanged();
@@ -423,7 +432,9 @@ qreal QQuickImage::paintedHeight() const
(The \l fillMode is independent of this.)
If both the sourceSize.width and sourceSize.height are set the image will be scaled
- down to fit within the specified size, maintaining the image's aspect ratio. The actual
+ down to fit within the specified size (unless PreserveAspectCrop or PreserveAspectFit
+ are used, then it will be scaled to match the optimal size for cropping/fitting),
+ maintaining the image's aspect ratio. The actual
size of the image after scaling is available via \l Item::implicitWidth and \l Item::implicitHeight.
If the source is an intrinsically scalable image (eg. SVG), this property
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp
index a2b99b6395..22d631e917 100644
--- a/src/quick/items/qquickimagebase.cpp
+++ b/src/quick/items/qquickimagebase.cpp
@@ -246,7 +246,7 @@ void QQuickImageBase::load()
resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);
}
- d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options, d->autoTransform);
+ d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options, d->providerOptions);
if (d->pix.isLoading()) {
if (d->progress != 0.0) {
@@ -281,7 +281,7 @@ void QQuickImageBase::requestFinished()
Q_D(QQuickImageBase);
if (d->pix.isError()) {
- qmlInfo(this) << d->pix.error();
+ qmlWarning(this) << d->pix.error();
d->pix.clear(this);
d->status = Error;
if (d->progress != 0.0) {
@@ -381,17 +381,18 @@ void QQuickImageBase::resolve2xLocalFile(const QUrl &url, qreal targetDevicePixe
bool QQuickImageBase::autoTransform() const
{
Q_D(const QQuickImageBase);
- if (d->autoTransform == UsePluginDefault)
- return d->pix.autoTransform() == ApplyTransform;
- return d->autoTransform == ApplyTransform;
+ if (d->providerOptions.autoTransform() == QQuickImageProviderOptions::UsePluginDefaultTransform)
+ return d->pix.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
+ return d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
}
void QQuickImageBase::setAutoTransform(bool transform)
{
Q_D(QQuickImageBase);
- if (d->autoTransform != UsePluginDefault && transform == (d->autoTransform == ApplyTransform))
+ if (d->providerOptions.autoTransform() != QQuickImageProviderOptions::UsePluginDefaultTransform &&
+ transform == (d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform))
return;
- d->autoTransform = transform ? ApplyTransform : DoNotApplyTransform;
+ d->providerOptions.setAutoTransform(transform ? QQuickImageProviderOptions::ApplyTransform : QQuickImageProviderOptions::DoNotApplyTransform);
emitAutoTransformBaseChanged();
}
diff --git a/src/quick/items/qquickimagebase_p_p.h b/src/quick/items/qquickimagebase_p_p.h
index 1eb566a3c8..d9b609c7fe 100644
--- a/src/quick/items/qquickimagebase_p_p.h
+++ b/src/quick/items/qquickimagebase_p_p.h
@@ -68,7 +68,6 @@ public:
: status(QQuickImageBase::Null),
progress(0.0),
devicePixelRatio(1.0),
- autoTransform(UsePluginDefault),
async(false),
cache(true),
mirror(false),
@@ -83,7 +82,7 @@ public:
QSize sourcesize;
QSize oldSourceSize;
qreal devicePixelRatio;
- AutoTransform autoTransform;
+ QQuickImageProviderOptions providerOptions;
bool async : 1;
bool cache : 1;
bool mirror: 1;
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 021ca9b64b..1a244b0dd9 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -333,6 +333,12 @@ QVariant QQuickItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
}
#endif // im
+void QQuickItemKeyFilter::shortcutOverride(QKeyEvent *event)
+{
+ if (m_next)
+ m_next->shortcutOverride(event);
+}
+
void QQuickItemKeyFilter::componentComplete()
{
if (m_next) m_next->componentComplete();
@@ -774,7 +780,7 @@ const SigMap sigMap[] = {
{ 0, 0 }
};
-const QByteArray QQuickKeysAttached::keyToSignal(int key)
+QByteArray QQuickKeysAttached::keyToSignal(int key)
{
QByteArray keySignal;
if (key >= Qt::Key_0 && key <= Qt::Key_9) {
@@ -789,9 +795,9 @@ const QByteArray QQuickKeysAttached::keyToSignal(int key)
return keySignal;
}
-bool QQuickKeysAttached::isConnected(const char *signalName)
+bool QQuickKeysAttached::isConnected(const char *signalName) const
{
- Q_D(QQuickKeysAttached);
+ Q_D(const QQuickKeysAttached);
int signal_index = d->signalIndex(signalName);
return d->isSignalConnected(signal_index);
}
@@ -935,6 +941,46 @@ bool QQuickKeysAttached::isConnected(const char *signalName)
*/
/*!
+ \qmlsignal QtQuick::Keys::shortcutOverride(KeyEvent event)
+ \since 5.9
+
+ This signal is emitted when a key has been pressed that could potentially
+ be used as a shortcut. The \a event parameter provides information about
+ the event.
+
+ Set \c event.accepted to \c true if you wish to prevent the pressed key
+ from being used as a shortcut by other types, such as \l Shortcut. For
+ example:
+
+ \code
+ Item {
+ id: escapeItem
+ focus: true
+
+ // Ensure that we get escape key press events first.
+ Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape)
+
+ Keys.onEscapePressed: {
+ console.log("escapeItem is handling escape");
+ event.accepted = true;
+ }
+ }
+
+ Shortcut {
+ sequence: "Escape"
+ onActivated: console.log("Shortcut is handling escape")
+ }
+ \endcode
+
+ As with the other signals, \c shortcutOverride will only be emitted for an
+ item if that item has \l {Item::}{activeFocus}.
+
+ The corresponding handler is \c onShortcutOverride.
+
+ \sa Shortcut
+*/
+
+/*!
\qmlsignal QtQuick::Keys::digit0Pressed(KeyEvent event)
This signal is emitted when the digit '0' has been pressed. The \a event
@@ -1426,6 +1472,16 @@ QVariant QQuickKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const
}
#endif // im
+void QQuickKeysAttached::shortcutOverride(QKeyEvent *event)
+{
+ Q_D(QQuickKeysAttached);
+ QQuickKeyEvent &keyEvent = d->theKeyEvent;
+ keyEvent.reset(*event);
+ emit shortcutOverride(&keyEvent);
+
+ event->setAccepted(keyEvent.isAccepted());
+}
+
QQuickKeysAttached *QQuickKeysAttached::qmlAttachedProperties(QObject *obj)
{
return new QQuickKeysAttached(obj);
@@ -1510,7 +1566,7 @@ QQuickLayoutMirroringAttached::QQuickLayoutMirroringAttached(QObject *parent) :
if (itemPrivate)
itemPrivate->extra.value().layoutDirectionAttached = this;
else
- qmlInfo(parent) << tr("LayoutDirection attached property only works with Items and Windows");
+ qmlWarning(parent) << tr("LayoutDirection attached property only works with Items and Windows");
}
QQuickLayoutMirroringAttached * QQuickLayoutMirroringAttached::qmlAttachedProperties(QObject *object)
@@ -1658,7 +1714,7 @@ QQuickEnterKeyAttached::QQuickEnterKeyAttached(QObject *parent)
itemPrivate = QQuickItemPrivate::get(item);
itemPrivate->extra.value().enterKeyAttached = this;
} else
- qmlInfo(parent) << tr("EnterKey attached property only works with Items");
+ qmlWarning(parent) << tr("EnterKey attached property only works with Items");
}
QQuickEnterKeyAttached *QQuickEnterKeyAttached::qmlAttachedProperties(QObject *object)
@@ -4320,7 +4376,7 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const
}
if (!itemObj && !item->isNull()) {
- qmlInfo(this) << "mapFromItem() given argument \"" << item->toQStringNoThrow()
+ qmlWarning(this) << "mapFromItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
v4->throwTypeError();
return;
@@ -4408,7 +4464,7 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
}
if (!itemObj && !item->isNull()) {
- qmlInfo(this) << "mapToItem() given argument \"" << item->toQStringNoThrow()
+ qmlWarning(this) << "mapToItem() given argument \"" << item->toQStringNoThrow()
<< "\" which is neither null nor an Item";
v4->throwTypeError();
return;
@@ -5021,6 +5077,13 @@ void QQuickItemPrivate::deliverInputMethodEvent(QInputMethodEvent *e)
}
#endif // im
+void QQuickItemPrivate::deliverShortcutOverrideEvent(QKeyEvent *event)
+{
+ if (extra.isAllocated() && extra->keyHandler) {
+ extra->keyHandler->shortcutOverride(event);
+ }
+}
+
/*!
Called when \a change occurs for this item.
@@ -7654,6 +7717,9 @@ bool QQuickItem::event(QEvent *ev)
case QEvent::KeyRelease:
d->deliverKeyEvent(static_cast<QKeyEvent*>(ev));
break;
+ case QEvent::ShortcutOverride:
+ d->deliverShortcutOverrideEvent(static_cast<QKeyEvent*>(ev));
+ break;
case QEvent::FocusIn:
focusInEvent(static_cast<QFocusEvent*>(ev));
break;
@@ -8325,7 +8391,7 @@ void QQuickItemWrapper::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine
{
QObjectWrapper::Data *This = static_cast<QObjectWrapper::Data *>(that);
if (QQuickItem *item = static_cast<QQuickItem*>(This->object())) {
- foreach (QQuickItem *child, QQuickItemPrivate::get(item)->childItems)
+ for (QQuickItem *child : qAsConst(QQuickItemPrivate::get(item)->childItems))
QV4::QObjectWrapper::markWrapper(child, e);
}
QV4::QObjectWrapper::markObjects(that, e);
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 45674a106d..c0c9bd46bd 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -559,6 +559,7 @@ public:
#if QT_CONFIG(im)
void deliverInputMethodEvent(QInputMethodEvent *);
#endif
+ void deliverShortcutOverrideEvent(QKeyEvent *);
bool isTransparentForPositioner() const;
void setTransparentForPositioner(bool trans);
@@ -622,6 +623,7 @@ public:
virtual void inputMethodEvent(QInputMethodEvent *event, bool post);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
#endif
+ virtual void shortcutOverride(QKeyEvent *event);
virtual void componentComplete();
bool m_processPost;
@@ -813,6 +815,7 @@ Q_SIGNALS:
void priorityChanged();
void pressed(QQuickKeyEvent *event);
void released(QQuickKeyEvent *event);
+ void shortcutOverride(QQuickKeyEvent *event);
void digit0Pressed(QQuickKeyEvent *event);
void digit1Pressed(QQuickKeyEvent *event);
void digit2Pressed(QQuickKeyEvent *event);
@@ -861,9 +864,10 @@ private:
void inputMethodEvent(QInputMethodEvent *, bool post) Q_DECL_OVERRIDE;
QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
#endif
- const QByteArray keyToSignal(int key);
+ void shortcutOverride(QKeyEvent *event) override;
+ static QByteArray keyToSignal(int key);
- bool isConnected(const char *signalName);
+ bool isConnected(const char *signalName) const;
};
Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const
diff --git a/src/quick/items/qquickitemanimation.cpp b/src/quick/items/qquickitemanimation.cpp
index fd4a7d733f..9873622f41 100644
--- a/src/quick/items/qquickitemanimation.cpp
+++ b/src/quick/items/qquickitemanimation.cpp
@@ -304,7 +304,7 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
bool ok;
const QTransform &transform = targetParent->itemTransform(d->via, &ok);
if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under complex transform");
+ qmlWarning(this) << QQuickParentAnimation::tr("Unable to preserve appearance under complex transform");
ok = false;
}
@@ -315,21 +315,21 @@ QAbstractAnimationJob* QQuickParentAnimation::transition(QQuickStateActions &act
if (transform.m11() == transform.m22())
scale = transform.m11();
else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ qmlWarning(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
} else if (ok && isRotate) {
if (transform.m11() == transform.m22())
scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
+ qmlWarning(this) << QQuickParentAnimation::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
if (scale != 0)
rotation = qAtan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
else {
- qmlInfo(this) << QQuickParentAnimation::tr("Unable to preserve appearance under scale of 0");
+ qmlWarning(this) << QQuickParentAnimation::tr("Unable to preserve appearance under scale of 0");
ok = false;
}
}
@@ -474,7 +474,7 @@ int QQuickAnchorAnimation::duration() const
void QQuickAnchorAnimation::setDuration(int duration)
{
if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
+ qmlWarning(this) << tr("Cannot set a duration of < 0");
return;
}
@@ -613,7 +613,7 @@ int QQuickPathAnimation::duration() const
void QQuickPathAnimation::setDuration(int duration)
{
if (duration < 0) {
- qmlInfo(this) << tr("Cannot set a duration of < 0");
+ qmlWarning(this) << tr("Cannot set a duration of < 0");
return;
}
@@ -869,7 +869,7 @@ QAbstractAnimationJob* QQuickPathAnimation::transition(QQuickStateActions &actio
data->reverse = direction == Backward ? true : false;
data->fromSourced = false;
data->fromDefined = (d->path && d->path->hasStartX() && d->path->hasStartY()) ? true : false;
- data->toDefined = d->path ? d->path->hasEnd() : false;
+ data->toDefined = d->path ? true : false;
int origModifiedSize = modified.count();
for (int i = 0; i < actions.count(); ++i) {
diff --git a/src/quick/items/qquickitemanimation_p_p.h b/src/quick/items/qquickitemanimation_p_p.h
index 92dd84e4a9..2d075dfab3 100644
--- a/src/quick/items/qquickitemanimation_p_p.h
+++ b/src/quick/items/qquickitemanimation_p_p.h
@@ -97,7 +97,7 @@ public:
entryInterval(0), exitInterval(0) {}
~QQuickPathAnimationUpdater() {}
- void setValue(qreal v);
+ void setValue(qreal v) override;
QQuickPath *path;
@@ -133,7 +133,7 @@ public:
void clearTemplate() { animationTemplate = 0; }
- QQuickPathAnimationUpdater *pathUpdater() { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
+ QQuickPathAnimationUpdater *pathUpdater() const { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
private:
QQuickPathAnimationPrivate *animationTemplate;
};
diff --git a/src/quick/items/qquickitemgrabresult.cpp b/src/quick/items/qquickitemgrabresult.cpp
index 1b0e1f07f6..12bcd43076 100644
--- a/src/quick/items/qquickitemgrabresult.cpp
+++ b/src/quick/items/qquickitemgrabresult.cpp
@@ -47,6 +47,7 @@
#endif
#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlInfo>
#include <private/qquickpixmapcache_p.h>
#include <private/qquickitem_p.h>
@@ -74,7 +75,7 @@ public:
void ensureImageInCache() const {
if (url.isEmpty() && !image.isNull()) {
- url.setScheme(QStringLiteral("ItemGrabber"));
+ url.setScheme(QQuickPixmap::itemGrabberScheme);
url.setPath(QVariant::fromValue(item.data()).toString());
static uint counter = 0;
url.setFragment(QString::number(++counter));
@@ -184,13 +185,26 @@ QQuickItemGrabResult::QQuickItemGrabResult(QObject *parent)
/*!
* Saves the grab result as an image to \a fileName. Returns true
* if successful; otherwise returns false.
+ *
+ * \note In Qt versions prior to 5.9, this function is marked as non-\c{const}.
*/
-bool QQuickItemGrabResult::saveToFile(const QString &fileName)
+bool QQuickItemGrabResult::saveToFile(const QString &fileName) const
{
- Q_D(QQuickItemGrabResult);
+ Q_D(const QQuickItemGrabResult);
return d->image.save(fileName);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ * \overload
+ * \internal
+ */
+bool QQuickItemGrabResult::saveToFile(const QString &fileName)
+{
+ return qAsConst(*this).saveToFile(fileName);
+}
+#endif // < Qt 6
+
QUrl QQuickItemGrabResult::url() const
{
Q_D(const QQuickItemGrabResult);
@@ -266,17 +280,17 @@ QQuickItemGrabResult *QQuickItemGrabResultPrivate::create(QQuickItem *item, cons
size = QSize(item->width(), item->height());
if (size.width() < 1 || size.height() < 1) {
- qWarning("Item::grabToImage: item has invalid dimensions");
+ qmlWarning(item) << "grabToImage: item has invalid dimensions";
return 0;
}
if (!item->window()) {
- qWarning("Item::grabToImage: item is not attached to a window");
+ qmlWarning(item) << "grabToImage: item is not attached to a window";
return 0;
}
if (!item->window()->isVisible()) {
- qWarning("Item::grabToImage: item's window is not visible");
+ qmlWarning(item) << "grabToImage: item's window is not visible";
return 0;
}
@@ -364,12 +378,12 @@ bool QQuickItem::grabToImage(const QJSValue &callback, const QSize &targetSize)
{
QQmlEngine *engine = qmlEngine(this);
if (!engine) {
- qWarning("Item::grabToImage: no QML Engine");
+ qmlWarning(this) << "grabToImage: item has no QML engine";
return false;
}
if (!callback.isCallable()) {
- qWarning("Item::grabToImage: 'callback' is not a function");
+ qmlWarning(this) << "grabToImage: 'callback' is not a function";
return false;
}
@@ -378,12 +392,12 @@ bool QQuickItem::grabToImage(const QJSValue &callback, const QSize &targetSize)
size = QSize(width(), height());
if (size.width() < 1 || size.height() < 1) {
- qWarning("Item::grabToImage: item has invalid dimensions");
+ qmlWarning(this) << "grabToImage: item has invalid dimensions";
return false;
}
if (!window()) {
- qWarning("Item::grabToImage: item is not attached to a window");
+ qmlWarning(this) << "grabToImage: item is not attached to a window";
return false;
}
diff --git a/src/quick/items/qquickitemgrabresult.h b/src/quick/items/qquickitemgrabresult.h
index 42d71862de..30f8f0c2ef 100644
--- a/src/quick/items/qquickitemgrabresult.h
+++ b/src/quick/items/qquickitemgrabresult.h
@@ -64,10 +64,13 @@ public:
QImage image() const;
QUrl url() const;
- Q_INVOKABLE bool saveToFile(const QString &fileName);
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ Q_INVOKABLE bool saveToFile(const QString &fileName); // ### Qt 6: remove
+#endif
+ Q_INVOKABLE bool saveToFile(const QString &fileName) const;
protected:
- bool event(QEvent *);
+ bool event(QEvent *) override;
Q_SIGNALS:
void ready();
diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp
index 0296ebe88c..a8824de9c8 100644
--- a/src/quick/items/qquickitemsmodule.cpp
+++ b/src/quick/items/qquickitemsmodule.cpp
@@ -373,6 +373,18 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor)
#if QT_CONFIG(quick_shadereffect)
qmlRegisterType<QQuickBorderImageMesh>("QtQuick", 2, 8, "BorderImageMesh");
#endif
+
+ qmlRegisterType<QQuickFlickable, 9>(uri, 2, 9, "Flickable");
+ qmlRegisterType<QQuickMouseArea, 9>(uri, 2, 9, "MouseArea");
+ qmlRegisterType<QQuickText, 9>(uri, 2, 9, "Text");
+ qmlRegisterType<QQuickTextInput, 9>(uri, 2, 9, "TextInput");
+ qmlRegisterType<QQuickTouchPoint>(uri, 2, 9, "TouchPoint");
+ qRegisterMetaType<QPointingDeviceUniqueId>("QPointingDeviceUniqueId");
+ qmlRegisterUncreatableType<QPointingDeviceUniqueId>(uri, 2, 9, "PointingDeviceUniqueId", QQuickTouchPoint::tr("PointingDeviceUniqueId is only available via read-only properties"));
+#if QT_CONFIG(quick_positioners)
+ qmlRegisterUncreatableType<QQuickBasePositioner, 9>(uri, 2, 9, "Positioner",
+ QStringLiteral("Positioner is an abstract type that is only available as an attached property."));
+#endif
}
static void initResources()
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index 7f8b26f20b..a8bac633cc 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -380,8 +380,8 @@ void QQuickItemView::setDelegate(QQmlComponent *delegate)
int oldCount = dataModel->count();
dataModel->setDelegate(delegate);
if (isComponentComplete()) {
- for (int i = 0; i < d->visibleItems.count(); ++i)
- d->releaseItem(d->visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(d->visibleItems))
+ d->releaseItem(item);
d->visibleItems.clear();
d->releaseItem(d->currentItem);
d->currentItem = 0;
@@ -487,7 +487,7 @@ void QQuickItemView::setCacheBuffer(int b)
{
Q_D(QQuickItemView);
if (b < 0) {
- qmlInfo(this) << "Cannot set a negative cache buffer";
+ qmlWarning(this) << "Cannot set a negative cache buffer";
return;
}
@@ -935,21 +935,23 @@ void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode)
return;
applyPendingChanges();
- int idx = qMax(qMin(index, model->count()-1), 0);
+ const int modelCount = model->count();
+ int idx = qMax(qMin(index, modelCount - 1), 0);
- qreal pos = isContentFlowReversed() ? -position() - size() : position();
+ const auto viewSize = size();
+ qreal pos = isContentFlowReversed() ? -position() - viewSize : position();
FxViewItem *item = visibleItem(idx);
qreal maxExtent = calculatedMaxExtent();
if (!item) {
qreal itemPos = positionAt(idx);
changedVisibleIndex(idx);
// save the currently visible items in case any of them end up visible again
- QList<FxViewItem *> oldVisible = visibleItems;
+ const QList<FxViewItem *> oldVisible = visibleItems;
visibleItems.clear();
setPosition(qMin(itemPos, maxExtent));
// now release the reference to all the old visible items.
- for (int i = 0; i < oldVisible.count(); ++i)
- releaseItem(oldVisible.at(i));
+ for (FxViewItem *item : oldVisible)
+ releaseItem(item);
item = visibleItem(idx);
}
if (item) {
@@ -961,22 +963,22 @@ void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode)
pos -= headerSize();
break;
case QQuickItemView::Center:
- pos = itemPos - (size() - item->size())/2;
+ pos = itemPos - (viewSize - item->size())/2;
break;
case QQuickItemView::End:
- pos = itemPos - size() + item->size();
- if (footer && (index >= model->count() || hasStickyFooter()))
+ pos = itemPos - viewSize + item->size();
+ if (footer && (index >= modelCount || hasStickyFooter()))
pos += footerSize();
break;
case QQuickItemView::Visible:
- if (itemPos > pos + size())
- pos = itemPos - size() + item->size();
+ if (itemPos > pos + viewSize)
+ pos = itemPos - viewSize + item->size();
else if (item->endPosition() <= pos)
pos = itemPos;
break;
case QQuickItemView::Contain:
- if (item->endPosition() >= pos + size())
- pos = itemPos - size() + item->size();
+ if (item->endPosition() >= pos + viewSize)
+ pos = itemPos - viewSize + item->size();
if (itemPos < pos)
pos = itemPos;
break;
@@ -1025,28 +1027,27 @@ void QQuickItemView::positionViewAtEnd()
d->positionViewAtIndex(d->model->count(), End);
}
-int QQuickItemView::indexAt(qreal x, qreal y) const
+static FxViewItem * fxViewItemAtPosition(const QList<FxViewItem *> &items, qreal x, qreal y)
{
- Q_D(const QQuickItemView);
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- const FxViewItem *item = d->visibleItems.at(i);
+ for (FxViewItem *item : items) {
if (item->contains(x, y))
- return item->index;
+ return item;
}
+ return nullptr;
+}
- return -1;
+int QQuickItemView::indexAt(qreal x, qreal y) const
+{
+ Q_D(const QQuickItemView);
+ const FxViewItem *item = fxViewItemAtPosition(d->visibleItems, x, y);
+ return item ? item->index : -1;
}
QQuickItem *QQuickItemView::itemAt(qreal x, qreal y) const
{
Q_D(const QQuickItemView);
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- const FxViewItem *item = d->visibleItems.at(i);
- if (item->contains(x, y))
- return item->item;
- }
-
- return 0;
+ const FxViewItem *item = fxViewItemAtPosition(d->visibleItems, x, y);
+ return item ? item->item : nullptr;
}
void QQuickItemView::forceLayout()
@@ -1198,10 +1199,10 @@ void QQuickItemViewPrivate::checkVisible() const
void QQuickItemViewPrivate::showVisibleItems() const
{
qDebug() << "Visible items:";
- for (int i = 0; i < visibleItems.count(); ++i) {
- qDebug() << "\t" << visibleItems.at(i)->index
- << visibleItems.at(i)->item->objectName()
- << visibleItems.at(i)->position();
+ for (FxViewItem *item : visibleItems) {
+ qDebug() << "\t" << item->index
+ << item->item->objectName()
+ << item->position();
}
}
@@ -1645,8 +1646,7 @@ FxViewItem *QQuickItemViewPrivate::visibleItem(int modelIndex) const {
// that don't look at the view position and size
FxViewItem *QQuickItemViewPrivate::firstVisibleItem() const {
const qreal pos = isContentFlowReversed() ? -position()-size() : position();
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : visibleItems) {
if (item->index != -1 && item->endPosition() > pos)
return item;
}
@@ -1743,14 +1743,14 @@ void QQuickItemViewPrivate::clear()
currentChanges.reset();
timeline.clear();
- for (int i = 0; i < visibleItems.count(); ++i)
- releaseItem(visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(visibleItems))
+ releaseItem(item);
visibleItems.clear();
visibleIndex = 0;
- for (int i = 0; i < releasePendingTransition.count(); ++i) {
- releasePendingTransition.at(i)->releaseAfterTransition = false;
- releaseItem(releasePendingTransition.at(i));
+ for (FxViewItem *item : qAsConst(releasePendingTransition)) {
+ item->releaseAfterTransition = false;
+ releaseItem(item);
}
releasePendingTransition.clear();
@@ -1787,10 +1787,11 @@ void QQuickItemViewPrivate::animationFinished(QAbstractAnimationJob *)
void QQuickItemViewPrivate::refill()
{
qreal s = qMax(size(), qreal(0.));
+ const auto pos = position();
if (isContentFlowReversed())
- refill(-position()-displayMarginBeginning-s, -position()+displayMarginEnd);
+ refill(-pos - displayMarginBeginning-s, -pos + displayMarginEnd);
else
- refill(position()-displayMarginBeginning, position()+displayMarginEnd+s);
+ refill(pos - displayMarginBeginning, pos + displayMarginEnd+s);
}
void QQuickItemViewPrivate::refill(qreal from, qreal to)
@@ -1910,9 +1911,9 @@ void QQuickItemViewPrivate::layout()
forceLayout = false;
if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) {
- for (int i=0; i<visibleItems.count(); i++) {
- if (!visibleItems.at(i)->transitionScheduledOrRunning())
- visibleItems.at(i)->transitionNextReposition(transitioner, QQuickItemViewTransitioner::PopulateTransition, true);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
+ if (!item->transitionScheduledOrRunning())
+ item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::PopulateTransition, true);
}
}
@@ -2008,18 +2009,18 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
ChangeResult removalResult(prevViewPos);
int removedCount = 0;
- for (int i=0; i<removals.count(); i++) {
- itemCount -= removals[i].count;
- if (applyRemovalChange(removals[i], &removalResult, &removedCount))
+ for (const QQmlChangeSet::Change &r : removals) {
+ itemCount -= r.count;
+ if (applyRemovalChange(r, &removalResult, &removedCount))
visibleAffected = true;
- if (!visibleAffected && needsRefillForAddedOrRemovedIndex(removals[i].index))
+ if (!visibleAffected && needsRefillForAddedOrRemovedIndex(r.index))
visibleAffected = true;
const int correctedFirstVisibleIndex = prevFirstVisibleIndex - removalResult.countChangeBeforeVisible;
- if (correctedFirstVisibleIndex >= 0 && removals[i].index < correctedFirstVisibleIndex) {
- if (removals[i].index + removals[i].count < correctedFirstVisibleIndex)
- removalResult.countChangeBeforeVisible += removals[i].count;
+ if (correctedFirstVisibleIndex >= 0 && r.index < correctedFirstVisibleIndex) {
+ if (r.index + r.count < correctedFirstVisibleIndex)
+ removalResult.countChangeBeforeVisible += r.count;
else
- removalResult.countChangeBeforeVisible += (correctedFirstVisibleIndex - removals[i].index);
+ removalResult.countChangeBeforeVisible += (correctedFirstVisibleIndex - r.index);
}
}
if (runDelayedRemoveTransition) {
@@ -2066,23 +2067,23 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult
}
itemCount += insertions[i].count;
}
- for (int i=0; i<newItems.count(); i++) {
- if (newItems.at(i)->attached)
- newItems.at(i)->attached->emitAdd();
+ for (FxViewItem *item : qAsConst(newItems)) {
+ if (item->attached)
+ item->attached->emitAdd();
}
// for each item that was moved directly into the view as a result of a move(),
// find the index it was moved from in order to set its initial position, so that we
// can transition it from this "original" position to its new position in the view
if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) {
- for (int i=0; i<movingIntoView.count(); i++) {
- int fromIndex = findMoveKeyIndex(movingIntoView.at(i).moveKey, removals);
+ for (const MovedItem &m : qAsConst(movingIntoView)) {
+ int fromIndex = findMoveKeyIndex(m.moveKey, removals);
if (fromIndex >= 0) {
if (prevFirstVisibleIndex >= 0 && fromIndex < prevFirstVisibleIndex)
- repositionItemAt(movingIntoView.at(i).item, fromIndex, -totalInsertionResult->sizeChangesAfterVisiblePos);
+ repositionItemAt(m.item, fromIndex, -totalInsertionResult->sizeChangesAfterVisiblePos);
else
- repositionItemAt(movingIntoView.at(i).item, fromIndex, totalInsertionResult->sizeChangesAfterVisiblePos);
- movingIntoView.at(i).item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, true);
+ repositionItemAt(m.item, fromIndex, totalInsertionResult->sizeChangesAfterVisiblePos);
+ m.item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::MoveTransition, true);
}
}
}
@@ -2343,7 +2344,7 @@ FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, bool asynchronous)
if (!delegateValidated) {
delegateValidated = true;
QObject* delegate = q->delegate();
- qmlInfo(delegate ? delegate : q) << QQuickItemView::tr("Delegate must be of Item type");
+ qmlWarning(delegate ? delegate : q) << QQuickItemView::tr("Delegate must be of Item type");
}
}
inRequest = false;
@@ -2428,14 +2429,14 @@ bool QQuickItemViewPrivate::releaseItem(FxViewItem *item)
return flags != QQmlInstanceModel::Referenced;
}
-QQuickItem *QQuickItemViewPrivate::createHighlightItem()
+QQuickItem *QQuickItemViewPrivate::createHighlightItem() const
{
return createComponentItem(highlightComponent, 0.0, true);
}
-QQuickItem *QQuickItemViewPrivate::createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault)
+QQuickItem *QQuickItemViewPrivate::createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault) const
{
- Q_Q(QQuickItemView);
+ Q_Q(const QQuickItemView);
QQuickItem *item = 0;
if (component) {
diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h
index c289ace408..b38bc6174f 100644
--- a/src/quick/items/qquickitemview_p.h
+++ b/src/quick/items/qquickitemview_p.h
@@ -232,10 +232,10 @@ public:
Q_INVOKABLE void positionViewAtEnd();
Q_REVISION(1) Q_INVOKABLE void forceLayout();
- void setContentX(qreal pos) Q_DECL_OVERRIDE;
- void setContentY(qreal pos) Q_DECL_OVERRIDE;
- qreal originX() const Q_DECL_OVERRIDE;
- qreal originY() const Q_DECL_OVERRIDE;
+ void setContentX(qreal pos) override;
+ void setContentY(qreal pos) override;
+ qreal originX() const override;
+ qreal originY() const override;
Q_SIGNALS:
void modelChanged();
@@ -277,13 +277,13 @@ Q_SIGNALS:
void highlightMoveDurationChanged();
protected:
- void updatePolish() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- qreal minYExtent() const Q_DECL_OVERRIDE;
- qreal maxYExtent() const Q_DECL_OVERRIDE;
- qreal minXExtent() const Q_DECL_OVERRIDE;
- qreal maxXExtent() const Q_DECL_OVERRIDE;
+ void updatePolish() override;
+ void componentComplete() override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+ qreal minYExtent() const override;
+ qreal maxYExtent() const override;
+ qreal minXExtent() const override;
+ qreal maxXExtent() const override;
protected Q_SLOTS:
void destroyRemoved();
@@ -316,7 +316,7 @@ public:
: QObject(parent), m_isCurrent(false), m_delayRemove(false) {}
~QQuickItemViewAttached() {}
- QQuickItemView *view() { return m_view; }
+ QQuickItemView *view() const { return m_view; }
void setView(QQuickItemView *view) {
if (view != m_view) {
m_view = view;
diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h
index 62851c9a89..3087682ac7 100644
--- a/src/quick/items/qquickitemview_p_p.h
+++ b/src/quick/items/qquickitemview_p_p.h
@@ -201,16 +201,16 @@ public:
void regenerate(bool orientationChanged=false);
void layout();
- virtual void animationFinished(QAbstractAnimationJob *) Q_DECL_OVERRIDE;
+ virtual void animationFinished(QAbstractAnimationJob *) override;
void refill();
void refill(qreal from, qreal to);
- void mirrorChange() Q_DECL_OVERRIDE;
+ void mirrorChange() override;
FxViewItem *createItem(int modelIndex, bool asynchronous = false);
virtual bool releaseItem(FxViewItem *item);
- QQuickItem *createHighlightItem();
- QQuickItem *createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault = false);
+ QQuickItem *createHighlightItem() const;
+ QQuickItem *createComponentItem(QQmlComponent *component, qreal zValue, bool createDefault = false) const;
void updateCurrent(int modelIndex);
void updateTrackedItem();
@@ -236,7 +236,7 @@ public:
void prepareVisibleItemTransitions();
void prepareRemoveTransitions(QHash<QQmlChangeSet::MoveKey, FxViewItem *> *removedItems);
bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds);
- void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) Q_DECL_OVERRIDE;
+ void viewItemTransitionFinished(QQuickItemViewTransitionableItem *item) override;
int findMoveKeyIndex(QQmlChangeSet::MoveKey key, const QVector<QQmlChangeSet::Change> &changes) const;
@@ -348,8 +348,8 @@ protected:
virtual bool showFooterForIndex(int index) const = 0;
virtual void updateHeader() = 0;
virtual void updateFooter() = 0;
- virtual bool hasStickyHeader() const { return false; };
- virtual bool hasStickyFooter() const { return false; };
+ virtual bool hasStickyHeader() const { return false; }
+ virtual bool hasStickyFooter() const { return false; }
virtual void createHighlight() = 0;
virtual void updateHighlight() = 0;
@@ -382,7 +382,7 @@ protected:
virtual void updateSectionCriteria() {}
virtual void updateSections() {}
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override;
};
diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp
index 6d2421c3df..700c4cc620 100644
--- a/src/quick/items/qquickitemviewtransition.cpp
+++ b/src/quick/items/qquickitemviewtransition.cpp
@@ -64,7 +64,7 @@ public:
bool *m_wasDeleted;
protected:
- void finished() Q_DECL_OVERRIDE;
+ void finished() override;
};
@@ -246,7 +246,7 @@ void QQuickItemViewTransitioner::resetTargetLists()
moveTransitionTargets.clear();
}
-QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget)
+QQuickTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const
{
if (type == QQuickItemViewTransitioner::NoTransition)
return 0;
diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h
index ff0e82ac7b..3d2f5361b1 100644
--- a/src/quick/items/qquickitemviewtransition_p.h
+++ b/src/quick/items/qquickitemviewtransition_p.h
@@ -97,7 +97,7 @@ public:
void addToTargetLists(QQuickItemViewTransitioner::TransitionType type, QQuickItemViewTransitionableItem *item, int index);
void resetTargetLists();
- QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget);
+ QQuickTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const;
const QList<int> &targetIndexes(QQuickItemViewTransitioner::TransitionType type) const;
const QList<QObject *> &targetItems(QQuickItemViewTransitioner::TransitionType type) const;
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index f89a995e76..0351077f20 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -65,51 +65,51 @@ class QQuickListViewPrivate : public QQuickItemViewPrivate
public:
static QQuickListViewPrivate* get(QQuickListView *item) { return item->d_func(); }
- Qt::Orientation layoutOrientation() const Q_DECL_OVERRIDE;
- bool isContentFlowReversed() const Q_DECL_OVERRIDE;
+ Qt::Orientation layoutOrientation() const override;
+ bool isContentFlowReversed() const override;
bool isRightToLeft() const;
bool isBottomToTop() const;
- qreal positionAt(int index) const Q_DECL_OVERRIDE;
- qreal endPositionAt(int index) const Q_DECL_OVERRIDE;
- qreal originPosition() const Q_DECL_OVERRIDE;
- qreal lastPosition() const Q_DECL_OVERRIDE;
+ qreal positionAt(int index) const override;
+ qreal endPositionAt(int index) const override;
+ qreal originPosition() const override;
+ qreal lastPosition() const override;
FxViewItem *itemBefore(int modelIndex) const;
QString sectionAt(int modelIndex);
qreal snapPosAt(qreal pos);
FxViewItem *snapItemAt(qreal pos);
- void init() Q_DECL_OVERRIDE;
- void clear() Q_DECL_OVERRIDE;
+ void init() override;
+ void clear() override;
- bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) Q_DECL_OVERRIDE;
- bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) Q_DECL_OVERRIDE;
- void visibleItemsChanged() Q_DECL_OVERRIDE;
+ bool addVisibleItems(qreal fillFrom, qreal fillTo, qreal bufferFrom, qreal bufferTo, bool doBuffer) override;
+ bool removeNonVisibleItems(qreal bufferFrom, qreal bufferTo) override;
+ void visibleItemsChanged() override;
void removeItem(FxViewItem *item);
- FxViewItem *newViewItem(int index, QQuickItem *item) Q_DECL_OVERRIDE;
- void initializeViewItem(FxViewItem *item) Q_DECL_OVERRIDE;
- bool releaseItem(FxViewItem *item) Q_DECL_OVERRIDE;
- void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) Q_DECL_OVERRIDE;
- void repositionPackageItemAt(QQuickItem *item, int index) Q_DECL_OVERRIDE;
- void resetFirstItemPosition(qreal pos = 0.0) Q_DECL_OVERRIDE;
- void adjustFirstItem(qreal forwards, qreal backwards, int) Q_DECL_OVERRIDE;
- void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) Q_DECL_OVERRIDE;
+ FxViewItem *newViewItem(int index, QQuickItem *item) override;
+ void initializeViewItem(FxViewItem *item) override;
+ bool releaseItem(FxViewItem *item) override;
+ void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer) override;
+ void repositionPackageItemAt(QQuickItem *item, int index) override;
+ void resetFirstItemPosition(qreal pos = 0.0) override;
+ void adjustFirstItem(qreal forwards, qreal backwards, int) override;
+ void updateSizeChangesBeforeVisiblePos(FxViewItem *item, ChangeResult *removeResult) override;
- void createHighlight() Q_DECL_OVERRIDE;
- void updateHighlight() Q_DECL_OVERRIDE;
- void resetHighlightPosition() Q_DECL_OVERRIDE;
+ void createHighlight() override;
+ void updateHighlight() override;
+ void resetHighlightPosition() override;
- void setPosition(qreal pos) Q_DECL_OVERRIDE;
- void layoutVisibleItems(int fromModelIndex = 0) Q_DECL_OVERRIDE;
+ void setPosition(qreal pos) override;
+ void layoutVisibleItems(int fromModelIndex = 0) override;
- bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) Q_DECL_OVERRIDE;
- void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) Q_DECL_OVERRIDE;
+ bool applyInsertionChange(const QQmlChangeSet::Change &insert, ChangeResult *changeResult, QList<FxViewItem *> *addedItems, QList<MovedItem> *movingIntoView) override;
+ void translateAndTransitionItemsAfter(int afterIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) override;
- void updateSectionCriteria() Q_DECL_OVERRIDE;
- void updateSections() Q_DECL_OVERRIDE;
+ void updateSectionCriteria() override;
+ void updateSections() override;
QQuickItem *getSectionItem(const QString &section);
void releaseSectionItem(QQuickItem *item);
void releaseSectionItems();
@@ -117,25 +117,25 @@ public:
void updateCurrentSection();
void updateStickySections();
- qreal headerSize() const Q_DECL_OVERRIDE;
- qreal footerSize() const Q_DECL_OVERRIDE;
- bool showHeaderForIndex(int index) const Q_DECL_OVERRIDE;
- bool showFooterForIndex(int index) const Q_DECL_OVERRIDE;
- void updateHeader() Q_DECL_OVERRIDE;
- void updateFooter() Q_DECL_OVERRIDE;
- bool hasStickyHeader() const Q_DECL_OVERRIDE;
- bool hasStickyFooter() const Q_DECL_OVERRIDE;
+ qreal headerSize() const override;
+ qreal footerSize() const override;
+ bool showHeaderForIndex(int index) const override;
+ bool showFooterForIndex(int index) const override;
+ void updateHeader() override;
+ void updateFooter() override;
+ bool hasStickyHeader() const override;
+ bool hasStickyFooter() const override;
- void changedVisibleIndex(int newIndex) Q_DECL_OVERRIDE;
- void initializeCurrentItem() Q_DECL_OVERRIDE;
+ void changedVisibleIndex(int newIndex) override;
+ void initializeCurrentItem() override;
void updateAverage();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void fixupPosition() Q_DECL_OVERRIDE;
- void fixup(AxisData &data, qreal minExtent, qreal maxExtent) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override;
+ void fixupPosition() override;
+ void fixup(AxisData &data, qreal minExtent, qreal maxExtent) override;
bool flick(QQuickItemViewPrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize,
- QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) Q_DECL_OVERRIDE;
+ QQuickTimeLineCallback::Callback fixupCallback, qreal velocity) override;
QQuickListView::Orientation orient;
qreal visiblePos;
@@ -263,7 +263,7 @@ public:
static_cast<QQuickListViewAttached*>(attached)->m_sectionItem = s;
}
- qreal position() const Q_DECL_OVERRIDE {
+ qreal position() const override {
if (section()) {
if (view->orientation() == QQuickListView::Vertical)
return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop ? -section()->height()-section()->y() : section()->y());
@@ -279,7 +279,7 @@ public:
else
return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -itemWidth()-itemX() : itemX());
}
- qreal size() const Q_DECL_OVERRIDE {
+ qreal size() const override {
if (section())
return (view->orientation() == QQuickListView::Vertical ? itemHeight()+section()->height() : itemWidth()+section()->width());
else
@@ -288,12 +288,12 @@ public:
qreal itemSize() const {
return (view->orientation() == QQuickListView::Vertical ? itemHeight() : itemWidth());
}
- qreal sectionSize() const Q_DECL_OVERRIDE {
+ qreal sectionSize() const override {
if (section())
return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width());
return 0.0;
}
- qreal endPosition() const Q_DECL_OVERRIDE {
+ qreal endPosition() const override {
if (view->orientation() == QQuickListView::Vertical) {
return (view->verticalLayoutDirection() == QQuickItemView::BottomToTop
? -itemY()
@@ -327,7 +327,7 @@ public:
else
item->setWidth(size);
}
- bool contains(qreal x, qreal y) const Q_DECL_OVERRIDE {
+ bool contains(qreal x, qreal y) const override {
return (x >= itemX() && x < itemX() + itemWidth() &&
y >= itemY() && y < itemY() + itemHeight());
}
@@ -438,11 +438,12 @@ qreal QQuickListViewPrivate::lastPosition() const
int invisibleCount = INT_MIN;
int delayRemovedCount = 0;
for (int i = visibleItems.count()-1; i >= 0; --i) {
- if (visibleItems.at(i)->index != -1) {
+ FxViewItem *item = visibleItems.at(i);
+ if (item->index != -1) {
// Find the invisible count after the last visible item with known index
- invisibleCount = model->count() - (visibleItems.at(i)->index + 1 + delayRemovedCount);
+ invisibleCount = model->count() - (item->index + 1 + delayRemovedCount);
break;
- } else if (visibleItems.at(i)->attached->delayRemove()) {
+ } else if (item->attached->delayRemove()) {
++delayRemovedCount;
}
}
@@ -530,8 +531,7 @@ FxViewItem *QQuickListViewPrivate::snapItemAt(qreal pos)
{
FxViewItem *snapItem = 0;
qreal prevItemSize = 0;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
if (item->index == -1)
continue;
qreal itemTop = item->position();
@@ -660,8 +660,8 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, qreal
int newModelIdx = qBound(0, modelIndex + count, model->count());
count = newModelIdx - modelIndex;
if (count) {
- for (int i = 0; i < visibleItems.count(); ++i)
- releaseItem(visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(visibleItems))
+ releaseItem(item);
visibleItems.clear();
modelIndex = newModelIdx;
visibleIndex = modelIndex;
@@ -1008,8 +1008,8 @@ void QQuickListViewPrivate::releaseSectionItem(QQuickItem *item)
void QQuickListViewPrivate::releaseSectionItems()
{
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(visibleItems)) {
+ FxListItemSG *listItem = static_cast<FxListItemSG *>(item);
if (listItem->section()) {
qreal pos = listItem->position();
releaseSectionItem(listItem->section());
@@ -1168,16 +1168,15 @@ void QQuickListViewPrivate::updateSections()
QQuickListViewAttached *prevAtt = 0;
int prevIdx = -1;
int idx = -1;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
QQuickListViewAttached *attached = static_cast<QQuickListViewAttached*>(item->attached);
attached->setPrevSection(prevSection);
- if (visibleItems.at(i)->index != -1) {
- QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property());
+ if (item->index != -1) {
+ QString propValue = model->stringValue(item->index, sectionCriteria->property());
attached->setSection(sectionCriteria->sectionString(propValue));
- idx = visibleItems.at(i)->index;
+ idx = item->index;
}
- updateInlineSection(static_cast<FxListItemSG*>(visibleItems.at(i)));
+ updateInlineSection(static_cast<FxListItemSG*>(item));
if (prevAtt)
prevAtt->setNextSection(sectionAt(prevIdx+1));
prevSection = attached->section();
@@ -1210,9 +1209,12 @@ void QQuickListViewPrivate::updateCurrentSection()
qreal startPos = hasStickyHeader() ? header->endPosition() : viewPos;
int index = 0;
int modelIndex = visibleIndex;
- while (index < visibleItems.count() && visibleItems.at(index)->endPosition() <= startPos) {
- if (visibleItems.at(index)->index != -1)
- modelIndex = visibleItems.at(index)->index;
+ while (index < visibleItems.count()) {
+ FxViewItem *item = visibleItems.at(index);
+ if (item->endPosition() > startPos)
+ break;
+ if (item->index != -1)
+ modelIndex = item->index;
++index;
}
@@ -1236,10 +1238,13 @@ void QQuickListViewPrivate::updateCurrentSection()
qreal endPos = hasStickyFooter() ? footer->position() : viewPos + size();
if (nextSectionItem && !inlineSections)
endPos -= orient == QQuickListView::Vertical ? nextSectionItem->height() : nextSectionItem->width();
- while (index < visibleItems.count() && static_cast<FxListItemSG*>(visibleItems.at(index))->itemPosition() < endPos) {
- if (visibleItems.at(index)->index != -1)
- modelIndex = visibleItems.at(index)->index;
- lastSection = visibleItems.at(index)->attached->section();
+ while (index < visibleItems.count()) {
+ FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(index));
+ if (listItem->itemPosition() >= endPos)
+ break;
+ if (listItem->index != -1)
+ modelIndex = listItem->index;
+ lastSection = listItem->attached->section();
++index;
}
@@ -1288,8 +1293,8 @@ void QQuickListViewPrivate::updateAverage()
if (!visibleItems.count())
return;
qreal sum = 0.0;
- for (int i = 0; i < visibleItems.count(); ++i)
- sum += visibleItems.at(i)->size();
+ for (FxViewItem *item : qAsConst(visibleItems))
+ sum += item->size();
averageSize = qRound(sum / visibleItems.count());
}
@@ -1462,9 +1467,15 @@ void QQuickListViewPrivate::fixupPosition()
void QQuickListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent)
{
- if ((orient == QQuickListView::Horizontal && &data == &vData)
- || (orient == QQuickListView::Vertical && &data == &hData))
+ if (orient == QQuickListView::Horizontal && &data == &vData) {
+ if (flickableDirection != QQuickFlickable::HorizontalFlick)
+ QQuickItemViewPrivate::fixup(data, minExtent, maxExtent);
+ return;
+ } else if (orient == QQuickListView::Vertical && &data == &hData) {
+ if (flickableDirection != QQuickFlickable::VerticalFlick)
+ QQuickItemViewPrivate::fixup(data, minExtent, maxExtent);
return;
+ }
correctFlick = false;
fixupMode = moveReason == Mouse ? fixupMode : Immediate;
@@ -1813,6 +1824,19 @@ bool QQuickListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExte
\image listview-layout-righttoleft.png
\endtable
+ \section1 Flickable Direction
+
+ By default, a vertical ListView sets \l {Flickable::}{flickableDirection} to \e Flickable.Vertical,
+ and a horizontal ListView sets it to \e Flickable.Horizontal. Furthermore, a vertical ListView only
+ calculates (estimates) the \l {Flickable::}{contentHeight}, and a horizontal ListView only calculates
+ the \l {Flickable::}{contentWidth}. The other dimension is set to \e -1.
+
+ Since Qt 5.9 (Qt Quick 2.9), it is possible to make a ListView that can be flicked to both directions.
+ In order to do this, the \l {Flickable::}{flickableDirection} can be set to \e Flickable.AutoFlickDirection
+ or \e Flickable.AutoFlickIfNeeded, and the desired \e contentWidth or \e contentHeight must be provided.
+
+ \snippet qml/listview/listview.qml flickBothDirections
+
\sa {QML Data Models}, GridView, PathView, {Qt Quick Examples - Views}
*/
QQuickListView::QQuickListView(QQuickItem *parent)
@@ -2099,6 +2123,8 @@ void QQuickListView::setSpacing(qreal spacing)
\li Vertical orientation:
\image listview-highlight.png
\endtable
+
+ \sa {Flickable Direction}
*/
QQuickListView::Orientation QQuickListView::orientation() const
{
@@ -2112,12 +2138,18 @@ void QQuickListView::setOrientation(QQuickListView::Orientation orientation)
if (d->orient != orientation) {
d->orient = orientation;
if (d->orient == Vertical) {
- setContentWidth(-1);
- setFlickableDirection(VerticalFlick);
+ if (d->flickableDirection == HorizontalFlick) {
+ setFlickableDirection(VerticalFlick);
+ if (isComponentComplete())
+ setContentWidth(-1);
+ }
setContentX(0);
} else {
- setContentHeight(-1);
- setFlickableDirection(HorizontalFlick);
+ if (d->flickableDirection == VerticalFlick) {
+ setFlickableDirection(HorizontalFlick);
+ if (isComponentComplete())
+ setContentHeight(-1);
+ }
setContentY(0);
}
d->regenerate(true);
@@ -2899,8 +2931,7 @@ void QQuickListView::viewportMoved(Qt::Orientations orient)
// Set visibility of items to eliminate cost of items outside the visible area.
qreal from = d->isContentFlowReversed() ? -d->position()-d->displayMarginBeginning-d->size() : d->position()-d->displayMarginBeginning;
qreal to = d->isContentFlowReversed() ? -d->position()+d->displayMarginEnd : d->position()+d->size()+d->displayMarginEnd;
- for (int i = 0; i < d->visibleItems.count(); ++i) {
- FxViewItem *item = static_cast<FxListItemSG*>(d->visibleItems.at(i));
+ for (FxViewItem *item : qAsConst(d->visibleItems)) {
if (item->item)
QQuickItemPrivate::get(item->item)->setCulled(item->endPosition() < from || item->position() > to);
}
@@ -3042,6 +3073,21 @@ void QQuickListView::initItem(int index, QObject *object)
}
}
+qreal QQuickListView::maxYExtent() const
+{
+ Q_D(const QQuickListView);
+ if (d->layoutOrientation() == Qt::Horizontal && d->flickableDirection != HorizontalFlick)
+ return QQuickFlickable::maxYExtent();
+ return QQuickItemView::maxYExtent();
+}
+
+qreal QQuickListView::maxXExtent() const
+{
+ Q_D(const QQuickListView);
+ if (d->layoutOrientation() == Qt::Vertical && d->flickableDirection != VerticalFlick)
+ return QQuickFlickable::maxXExtent();
+ return QQuickItemView::maxXExtent();
+}
/*!
\qmlmethod QtQuick::ListView::incrementCurrentIndex()
@@ -3120,8 +3166,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
if (modelIndex < visibleIndex) {
// Insert before visible items
visibleIndex += count;
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex)
item->index += count;
}
@@ -3138,8 +3183,7 @@ bool QQuickListViewPrivate::applyInsertionChange(const QQmlChangeSet::Change &ch
}
// Update the indexes of the following visible items.
- for (int i = 0; i < visibleItems.count(); ++i) {
- FxViewItem *item = visibleItems.at(i);
+ for (FxViewItem *item : qAsConst(visibleItems)) {
if (item->index != -1 && item->index >= modelIndex) {
item->index += count;
if (change.isMove())
@@ -3281,8 +3325,10 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
qreal sizeRemoved = -removalResult.sizeChangesAfterVisiblePos
- (removalResult.countChangeAfterVisibleItems * (averageSize + spacing));
- for (int i=markerItemIndex+1; i<visibleItems.count() && visibleItems.at(i)->position() < viewEndPos; i++) {
+ for (int i=markerItemIndex+1; i<visibleItems.count(); i++) {
FxListItemSG *listItem = static_cast<FxListItemSG *>(visibleItems.at(i));
+ if (listItem->position() >= viewEndPos)
+ break;
if (!listItem->transitionScheduledOrRunning()) {
qreal pos = listItem->position();
listItem->setPosition(pos - sizeRemoved);
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 8d0ad7f618..f8db0f0f8f 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -88,7 +88,7 @@ public:
enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
Q_ENUM(LabelPositioning)
- int labelPositioning() { return m_labelPositioning; }
+ int labelPositioning() const { return m_labelPositioning; }
void setLabelPositioning(int pos);
Q_SIGNALS:
@@ -146,7 +146,7 @@ public:
QQuickViewSection *sectionCriteria();
QString currentSection() const;
- void setHighlightFollowsCurrentItem(bool) Q_DECL_OVERRIDE;
+ void setHighlightFollowsCurrentItem(bool) override;
qreal highlightMoveVelocity() const;
void setHighlightMoveVelocity(qreal);
@@ -157,7 +157,7 @@ public:
int highlightResizeDuration() const;
void setHighlightResizeDuration(int);
- void setHighlightMoveDuration(int) Q_DECL_OVERRIDE;
+ void setHighlightMoveDuration(int) override;
enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
Q_ENUM(SnapMode)
@@ -192,10 +192,12 @@ Q_SIGNALS:
Q_REVISION(2) void footerPositioningChanged();
protected:
- void viewportMoved(Qt::Orientations orient) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry) Q_DECL_OVERRIDE;
- void initItem(int index, QObject *item) Q_DECL_OVERRIDE;
+ void viewportMoved(Qt::Orientations orient) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry) override;
+ void initItem(int index, QObject *item) override;
+ qreal maxYExtent() const override;
+ qreal maxXExtent() const override;
};
class QQuickListViewAttached : public QQuickItemViewAttached
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index eeec562e3c..5d5934bbd2 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -971,7 +971,7 @@ QV4::ReturnedValue QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Funct
QV4::ScopedValue v(scope, (*args)[1]);
if (!v->isObject() || v->as<QV4::ArrayObject>()) {
*error = true;
- qmlInfo(loader) << QQuickLoader::tr("setSource: value is not an object");
+ qmlWarning(loader) << QQuickLoader::tr("setSource: value is not an object");
} else {
*error = false;
valuemap = v;
diff --git a/src/quick/items/qquickloader_p_p.h b/src/quick/items/qquickloader_p_p.h
index a1e97b97d8..9b6267e011 100644
--- a/src/quick/items/qquickloader_p_p.h
+++ b/src/quick/items/qquickloader_p_p.h
@@ -94,7 +94,7 @@ public:
void incubatorStateChanged(QQmlIncubator::Status status);
void setInitialState(QObject *o);
void disposeInitialPropertyValues();
- QUrl resolveSourceUrl(QQmlV4Function *args);
+ static QUrl resolveSourceUrl(QQmlV4Function *args);
QV4::ReturnedValue extractInitialPropertyValues(QQmlV4Function *args, QObject *loader, bool *error);
qreal getImplicitWidth() const Q_DECL_OVERRIDE;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 4dcefc700d..c662efe40e 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -60,7 +60,8 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE)
QQuickMouseAreaPrivate::QQuickMouseAreaPrivate()
: enabled(true), scrollGestureEnabled(true), hovered(false), longPress(false),
moved(false), stealMouse(false), doubleClick(false), preventStealing(false),
- propagateComposedEvents(false), overThreshold(false), pressed(0)
+ propagateComposedEvents(false), overThreshold(false), pressed(0),
+ pressAndHoldInterval(-1)
#if QT_CONFIG(draganddrop)
, drag(0)
#endif
@@ -205,6 +206,9 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i
the proxied item. When disabled, the mouse area becomes transparent to
mouse events.
+ MouseArea is an invisible Item, but it has a visible property.
+ When set to false, the mouse area becomes transparent to mouse events.
+
The \l pressed read-only property indicates whether or not the user is
holding down a mouse button over the mouse area. This property is often
used in bindings between properties in a user interface. The containsMouse
@@ -688,7 +692,7 @@ void QQuickMouseArea::mousePressEvent(QMouseEvent *event)
setKeepMouseGrab(d->stealMouse);
event->setAccepted(setPressed(event->button(), true, event->source()));
if (event->isAccepted())
- d->pressAndHoldTimer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), this);
+ d->pressAndHoldTimer.start(pressAndHoldInterval(), this);
}
}
@@ -1306,6 +1310,48 @@ void QQuickMouseArea::setCursorShape(Qt::CursorShape shape)
#endif
+
+/*!
+ \qmlproperty int QtQuick::MouseArea::pressAndHoldInterval
+ \since 5.9
+
+ This property overrides the elapsed time in milliseconds before
+ \c pressAndHold is emitted.
+
+ If not explicitly set -- or after reset -- the value follows
+ \c QStyleHints::mousePressAndHoldInterval.
+
+ Typically it's sufficient to set this property globally using the
+ application style hint. This property should be used when varying intervals
+ are needed for certain MouseAreas.
+
+ \sa pressAndHold
+*/
+int QQuickMouseArea::pressAndHoldInterval() const
+{
+ Q_D(const QQuickMouseArea);
+ return d->pressAndHoldInterval > -1 ?
+ d->pressAndHoldInterval : QGuiApplication::styleHints()->mousePressAndHoldInterval();
+}
+
+void QQuickMouseArea::setPressAndHoldInterval(int interval)
+{
+ Q_D(QQuickMouseArea);
+ if (interval != d->pressAndHoldInterval) {
+ d->pressAndHoldInterval = interval;
+ emit pressAndHoldIntervalChanged();
+ }
+}
+
+void QQuickMouseArea::resetPressAndHoldInterval()
+{
+ Q_D(QQuickMouseArea);
+ if (d->pressAndHoldInterval > -1) {
+ d->pressAndHoldInterval = -1;
+ emit pressAndHoldIntervalChanged();
+ }
+}
+
/*!
\qmlpropertygroup QtQuick::MouseArea::drag
\qmlproperty Item QtQuick::MouseArea::drag.target
diff --git a/src/quick/items/qquickmousearea_p.h b/src/quick/items/qquickmousearea_p.h
index d90c8e1baa..ee166a2082 100644
--- a/src/quick/items/qquickmousearea_p.h
+++ b/src/quick/items/qquickmousearea_p.h
@@ -84,6 +84,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickMouseArea : public QQuickItem
Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape RESET unsetCursor NOTIFY cursorShapeChanged)
#endif
Q_PROPERTY(bool containsPress READ containsPress NOTIFY containsPressChanged REVISION 1)
+ Q_PROPERTY(int pressAndHoldInterval READ pressAndHoldInterval WRITE setPressAndHoldInterval NOTIFY pressAndHoldIntervalChanged RESET resetPressAndHoldInterval REVISION 9)
public:
QQuickMouseArea(QQuickItem *parent=0);
@@ -125,6 +126,10 @@ public:
void setCursorShape(Qt::CursorShape shape);
#endif
+ int pressAndHoldInterval() const;
+ void setPressAndHoldInterval(int interval);
+ void resetPressAndHoldInterval();
+
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
@@ -152,6 +157,7 @@ Q_SIGNALS:
void exited();
void canceled();
Q_REVISION(1) void containsPressChanged();
+ Q_REVISION(9) void pressAndHoldIntervalChanged();
protected:
void setHovered(bool);
diff --git a/src/quick/items/qquickmousearea_p_p.h b/src/quick/items/qquickmousearea_p_p.h
index 456b1866a3..2fa5f7cd44 100644
--- a/src/quick/items/qquickmousearea_p_p.h
+++ b/src/quick/items/qquickmousearea_p_p.h
@@ -95,6 +95,7 @@ public:
bool propagateComposedEvents : 1;
bool overThreshold : 1;
Qt::MouseButtons pressed;
+ int pressAndHoldInterval;
#if QT_CONFIG(draganddrop)
QQuickDrag *drag;
#endif
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index 706980cd13..62119effb2 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -60,6 +60,8 @@ DEFINE_BOOL_CONFIG_OPTION(qmlVisualTouchDebugging, QML_VISUAL_TOUCH_DEBUGGING)
The TouchPoint type contains information about a touch point, such as the current
position, pressure, and area.
+
+ \image touchpoint-metrics.png
*/
/*!
@@ -101,16 +103,29 @@ void QQuickTouchPoint::setY(qreal y)
}
/*!
+ \qmlproperty size QtQuick::TouchPoint::ellipseDiameters
+ \since 5.9
+
+ This property holds the major and minor axes of the ellipse representing
+ the covered area of the touch point.
+*/
+void QQuickTouchPoint::setEllipseDiameters(const QSizeF &d)
+{
+ if (_ellipseDiameters == d)
+ return;
+ _ellipseDiameters = d;
+ emit ellipseDiametersChanged();
+}
+
+/*!
\qmlproperty real QtQuick::TouchPoint::pressure
\qmlproperty vector2d QtQuick::TouchPoint::velocity
- \qmlproperty rectangle QtQuick::TouchPoint::area
These properties hold additional information about the current state of the touch point.
\list
\li \c pressure is a value in the range of 0.0 to 1.0.
\li \c velocity is a vector with magnitude reported in pixels per second.
- \li \c area is a rectangle covering the area of the touch point, centered on the current position of the touch point.
\endlist
Not all touch devices support velocity. If velocity is not supported, it will be reported
@@ -124,6 +139,26 @@ void QQuickTouchPoint::setPressure(qreal pressure)
emit pressureChanged();
}
+/*!
+ \qmlproperty real QtQuick::TouchPoint::rotation
+ \since 5.9
+
+ This property holds the angular orientation of this touch point. The return
+ value is in degrees, where zero (the default) indicates the finger or token
+ is pointing upwards, a negative angle means it's rotated to the left, and a
+ positive angle means it's rotated to the right. Most touchscreens do not
+ detect rotation, so zero is the most common value.
+
+ \sa QTouchEvent::TouchPoint::rotation()
+*/
+void QQuickTouchPoint::setRotation(qreal r)
+{
+ if (_rotation == r)
+ return;
+ _rotation = r;
+ emit rotationChanged();
+}
+
void QQuickTouchPoint::setVelocity(const QVector2D &velocity)
{
if (_velocity == velocity)
@@ -132,6 +167,18 @@ void QQuickTouchPoint::setVelocity(const QVector2D &velocity)
emit velocityChanged();
}
+/*!
+ \deprecated
+ \qmlproperty rectangle QtQuick::TouchPoint::area
+
+ A rectangle covering the area of the touch point, centered on the current
+ position of the touch point.
+
+ It is deprecated because a touch point is more correctly modeled as an ellipse,
+ whereas this rectangle represents the outer bounds of the ellipse after \l rotation.
+
+ \sa horizontalDiameter, verticalDiameter
+*/
void QQuickTouchPoint::setArea(const QRectF &area)
{
if (_area == area)
@@ -222,6 +269,25 @@ void QQuickTouchPoint::setSceneY(qreal sceneY)
}
/*!
+ \qmlproperty PointingDeviceUniqueId QtQuick::TouchPoint::uniqueId
+ \since 5.9
+
+ This property holds the unique ID of the touch point or token.
+
+ It is normally empty, because touchscreens cannot uniquely identify fingers.
+ But when it is set, it is expected to uniquely identify a specific token
+ (fiducial object).
+
+ Interpreting the contents of this ID requires knowledge of the hardware and
+ drivers in use (e.g. various TUIO-based touch surfaces).
+*/
+void QQuickTouchPoint::setUniqueId(const QPointingDeviceUniqueId &id)
+{
+ _uniqueId = id;
+ emit uniqueIdChanged();
+}
+
+/*!
\qmltype MultiPointTouchArea
\instantiates QQuickMultiPointTouchArea
\inqmlmodule QtQuick
@@ -691,9 +757,12 @@ void QQuickMultiPointTouchArea::updateTouchPoint(QQuickTouchPoint *dtp, const QT
{
//TODO: if !qmlDefined, could bypass setters.
// also, should only emit signals after all values have been set
+ dtp->setUniqueId(p->uniqueId());
dtp->setX(p->pos().x());
dtp->setY(p->pos().y());
+ dtp->setEllipseDiameters(p->ellipseDiameters());
dtp->setPressure(p->pressure());
+ dtp->setRotation(p->rotation());
dtp->setVelocity(p->velocity());
dtp->setArea(p->rect());
dtp->setStartX(p->startPos().x());
diff --git a/src/quick/items/qquickmultipointtoucharea_p.h b/src/quick/items/qquickmultipointtoucharea_p.h
index 541eb04764..25e1056712 100644
--- a/src/quick/items/qquickmultipointtoucharea_p.h
+++ b/src/quick/items/qquickmultipointtoucharea_p.h
@@ -67,10 +67,13 @@ class Q_AUTOTEST_EXPORT QQuickTouchPoint : public QObject
{
Q_OBJECT
Q_PROPERTY(int pointId READ pointId NOTIFY pointIdChanged)
+ Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId NOTIFY uniqueIdChanged REVISION 9)
Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged)
Q_PROPERTY(qreal x READ x NOTIFY xChanged)
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
+ Q_PROPERTY(QSizeF ellipseDiameters READ ellipseDiameters NOTIFY ellipseDiametersChanged REVISION 9)
Q_PROPERTY(qreal pressure READ pressure NOTIFY pressureChanged)
+ Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged REVISION 9)
Q_PROPERTY(QVector2D velocity READ velocity NOTIFY velocityChanged)
Q_PROPERTY(QRectF area READ area NOTIFY areaChanged)
@@ -86,6 +89,7 @@ public:
: _id(0),
_x(0.0), _y(0.0),
_pressure(0.0),
+ _rotation(0),
_qmlDefined(qmlDefined),
_inUse(false),
_pressed(false),
@@ -97,15 +101,24 @@ public:
int pointId() const { return _id; }
void setPointId(int id);
+ QPointingDeviceUniqueId uniqueId() const { return _uniqueId; }
+ void setUniqueId(const QPointingDeviceUniqueId &id);
+
qreal x() const { return _x; }
void setX(qreal x);
qreal y() const { return _y; }
void setY(qreal y);
+ QSizeF ellipseDiameters() const { return _ellipseDiameters; }
+ void setEllipseDiameters(const QSizeF &d);
+
qreal pressure() const { return _pressure; }
void setPressure(qreal pressure);
+ qreal rotation() const { return _rotation; }
+ void setRotation(qreal r);
+
QVector2D velocity() const { return _velocity; }
void setVelocity(const QVector2D &velocity);
@@ -141,9 +154,12 @@ public:
Q_SIGNALS:
void pressedChanged();
void pointIdChanged();
+ Q_REVISION(9) void uniqueIdChanged();
void xChanged();
void yChanged();
+ Q_REVISION(9) void ellipseDiametersChanged();
void pressureChanged();
+ Q_REVISION(9) void rotationChanged();
void velocityChanged();
void areaChanged();
void startXChanged();
@@ -159,6 +175,8 @@ private:
qreal _x;
qreal _y;
qreal _pressure;
+ qreal _rotation;
+ QSizeF _ellipseDiameters;
QVector2D _velocity;
QRectF _area;
bool _qmlDefined;
@@ -170,6 +188,7 @@ private:
qreal _previousY;
qreal _sceneX;
qreal _sceneY;
+ QPointingDeviceUniqueId _uniqueId;
};
class QQuickGrabGestureEvent : public QObject
diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp
index c7b851d33e..4f4c403483 100644
--- a/src/quick/items/qquickopenglshadereffect.cpp
+++ b/src/quick/items/qquickopenglshadereffect.cpp
@@ -288,14 +288,14 @@ void QQuickOpenGLShaderEffectCommon::updateParseLog(bool ignoreAttributes)
parseLog.clear();
if (!ignoreAttributes) {
if (!attributes.contains(qtPositionAttributeName())) {
- parseLog += QLatin1String("Warning: Missing reference to \'");
- parseLog += QLatin1String(qtPositionAttributeName());
- parseLog += QLatin1String("\'.\n");
+ parseLog += QLatin1String("Warning: Missing reference to \'")
+ + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\'.\n");
}
if (!attributes.contains(qtTexCoordAttributeName())) {
- parseLog += QLatin1String("Warning: Missing reference to \'");
- parseLog += QLatin1String(qtTexCoordAttributeName());
- parseLog += QLatin1String("\'.\n");
+ parseLog += QLatin1String("Warning: Missing reference to \'")
+ + QLatin1String(qtTexCoordAttributeName())
+ + QLatin1String("\'.\n");
}
}
bool respectsMatrix = false;
@@ -922,9 +922,7 @@ QSGNode *QQuickOpenGLShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQuic
if (!mesh->validateAttributes(m_common.attributes, &posIndex)) {
QString log = mesh->log();
if (!log.isNull()) {
- m_log = parseLog();
- m_log += QLatin1String("*** Mesh ***\n");
- m_log += log;
+ m_log = parseLog() + QLatin1String("*** Mesh ***\n") + log;
m_status = QQuickShaderEffect::Error;
emit m_item->logChanged();
emit m_item->statusChanged();
diff --git a/src/quick/items/qquickopenglshadereffect_p.h b/src/quick/items/qquickopenglshadereffect_p.h
index 64e79a9343..bc2e2975ee 100644
--- a/src/quick/items/qquickopenglshadereffect_p.h
+++ b/src/quick/items/qquickopenglshadereffect_p.h
@@ -70,7 +70,6 @@ QT_REQUIRE_CONFIG(quick_shadereffect);
QT_BEGIN_NAMESPACE
class QSGContext;
-class QSignalMapper;
class QFileSelector;
class QQuickOpenGLCustomMaterialShader;
diff --git a/src/quick/items/qquickopenglshadereffectnode.cpp b/src/quick/items/qquickopenglshadereffectnode.cpp
index 02b76b2dbc..2d2cffbeed 100644
--- a/src/quick/items/qquickopenglshadereffectnode.cpp
+++ b/src/quick/items/qquickopenglshadereffectnode.cpp
@@ -260,14 +260,12 @@ void QQuickCustomMaterialShader::compile()
m_log.clear();
m_compiled = true;
- if (!program()->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader())) {
- m_log += QLatin1String("*** Vertex shader ***\n");
- m_log += program()->log();
+ if (!program()->addCacheableShaderFromSourceCode(QOpenGLShader::Vertex, vertexShader())) {
+ m_log += QLatin1String("*** Vertex shader ***\n") + program()->log();
m_compiled = false;
}
- if (!program()->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader())) {
- m_log += QLatin1String("*** Fragment shader ***\n");
- m_log += program()->log();
+ if (!program()->addCacheableShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShader())) {
+ m_log += QLatin1String("*** Fragment shader ***\n") + program()->log();
m_compiled = false;
}
diff --git a/src/quick/items/qquickpainteditem.cpp b/src/quick/items/qquickpainteditem.cpp
index c5155c9c35..3911bb0f28 100644
--- a/src/quick/items/qquickpainteditem.cpp
+++ b/src/quick/items/qquickpainteditem.cpp
@@ -53,7 +53,7 @@ class QQuickPaintedItemTextureProvider : public QSGTextureProvider
{
public:
QSGPainterNode *node;
- QSGTexture *texture() const { return node ? node->texture() : 0; }
+ QSGTexture *texture() const override { return node ? node->texture() : 0; }
void fireTextureChanged() { emit textureChanged(); }
};
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index e54ee66fe5..53e547fe98 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -63,13 +63,7 @@ Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle)
const qreal MinimumFlickVelocity = 75.0;
-inline qreal qmlMod(qreal x, qreal y)
-{
- using std::fmod;
- return fmod(x, y);
-}
-
-static QQmlOpenMetaObjectType *qPathViewAttachedType = 0;
+static QQmlOpenMetaObjectType *qPathViewAttachedType = nullptr;
QQuickPathViewAttached::QQuickPathViewAttached(QObject *parent)
: QObject(parent), m_percent(-1), m_view(0), m_onPath(false), m_isCurrent(false)
@@ -96,7 +90,7 @@ void QQuickPathViewAttached::setValue(const QByteArray &name, const QVariant &va
}
QQuickPathViewPrivate::QQuickPathViewPrivate()
- : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0)
+ : path(nullptr), currentIndex(0), currentItemOffset(0.0), startPc(0)
, offset(0.0), offsetAdj(0.0), mappedRange(1.0), mappedCache(0.0)
, stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true)
, autoHighlight(true), highlightUp(false), layoutScheduled(false)
@@ -106,7 +100,7 @@ QQuickPathViewPrivate::QQuickPathViewPrivate()
, moveOffset(this, &QQuickPathViewPrivate::setAdjustedOffset), flickDuration(0)
, pathItems(-1), requestedIndex(-1), cacheSize(0), requestedZ(0)
, moveReason(Other), movementDirection(QQuickPathView::Shortest), moveDirection(QQuickPathView::Shortest)
- , attType(0), highlightComponent(0), highlightItem(0)
+ , attType(nullptr), highlightComponent(nullptr), highlightItem(nullptr)
, moveHighlight(this, &QQuickPathViewPrivate::setHighlightPosition)
, highlightPosition(0)
, highlightRangeStart(0), highlightRangeEnd(0)
@@ -143,7 +137,7 @@ QQuickItem *QQuickPathViewPrivate::getItem(int modelIndex, qreal z, bool async)
if (!delegateValidated) {
delegateValidated = true;
QObject* delegate = q->delegate();
- qmlInfo(delegate ? delegate : q) << QQuickPathView::tr("Delegate must be of Item type");
+ qmlWarning(delegate ? delegate : q) << QQuickPathView::tr("Delegate must be of Item type");
}
}
} else {
@@ -163,7 +157,7 @@ void QQuickPathView::createdItem(int index, QObject *object)
if (d->requestedIndex != index) {
qPathViewAttachedType = d->attachedType();
QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item));
- qPathViewAttachedType = 0;
+ qPathViewAttachedType = nullptr;
if (att) {
att->m_view = this;
att->setOnPath(false);
@@ -186,7 +180,7 @@ void QQuickPathView::initItem(int index, QObject *object)
item->setParentItem(this);
qPathViewAttachedType = d->attachedType();
QQuickPathViewAttached *att = static_cast<QQuickPathViewAttached *>(qmlAttachedPropertiesObject<QQuickPathView>(item));
- qPathViewAttachedType = 0;
+ qPathViewAttachedType = nullptr;
if (att) {
att->m_view = this;
qreal percent = d->positionOfIndex(index);
@@ -215,7 +209,7 @@ void QQuickPathViewPrivate::releaseItem(QQuickItem *item)
att->setOnPath(false);
} else if (flags & QQmlInstanceModel::Destroyed) {
// but we still reference it
- item->setParentItem(0);
+ item->setParentItem(nullptr);
}
}
@@ -244,7 +238,7 @@ void QQuickPathViewPrivate::clear()
{
if (currentItem) {
releaseItem(currentItem);
- currentItem = 0;
+ currentItem = nullptr;
}
for (QQuickItem *p : qAsConst(items))
releaseItem(p);
@@ -280,13 +274,13 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
|| snapMode != QQuickPathView::NoSnap))
start = highlightRangeStart;
qreal globalPos = index + offset;
- globalPos = qmlMod(globalPos, qreal(modelCount)) / modelCount;
+ globalPos = std::fmod(globalPos, qreal(modelCount)) / modelCount;
if (pathItems != -1 && pathItems < modelCount) {
globalPos += start / mappedRange;
- globalPos = qmlMod(globalPos, 1.0);
+ globalPos = std::fmod(globalPos, qreal(1.0));
pos = globalPos * mappedRange;
} else {
- pos = qmlMod(globalPos + start, 1.0);
+ pos = std::fmod(globalPos + start, qreal(1.0));
}
}
@@ -315,13 +309,13 @@ void QQuickPathViewPrivate::createHighlight()
bool changed = false;
if (highlightItem) {
- highlightItem->setParentItem(0);
+ highlightItem->setParentItem(nullptr);
highlightItem->deleteLater();
- highlightItem = 0;
+ highlightItem = nullptr;
changed = true;
}
- QQuickItem *item = 0;
+ QQuickItem *item = nullptr;
if (highlightComponent) {
QQmlContext *creationContext = highlightComponent->creationContext();
QQmlContext *highlightContext = new QQmlContext(
@@ -397,7 +391,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
qreal range = qreal(modelCount);
// calc normalized position of highlight relative to offset
- qreal relativeHighlight = qmlMod(pos + offset, range) / range;
+ qreal relativeHighlight = std::fmod(pos + offset, range) / range;
if (!highlightUp && relativeHighlight > end / mappedRange) {
qreal diff = 1.0 - relativeHighlight;
@@ -636,7 +630,7 @@ void QQuickPathView::setModel(const QVariant &m)
d->modelVariant = model;
QObject *object = qvariant_cast<QObject*>(model);
- QQmlInstanceModel *vim = 0;
+ QQmlInstanceModel *vim = nullptr;
if (object && (vim = qobject_cast<QQmlInstanceModel *>(object))) {
if (d->ownModel) {
delete d->model;
@@ -710,16 +704,23 @@ void QQuickPathView::setPath(QQuickPath *path)
qmlobject_disconnect(d->path, QQuickPath, SIGNAL(changed()),
this, QQuickPathView, SLOT(pathUpdated()));
d->path = path;
- qmlobject_connect(d->path, QQuickPath, SIGNAL(changed()),
- this, QQuickPathView, SLOT(pathUpdated()));
- if (d->isValid() && isComponentComplete()) {
+
+ if (path) {
+ qmlobject_connect(d->path, QQuickPath, SIGNAL(changed()),
+ this, QQuickPathView, SLOT(pathUpdated()));
+ }
+
+ if (isComponentComplete()) {
d->clear();
- if (d->attType) {
- d->attType->release();
- d->attType = 0;
+ if (d->isValid()) {
+ if (d->attType) {
+ d->attType->release();
+ d->attType = nullptr;
+ }
+ d->regenerate();
}
- d->regenerate();
}
+
emit pathChanged();
}
@@ -755,7 +756,7 @@ void QQuickPathView::setCurrentIndex(int idx)
}
int oldCurrentIdx = d->currentIndex;
QQuickItem *oldCurrentItem = d->currentItem;
- d->currentItem = 0;
+ d->currentItem = nullptr;
d->moveReason = QQuickPathViewPrivate::SetIndex;
d->currentIndex = idx;
if (d->modelCount) {
@@ -836,7 +837,7 @@ void QQuickPathViewPrivate::setOffset(qreal o)
if (offset != o) {
if (isValid() && q->isComponentComplete()) {
qreal oldOffset = offset;
- offset = qmlMod(o, qreal(modelCount));
+ offset = std::fmod(o, qreal(modelCount));
if (offset < 0)
offset += qreal(modelCount);
qCDebug(lcItemViewDelegateLifecycle) << o << "was" << oldOffset << "now" << offset;
@@ -902,7 +903,7 @@ void QQuickPathView::setHighlight(QQmlComponent *highlight)
\sa highlight
*/
-QQuickItem *QQuickPathView::highlightItem()
+QQuickItem *QQuickPathView::highlightItem() const
{
Q_D(const QQuickPathView);
return d->highlightItem;
@@ -1237,7 +1238,7 @@ QQmlComponent *QQuickPathView::delegate() const
return dataModel->delegate();
}
- return 0;
+ return nullptr;
}
void QQuickPathView::setDelegate(QQmlComponent *delegate)
@@ -1468,7 +1469,7 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
// Small offset since the last point coincides with the first and
// this the only "end" position that gives the expected visual result.
qreal adj = sizeof(qreal) == sizeof(float) ? 0.00001f : 0.000000000001;
- endOffset = qmlMod(beginOffset + count, d->modelCount) - adj;
+ endOffset = std::fmod(beginOffset + count, qreal(d->modelCount)) - adj;
}
qreal offset = d->offset;
switch (mode) {
@@ -1489,8 +1490,8 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
case Contain:
if ((beginOffset < endOffset && (d->offset < beginOffset || d->offset > endOffset))
|| (d->offset < beginOffset && d->offset > endOffset)) {
- qreal diff1 = qmlMod(beginOffset - d->offset + d->modelCount, d->modelCount);
- qreal diff2 = qmlMod(d->offset - endOffset + d->modelCount, d->modelCount);
+ qreal diff1 = std::fmod(beginOffset - d->offset + d->modelCount, qreal(d->modelCount));
+ qreal diff2 = std::fmod(d->offset - endOffset + d->modelCount, qreal(d->modelCount));
if (diff1 < diff2)
offset = beginOffset;
else
@@ -1518,7 +1519,7 @@ int QQuickPathView::indexAt(qreal x, qreal y) const
{
Q_D(const QQuickPathView);
QQuickItem *item = itemAt(x, y);
- return item ? d->model->indexOf(item, 0) : -1;
+ return item ? d->model->indexOf(item, nullptr) : -1;
}
/*!
@@ -1533,7 +1534,7 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
{
Q_D(const QQuickPathView);
if (!d->isValid())
- return 0;
+ return nullptr;
for (QQuickItem *item : d->items) {
QPointF p = item->mapFromItem(this, QPointF(x, y));
@@ -1541,7 +1542,7 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
return item;
}
- return 0;
+ return nullptr;
}
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
@@ -1606,7 +1607,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const
return velocity;
}
-qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event)
+qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event) const
{
if (0 != event->timestamp())
return event->timestamp();
@@ -1810,7 +1811,7 @@ bool QQuickPathView::sendMouseEvent(QMouseEvent *event)
QPointF localPos = mapFromScene(event->windowPos());
QQuickWindow *c = window();
- QQuickItem *grabber = c ? c->mouseGrabberItem() : 0;
+ QQuickItem *grabber = c ? c->mouseGrabberItem() : nullptr;
if (grabber == this && d->stealMouse) {
// we are already the grabber and we do want the mouse event to ourselves.
return true;
@@ -1836,7 +1837,7 @@ bool QQuickPathView::sendMouseEvent(QMouseEvent *event)
default:
break;
}
- grabber = c ? c->mouseGrabberItem() : 0;
+ grabber = c ? c->mouseGrabberItem() : nullptr;
if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || grabberDisabled) {
grabMouse();
}
@@ -1915,7 +1916,7 @@ void QQuickPathView::componentComplete()
if (d->model) {
d->modelCount = d->model->count();
if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex
- d->offset = qmlMod(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount), d->modelCount);
+ d->offset = std::fmod(qreal(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount)), qreal(d->modelCount));
}
d->createHighlight();
@@ -1951,7 +1952,7 @@ void QQuickPathView::refill()
QList<QQuickItem*>::iterator it = d->items.begin();
while (it != d->items.end()) {
QQuickItem *item = *it;
- int idx = d->model->indexOf(item, 0);
+ int idx = d->model->indexOf(item, nullptr);
qreal pos = d->positionOfIndex(idx);
if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
QQuickText *text = qmlobject_cast<QQuickText*>(item);
@@ -1996,7 +1997,7 @@ void QQuickPathView::refill()
startPos = 2.0;
for (QQuickItem * item : qAsConst(d->items)) {
- int idx = d->model->indexOf(item, 0);
+ int idx = d->model->indexOf(item, nullptr);
qreal curPos = d->positionOfIndex(idx);
if (curPos > endPos) {
endPos = curPos;
@@ -2198,7 +2199,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
if (QQuickPathViewAttached *att = d->attached(d->currentItem))
att->setIsCurrentItem(true);
d->releaseItem(d->currentItem);
- d->currentItem = 0;
+ d->currentItem = nullptr;
}
d->currentIndex = qMin(r.index, d->modelCount - r.count - 1);
currentChanged = true;
@@ -2231,7 +2232,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->modelCount += i.count;
}
- d->offset = qmlMod(d->offset, d->modelCount);
+ d->offset = std::fmod(d->offset, qreal(d->modelCount));
if (d->offset < 0)
d->offset += d->modelCount;
if (d->currentIndex == -1)
@@ -2249,7 +2250,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->tl.reset(d->moveOffset);
} else {
if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QQuickPathView::StrictlyEnforceRange) {
- d->offset = qmlMod(d->modelCount - d->currentIndex, d->modelCount);
+ d->offset = std::fmod(qreal(d->modelCount - d->currentIndex), qreal(d->modelCount));
changedOffset = true;
}
d->updateMappedRange();
@@ -2295,10 +2296,10 @@ int QQuickPathViewPrivate::calcCurrentIndex()
{
int current = 0;
if (modelCount && model && items.count()) {
- offset = qmlMod(offset, modelCount);
+ offset = std::fmod(offset, qreal(modelCount));
if (offset < 0)
offset += modelCount;
- current = qRound(qAbs(qmlMod(modelCount - offset, modelCount)));
+ current = qRound(qAbs(std::fmod(modelCount - offset, qreal(modelCount))));
current = current % modelCount;
}
@@ -2312,7 +2313,7 @@ void QQuickPathViewPrivate::createCurrentItem()
bool inItems = false;
for (QQuickItem *item : qAsConst(items)) {
- if (model->indexOf(item, 0) == currentIndex) {
+ if (model->indexOf(item, nullptr) == currentIndex) {
inItems = true;
break;
}
@@ -2350,7 +2351,7 @@ void QQuickPathViewPrivate::updateCurrent()
}
int oldCurrentIndex = currentIndex;
currentIndex = idx;
- currentItem = 0;
+ currentItem = nullptr;
createCurrentItem();
if (oldCurrentIndex != currentIndex)
emit q->currentIndexChanged();
@@ -2383,7 +2384,7 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason)
if (!model || modelCount <= 0)
return;
- qreal targetOffset = qmlMod(modelCount - index, modelCount);
+ qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount));
if (offset == targetOffset)
return;
diff --git a/src/quick/items/qquickpathview_p.h b/src/quick/items/qquickpathview_p.h
index a44d1be5c4..0e237b7b74 100644
--- a/src/quick/items/qquickpathview_p.h
+++ b/src/quick/items/qquickpathview_p.h
@@ -102,7 +102,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathView : public QQuickItem
Q_PROPERTY(int cacheItemCount READ cacheItemCount WRITE setCacheItemCount NOTIFY cacheItemCountChanged)
public:
- QQuickPathView(QQuickItem *parent=0);
+ QQuickPathView(QQuickItem *parent = nullptr);
virtual ~QQuickPathView();
QVariant model() const;
@@ -121,7 +121,7 @@ public:
QQmlComponent *highlight() const;
void setHighlight(QQmlComponent *highlight);
- QQuickItem *highlightItem();
+ QQuickItem *highlightItem() const;
enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
Q_ENUM(HighlightRangeMode)
@@ -221,14 +221,14 @@ Q_SIGNALS:
void cacheItemCountChanged();
protected:
- void updatePolish() Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void updatePolish() override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
bool sendMouseEvent(QMouseEvent *event);
- bool childMouseEventFilter(QQuickItem *, QEvent *) Q_DECL_OVERRIDE;
- void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
+ bool childMouseEventFilter(QQuickItem *, QEvent *) override;
+ void mouseUngrabEvent() override;
+ void componentComplete() override;
private Q_SLOTS:
void refill();
@@ -259,7 +259,7 @@ public:
QQuickPathViewAttached(QObject *parent);
~QQuickPathViewAttached();
- QQuickPathView *view() { return m_view; }
+ QQuickPathView *view() const { return m_view; }
bool isCurrentItem() const { return m_isCurrent; }
void setIsCurrentItem(bool c) {
diff --git a/src/quick/items/qquickpathview_p_p.h b/src/quick/items/qquickpathview_p_p.h
index 64abe3d1dc..d58c986d1a 100644
--- a/src/quick/items/qquickpathview_p_p.h
+++ b/src/quick/items/qquickpathview_p_p.h
@@ -80,7 +80,7 @@ public:
void init();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE {
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override {
if (change.sizeChange() && (!highlightItem || item != highlightItem)) {
if (QQuickPathViewAttached *att = attached(item))
att->m_percent = -1;
@@ -129,7 +129,7 @@ public:
QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const;
void addVelocitySample(qreal v);
qreal calcVelocity() const;
- qint64 computeCurrentTime(QInputEvent *event);
+ qint64 computeCurrentTime(QInputEvent *event) const;
void setDragging(bool d);
QQuickPath *path;
diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp
index e22427ca49..05d3ae0191 100644
--- a/src/quick/items/qquickpositioners.cpp
+++ b/src/quick/items/qquickpositioners.cpp
@@ -290,6 +290,11 @@ void QQuickBasePositioner::itemChange(ItemChange change, const ItemChangeData &v
QQuickItem::itemChange(change, value);
}
+void QQuickBasePositioner::forceLayout()
+{
+ updatePolish();
+}
+
void QQuickBasePositioner::prePositioning()
{
Q_D(QQuickBasePositioner);
@@ -401,6 +406,8 @@ void QQuickBasePositioner::prePositioning()
//Set implicit size to the size of its children
setImplicitSize(contentSize.width(), contentSize.height());
+
+ emit positioningComplete();
}
void QQuickBasePositioner::positionItem(qreal x, qreal y, PositionedItem *target)
@@ -910,6 +917,28 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem)
\sa Grid::spacing
*/
+/*!
+ \qmlmethod QtQuick::Column::forceLayout()
+ \since 5.9
+
+ Column typically positions its children once per frame. This means that
+ inside script blocks it is possible for the underlying children to have changed,
+ but the Column to have not yet been updated accordingly.
+
+ This method forces the Column to immediately respond to any outstanding
+ changes in its children.
+
+ \b Note: methods in general should only be called after the Component has completed.
+*/
+/*!
+ \qmlsignal QtQuick::Column::positioningComplete()
+ \since 5.9
+
+ This signal is emitted when positioning has been completed.
+
+ The corresponding handler is \c onPositioningComplete.
+*/
+
QQuickColumn::QQuickColumn(QQuickItem *parent)
: QQuickBasePositioner(Vertical, parent)
{
@@ -957,7 +986,7 @@ void QQuickColumn::reportConflictingAnchors()
}
}
if (d->anchorConflict) {
- qmlInfo(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column."
+ qmlWarning(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column."
<< " Column will not function.";
}
}
@@ -1077,6 +1106,27 @@ void QQuickColumn::reportConflictingAnchors()
\sa Grid::spacing
*/
+/*!
+ \qmlmethod QtQuick::Row::forceLayout()
+ \since 5.9
+
+ Row typically positions its children once per frame. This means that
+ inside script blocks it is possible for the underlying children to have changed,
+ but the Row to have not yet been updated accordingly.
+
+ This method forces the Row to immediately respond to any outstanding
+ changes in its children.
+
+ \b Note: methods in general should only be called after the Component has completed.
+*/
+/*!
+ \qmlsignal QtQuick::Row::positioningComplete()
+ \since 5.9
+
+ This signal is emitted when positioning has been completed.
+
+ The corresponding handler is \c onPositioningComplete.
+*/
class QQuickRowPrivate : public QQuickBasePositionerPrivate
{
@@ -1224,7 +1274,7 @@ void QQuickRow::reportConflictingAnchors()
}
}
if (d->anchorConflict)
- qmlInfo(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row."
+ qmlWarning(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row."
<< " Row will not function.";
}
@@ -1355,6 +1405,27 @@ void QQuickRow::reportConflictingAnchors()
\sa rows, columns
*/
+/*!
+ \qmlmethod QtQuick::Grid::forceLayout()
+ \since 5.9
+
+ Grid typically positions its children once per frame. This means that
+ inside script blocks it is possible for the underlying children to have changed,
+ but the Grid to have not yet been updated accordingly.
+
+ This method forces the Grid to immediately respond to any outstanding
+ changes in its children.
+
+ \b Note: methods in general should only be called after the Component has completed.
+*/
+/*!
+ \qmlsignal QtQuick::Grid::positioningComplete()
+ \since 5.9
+
+ This signal is emitted when positioning has been completed.
+
+ The corresponding handler is \c onPositioningComplete.
+*/
class QQuickGridPrivate : public QQuickBasePositionerPrivate
{
@@ -1808,7 +1879,7 @@ void QQuickGrid::reportConflictingAnchors()
}
}
if (d->anchorConflict)
- qmlInfo(this) << "Cannot specify anchors for items inside Grid." << " Grid will not function.";
+ qmlWarning(this) << "Cannot specify anchors for items inside Grid." << " Grid will not function.";
}
/*!
@@ -1920,6 +1991,28 @@ void QQuickGrid::reportConflictingAnchors()
\sa Grid::spacing
*/
+/*!
+ \qmlmethod QtQuick::Flow::forceLayout()
+ \since 5.9
+
+ Flow typically positions its children once per frame. This means that
+ inside script blocks it is possible for the underlying children to have changed,
+ but the Flow to have not yet been updated accordingly.
+
+ This method forces the Flow to immediately respond to any outstanding
+ changes in its children.
+
+
+ \b Note: methods in general should only be called after the Component has completed.
+*/
+/*!
+ \qmlsignal QtQuick::Flow::positioningComplete()
+ \since 5.9
+
+ This signal is emitted when positioning has been completed.
+
+ The corresponding handler is \c onPositioningComplete.
+*/
class QQuickFlowPrivate : public QQuickBasePositionerPrivate
{
@@ -2121,7 +2214,7 @@ void QQuickFlow::reportConflictingAnchors()
}
}
if (d->anchorConflict)
- qmlInfo(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function.";
+ qmlWarning(this) << "Cannot specify anchors for items inside Flow." << " Flow will not function.";
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h
index c25ecd6dbc..ae6e795794 100644
--- a/src/quick/items/qquickpositioners_p.h
+++ b/src/quick/items/qquickpositioners_p.h
@@ -155,6 +155,8 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
+ Q_REVISION(9) Q_INVOKABLE void forceLayout();
+
protected:
QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent);
void componentComplete() Q_DECL_OVERRIDE;
@@ -172,6 +174,7 @@ Q_SIGNALS:
Q_REVISION(6) void leftPaddingChanged();
Q_REVISION(6) void rightPaddingChanged();
Q_REVISION(6) void bottomPaddingChanged();
+ Q_REVISION(9) void positioningComplete();
protected Q_SLOTS:
void prePositioning();
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 4f46f41b0d..a7254464ed 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -423,7 +423,7 @@ void QQuickRepeater::initItem(int index, QObject *object)
if (!d->delegateValidated) {
d->delegateValidated = true;
QObject* delegate = this->delegate();
- qmlInfo(delegate ? delegate : this) << QQuickRepeater::tr("Delegate must be of Item type");
+ qmlWarning(delegate ? delegate : this) << QQuickRepeater::tr("Delegate must be of Item type");
}
}
return;
diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp
index 5d01a2af9d..20c6973ee1 100644
--- a/src/quick/items/qquickscreen.cpp
+++ b/src/quick/items/qquickscreen.cpp
@@ -207,100 +207,181 @@ QT_BEGIN_NAMESPACE
By default it is set to the value of the QScreen that the window uses.
*/
-QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
- : QObject(attachee)
- , m_screen(NULL)
- , m_window(NULL)
- , m_updateMask(0)
- , m_updateMaskSet(false)
+QQuickScreenInfo::QQuickScreenInfo(QObject *parent, QScreen *wrappedScreen)
+ : QObject(parent)
+ , m_screen(wrappedScreen)
{
- m_attachee = qobject_cast<QQuickItem*>(attachee);
-
- if (m_attachee) {
- QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this;
-
- if (m_attachee->window()) //It might not be assigned to a window yet
- windowChanged(m_attachee->window());
- } else {
- QQuickWindow *window = qobject_cast<QQuickWindow*>(attachee);
- if (window)
- windowChanged(window);
- }
-
- if (!m_screen)
- screenChanged(QGuiApplication::primaryScreen());
}
-QString QQuickScreenAttached::name() const
+QString QQuickScreenInfo::name() const
{
if (!m_screen)
return QString();
return m_screen->name();
}
-int QQuickScreenAttached::width() const
+int QQuickScreenInfo::width() const
{
if (!m_screen)
return 0;
return m_screen->size().width();
}
-int QQuickScreenAttached::height() const
+int QQuickScreenInfo::height() const
{
if (!m_screen)
return 0;
return m_screen->size().height();
}
-int QQuickScreenAttached::desktopAvailableWidth() const
+int QQuickScreenInfo::desktopAvailableWidth() const
{
if (!m_screen)
return 0;
return m_screen->availableVirtualSize().width();
}
-int QQuickScreenAttached::desktopAvailableHeight() const
+int QQuickScreenInfo::desktopAvailableHeight() const
{
if (!m_screen)
return 0;
return m_screen->availableVirtualSize().height();
}
-qreal QQuickScreenAttached::logicalPixelDensity() const
+qreal QQuickScreenInfo::logicalPixelDensity() const
{
if (!m_screen)
return 0.0;
return m_screen->logicalDotsPerInch() / 25.4;
}
-qreal QQuickScreenAttached::pixelDensity() const
+qreal QQuickScreenInfo::pixelDensity() const
{
if (!m_screen)
return 0.0;
return m_screen->physicalDotsPerInch() / 25.4;
}
-qreal QQuickScreenAttached::devicePixelRatio() const
+qreal QQuickScreenInfo::devicePixelRatio() const
{
if (!m_screen)
return 1.0;
return m_screen->devicePixelRatio();
}
-Qt::ScreenOrientation QQuickScreenAttached::primaryOrientation() const
+Qt::ScreenOrientation QQuickScreenInfo::primaryOrientation() const
{
if (!m_screen)
return Qt::PrimaryOrientation;
return m_screen->primaryOrientation();
}
-Qt::ScreenOrientation QQuickScreenAttached::orientation() const
+Qt::ScreenOrientation QQuickScreenInfo::orientation() const
{
if (!m_screen)
return Qt::PrimaryOrientation;
return m_screen->orientation();
}
+int QQuickScreenInfo::virtualX() const
+{
+ if (!m_screen)
+ return 0;
+ return m_screen->geometry().topLeft().x();
+}
+
+int QQuickScreenInfo::virtualY() const
+{
+ if (!m_screen)
+ return 0;
+ return m_screen->geometry().topLeft().y();
+}
+
+void QQuickScreenInfo::setWrappedScreen(QScreen *screen)
+{
+ if (screen == m_screen)
+ return;
+
+ QScreen *oldScreen = m_screen;
+ m_screen = screen;
+
+ if (oldScreen)
+ oldScreen->disconnect(this);
+
+ if (!screen) //Don't bother emitting signals, because the new values are garbage anyways
+ return;
+
+ if (!oldScreen || screen->geometry() != oldScreen->geometry()) {
+ emit virtualXChanged();
+ emit virtualYChanged();
+ }
+ if (!oldScreen || screen->size() != oldScreen->size()) {
+ emit widthChanged();
+ emit heightChanged();
+ }
+ if (!oldScreen || screen->name() != oldScreen->name())
+ emit nameChanged();
+ if (!oldScreen || screen->orientation() != oldScreen->orientation())
+ emit orientationChanged();
+ if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
+ emit primaryOrientationChanged();
+ if (!oldScreen || screen->availableVirtualGeometry() != oldScreen->availableVirtualGeometry())
+ emit desktopGeometryChanged();
+ if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
+ emit logicalPixelDensityChanged();
+ if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
+ emit pixelDensityChanged();
+ if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
+ emit devicePixelRatioChanged();
+
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(widthChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(heightChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(virtualXChanged()));
+ connect(screen, SIGNAL(geometryChanged(QRect)),
+ this, SIGNAL(virtualYChanged()));
+ connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
+ this, SIGNAL(orientationChanged()));
+ connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
+ this, SIGNAL(primaryOrientationChanged()));
+ connect(screen, SIGNAL(virtualGeometryChanged(QRect)),
+ this, SIGNAL(desktopGeometryChanged()));
+ connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
+ this, SIGNAL(logicalPixelDensityChanged()));
+ connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
+ this, SIGNAL(pixelDensityChanged()));
+}
+
+QScreen *QQuickScreenInfo::wrappedScreen() const
+{
+ return m_screen;
+}
+
+QQuickScreenAttached::QQuickScreenAttached(QObject* attachee)
+ : QQuickScreenInfo(attachee)
+ , m_window(NULL)
+ , m_updateMask(0)
+ , m_updateMaskSet(false)
+{
+ m_attachee = qobject_cast<QQuickItem*>(attachee);
+
+ if (m_attachee) {
+ QQuickItemPrivate::get(m_attachee)->extra.value().screenAttached = this;
+
+ if (m_attachee->window()) //It might not be assigned to a window yet
+ windowChanged(m_attachee->window());
+ } else {
+ QQuickWindow *window = qobject_cast<QQuickWindow*>(attachee);
+ if (window)
+ windowChanged(window);
+ }
+
+ if (!m_screen)
+ screenChanged(QGuiApplication::primaryScreen());
+}
+
Qt::ScreenOrientations QQuickScreenAttached::orientationUpdateMask() const
{
return m_updateMask;
@@ -341,55 +422,15 @@ void QQuickScreenAttached::screenChanged(QScreen *screen)
{
//qDebug() << "QQuickScreenAttached::screenChanged" << (screen ? screen->name() : QString::fromLatin1("null"));
if (screen != m_screen) {
- QScreen* oldScreen = m_screen;
- m_screen = screen;
-
- if (oldScreen)
- oldScreen->disconnect(this);
-
- if (!screen)
- return; //Don't bother emitting signals, because the new values are garbage anyways
-
+ setWrappedScreen(screen);
+ if (!m_screen)
+ return;
if (m_updateMaskSet) {
- screen->setOrientationUpdateMask(m_updateMask);
- } else if (m_updateMask != screen->orientationUpdateMask()) {
- m_updateMask = screen->orientationUpdateMask();
+ m_screen->setOrientationUpdateMask(m_updateMask);
+ } else if (m_updateMask != m_screen->orientationUpdateMask()) {
+ m_updateMask = m_screen->orientationUpdateMask();
emit orientationUpdateMaskChanged();
}
-
- if (!oldScreen || screen->size() != oldScreen->size()) {
- emit widthChanged();
- emit heightChanged();
- }
- if (!oldScreen || screen->name() != oldScreen->name())
- emit nameChanged();
- if (!oldScreen || screen->orientation() != oldScreen->orientation())
- emit orientationChanged();
- if (!oldScreen || screen->primaryOrientation() != oldScreen->primaryOrientation())
- emit primaryOrientationChanged();
- if (!oldScreen || screen->availableVirtualGeometry() != oldScreen->availableVirtualGeometry())
- emit desktopGeometryChanged();
- if (!oldScreen || screen->logicalDotsPerInch() != oldScreen->logicalDotsPerInch())
- emit logicalPixelDensityChanged();
- if (!oldScreen || screen->physicalDotsPerInch() != oldScreen->physicalDotsPerInch())
- emit pixelDensityChanged();
- if (!oldScreen || screen->devicePixelRatio() != oldScreen->devicePixelRatio())
- emit devicePixelRatioChanged();
-
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(widthChanged()));
- connect(screen, SIGNAL(geometryChanged(QRect)),
- this, SIGNAL(heightChanged()));
- connect(screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(orientationChanged()));
- connect(screen, SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)),
- this, SIGNAL(primaryOrientationChanged()));
- connect(screen, SIGNAL(virtualGeometryChanged(QRect)),
- this, SIGNAL(desktopGeometryChanged()));
- connect(screen, SIGNAL(logicalDotsPerInchChanged(qreal)),
- this, SIGNAL(logicalPixelDensityChanged()));
- connect(screen, SIGNAL(physicalDotsPerInchChanged(qreal)),
- this, SIGNAL(pixelDensityChanged()));
}
}
diff --git a/src/quick/items/qquickscreen_p.h b/src/quick/items/qquickscreen_p.h
index 06d9a06070..99e1466631 100644
--- a/src/quick/items/qquickscreen_p.h
+++ b/src/quick/items/qquickscreen_p.h
@@ -63,10 +63,10 @@ class QQuickItem;
class QQuickWindow;
class QScreen;
-class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject
+
+class Q_AUTOTEST_EXPORT QQuickScreenInfo : public QObject
{
Q_OBJECT
-
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
@@ -79,11 +79,12 @@ class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QObject
Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
// TODO Qt 6 Remove this orientation -> incomplete device orientation -> better use OrientationSensor
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
- Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
- WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
+
+ Q_PROPERTY(int virtualX READ virtualX NOTIFY virtualXChanged REVISION 1)
+ Q_PROPERTY(int virtualY READ virtualY NOTIFY virtualYChanged REVISION 1)
public:
- QQuickScreenAttached(QObject* attachee);
+ QQuickScreenInfo(QObject *parent = nullptr, QScreen *wrappedScreen = nullptr);
QString name() const;
int width() const;
@@ -95,13 +96,11 @@ public:
qreal devicePixelRatio() const;
Qt::ScreenOrientation primaryOrientation() const;
Qt::ScreenOrientation orientation() const;
- Qt::ScreenOrientations orientationUpdateMask() const;
- void setOrientationUpdateMask(Qt::ScreenOrientations mask);
+ int virtualX() const;
+ int virtualY() const;
- //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
- Q_INVOKABLE int angleBetween(int a, int b);
-
- void windowChanged(QQuickWindow*);
+ void setWrappedScreen(QScreen *screen);
+ QScreen *wrappedScreen() const;
Q_SIGNALS:
void nameChanged();
@@ -113,13 +112,37 @@ Q_SIGNALS:
void devicePixelRatioChanged();
void primaryOrientationChanged();
void orientationChanged();
+ Q_REVISION(1) void virtualXChanged();
+ Q_REVISION(1) void virtualYChanged();
+
+protected:
+ QPointer<QScreen> m_screen;
+};
+
+class Q_AUTOTEST_EXPORT QQuickScreenAttached : public QQuickScreenInfo
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::ScreenOrientations orientationUpdateMask READ orientationUpdateMask
+ WRITE setOrientationUpdateMask NOTIFY orientationUpdateMaskChanged)
+
+public:
+ QQuickScreenAttached(QObject* attachee);
+
+ Qt::ScreenOrientations orientationUpdateMask() const;
+ void setOrientationUpdateMask(Qt::ScreenOrientations mask);
+
+ //Treats int as Qt::ScreenOrientation, due to QTBUG-20639
+ Q_INVOKABLE int angleBetween(int a, int b);
+
+ void windowChanged(QQuickWindow*);
+
+Q_SIGNALS:
void orientationUpdateMaskChanged();
protected Q_SLOTS:
void screenChanged(QScreen*);
private:
- QPointer<QScreen> m_screen;
QQuickWindow* m_window;
QQuickItem* m_attachee;
Qt::ScreenOrientations m_updateMask;
@@ -136,5 +159,6 @@ public:
QT_END_NAMESPACE
QML_DECLARE_TYPEINFO(QQuickScreen, QML_HAS_ATTACHED_PROPERTIES)
+QML_DECLARE_TYPE(QQuickScreenInfo)
#endif
diff --git a/src/quick/items/qquickshadereffectmesh.cpp b/src/quick/items/qquickshadereffectmesh.cpp
index b572feb5ee..d23b576d42 100644
--- a/src/quick/items/qquickshadereffectmesh.cpp
+++ b/src/quick/items/qquickshadereffectmesh.cpp
@@ -95,9 +95,8 @@ bool QQuickGridMesh::validateAttributes(const QVector<QByteArray> &attributes, i
return false;
case 1:
if (positionIndex != 0) {
- m_log = QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtPositionAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\' attribute.\n");
return false;
}
break;
@@ -105,14 +104,12 @@ bool QQuickGridMesh::validateAttributes(const QVector<QByteArray> &attributes, i
if (positionIndex == -1 || texCoordIndex == -1) {
m_log.clear();
if (positionIndex == -1) {
- m_log = QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtPositionAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log = QLatin1String("Error: Missing \'") + QLatin1String(qtPositionAttributeName())
+ + QLatin1String("\' attribute.\n");
}
if (texCoordIndex == -1) {
- m_log += QLatin1String("Error: Missing \'");
- m_log += QLatin1String(qtTexCoordAttributeName());
- m_log += QLatin1String("\' attribute.\n");
+ m_log += QLatin1String("Error: Missing \'") + QLatin1String(qtTexCoordAttributeName())
+ + QLatin1String("\' attribute.\n");
}
return false;
}
@@ -367,7 +364,7 @@ QSGGeometry *QQuickBorderImageMesh::updateGeometry(QSGGeometry *geometry, int at
}
\endqml
*/
-QQuickScaleGrid *QQuickBorderImageMesh::border()
+QQuickScaleGrid *QQuickBorderImageMesh::border() const
{
return m_border;
}
diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h
index cbf33b795f..aa3112b5a5 100644
--- a/src/quick/items/qquickshadereffectmesh_p.h
+++ b/src/quick/items/qquickshadereffectmesh_p.h
@@ -127,7 +127,7 @@ public:
QSGGeometry *updateGeometry(QSGGeometry *geometry, int attrCount, int posIndex,
const QRectF &srcRect, const QRectF &rect) override;
- QQuickScaleGrid *border();
+ QQuickScaleGrid *border() const;
enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile };
Q_ENUM(TileMode)
diff --git a/src/quick/items/qquickshadereffectsource.cpp b/src/quick/items/qquickshadereffectsource.cpp
index a60a06f59a..1b37a746d3 100644
--- a/src/quick/items/qquickshadereffectsource.cpp
+++ b/src/quick/items/qquickshadereffectsource.cpp
@@ -64,7 +64,7 @@ public:
{
}
- QSGTexture *texture() const {
+ QSGTexture *texture() const override {
sourceTexture->setMipmapFiltering(mipmapFiltering);
sourceTexture->setFiltering(filtering);
sourceTexture->setHorizontalWrapMode(horizontalWrap);
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index b1905f2cc5..d26a1f8a64 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -323,13 +323,13 @@ void QQuickStochasticEngine::setGoal(int state, int sprite, bool jump)
return;
}
-QQuickPixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprites
+QQuickPixmap::Status QQuickSpriteEngine::status() const //Composed status of all Sprites
{
if (!m_startedImageAssembly)
return QQuickPixmap::Null;
int null, loading, ready;
null = loading = ready = 0;
- for (QQuickSprite* s : qAsConst(m_sprites)) {
+ for (QQuickSprite* s : m_sprites) {
switch (s->m_pix.status()) {
// ### Maybe add an error message here, because this null shouldn't be reached but when it does, the image fails without an error message.
case QQuickPixmap::Null : null++; break;
@@ -378,7 +378,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
if (!m_errorsPrinted && stat == QQuickPixmap::Error) {
for (QQuickSprite* s : qAsConst(m_sprites))
if (s->m_pix.isError())
- qmlInfo(s) << s->m_pix.error();
+ qmlWarning(s) << s->m_pix.error();
m_errorsPrinted = true;
}
@@ -399,7 +399,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
{
const QSize frameSize(state->m_frameWidth, state->m_frameHeight);
if (!(img.size() - frameSize).isValid()) {
- qmlInfo(state).nospace() << "SpriteEngine: Invalid frame size " << frameSize << "."
+ qmlWarning(state).nospace() << "SpriteEngine: Invalid frame size " << frameSize << "."
" It's bigger than image size " << img.size() << ".";
return QImage();
}
@@ -419,10 +419,10 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
int rowsNeeded = helper::divRoundUp(state->frames(), (maxSize / state->frameWidth()));
if (h + rowsNeeded * state->frameHeight() > maxSize){
if (rowsNeeded * state->frameHeight() > maxSize)
- qmlInfo(state) << "SpriteEngine: Animation too large to fit in one texture:" << state->source().toLocalFile();
+ qmlWarning(state) << "SpriteEngine: Animation too large to fit in one texture:" << state->source().toLocalFile();
else
- qmlInfo(state) << "SpriteEngine: Animations too large to fit in one texture, pushed over the edge by:" << state->source().toLocalFile();
- qmlInfo(state) << "SpriteEngine: Your texture max size today is " << maxSize;
+ qmlWarning(state) << "SpriteEngine: Animations too large to fit in one texture, pushed over the edge by:" << state->source().toLocalFile();
+ qmlWarning(state) << "SpriteEngine: Your texture max size today is " << maxSize;
return QImage();
}
state->m_generatedCount = rowsNeeded;
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 3b7fcfb1f1..90ee68b2f6 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -293,11 +293,11 @@ public:
void advance(int index=0) Q_DECL_OVERRIDE;
//Similar API to QQuickPixmap for async loading convenience
- bool isNull() { return status() == QQuickPixmap::Null; }
- bool isReady() { return status() == QQuickPixmap::Ready; }
- bool isLoading() { return status() == QQuickPixmap::Loading; }
- bool isError() { return status() == QQuickPixmap::Error; }
- QQuickPixmap::Status status();//Composed status of all Sprites
+ bool isNull() const { return status() == QQuickPixmap::Null; }
+ bool isReady() const { return status() == QQuickPixmap::Ready; }
+ bool isLoading() const { return status() == QQuickPixmap::Loading; }
+ bool isError() const { return status() == QQuickPixmap::Error; }
+ QQuickPixmap::Status status() const; //Composed status of all Sprites
void startAssemblingImage();
QImage assembledImage(int maxSize = 2048);
diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp
index 25a39f951a..858a3c0576 100644
--- a/src/quick/items/qquickspritesequence.cpp
+++ b/src/quick/items/qquickspritesequence.cpp
@@ -209,7 +209,7 @@ QSGSpriteNode *QQuickSpriteSequence::initNode()
Q_D(QQuickSpriteSequence);
if (!d->m_spriteEngine) {
- qmlInfo(this) << "No sprite engine...";
+ qmlWarning(this) << "No sprite engine...";
return nullptr;
} else if (d->m_spriteEngine->status() == QQuickPixmap::Null) {
d->m_spriteEngine->startAssemblingImage();
diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp
index 7e485c675c..b40a9e2843 100644
--- a/src/quick/items/qquickstateoperations.cpp
+++ b/src/quick/items/qquickstateoperations.cpp
@@ -78,7 +78,7 @@ void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *s
bool ok;
const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok);
if (transform.type() >= QTransform::TxShear || !ok) {
- qmlInfo(q) << QQuickParentChange::tr("Unable to preserve appearance under complex transform");
+ qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under complex transform");
ok = false;
}
@@ -89,21 +89,21 @@ void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *s
if (transform.m11() == transform.m22())
scale = transform.m11();
else {
- qmlInfo(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale");
+ qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
} else if (ok && isRotate) {
if (transform.m11() == transform.m22())
scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
else {
- qmlInfo(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale");
+ qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under non-uniform scale");
ok = false;
}
if (scale != 0)
rotation = qAtan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI;
else {
- qmlInfo(q) << QQuickParentChange::tr("Unable to preserve appearance under scale of 0");
+ qmlWarning(q) << QQuickParentChange::tr("Unable to preserve appearance under scale of 0");
ok = false;
}
}
@@ -899,9 +899,9 @@ QQuickAnchorChanges::ActionList QQuickAnchorChanges::actions()
return ActionList() << a;
}
-QQuickAnchorSet *QQuickAnchorChanges::anchors()
+QQuickAnchorSet *QQuickAnchorChanges::anchors() const
{
- Q_D(QQuickAnchorChanges);
+ Q_D(const QQuickAnchorChanges);
return d->anchorSet;
}
@@ -1134,9 +1134,9 @@ QQuickStateActionEvent::EventType QQuickAnchorChanges::type() const
return AnchorChanges;
}
-QList<QQuickStateAction> QQuickAnchorChanges::additionalActions()
+QList<QQuickStateAction> QQuickAnchorChanges::additionalActions() const
{
- Q_D(QQuickAnchorChanges);
+ Q_D(const QQuickAnchorChanges);
QList<QQuickStateAction> extra;
QQuickAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors;
diff --git a/src/quick/items/qquickstateoperations_p.h b/src/quick/items/qquickstateoperations_p.h
index 29dec218fa..48b4b23a76 100644
--- a/src/quick/items/qquickstateoperations_p.h
+++ b/src/quick/items/qquickstateoperations_p.h
@@ -192,7 +192,7 @@ public:
ActionList actions() Q_DECL_OVERRIDE;
- QQuickAnchorSet *anchors();
+ QQuickAnchorSet *anchors() const;
QQuickItem *object() const;
void setObject(QQuickItem *);
@@ -210,7 +210,7 @@ public:
void rewind() Q_DECL_OVERRIDE;
void saveCurrentValues() Q_DECL_OVERRIDE;
- QList<QQuickStateAction> additionalActions();
+ QList<QQuickStateAction> additionalActions() const;
void saveTargetValues() Q_DECL_OVERRIDE;
};
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index e37a7e6d5e..1720377046 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -74,7 +74,7 @@ Q_DECLARE_LOGGING_CATEGORY(DBG_HOVER_TRACE)
const QChar QQuickTextPrivate::elideChar = QChar(0x2026);
QQuickTextPrivate::QQuickTextPrivate()
- : elideLayout(0), textLine(0), lineWidth(0)
+ : fontInfo(font), elideLayout(0), textLine(0), lineWidth(0)
, color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000)
, lineCount(1), multilengthEos(-1)
, elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop)
@@ -1018,6 +1018,17 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline)
implicitWidthValid = true;
implicitHeightValid = true;
+ QFontInfo scaledFontInfo(scaledFont);
+ if (fontInfo.weight() != scaledFontInfo.weight()
+ || fontInfo.pixelSize() != scaledFontInfo.pixelSize()
+ || fontInfo.italic() != scaledFontInfo.italic()
+ || !qFuzzyCompare(fontInfo.pointSizeF(), scaledFontInfo.pointSizeF())
+ || fontInfo.family() != scaledFontInfo.family()
+ || fontInfo.styleName() != scaledFontInfo.styleName()) {
+ fontInfo = scaledFontInfo;
+ emit q->fontInfoChanged();
+ }
+
if (eos != multilengthEos)
truncated = true;
@@ -1135,7 +1146,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
needToUpdateLayout = true;
}
} else if (image->pix->isError()) {
- qmlInfo(q) << image->pix->error();
+ qmlWarning(q) << image->pix->error();
}
}
@@ -2795,11 +2806,23 @@ void QQuickText::setRenderType(QQuickText::RenderType renderType)
/*!
\qmlmethod QtQuick::Text::doLayout()
+ \deprecated
- Triggers a re-layout of the displayed text.
+ Use \l forceLayout() instead.
*/
void QQuickText::doLayout()
{
+ forceLayout();
+}
+
+/*!
+ \qmlmethod QtQuick::Text::forceLayout()
+ \since 5.9
+
+ Triggers a re-layout of the displayed text.
+*/
+void QQuickText::forceLayout()
+{
Q_D(QQuickText);
d->updateSize();
}
@@ -2962,4 +2985,80 @@ void QQuickText::resetBottomPadding()
d->setBottomPadding(0, true);
}
+/*!
+ \qmlproperty string QtQuick::Text::fontInfo.family
+ \since 5.9
+
+ The family name of the font that has been resolved for the current font
+ and fontSizeMode.
+*/
+
+/*!
+ \qmlproperty string QtQuick::Text::fontInfo.styleName
+ \since 5.9
+
+ The style name of the font info that has been resolved for the current font
+ and fontSizeMode.
+*/
+
+/*!
+ \qmlproperty bool QtQuick::Text::fontInfo.bold
+ \since 5.9
+
+ The bold state of the font info that has been resolved for the current font
+ and fontSizeMode. This is true if the weight of the resolved font is bold or higher.
+*/
+
+/*!
+ \qmlproperty int QtQuick::Text::fontInfo.weight
+ \since 5.9
+
+ The weight of the font info that has been resolved for the current font
+ and fontSizeMode.
+*/
+
+/*!
+ \qmlproperty bool QtQuick::Text::fontInfo.italic
+ \since 5.9
+
+ The italic state of the font info that has been resolved for the current font
+ and fontSizeMode.
+*/
+
+/*!
+ \qmlproperty real QtQuick::Text::fontInfo.pointSize
+ \since 5.9
+
+ The pointSize of the font info that has been resolved for the current font
+ and fontSizeMode.
+*/
+
+/*!
+ \qmlproperty string QtQuick::Text::fontInfo.pixelSize
+ \since 5.9
+
+ The pixel size of the font info that has been resolved for the current font
+ and fontSizeMode.
+*/
+QJSValue QQuickText::fontInfo() const
+{
+ Q_D(const QQuickText);
+
+ QJSEngine *engine = qjsEngine(this);
+ if (!engine) {
+ qmlWarning(this) << "fontInfo: item has no JS engine";
+ return QJSValue();
+ }
+
+ QJSValue value = engine->newObject();
+ value.setProperty(QStringLiteral("family"), d->fontInfo.family());
+ value.setProperty(QStringLiteral("styleName"), d->fontInfo.styleName());
+ value.setProperty(QStringLiteral("bold"), d->fontInfo.bold());
+ value.setProperty(QStringLiteral("weight"), d->fontInfo.weight());
+ value.setProperty(QStringLiteral("italic"), d->fontInfo.italic());
+ value.setProperty(QStringLiteral("pointSize"), d->fontInfo.pointSizeF());
+ value.setProperty(QStringLiteral("pixelSize"), d->fontInfo.pixelSize());
+ return value;
+}
+
QT_END_NAMESPACE
diff --git a/src/quick/items/qquicktext_p.h b/src/quick/items/qquicktext_p.h
index 40dbd51f39..b190738cfb 100644
--- a/src/quick/items/qquicktext_p.h
+++ b/src/quick/items/qquicktext_p.h
@@ -98,6 +98,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickText : public QQuickImplicitSizeItem
Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged REVISION 6)
Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged REVISION 6)
+ Q_PROPERTY(QJSValue fontInfo READ fontInfo NOTIFY fontInfoChanged REVISION 9)
+
public:
QQuickText(QQuickItem *parent=0);
~QQuickText();
@@ -218,7 +220,8 @@ public:
QRectF boundingRect() const Q_DECL_OVERRIDE;
QRectF clipRect() const Q_DECL_OVERRIDE;
- Q_INVOKABLE void doLayout();
+ Q_INVOKABLE void doLayout(); // ### Qt 6: remove
+ Q_REVISION(9) Q_INVOKABLE void forceLayout();
RenderType renderType() const;
void setRenderType(RenderType renderType);
@@ -247,6 +250,8 @@ public:
void setBottomPadding(qreal padding);
void resetBottomPadding();
+ QJSValue fontInfo() const;
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
@@ -279,6 +284,7 @@ Q_SIGNALS:
Q_REVISION(6) void leftPaddingChanged();
Q_REVISION(6) void rightPaddingChanged();
Q_REVISION(6) void bottomPaddingChanged();
+ Q_REVISION(9) void fontInfoChanged();
protected:
QQuickText(QQuickTextPrivate &dd, QQuickItem *parent = 0);
diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h
index 0669bcf115..6456750359 100644
--- a/src/quick/items/qquicktext_p_p.h
+++ b/src/quick/items/qquicktext_p_p.h
@@ -122,6 +122,7 @@ public:
QString text;
QFont font;
QFont sourceFont;
+ QFontInfo fontInfo;
QTextLayout layout;
QTextLayout *elideLayout;
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 66936b0943..555fd233b3 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -1660,8 +1660,8 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source)
#if QT_CONFIG(texthtmlparser)
if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
// x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
- QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
- richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ const QString richtext = QLatin1String("<meta name=\"qrichtext\" content=\"1\" />")
+ + QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
hasData = true;
} else if (source->hasHtml() && d->acceptRichText) {
diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h
index 9bc5d057c7..70104a97e0 100644
--- a/src/quick/items/qquicktextcontrol_p.h
+++ b/src/quick/items/qquicktextcontrol_p.h
@@ -194,9 +194,11 @@ class QQuickTextEditMimeData : public QMimeData
public:
inline QQuickTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
- virtual QStringList formats() const;
+ QStringList formats() const override;
+
protected:
- virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
+ QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
+
private:
void setup() const;
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index e7492b97ae..c272503480 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -179,7 +179,7 @@ void QQuickTextDocumentWithImageResources::drawObject(
{
}
-QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format)
+QImage QQuickTextDocumentWithImageResources::image(const QTextImageFormat &format) const
{
QVariant res = resource(QTextDocument::ImageResource, QUrl(format.name()));
return res.value<QImage>();
@@ -211,7 +211,7 @@ QQuickPixmap *QQuickTextDocumentWithImageResources::loadPixmap(
if (p->isError()) {
if (!errors.contains(url)) {
errors.insert(url);
- qmlInfo(parent()) << p->error();
+ qmlWarning(parent()) << p->error();
}
}
return p;
diff --git a/src/quick/items/qquicktextdocument_p.h b/src/quick/items/qquicktextdocument_p.h
index 3ffedb5b96..1218b12b89 100644
--- a/src/quick/items/qquicktextdocument_p.h
+++ b/src/quick/items/qquicktextdocument_p.h
@@ -75,10 +75,10 @@ public:
void setText(const QString &);
int resourcesLoading() const { return outstanding; }
- QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format);
- void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format);
+ QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format) override;
+ void drawObject(QPainter *p, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format) override;
- QImage image(const QTextImageFormat &format);
+ QImage image(const QTextImageFormat &format) const;
public Q_SLOTS:
void clearResources();
@@ -87,7 +87,7 @@ Q_SIGNALS:
void imagesLoaded();
protected:
- QVariant loadResource(int type, const QUrl &name);
+ QVariant loadResource(int type, const QUrl &name) override;
QQuickPixmap *loadPixmap(QQmlContext *context, const QUrl &name);
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 94da44c00d..075fd48a46 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1743,7 +1743,7 @@ void QQuickTextEdit::select(int start, int end)
bool QQuickTextEdit::isRightToLeft(int start, int end)
{
if (start > end) {
- qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
+ qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
return false;
} else {
return getText(start, end).isRightToLeft();
@@ -2569,7 +2569,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption()
{
Q_Q(QQuickTextEdit);
QTextOption opt = document->defaultTextOption();
- int oldAlignment = opt.alignment();
+ const Qt::Alignment oldAlignment = opt.alignment();
Qt::LayoutDirection oldTextDirection = opt.textDirection();
QQuickTextEdit::HAlignment horizontalAlignment = q->effectiveHAlign();
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index b3c7da1e3e..a023ad8a8c 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1152,6 +1152,17 @@ bool QQuickTextInput::hasAcceptableInput() const
The corresponding handler is \c onEditingFinished.
*/
+/*!
+ \qmlsignal QtQuick::TextInput::textEdited()
+ \since 5.9
+
+ This signal is emitted whenever the text is edited. Unlike \c textChanged(),
+ this signal is not emitted when the text is changed programmatically, for example,
+ by changing the value of the \c text property or by calling \c clear().
+
+ The corresponding handler is \c onTextEdited.
+*/
+
#if QT_CONFIG(im)
Qt::InputMethodHints QQuickTextInputPrivate::effectiveInputMethodHints() const
{
@@ -1991,10 +2002,10 @@ void QQuickTextInput::selectAll()
bool QQuickTextInput::isRightToLeft(int start, int end)
{
if (start > end) {
- qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
+ qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
return false;
} else {
- return text().mid(start, end - start).isRightToLeft();
+ return text().midRef(start, end - start).isRightToLeft();
}
}
@@ -2846,7 +2857,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate)
// drawing boxes when using fonts that don't have glyphs for such
// characters)
QChar* uc = str.data();
- for (int i = 0; i < (int)str.length(); ++i) {
+ for (int i = 0; i < str.length(); ++i) {
if ((uc[i].unicode() < 0x20 && uc[i] != QChar::Tabulation)
|| uc[i] == QChar::LineSeparator
|| uc[i] == QChar::ParagraphSeparator
@@ -3232,7 +3243,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
commitPreedit();
#endif
- if (start < 0 || start > (int)m_text.length()){
+ if (start < 0 || start > m_text.length()) {
qWarning("QQuickTextInputPrivate::setSelection: Invalid start position");
return;
}
@@ -3241,7 +3252,7 @@ void QQuickTextInputPrivate::setSelection(int start, int length)
if (start == m_selstart && start + length == m_selend && m_cursor == m_selend)
return;
m_selstart = start;
- m_selend = qMin(start + length, (int)m_text.length());
+ m_selend = qMin(start + length, m_text.length());
m_cursor = m_selend;
} else if (length < 0){
if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart)
@@ -3499,7 +3510,7 @@ void QQuickTextInputPrivate::selectWordAtPos(int cursor)
The \a update value is currently unused.
*/
-bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bool /*edited*/)
+bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bool edited)
{
Q_Q(QQuickTextInput);
@@ -3570,6 +3581,8 @@ bool QQuickTextInputPrivate::finishChange(int validateFromState, bool update, bo
m_preeditDirty = false;
#endif
alignmentChanged = determineHorizontalAlignment();
+ if (edited)
+ emit q->textEdited();
emit q->textChanged();
}
@@ -3679,7 +3692,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
Q_ASSERT(!hasSelectedText()); // insert(), processInputMethodEvent() call removeSelectedText() first.
if (m_maskData) {
QString ms = maskString(m_cursor, s);
- for (int i = 0; i < (int) ms.length(); ++i) {
+ for (int i = 0; i < ms.length(); ++i) {
addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1));
addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1));
}
@@ -3690,9 +3703,10 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
} else {
int remaining = m_maxLength - m_text.length();
if (remaining != 0) {
- m_text.insert(m_cursor, s.left(remaining));
- for (int i = 0; i < (int) s.leftRef(remaining).length(); ++i)
- addCommand(Command(Insert, m_cursor++, s.at(i), -1, -1));
+ const QStringRef remainingStr = s.leftRef(remaining);
+ m_text.insert(m_cursor, remainingStr);
+ for (auto e : remainingStr)
+ addCommand(Command(Insert, m_cursor++, e, -1, -1));
m_textDirty = true;
}
}
@@ -3711,7 +3725,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
*/
void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
{
- if (m_cursor < (int) m_text.length()) {
+ if (m_cursor < m_text.length()) {
cancelPasswordEchoTimer();
Q_ASSERT(!hasSelectedText()); // del(), backspace() call removeSelectedText() first.
addCommand(Command((CommandType)((m_maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)),
@@ -3737,7 +3751,7 @@ void QQuickTextInputPrivate::internalDelete(bool wasBackspace)
*/
void QQuickTextInputPrivate::removeSelectedText()
{
- if (m_selstart < m_selend && m_selend <= (int) m_text.length()) {
+ if (m_selstart < m_selend && m_selend <= m_text.length()) {
cancelPasswordEchoTimer();
int i ;
if (m_selstart <= m_cursor && m_cursor < m_selend) {
@@ -4023,44 +4037,44 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
if (strIndex < str.length()) {
if (m_maskData[i].separator) {
s += m_maskData[i].maskChar;
- if (str[(int)strIndex] == m_maskData[i].maskChar)
+ if (str[strIndex] == m_maskData[i].maskChar)
strIndex++;
++i;
} else {
- if (isValidInput(str[(int)strIndex], m_maskData[i].maskChar)) {
+ if (isValidInput(str[strIndex], m_maskData[i].maskChar)) {
switch (m_maskData[i].caseMode) {
case MaskInputData::Upper:
- s += str[(int)strIndex].toUpper();
+ s += str[strIndex].toUpper();
break;
case MaskInputData::Lower:
- s += str[(int)strIndex].toLower();
+ s += str[strIndex].toLower();
break;
default:
- s += str[(int)strIndex];
+ s += str[strIndex];
}
++i;
} else {
// search for separator first
- int n = findInMask(i, true, true, str[(int)strIndex]);
+ int n = findInMask(i, true, true, str[strIndex]);
if (n != -1) {
- if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[(int)strIndex]))) {
+ if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
s += fill.midRef(i, n-i+1);
i = n + 1; // update i to find + 1
}
} else {
// search for valid m_blank if not
- n = findInMask(i, true, false, str[(int)strIndex]);
+ n = findInMask(i, true, false, str[strIndex]);
if (n != -1) {
s += fill.midRef(i, n-i);
switch (m_maskData[n].caseMode) {
case MaskInputData::Upper:
- s += str[(int)strIndex].toUpper();
+ s += str[strIndex].toUpper();
break;
case MaskInputData::Lower:
- s += str[(int)strIndex].toLower();
+ s += str[strIndex].toLower();
break;
default:
- s += str[(int)strIndex];
+ s += str[strIndex];
}
i = n + 1; // updates i to find + 1
}
@@ -4111,7 +4125,7 @@ QString QQuickTextInputPrivate::stripString(const QString &str) const
return str;
QString s;
- int end = qMin(m_maxLength, (int)str.length());
+ int end = qMin(m_maxLength, str.length());
for (int i = 0; i < end; ++i) {
if (m_maskData[i].separator)
s += m_maskData[i].maskChar;
@@ -4201,7 +4215,7 @@ void QQuickTextInputPrivate::internalRedo()
if (!isRedoAvailable())
return;
internalDeselect();
- while (m_undoState < (int)m_history.size()) {
+ while (m_undoState < m_history.size()) {
Command& cmd = m_history[m_undoState++];
switch (cmd.type) {
case Insert:
@@ -4228,7 +4242,7 @@ void QQuickTextInputPrivate::internalRedo()
m_cursor = cmd.pos;
break;
}
- if (m_undoState < (int)m_history.size()) {
+ if (m_undoState < m_history.size()) {
Command& next = m_history[m_undoState];
if (next.type != cmd.type
&& cmd.type < RemoveSelection
diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h
index f4545e1574..c4da807471 100644
--- a/src/quick/items/qquicktextinput_p.h
+++ b/src/quick/items/qquicktextinput_p.h
@@ -319,6 +319,7 @@ Q_SIGNALS:
void accepted();
void acceptableInputChanged();
Q_REVISION(2) void editingFinished();
+ Q_REVISION(9) void textEdited();
void colorChanged();
void selectionColorChanged();
void selectedTextColorChanged();
diff --git a/src/quick/items/qquicktextutil.cpp b/src/quick/items/qquicktextutil.cpp
index 8bcdb0b5f6..b07289f4a3 100644
--- a/src/quick/items/qquicktextutil.cpp
+++ b/src/quick/items/qquicktextutil.cpp
@@ -61,7 +61,7 @@ QQuickItem *QQuickTextUtil::createCursor(
item->setPosition(rectangle.topLeft());
item->setHeight(rectangle.height());
} else {
- qmlInfo(parent) << tr("%1 does not support loading non-visual cursor delegates.")
+ qmlWarning(parent) << tr("%1 does not support loading non-visual cursor delegates.")
.arg(QString::fromUtf8(className));
}
component->completeCreate();
@@ -72,7 +72,7 @@ QQuickItem *QQuickTextUtil::createCursor(
parent, SLOT(createCursor()), Qt::UniqueConnection);
return item;
}
- qmlInfo(parent, component->errors()) << tr("Could not load cursor delegate");
+ qmlWarning(parent, component->errors()) << tr("Could not load cursor delegate");
return item;
}
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 573440ff7f..d7171bf910 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -62,6 +62,8 @@ void QQuickViewPrivate::init(QQmlEngine* e)
if (engine.isNull())
engine = new QQmlEngine(q);
+ QQmlEngine::setContextForObject(contentItem, engine.data()->rootContext());
+
if (!engine.data()->incubationController())
engine.data()->setIncubationController(q->incubationController());
diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h
index 1fcc34e3a1..6d3b30e4c4 100644
--- a/src/quick/items/qquickview.h
+++ b/src/quick/items/qquickview.h
@@ -97,14 +97,14 @@ private Q_SLOTS:
void continueExecute();
protected:
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent*) Q_DECL_OVERRIDE;
-
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *) override;
+ void timerEvent(QTimerEvent*) override;
+
+ void keyPressEvent(QKeyEvent *) override;
+ void keyReleaseEvent(QKeyEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
private:
Q_DISABLE_COPY(QQuickView)
Q_DECLARE_PRIVATE(QQuickView)
diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h
index a090bdc9f7..f92d4b95d6 100644
--- a/src/quick/items/qquickview_p.h
+++ b/src/quick/items/qquickview_p.h
@@ -88,7 +88,7 @@ public:
~QQuickViewPrivate();
void execute();
- void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) Q_DECL_OVERRIDE;
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override;
void initResize();
void updateSize();
void setRootObject(QObject *);
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index e9108b7bda..f90384b3b6 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -453,13 +453,20 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size)
fboId = renderTargetId;
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
+ if (QQuickRenderControl::renderWindowFor(q)) {
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
+ renderer->setDevicePixelRatio(devicePixelRatio);
+ } else {
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()));
+ renderer->setDevicePixelRatio(1);
+ }
} else {
QRect rect(QPoint(0, 0), devicePixelRatio * size);
renderer->setDeviceRect(rect);
renderer->setViewportRect(rect);
+ renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
+ renderer->setDevicePixelRatio(devicePixelRatio);
}
- renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size));
- renderer->setDevicePixelRatio(devicePixelRatio);
context->renderNextFrame(renderer, fboId);
}
@@ -1796,7 +1803,7 @@ bool QQuickWindowPrivate::deliverWheelEvent(QQuickItem *item, QWheelEvent *event
QPointF p = item->mapFromScene(event->posF());
if (item->contains(p)) {
- QWheelEvent wheel(p, p, event->pixelDelta(), event->angleDelta(), event->delta(),
+ QWheelEvent wheel(p, event->globalPosF(), event->pixelDelta(), event->angleDelta(), event->delta(),
event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
wheel.setTimestamp(event->timestamp());
wheel.accept();
@@ -1895,8 +1902,6 @@ void QQuickWindowPrivate::deliverDelayedTouchEvent()
deliverPointerEvent(pointerEventInstance(e.data()));
}
-static bool qquickwindow_no_touch_compression = qEnvironmentVariableIsSet("QML_NO_TOUCH_COMPRESSION");
-
bool QQuickWindowPrivate::compressTouchEvent(QTouchEvent *event)
{
Q_Q(QQuickWindow);
@@ -1973,6 +1978,8 @@ void QQuickWindowPrivate::handleTouchEvent(QTouchEvent *event)
qCDebug(DBG_TOUCH) << event;
+ static bool qquickwindow_no_touch_compression = qEnvironmentVariableIsSet("QML_NO_TOUCH_COMPRESSION");
+
if (qquickwindow_no_touch_compression || pointerEventRecursionGuard) {
deliverPointerEvent(pointerEventInstance(event));
return;
@@ -2101,7 +2108,7 @@ void QQuickWindowPrivate::flushFrameSynchronousEvents()
There is a unique instance per QQuickPointerDevice, which is determined
from \a event's device.
*/
-QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event)
+QQuickPointerEvent *QQuickWindowPrivate::pointerEventInstance(QEvent *event) const
{
QQuickPointerDevice *dev = nullptr;
switch (event->type()) {
@@ -4165,6 +4172,28 @@ void QQuickWindow::resetOpenGLState()
*/
/*!
+ \qmlproperty variant Window::screen
+
+ The screen with which the window is associated.
+
+ If specified before showing a window, will result in the window being shown
+ on that screen, unless an explicit window position has been set. The value
+ must be an element from the Qt.application.screens array.
+
+ \note To ensure that the window is associated with the desired screen when
+ the underlying native window is created, make sure this property is set as
+ early as possible and that the setting of its value is not deferred. This
+ can be particularly important on embedded platforms without a windowing system,
+ where only one window per screen is allowed at a time. Setting the screen after
+ a window has been created does not move the window if the new screen is part of
+ the same virtual desktop as the old screen.
+
+ \since 5.9
+
+ \sa QWindow::setScreen(), QWindow::screen(), QScreen, Qt.application
+ */
+
+/*!
\qmlproperty Item Window::activeFocusItem
\since 5.1
diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h
index c1f690f325..27a73988ae 100644
--- a/src/quick/items/qquickwindow.h
+++ b/src/quick/items/qquickwindow.h
@@ -56,6 +56,7 @@ class QSGTexture;
class QInputMethodEvent;
class QQuickWindowPrivate;
class QQuickWindowAttached;
+class QOpenGLContext;
class QOpenGLFramebufferObject;
class QQmlIncubationController;
class QInputMethodEvent;
diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h
index 829fe53458..be915903c6 100644
--- a/src/quick/items/qquickwindow_p.h
+++ b/src/quick/items/qquickwindow_p.h
@@ -163,7 +163,7 @@ public:
void deliverDelayedTouchEvent();
// delivery of pointer events:
- QQuickPointerEvent *pointerEventInstance(QEvent *ev);
+ QQuickPointerEvent *pointerEventInstance(QEvent *ev) const;
void deliverPointerEvent(QQuickPointerEvent *);
void deliverTouchEvent(QQuickPointerTouchEvent *);
bool deliverTouchCancelEvent(QTouchEvent *);
@@ -200,7 +200,7 @@ public:
void setFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = 0);
void clearFocusInScope(QQuickItem *scope, QQuickItem *item, Qt::FocusReason reason, FocusOptions = 0);
static void notifyFocusChangesRecur(QQuickItem **item, int remaining);
- void clearFocusObject();
+ void clearFocusObject() override;
void updateFocusItemTransform();
diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp
index deb44ce34d..6211b7802f 100644
--- a/src/quick/items/qquickwindowmodule.cpp
+++ b/src/quick/items/qquickwindowmodule.cpp
@@ -73,6 +73,7 @@ QQuickWindowQmlImpl::QQuickWindowQmlImpl(QWindow *parent)
{
connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged);
connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged);
+ connect(this, &QWindow::screenChanged, this, &QQuickWindowQmlImpl::screenChanged);
}
void QQuickWindowQmlImpl::setVisible(bool visible)
@@ -100,6 +101,9 @@ void QQuickWindowQmlImpl::classBegin()
{
Q_D(QQuickWindowQmlImpl);
QQmlEngine* e = qmlEngine(this);
+
+ QQmlEngine::setContextForObject(contentItem(), e->rootContext());
+
//Give QQuickView behavior when created from QML with QQmlApplicationEngine
if (QCoreApplication::instance()->property("__qml_using_qqmlapplicationengine") == QVariant(true)) {
if (e && !e->incubationController())
@@ -170,6 +174,17 @@ void QQuickWindowQmlImpl::setWindowVisibility()
}
}
+QObject *QQuickWindowQmlImpl::screen() const
+{
+ return new QQuickScreenInfo(const_cast<QQuickWindowQmlImpl *>(this), QWindow::screen());
+}
+
+void QQuickWindowQmlImpl::setScreen(QObject *screen)
+{
+ QQuickScreenInfo *screenWrapper = qobject_cast<QQuickScreenInfo *>(screen);
+ QWindow::setScreen(screenWrapper ? screenWrapper->wrappedScreen() : nullptr);
+}
+
void QQuickWindowModule::defineModule()
{
const char uri[] = "QtQuick.Window";
@@ -181,7 +196,10 @@ void QQuickWindowModule::defineModule()
qmlRegisterRevision<QQuickWindow,2>(uri, 2, 2);
qmlRegisterType<QQuickWindowQmlImpl>(uri, 2, 1, "Window");
qmlRegisterType<QQuickWindowQmlImpl,1>(uri, 2, 2, "Window");
+ qmlRegisterType<QQuickWindowQmlImpl,2>(uri, 2, 3, "Window");
qmlRegisterUncreatableType<QQuickScreen>(uri, 2, 0, "Screen", QStringLiteral("Screen can only be used via the attached property."));
+ qmlRegisterUncreatableType<QQuickScreen,1>(uri, 2, 3, "Screen", QStringLiteral("Screen can only be used via the attached property."));
+ qmlRegisterUncreatableType<QQuickScreenInfo,2>(uri, 2, 3, "ScreenInfo", QStringLiteral("ScreenInfo can only be used via the attached property."));
}
QT_END_NAMESPACE
diff --git a/src/quick/items/qquickwindowmodule_p.h b/src/quick/items/qquickwindowmodule_p.h
index 8a6bbac412..16130bc8a0 100644
--- a/src/quick/items/qquickwindowmodule_p.h
+++ b/src/quick/items/qquickwindowmodule_p.h
@@ -67,6 +67,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowQmlImpl : public QQuickWindow, public Q
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged)
+ Q_PROPERTY(QObject *screen READ screen WRITE setScreen NOTIFY screenChanged REVISION 2)
public:
QQuickWindowQmlImpl(QWindow *parent = Q_NULLPTR);
@@ -74,11 +75,15 @@ public:
void setVisible(bool visible);
void setVisibility(Visibility visibility);
+ QObject *screen() const;
+ void setScreen(QObject *screen);
+
static QQuickWindowAttached *qmlAttachedProperties(QObject *object);
Q_SIGNALS:
void visibleChanged(bool arg);
void visibilityChanged(QWindow::Visibility visibility);
+ Q_REVISION(2) void screenChanged();
protected:
void classBegin() Q_DECL_OVERRIDE;