From 06378ac23a1f75b30da08cfa74b3e774aaba9298 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 11 Feb 2013 11:45:34 +0100 Subject: Doc: Update QtQuickTest documentation Add some information about -input, -functions and -help command-line options. Add some examples on how to run a single file and a single function for a QtQuickTest based test. Change-Id: Icd5f92bf8541aa412e2cd18d82dec16a85fe78c9 Reviewed-by: Alan Alpert --- src/quick/doc/src/appdevguide/qtquicktest.qdoc | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/quick/doc/src/appdevguide/qtquicktest.qdoc b/src/quick/doc/src/appdevguide/qtquicktest.qdoc index bf8ca86959..f6085764be 100644 --- a/src/quick/doc/src/appdevguide/qtquicktest.qdoc +++ b/src/quick/doc/src/appdevguide/qtquicktest.qdoc @@ -95,6 +95,20 @@ tst_example -input /mnt/SDCard/qmltests \endcode + It is also possible to run a single file using the \c{-input} option. + For example: + + \code + tst_example -input data/test.qml + \endcode + + \code + tst_example -input /test.qml + \endcode + + \note Specifying the full path to the qml test file is for example + needed for shadow builds. + If your test case needs QML imports, then you can add them as \c{-import} options to the test program command-line by adding the following line to your .pro file: @@ -102,4 +116,18 @@ \code IMPORTPATH += $$PWD/../imports/my_module1 $$PWD/../imports/my_module2 \endcode + + The \c{-functions} command-line option will return a list of the current + tests functions. It is possible to run a single test function using the name + of the test function as an argument. For example: + + \code + tst_example Test_Name::function1 + \endcode + + The \c{-help} command-line option will return all the options available. + + \code + tst_example -help + \endcode */ -- cgit v1.2.3 From 36ef4052e0018c396b42cdef950e80e2efce3778 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 19 Feb 2013 10:26:44 +0100 Subject: Fix embedding images in text elements It seems that the the inner target rect has either been added recently or its default has been changed to something invalid, because we need to set it to the same as targetRect for the image to show up at all. Task-number: QTBUG-29560 Change-Id: I0fe6b7c5ab07afc780b8ea33a7ccc210861e0821 Reviewed-by: Gunnar Sletta --- src/quick/items/qquicktextnode.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp index 4d3f97adaf..5e1b20c032 100644 --- a/src/quick/items/qquicktextnode.cpp +++ b/src/quick/items/qquicktextnode.cpp @@ -1105,6 +1105,7 @@ void QQuickTextNode::addImage(const QRectF &rect, const QImage &image) QSGTexture *texture = m_context->createTexture(image); m_textures.append(texture); node->setTargetRect(rect); + node->setInnerTargetRect(rect); node->setTexture(texture); appendChildNode(node); node->update(); -- cgit v1.2.3 From c3f797695707d807ac19736cf7d12f1cc0f6bded Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 14 Feb 2013 02:36:31 -0800 Subject: Clarify Component::createObject docs Task-number: QTBUG-29650 Change-Id: Ie6f9027ff779f8a513a52b425d9a393c0ecd9c7d Reviewed-by: Jerome Pasion --- src/qml/qml/qqmlcomponent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index b335d6f402..5c123a678b 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1137,9 +1137,9 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent) As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a map of initial property values for the created object. These values are applied before object - creation is finalized. (This is more efficient than setting property values after object creation, + creation is finalized. This is more efficient than setting property values after object creation, particularly where large sets of property values are defined, and also allows property bindings - to be set up before the object is created.) + to be set up (using \l{Qt::binding}{Qt.binding}) before the object is created. The \a properties argument is specified as a map of property-value items. For example, the code below creates an object with initial \c x and \c y values of 100 and 200, respectively: -- cgit v1.2.3 From ce447efe1dc546ff5f7d3b3d327f1759231124f2 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 15 Feb 2013 00:50:58 +0100 Subject: Docs: Slow Down Animations only exists in qml1 The functionality was part of qmlviewer. Change-Id: Iaf2e19acf54e6773e2b79659f4dc51b92de91dd4 Reviewed-by: Jerome Pasion --- src/quick/doc/src/appdevguide/debugging.qdoc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/quick/doc/src/appdevguide/debugging.qdoc b/src/quick/doc/src/appdevguide/debugging.qdoc index 86a577f069..94ce13459c 100644 --- a/src/quick/doc/src/appdevguide/debugging.qdoc +++ b/src/quick/doc/src/appdevguide/debugging.qdoc @@ -123,14 +123,6 @@ function f() { \c console.exception prints an error message together with the stack trace of JavaScript execution at the point where it is called. -\section1 Debugging Transitions - -When a transition doesn't look quite right, it can be helpful to view it in slow -motion to see what is happening more clearly. This functionality is supported -in the \l{qtquick-qmlscene.html}{QML Scene} tool: to enable this, -click on the "Debugging" menu, then "Slow Down Animations". - - \section1 Debugging module imports The \c QML_IMPORT_TRACE environment variable can be set to enable debug output -- cgit v1.2.3 From 35989314618c9fc0ef495d2903fb9afda65dcb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 19 Feb 2013 14:47:12 +0100 Subject: Fixed build when Qt is configured with -no-opengl. Task-number: QTBUG-28849 Change-Id: I331ebca76892ce7ffbc6f8e03ff4afe0c8e28d5e Reviewed-by: Gunnar Sletta --- examples/examples.pro | 7 +++---- examples/qml/qml.pro | 6 +++--- src/src.pro | 2 +- tools/tools.pro | 11 ++++------- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/examples.pro b/examples/examples.pro index 1bcc66d164..0712e81552 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs -SUBDIRS += \ - qmltest \ - qml \ - quick +qtHaveModule(qmltest): SUBDIRS += qmltest +SUBDIRS += qml +qtHaveModule(quick): SUBDIRS += quick diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro index e6591c895f..34b2622b98 100644 --- a/examples/qml/qml.pro +++ b/examples/qml/qml.pro @@ -1,11 +1,11 @@ TEMPLATE = subdirs +qtHaveModule(quick): SUBDIRS += networkaccessmanagerfactory xmlhttprequest + SUBDIRS += \ - networkaccessmanagerfactory \ plugins \ referenceexamples \ - shell \ - xmlhttprequest + shell EXAMPLE_FILES = \ dynamicscene \ diff --git a/src/src.pro b/src/src.pro index f593eb8968..758482304f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -3,7 +3,7 @@ CONFIG += ordered SUBDIRS += \ qml -qtHaveModule(gui) { +qtHaveModule(gui):contains(QT_CONFIG, opengl(es1|es2)?) { SUBDIRS += \ quick \ qmltest \ diff --git a/tools/tools.pro b/tools/tools.pro index c193cc97d0..86e2f3804f 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -1,11 +1,8 @@ TEMPLATE = subdirs +qtHaveModule(quick): SUBDIRS += qmlscene qmlplugindump +qtHaveModule(qmltest): SUBDIRS += qmltestrunner SUBDIRS += \ - qmlscene \ - qmlplugindump \ qmlmin \ qmlprofiler \ - qmlbundle \ - qmltestrunner -qtHaveModule(widgets): SUBDIRS += qmleasing - - + qmlbundle +qtHaveModule(quick):qtHaveModule(widgets): SUBDIRS += qmleasing -- cgit v1.2.3 From a76e297b30686557de1a773ba9752b23b9700b13 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 19 Feb 2013 18:05:10 +0100 Subject: Fix QQuickTimeLine::accel() & accelDistance() Do not compare real numbers (velocities, accelerations and distances) to 0.0f, but use qFuzzyIsNull() and qIsNaN(). Task-number: QTBUG-29144 Change-Id: I8fe7ebfbc9f665fa2507e66344d081ef2f43b181 Reviewed-by: Alan Alpert Reviewed-by: Frederik Gladhorn --- src/quick/util/qquicktimeline.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp index a3a9220f03..f1d7e19dc2 100644 --- a/src/quick/util/qquicktimeline.cpp +++ b/src/quick/util/qquicktimeline.cpp @@ -49,6 +49,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -386,7 +387,7 @@ void QQuickTimeLine::set(QQuickTimeLineValue &timeLineValue, qreal value) */ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration) { - if (acceleration == 0.0f) + if (qFuzzyIsNull(acceleration) || qIsNaN(acceleration)) return -1; if ((velocity > 0.0f) == (acceleration > 0.0f)) @@ -412,7 +413,7 @@ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qr */ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) { - if (maxDistance == 0.0f || acceleration == 0.0f) + if (qFuzzyIsNull(maxDistance) || qIsNaN(maxDistance) || qFuzzyIsNull(acceleration) || qIsNaN(acceleration)) return -1; Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f); @@ -441,7 +442,7 @@ int QQuickTimeLine::accel(QQuickTimeLineValue &timeLineValue, qreal velocity, qr */ int QQuickTimeLine::accelDistance(QQuickTimeLineValue &timeLineValue, qreal velocity, qreal distance) { - if (distance == 0.0f || velocity == 0.0f) + if (qFuzzyIsNull(distance) || qIsNaN(distance) || qFuzzyIsNull(velocity) || qIsNaN(velocity)) return -1; Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f)); -- cgit v1.2.3 From 9565fb9f360b053f47aa46c5112c86925c7e225f Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 19 Feb 2013 11:16:56 +0100 Subject: Doc: Fix paths and add missing project files for QML and Quick examples This change fixes a number of 'example path does not exist' warnings from qdoc, and adds .qmlproject files for pure qml examples so they'll appear correctly in the example manifest files. Change-Id: Id0a424c4826fb5d8ebe6c3309bf33b976ff8477c Reviewed-by: Geir Vattekar Reviewed-by: Jerome Pasion --- examples/qml/dynamicscene/dynamicscene.qmlproject | 16 ++++++++++++++++ examples/qml/i18n/i18n.qmlproject | 16 ++++++++++++++++ examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc | 2 +- examples/quick/localstorage/doc/src/localstorage.qdoc | 6 +++--- .../painteditem/textballoons/doc/src/textballoons.qdoc | 4 ++-- .../dynamicview/dynamicview1/dynamicview1.qmlproject | 16 ++++++++++++++++ .../dynamicview/dynamicview2/dynamicview2.qmlproject | 16 ++++++++++++++++ .../dynamicview/dynamicview3/dynamicview3.qmlproject | 16 ++++++++++++++++ .../dynamicview/dynamicview4/dynamicview4.qmlproject | 16 ++++++++++++++++ 9 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 examples/qml/dynamicscene/dynamicscene.qmlproject create mode 100644 examples/qml/i18n/i18n.qmlproject create mode 100644 examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qmlproject create mode 100644 examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qmlproject create mode 100644 examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qmlproject create mode 100644 examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qmlproject diff --git a/examples/qml/dynamicscene/dynamicscene.qmlproject b/examples/qml/dynamicscene/dynamicscene.qmlproject new file mode 100644 index 0000000000..52ac474383 --- /dev/null +++ b/examples/qml/dynamicscene/dynamicscene.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dynamicscene.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/i18n/i18n.qmlproject b/examples/qml/i18n/i18n.qmlproject new file mode 100644 index 0000000000..7ee5b76b92 --- /dev/null +++ b/examples/qml/i18n/i18n.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "i18n.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc index 60a9725e53..9e2dc01667 100644 --- a/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc +++ b/examples/quick/demos/calqlatr/doc/src/calqlatr.qdoc @@ -27,7 +27,7 @@ /*! \title QML Demo - Calqlatr - \example demos/calqlatr + \example quick/demos/calqlatr \brief This is an example calculator written in QML. \image qml-calqlatr-demo-small.png \ingroup qmldemos diff --git a/examples/quick/localstorage/doc/src/localstorage.qdoc b/examples/quick/localstorage/doc/src/localstorage.qdoc index d3b7fef798..f4dfa56dcf 100644 --- a/examples/quick/localstorage/doc/src/localstorage.qdoc +++ b/examples/quick/localstorage/doc/src/localstorage.qdoc @@ -26,13 +26,13 @@ ****************************************************************************/ /*! \title QtQuick Examples - Local Storage - \example localstorage - \brief This is a collection of QML local storage examples + \example quick/localstorage + \brief A collection of QML local storage examples. \image qml-localstorage-example.png This is a collection of small QML examples relating to local storage functionality. - Hello World demos creating a simple SQL table and how to do inserting/selecting operations. + \e {Hello World} demonstrates creating a simple SQL table and doing insert/select operations. */ diff --git a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc index e733512712..6f1d751a5f 100644 --- a/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc +++ b/examples/quick/painteditem/textballoons/doc/src/textballoons.qdoc @@ -28,8 +28,8 @@ /*! \title Scenegraph Painted Item Example - \brief Shows how to implement QPainter-based custom scenegraph items - \example quick/painteditem/textballoons + \brief Shows how to implement QPainter-based custom scenegraph items. + \example quick/customitems/painteditem \ingroup qtquickexamples The Painted Item example shows how to use the QML Scene Graph framework to diff --git a/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qmlproject b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qmlproject new file mode 100644 index 0000000000..aa20fbadc0 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview1/dynamicview1.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dynamicview.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qmlproject b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qmlproject new file mode 100644 index 0000000000..aa20fbadc0 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview2/dynamicview2.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dynamicview.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qmlproject b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qmlproject new file mode 100644 index 0000000000..aa20fbadc0 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview3.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dynamicview.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qmlproject b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qmlproject new file mode 100644 index 0000000000..aa20fbadc0 --- /dev/null +++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview4.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dynamicview.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} -- cgit v1.2.3 From fb7ab18fa799032f37fd6f78ab34b76aff91ed6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20E=2E=20Narv=C3=A1ez?= Date: Sat, 16 Feb 2013 10:42:23 -0500 Subject: Add Test for Animating Qml Dynamic Properties using QPropertyAnimation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test case for calling QQmlVMEMetaObject::metaCall from QPropertyAnimationPrivate::updateProperty Task-number: QTBUG-29082 Change-Id: Iecab74132eb3a843e53356effe3b6bbe4d5a8fb2 Reviewed-by: Alan Alpert Reviewed-by: Jędrzej Nowacki --- .../qquickdynamicpropertyanimation/data/MyItem.qml | 13 ++ .../qquickdynamicpropertyanimation.pro | 14 +++ .../tst_qquickdynamicpropertyanimation.cpp | 138 +++++++++++++++++++++ tests/auto/quick/quick.pro | 1 + 4 files changed, 166 insertions(+) create mode 100644 tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml create mode 100644 tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro create mode 100644 tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml b/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml new file mode 100644 index 0000000000..2fc8b90ac8 --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/data/MyItem.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item +{ + property int testInt: 0 + property double testDouble: 0.0 + property real testReal: 0.0 + property point testPoint: Qt.point(0, 0) + property size testSize: Qt.size(0, 0) + property rect testRect: Qt.rect(0, 0, 0, 0) + property color testColor: Qt.rgba(0.0, 0.0, 0.0, 0.0) + property var testVar: 0 +} diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro b/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro new file mode 100644 index 0000000000..a67daa91ba --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/qquickdynamicpropertyanimation.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickdynamicpropertyanimation +SOURCES += tst_qquickdynamicpropertyanimation.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +TESTDATA = data/* + +CONFIG += parallel_test + +QT += core gui qml quick testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp new file mode 100644 index 0000000000..78f2d17e9b --- /dev/null +++ b/tests/auto/quick/qquickdynamicpropertyanimation/tst_qquickdynamicpropertyanimation.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../shared/util.h" + +class tst_qquickdynamicpropertyanimation : public QQmlDataTest +{ + Q_OBJECT +public: + tst_qquickdynamicpropertyanimation() {} + +private: + template + void dynamicPropertyAnimation(const QByteArray & propertyName, T toValue) + { + QQuickView view(testFileUrl("MyItem.qml")); + QQuickItem * item = qobject_cast(view.rootObject()); + QVERIFY(item); + QQmlProperty testProp(item, propertyName); + QPropertyAnimation animation(item, propertyName, this); + animation.setEndValue(toValue); + QVERIFY(animation.targetObject() == item); + QVERIFY(animation.propertyName() == propertyName); + QVERIFY(animation.endValue().value() == toValue); + animation.start(); + QVERIFY(animation.state() == QAbstractAnimation::Running); + QTest::qWait(animation.duration()); + QTRY_COMPARE(testProp.read().value(), toValue); + } + +private slots: + void initTestCase() + { + QQmlEngine engine; // ensure types are registered + QQmlDataTest::initTestCase(); + } + + void dynamicIntPropertyAnimation(); + void dynamicDoublePropertyAnimation(); + void dynamicRealPropertyAnimation(); + void dynamicPointPropertyAnimation(); + void dynamicSizePropertyAnimation(); + void dynamicRectPropertyAnimation(); + void dynamicColorPropertyAnimation(); + void dynamicVarPropertyAnimation(); +}; + +void tst_qquickdynamicpropertyanimation::dynamicIntPropertyAnimation() +{ + dynamicPropertyAnimation("testInt", 1); +} + +void tst_qquickdynamicpropertyanimation::dynamicDoublePropertyAnimation() +{ + dynamicPropertyAnimation("testDouble", 1.0); +} + +void tst_qquickdynamicpropertyanimation::dynamicRealPropertyAnimation() +{ + dynamicPropertyAnimation("testReal", qreal(1.0)); +} + +void tst_qquickdynamicpropertyanimation::dynamicPointPropertyAnimation() +{ + dynamicPropertyAnimation("testPoint", QPoint(1, 1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicSizePropertyAnimation() +{ + dynamicPropertyAnimation("testSize", QSize(1,1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicRectPropertyAnimation() +{ + dynamicPropertyAnimation("testRect", QRect(1, 1, 1, 1)); +} + +void tst_qquickdynamicpropertyanimation::dynamicColorPropertyAnimation() +{ + dynamicPropertyAnimation("testColor", QColor::fromRgbF(1.0, 1.0, 1.0, 1.0)); +} + +void tst_qquickdynamicpropertyanimation::dynamicVarPropertyAnimation() +{ + dynamicPropertyAnimation("testVar", QVariant::fromValue(1)); +} + +QTEST_MAIN(tst_qquickdynamicpropertyanimation) + +#include "tst_qquickdynamicpropertyanimation.moc" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 3ed6ca8c99..c4a4173e0f 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -35,6 +35,7 @@ QUICKTESTS = \ qquickanchors \ qquickanimatedimage \ qquickanimatedsprite \ + qquickdynamicpropertyanimation \ qquickborderimage \ qquickwindow \ qquickdrag \ -- cgit v1.2.3 From b9e05ba421c97ec60f4b308efaaed32c1a35b0b8 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 21 Feb 2013 13:17:45 +0100 Subject: Stabilize clicking in QQuickTextEdit test This test would try to emulate mouse clicks and not wait inbetween. That can lead to clicks spilling over to the next mouse event. Change-Id: I320f86453215190a1c694ba49c0fc3831dcb60b9 Reviewed-by: Pierre Rossi --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 78ae94e53e..bf7539e449 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -1872,6 +1872,8 @@ void tst_qquicktextedit::mouseSelection() QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2); QTRY_COMPARE(textEditObject->selectedText(), selectedText); + QTest::qWait(QGuiApplication::styleHints()->mouseDoubleClickInterval() + 10); + // Clicking and shift to clicking between the same points should select the same text. textEditObject->setCursorPosition(0); if (clicks > 1) -- cgit v1.2.3 From b939bc6300d79862340ff35dc8910663bda5744f Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 21 Feb 2013 13:13:04 +0100 Subject: Typos: tripple->triple This enables grepping. Change-Id: Ibf85800b998a02645c50b1b84d42088d16091378 Reviewed-by: Pierre Rossi --- src/quick/items/qquicktextcontrol.cpp | 36 ++++++++++++++++----------------- src/quick/items/qquicktextcontrol_p_p.h | 6 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 02aeaa7e35..6cce3cc25a 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -359,7 +359,7 @@ void QQuickTextControlPrivate::setCursorPosition(int pos, QTextCursor::MoveMode if (mode != QTextCursor::KeepAnchor) { selectedWordOnDoubleClick = QTextCursor(); - selectedBlockOnTrippleClick = QTextCursor(); + selectedBlockOnTripleClick = QTextCursor(); } } @@ -527,18 +527,18 @@ void QQuickTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition Q_Q(QQuickTextControl); // if inside the initial selected line keep that - if (suggestedNewPosition >= selectedBlockOnTrippleClick.selectionStart() - && suggestedNewPosition <= selectedBlockOnTrippleClick.selectionEnd()) { - q->setTextCursor(selectedBlockOnTrippleClick); + if (suggestedNewPosition >= selectedBlockOnTripleClick.selectionStart() + && suggestedNewPosition <= selectedBlockOnTripleClick.selectionEnd()) { + q->setTextCursor(selectedBlockOnTripleClick); return; } - if (suggestedNewPosition < selectedBlockOnTrippleClick.position()) { - cursor.setPosition(selectedBlockOnTrippleClick.selectionEnd()); + if (suggestedNewPosition < selectedBlockOnTripleClick.position()) { + cursor.setPosition(selectedBlockOnTripleClick.selectionEnd()); cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor); } else { - cursor.setPosition(selectedBlockOnTrippleClick.selectionStart()); + cursor.setPosition(selectedBlockOnTripleClick.selectionStart()); cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); @@ -791,8 +791,8 @@ void QQuickTextControl::timerEvent(QTimerEvent *e) d->cursorOn = !d->cursorOn; d->repaintCursor(); - } else if (e->timerId() == d->trippleClickTimer.timerId()) { - d->trippleClickTimer.stop(); + } else if (e->timerId() == d->tripleClickTimer.timerId()) { + d->tripleClickTimer.stop(); } } @@ -1022,17 +1022,17 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po commitPreedit(); #endif - if (trippleClickTimer.isActive() - && ((pos - trippleClickPoint).toPoint().manhattanLength() < qApp->styleHints()->startDragDistance())) { + if (tripleClickTimer.isActive() + && ((pos - tripleClickPoint).toPoint().manhattanLength() < qApp->styleHints()->startDragDistance())) { cursor.movePosition(QTextCursor::StartOfBlock); cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); - selectedBlockOnTrippleClick = cursor; + selectedBlockOnTripleClick = cursor; anchorOnMousePress = QString(); - trippleClickTimer.stop(); + tripleClickTimer.stop(); } else { int cursorPos = q->hitTest(pos, Qt::FuzzyHit); if (cursorPos == -1) { @@ -1046,7 +1046,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); } - if (selectedBlockOnTrippleClick.hasSelection()) + if (selectedBlockOnTripleClick.hasSelection()) extendBlockwiseSelection(cursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(cursorPos, pos.x()); @@ -1079,7 +1079,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou if (!(mousePressed || editable || selectedWordOnDoubleClick.hasSelection() - || selectedBlockOnTrippleClick.hasSelection())) + || selectedBlockOnTripleClick.hasSelection())) return; const QTextCursor oldSelection = cursor; @@ -1114,7 +1114,7 @@ void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mou selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); } - if (selectedBlockOnTrippleClick.hasSelection()) + if (selectedBlockOnTripleClick.hasSelection()) extendBlockwiseSelection(newCursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(newCursorPos, mouseX); @@ -1219,8 +1219,8 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin cursorIsFocusIndicator = false; selectedWordOnDoubleClick = cursor; - trippleClickPoint = pos; - trippleClickTimer.start(qApp->styleHints()->mouseDoubleClickInterval(), q); + tripleClickPoint = pos; + tripleClickTimer.start(qApp->styleHints()->mouseDoubleClickInterval(), q); if (doEmit) { selectionChanged(); #ifndef QT_NO_CLIPBOARD diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h index 059ccd36bf..a0727c7a71 100644 --- a/src/quick/items/qquicktextcontrol_p_p.h +++ b/src/quick/items/qquicktextcontrol_p_p.h @@ -126,7 +126,7 @@ public: void cancelPreedit(); #endif - QPointF trippleClickPoint; + QPointF tripleClickPoint; QPointF mousePressPos; QTextCharFormat lastCharFormat; @@ -134,12 +134,12 @@ public: QTextDocument *doc; QTextCursor cursor; QTextCursor selectedWordOnDoubleClick; - QTextCursor selectedBlockOnTrippleClick; + QTextCursor selectedBlockOnTripleClick; QString anchorOnMousePress; QString linkToCopy; QBasicTimer cursorBlinkTimer; - QBasicTimer trippleClickTimer; + QBasicTimer tripleClickTimer; #ifndef QT_NO_IM int preeditCursor; -- cgit v1.2.3 From 7a1282a9edd8afa4645d7d449ca2ed3746fb8d71 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 15 Feb 2013 21:29:32 +1000 Subject: MouseArea shouldn't grab the mouse until there is an effective drag. A MouseArea shouldn't prevent a parent MouseArea or Flickable from handling a drag event unless it is going to do something useful with it. Task-number: 29717 Change-Id: I24016994f6cf9116382ef7faeb50b10e5716e10e Reviewed-by: Alan Alpert --- src/quick/items/qquickmousearea.cpp | 49 ++++++---------- .../qquickmousearea/data/nestedStopAtBounds.qml | 44 ++++++++++++++ .../quick/qquickmousearea/tst_qquickmousearea.cpp | 68 ++++++++++++++++++++++ 3 files changed, 131 insertions(+), 30 deletions(-) create mode 100644 tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index e75a60181f..2fa52d9ed2 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -797,9 +797,6 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) curLocalPos = event->windowPos(); } - qreal dx = qAbs(curLocalPos.x() - startLocalPos.x()); - qreal dy = qAbs(curLocalPos.y() - startLocalPos.y()); - if (keepMouseGrab() && d->stealMouse && !d->drag->active()) d->drag->setActive(true); @@ -807,38 +804,30 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event) ? d->drag->target()->parentItem()->mapFromScene(d->targetStartPos) : d->targetStartPos; - QPointF dragPos = d->drag->target()->position(); - bool dragX = drag()->axis() & QQuickDrag::XAxis; bool dragY = drag()->axis() & QQuickDrag::YAxis; - if (dragX && d->drag->active()) { - qreal x = (curLocalPos.x() - startLocalPos.x()) + startPos.x(); - if (x < drag()->xmin()) - x = drag()->xmin(); - else if (x > drag()->xmax()) - x = drag()->xmax(); - dragPos.setX(x); + QPointF dragPos = d->drag->target()->position(); + if (dragX) { + dragPos.setX(qBound( + d->drag->xmin(), + startPos.x() + curLocalPos.x() - startLocalPos.x(), + d->drag->xmax())); } - if (dragY && d->drag->active()) { - qreal y = (curLocalPos.y() - startLocalPos.y()) + startPos.y(); - if (y < drag()->ymin()) - y = drag()->ymin(); - else if (y > drag()->ymax()) - y = drag()->ymax(); - dragPos.setY(y); + if (dragY) { + dragPos.setY(qBound( + d->drag->ymin(), + startPos.y() + curLocalPos.y() - startLocalPos.y(), + d->drag->ymax())); } - d->drag->target()->setPosition(dragPos); - - if (!keepMouseGrab()) { - bool xDragged = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event); - bool yDragged = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event); - if ((!dragY && !yDragged && dragX && xDragged) - || (!dragX && !xDragged && dragY && yDragged) - || (dragX && dragY && (xDragged || yDragged))) { - setKeepMouseGrab(true); - d->stealMouse = true; - } + if (d->drag->active()) + d->drag->target()->setPosition(dragPos); + + if (!keepMouseGrab() + && (QQuickWindowPrivate::dragOverThreshold(dragPos.x() - startPos.x(), Qt::XAxis, event) + || QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event))) { + setKeepMouseGrab(true); + d->stealMouse = true; } d->moved = true; diff --git a/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml new file mode 100644 index 0000000000..1fd39bb321 --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/nestedStopAtBounds.qml @@ -0,0 +1,44 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 400 + + MouseArea { + id: outer + objectName: "outer" + x: 50 + y: 50 + width: 300 + height: 300 + + drag.target: outer + drag.filterChildren: true + + Rectangle { + anchors.fill: parent + color: "yellow" + } + + MouseArea { + id: inner + objectName: "inner" + + x: 0 + y: 0 + width: 200 + height: 200 + + drag.target: inner + drag.minimumX: 0 + drag.maximumX: 100 + drag.minimumY: 0 + drag.maximumY: 100 + + Rectangle { + anchors.fill: parent + color: "blue" + } + } + } +} diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 37ce0fd394..ef7dc72345 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -89,6 +89,8 @@ private slots: void cursorShape(); #endif void moveAndReleaseWithoutPress(); + void nestedStopAtBounds(); + void nestedStopAtBounds_data(); private: void acceptedButton_data(); @@ -1426,6 +1428,72 @@ void tst_QQuickMouseArea::moveAndReleaseWithoutPress() delete window; } +void tst_QQuickMouseArea::nestedStopAtBounds_data() +{ + QTest::addColumn("transpose"); + QTest::addColumn("invert"); + + QTest::newRow("left") << false << false; + QTest::newRow("right") << false << true; + QTest::newRow("top") << true << false; + QTest::newRow("bottom") << true << true; +} + +void tst_QQuickMouseArea::nestedStopAtBounds() +{ + QFETCH(bool, transpose); + QFETCH(bool, invert); + + QQuickView view; + view.setSource(testFileUrl("nestedStopAtBounds.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(view.rootObject()); + + QQuickMouseArea *outer = view.rootObject()->findChild("outer"); + QVERIFY(outer); + + QQuickMouseArea *inner = outer->findChild("inner"); + QVERIFY(inner); + inner->drag()->setAxis(transpose ? QQuickDrag::YAxis : QQuickDrag::XAxis); + inner->setX(invert ? 100 : 0); + inner->setY(invert ? 100 : 0); + + const int threshold = qApp->styleHints()->startDragDistance(); + + QPoint position(200, 200); + int &axis = transpose ? position.ry() : position.rx(); + + // drag toward the aligned boundary. Outer mouse area dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? threshold * 2 : -threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? threshold : -threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->drag()->active(), true); + QCOMPARE(inner->drag()->active(), false); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->drag()->active()); + + axis = 200; + outer->setX(50); + outer->setY(50); + + // drag away from the aligned boundary. Inner mouse area dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? -threshold * 2 : threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? -threshold : threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->drag()->active(), false); + QCOMPARE(inner->drag()->active(), true); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" -- cgit v1.2.3 From 6ad4a61d482d895d135a7a281115bf104e0b9a90 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Sat, 16 Feb 2013 17:21:28 +1000 Subject: Flickable shouldn't grab the mouse until it starts an effective move. If the boundBehavior prevents the flickable from moving its content item in response to a drag it shouldn't grab the mouse as that will prevent a parent MouseArea or Flickable from handling the drag. Task-number: QTBUG-29718 Change-Id: I3a1be4ed0132b91dca2fb0387ecefd39275a52da Reviewed-by: Alan Alpert --- src/quick/items/qquickflickable.cpp | 47 +++++++------- .../qquickflickable/data/nestedStopAtBounds.qml | 37 +++++++++++ .../quick/qquickflickable/tst_qquickflickable.cpp | 71 ++++++++++++++++++++++ .../quick/qquickgridview/tst_qquickgridview.cpp | 12 ++-- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 4 +- 5 files changed, 137 insertions(+), 34 deletions(-) create mode 100644 tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index c1e8dd378c..3482db0dfe 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1018,9 +1018,9 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (q->yflick()) { qreal dy = event->localPos().y() - pressPos.y(); bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event); + if (vData.dragStartOffset == 0) + vData.dragStartOffset = dy; if (overThreshold || elapsedSincePress > 200) { - if (!vMoved) - vData.dragStartOffset = dy; qreal newY = dy + vData.pressPos - vData.dragStartOffset; // Recalculate bounds in case margins have changed, but use the content // size estimate taken at the start of the drag in case the drag causes @@ -1031,23 +1031,20 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QQuickFlickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newY <= maxY) { + newY = maxY; + rejectY = vData.pressPos == maxY && dy < 0; + } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newY >= minY) { + newY = minY; + rejectY = vData.pressPos == minY && dy > 0; } if (!rejectY && stealMouse && dy != 0.0) { clearTimeline(); vData.move.setValue(newY); vMoved = true; } - if (overThreshold) + if (!rejectY && overThreshold) stealY = true; } } @@ -1055,9 +1052,9 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) if (q->xflick()) { qreal dx = event->localPos().x() - pressPos.x(); bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event); + if (hData.dragStartOffset == 0) + hData.dragStartOffset = dx; if (overThreshold || elapsedSincePress > 200) { - if (!hMoved) - hData.dragStartOffset = dx; qreal newX = dx + hData.pressPos - hData.dragStartOffset; const qreal minX = hData.dragMinBound + hData.startMargin; const qreal maxX = hData.dragMaxBound - hData.endMargin; @@ -1065,24 +1062,22 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QQuickFlickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newX <= maxX) { + newX = maxX; + rejectX = hData.pressPos == maxX && dx < 0; + } + if (boundsBehavior == QQuickFlickable::StopAtBounds && newX >= minX) { + newX = minX; + rejectX = hData.pressPos == minX && dx > 0; } + if (!rejectX && stealMouse && dx != 0.0) { clearTimeline(); hData.move.setValue(newX); hMoved = true; } - if (overThreshold) + if (!rejectX && overThreshold) stealX = true; } } diff --git a/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml new file mode 100644 index 0000000000..59318e5b95 --- /dev/null +++ b/tests/auto/quick/qquickflickable/data/nestedStopAtBounds.qml @@ -0,0 +1,37 @@ +import QtQuick 2.0 + +Flickable { + id: outer + objectName: "outerFlickable" + width: 400 + height: 400 + contentX: 50 + contentY: 50 + contentWidth: 500 + contentHeight: 500 + flickableDirection: inner.flickableDirection + + Rectangle { + x: 100 + y: 100 + width: 300 + height: 300 + + color: "yellow" + Flickable { + id: inner + objectName: "innerFlickable" + anchors.fill: parent + contentX: 100 + contentY: 100 + contentWidth: 400 + contentHeight: 400 + boundsBehavior: Flickable.StopAtBounds + Rectangle { + anchors.fill: parent + anchors.margins: 100 + color: "blue" + } + } + } +} diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 784988b913..57c4c12264 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -91,6 +91,8 @@ private slots: void cancelOnMouseGrab(); void clickAndDragWhenTransformed(); void flickTwiceUsingTouches(); + void nestedStopAtBounds(); + void nestedStopAtBounds_data(); private: void flickWithTouch(QWindow *window, QTouchDevice *touchDevice); @@ -1311,6 +1313,75 @@ void tst_qquickflickable::flickWithTouch(QWindow *window, QTouchDevice *touchDev QTest::qWait(1); } +void tst_qquickflickable::nestedStopAtBounds_data() +{ + QTest::addColumn("transpose"); + QTest::addColumn("invert"); + + QTest::newRow("left") << false << false; + QTest::newRow("right") << false << true; + QTest::newRow("top") << true << false; + QTest::newRow("bottom") << true << true; +} + +void tst_qquickflickable::nestedStopAtBounds() +{ + QFETCH(bool, transpose); + QFETCH(bool, invert); + + QQuickView view; + view.setSource(testFileUrl("nestedStopAtBounds.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QVERIFY(view.rootObject()); + + QQuickFlickable *outer = qobject_cast(view.rootObject()); + QVERIFY(outer); + + QQuickFlickable *inner = outer->findChild("innerFlickable"); + QVERIFY(inner); + inner->setFlickableDirection(transpose ? QQuickFlickable::VerticalFlick : QQuickFlickable::HorizontalFlick); + inner->setContentX(invert ? 0 : 100); + inner->setContentY(invert ? 0 : 100); + + const int threshold = qApp->styleHints()->startDragDistance(); + + QPoint position(200, 200); + int &axis = transpose ? position.ry() : position.rx(); + + // drag toward the aligned boundary. Outer flickable dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? threshold * 2 : -threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? threshold : -threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->isDragging(), true); + QCOMPARE(inner->isDragging(), false); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QVERIFY(!outer->isDragging()); + QTRY_VERIFY(!outer->isMoving()); + + axis = 200; + outer->setContentX(50); + outer->setContentY(50); + + // drag away from the aligned boundary. Inner flickable dragged. + QTest::mousePress(&view, Qt::LeftButton, 0, position); + QTest::qWait(10); + axis += invert ? -threshold * 2 : threshold * 2; + QTest::mouseMove(&view, position); + axis += invert ? -threshold : threshold; + QTest::mouseMove(&view, position); + QCOMPARE(outer->isDragging(), false); + QCOMPARE(inner->isDragging(), true); + QTest::mouseRelease(&view, Qt::LeftButton, 0, position); + + QTRY_VERIFY(!outer->isMoving()); +} + QTEST_MAIN(tst_qquickflickable) #include "tst_qquickflickable.moc" diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 802cc0a4c9..3c30f9e887 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -4308,22 +4308,22 @@ void tst_QQuickGridView::snapOneRow_data() QTest::addColumn("startExtent"); QTest::newRow("vertical, left to right") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; QTest::newRow("horizontal, left to right") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 240.0 << 0.0; QTest::newRow("horizontal, right to left") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 << -240.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 << -240.0; QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::FlowLeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(20, 160) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::FlowTopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; + << QPoint(160, 20) << QPoint(20, 20) << 100.0 << 340.0 << -20.0; QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::FlowTopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange) - << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0; + << QPoint(20, 20) << QPoint(160, 20) << -340.0 << -240.0 - 240.0 - 100.0 << -220.0; } void tst_QQuickGridView::snapOneRow() diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index ef7dc72345..327abbebd5 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -805,8 +805,8 @@ void tst_QQuickMouseArea::preventStealing() // Flickable content should have moved. - QCOMPARE(flickable->contentX(), 11.); - QCOMPARE(flickable->contentY(), 11.); + QCOMPARE(flickable->contentX(), 22.); + QCOMPARE(flickable->contentY(), 22.); QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 50)); -- cgit v1.2.3 From 523bf6c3d0076e43aee6747211f6e93005f2d1c6 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 21 Feb 2013 08:46:56 -0600 Subject: ListView's highlightMoveDuration should default to -1. Change-Id: Ibb53cc21b4f1f301569cd7724c60cb8df978921a Reviewed-by: Bea Lam --- src/quick/items/qquicklistview.cpp | 4 +++- tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 57f1b99456..63528ff702 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -172,7 +172,9 @@ public: , highlightMoveVelocity(400), highlightResizeVelocity(400), highlightResizeDuration(-1) , sectionCriteria(0), currentSectionItem(0), nextSectionItem(0) , overshootDist(0.0), correctFlick(false), inFlickCorrection(false) - {} + { + highlightMoveDuration = -1; //override default value set in base class + } ~QQuickListViewPrivate() { delete highlightPosAnimator; delete highlightSizeAnimator; diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 9fad01ef40..c034fe83c8 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -206,6 +206,7 @@ private slots: void destroyItemOnCreation(); void parentBinding(); + void defaultHighlightMoveDuration(); private: template void items(const QUrl &source, bool forceLayout); @@ -6801,6 +6802,18 @@ void tst_QQuickListView::parentBinding() delete window; } +void tst_QQuickListView::defaultHighlightMoveDuration() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick 2.0; ListView {}", QUrl::fromLocalFile("")); + + QObject *obj = component.create(); + QVERIFY(obj); + + QCOMPARE(obj->property("highlightMoveDuration").toInt(), -1); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" -- cgit v1.2.3 From a496e0874858a4b7d991c179c0e12df46c3d324c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 22 Dec 2012 13:56:44 -0800 Subject: Fix warnings about shadowing members util/qqmlpropertymap.h:87:9: error: declaration of 'parent' shadows a member of 'this' [-Werror=shadow] [and others] Change-Id: I2ff1a3c133efe2132e74dad00596931a84a7f421 Reviewed-by: Alan Alpert --- src/qml/util/qqmlpropertymap.h | 4 ++-- src/quick/scenegraph/util/qsgsimplematerial.h | 4 ++-- src/quick/scenegraph/util/qsgtexturematerial.h | 4 ++-- tests/auto/headersclean/headersclean.pro | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/qml/util/qqmlpropertymap.h b/src/qml/util/qqmlpropertymap.h index cd3516a907..5c79f08926 100644 --- a/src/qml/util/qqmlpropertymap.h +++ b/src/qml/util/qqmlpropertymap.h @@ -83,8 +83,8 @@ protected: virtual QVariant updateValue(const QString &key, const QVariant &input); template - QQmlPropertyMap(DerivedType *derived, QObject *parent) - : QObject(*allocatePrivate(), parent) + QQmlPropertyMap(DerivedType *derived, QObject *parentObj) + : QObject(*allocatePrivate(), parentObj) { Q_UNUSED(derived) init(&DerivedType::staticMetaObject); diff --git a/src/quick/scenegraph/util/qsgsimplematerial.h b/src/quick/scenegraph/util/qsgsimplematerial.h index 25ac93b2c5..877ea1c4b5 100644 --- a/src/quick/scenegraph/util/qsgsimplematerial.h +++ b/src/quick/scenegraph/util/qsgsimplematerial.h @@ -142,8 +142,8 @@ class QSGSimpleMaterial : public QSGMaterial { public: #ifndef qdoc - QSGSimpleMaterial(const State &state, PtrShaderCreateFunc func) - : m_state(state) + QSGSimpleMaterial(const State &aState, PtrShaderCreateFunc func) + : m_state(aState) , m_func(func) { } diff --git a/src/quick/scenegraph/util/qsgtexturematerial.h b/src/quick/scenegraph/util/qsgtexturematerial.h index 7fc06c7927..822084b463 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.h +++ b/src/quick/scenegraph/util/qsgtexturematerial.h @@ -61,10 +61,10 @@ public: void setTexture(QSGTexture *texture); QSGTexture *texture() const { return m_texture; } - void setMipmapFiltering(QSGTexture::Filtering filtering) { m_mipmap_filtering = filtering; } + void setMipmapFiltering(QSGTexture::Filtering filteringType) { m_mipmap_filtering = filteringType; } QSGTexture::Filtering mipmapFiltering() const { return (QSGTexture::Filtering) m_mipmap_filtering; } - void setFiltering(QSGTexture::Filtering filtering) { m_filtering = filtering; } + void setFiltering(QSGTexture::Filtering filteringType) { m_filtering = filteringType; } QSGTexture::Filtering filtering() const { return (QSGTexture::Filtering) m_filtering; } void setHorizontalWrapMode(QSGTexture::WrapMode mode) { m_horizontal_wrap = mode; } diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro index 6d2f74a6bc..4457fe1c38 100644 --- a/tests/auto/headersclean/headersclean.pro +++ b/tests/auto/headersclean/headersclean.pro @@ -1,4 +1,2 @@ QT = qml quick qmltest qmldevtools load(qt_headersclean) -# shadowing problems in scenegraph, allow it for now -*-g++*: QMAKE_CXXFLAGS -= -Wshadow -- cgit v1.2.3