From 1adbf16f2526b797a70bccf21b1400451f9d4cbb Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 16 Jul 2019 09:28:46 +0200 Subject: doc: Clarify that the delegate populate transition doesn't always run Fixes: QTBUG-42798 Change-Id: If10f06450f1e50893e5ba103e7c8c2d83667a651 Reviewed-by: Venugopal Shivashankar --- src/quick/items/qquickgridview.cpp | 24 +++++++++++++++++++++++- src/quick/items/qquicklistview.cpp | 23 ++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index 272d4a4df5..dd45211115 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -1758,7 +1758,7 @@ void QQuickGridView::setSnapMode(SnapMode mode) \list \li The view is first created - \li The view's \l model changes + \li The view's \l model changes in such a way that the visible delegates are completely replaced \li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass \endlist @@ -1776,6 +1776,28 @@ void QQuickGridView::setSnapMode(SnapMode mode) When the view is initialized, the view will create all the necessary items for the view, then animate them to their correct positions within the view over one second. + However when scrolling the view later, the populate transition does not + run, even though delegates are being instantiated as they become visible. + When the model changes in a way that new delegates become visible, the + \l add transition is the one that runs. So you should not depend on the + \c populate transition to initialize properties in the delegate, because it + does not apply to every delegate. If your animation sets the \c to value of + a property, the property should initially have the \c to value, and the + animation should set the \c from value in case it is animated: + + \code + GridView { + ... + delegate: Rectangle { + opacity: 1 // not necessary because it's the default; but don't set 0 + ... + } + populate: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 1000 } + } + } + \endcode + For more details and examples on how to use view transitions, see the ViewTransition documentation. diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 75a24c7d76..c4c22526f3 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2724,7 +2724,7 @@ void QQuickListView::setFooterPositioning(QQuickListView::FooterPositioning posi \list \li The view is first created - \li The view's \l model changes + \li The view's \l model changes in such a way that the visible delegates are completely replaced \li The view's \l model is \l {QAbstractItemModel::reset()}{reset}, if the model is a QAbstractItemModel subclass \endlist @@ -2742,6 +2742,27 @@ void QQuickListView::setFooterPositioning(QQuickListView::FooterPositioning posi When the view is initialized, the view will create all the necessary items for the view, then animate them to their correct positions within the view over one second. + However when scrolling the view later, the populate transition does not + run, even though delegates are being instantiated as they become visible. + When the model changes in a way that new delegates become visible, the + \l add transition is the one that runs. So you should not depend on the + \c populate transition to initialize properties in the delegate, because it + does not apply to every delegate. If your animation sets the \c to value of + a property, the property should initially have the \c to value, and the + animation should set the \c from value in case it is animated: + + \code + ListView { + ... + delegate: Rectangle { + opacity: 1 // not necessary because it's the default + } + populate: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1; duration: 1000 } + } + } + \endcode + For more details and examples on how to use view transitions, see the ViewTransition documentation. -- cgit v1.2.3 From 38bac80aea1c2bd58acb10000e9a3daa65bba503 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 21 Aug 2019 10:03:31 +0200 Subject: Document that QQmlPropertyMap's meta object is not threadsafe It is generated and modified at runtime, so applications have to synchronize access explicitly. Fixes: QTBUG-70915 Change-Id: Ie6f29eef8532e2fa4ebf8dad1678cd2acbacf659 Reviewed-by: Ulf Hermann Reviewed-by: Volker Hilsheimer --- src/qml/util/qqmlpropertymap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qml/util/qqmlpropertymap.cpp b/src/qml/util/qqmlpropertymap.cpp index 3f78ca6b69..82f048d9d9 100644 --- a/src/qml/util/qqmlpropertymap.cpp +++ b/src/qml/util/qqmlpropertymap.cpp @@ -180,6 +180,10 @@ int QQmlPropertyMapMetaObject::createProperty(const char *name, const char *valu \note When deriving a class from QQmlPropertyMap, use the \l {QQmlPropertyMap::QQmlPropertyMap(DerivedType *derived, QObject *parent)} {protected two-argument constructor} which ensures that the class is correctly registered with the Qt \l {Meta-Object System}. + + \note The QMetaObject of a QQmlPropertyMap is dynamically generated and modified. + Operations on that meta object are not thread safe, so applications need to take + care to explicitly synchronize access to the meta object. */ /*! -- cgit v1.2.3 From 4d080635872fbb77a2adfb736d3f108b62cc058a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 23 Aug 2019 10:03:39 +0200 Subject: Remove HACKING file This file ends up in release packages and contains some outdated documentation about where to put different types of examples, which should probably not be documented by random files in the source repository. Change-Id: If35ee6cd2b4084fc5763a0cab39b9ff3e44fa133 Reviewed-by: Lars Knoll --- examples/HACKING | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 examples/HACKING diff --git a/examples/HACKING b/examples/HACKING deleted file mode 100644 index 7d2a61a481..0000000000 --- a/examples/HACKING +++ /dev/null @@ -1,23 +0,0 @@ -Some guidelines for Qt QML examples - -Snippets ---- -Snippets are snatches of QML code that won't even run on their own. They don't belong here, they belong in doc/src/snippets. They should be contained in files that will compile on their own, for automated syntax validation, but don't have to look like anything. - -Examples ---- - -Examples are large blocks of QML code that demonstrate a feature. You should be able to launch an example and visually see the feature take effect. Examples should be written in a small form, and should automatically activate any features. Ideally, when you run an example, you see the feature demonstrate itself over and over until you get bored and close the application using your platform's close window mechanism. Examples shouldn't contain their own close buttons or start screen, explanatory text should be kept to a minimum (show, not tell), and reserve interaction for demonstrating interactive elements. The code should be held to a high level of quality, and should be understandable by people new to QML. - -Unless the demonstrated feature uses it, assume no interface devices other than a screen that can show a 320x480 rectangle and a generic pointing device (with the shared subset of mouse/touch functionality). - -Groups of similar examples should be placed in one folder with a single launcher application, which uses the shared folder of common components. - -The example, or launcher application in case of groups, should contain a qdoc comment explaining the example. The example or launcher should be buildable as a full C++ application and runnable with the standard qml file launcher. Usually this will consist primarily of using the macro found in shared.h. - -Demos ---- - -Demos are examples of creating full applications using QML. They should fit both a desktop and a mobile form factor, they should have their own start screen and method of exiting the application. They should be at a level of quality that you'd be comfortable submitting them to an app store for a platform of the appropriate hardware (screen size, input methods, etc.). The code should be written to a level that is easily understood and modified by a QML expert. - -Demos should have a qdoc file in their directory explaining the demo at a high level. The demo should be buildable as a full C++ application and preferably runnable with the standard qml file launcher. -- cgit v1.2.3 From 4b944cb61fb3ceee2f1b743823e4a83b686bafd6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Aug 2019 11:48:48 +0200 Subject: Fix loading of ES modules when using CONFIG += qtquickcompiler Added the missing lookup for cached .mjs files in ExecutionEngine::compileModule. This allows using .mjs files in WorkerScript {} elements in conjunction with the Qt Quick Compiler and also fixes the use when using QJSEngine::importModule. [ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt Quick Compiler. Fixes: QTBUG-77761 Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491 Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4engine.cpp | 7 +++++++ tests/auto/qml/qmlcachegen/data/module.mjs | 6 ++++++ tests/auto/qml/qmlcachegen/data/utils.mjs | 4 ++++ tests/auto/qml/qmlcachegen/qmlcachegen.pro | 4 +++- tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 10 ++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qmlcachegen/data/module.mjs create mode 100644 tests/auto/qml/qmlcachegen/data/utils.mjs diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index b6000dbcca..f9747207db 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1743,6 +1743,13 @@ ReturnedValue ExecutionEngine::global() QQmlRefPointer ExecutionEngine::compileModule(const QUrl &url) { + QQmlMetaType::CachedUnitLookupError cacheError = QQmlMetaType::CachedUnitLookupError::NoError; + if (const QV4::CompiledData::Unit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url, &cacheError)) { + QQmlRefPointer jsUnit; + jsUnit.adopt(new QV4::CompiledData::CompilationUnit(cachedUnit, url.fileName(), url.toString())); + return jsUnit; + } + QFile f(QQmlFile::urlToLocalFileOrQrc(url)); if (!f.open(QIODevice::ReadOnly)) { throwError(QStringLiteral("Could not open module %1 for reading").arg(url.toString())); diff --git a/tests/auto/qml/qmlcachegen/data/module.mjs b/tests/auto/qml/qmlcachegen/data/module.mjs new file mode 100644 index 0000000000..6838766329 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/module.mjs @@ -0,0 +1,6 @@ + +import { helper } from "utils.mjs" + +export function entry() { + return helper() +} diff --git a/tests/auto/qml/qmlcachegen/data/utils.mjs b/tests/auto/qml/qmlcachegen/data/utils.mjs new file mode 100644 index 0000000000..25a1f38709 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/utils.mjs @@ -0,0 +1,4 @@ + +export function helper() { + return "ok" +} diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro index 7f8e93d101..ec1ec10ec1 100644 --- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro +++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro @@ -15,7 +15,9 @@ RESOURCES += \ data/Enums.qml \ data/componentInItem.qml \ data/jsmoduleimport.qml \ - data/script.mjs + data/script.mjs \ + data/module.mjs \ + data/utils.mjs workerscripts_test.files = \ data/worker.js \ diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index e290f21986..27314d815b 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -63,6 +63,7 @@ private slots: void qrcScriptImport(); void fsScriptImport(); void moduleScriptImport(); + void esModulesViaQJSEngine(); void enums(); @@ -596,6 +597,15 @@ void tst_qmlcachegen::moduleScriptImport() } } +void tst_qmlcachegen::esModulesViaQJSEngine() +{ + QCOMPARE(QFileInfo(":/data/module.mjs").size(), 0); + QJSEngine engine; + QJSValue module = engine.importModule(":/data/module.mjs"); + QJSValue result = module.property("entry").call(); + QCOMPARE(result.toString(), "ok"); +} + void tst_qmlcachegen::enums() { QQmlEngine engine; -- cgit v1.2.3 From 0ec16fb93db6ad6792b3269838211485e8af464b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 26 Aug 2019 14:39:04 +0200 Subject: Add missing HoverHandler docs It was intended to inherit most of the docs from SinglePointHandler; but the hovered property is unique. Task-number: QTBUG-68072 Change-Id: I4b49569c9966b9252a61e40e8b07ef98f34849a4 Reviewed-by: Richard Moe Gustavsen --- src/quick/handlers/qquickhoverhandler.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp index bdcd5dc4cc..6391fb2958 100644 --- a/src/quick/handlers/qquickhoverhandler.cpp +++ b/src/quick/handlers/qquickhoverhandler.cpp @@ -47,14 +47,24 @@ Q_LOGGING_CATEGORY(lcHoverHandler, "qt.quick.handler.hover") /*! \qmltype HoverHandler \instantiates QQuickHoverHandler + \inherits SinglePointHandler \inqmlmodule QtQuick \ingroup qtquick-input-handlers \brief Handler for mouse and tablet hover. - HoverHandler detects a hovering cursor. Since touchscreens don't generally - offer hover events, in practice it detects a hovering mouse or tablet stylus. + HoverHandler detects a hovering mouse or tablet stylus cursor. - \sa MouseArea + A binding to the \l hovered property is the easiest way to react when the + cursor enters or leaves the \l {PointerHandler::parent}{parent} Item. + The \l {SinglePointHandler::point}{point} property provides more detail, + including the cursor position. The + \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices}, + \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes}, + and \l {PointerDeviceHandler::acceptedModifiers}{acceptedModifiers} + properties can be used to narrow the behavior to detect hovering of + specific kinds of devices or while holding a modifier key. + + \sa MouseArea, PointHandler */ QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent) @@ -97,6 +107,14 @@ void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point) setPassiveGrab(point); } +/*! + \qmlproperty bool QtQuick::HoverHandler::hovered + \readonly + + Holds true whenever any pointing device cursor (mouse or tablet) is within + the bounds of the \c parent Item, extended by the + \l {PointerHandler::margin}{margin}, if any. +*/ void QQuickHoverHandler::setHovered(bool hovered) { if (m_hovered != hovered) { -- cgit v1.2.3 From 8577f12bf4dfd9adfe8c5b85a3712bf1cc5ba0c3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 22 Aug 2019 10:32:54 +0200 Subject: Fix build with -no-feature-quick-sprite Change-Id: I1599dde865a7c5454a52b45b2cc877a8c43fb10d Reviewed-by: Mitch Curtis --- src/quick/items/qquickitemsmodule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index b2fcfb4307..d6d0aa8146 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -465,7 +465,9 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qRegisterMetaType(); // The rest of the 5.12 revisions +#if QT_CONFIG(quick_sprite) qmlRegisterType("QtQuick", 2, 12, "AnimatedSprite"); +#endif qmlRegisterType(uri, 2, 12, "Gradient"); qmlRegisterType(uri, 2, 12, "Flickable"); qmlRegisterType(uri, 2, 12, "Text"); -- cgit v1.2.3