From 02b47ec4a5f956b45436e078fbc7505c664d3bea Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 30 Jul 2019 11:25:43 +0300 Subject: Add changes file for Qt 5.13.1 Change-Id: I1edcf6d4b755ae433498e4db9791dad487f4f5c1 Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge --- dist/changes-5.13.1 | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 dist/changes-5.13.1 diff --git a/dist/changes-5.13.1 b/dist/changes-5.13.1 new file mode 100644 index 0000000000..d859a5e747 --- /dev/null +++ b/dist/changes-5.13.1 @@ -0,0 +1,107 @@ +Qt 5.13.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.13.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.13 series is binary compatible with the 5.12.x series. +Applications compiled for 5.12 will continue to run with 5.13. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - [QTBUG-76871] TapHandler.point now holds the release position while the + tapped() signal is emitted. + - [QTBUG-14769][QTBUG-50482] TextEdit now uses the I-beam cursor by default, + and the pointing cursor for links. But if user code sets a custom cursor, + we restore it when the mouse is no longer hovering a link. + +**************************************************************************** +* QtQml * +**************************************************************************** + + - [QTBUG-56264] Fixed segfault on Sparc64. + - [QTBUG-77102] Fix bug with singletons not being imported from modules when + using older versions. + - [QTBUG-77047] Fixed crash when creating arrays using the spread operator. + - [QTBUG-75983] Fixed crash in XMLHttpRequest.open. + - [QTBUG-77012] Fixed static build issue: multiple definitions of + qtPositionAttributeName(). + - [QTBUG-71329] Fixed promise chaining. + - [QTBUG-76441] Fix support for import statements using qrc:/ urls. + - [QTBUG-55407] Fixed a crash when setData or create is called after a user + mistakenly used the internal constructor of QQmlComponent which does + not take an engine. + - [QTBUG-76796] Fixed late binding re-evaluation when using typeof(name). + - [QTBUG-76627] qmlplugindump now finds enums in composite types. + - [QTBUG-76656] Fixed resolution of 'this' when using the call operator on scope and context + properties. + - [QTBUG-71387] Fixed a crash after calling qmlClearTypeRegistrations(). + - [QTBUG-75642] Fixed an invalid memory read in JIT with template literals. + - [QTBUG-75939] Fix crash when destroying QJSValues from other threads. + - [QTBUG-76085] Fixed automatic loading of translations from resources. + - [QTBUG-76018] Fixed grammar to permit readonly list properties. + - [QTBUG-75880] Fix accidental implicit creation of local variable when using anonymous functions + in object literals. + - [QTBUG-67343] Fixed assertion when having a ShaderEffect as a delegate + in a ComboBox. + - [QTBUG-75896] Fixed property lookup in QML singletons. + - [QTBUG-75392] Fixed a crash by working around a compiler bug. + - [QTBUG-48809] Print a warning when using absolute paths in qmldir files. + - [QTBUG-75609] Fixed a performance regression with attached properties. + - [QTBUG-76074] Loader now frees custom qml types when unloading. + +**************************************************************************** +* QtQuick * +**************************************************************************** + + - Item Views: + * [QTBUG-76487] We now properly populate delegates with the populate + transition when the view is resized after componentComplete. + * [QTBUG-31677] A ListView footer is now positioned correctly after the + last item is removed. + * [QTBUG-76433][QTBUG-44308] Fixed a crash while doing fast flicking in + transitions that use Animators. + * [QTBUG-76254] Fixed a crash in QQmlDelegateModel. + * [QTBUG-71581] Fixed a crash in ListView when closing an application that + dynamically creates and appends items to an ObjectModel. + + - Input: + * [QTBUG-75399] Fixed a crash when using the KeyNavigation attached property. + * [QTBUG-76875] DragHandler now respects acceptedButtons. + * [QTBUG-71218] If a Controls 2 Button has a DragHandler, the button is + now released when the drag begins. + * [QTBUG-75770] MouseArea now respects QPlatformTheme::TouchDoubleTapDistance + to avoid generating double-clicks while moving and clicking the mouse quickly. + + - Scene graph: + * [QTBUG-76603] qmlscene now sets the default surface format earlier + and correctly. + * [QTBUG-68566] Fixed rendering freeze when using software rendering + of WebEngine in QQuickWidget. + * [QTBUG-73768] Fixed an assert in BorderImage when any border size + exceeds source image size. + * [QTBUG-66810] Software rendering: repaint everything when moving + between HiDpi and lower-resolution screens. + * [QTBUG-74348] Fixed leaking scene graph rendering contexts when using + the threaded render loop. + * [QTBUG-76055] Cleaned up error messages in shadereffect. + + - Text: + * [QTBUG-74761] Added support for text color when using color fonts. + * [QTBUG-76528] Fixed missing glyphs and in some cases crashes when + displaying many characters from the same font on a system with a + low maximum texture size. + * [QTBUG-75002] Accessibility: StaticText nodes are announced as + read-only rather than editable in Windows Narrator. -- cgit v1.2.3 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 9655f7fdc96d26de369578bb6620f525c6f919d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 15 Aug 2019 11:22:40 +0200 Subject: Fix flakiness in QQuickTextEdit::mouseSelection Avoid that the last click from the previous test data and the first click in the current test data happens so close in time that they are interpreted as a double click. Task-number: QTBUG-77389 Change-Id: Ia2d159452dcdb58cacccf7101cc3360175b39594 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 33a6b829bc..a9016be84a 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2106,13 +2106,17 @@ void tst_qquicktextedit::mouseSelection() textEditObject->setFocus(focus); textEditObject->setFocusOnPress(focusOnPress); + // Avoid that the last click from the previous test data and the first click in the + // current test data happens so close in time that they are interpreted as a double click. + static const int moreThanDoubleClickInterval = QGuiApplication::styleHints()->mouseDoubleClickInterval() + 1; + // press-and-drag-and-release from x1 to x2 QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint(); QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint(); if (clicks == 2) - QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); else if (clicks == 3) - QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1); if (clicks == 2) { // QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating -- 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 1d6b0b0a7976978f43e415d777e1f070cb8a47c8 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 26 Jun 2019 13:08:37 +1000 Subject: nothread: enable shapes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These seem to work fine on nothread build, so enable them. Change-Id: Ib2c7f6e462ca04d82b729bc29c846017f7bf131a Reviewed-by: Morten Johan Sørvig --- src/imports/imports.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imports/imports.pro b/src/imports/imports.pro index 54e52b1103..9714e4697b 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -25,6 +25,6 @@ qtHaveModule(quick) { qtConfig(quick-particles): \ SUBDIRS += particles - qtConfig(quick-path):qtConfig(thread): SUBDIRS += shapes + qtConfig(quick-path): SUBDIRS += shapes } -- cgit v1.2.3 From 0d66040a794be1d39e026a6e3368a5fe1632f5c3 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Tue, 13 Aug 2019 16:41:15 +0200 Subject: Doc: Replace the "Qt Quick Controls 2" instances This is one of the several commits, replacing the "Qt Quick Controls 2" instances with "Qt Quick Controls". Change-Id: I2e1f1e53bd7756331320f5447dbdabef36dfcb66 Reviewed-by: Paul Wicking --- src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc | 2 +- src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc | 16 ++++++++-------- .../doc/src/guidelines/qtquick-toolsnutilities.qdoc | 6 +++--- src/quick/doc/src/qtquick.qdoc | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc index e4d837112f..7695bb57db 100644 --- a/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc +++ b/src/quick/doc/src/concepts/modelviewsdata/cppmodels.qdoc @@ -227,7 +227,7 @@ access to the data from QML: The QSqlQueryModel class is good enough to implement a custom read-only model that represents data in an SQL database. The -\l{Qt Quick Controls 2 - Chat Tutorial}{chat tutorial} example +\l{Qt Quick Controls - Chat Tutorial}{chat tutorial} example demonstrates this very well by implementing a custom model to fetch the contact details from an SQLite database. diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc index dd7f21e81a..f4a1616943 100644 --- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc +++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc @@ -45,9 +45,9 @@ UI. It is recommended to browse this list of UI controls before creating your own custom UI control. Besides these basic UI controls offered by Qt Quick itself, a rich set of UI -controls are also available with Qt Quick Controls 2. They cater to the most +controls are also available with Qt Quick Controls. They cater to the most common use cases without any change, and offer a lot more possibilities with their -customization options. In particular, Qt Quick Controls 2 provides styling +customization options. In particular, Qt Quick Controls provides styling options that align with the latest UI design trends. If these UI controls do not satisfy your application's needs, only then it is recommended to create a custom control. @@ -55,7 +55,7 @@ custom control. \section2 Related Information \list -\li \l{Qt Quick Controls 2} +\li \l{Qt Quick Controls} \li \l{Qt Quick} \endlist @@ -323,7 +323,7 @@ see \l {Choosing the Correct Integration Method Between C++ and QML}. \section2 Related Information \list \li \l{Integrating QML and C++} -\li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat application tutorial} +\li \l{Qt Quick Controls - Chat Tutorial}{Chat application tutorial} \endlist \section1 Using Qt Quick Layouts @@ -426,7 +426,7 @@ developers to follow these tips: \li Use anchors or the Qt Quick Layouts module to lay out the visual items. \li Do not specify explicit width and height for a visual item. \li Provide UI resources such as images and icons for each display resolution - that your application supports. The Qt Quick Controls 2 gallery example + that your application supports. The Qt Quick Controls gallery example demonstrates this well by providing the \c qt-logo.png for \c @2x, \c @3x, and \c @4x resolutions, enabling the application to cater to high resolution displays. Qt automatically chooses the appropriate @@ -437,7 +437,7 @@ developers to follow these tips: versions of an image, as is necessary with bitmap images. \li Use font-based icons, such as Font Awesome. These scale to any display resolution, and also allow colorization. The - Qt Quick Controls 2 Text Editor example demonstrates this well. + Qt Quick Controls Text Editor example demonstrates this well. \endlist With this in place, your application's UI should scale depending @@ -448,8 +448,8 @@ on the display resolution on offer. \section2 Related Information \list - \li \l{Qt Quick Controls 2 - Gallery}{Gallery example} - \li \l{Qt Quick Controls 2 - Text Editor}{Text Editor example} + \li \l{Qt Quick Controls - Gallery}{Gallery example} + \li \l{Qt Quick Controls - Text Editor}{Text Editor example} \li \l{Font Awesome} \li \l{Scalability} \li \l{High DPI Displays} diff --git a/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc b/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc index 0669ec06c8..84741efa61 100644 --- a/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc +++ b/src/quick/doc/src/guidelines/qtquick-toolsnutilities.qdoc @@ -39,15 +39,15 @@ information about them. The Qt Quick Designer enables designing Qt Quick-based UIs using simple drag-n-drop gestures that most designers are familiar with. It offers UI -elements from the Qt Quick and Qt Quick Controls 2 modules, as well as +elements from the Qt Quick and Qt Quick Controls modules, as well as integration for custom UI elements. The following is a list of example applications that use UIs created by the Qt Quick Designer: \list - \li \l{Qt Quick Controls 2 - Contact List} - \li \l{Qt Quick Controls 2 - Flat Style} + \li \l{Qt Quick Controls - Contact List} + \li \l{Qt Quick Controls - Flat Style} \endlist \section2 QML Debugger and Profiler diff --git a/src/quick/doc/src/qtquick.qdoc b/src/quick/doc/src/qtquick.qdoc index 7f72217279..4b843f366b 100644 --- a/src/quick/doc/src/qtquick.qdoc +++ b/src/quick/doc/src/qtquick.qdoc @@ -43,7 +43,7 @@ QML types for creating user interfaces with the QML language, and a \l{Qt Quick C++ Classes}{C++ API} for extending QML applications with C++ code. \note A set of Qt Quick-based UI controls is also available to create user -interfaces. See \l{Qt Quick Controls 2} for more information. +interfaces. See \l{Qt Quick Controls} for more information. For those new to QML and Qt Quick, please see \l{QML Applications} -- 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 7b47350736f46c59d81238d3d6284358a652983b Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 20 Aug 2019 13:16:26 +0300 Subject: Add changes file for Qt 5.12.5 Change-Id: I147d3faefac8114e08a0594a0c43b3cdae959804 Reviewed-by: Ulf Hermann Reviewed-by: Shawn Rutledge --- dist/changes-5.12.5 | 89 ++++++++++++++++++++++++++++++++++ tests/auto/qml/ecmascripttests/test262 | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 dist/changes-5.12.5 diff --git a/dist/changes-5.12.5 b/dist/changes-5.12.5 new file mode 100644 index 0000000000..be0621c138 --- /dev/null +++ b/dist/changes-5.12.5 @@ -0,0 +1,89 @@ +Qt 5.12.5 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.12.0 through 5.12.4. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.12 series is binary compatible with the 5.11.x series. +Applications compiled for 5.11 will continue to run with 5.12. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + + - [QTBUG-76871] TapHandler.point now holds the release position while the + tapped() signal is emitted. + +**************************************************************************** +* QtQml * +**************************************************************************** + + - [QTBUG-76018] Readonly QML properties can now be templates such as + list<...>. + - [QTBUG-76085] QQmlApplication engine now automatically loads translation + files from resource directories. + - [QTBUG-75939] Instances of QJSValue can now safely be passed between + threads and destroyed in a different thread. + - [QTBUG-75642] Fixed an invalid memory read caused by the JIT compiler. + - [QTBUG-71387] Fixed a use-after-free condition caused by calling + qmlClearTypeRegistrations(). + - [QTBUG-76656] Made sure JavaScript "this" points to the right object when + calling scope and context properties through lookups. + - [QTBUG-76796] Fixed bindings to typeof() to get re-evaluated when + gets defined. + - [QTBUG-55407] Avoid invalid memory access when calling setData() on a + QQmlComponent constructed without an engine. + - [QTBUG-76441] Fixed importing "qrc:/" (with exactly one slash). + - [QTBUG-71329] Implemented the missing bits of JavaScript promise chains. + - [QTBUG-75983] Fixed null pointer dereference in QQmlXmlHttpRequest. + - [QTBUG-77012] Fixed static build issue: multiple definitions of + qtPositionAttributeName(). + - [QTBUG-77102] The component versioning is not enforced when loading + singletons. + +**************************************************************************** +* QtQuick * +**************************************************************************** + + - Item Views: + * [QTBUG-76487] We now properly populate delegates with the populate + transition when the view is resized after componentComplete. + * [QTBUG-31677] A ListView footer is now positioned correctly after the + last item is removed. + * [QTBUG-76433][QTBUG-44308] Fixed a crash while doing fast flicking in + transitions that use Animators. + * [QTBUG-76254] Fixed a crash in QQmlDelegateModel. + + - Input: + * [QTBUG-75399] Fixed a crash when using the KeyNavigation attached property. + * [QTBUG-76875] DragHandler now respects acceptedButtons. + * [QTBUG-71218] If a Controls 2 Button has a DragHandler, the button is + now released when the drag begins. + + - Scene graph: + * [QTBUG-76603] qmlscene now sets the default surface format earlier + and correctly. + * [QTBUG-68566] Fixed rendering freeze when using software rendering + of WebEngine in QQuickWidget. + * [QTBUG-66810] Software rendering: repaint everything when moving + between HiDpi and lower-resolution screens. + + - Text: + * [QTBUG-77217] Fixed a bug where aligning an image to "top" or "bottom" + could cause a crash under certain circumstances. + * [QTBUG-76528] Fixed missing glyphs and in some cases crashes when + displaying many characters from the same font on a system with a + low maximum texture size. + * [QTBUG-76528] Fixed a bug when displaying many characters from the same + font on a system with a low maximum texture size. + * [QTBUG-74761] Added support for text color when using color fonts. diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 index 6b0c42c63c..3c69133cc4 160000 --- a/tests/auto/qml/ecmascripttests/test262 +++ b/tests/auto/qml/ecmascripttests/test262 @@ -1 +1 @@ -Subproject commit 6b0c42c63c2492bd0a7a96d3179d122b5f71793f +Subproject commit 3c69133cc419840c1be34638039cd8c48a7ef581 -- 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 From 0ae01dec7aa0ffbb59e6e947bfa2e73ae030346a Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 18 Jun 2019 15:45:16 +0200 Subject: Doc: minor language issue in image elements documentation Change-Id: I5f3774ec4650dcc7eb316b4a15740e4a67504365 Reviewed-by: Paul Wicking --- examples/quick/imageelements/doc/src/imageelements.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/quick/imageelements/doc/src/imageelements.qdoc b/examples/quick/imageelements/doc/src/imageelements.qdoc index 2c6490fb2c..4c00915e56 100644 --- a/examples/quick/imageelements/doc/src/imageelements.qdoc +++ b/examples/quick/imageelements/doc/src/imageelements.qdoc @@ -38,12 +38,12 @@ \section1 Scaling with BorderImage - \e BorderImage shows off the various scaling modes of the \l BorderImage + \e BorderImage shows the various scaling modes of the \l BorderImage type by setting its horizontalTileMode and verticalTileMode properties. \section1 Image Fill - \e Image shows off the various fill modes of the \l Image type. + \e Image shows the various fill modes of the \l Image type. \section1 Shadow Effects -- cgit v1.2.3 From cfa2c53bc085c775f8ea8dd907e7cd0538542816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 22 Aug 2019 16:47:58 +0200 Subject: Make mouseSelection test more stable QTestLib assumes that the double click interval is below 500ms. Therefore it adds a 500ms delay after all synthesized single- and doubleclick releases to prevent unintentional synthesizing of double click events. This has two unfortunate side-effects: 1. If the double click interval is smaller than 500 ms, it is not possible to synthesize a triple click. (Triple clicks are used for selecting paragraphs in text). This is why the workaround in the block (if clicks ==2) was needed. 2. If the double click interval is bigger than 500ms we might still accidentally trigger a double click event with two successive single click events, so it doesn't even work reliably for that case (!). Therefore, the hardcoded 500ms in QTestLib should probably be revisited. Anyway, to fix this test we therefore have to cancel the 500ms delta QTestLib adds in order to properly synthesize the triple click by adjusting the internal QTest::lastMouseTimestamp. Task-number: QTBUG-77389 Change-Id: Ic738f51b294270ddf99b6d91d256f6ec4b34d039 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index a9016be84a..facd63027e 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2117,23 +2117,20 @@ void tst_qquicktextedit::mouseSelection() QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); else if (clicks == 3) QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); + // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval + QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval; QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1); - if (clicks == 2) { - // QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating - // double click events by adding 500ms delta to release event timestamps. - // Send a double click event by hand to ensure the correct sequence: - // press, release, press, _dbl click_, move, release. - QMouseEvent dblClickEvent(QEvent::MouseButtonDblClick, p1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - QGuiApplication::sendEvent(textEditObject, &dblClickEvent); - } QTest::mouseMove(&window, p2); QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2); QTRY_COMPARE(textEditObject->selectedText(), selectedText); // Clicking and shift to clicking between the same points should select the same text. textEditObject->setCursorPosition(0); - if (clicks > 1) + if (clicks > 1) { QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval + QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval; + } if (clicks != 2) QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1); QTest::mouseClick(&window, Qt::LeftButton, Qt::ShiftModifier, p2); -- cgit v1.2.3 From da04b1d716617fbe4a2d93dc5a51f38dbd03a5b8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 23 Aug 2019 13:11:31 +0200 Subject: QQuickTableView: always relayout after a rebuild The current logic was based on the idea that if both rowHeight-, and columnWidthProveders were set, we didn't have to relayout the items at the end of a rebuild. Because in that case, the row and column sizes would already be correct after the initial load. This assumption turns out to be false, because the providers are allowed to return -1 to signal that the size of a row or column should use default values (meaning, calculated by TableView). And for those cases, we need to do a relayout at the end of a rebuild. Fixes: QTBUG-77074 Change-Id: I0e0f2fdca1cfa9e98f2a0a2b227c3715c16a70f9 Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 10 +-- .../qquicktableview/data/tweakimplicitsize.qml | 89 ++++++++++++++++++++++ .../quick/qquicktableview/tst_qquicktableview.cpp | 27 +++++++ 3 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 83fa11a446..38b38ddfda 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1541,15 +1541,7 @@ void QQuickTableViewPrivate::beginRebuildTable() void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() { - if (rowHeightProvider.isUndefined() || columnWidthProvider.isUndefined()) { - // Since we don't have both size providers, we need to calculate the - // size of each row and column based on the size of the delegate items. - // This couldn't be done while we were loading the initial rows and - // columns, since during the process, we didn't have all the items - // available yet for the calculation. So we do it now. - relayoutTable(); - } - + relayoutTable(); updateAverageEdgeSize(); updateContentWidth(); updateContentHeight(); diff --git a/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml b/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml new file mode 100644 index 0000000000..ecc79a9368 --- /dev/null +++ b/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick 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$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.3 + +Item { + width: 640 + height: 450 + + property alias tableView: tableView + property real delegateSize: 10 + property int hideRow: -1 + + TableView { + id: tableView + width: 600 + height: 400 + anchors.margins: 1 + clip: true + delegate: tableViewDelegate + columnSpacing: 1 + rowSpacing: 1 + columnWidthProvider: function(column) { + return -1 + } + rowHeightProvider: function(row) { + if (row === hideRow) + return 0 + return -1 + } + } + + Component { + id: tableViewDelegate + Rectangle { + objectName: "tableViewDelegate" + implicitWidth: row === 0 ? 10 : delegateSize + implicitHeight: column === 0 ? 10 : delegateSize + color: "lightgray" + border.width: 1 + + Text { + id: textItem + anchors.centerIn: parent + text: model.display + renderType: Text.NativeRendering + } + } + } + +} + diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 60d48bb59f..acb475b1c5 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -119,6 +119,7 @@ private slots: void checkRowHeightProviderNegativeReturnValue(); void checkRowHeightProviderNotCallable(); void checkForceLayoutFunction(); + void checkForceLayoutEndUpDoingALayout(); void checkContentWidthAndHeight(); void checkPageFlicking(); void checkExplicitContentWidthAndHeight(); @@ -550,6 +551,32 @@ void tst_QQuickTableView::checkForceLayoutFunction() QCOMPARE(fxItem->item->width(), newColumnWidth); } +void tst_QQuickTableView::checkForceLayoutEndUpDoingALayout() +{ + // QTBUG-77074 + // Check that we change the implicit size of the delegate after + // the initial loading, and at the same time hide some rows or + // columns, and then do a forceLayout(), we end up with a + // complete relayout that respects the new implicit size. + LOAD_TABLEVIEW("tweakimplicitsize.qml"); + + auto model = TestModelAsVariant(10, 10); + + tableView->setModel(model); + + WAIT_UNTIL_POLISHED; + + const qreal newDelegateSize = 20; + view->rootObject()->setProperty("delegateSize", newDelegateSize); + // Hide a row, just to force the following relayout to + // do a complete reload (and not just a relayout) + view->rootObject()->setProperty("hideRow", 1); + tableView->forceLayout(); + + for (auto fxItem : tableViewPrivate->loadedItems) + QCOMPARE(fxItem->item->height(), newDelegateSize); +} + void tst_QQuickTableView::checkContentWidthAndHeight() { // Check that contentWidth/Height reports the correct size of the the -- cgit v1.2.3 From 35acc9fc3c41446bacbbfe754f7f494de7f62411 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Fri, 23 Aug 2019 22:28:56 +0800 Subject: QQuickTextNodeEngine: don't create background when its alpha is 0 If the alpha value for the background color of a text element is 0, we don't need to create a rectangle node to represent it, as the rectangle will be invisible anyway. [ChangeLog][QtQuick][QQuickTextNodeEngine] don't create a new rectangle node as the background of text, when the alpha of it is 0 Fixes: QTBUG-76137 Change-Id: I40c624ee8f61740fd07e7d3751a78b6224882913 Reviewed-by: Shawn Rutledge Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktextnodeengine.cpp | 4 ++-- .../qquicktext/data/transparentBackground.qml | 16 ++++++++++++++++ tests/auto/quick/qquicktext/tst_qquicktext.cpp | 22 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 tests/auto/quick/qquicktext/data/transparentBackground.qml diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 5a4ef2b686..f407de84cb 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -781,8 +781,8 @@ void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, for (int i = 0; i < m_backgrounds.size(); ++i) { const QRectF &rect = m_backgrounds.at(i).first; const QColor &color = m_backgrounds.at(i).second; - - parentNode->addRectangleNode(rect, color); + if (color.alpha() != 0) + parentNode->addRectangleNode(rect, color); } // Add all text with unselected color first diff --git a/tests/auto/quick/qquicktext/data/transparentBackground.qml b/tests/auto/quick/qquicktext/data/transparentBackground.qml new file mode 100644 index 0000000000..a10a1779bb --- /dev/null +++ b/tests/auto/quick/qquicktext/data/transparentBackground.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "white" + Text { + objectName: "text" + textFormat: Text.RichText + anchors.fill: parent + color: "black" + text: "

foo

" + verticalAlignment: Text.AlignTop + horizontalAlignment: Text.AlignLeft + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index eafa6cb052..3414bec4a6 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -163,6 +163,8 @@ private slots: void verticallyAlignedImageInTable(); + void transparentBackground(); + private: QStringList standard; QStringList richText; @@ -4428,6 +4430,26 @@ void tst_qquicktext::verticallyAlignedImageInTable() // Don't crash } +void tst_qquicktext::transparentBackground() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms"); + + QScopedPointer window(new QQuickView); + window->setSource(testFileUrl("transparentBackground.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QImage img = window->grabWindow(); + QCOMPARE(img.isNull(), false); + + QColor color = img.pixelColor(0, 0); + QCOMPARE(color.red(), 255); + QCOMPARE(color.blue(), 255); + QCOMPARE(color.green(), 255); +} QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" -- cgit v1.2.3 From 1dc3f4c24583e14dee3c5fa650a8ac239b953458 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 18 Jul 2019 15:18:31 +0200 Subject: Doc: Fix documentation warnings for qtdeclarative After recent changes to QDoc, it now correctly warns about missing documentation for QML method parameters - fix all of these and also do some minor language editing. Remove duplicated entries for - \qmlmodule Qt.labs.qmlmodels - \group qtjavascript as they were causing issues. Change-Id: I55cd670cc8a0cc6427cdb7945dbd7c28ea94f796 Reviewed-by: Mitch Curtis --- .../folderlistmodel/qquickfolderlistmodel.cpp | 8 +- src/imports/settings/qqmlsettings.cpp | 2 +- src/particles/qquickitemparticle.cpp | 20 ++- src/particles/qquickparticleaffector.cpp | 2 +- src/particles/qquickparticleemitter.cpp | 15 +- .../doc/src/cppintegration/extending-tutorial.qdoc | 3 +- src/qml/doc/src/javascript/qtjavascript.qdoc | 7 - src/qml/doc/src/javascript/string.qdoc | 4 +- src/qml/jsapi/qjsengine.cpp | 4 +- src/qml/qml/ftw/qintrusivelist.cpp | 4 + src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 198 ++++++++++++--------- src/qml/types/qqmldelegatecomponent.cpp | 13 -- src/qml/types/qqmldelegatemodel.cpp | 4 +- src/qml/types/qqmlobjectmodel.cpp | 8 +- src/quick/handlers/qquicktaphandler.cpp | 10 +- src/quick/items/context2d/qquickcanvasitem.cpp | 58 +++--- src/quick/items/context2d/qquickcontext2d.cpp | 179 +++++++++++-------- src/quick/items/qquickdrag.cpp | 4 + src/quick/items/qquickdroparea.cpp | 4 +- src/quick/items/qquickmousearea.cpp | 2 +- src/quick/items/qquickmultipointtoucharea.cpp | 2 +- src/quick/items/qquickscreen.cpp | 3 +- src/quick/items/qquicktextedit.cpp | 6 +- src/quick/items/qquicktextinput.cpp | 25 +-- src/quick/util/qquickfontmetrics.cpp | 7 +- src/quickshapes/qquickshape.cpp | 12 +- 26 files changed, 336 insertions(+), 268 deletions(-) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index affb1e9fe2..2040fb5f0c 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -852,7 +852,7 @@ QQuickFolderListModel::Status QQuickFolderListModel::status() const \qmlproperty bool FolderListModel::sortCaseSensitive \since 5.12 - If set to true, the sort is case sensitive. This property is true by default. + If set to \c true, the sort is case sensitive. This property is \c true by default. */ bool QQuickFolderListModel::sortCaseSensitive() const @@ -874,8 +874,8 @@ void QQuickFolderListModel::setSortCaseSensitive(bool on) /*! \qmlmethod var FolderListModel::get(int index, string property) - Get the folder property for the given index. The following properties - are available. + Returns the folder \a property for the given \a index. The following properties + are available: \list \li \c fileName @@ -902,7 +902,7 @@ QVariant QQuickFolderListModel::get(int idx, const QString &property) const \qmlmethod int FolderListModel::indexOf(url file) \since 5.6 - Get the index of the given file URL if the model contains it, + Returns the index of the given \a file URL if the model contains it, or -1 if not. */ int QQuickFolderListModel::indexOf(const QUrl &file) const diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp index 287a70363a..d43f9bafb7 100644 --- a/src/imports/settings/qqmlsettings.cpp +++ b/src/imports/settings/qqmlsettings.cpp @@ -473,7 +473,7 @@ QVariant QQmlSettings::value(const QString &key, const QVariant &defaultValue) c /*! \qmlmethod Settings::setValue(string key, var value) - Sets the value of setting key to value. If the key already exists, + Sets the value of setting \a key to \a value. If the key already exists, the previous value is overwritten. \since Qt 5.12 diff --git a/src/particles/qquickitemparticle.cpp b/src/particles/qquickitemparticle.cpp index c5c18a201c..a171fc3288 100644 --- a/src/particles/qquickitemparticle.cpp +++ b/src/particles/qquickitemparticle.cpp @@ -59,32 +59,38 @@ QT_BEGIN_NAMESPACE /*! \qmlmethod QtQuick.Particles::ItemParticle::freeze(Item item) - Suspends the flow of time for the logical particle which item represents, allowing you to control its movement. + Suspends the flow of time for the logical particle which \a item represents, + allowing you to control its movement. */ /*! \qmlmethod QtQuick.Particles::ItemParticle::unfreeze(Item item) - Restarts the flow of time for the logical particle which item represents, allowing it to be moved by the particle system again. + Restarts the flow of time for the logical particle which \a item represents, + allowing it to be moved by the particle system again. */ /*! \qmlmethod QtQuick.Particles::ItemParticle::take(Item item, bool prioritize) - Asks the ItemParticle to take over control of item positioning temporarily. + Asks the ItemParticle to take over control of \a item positioning temporarily. It will follow the movement of a logical particle when one is available. - By default items form a queue when waiting for a logical particle, but if prioritize is true then it will go immediately to the - head of the queue. + By default items form a queue when waiting for a logical particle, but if + \a prioritize is \c true, then it will go immediately to the head of the + queue. ItemParticle does not take ownership of the item, and will relinquish control when the logical particle expires. Commonly at this point you will want to put it back in the queue, you can do this with the below line in the delegate definition: + \code ItemParticle.onDetached: itemParticleInstance.take(delegateRootItem); \endcode + or delete it, such as with the below line in the delegate definition: + \code ItemParticle.onDetached: delegateRootItem.destroy(); \endcode @@ -93,7 +99,9 @@ QT_BEGIN_NAMESPACE /*! \qmlmethod QtQuick.Particles::ItemParticle::give(Item item) - Orders the ItemParticle to give you control of the item. It will cease controlling it and the item will lose its association to the logical particle. + Orders the ItemParticle to give you control of the \a item. It will cease + controlling it and the item will lose its association to the logical + particle. */ /*! diff --git a/src/particles/qquickparticleaffector.cpp b/src/particles/qquickparticleaffector.cpp index 3d6035c577..ffbd5674f0 100644 --- a/src/particles/qquickparticleaffector.cpp +++ b/src/particles/qquickparticleaffector.cpp @@ -125,7 +125,7 @@ QT_BEGIN_NAMESPACE themselves). As this executes JavaScript code per particle, it is not recommended to use this signal with a high-volume particle system. - x,y is the particle's current position. + (\a {x}, \a {y}) is the particle's current position. The corresponding handler is \c onAffected. */ diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp index 5ec834a463..f154446484 100644 --- a/src/particles/qquickparticleemitter.cpp +++ b/src/particles/qquickparticleemitter.cpp @@ -190,10 +190,10 @@ QT_BEGIN_NAMESPACE /*! \qmlsignal QtQuick.Particles::Emitter::emitParticles(Array particles) - This signal is emitted when particles are emitted. particles is a JavaScript + This signal is emitted when particles are emitted. \a particles is a JavaScript array of Particle objects. You can modify particle attributes directly within the handler. - Note that JavaScript is slower to execute, so it is not recommended to use this in + \note JavaScript is slower to execute, so it is not recommended to use this in high-volume particle systems. The corresponding handler is \c onEmitParticles. @@ -201,19 +201,20 @@ QT_BEGIN_NAMESPACE /*! \qmlmethod QtQuick.Particles::Emitter::burst(int count) - Emits count particles from this emitter immediately. + Emits a number of particles, specified by \a count, from this emitter immediately. */ /*! \qmlmethod QtQuick.Particles::Emitter::burst(int count, int x, int y) - Emits count particles from this emitter immediately. The particles are emitted - as if the Emitter was positioned at x,y but all other properties are the same. + Emits a number of particles, specified by \a count, from this emitter immediately. + The particles are emitted as if the Emitter was positioned at (\a {x}, \a {y}) but + all other properties are the same. */ /*! \qmlmethod QtQuick.Particles::Emitter::pulse(int duration) - If the emitter is not enabled, enables it for duration milliseconds and then switches - it back off. + If the emitter is not enabled, enables it for a specified \a duration + (in milliseconds) and then switches it back off. */ QQuickParticleEmitter::QQuickParticleEmitter(QQuickItem *parent) : diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc index 26556644d6..43987354ae 100644 --- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc +++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc @@ -407,8 +407,7 @@ located at the same level as the application that uses our new import module. This way, the QML engine will find our module as the default search path for QML imports includes the directory of the application executable. On \macos, the plugin binary is copied to \c Contents/PlugIns in the the application bundle; -this path is set in \l {tutorials/extending-qml/chapter6-plugins/app.pro} -{chapter6-plugins/app.pro}: +this path is set in \c {chapter6-plugins/app.pro}: \quotefromfile tutorials/extending-qml/chapter6-plugins/app.pro \skipto osx diff --git a/src/qml/doc/src/javascript/qtjavascript.qdoc b/src/qml/doc/src/javascript/qtjavascript.qdoc index ad93d9d9ac..aa4dce6a37 100644 --- a/src/qml/doc/src/javascript/qtjavascript.qdoc +++ b/src/qml/doc/src/javascript/qtjavascript.qdoc @@ -25,13 +25,6 @@ ** ****************************************************************************/ -/*! - \group qtjavascript - \title Scripting Classes and Overviews - - \brief Classes for embedding JavaScript in Qt/C++ applications. -*/ - /*! \page qtjavascript.html \title Making Applications Scriptable diff --git a/src/qml/doc/src/javascript/string.qdoc b/src/qml/doc/src/javascript/string.qdoc index f896af3378..47922ff17a 100644 --- a/src/qml/doc/src/javascript/string.qdoc +++ b/src/qml/doc/src/javascript/string.qdoc @@ -39,8 +39,8 @@ /*! \qmlmethod string String::arg(value) - Returns a copy of this string with the lowest numbered place marker replaced by value, - i.e., %1, %2, ..., %99. The following example prints "There are 20 items" + Returns a copy of this string with the lowest numbered place marker replaced by \a value, + i.e., %1, %2, ..., %99. The following example prints "There are 20 items": \code var message = "There are %1 items" diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index aab72f8b2d..c41738c811 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -585,7 +585,9 @@ QJSValue QJSEngine::newObject() /*! \since 5.12 - Creates a JavaScript object of class Error. + + Creates a JavaScript object of class Error, with \a message as the error + message. The prototype of the created object will be \a errorType. diff --git a/src/qml/qml/ftw/qintrusivelist.cpp b/src/qml/qml/ftw/qintrusivelist.cpp index eb337a4de0..2ebaffb375 100644 --- a/src/qml/qml/ftw/qintrusivelist.cpp +++ b/src/qml/qml/ftw/qintrusivelist.cpp @@ -150,6 +150,10 @@ Returns an STL-style iterator pointing to the imaginary item after the last item Remove the current object from the list, and return an iterator to the next element. */ +/*! + \class QIntrusiveListNode + \internal +*/ /*! \fn QIntrusiveListNode::QIntrusiveListNode() diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 64dc581a56..4422195e3d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -229,8 +229,10 @@ OwnPropertyKeyIterator *QtObject::virtualOwnPropertyKeys(const Object *m, Value } /*! -\qmlmethod bool Qt::isQtObject(object) -Returns true if \c object is a valid reference to a Qt or QML object, otherwise false. + \qmlmethod bool Qt::isQtObject(object) + + Returns \c true if \a object is a valid reference to a Qt or QML object, + \c false otherwise. */ ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, const Value *argv, int argc) { @@ -241,10 +243,10 @@ ReturnedValue QtObject::method_isQtObject(const FunctionObject *, const Value *, } /*! -\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) + \qmlmethod color Qt::rgba(real red, real green, real blue, real alpha) -Returns a color with the specified \c red, \c green, \c blue and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a red, \a green, \a blue, and \a alpha + components. All components should be in the range 0-1 (inclusive). */ ReturnedValue QtObject::method_rgba(const FunctionObject *f, const Value *, const Value *argv, int argc) { @@ -270,10 +272,10 @@ ReturnedValue QtObject::method_rgba(const FunctionObject *f, const Value *, cons } /*! -\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) + \qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha) -Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a hue, \a saturation, \a lightness, and \a alpha + components. All components should be in the range 0-1 (inclusive). */ ReturnedValue QtObject::method_hsla(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -300,12 +302,12 @@ ReturnedValue QtObject::method_hsla(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod color Qt::hsva(real hue, real saturation, real value, real alpha) + \since 5.5 + \qmlmethod color Qt::hsva(real hue, real saturation, real value, real alpha) -Returns a color with the specified \c hue, \c saturation, \c value and \c alpha components. -All components should be in the range 0-1 inclusive. + Returns a color with the specified \a hue, \a saturation, \a value and \a alpha + components. All components should be in the range 0-1 (inclusive). -\since 5.5 */ ReturnedValue QtObject::method_hsva(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -328,12 +330,12 @@ ReturnedValue QtObject::method_hsva(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod color Qt::colorEqual(color lhs, string rhs) + \qmlmethod color Qt::colorEqual(color lhs, string rhs) -Returns true if both \c lhs and \c rhs yield equal color values. Both arguments -may be either color values or string values. If a string value is supplied it -must be convertible to a color, as described for the \l{colorbasictypedocs}{color} -basic type. + Returns \c true if both \a lhs and \a rhs yield equal color values. Both + arguments may be either color values or string values. If a string value + is supplied it must be convertible to a color, as described for the + \l{colorbasictypedocs}{color} basic type. */ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -368,11 +370,9 @@ ReturnedValue QtObject::method_colorEqual(const FunctionObject *b, const Value * } /*! -\qmlmethod rect Qt::rect(int x, int y, int width, int height) - -Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height. + \qmlmethod rect Qt::rect(int x, int y, int width, int height) -The returned object has \c x, \c y, \c width and \c height attributes with the given values. + Returns a rect with the top-left corner at \a x, \a y and the specified \a width and \a height. */ ReturnedValue QtObject::method_rect(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -389,8 +389,9 @@ ReturnedValue QtObject::method_rect(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod point Qt::point(int x, int y) -Returns a Point with the specified \c x and \c y coordinates. + \qmlmethod point Qt::point(int x, int y) + + Returns a point with the specified \a x and \a y coordinates. */ ReturnedValue QtObject::method_point(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -405,8 +406,9 @@ ReturnedValue QtObject::method_point(const FunctionObject *b, const Value *, con } /*! -\qmlmethod Qt::size(int width, int height) -Returns a Size with the specified \c width and \c height. + \qmlmethod size Qt::size(int width, int height) + + Returns a size with the specified \a width and \a height. */ ReturnedValue QtObject::method_size(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -421,12 +423,13 @@ ReturnedValue QtObject::method_size(const FunctionObject *b, const Value *, cons } /*! -\qmlmethod Qt::font(object fontSpecifier) -Returns a Font with the properties specified in the \c fontSpecifier object -or the nearest matching font. The \c fontSpecifier object should contain -key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's -subproperty names, and the values are valid values for each subproperty. -Invalid keys will be ignored. + \qmlmethod font Qt::font(object fontSpecifier) + + Returns a font with the properties specified in the \a fontSpecifier object + or the nearest matching font. The \a fontSpecifier object should contain + key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's + subproperty names, and the values are valid values for each subproperty. + Invalid keys will be ignored. */ ReturnedValue QtObject::method_font(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -445,8 +448,9 @@ ReturnedValue QtObject::method_font(const FunctionObject *b, const Value *, cons /*! -\qmlmethod Qt::vector2d(real x, real y) -Returns a Vector2D with the specified \c x and \c y. + \qmlmethod vector2d Qt::vector2d(real x, real y) + + Returns a vector2d with the specified \a x and \a y values. */ ReturnedValue QtObject::method_vector2d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -463,8 +467,9 @@ ReturnedValue QtObject::method_vector2d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::vector3d(real x, real y, real z) -Returns a Vector3D with the specified \c x, \c y and \c z. + \qmlmethod vector3d Qt::vector3d(real x, real y, real z) + + Returns a vector3d with the specified \a x, \a y, and \a z values. */ ReturnedValue QtObject::method_vector3d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -482,8 +487,9 @@ ReturnedValue QtObject::method_vector3d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::vector4d(real x, real y, real z, real w) -Returns a Vector4D with the specified \c x, \c y, \c z and \c w. + \qmlmethod vector4d Qt::vector4d(real x, real y, real z, real w) + + Returns a vector4d with the specified \a x, \a y, \a z, and \a w values. */ ReturnedValue QtObject::method_vector4d(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -502,8 +508,9 @@ ReturnedValue QtObject::method_vector4d(const FunctionObject *b, const Value *, } /*! -\qmlmethod Qt::quaternion(real scalar, real x, real y, real z) -Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. + \qmlmethod quaternion Qt::quaternion(real scalar, real x, real y, real z) + + Returns a quaternion with the specified \a scalar, \a x, \a y, and \a z values. */ ReturnedValue QtObject::method_quaternion(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -522,13 +529,25 @@ ReturnedValue QtObject::method_quaternion(const FunctionObject *b, const Value * } /*! -\qmlmethod Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44) -Returns a Matrix4x4 with the specified values. -Alternatively, the function may be called with a single argument -where that argument is a JavaScript array which contains the sixteen -matrix values. -Finally, the function may be called with no arguments and the resulting -matrix will be the identity matrix. + \qmlmethod matrix4x4 Qt::matrix4x4(real m11, real m12, real m13, real m14, real m21, real m22, real m23, real m24, real m31, real m32, real m33, real m34, real m41, real m42, real m43, real m44) + + Returns a matrix4x4 with the specified values. + + The arguments correspond to their positions in the matrix: + + \table + \row \li \a m11 \li \a m12 \li \a m13 \li \a m14 + \row \li \a m21 \li \a m22 \li \a m23 \li \a m24 + \row \li \a m31 \li \a m32 \li \a m33 \li \a m34 + \row \li \a m41 \li \a m42 \li \a m43 \li \a m44 + \endtable + + Alternatively, the function may be called with a single argument + where that argument is a JavaScript array which contains the sixteen + matrix values. + + Finally, the function may be called with no arguments and the resulting + matrix will be the identity matrix. */ ReturnedValue QtObject::method_matrix4x4(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -572,18 +591,19 @@ ReturnedValue QtObject::method_matrix4x4(const FunctionObject *b, const Value *, } /*! -\qmlmethod color Qt::lighter(color baseColor, real factor) -Returns a color lighter than \c baseColor by the \c factor provided. + \qmlmethod color Qt::lighter(color baseColor, real factor) + + Returns a color lighter than \a baseColor by the \a factor provided. -If the factor is greater than 1.0, this functions returns a lighter color. -Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, -the return color is darker, but we recommend using the Qt.darker() function for this purpose. -If the factor is 0 or negative, the return value is unspecified. + If the factor is greater than 1.0, this functions returns a lighter color. + Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, + the return color is darker, but we recommend using the Qt.darker() function for this purpose. + If the factor is 0 or negative, the return value is unspecified. -The function converts the current RGB color to HSV, multiplies the value (V) component -by factor and converts the color back to RGB. + The function converts the current RGB color to HSV, multiplies the value (V) component + by factor and converts the color back to RGB. -If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5). + If \a factor is not supplied, returns a color that is 50% lighter than \a baseColor (factor 1.5). */ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -610,19 +630,20 @@ ReturnedValue QtObject::method_lighter(const FunctionObject *b, const Value *, c } /*! -\qmlmethod color Qt::darker(color baseColor, real factor) -Returns a color darker than \c baseColor by the \c factor provided. + \qmlmethod color Qt::darker(color baseColor, real factor) -If the factor is greater than 1.0, this function returns a darker color. -Setting factor to 3.0 returns a color that has one-third the brightness. -If the factor is less than 1.0, the return color is lighter, but we recommend using -the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return -value is unspecified. + Returns a color darker than \a baseColor by the \a factor provided. -The function converts the current RGB color to HSV, divides the value (V) component -by factor and converts the color back to RGB. + If the factor is greater than 1.0, this function returns a darker color. + Setting factor to 3.0 returns a color that has one-third the brightness. + If the factor is less than 1.0, the return color is lighter, but we recommend using + the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return + value is unspecified. -If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0). + The function converts the current RGB color to HSV, divides the value (V) component + by factor and converts the color back to RGB. + + If \a factor is not supplied, returns a color that is 50% darker than \a baseColor (factor 2.0). */ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -650,7 +671,8 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co /*! \qmlmethod color Qt::tint(color baseColor, color tintColor) - This function allows tinting one color with another. + + This function allows tinting one color (\a baseColor) with another (\a tintColor). The tint color should usually be mostly transparent, or you will not be able to see the underlying color. The below example provides a slight red @@ -670,7 +692,8 @@ ReturnedValue QtObject::method_darker(const FunctionObject *b, const Value *, co \endqml \image declarative-rect_tint.png - Tint is most useful when a subtle change is intended to be conveyed due to some event; you can then use tinting to more effectively tune the visible color. + Tint is most useful when a subtle change is intended to be conveyed due to some event; + you can then use tinting to more effectively tune the visible color. */ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -708,8 +731,8 @@ ReturnedValue QtObject::method_tint(const FunctionObject *b, const Value *, cons /*! \qmlmethod string Qt::formatDate(datetime date, variant format) -Returns a string representation of \c date, optionally formatted according -to \c format. +Returns a string representation of \a date, optionally formatted according +to \a format. The \a date parameter may be a JavaScript \c Date object, a \l{date}{date} property, a QDate, or QDateTime value. The \a format parameter may be any of @@ -752,8 +775,8 @@ ReturnedValue QtObject::method_formatDate(const FunctionObject *b, const Value * /*! \qmlmethod string Qt::formatTime(datetime time, variant format) -Returns a string representation of \c time, optionally formatted according to -\c format. +Returns a string representation of \a time, optionally formatted according to +\a format. The \a time parameter may be a JavaScript \c Date object, a QTime, or QDateTime value. The \a format parameter may be any of the possible format values as @@ -801,10 +824,10 @@ ReturnedValue QtObject::method_formatTime(const FunctionObject *b, const Value * /*! \qmlmethod string Qt::formatDateTime(datetime dateTime, variant format) -Returns a string representation of \c datetime, optionally formatted according to -\c format. +Returns a string representation of \a dateTime, optionally formatted according to +\a format. -The \a date parameter may be a JavaScript \c Date object, a \l{date}{date} +The \a dateTime parameter may be a JavaScript \c Date object, a \l{date}{date} property, a QDate, QTime, or QDateTime value. If \a format is not provided, \a dateTime is formatted using @@ -921,8 +944,8 @@ ReturnedValue QtObject::method_formatDateTime(const FunctionObject *b, const Val /*! \qmlmethod bool Qt::openUrlExternally(url target) - Attempts to open the specified \c target url in an external application, based on the user's - desktop preferences. Returns true if it succeeds, and false otherwise. + Attempts to open the specified \a target url in an external application, based on the user's + desktop preferences. Returns \c true if it succeeds, \c false otherwise. \warning A return value of \c true indicates that the application has successfully requested the operating system to open the URL in an external application. The external application may @@ -942,6 +965,7 @@ ReturnedValue QtObject::method_openUrlExternally(const FunctionObject *b, const /*! \qmlmethod url Qt::resolvedUrl(url url) + Returns \a url resolved relative to the URL of the caller. */ ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value *, const Value *argv, int argc) @@ -967,6 +991,7 @@ ReturnedValue QtObject::method_resolvedUrl(const FunctionObject *b, const Value /*! \qmlmethod list Qt::fontFamilies() + Returns a list of the font families available to the application. */ ReturnedValue QtObject::method_fontFamilies(const FunctionObject *b, const Value *, const Value *, int argc) @@ -980,7 +1005,7 @@ ReturnedValue QtObject::method_fontFamilies(const FunctionObject *b, const Value /*! \qmlmethod string Qt::md5(data) -Returns a hex string of the md5 hash of \c data. +Returns a hex string of the md5 hash of \a data. */ ReturnedValue QtObject::method_md5(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -995,7 +1020,7 @@ ReturnedValue QtObject::method_md5(const FunctionObject *b, const Value *, const /*! \qmlmethod string Qt::btoa(data) -Binary to ASCII - this function returns a base64 encoding of \c data. +Binary to ASCII - this function returns a base64 encoding of \a data. */ ReturnedValue QtObject::method_btoa(const FunctionObject *b, const Value *, const Value *argv, int argc) { @@ -1043,9 +1068,9 @@ ReturnedValue QtObject::method_quit(const FunctionObject *b, const Value *, cons This function causes the QQmlEngine::exit(int) signal to be emitted. Within the \l {Prototyping with qmlscene}, this causes the launcher application to exit - the specified return code. To exit from the event loop with a specified return code when this - method is called, a C++ application can connect the QQmlEngine::exit(int) signal - to the QCoreApplication::exit(int) slot. + the specified return code (\a retCode). To exit from the event loop with a specified + return code when this method is called, a C++ application can connect the + QQmlEngine::exit(int) signal to the QCoreApplication::exit(int) slot. \sa quit() */ @@ -1318,13 +1343,13 @@ ReturnedValue QtObject::method_createComponent(const FunctionObject *b, const Va \qmlmethod Qt::locale(name) Returns a JS object representing the locale with the specified - name, which has the format "language[_territory][.codeset][@modifier]" + \a name, which has the format "language[_territory][.codeset][@modifier]" or "C", where: \list - \li language is a lowercase, two-letter, ISO 639 language code, - \li territory is an uppercase, two-letter, ISO 3166 country code, - \li and codeset and modifier are ignored. + \li \c language is a lowercase, two-letter, ISO 639 language code, + \li \c territory is an uppercase, two-letter, ISO 3166 country code, and + \li \c codeset and \c modifier are ignored. \endlist If the string violates the locale format, or language is not a @@ -1372,7 +1397,8 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction); /*! \qmlmethod Qt::binding(function) - Returns a JavaScript object representing a \l{Property Binding}{property binding}. + Returns a JavaScript object representing a \l{Property Binding}{property binding}, + with a \a function that evaluates the binding. There are two main use-cases for the function: firstly, to apply a property binding imperatively from JavaScript code: diff --git a/src/qml/types/qqmldelegatecomponent.cpp b/src/qml/types/qqmldelegatecomponent.cpp index d6c7ba6bdd..676a524872 100644 --- a/src/qml/types/qqmldelegatecomponent.cpp +++ b/src/qml/types/qqmldelegatecomponent.cpp @@ -58,19 +58,6 @@ QVariant QQmlAbstractDelegateComponent::value(QQmlAdaptorModel *adaptorModel, in return adaptorModel->value(adaptorModel->indexAt(row, column), role); } -/*! - \qmlmodule Qt.labs.qmlmodels 1.0 - \title Qt Labs QML Models - QML Types - \ingroup qmlmodules - \brief The Qt Labs QML Models module provides various model-related types for use with views. - - To use this module, import the module with the following line: - - \qml - import Qt.labs.qmlmodels 1.0 - \endqml -*/ - /*! \qmltype DelegateChoice \instantiates QQmlDelegateChoice diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index af328fbe2a..f58bab7c09 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -540,10 +540,10 @@ void QQmlDelegateModel::setRootIndex(const QVariant &root) \qmlmethod QModelIndex QtQml.Models::DelegateModel::modelIndex(int index) QAbstractItemModel provides a hierarchical tree of data, whereas - QML only operates on list data. This function assists in using + QML only operates on list data. This function assists in using tree models in QML. - Returns a QModelIndex for the specified index. + Returns a QModelIndex for the specified \a index. This value can be assigned to rootIndex. \sa rootIndex diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp index 2f4d427430..525920c6e0 100644 --- a/src/qml/types/qqmlobjectmodel.cpp +++ b/src/qml/types/qqmlobjectmodel.cpp @@ -328,7 +328,7 @@ QObject *QQmlObjectModel::get(int index) const \qmlmethod QtQml.Models::ObjectModel::append(object item) \since 5.6 - Appends a new item to the end of the model. + Appends a new \a item to the end of the model. \code objectModel.append(objectComponent.createObject()) @@ -346,7 +346,7 @@ void QQmlObjectModel::append(QObject *object) \qmlmethod QtQml.Models::ObjectModel::insert(int index, object item) \since 5.6 - Inserts a new item to the model at position \a index. + Inserts a new \a item to the model at position \a index. \code objectModel.insert(2, objectComponent.createObject()) @@ -371,7 +371,7 @@ void QQmlObjectModel::insert(int index, QObject *object) \qmlmethod QtQml.Models::ObjectModel::move(int from, int to, int n = 1) \since 5.6 - Moves \a n items \a from one position \a to another. + Moves \e n items \a from one position \a to another. The from and to ranges must exist; for example, to move the first 3 items to the end of the model: @@ -398,7 +398,7 @@ void QQmlObjectModel::move(int from, int to, int n) \qmlmethod QtQml.Models::ObjectModel::remove(int index, int n = 1) \since 5.6 - Removes the items at \a index from the model. + Removes \e n items at \a index from the model. \sa clear() */ diff --git a/src/quick/handlers/qquicktaphandler.cpp b/src/quick/handlers/qquicktaphandler.cpp index 255e47d73a..3b42c5e536 100644 --- a/src/quick/handlers/qquicktaphandler.cpp +++ b/src/quick/handlers/qquicktaphandler.cpp @@ -388,7 +388,7 @@ void QQuickTapHandler::updateTimeHeld() That is, if you press and release a touchpoint or button within a time period less than \l longPressThreshold, while any movement does not exceed the drag threshold, then the \c tapped signal will be emitted at the time - of release. The \c eventPoint signal parameter contains information + of release. The \a eventPoint signal parameter contains information from the release event about the point that was tapped: \snippet pointerHandlers/tapHandlerOnTapped.qml 0 @@ -401,7 +401,7 @@ void QQuickTapHandler::updateTimeHeld() This signal is emitted when the \c parent Item is tapped once. After an amount of time greater than QStyleHints::mouseDoubleClickInterval, it can be tapped again; but if the time until the next tap is less, - \l tapCount will increase. The \c eventPoint signal parameter contains + \l tapCount will increase. The \a eventPoint signal parameter contains information from the release event about the point that was tapped. */ @@ -413,13 +413,13 @@ void QQuickTapHandler::updateTimeHeld() short span of time (QStyleHints::mouseDoubleClickInterval) and distance (QPlatformTheme::MouseDoubleClickDistance or QPlatformTheme::TouchDoubleTapDistance). This signal always occurs after - \l singleTapped, \l tapped, and \l tapCountChanged. The \c eventPoint + \l singleTapped, \l tapped, and \l tapCountChanged. The \a eventPoint signal parameter contains information from the release event about the point that was tapped. */ /*! - \qmlsignal QtQuick::TapHandler::longPressed + \qmlsignal QtQuick::TapHandler::longPressed() This signal is emitted when the \c parent Item is pressed and held for a time period greater than \l longPressThreshold. That is, if you press and @@ -429,7 +429,7 @@ void QQuickTapHandler::updateTimeHeld() */ /*! - \qmlsignal QtQuick::TapHandler::tapCountChanged + \qmlsignal QtQuick::TapHandler::tapCountChanged() This signal is emitted when the \c parent Item is tapped once or more (within a specified time and distance span) and when the present \c tapCount differs diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 14443a2f2f..3462b0dbac 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -850,13 +850,15 @@ QSGTextureProvider *QQuickCanvasItem::textureProvider() const The \a contextId parameter names the required context. The Canvas item will return a context that implements the required drawing mode. After the first call to getContext, any subsequent call to getContext with the same - contextId will return the same context object. + contextId will return the same context object. Any additional arguments + (\a args) are currently ignored. If the context type is not supported or the canvas has previously been requested to provide a different and incompatible context type, \c null will be returned. Canvas only supports a 2d context. + */ void QQuickCanvasItem::getContext(QQmlV4Function *args) @@ -899,7 +901,7 @@ void QQuickCanvasItem::getContext(QQmlV4Function *args) /*! \qmlmethod int QtQuick::Canvas::requestAnimationFrame(callback) - This function schedules callback to be invoked before composing the Qt Quick + This function schedules \a callback to be invoked before composing the Qt Quick scene. */ @@ -962,7 +964,7 @@ void QQuickCanvasItem::requestPaint() /*! \qmlmethod QtQuick::Canvas::markDirty(rect area) - Mark the given \a area as dirty, so that when this area is visible the + Marks the given \a area as dirty, so that when this area is visible the canvas renderer will redraw it. This will trigger the \c paint signal. \sa paint, requestPaint() @@ -986,16 +988,16 @@ void QQuickCanvasItem::checkAnimationCallbacks() } /*! - \qmlmethod bool QtQuick::Canvas::save(string filename) + \qmlmethod bool QtQuick::Canvas::save(string filename) - Save the current canvas content into an image file \a filename. - The saved image format is automatically decided by the \a filename's - suffix. + Saves the current canvas content into an image file \a filename. + The saved image format is automatically decided by the \a filename's + suffix. Returns \c true on success. - Note: calling this method will force painting the whole canvas, not just the - current canvas visible window. + \note Calling this method will force painting the whole canvas, not just the + current canvas visible window. - \sa canvasWindow, canvasSize, toDataURL() + \sa canvasWindow, canvasSize, toDataURL() */ bool QQuickCanvasItem::save(const QString &filename) const { @@ -1025,15 +1027,17 @@ QQmlRefPointer QQuickCanvasItem::loadedPixmap(const QUrl& ur */ /*! - \qmlmethod QtQuick::Canvas::loadImage(url image) - Loads the given \c image asynchronously. + \qmlmethod QtQuick::Canvas::loadImage(url image) + + Loads the given \a image asynchronously. - When the image is ready, \l imageLoaded will be emitted. - The loaded image can be unloaded by the unloadImage() method. + Once the image is ready, imageLoaded() signal will be emitted. + The loaded image can be unloaded with the unloadImage() method. - Note: Only loaded images can be painted on the Canvas item. - \sa unloadImage, imageLoaded, isImageLoaded(), - Context2D::createImageData(), Context2D::drawImage() + \note Only loaded images can be painted on the Canvas item. + + \sa unloadImage(), imageLoaded(), isImageLoaded(), + Context2D::createImageData(), Context2D::drawImage() */ void QQuickCanvasItem::loadImage(const QUrl& url) { @@ -1053,14 +1057,15 @@ void QQuickCanvasItem::loadImage(const QUrl& url) } } /*! - \qmlmethod QtQuick::Canvas::unloadImage(url image) - Unloads the \c image. + \qmlmethod QtQuick::Canvas::unloadImage(url image) + + Unloads the \a image. - Once an image is unloaded it cannot be painted by the canvas context - unless it is loaded again. + Once an image is unloaded, it cannot be painted by the canvas context + unless it is loaded again. - \sa loadImage(), imageLoaded, isImageLoaded(), - Context2D::createImageData(), Context2D::drawImage + \sa loadImage(), imageLoaded(), isImageLoaded(), + Context2D::createImageData(), Context2D::drawImage */ void QQuickCanvasItem::unloadImage(const QUrl& url) { @@ -1069,10 +1074,11 @@ void QQuickCanvasItem::unloadImage(const QUrl& url) } /*! - \qmlmethod QtQuick::Canvas::isImageError(url image) - Returns true if the \a image failed to load. + \qmlmethod QtQuick::Canvas::isImageError(url image) - \sa loadImage() + Returns \c true if the \a image failed to load, \c false otherwise. + + \sa loadImage() */ bool QQuickCanvasItem::isImageError(const QUrl& url) const { diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 393f8a4a44..7cd222d3c1 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -1149,6 +1149,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(const QV4::FunctionO /*! \qmlmethod object QtQuick::Context2D::setTransform(real a, real b, real c, real d, real e, real f) + Changes the transformation matrix to the matrix given by the arguments as described below. Modifying the transformation matrix directly enables you to perform scaling, @@ -1161,21 +1162,22 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_scale(const QV4::FunctionO \image qml-item-canvas-math.png where: \list - \li \c{a} is the scale factor in the horizontal (x) direction + \li \a{a} is the scale factor in the horizontal (x) direction \image qml-item-canvas-scalex.png - \li \c{c} is the skew factor in the x direction + \li \a{c} is the skew factor in the x direction \image qml-item-canvas-skewx.png - \li \c{e} is the translation in the x direction + \li \a{e} is the translation in the x direction \image qml-item-canvas-translate.png - \li \c{b} is the skew factor in the y (vertical) direction + \li \a{b} is the skew factor in the y (vertical) direction \image qml-item-canvas-skewy.png - \li \c{d} is the scale factor in the y direction + \li \a{d} is the scale factor in the y direction \image qml-item-canvas-scaley.png - \li \c{f} is the translation in the y direction + \li \a{f} is the translation in the y direction \image qml-item-canvas-translatey.png \li the last row remains constant \endlist - The scale factors and skew factors are multiples; \c{e} and \c{f} are + + The scale factors and skew factors are multiples; \a{e} and \a{f} are coordinate space units, just like the units in the translate(x,y) method. @@ -1203,11 +1205,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_setTransform(const QV4::Fu /*! \qmlmethod object QtQuick::Context2D::transform(real a, real b, real c, real d, real e, real f) - This method is very similar to setTransform(), but instead of replacing the old - transform matrix, this method applies the given tranform matrix to the current matrix by multiplying to it. + This method is very similar to setTransform(), but instead of replacing + the old transform matrix, this method applies the given tranform matrix + to the current matrix by multiplying to it. - The setTransform(a, b, c, d, e, f) method actually resets the current transform to the identity matrix, - and then invokes the transform(a, b, c, d, e, f) method with the same arguments. + The setTransform(\a a, \a b, \a c, \a d, \a e, \a f) method actually + resets the current transform to the identity matrix, and then invokes + the transform(\a a, \a b, \a c, \a d, \a e, \a f) method with the same + arguments. \sa setTransform() */ @@ -1627,9 +1632,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(const } /*! - \qmlmethod object QtQuick::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1) - Returns a CanvasGradient object that represents a radial gradient that paints along the cone given by the start circle with - origin (x0, y0) and radius r0, and the end circle with origin (x1, y1) and radius r1. + \qmlmethod object QtQuick::Context2D::createRadialGradient(real x0, real y0, real r0, real x1, real y1, real r1) + + Returns a CanvasGradient object that represents a radial gradient that + paints along the cone given by the start circle with origin (\a x0, \a y0) + and radius \a r0, and the end circle with origin (\a x1, \a y1) and radius + \a r1. \sa CanvasGradient::addColorStop() \sa createLinearGradient() @@ -1680,8 +1688,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(const /*! \qmlmethod object QtQuick::Context2D::createConicalGradient(real x, real y, real angle) - Returns a CanvasGradient object that represents a conical gradient that interpolate colors counter-clockwise around a center point (\c x, \c y) - with start angle \c angle in units of radians. + + Returns a CanvasGradient object that represents a conical gradient that + interpolates colors counter-clockwise around a center point (\a x, \a y) + with a start angle \a angle in units of radians. \sa CanvasGradient::addColorStop() \sa createLinearGradient() @@ -2264,8 +2274,10 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_path(const QV4::FunctionObject //rects /*! - \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. + \qmlmethod object QtQuick::Context2D::clearRect(real x, real y, real w, real h) + + Clears all pixels on the canvas in the rectangle specified by + (\a x, \a y, \a w, \a h) to transparent black. */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2284,8 +2296,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clearRect(const QV4::Funct } /*! - \qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h) - Paint the specified rectangular area using the fillStyle. + \qmlmethod object QtQuick::Context2D::fillRect(real x, real y, real w, real h) + + Paints a rectangular area specified by (\a x, \a y, \a w, \a h) using fillStyle. \sa fillStyle */ @@ -2302,14 +2315,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillRect(const QV4::Functi } /*! - \qmlmethod object QtQuick::Context2D::strokeRect(real x, real y, real w, real h) - Stroke the specified rectangle's path using the strokeStyle, lineWidth, lineJoin, - and (if appropriate) miterLimit attributes. - - \sa strokeStyle - \sa lineWidth - \sa lineJoin - \sa miterLimit + \qmlmethod object QtQuick::Context2D::strokeRect(real x, real y, real w, real h) + + Strokes the path of the rectangle specified by (\a x, \a y, \a w, \a h) using + strokeStyle, lineWidth, lineJoin, and (if appropriate) miterLimit attributes. + + \sa strokeStyle, lineWidth, lineJoin, miterLimit */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2333,7 +2344,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(const QV4::Func circle whose center is at the point (\a x, \a y) and whose radius is \a radius. - Both \c startAngle and \c endAngle are measured from the x-axis in radians. + Both \a startAngle and \a endAngle are measured from the x-axis in radians. \image qml-item-canvas-arc.png @@ -2440,10 +2451,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(const QV4::Funct /*! \qmlmethod object QtQuick::Context2D::bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y) - Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (\c cp1x, cp1y), - and (\c cp2x, \c cp2y). - After the curve is added, the current position is updated to be at the end point (\c x, \c y) of the curve. + Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (\a {cp1x}, \a {cp1y}), + and (\a {cp2x}, \a {cp2y}). + After the curve is added, the current position is updated to be at the end point (\a {x}, \a {y}) of the curve. The following code produces the path shown below: + \code ctx.strokeStyle = Qt.rgba(0, 0, 0, 1); ctx.lineWidth = 1; @@ -2452,7 +2464,9 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(const QV4::Funct ctx.bezierCurveTo(-10, 90, 210, 90, 180, 0); ctx.stroke(); \endcode + \image qml-item-canvas-bezierCurveTo.png + \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} */ @@ -2551,7 +2565,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(const QV4::FunctionOb /*! \qmlmethod object QtQuick::Context2D::lineTo(real x, real y) - Draws a line from the current position to the point (x, y). + Draws a line from the current position to the point at (\a x, \a y). */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2575,7 +2589,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(const QV4::Function /*! \qmlmethod object QtQuick::Context2D::moveTo(real x, real y) - Creates a new subpath with the given point. + Creates a new subpath with a point at (\a x, \a y). */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2596,11 +2610,12 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(const QV4::Function } /*! - \qmlmethod object QtQuick::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y) + \qmlmethod object QtQuick::Context2D::quadraticCurveTo(real cpx, real cpy, real x, real y) - Adds a quadratic bezier curve between the current point and the endpoint (\c x, \c y) with the control point specified by (\c cpx, \c cpy). + Adds a quadratic bezier curve between the current point and the endpoint + (\a x, \a y) with the control point specified by (\a cpx, \a cpy). - See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo} + \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-quadraticcurveto}{W3C 2d context standard for quadraticCurveTo} */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2624,9 +2639,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(const QV4 } /*! - \qmlmethod object QtQuick::Context2D::rect(real x, real y, real w, real h) + \qmlmethod object QtQuick::Context2D::rect(real x, real y, real w, real h) - Adds a rectangle at position (\c x, \c y), with the given width \c w and height \c h, as a closed subpath. + Adds a rectangle at position (\a x, \a y), with the given width \a w and + height \a h, as a closed subpath. */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2641,10 +2657,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(const QV4::FunctionOb } /*! - \qmlmethod object QtQuick::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius) + \qmlmethod object QtQuick::Context2D::roundedRect(real x, real y, real w, real h, real xRadius, real yRadius) - 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. + Adds a rounded-corner rectangle, specified by (\a x, \a y, \a w, \a h), to the path. + The \a xRadius and \a yRadius arguments specify the radius of the + ellipses defining the corners of the rounded rectangle. */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2664,12 +2681,14 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(const QV4::Fun } /*! - \qmlmethod object QtQuick::Context2D::ellipse(real x, real y, real w, real h) + \qmlmethod object QtQuick::Context2D::ellipse(real x, real y, real w, real h) - Creates an ellipse within the bounding rectangle defined by its top-left corner at (\a x, \ y), width \a w and height \a h, - and adds it to the path as a closed subpath. + Creates an ellipse within the bounding rectangle defined by its top-left + corner at (\a x, \a y), width \a w and height \a h, and adds it to the + path as a closed subpath. - The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position). + The ellipse is composed of a clockwise curve, starting and finishing at + zero degrees (the 3 o'clock position). */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2687,8 +2706,11 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(const QV4::Functio /*! \qmlmethod object QtQuick::Context2D::text(string text, real x, real y) - 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). + Adds the given \a 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 (\a x, \a y). */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -2713,9 +2735,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(const QV4::FunctionOb Strokes the subpaths with the current stroke style. - See \l{http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke}{W3C 2d context standard for stroke} - - \sa strokeStyle + \sa strokeStyle, {http://www.w3.org/TR/2dcontext/#dom-context-2d-stroke}{W3C 2d context standard for stroke} */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *, int) { @@ -2731,7 +2751,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(const QV4::Function /*! \qmlmethod object QtQuick::Context2D::isPointInPath(real x, real y) - Returns true if the given point is in the current path. + Returns \c true if the point (\a x, \a y) is in the current path. \sa {http://www.w3.org/TR/2dcontext/#dom-context-2d-ispointinpath}{W3C 2d context standard for isPointInPath} */ @@ -2949,7 +2969,9 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(const QV4::Functio /*! \qmlmethod object QtQuick::Context2D::fillText(text, x, y) - Fills the given text at the given position. + + Fills the specified \a text at the given position (\a x, \a y). + \sa font \sa textAlign \sa textBaseline @@ -2973,13 +2995,15 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(const QV4::Functi RETURN_RESULT(*thisObject); } /*! - \qmlmethod object QtQuick::Context2D::strokeText(text, x, y) - Strokes the given text at the given position. - \sa font - \sa textAlign - \sa textBaseline - \sa fillText - */ + \qmlmethod object QtQuick::Context2D::strokeText(text, x, y) + + Strokes the given \a text at a position specified by (\a x, \a y). + + \sa font + \sa textAlign + \sa textBaseline + \sa fillText +*/ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { QV4::Scope scope(b); @@ -3415,8 +3439,10 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(const QV4: } /*! - \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. + \qmlmethod CanvasImageData QtQuick::Context2D::getImageData(real x, real y, real w, real h) + + Returns an CanvasImageData object containing the image data for the canvas + rectangle specified by (\a x, \a y, \a w, \a h). */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -3442,8 +3468,13 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(const QV4::Fu } /*! - \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. + \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 \a imageData object onto the canvas at + (\a dx, \a dy). + + 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(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { @@ -3536,16 +3567,18 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(const QV4::Fu */ /*! - \qmlmethod CanvasGradient QtQuick::CanvasGradient::addColorStop(real offsetof, string color) - Adds a color stop with the given color to the gradient at the given offset. - 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. + \qmlmethod CanvasGradient QtQuick::CanvasGradient::addColorStop(real offset, string color) - For example: - \code - var gradient = ctx.createLinearGradient(0, 0, 100, 100); - gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1)); - gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1'); - \endcode + Adds a color stop with the given \a color to the gradient at the given \a offset. + 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end. + + For example: + + \code + var gradient = ctx.createLinearGradient(0, 0, 100, 100); + gradient.addColorStop(0.3, Qt.rgba(1, 0, 0, 1)); + gradient.addColorStop(0.7, 'rgba(0, 255, 255, 1'); + \endcode */ QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(const QV4::FunctionObject *b, const QV4::Value *thisObject, const QV4::Value *argv, int argc) { diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index f60f3c1ccf..a900406b17 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -754,7 +754,11 @@ void QQuickDragAttached::cancel() This signal is emitted when a drag finishes and the drag was started with the \l startDrag() method or started automatically using the \l dragType property. + \a dropAction holds the action accepted by the target item. + The corresponding handler is \c onDragFinished. + + \sa drop() */ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedActions) diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp index cb87bdce76..fbbee31653 100644 --- a/src/quick/items/qquickdroparea.cpp +++ b/src/quick/items/qquickdroparea.cpp @@ -209,7 +209,7 @@ qreal QQuickDropAreaDrag::y() const /*! \qmlsignal QtQuick::DropArea::positionChanged(DragEvent drag) - This signal is emitted when the position of a drag has changed. + This signal is emitted when the position of a \a drag has changed. The corresponding handler is \c onPositionChanged. */ @@ -312,7 +312,7 @@ void QQuickDropArea::dragLeaveEvent(QDragLeaveEvent *) /*! \qmlsignal QtQuick::DropArea::dropped(DragEvent drop) - This signal is emitted when a drop event occurs within the bounds of + This signal is emitted when a \a drop event occurs within the bounds of a DropArea. The corresponding handler is \c onDropped. diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index 0b345697ec..4bee4864d5 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -429,7 +429,7 @@ bool QQuickMouseAreaPrivate::propagateHelper(QQuickMouseEvent *ev, QQuickItem *i This signal is emitted in response to both mouse wheel and trackpad scroll gestures. - The \l {WheelEvent}{wheel} parameter provides information about the event, including the x and y + The \a wheel parameter provides information about the event, including the x and y position, any buttons currently pressed, and information about the wheel movement, including angleDelta and pixelDelta. diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 3eca535a67..70426a6a8c 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -410,7 +410,7 @@ void QQuickTouchPoint::setUniqueId(const QPointingDeviceUniqueId &id) area should grab the current touch points. By default they will not be grabbed; to grab them call \c gesture.grab(). If the gesture is not grabbed, the nesting Flickable, for example, would also have an opportunity to grab. - The gesture object also includes information on the current set of \c touchPoints and the \c dragThreshold. + The \a gesture object also includes information on the current set of \c touchPoints and the \c dragThreshold. The corresponding handler is \c onGestureStarted. */ diff --git a/src/quick/items/qquickscreen.cpp b/src/quick/items/qquickscreen.cpp index b057fd9d8f..b17e505f4f 100644 --- a/src/quick/items/qquickscreen.cpp +++ b/src/quick/items/qquickscreen.cpp @@ -229,7 +229,8 @@ QT_BEGIN_NAMESPACE /*! \qmlattachedmethod int Screen::angleBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b) - Returns the rotation angle, in degrees, between the two specified angles. + Returns the rotation angle, in degrees, between the specified screen + orientations \a a and \a b. */ /*! diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index b299e7c92f..ad1a6039c7 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -1065,7 +1065,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const } /*! - \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters) + \qmlmethod QtQuick::TextEdit::moveCursorSelection(int position, SelectionMode mode) Moves the cursor to \a position and updates the selection according to the optional \a mode parameter. (To only move the cursor, set the \l cursorPosition property.) @@ -1076,7 +1076,7 @@ int QQuickTextEdit::positionAt(qreal x, qreal y) const text range. The selection mode specifies whether the selection is updated on a per character or a per word - basis. If not specified the selection mode will default to TextEdit.SelectCharacters. + basis. If not specified the selection mode will default to \c {TextEdit.SelectCharacters}. \list \li TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at @@ -2801,7 +2801,7 @@ QString QQuickTextEdit::getFormattedText(int start, int end) const /*! \qmlmethod QtQuick::TextEdit::insert(int position, string text) - Inserts \a text into the TextEdit at position. + Inserts \a text into the TextEdit at \a position. */ void QQuickTextEdit::insert(int position, const QString &text) { diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 5f6fd8f50f..cd601a8059 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1358,8 +1358,8 @@ void QQuickTextInput::createCursor() /*! \qmlmethod rect QtQuick::TextInput::positionToRectangle(int pos) - This function takes a character position and returns the rectangle that the - cursor would occupy, if it was placed at that character position. + This function takes a character position \a pos and returns the rectangle + that the cursor would occupy, if it was placed at that character position. This is similar to setting the cursorPosition, and then querying the cursor rectangle, but the cursorPosition is not changed. @@ -1389,10 +1389,10 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const } /*! - \qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position = CursorBetweenCharacters) + \qmlmethod int QtQuick::TextInput::positionAt(real x, real y, CursorPosition position) This function returns the character position at - x and y pixels from the top left of the textInput. Position 0 is before the + \a x and \a y pixels from the top left of the textInput. Position 0 is before the first character, position 1 is after the first character but before the second, and so on until position text.length, which is after all characters. @@ -1402,12 +1402,13 @@ QRectF QQuickTextInput::positionToRectangle(int pos) const the first line and if it is below the text the position of the nearest character on the last line will be returned. - The cursor position type specifies how the cursor position should be resolved. + The cursor \a position parameter specifies how the cursor position should be resolved: - \list - \li TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x. - \li TextInput.CursorOnCharacter - Returns the position before the character that is nearest x. - \endlist + \value TextInput.CursorBetweenCharacters + Returns the position between characters that is nearest x. + This is the default value. + \value TextInput.CursorOnCharacter + Returns the position before the character that is nearest x. */ void QQuickTextInput::positionAt(QQmlV4Function *args) const @@ -2131,7 +2132,7 @@ void QQuickTextInput::redo() /*! \qmlmethod QtQuick::TextInput::insert(int position, string text) - Inserts \a text into the TextInput at position. + Inserts \a text into the TextInput at \a position. */ void QQuickTextInput::insert(int position, const QString &text) @@ -2538,7 +2539,7 @@ void QQuickTextInput::moveCursorSelection(int position) } /*! - \qmlmethod QtQuick::TextInput::moveCursorSelection(int position, SelectionMode mode = TextInput.SelectCharacters) + \qmlmethod QtQuick::TextInput::moveCursorSelection(int position, SelectionMode mode) Moves the cursor to \a position and updates the selection according to the optional \a mode parameter. (To only move the cursor, set the \l cursorPosition property.) @@ -2549,7 +2550,7 @@ void QQuickTextInput::moveCursorSelection(int position) text range. The selection mode specifies whether the selection is updated on a per character or a per word - basis. If not specified the selection mode will default to TextInput.SelectCharacters. + basis. If not specified the selection mode will default to \c {TextInput.SelectCharacters}. \list \li TextInput.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at diff --git a/src/quick/util/qquickfontmetrics.cpp b/src/quick/util/qquickfontmetrics.cpp index 42b3038c48..c9a9008180 100644 --- a/src/quick/util/qquickfontmetrics.cpp +++ b/src/quick/util/qquickfontmetrics.cpp @@ -327,10 +327,13 @@ QRectF QQuickFontMetrics::tightBoundingRect(const QString &text) const /*! \qmlmethod string QtQuick::FontMetrics::elidedText(string text, enumeration mode, real width, int flags) - This method returns a returns an elided version of the string (i.e., a + This method returns an elided version of the string (i.e., a string with "..." in it) if the string \a text is wider than \a width. Otherwise, returns the original string. + The \a mode argument specifies the text elide mode; that is, where + the ellipsis should appear when displaying text that doesn't fit. + The \a flags argument is optional and currently only supports \l {Qt::TextShowMnemonic}. @@ -338,7 +341,7 @@ QRectF QQuickFontMetrics::tightBoundingRect(const QString &text) const \l {QQuickTextMetrics::elidedText}{elidedText} property of \l {QQuickTextMetrics::elidedText}{TextMetrics}. - \sa {QFontMetricsF::elidedText()} + \sa Qt::TextElideMode, QFontMetricsF::elidedText() */ QString QQuickFontMetrics::elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags) const { diff --git a/src/quickshapes/qquickshape.cpp b/src/quickshapes/qquickshape.cpp index 0ae16313ca..47b9ae397e 100644 --- a/src/quickshapes/qquickshape.cpp +++ b/src/quickshapes/qquickshape.cpp @@ -89,7 +89,7 @@ QQuickShapeStrokeFillParams::QQuickShapeStrokeFillParams() /*! \qmltype ShapePath - \instantiates QQuickShapePath + //! \instantiates QQuickShapePath \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views @@ -516,7 +516,7 @@ void QQuickShapePath::resetFillGradient() /*! \qmltype Shape - \instantiates QQuickShape + //! \instantiates QQuickShape \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views @@ -1123,7 +1123,7 @@ void QQuickShapePrivate::sync() /*! \qmltype ShapeGradient - \instantiates QQuickShapeGradient + //! \instantiates QQuickShapeGradient \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views @@ -1174,7 +1174,7 @@ void QQuickShapeGradient::setSpread(SpreadMode mode) /*! \qmltype LinearGradient - \instantiates QQuickShapeLinearGradient + //! \instantiates QQuickShapeLinearGradient \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views @@ -1265,7 +1265,7 @@ void QQuickShapeLinearGradient::setY2(qreal v) /*! \qmltype RadialGradient - \instantiates QQuickShapeRadialGradient + //! \instantiates QQuickShapeRadialGradient \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views @@ -1418,7 +1418,7 @@ void QQuickShapeRadialGradient::setFocalRadius(qreal v) /*! \qmltype ConicalGradient - \instantiates QQuickShapeConicalGradient + //! \instantiates QQuickShapeConicalGradient \inqmlmodule QtQuick.Shapes \ingroup qtquick-paths \ingroup qtquick-views -- cgit v1.2.3 From 98f29914e4e233358ef31068542fceeea92eda97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 9 Aug 2019 12:49:04 +0200 Subject: Fix QQuickTextEdit triple click detection It should use the events own timestamps instead of a QTimer. It should give a more accurate measurement of tripleclicks, in addition to that qtestlib synthesized events (with timestamps) are respected. Task-number: QTBUG-77389 Change-Id: I4f553ec17b53a00b55519bb8082f1373aa9d130d Reviewed-by: Shawn Rutledge --- src/quick/items/qquicktextcontrol.cpp | 8 +++----- src/quick/items/qquicktextcontrol_p_p.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index ac8093e10b..5c55f4f43f 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -790,8 +790,6 @@ void QQuickTextControl::timerEvent(QTimerEvent *e) d->cursorOn = !d->cursorOn; d->repaintCursor(); - } else if (e->timerId() == d->tripleClickTimer.timerId()) { - d->tripleClickTimer.stop(); } } @@ -1046,7 +1044,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po commitPreedit(); #endif - if (tripleClickTimer.isActive() + if ((e->timestamp() < (timestampAtLastDoubleClick + QGuiApplication::styleHints()->mouseDoubleClickInterval())) && ((pos - tripleClickPoint).toPoint().manhattanLength() < QGuiApplication::styleHints()->startDragDistance())) { cursor.movePosition(QTextCursor::StartOfBlock); @@ -1056,7 +1054,7 @@ void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &po anchorOnMousePress = QString(); - tripleClickTimer.stop(); + timestampAtLastDoubleClick = 0; // do not enter this condition in case of 4(!) rapid clicks } else { int cursorPos = q->hitTest(pos, Qt::FuzzyHit); if (cursorPos == -1) { @@ -1245,7 +1243,7 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPoin selectedWordOnDoubleClick = cursor; tripleClickPoint = pos; - tripleClickTimer.start(QGuiApplication::styleHints()->mouseDoubleClickInterval(), q); + timestampAtLastDoubleClick = e->timestamp(); if (doEmit) { selectionChanged(); #if QT_CONFIG(clipboard) diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h index 0582e6d113..431bf1b6c4 100644 --- a/src/quick/items/qquicktextcontrol_p_p.h +++ b/src/quick/items/qquicktextcontrol_p_p.h @@ -141,7 +141,7 @@ public: QString hoveredLink; QBasicTimer cursorBlinkTimer; - QBasicTimer tripleClickTimer; + ulong timestampAtLastDoubleClick = 0; // will only be set at a double click #if QT_CONFIG(im) int preeditCursor; -- cgit v1.2.3 From eeb00570679c447f4701a92cd2e836f098724979 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 2 Sep 2019 15:30:17 +0200 Subject: Visit lists iteratively when parsing QML Change-Id: I243d12b75a07ac04560b444c326bff77d0dc642c Fixes: QTBUG-74087 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann (cherry picked from commit 426f3035a3753800ce340a83bdf8db13922f4cae) --- src/qml/parser/qqmljsast.cpp | 73 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 54a1200493..bd8cc38adf 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -238,12 +238,11 @@ void StringLiteral::accept0(Visitor *visitor) void TemplateLiteral::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - if (next) - accept(next, visitor); + bool accepted = true; + for (TemplateLiteral *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + visitor->endVisit(it); } - - visitor->endVisit(this); } void NumericLiteral::accept0(Visitor *visitor) @@ -1013,13 +1012,13 @@ QStringList FormalParameterList::boundNames() const void FormalParameterList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(element, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (FormalParameterList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->element, visitor); + visitor->endVisit(it); } - - visitor->endVisit(this); } FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *pool) @@ -1290,12 +1289,14 @@ void UiPragma::accept0(Visitor *visitor) void UiHeaderItemList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(headerItem, visitor); - accept(next, visitor); - } + bool accepted = true; + for (UiHeaderItemList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->headerItem, visitor); - visitor->endVisit(this); + visitor->endVisit(it); + } } @@ -1359,14 +1360,15 @@ void PatternElement::boundNames(QStringList *names) void PatternElementList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(elision, visitor); - accept(element, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (PatternElementList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) { + accept(it->elision, visitor); + accept(it->element, visitor); + } + visitor->endVisit(it); } - - visitor->endVisit(this); } void PatternElementList::boundNames(QStringList *names) @@ -1395,13 +1397,13 @@ void PatternProperty::boundNames(QStringList *names) void PatternPropertyList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(property, visitor); - if (next) - accept(next, visitor); + bool accepted = true; + for (PatternPropertyList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->property, visitor); + visitor->endVisit(it); } - - visitor->endVisit(this); } void PatternPropertyList::boundNames(QStringList *names) @@ -1446,13 +1448,14 @@ void ClassDeclaration::accept0(Visitor *visitor) void ClassElementList::accept0(Visitor *visitor) { - if (visitor->visit(this)) { - accept(property, visitor); - if (next) - accept(next, visitor); - } + bool accepted = true; + for (ClassElementList *it = this; it && accepted; it = it->next) { + accepted = visitor->visit(it); + if (accepted) + accept(it->property, visitor); - visitor->endVisit(this); + visitor->endVisit(it); + } } ClassElementList *ClassElementList::finish() -- cgit v1.2.3 From db3dd029d7cd911712102efd5ea71868494f9f6f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 13 Jun 2019 12:29:02 +0200 Subject: Fix various accumulator-saving problems We need to keep the accumulator alive across function calls. This requires: 1, Saving the accumulator on the stack if the function might allocate, to protect it from the garbage collector. However, we don't need to do that if the result of the function is to be saved in the accumulator and the function itself doesn't use the accumulator as argument. In this case the previous value becomes unaccessible and we might as well GC it. 2, In the JIT, restoring the accumulator from the stack after the function call if we want to ignore the return value. 3, Therefore, also saving the accumulator on the stack before calling in case of 2. We assume that we don't need to keep the accumulator alive across the jump to the exception handler. Saving the accumulator more often than necessary is detrimental for performance. To make sure the assumption holds, explicitly load the accumulator with undefined _before_ jumping to any exception handler. Change-Id: I78cbc42847b8885a0659b23f3b81655b7f1a0bc4 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4assemblercommon_p.h | 2 +- src/qml/jit/qv4baselineassembler.cpp | 7 ++++++- src/qml/jit/qv4baselineassembler_p.h | 1 + src/qml/jit/qv4baselinejit.cpp | 16 +++++++++++++++- src/qml/jsruntime/qv4vme_moth.cpp | 6 ++++-- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/qml/jit/qv4assemblercommon_p.h b/src/qml/jit/qv4assemblercommon_p.h index 729d0fc53d..dcf39ab636 100644 --- a/src/qml/jit/qv4assemblercommon_p.h +++ b/src/qml/jit/qv4assemblercommon_p.h @@ -621,9 +621,9 @@ public: loadPtr(exceptionHandlerAddress(), ScratchRegister); Jump exitFunction = branchPtr(Equal, ScratchRegister, TrustedImmPtr(0)); + loadUndefined(); jump(ScratchRegister); exitFunction.link(this); - loadUndefined(); if (functionExit.isSet()) jump(functionExit); diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp index b13f646360..73e396890e 100644 --- a/src/qml/jit/qv4baselineassembler.cpp +++ b/src/qml/jit/qv4baselineassembler.cpp @@ -1469,6 +1469,12 @@ void BaselineAssembler::saveAccumulatorInFrame() offsetof(CallData, accumulator))); } +void BaselineAssembler::loadAccumulatorFromFrame() +{ + pasm()->loadAccumulator(PlatformAssembler::Address(PlatformAssembler::JSStackFrameRegister, + offsetof(CallData, accumulator))); +} + static ReturnedValue TheJitIs__Tail_Calling__ToTheRuntimeSoTheJitFrameIsMissing(CppStackFrame *frame, ExecutionEngine *engine) { return Runtime::method_tailCall(frame, engine); @@ -1594,7 +1600,6 @@ void BaselineAssembler::deadTemporalZoneCheck(int offsetForSavedIP, int variable { auto valueIsAliveJump = pasm()->jumpNotEmpty(); storeInstructionPointer(offsetForSavedIP); - saveAccumulatorInFrame(); prepareCallWithArgCount(2); passInt32AsArg(variableName, 1); passEngineAsArg(0); diff --git a/src/qml/jit/qv4baselineassembler_p.h b/src/qml/jit/qv4baselineassembler_p.h index 0aa508ae71..f5ae826c55 100644 --- a/src/qml/jit/qv4baselineassembler_p.h +++ b/src/qml/jit/qv4baselineassembler_p.h @@ -152,6 +152,7 @@ public: void passInt32AsArg(int value, int arg); void callRuntime(const char *functionName, const void *funcPtr, CallResultDestination dest); void saveAccumulatorInFrame(); + void loadAccumulatorFromFrame(); void jsTailCall(int func, int thisObject, int argc, int argv); // exception/context stuff diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index 7bd51ba37e..51cd15099d 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -75,6 +75,7 @@ void BaselineJIT::generate() #define STORE_IP() as->storeInstructionPointer(nextInstructionOffset()) #define STORE_ACC() as->saveAccumulatorInFrame() +#define LOAD_ACC() as->loadAccumulatorFromFrame() #define BASELINEJIT_GENERATE_RUNTIME_CALL(function, destination) \ as->GENERATE_RUNTIME_CALL(function, destination) #define BASELINEJIT_GENERATE_TAIL_CALL(function) \ @@ -233,6 +234,7 @@ void BaselineJIT::generate_StoreNameSloppy(int name) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameSloppy, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_StoreNameStrict(int name) @@ -245,6 +247,7 @@ void BaselineJIT::generate_StoreNameStrict(int name) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeNameStrict, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadElement(int base) @@ -270,6 +273,7 @@ void BaselineJIT::generate_StoreElement(int base, int index) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeElement, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadProperty(int name) @@ -308,6 +312,7 @@ void BaselineJIT::generate_StoreProperty(int name, int base) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeProperty, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_SetLookup(int index, int base) @@ -327,7 +332,6 @@ void BaselineJIT::generate_SetLookup(int index, int base) void BaselineJIT::generate_LoadSuperProperty(int property) { STORE_IP(); - STORE_ACC(); as->prepareCallWithArgCount(2); as->passJSSlotAsArg(property, 1); as->passEngineAsArg(0); @@ -345,6 +349,7 @@ void BaselineJIT::generate_StoreSuperProperty(int property) as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_storeSuperProperty, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_Yield() @@ -589,6 +594,7 @@ void BaselineJIT::generate_PushBlockContext(int index) as->passInt32AsArg(index, 1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushBlockContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_CloneBlockContext() @@ -597,6 +603,7 @@ void BaselineJIT::generate_CloneBlockContext() as->prepareCallWithArgCount(1); as->passJSSlotAsArg(CallData::Context, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::cloneBlockContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PushScriptContext(int index) @@ -607,6 +614,7 @@ void BaselineJIT::generate_PushScriptContext(int index) as->passEngineAsArg(1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::pushScriptContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PopScriptContext() @@ -616,6 +624,7 @@ void BaselineJIT::generate_PopScriptContext() as->passEngineAsArg(1); as->passJSSlotAsArg(0, 0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::popScriptContext, CallResultDestination::Ignore); + as->loadAccumulatorFromFrame(); } void BaselineJIT::generate_PopContext() { as->popContext(); } @@ -716,11 +725,13 @@ void BaselineJIT::generate_TypeofValue() void BaselineJIT::generate_DeclareVar(int varName, int isDeletable) { + STORE_ACC(); as->prepareCallWithArgCount(3); as->passInt32AsArg(varName, 2); as->passInt32AsArg(isDeletable, 1); as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Runtime::method_declareVar, CallResultDestination::Ignore); + LOAD_ACC(); } void BaselineJIT::generate_DefineArray(int argc, int args) @@ -778,11 +789,13 @@ void BaselineJIT::generate_CreateRestParameter(int argIndex) void BaselineJIT::generate_ConvertThisToObject() { + STORE_ACC(); as->prepareCallWithArgCount(2); as->passJSSlotAsArg(CallData::This, 1); as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::convertThisToObject, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_LoadSuperConstructor() @@ -909,6 +922,7 @@ void BaselineJIT::generate_ThrowOnNullOrUndefined() as->passEngineAsArg(0); BASELINEJIT_GENERATE_RUNTIME_CALL(Helpers::throwOnNullOrUndefined, CallResultDestination::Ignore); as->checkException(); + LOAD_ACC(); } void BaselineJIT::generate_GetTemplateObject(int index) diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index c69bb67061..47ad22f4f7 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -640,7 +640,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(LoadSuperProperty) STORE_IP(); - STORE_ACC(); acc = Runtime::method_loadSuperProperty(engine, STACK_VALUE(property)); CHECK_EXCEPTION; MOTH_END_INSTR(LoadSuperProperty) @@ -787,12 +786,14 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(Construct) STORE_IP(); + STORE_ACC(); acc = Runtime::method_construct(engine, STACK_VALUE(func), ACC, stack + argv, argc); CHECK_EXCEPTION; MOTH_END_INSTR(Construct) MOTH_BEGIN_INSTR(ConstructWithSpread) STORE_IP(); + STORE_ACC(); acc = Runtime::method_constructWithSpread(engine, STACK_VALUE(func), ACC, stack + argv, argc); CHECK_EXCEPTION; MOTH_END_INSTR(ConstructWithSpread) @@ -820,7 +821,6 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_BEGIN_INSTR(DeadTemporalZoneCheck) if (ACC.isEmpty()) { STORE_IP(); - STORE_ACC(); Runtime::method_throwReferenceError(engine, name); goto handleUnwind; } @@ -989,6 +989,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, if (t->isNullOrUndefined()) { *t = engine->globalObject->asReturnedValue(); } else { + STORE_ACC(); *t = t->toObject(engine)->asReturnedValue(); CHECK_EXCEPTION; } @@ -1001,6 +1002,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_END_INSTR(LoadSuperConstructor) MOTH_BEGIN_INSTR(ToObject) + STORE_ACC(); acc = ACC.toObject(engine)->asReturnedValue(); CHECK_EXCEPTION; MOTH_END_INSTR(ToObject) -- cgit v1.2.3 From ac3698ae6aaac437e21f3ce08117ea6eedb148dc Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 4 Sep 2019 14:46:29 +0200 Subject: lancelot graphics test: prepare for new host info mechanism The old hacky way of the test running a "hostinfo.sh" script is about to be removed, see https://codereview.qt-project.org/c/qt/qtbase/+/272694 Insted add the value of QT_QUICK_BACKEND (the only not-automatically-gathered important piece of host information) programmatically. As a driveby, update it from the obsolete name "QMLSCENE_DEVICE". Change-Id: If95a4ccc89ec1c32bf03743071261dfa1b8f5b4d Reviewed-by: Allan Sandfeld Jensen --- tests/manual/scenegraph_lancelot/hostinfo.sh | 76 ---------------------- .../scenegraph/tst_scenegraph.cpp | 4 ++ 2 files changed, 4 insertions(+), 76 deletions(-) delete mode 100644 tests/manual/scenegraph_lancelot/hostinfo.sh diff --git a/tests/manual/scenegraph_lancelot/hostinfo.sh b/tests/manual/scenegraph_lancelot/hostinfo.sh deleted file mode 100644 index 6bad2ba467..0000000000 --- a/tests/manual/scenegraph_lancelot/hostinfo.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the QtQml module of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## 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 General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## 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-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -# printProperty(): prints a key-value pair from given key and cmd list. -# If running cmd fails, or does not produce any stdout, nothing is printed. -# Arguments: $1: key, $2: cmd, $3: optional, field specification as to cut(1) -f -printProperty () -{ - key=$1 - val=`{ eval $2 ; } 2>/dev/null` - [ -n "$3" ] && val=`echo $val | tr -s '[:blank:]' '\t' | cut -f$3` - [ -n "$val" ] && echo $key: $val -} - -# printEnvVar(): prints a key-value pair from given environment variable name. -# key is printed as "Env_". -# If the variable is undefined, nothing is printed. -# Arguments: $1: varname - -printEnvVar () -{ - key=Env_$1 - val=`eval 'echo $'$1` - [ -n "$val" ] && echo $key: $val -} - - -# printOnOff(): prints a key-value pair from given environment variable name. -# If variable is defined, value is printed as "-On"; otherwise "-Off". -# Arguments: $1: key $2: varname - -printOnOff () -{ - key=$1 - val=`eval 'echo $'$2` - if [ -z "$val" ] ; then - val=Off - else - val=On - fi - echo $key: $key-$val -} - -# ------------ - -printProperty Uname "uname -a" - -printProperty WlanMAC "ifconfig wlan0 | grep HWaddr" 5 - -printEnvVar QMLSCENE_DEVICE diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp index 3f28d90e7b..95188ec0f8 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp +++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp @@ -81,6 +81,10 @@ tst_Scenegraph::tst_Scenegraph() void tst_Scenegraph::initTestCase() { + const char *backendVarName = "QT_QUICK_BACKEND"; + const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default")); + QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend); + QByteArray msg; if (!QBaselineTest::connectToBaselineServer(&msg)) QSKIP(msg); -- cgit v1.2.3 From 69f5eabe45adcb3d07f7c955251f9106270690da Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 2 Sep 2019 15:34:45 +0200 Subject: QQuickWidget: state that we want premul alpha based blending Task-number: QTBUG-77471 Change-Id: I819c4e0cf751a12726a170f2c48f63f003c549a1 Reviewed-by: Paul Olav Tvete --- src/quickwidgets/qquickwidget.cpp | 7 +++++++ src/quickwidgets/qquickwidget_p.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index db76f3e62a..0da9b12e86 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -1119,6 +1119,13 @@ GLuint QQuickWidgetPrivate::textureId() const return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0); } + +QPlatformTextureList::Flags QQuickWidgetPrivate::textureListFlags() +{ + QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags(); + flags |= QPlatformTextureList::NeedsPremultipliedAlphaBlending; + return flags; +} #endif /*! diff --git a/src/quickwidgets/qquickwidget_p.h b/src/quickwidgets/qquickwidget_p.h index 03571e8dc7..f4f9db7772 100644 --- a/src/quickwidgets/qquickwidget_p.h +++ b/src/quickwidgets/qquickwidget_p.h @@ -101,6 +101,7 @@ public: #if QT_CONFIG(opengl) GLuint textureId() const override; + QPlatformTextureList::Flags textureListFlags() override; QImage grabFramebuffer() override; #else QImage grabFramebuffer(); -- cgit v1.2.3 From 264766764e9d0ddf25442a27b900287623826eb7 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 9 Sep 2019 10:21:40 +0200 Subject: Drop expendable rhi data when in release(Cached)Resources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that a suitable function is introduced in QRhi, call it. Change-Id: I6328a4be90418015384b472655c9b8ad34a07e12 Reviewed-by: Christian Strømme --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 336107a61d..c7bc3d6abc 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -1123,6 +1123,9 @@ void Renderer::releaseCachedResources() m_pipelines.clear(); m_samplers.clear(); m_dummyTexture = nullptr; + + if (m_rhi) + m_rhi->releaseCachedResources(); } void Renderer::invalidateAndRecycleBatch(Batch *b) -- cgit v1.2.3 From 2b566231a6e35ee1646754cee09b30fc99240a80 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Sun, 8 Sep 2019 01:40:19 +0800 Subject: QQuickFolderListModel: make sure properties' values can be update There are some properties in FolderListModel neglect to update their values, although the new values are passed to the thread which does the real work [ChangeLog][QtQuick][QQuickFolderListModel] update the values of some properties when setting new values to them Fixes: QTBUG-77965 Change-Id: I77db3388cee569479459deaa2e19546a77da6178 Reviewed-by: Ulf Hermann --- .../folderlistmodel/qquickfolderlistmodel.cpp | 4 +++ .../tst_qquickfolderlistmodel.cpp | 42 ++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index affb1e9fe2..49836ad10c 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -731,6 +731,7 @@ void QQuickFolderListModel::setShowDotAndDotDot(bool on) if (on != d->showDotAndDotDot) { d->fileInfoThread.setShowDotAndDotDot(on); + d->showDotAndDotDot = on; } } @@ -756,6 +757,7 @@ void QQuickFolderListModel::setShowHidden(bool on) if (on != d->showHidden) { d->fileInfoThread.setShowHidden(on); + d->showHidden = on; } } @@ -781,6 +783,7 @@ void QQuickFolderListModel::setShowOnlyReadable(bool on) if (on != d->showOnlyReadable) { d->fileInfoThread.setShowOnlyReadable(on); + d->showOnlyReadable = on; } } @@ -805,6 +808,7 @@ void QQuickFolderListModel::setCaseSensitive(bool on) if (on != d->caseSensitive) { d->fileInfoThread.setCaseSensitive(on); + d->caseSensitive = on; } } diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index b7600351b7..ae99e35467 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -75,6 +75,7 @@ private slots: void introspectQrc(); void sortCaseSensitive_data(); void sortCaseSensitive(); + void updateProperties(); private: void checkNoErrors(const QQmlComponent& component); QQmlEngine engine; @@ -425,6 +426,47 @@ void tst_qquickfolderlistmodel::sortCaseSensitive() QTRY_COMPARE(flm->data(flm->index(i),FileNameRole).toString(), expectedOrder.at(i)); } +void tst_qquickfolderlistmodel::updateProperties() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QObject *folderListModel = component.create(); + QVERIFY(folderListModel); + + QVariant caseSensitive = folderListModel->property("caseSensitive"); + QVERIFY(caseSensitive.isValid()); + QCOMPARE(caseSensitive.toBool(), true); + folderListModel->setProperty("caseSensitive", false); + caseSensitive = folderListModel->property("caseSensitive"); + QVERIFY(caseSensitive.isValid()); + QCOMPARE(caseSensitive.toBool(), false); + + QVariant showOnlyReadable = folderListModel->property("showOnlyReadable"); + QVERIFY(showOnlyReadable.isValid()); + QCOMPARE(showOnlyReadable.toBool(), false); + folderListModel->setProperty("showOnlyReadable", true); + showOnlyReadable = folderListModel->property("showOnlyReadable"); + QVERIFY(showOnlyReadable.isValid()); + QCOMPARE(showOnlyReadable.toBool(), true); + + QVariant showDotAndDotDot = folderListModel->property("showDotAndDotDot"); + QVERIFY(showDotAndDotDot.isValid()); + QCOMPARE(showDotAndDotDot.toBool(), false); + folderListModel->setProperty("showDotAndDotDot", true); + showDotAndDotDot = folderListModel->property("showDotAndDotDot"); + QVERIFY(showDotAndDotDot.isValid()); + QCOMPARE(showDotAndDotDot.toBool(), true); + + QVariant showHidden = folderListModel->property("showHidden"); + QVERIFY(showHidden.isValid()); + QCOMPARE(showHidden.toBool(), false); + folderListModel->setProperty("showHidden", true); + showHidden = folderListModel->property("showHidden"); + QVERIFY(showHidden.isValid()); + QCOMPARE(showHidden.toBool(), true); +} + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" -- cgit v1.2.3 From 1bb96cfcce47152c578bcc9a7c2ad80b0f0e6553 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 9 Sep 2019 15:31:26 +0200 Subject: Request correct alpha composition on the rhi code path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-78089 Change-Id: I22f8bb5ec0af33397df14e064a0306bd4c5a5ef5 Reviewed-by: Christian Strømme --- src/quick/scenegraph/qsgrenderloop.cpp | 11 ++++++++++- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 10 +++++++++- tests/manual/nodetypes_ng/nodetypes_ng.cpp | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index f15105168e..25d10d37d4 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -561,6 +561,14 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab + // QQ is always premul alpha. Decide based on alphaBufferSize in + // requestedFormat(). (the platform plugin can override format() but + // what matters here is what the application wanted, hence using the + // requested one) + const bool alpha = window->requestedFormat().alphaBufferSize() > 0; + if (alpha) + flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; + cd->swapchain = rhi->newSwapChain(); cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(), @@ -568,7 +576,8 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) QRhiRenderBuffer::UsedWithSwapChainOnly); cd->swapchain->setWindow(window); cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain); - qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d", rhiSampleCount); + qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s", + rhiSampleCount, alpha ? "yes" : "no"); cd->swapchain->setSampleCount(rhiSampleCount); cd->swapchain->setFlags(flags); cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor(); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 9bcb96a65a..eb6eec342c 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -924,6 +924,13 @@ void QSGRenderThread::run() if (rhi && !cd->swapchain) { cd->rhi = rhi; QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab + // QQ is always premul alpha. Decide based on alphaBufferSize in + // requestedFormat(). (the platform plugin can override format() but + // what matters here is what the application wanted, hence using the + // requested one) + const bool alpha = window->requestedFormat().alphaBufferSize() > 0; + if (alpha) + flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; cd->swapchain = rhi->newSwapChain(); cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(), @@ -931,7 +938,8 @@ void QSGRenderThread::run() QRhiRenderBuffer::UsedWithSwapChainOnly); cd->swapchain->setWindow(window); cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain); - qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d", rhiSampleCount); + qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s.", + rhiSampleCount, alpha ? "yes" : "no"); cd->swapchain->setSampleCount(rhiSampleCount); cd->swapchain->setFlags(flags); cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor(); diff --git a/tests/manual/nodetypes_ng/nodetypes_ng.cpp b/tests/manual/nodetypes_ng/nodetypes_ng.cpp index 829002b538..8fe0e0dc98 100644 --- a/tests/manual/nodetypes_ng/nodetypes_ng.cpp +++ b/tests/manual/nodetypes_ng/nodetypes_ng.cpp @@ -301,6 +301,13 @@ int main(int argc, char **argv) fmt.setProfile(QSurfaceFormat::CoreProfile); view.setFormat(fmt); } + if (app.arguments().contains(QLatin1String("--transparent"))) { + qDebug("Requesting alpha channel for the window and using Qt::transparent as background"); + QSurfaceFormat fmt = view.format(); + fmt.setAlphaBufferSize(8); + view.setFormat(fmt); + view.setColor(Qt::transparent); + } view.engine()->rootContext()->setContextProperty(QLatin1String("helper"), &helper); -- cgit v1.2.3 From d38bac596946c3dd9cce3c0b4127509421dc917d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Sep 2019 14:29:51 +0200 Subject: Fix gcc warnings in vulkanunderqml example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iea81662f39d2a128cea0e83a766395e0fb1e9896 Reviewed-by: Christian Strømme --- examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp index 59e9606e7b..6e24391257 100644 --- a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp +++ b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp @@ -362,13 +362,13 @@ void SquircleRenderer::init(int framesInFlight) } } } - if (memTypeIndex < 0) + if (memTypeIndex == uint32_t(-1)) qFatal("Failed to find host visible and coherent memory type"); allocInfo.memoryTypeIndex = memTypeIndex; err = m_devFuncs->vkAllocateMemory(m_dev, &allocInfo, nullptr, &m_vbufMem); if (err != VK_SUCCESS) - qFatal("Failed to allocate vertex buffer memory of size %llu: %d", allocInfo.allocationSize, err); + qFatal("Failed to allocate vertex buffer memory of size %u: %d", uint(allocInfo.allocationSize), err); void *p = nullptr; err = m_devFuncs->vkMapMemory(m_dev, m_vbufMem, 0, allocInfo.allocationSize, 0, &p); @@ -412,14 +412,14 @@ void SquircleRenderer::init(int framesInFlight) } } } - if (memTypeIndex < 0) + if (memTypeIndex == uint32_t(-1)) qFatal("Failed to find host visible and coherent memory type"); allocInfo.allocationSize = framesInFlight * m_allocPerUbuf; allocInfo.memoryTypeIndex = memTypeIndex; err = m_devFuncs->vkAllocateMemory(m_dev, &allocInfo, nullptr, &m_ubufMem); if (err != VK_SUCCESS) - qFatal("Failed to allocate uniform buffer memory of size %llu: %d", allocInfo.allocationSize, err); + qFatal("Failed to allocate uniform buffer memory of size %u: %d", uint(allocInfo.allocationSize), err); err = m_devFuncs->vkBindBufferMemory(m_dev, m_ubuf, m_ubufMem, 0); if (err != VK_SUCCESS) -- cgit v1.2.3 From 5ca1d2e0b2912e578a32c5e11b4fd1d7a0ef28f3 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 11 Sep 2019 16:38:29 +0200 Subject: QQmlTypeLoader: Prevent trivial cycles The type loader already contained a cycle check, however it did not work for the attached example. We now do an additional test for A->B->A cycles, which fixes the bug. This is a valid strategy, as in that case the currently resolved type would immediately fullfill the depentency of the type waiting on it, which in turn resolves the only dependency of the current type. Fixes: QTBUG-78098 Change-Id: I8b550a1c240d3d0fbf158beb99a5daf992904cb0 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmldatablob_p.h | 2 ++ src/qml/qml/qqmltypedata.cpp | 2 +- .../qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml | 5 +++++ .../data/Com/Orga/Handlers/Handler.qml | 7 +++++++ .../qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir | 2 ++ .../auto/qml/qqmltypeloader/data/Com/Orga/Style.qml | 6 ++++++ tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir | 2 ++ tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 20 +++++++++++++++++++- 8 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir diff --git a/src/qml/qml/qqmldatablob_p.h b/src/qml/qml/qqmldatablob_p.h index da3bbe2c1f..0450e94c02 100644 --- a/src/qml/qml/qqmldatablob_p.h +++ b/src/qml/qml/qqmldatablob_p.h @@ -242,7 +242,9 @@ private: mutable QString m_finalUrlString; // List of QQmlDataBlob's that are waiting for me to complete. +protected: QList m_waitingOnMe; +private: // List of QQmlDataBlob's that I am waiting for to complete. QVector> m_waitingFor; diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 8d75b57fc1..b9fbf40e96 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -678,7 +678,7 @@ void QQmlTypeData::resolveTypes() if (ref.type.isCompositeSingleton()) { ref.typeData = typeLoader()->getType(ref.type.sourceUrl()); - if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies) { + if (ref.typeData->status() == QQmlDataBlob::ResolvingDependencies || m_waitingOnMe.contains(ref.typeData.data())) { // TODO: give an error message? If so, we should record and show the path of the cycle. continue; } diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml new file mode 100644 index 0000000000..28521e3af2 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml @@ -0,0 +1,5 @@ +import QtQuick 2.6 + +Item { + +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml new file mode 100644 index 0000000000..b20a2def11 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml @@ -0,0 +1,7 @@ +import QtQuick 2.6 +import Com.Orga 1.0 + +Rectangle { + color: Style.name + Text {text: "Hello world!"} +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir new file mode 100644 index 0000000000..368cb65b35 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir @@ -0,0 +1,2 @@ +module Com.Orga.Handlers +Handler 1.0 Handler.qml diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml new file mode 100644 index 0000000000..7951f5e768 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.6 + +BaseStyle { + property color name: "black" +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir b/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir new file mode 100644 index 0000000000..9c5560b323 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir @@ -0,0 +1,2 @@ +singleton Style 1.0 Style.qml +BaseStyle 1.0 BaseStyle.qml diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 2993b4b3c8..9ad53aaa8b 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -60,6 +60,7 @@ private slots: void implicitComponentModule(); void qrcRootPathUrl(); void implicitImport(); + void compositeSingletonCycle(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -434,7 +435,7 @@ void tst_QQMLTypeLoader::redirect() component.loadUrl(server.urlString("/Load.qml"), QQmlComponent::Asynchronous); QTRY_VERIFY2(component.isReady(), qPrintable(component.errorString())); - QObject *object = component.create(); + QScopedPointer object {component.create()}; QTRY_COMPARE(object->property("xy").toInt(), 323232); } @@ -524,6 +525,23 @@ void tst_QQMLTypeLoader::implicitImport() QVERIFY(!obj.isNull()); } +void tst_QQMLTypeLoader::compositeSingletonCycle() +{ + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + QVERIFY(server.serveDirectory(dataDirectory())); + + QQmlEngine engine; + QQmlComponent component(&engine); + engine.addImportPath(server.baseUrl().toString()); + component.loadUrl(server.urlString("Com/Orga/Handlers/Handler.qml"), QQmlComponent::Asynchronous); + QTRY_VERIFY2(component.isReady(), qPrintable(component.errorString())); + + QScopedPointer object {component.create()}; + QVERIFY(object); + QCOMPARE(qvariant_cast(object->property("color")), QColorConstants::Black); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" -- cgit v1.2.3 From d0d2e7da01963988441aa41a9616fb3a904306b2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 30 Aug 2019 11:55:33 +0200 Subject: Rename textureinsgnode example to a more fitting name It shows QQuickFramebufferObject. "Texture in QSGNode" is ambiguous as it suggests another type of use case (where an existing texture is imported and used with the QQ scene - without rendering to it). This would conflict with upcoming future examples, so rename to fboitem, which is what this example is about. The link from examples.qdoc is already using the fitting title so that will just work. Change-Id: Ide7a563398a4b464c55f14e10fa9386432b3d06d Reviewed-by: Andy Nichols --- .../fboitem/doc/images/fboitem-example.jpg | Bin 0 -> 25863 bytes .../quick/scenegraph/fboitem/doc/src/fboitem.qdoc | 36 ++++++ .../quick/scenegraph/fboitem/fboinsgrenderer.cpp | 85 ++++++++++++ .../quick/scenegraph/fboitem/fboinsgrenderer.h | 65 ++++++++++ examples/quick/scenegraph/fboitem/fboitem.pro | 16 +++ examples/quick/scenegraph/fboitem/fboitem.qrc | 5 + examples/quick/scenegraph/fboitem/main.cpp | 69 ++++++++++ examples/quick/scenegraph/fboitem/main.qml | 142 +++++++++++++++++++++ examples/quick/scenegraph/scenegraph.pro | 2 +- .../doc/images/textureinsgnode-example.jpg | Bin 25863 -> 0 bytes .../textureinsgnode/doc/src/textureinsgnode.qdoc | 36 ------ .../scenegraph/textureinsgnode/fboinsgrenderer.cpp | 85 ------------ .../scenegraph/textureinsgnode/fboinsgrenderer.h | 65 ---------- examples/quick/scenegraph/textureinsgnode/main.cpp | 69 ---------- examples/quick/scenegraph/textureinsgnode/main.qml | 142 --------------------- .../scenegraph/textureinsgnode/textureinsgnode.pro | 16 --- .../scenegraph/textureinsgnode/textureinsgnode.qrc | 5 - 17 files changed, 419 insertions(+), 419 deletions(-) create mode 100644 examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg create mode 100644 examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc create mode 100644 examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp create mode 100644 examples/quick/scenegraph/fboitem/fboinsgrenderer.h create mode 100644 examples/quick/scenegraph/fboitem/fboitem.pro create mode 100644 examples/quick/scenegraph/fboitem/fboitem.qrc create mode 100644 examples/quick/scenegraph/fboitem/main.cpp create mode 100644 examples/quick/scenegraph/fboitem/main.qml delete mode 100644 examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg delete mode 100644 examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc delete mode 100644 examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp delete mode 100644 examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h delete mode 100644 examples/quick/scenegraph/textureinsgnode/main.cpp delete mode 100644 examples/quick/scenegraph/textureinsgnode/main.qml delete mode 100644 examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro delete mode 100644 examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc diff --git a/examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg b/examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg new file mode 100644 index 0000000000..306b8bab20 Binary files /dev/null and b/examples/quick/scenegraph/fboitem/doc/images/fboitem-example.jpg differ diff --git a/examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc b/examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc new file mode 100644 index 0000000000..b5add02991 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/doc/src/fboitem.qdoc @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example scenegraph/fboitem + \title Scene Graph - Rendering FBOs + \ingroup qtquickexamples + + \brief Shows how to use FramebufferObjects with Qt Quick. + + \image fboitem-example.jpg + */ diff --git a/examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp b/examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp new file mode 100644 index 0000000000..8ba5bddb2a --- /dev/null +++ b/examples/quick/scenegraph/fboitem/fboinsgrenderer.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fboinsgrenderer.h" +#include "logorenderer.h" + +#include + +#include +#include + +class LogoInFboRenderer : public QQuickFramebufferObject::Renderer +{ +public: + LogoInFboRenderer() + { + logo.initialize(); + } + + void render() override { + logo.render(); + update(); + } + + QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override { + QOpenGLFramebufferObjectFormat format; + format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + format.setSamples(4); + return new QOpenGLFramebufferObject(size, format); + } + + LogoRenderer logo; +}; + +QQuickFramebufferObject::Renderer *FboInSGRenderer::createRenderer() const +{ + return new LogoInFboRenderer(); +} diff --git a/examples/quick/scenegraph/fboitem/fboinsgrenderer.h b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h new file mode 100644 index 0000000000..e1a9ce22c8 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/fboinsgrenderer.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FBOINSGRENDERER_H +#define FBOINSGRENDERER_H + +#include + +class LogoRenderer; + +class FboInSGRenderer : public QQuickFramebufferObject +{ + Q_OBJECT +public: + Renderer *createRenderer() const; +}; + +#endif diff --git a/examples/quick/scenegraph/fboitem/fboitem.pro b/examples/quick/scenegraph/fboitem/fboitem.pro new file mode 100644 index 0000000000..e40e5f4cf8 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/fboitem.pro @@ -0,0 +1,16 @@ +QT += qml quick + +HEADERS += fboinsgrenderer.h +SOURCES += fboinsgrenderer.cpp main.cpp + +INCLUDEPATH += ../shared +HEADERS += ../shared/logorenderer.h +SOURCES += ../shared/logorenderer.cpp + +RESOURCES += fboitem.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/fboitem +INSTALLS += target + +OTHER_FILES += \ + main.qml diff --git a/examples/quick/scenegraph/fboitem/fboitem.qrc b/examples/quick/scenegraph/fboitem/fboitem.qrc new file mode 100644 index 0000000000..9d9db70654 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/fboitem.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/examples/quick/scenegraph/fboitem/main.cpp b/examples/quick/scenegraph/fboitem/main.cpp new file mode 100644 index 0000000000..429224ba95 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/main.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include "fboinsgrenderer.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("SceneGraphRendering", 1, 0, "Renderer"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///scenegraph/fboitem/main.qml")); + view.show(); + + return app.exec(); +} diff --git a/examples/quick/scenegraph/fboitem/main.qml b/examples/quick/scenegraph/fboitem/main.qml new file mode 100644 index 0000000000..92fa99e847 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/main.qml @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +import SceneGraphRendering 1.0 + +Item { + width: 400 + height: 400 + + // The checkers background + ShaderEffect { + id: tileBackground + anchors.fill: parent + + property real tileSize: 16 + property color color1: Qt.rgba(0.9, 0.9, 0.9, 1); + property color color2: Qt.rgba(0.85, 0.85, 0.85, 1); + + property size pixelSize: Qt.size(width / tileSize, height / tileSize); + + fragmentShader: + " + uniform lowp vec4 color1; + uniform lowp vec4 color2; + uniform highp vec2 pixelSize; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize)); + if (tc.x != tc.y) + gl_FragColor = color1; + else + gl_FragColor = color2; + } + " + } + + Renderer { + id: renderer + anchors.fill: parent + anchors.margins: 10 + + // The transform is just to show something interesting.. + transform: [ + Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; }, + Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 }, + Scale { id: scale; }, + Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 } + ] + } + + // Just to show something interesting + SequentialAnimation { + PauseAnimation { duration: 5000 } + ParallelAnimation { + NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack } + NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack } + } + NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic } + NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic } + NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic } + NumberAnimation { target: renderer; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic } + PauseAnimation { duration: 1000 } + NumberAnimation { target: renderer; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic } + ParallelAnimation { + NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack } + NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack } + } + running: true + loops: Animation.Infinite + } + + Rectangle { + id: labelFrame + anchors.margins: -10 + radius: 5 + color: "white" + border.color: "black" + opacity: 0.8 + anchors.fill: label + } + + Text { + id: label + anchors.bottom: renderer.bottom + anchors.left: renderer.left + anchors.right: renderer.right + anchors.margins: 20 + wrapMode: Text.WordWrap + text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application on the scene graph rendering thread. The FBO is managed and displayed using the QQuickFramebufferObject convenience class." + } + + +} diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro index e05e1ddb44..5fea3b974a 100644 --- a/examples/quick/scenegraph/scenegraph.pro +++ b/examples/quick/scenegraph/scenegraph.pro @@ -5,7 +5,7 @@ qtConfig(opengl(es1|es2)?) { graph \ simplematerial \ sgengine \ - textureinsgnode \ + fboitem \ openglunderqml \ textureinthread \ twotextureproviders diff --git a/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg b/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg deleted file mode 100644 index 306b8bab20..0000000000 Binary files a/examples/quick/scenegraph/textureinsgnode/doc/images/textureinsgnode-example.jpg and /dev/null differ diff --git a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc b/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc deleted file mode 100644 index c1c830338b..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/doc/src/textureinsgnode.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example scenegraph/textureinsgnode - \title Scene Graph - Rendering FBOs - \ingroup qtquickexamples - - \brief Shows how to use FramebufferObjects with Qt Quick. - - \image textureinsgnode-example.jpg - */ diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp deleted file mode 100644 index 8ba5bddb2a..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "fboinsgrenderer.h" -#include "logorenderer.h" - -#include - -#include -#include - -class LogoInFboRenderer : public QQuickFramebufferObject::Renderer -{ -public: - LogoInFboRenderer() - { - logo.initialize(); - } - - void render() override { - logo.render(); - update(); - } - - QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override { - QOpenGLFramebufferObjectFormat format; - format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); - format.setSamples(4); - return new QOpenGLFramebufferObject(size, format); - } - - LogoRenderer logo; -}; - -QQuickFramebufferObject::Renderer *FboInSGRenderer::createRenderer() const -{ - return new LogoInFboRenderer(); -} diff --git a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h b/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h deleted file mode 100644 index e1a9ce22c8..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/fboinsgrenderer.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FBOINSGRENDERER_H -#define FBOINSGRENDERER_H - -#include - -class LogoRenderer; - -class FboInSGRenderer : public QQuickFramebufferObject -{ - Q_OBJECT -public: - Renderer *createRenderer() const; -}; - -#endif diff --git a/examples/quick/scenegraph/textureinsgnode/main.cpp b/examples/quick/scenegraph/textureinsgnode/main.cpp deleted file mode 100644 index 8eececc0aa..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include "fboinsgrenderer.h" - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("SceneGraphRendering", 1, 0, "Renderer"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); - view.show(); - - return app.exec(); -} diff --git a/examples/quick/scenegraph/textureinsgnode/main.qml b/examples/quick/scenegraph/textureinsgnode/main.qml deleted file mode 100644 index 92fa99e847..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/main.qml +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -import SceneGraphRendering 1.0 - -Item { - width: 400 - height: 400 - - // The checkers background - ShaderEffect { - id: tileBackground - anchors.fill: parent - - property real tileSize: 16 - property color color1: Qt.rgba(0.9, 0.9, 0.9, 1); - property color color2: Qt.rgba(0.85, 0.85, 0.85, 1); - - property size pixelSize: Qt.size(width / tileSize, height / tileSize); - - fragmentShader: - " - uniform lowp vec4 color1; - uniform lowp vec4 color2; - uniform highp vec2 pixelSize; - varying highp vec2 qt_TexCoord0; - void main() { - highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize)); - if (tc.x != tc.y) - gl_FragColor = color1; - else - gl_FragColor = color2; - } - " - } - - Renderer { - id: renderer - anchors.fill: parent - anchors.margins: 10 - - // The transform is just to show something interesting.. - transform: [ - Rotation { id: rotation; axis.x: 0; axis.z: 0; axis.y: 1; angle: 0; origin.x: renderer.width / 2; origin.y: renderer.height / 2; }, - Translate { id: txOut; x: -renderer.width / 2; y: -renderer.height / 2 }, - Scale { id: scale; }, - Translate { id: txIn; x: renderer.width / 2; y: renderer.height / 2 } - ] - } - - // Just to show something interesting - SequentialAnimation { - PauseAnimation { duration: 5000 } - ParallelAnimation { - NumberAnimation { target: scale; property: "xScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack } - NumberAnimation { target: scale; property: "yScale"; to: 0.6; duration: 1000; easing.type: Easing.InOutBack } - } - NumberAnimation { target: rotation; property: "angle"; to: 80; duration: 1000; easing.type: Easing.InOutCubic } - NumberAnimation { target: rotation; property: "angle"; to: -80; duration: 1000; easing.type: Easing.InOutCubic } - NumberAnimation { target: rotation; property: "angle"; to: 0; duration: 1000; easing.type: Easing.InOutCubic } - NumberAnimation { target: renderer; property: "opacity"; to: 0.5; duration: 1000; easing.type: Easing.InOutCubic } - PauseAnimation { duration: 1000 } - NumberAnimation { target: renderer; property: "opacity"; to: 0.8; duration: 1000; easing.type: Easing.InOutCubic } - ParallelAnimation { - NumberAnimation { target: scale; property: "xScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack } - NumberAnimation { target: scale; property: "yScale"; to: 1; duration: 1000; easing.type: Easing.InOutBack } - } - running: true - loops: Animation.Infinite - } - - Rectangle { - id: labelFrame - anchors.margins: -10 - radius: 5 - color: "white" - border.color: "black" - opacity: 0.8 - anchors.fill: label - } - - Text { - id: label - anchors.bottom: renderer.bottom - anchors.left: renderer.left - anchors.right: renderer.right - anchors.margins: 20 - wrapMode: Text.WordWrap - text: "The blue rectangle with the vintage 'Q' is an FBO, rendered by the application on the scene graph rendering thread. The FBO is managed and displayed using the QQuickFramebufferObject convenience class." - } - - -} diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro deleted file mode 100644 index 238e20a553..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.pro +++ /dev/null @@ -1,16 +0,0 @@ -QT += qml quick - -HEADERS += fboinsgrenderer.h -SOURCES += fboinsgrenderer.cpp main.cpp - -INCLUDEPATH += ../shared -HEADERS += ../shared/logorenderer.h -SOURCES += ../shared/logorenderer.cpp - -RESOURCES += textureinsgnode.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinsgnode -INSTALLS += target - -OTHER_FILES += \ - main.qml diff --git a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc b/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc deleted file mode 100644 index 9ecf0ada1c..0000000000 --- a/examples/quick/scenegraph/textureinsgnode/textureinsgnode.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - main.qml - - -- cgit v1.2.3 From 90a706dffb944e7d18b8b199b1cea68633e2b172 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 12 Sep 2019 09:57:40 +0200 Subject: Move qsgrhisupport to an unconditional section in the pri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia53b43cb2e81053ffa8709767d84ac1e5db72d27 Fixes: QTBUG-78243 Reviewed-by: Christian Strømme --- src/quick/scenegraph/scenegraph.pri | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri index c345f3b16d..56d97226fb 100644 --- a/src/quick/scenegraph/scenegraph.pri +++ b/src/quick/scenegraph/scenegraph.pri @@ -94,7 +94,6 @@ qtConfig(opengl(es1|es2)?) { # rhi, still tied to OpenGL-enabled Qt builds for now HEADERS += \ - $$PWD/qsgrhisupport_p.h \ $$PWD/qsgrhitextureglyphcache_p.h \ $$PWD/util/qsgrhiatlastexture_p.h \ $$PWD/qsgrhilayer_p.h \ @@ -102,7 +101,6 @@ qtConfig(opengl(es1|es2)?) { $$PWD/qsgrhidistancefieldglyphcache_p.h SOURCES += \ - $$PWD/qsgrhisupport.cpp \ $$PWD/qsgrhitextureglyphcache.cpp \ $$PWD/qsgrhilayer.cpp \ $$PWD/qsgrhishadereffectnode.cpp \ @@ -118,7 +116,8 @@ HEADERS += \ $$PWD/qsgbasicinternalrectanglenode_p.h \ $$PWD/qsgbasicinternalimagenode_p.h \ $$PWD/qsgbasicglyphnode_p.h \ - $$PWD/qsgrenderloop_p.h + $$PWD/qsgrenderloop_p.h \ + $$PWD/qsgrhisupport_p.h SOURCES += \ $$PWD/qsgadaptationlayer.cpp \ @@ -127,7 +126,8 @@ SOURCES += \ $$PWD/qsgbasicinternalrectanglenode.cpp \ $$PWD/qsgbasicinternalimagenode.cpp \ $$PWD/qsgbasicglyphnode.cpp \ - $$PWD/qsgrenderloop.cpp + $$PWD/qsgrenderloop.cpp \ + $$PWD/qsgrhisupport.cpp qtConfig(opengl(es1|es2)?) { SOURCES += \ -- cgit v1.2.3 From e38ab72a7c2ce12b44e7772dee79cf1e00386b38 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Sep 2019 09:31:16 +0200 Subject: tst_qqmlecmascript: Cast pointer to unsigned for printing Otherwise QString::number() will apparently extend "negative" values to 64bits even if the actual type is only 32bits long. Change-Id: Ibdecff2fe707616d2254b7e34e08247f0ff52489 Reviewed-by: Fabian Kosmale Reviewed-by: Assam Boudjelthia Reviewed-by: Liang Qi --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d06243897c..df4963cb6e 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2047,7 +2047,7 @@ void tst_qqmlecmascript::functionErrors() QObject *resource = qobject_cast(QQmlProperty::read(object, "a").value()); warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - warning = warning.arg(QString::number((qintptr)resource, 16)); + warning = warning.arg(QString::number(quintptr(resource), 16)); QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); delete object; @@ -4553,7 +4553,7 @@ void tst_qqmlecmascript::scarceResources_other() eo = qobject_cast(QQmlProperty::read(object, "a").value()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); + expectedWarning = expectedWarning.arg(QString::number(quintptr(eo), 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. @@ -4627,7 +4627,7 @@ void tst_qqmlecmascript::scarceResources_other() eo = qobject_cast(QQmlProperty::read(object, "a").value()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); + expectedWarning = expectedWarning.arg(QString::number(quintptr(eo), 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. -- cgit v1.2.3 From a852ec4fd0c2ea6560270da8ead43a85f1573412 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 10 Sep 2019 12:58:01 +0200 Subject: Blacklist tst_qquicktextinput::mouseSelectionMode on OpenSuse 15.0 Task-number: QTBUG-78162 Change-Id: I8b4f536583afba889a9225d257900031c21ba9e0 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextinput/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/quick/qquicktextinput/BLACKLIST diff --git a/tests/auto/quick/qquicktextinput/BLACKLIST b/tests/auto/quick/qquicktextinput/BLACKLIST new file mode 100644 index 0000000000..ada7c57c75 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-78162 +[mouseSelectionMode] +opensuse-leap -- cgit v1.2.3 From c950ce0daf4b9fbfbcf6c00aa8ef4875297046f9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 10 Sep 2019 09:26:33 +0200 Subject: Blacklist tst_qquickmousearea::nestedStopAtBounds on opensuse 15.0 Task-number: QTBUG-78153 Change-Id: Ifdca53d4eed452067ba7f75ae0b3e74cf2027895 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickmousearea/BLACKLIST | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/auto/quick/qquickmousearea/BLACKLIST diff --git a/tests/auto/quick/qquickmousearea/BLACKLIST b/tests/auto/quick/qquickmousearea/BLACKLIST new file mode 100644 index 0000000000..f2cb00225b --- /dev/null +++ b/tests/auto/quick/qquickmousearea/BLACKLIST @@ -0,0 +1,4 @@ +# QTBUG-78153 +[nestedStopAtBounds] +opensuse-leap + -- cgit v1.2.3 From 3df387d63421f09533ab72e2a73fb5d259693120 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 10 Sep 2019 15:26:56 +0200 Subject: PathView: reduce velocity by linear decay model if release is delayed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That is, from the time between the last mouse move event to the mouse release, the velocity will be linearly discounted/depreciated until it reaches 0 at QML_FLICK_VELOCITY_DECAY_TIME, which is currently 50 ms. 50 ms seems like a long time if the user meant to flick and release immediately (in practice it might be more like 4 ms), and also a short time if the user meant to "dwell" before releasing. If we try to translate the fake physics to real physics, this would be approximately equivalent to saying that if you slide a flat plate on an air hockey table with one finger, and then stop suddenly, its momentum _would_ cause it to keep moving under your finger for up to 50ms (except that it doesn't, because our timeline doesn't "tick" until after the release); and yet if you hold it for longer than 50ms, it will stop right on the spot. That's not quite realistic, but feels OK for fake physics (like the rest of the physics in Qt Quick). Also add the qt.quick.pathview logging category, which will just log the velocity calculations for now (but is intended for anything else in PathView that seems worth logging later on). Task-number: QTBUG-77173 Task-number: QTBUG-59052 Change-Id: Ie86f18d3b3305874b698c848290e0fd3beda94de Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickflickablebehavior_p.h | 5 +++++ src/quick/items/qquickpathview.cpp | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquickflickablebehavior_p.h b/src/quick/items/qquickflickablebehavior_p.h index ae7fe71359..fbce62f075 100644 --- a/src/quick/items/qquickflickablebehavior_p.h +++ b/src/quick/items/qquickflickablebehavior_p.h @@ -93,6 +93,11 @@ #define QML_FLICK_MULTIFLICK_THRESHOLD 1250 #endif +// If the time (ms) between the last move and the release exceeds this, then velocity will be zero. +#ifndef QML_FLICK_VELOCITY_DECAY_TIME +#define QML_FLICK_VELOCITY_DECAY_TIME 50 +#endif + // Multiflick acceleration minimum contentSize/viewSize ratio #ifndef QML_FLICK_MULTIFLICK_RATIO #define QML_FLICK_MULTIFLICK_RATIO 10 diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 4e81573356..35b8a872ec 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle) +Q_LOGGING_CATEGORY(lcPathView, "qt.quick.pathview") const qreal MinimumFlickVelocity = 75.0; @@ -1623,6 +1624,7 @@ void QQuickPathViewPrivate::addVelocitySample(qreal v) velocityBuffer.append(v); if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER) velocityBuffer.remove(0); + qCDebug(lcPathView) << "instantaneous velocity" << v; } qreal QQuickPathViewPrivate::calcVelocity() const @@ -1635,6 +1637,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const velocity += v; } velocity /= count; + qCDebug(lcPathView) << "average velocity" << velocity << "based on" << count << "samples"; } return velocity; } @@ -1765,7 +1768,7 @@ void QQuickPathView::mouseReleaseEvent(QMouseEvent *event) } } -void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *) +void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *event) { Q_Q(QQuickPathView); stealMouse = false; @@ -1779,6 +1782,12 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *) } qreal velocity = calcVelocity(); + qint64 elapsed = computeCurrentTime(event) - lastPosTime; + // Let the velocity linearly decay such that it becomes 0 if elapsed time > QML_FLICK_VELOCITY_DECAY_TIME + // The intention is that if you are flicking at some speed, then stop in one place for some time before releasing, + // the previous velocity is lost. (QTBUG-77173, QTBUG-59052) + velocity *= qreal(qMax(0LL, QML_FLICK_VELOCITY_DECAY_TIME - elapsed)) / QML_FLICK_VELOCITY_DECAY_TIME; + qCDebug(lcPathView) << "after elapsed time" << elapsed << "velocity decayed to" << velocity; qreal count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount); const auto averageItemLength = path->path().length() / count; qreal pixelVelocity = averageItemLength * velocity; -- cgit v1.2.3 From b1b284e3cea67ef4ef128af50dd6c3aa35c46809 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 11 Sep 2019 14:20:19 +0200 Subject: tst_gridlayout.qml: convert to a proper data-driven test Change-Id: I9f2ccd3d4e6933d68b03d82c2c319aa2e8951e78 Reviewed-by: Liang Qi --- .../quick/qquicklayouts/data/tst_gridlayout.qml | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml index 6a1c0632ad..abd386aeb7 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml @@ -60,8 +60,8 @@ Item { id: testCase name: "Tests_GridLayout" when: windowShown - width: 200 - height: 200 + width: parent.width + height: parent.height Component { id: layout_flow_Component @@ -851,24 +851,37 @@ Item { } } - function test_spacings() + function test_spacings_data() + { + let data = [ + { spacing: Number.NaN }, + { spacing: 0 }, + { spacing: 10 }, + { spacing: -5 }, + { spacing: -19 } + ] + for (let i = 0; i < data.length; ++i) { + data[i].tag = data[i].spacing.toString() + } + return data + } + + function test_spacings(data) { var layout = layout_spacings_Component.createObject(container); // breaks down below -19. This is acceptable, since it means that the implicit size of the layout is negative var testSpacings = [Number.NaN, 0, 10, -5, -19] layout.rowSpacing = 0 - for (var i = 0; i < testSpacings.length; ++i) { - var sp = testSpacings[i] - if (isNaN(sp)) { - sp = 5 // Test defaults - } else { - layout.columnSpacing = sp - } - tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) - tryCompare(layout.children[1], "itemRect", [10 + sp, 0, 10, 10]) - compare(layout.implicitWidth, 20 + sp) + var spacing = data.spacing + if (isNaN(spacing)) { + spacing = 5 // Test defaults + } else { + layout.columnSpacing = spacing } + tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) + tryCompare(layout.children[1], "itemRect", [10 + spacing, 0, 10, 10]) + compare(layout.implicitWidth, 20 + spacing) // do not crash layout.columnSpacing = -100 -- cgit v1.2.3 From 69f62dc8efc738dff1fac50f8a6d8b2b09e654cf Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 11 Sep 2019 14:25:05 +0200 Subject: tst_gridlayout.qml: use createTemporaryObject() Ensures that items created in a function are destroyed upon failures in that function, and results in less code. Change-Id: I62b3b7c3a19dbb2128c5c45bdc7adf4fe80df70d Reviewed-by: Liang Qi --- .../quick/qquicklayouts/data/tst_gridlayout.qml | 56 ++++++---------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml index abd386aeb7..49838c4fd5 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml @@ -84,7 +84,7 @@ Item { function test_flow() { - var layout = layout_flow_Component.createObject(container); + var layout = createTemporaryObject(layout_flow_Component, container); tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[1], "itemRect", [10, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [20, 0, 10, 10]) @@ -102,8 +102,6 @@ Item { tryCompare(layout.children[4], "itemRect", [10, 0, 10, 10]) tryCompare(layout.children[5], "itemRect", [10, 10, 10, 10]) - - layout.destroy() } Component { @@ -178,7 +176,7 @@ Item { } function test_flowLeftToRight() { - var layout = layout_flowLeftToRight_Component.createObject(container); + var layout = createTemporaryObject(layout_flowLeftToRight_Component, container); compare(layout.implicitWidth, 80); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); @@ -208,8 +206,6 @@ Item { compare(layout.children[11].y, 60); compare(layout.children[12].x, 40); compare(layout.children[12].y, 80); - - layout.destroy(); } @@ -259,7 +255,7 @@ Item { function test_flowLeftToRightDefaultPositions() { ignoreWarning("QGridLayoutEngine::addItem: Cell (1, 0) already taken"); - var layout = layout_flowLeftToRightDefaultPositions_Component.createObject(container); + var layout = createTemporaryObject(layout_flowLeftToRightDefaultPositions_Component, container); compare(layout.implicitWidth, 40); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); @@ -267,7 +263,6 @@ Item { compare(layout.children[1].y, 20); compare(layout.children[2].x, 20); compare(layout.children[2].y, 20); - layout.destroy(); } @@ -342,7 +337,7 @@ Item { } function test_flowTopToBottom() { - var layout = layout_flowTopToBottom_Component.createObject(container); + var layout = createTemporaryObject(layout_flowTopToBottom_Component, container); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); compare(layout.children[1].x, 20); @@ -371,8 +366,6 @@ Item { compare(layout.children[11].y, 60); compare(layout.children[12].x, 80); compare(layout.children[12].y, 0); - - layout.destroy(); } Component { @@ -432,7 +425,7 @@ Item { } function test_spanAcrossEmptyRows() { - var layout = layout_spanAcrossEmptyRows_Component.createObject(container); + var layout = createTemporaryObject(layout_spanAcrossEmptyRows_Component, container); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); compare(layout.children[1].x, 20); @@ -442,8 +435,6 @@ Item { compare(layout.implicitWidth, 60); compare(layout.Layout.maximumWidth, 120); - - layout.destroy(); } Component { @@ -463,14 +454,13 @@ Item { } function test_spanIsMoreThanColumns() { - var layout = layout_spanIsMoreThanColumns_Component.createObject(container); + var layout = createTemporaryObject(layout_spanIsMoreThanColumns_Component, container); // item was not added, therefore implicit width is 0 compare(layout.implicitWidth, 0); - layout.destroy(); } function test_sizeHints() { - var layout = layout_spanAcrossEmptyRows_Component.createObject(container); + var layout = createTemporaryObject(layout_spanAcrossEmptyRows_Component, container); compare(layout.visible, true) var minWidth = layout.Layout.minimumWidth @@ -489,8 +479,6 @@ Item { compare(prefHeight, layout.implicitHeight) compare(maxWidth, layout.Layout.maximumWidth) compare(maxHeight, layout.Layout.maximumHeight) - - layout.destroy(); } Component { @@ -567,7 +555,7 @@ Item { function test_alignment() { - var layout = layout_alignment_Component.createObject(container); + var layout = createTemporaryObject(layout_alignment_Component, container); layout.width = 60; layout.height = 100; @@ -596,8 +584,6 @@ Item { layout.children[4].Layout.alignment = Qt.AlignLeft tryCompare(layout.children[4], "x", 0); tryCompare(layout.children[4], "y", 60); - - layout.destroy(); } @@ -648,7 +634,7 @@ Item { function test_rightToLeft() { - var layout = layout_rightToLeft_Component.createObject(container); + var layout = createTemporaryObject(layout_rightToLeft_Component, container); layout.width = 180; layout.height = 50; @@ -674,8 +660,6 @@ Item { layout.LayoutMirroring.enabled = true verifyIsRightToLeft(layout) - - layout.destroy(); } Component { @@ -698,7 +682,7 @@ Item { function test_columnsChanged() { - var layout = layout_columnsOrRowsChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnsOrRowsChanged_Component, container); layout.width = 40; layout.height = 20; tryCompare(layout.children[0], "itemRect", [ 0, 5, 10, 10]) @@ -711,13 +695,11 @@ Item { tryCompare(layout.children[1], "itemRect", [20, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [ 0, 10, 10, 10]) tryCompare(layout.children[3], "itemRect", [20, 10, 10, 10]) - - layout.destroy() } function test_rowsChanged() { - var layout = layout_columnsOrRowsChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnsOrRowsChanged_Component, container); layout.flow = GridLayout.TopToBottom layout.width = 20; layout.height = 40; @@ -731,8 +713,6 @@ Item { tryCompare(layout.children[1], "itemRect", [ 0, 25, 10, 10]) tryCompare(layout.children[2], "itemRect", [10, 5, 10, 10]) tryCompare(layout.children[3], "itemRect", [10, 25, 10, 10]) - - layout.destroy() } Component { @@ -767,7 +747,7 @@ Item { function test_columnOrRowChanged() { - var layout = layout_columnOrRowChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnOrRowChanged_Component, container); layout.width = layout.implicitWidth layout.height = layout.implicitHeight // c0-c1-c2 @@ -795,8 +775,6 @@ Item { tryCompare(layout.children[0], "itemRect", [10, 10, 10, 10]) tryCompare(layout.children[1], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [20, 0, 10, 10]) - - layout.destroy() } Component { @@ -819,7 +797,7 @@ Item { } function test_baselines() { - var layout = layout_baselines_Component.createObject(container); + var layout = createTemporaryObject(layout_baselines_Component, container); tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[1], "itemRect", [10, 0, 10, 10]) compare(layout.implicitWidth, 20) @@ -832,8 +810,6 @@ Item { tryCompare(layout.children[1], "itemRect", [10, 10, 10, 10]) compare(layout.implicitWidth, 20) compare(layout.implicitHeight, 20) - - layout.destroy(); } Component { @@ -868,7 +844,7 @@ Item { function test_spacings(data) { - var layout = layout_spacings_Component.createObject(container); + var layout = createTemporaryObject(layout_spacings_Component, container); // breaks down below -19. This is acceptable, since it means that the implicit size of the layout is negative var testSpacings = [Number.NaN, 0, 10, -5, -19] @@ -887,7 +863,6 @@ Item { layout.columnSpacing = -100 waitForRendering(layout) verify(isFinite(layout.implicitWidth)) - layout.destroy(); } Component { @@ -1039,11 +1014,10 @@ Item { function test_invalidateWhileRearranging_QTBUG_44139() { - var layout = layout_invalidateWhileRearranging_Component.createObject(container) + var layout = createTemporaryObject(layout_invalidateWhileRearranging_Component, container) waitForRendering(layout); verify(layout.children[1].visible == false); - layout.destroy() } } } -- cgit v1.2.3 From 04d92f9f9c16ace63a33ee18756ab8d40a1c1a66 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Thu, 5 Sep 2019 15:17:53 +0200 Subject: lancelot graphics test: support shadow build and install Use the QFINDTESTDATA mechanism to locate the test suite directory, and add the data directory and qmlscenegrabber to the installs. As a driveby, improve runtime by cutting down on needlessly long waiting time between test scenes. Change-Id: Id8452c843eef198d8548b196b0a2b5f0bc6be8ba Reviewed-by: Andy Nichols --- .../scenegraph_lancelot/scenegraph/scenegraph.pro | 4 ++++ .../scenegraph/tst_scenegraph.cpp | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro index 65819ab5bf..dd0ef268b1 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro +++ b/tests/manual/scenegraph_lancelot/scenegraph/scenegraph.pro @@ -9,3 +9,7 @@ SOURCES += tst_scenegraph.cpp # Include Lancelot protocol code to communicate with baseline server. # Assuming that we are in a normal Qt5 source code tree include(../../../../../qtbase/tests/baselineserver/shared/qbaselinetest.pri) + +TEST_HELPER_INSTALLS += .././qmlscenegrabber + +TESTDATA += ../data diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp index 95188ec0f8..40b17ec2a2 100644 --- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp +++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp @@ -68,6 +68,7 @@ private: bool renderAndGrab(const QString& qmlFile, const QStringList& extraArgs, QImage *screenshot, QString *errMsg); quint16 checksumFileOrDir(const QString &path); + QString testSuitePath; int consecutiveErrors; // Not test failures (image mismatches), but system failures (so no image at all) bool aborted; // This run given up because of too many system failures }; @@ -81,6 +82,14 @@ tst_Scenegraph::tst_Scenegraph() void tst_Scenegraph::initTestCase() { + QString dataDir = QFINDTESTDATA("../data/."); + if (dataDir.isEmpty()) + dataDir = QStringLiteral("data"); + QFileInfo fi(dataDir); + if (!fi.exists() || !fi.isDir() || !fi.isReadable()) + QSKIP("Test suite data directory missing or unreadable: " + fi.canonicalFilePath().toLatin1()); + testSuitePath = fi.canonicalFilePath(); + const char *backendVarName = "QT_QUICK_BACKEND"; const QString backend = qEnvironmentVariable(backendVarName, QString::fromLatin1("default")); QBaselineTest::addClientProperty(QString::fromLatin1(backendVarName), backend); @@ -95,7 +104,7 @@ void tst_Scenegraph::cleanup() { // Allow subsystems time to settle if (!aborted) - QTest::qWait(200); + QTest::qWait(20); } void tst_Scenegraph::testNoTextRendering_data() @@ -131,13 +140,6 @@ void tst_Scenegraph::setupTestSuite(const QByteArray& filter) QTest::addColumn("qmlFile"); int numItems = 0; - QString testSuiteDir = QLatin1String("data"); - QString testSuiteLocation = QCoreApplication::applicationDirPath(); - QString testSuitePath = testSuiteLocation + QDir::separator() + testSuiteDir; - QFileInfo fi(testSuitePath); - if (!fi.exists() || !fi.isDir() || !fi.isReadable()) - QSKIP("Test suite data directory missing or unreadable: " + testSuitePath.toLatin1()); - QStringList ignoreItems; QFile ignoreFile(testSuitePath + "/Ignore"); if (ignoreFile.open(QIODevice::ReadOnly)) { @@ -237,7 +239,7 @@ quint16 tst_Scenegraph::checksumFileOrDir(const QString &path) QFile f(path); f.open(QIODevice::ReadOnly); QByteArray contents = f.readAll(); - return qChecksum(contents.constData(), contents.size()); + return qChecksum(contents.constData(), uint(contents.size())); } if (fi.isDir()) { static const QStringList nameFilters = QStringList() << "*.qml" << "*.cpp" << "*.png" << "*.jpg"; -- cgit v1.2.3 From 144193549a3a47ea3ade74289e3adc55c2bd65e6 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 6 Sep 2019 16:13:30 +0200 Subject: lancelot graphics test: Fix screengrabs being distorted on Windows The grabbing process transports the image data to the main process over the stdout stream. Windows by default applies LF->CRLF conversion on that stream. Avoid by setting the binary mode flag on it. Change-Id: Ieec0911e24e21c111caeb35e35259833e1fdd639 Reviewed-by: Laszlo Agocs Reviewed-by: Andy Nichols --- tests/manual/scenegraph_lancelot/scenegrabber/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp index 6da0799bbc..23c678380c 100644 --- a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp +++ b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp @@ -36,6 +36,11 @@ #include #include +#ifdef Q_OS_WIN +# include +# include +#endif // Q_OS_WIN + // Timeout values: // A valid screen grab requires the scene to not change @@ -101,6 +106,10 @@ private slots: #endif if (ofile == "-") { // Write to stdout QFile of; +#ifdef Q_OS_WIN + // Make sure write to stdout doesn't do LF->CRLF + _setmode(_fileno(stdout), _O_BINARY); +#endif // Q_OS_WIN if (!of.open(1, QIODevice::WriteOnly) || !lastGrab.save(&of, "ppm")) { qWarning() << "Error: failed to write grabbed image to stdout."; QGuiApplication::exit(2); -- cgit v1.2.3 From 122d0367fd96526b3573a3188286153c846680ca Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 12 Sep 2019 17:44:04 +0200 Subject: Use the correct type's meta-type ID for int and save a misplaced cast I got compiler warnings because of a comparison of a QVariant::type() with an int(). These were caused by a "fix" that cast to int a QMetaType::Int, where the correct fix was surely to use QVariant::Int. This amends commit 83f8d886cee0a40ac1ad5e43e597f309f602ad76. Change-Id: I3f1718e4f2c0c5a6a1cbb79266768fba4e3290e3 Reviewed-by: Friedemann Kleint --- tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index cf0f3c7bb3..07af519a3d 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -470,7 +470,7 @@ void tst_qqmlconnections::noAcceleratedGlobalLookup() QVERIFY(c.isReady()); QScopedPointer object(c.create()); const QVariant val = object->property("testEnum"); - QCOMPARE(val.type(), int(QMetaType::Int)); + QCOMPARE(val.type(), QVariant::Int); QCOMPARE(val.toInt(), int(Proxy::EnumValue)); } -- cgit v1.2.3 From 28eb0caec23e0c315056cb035535b8806ccb0f37 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 5 Sep 2019 16:41:11 +0200 Subject: Force creation of metaobjects for top level objects and components We want those to be different types, even if they don't add any properties, signals etc. Otherwise you can cross-assign objects of components defined in different files. Fully-dynamic types, such as QQmlPropertyMap are still an exception to this. We need to use the original meta object so that you can still dynamically add properties to any derived types. Therefore, all types derived from QQmlPropertyMap are in fact just aliases of each other. Also, types which aren't addressable from the outside don't get their own meta object. Types are addressable if they live in files and the file name starts with an uppercase character. Otherwise there is no way to refer to the component from anywhere else in QML. Fixes: QTBUG-76021 Change-Id: I96a01fdad13e50e4705520fec46f2b3373e0c365 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlpropertycachecreator_p.h | 11 ++++++++++- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 12 ++++++------ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 17 +++++++++++++---- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 11 +++++++++-- .../auto/qml/qqmlpropertycache/data/SpecialObject1.qml | 5 +++++ .../auto/qml/qqmlpropertycache/data/SpecialObject2.qml | 5 +++++ tests/auto/qml/qqmlpropertycache/data/noDuckType.qml | 7 +++++++ .../qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 11 +++++++++++ 8 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml create mode 100644 tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml create mode 100644 tests/auto/qml/qqmlpropertycache/data/noDuckType.qml diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index def4480198..94bf3cbdc3 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -152,9 +152,18 @@ inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buil template inline QQmlJS::DiagnosticMessage QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context) { + auto isAddressable = [](const QUrl &url) { + const QString fileName = url.fileName(); + return !fileName.isEmpty() && fileName.front().isUpper(); + }; + const CompiledObject *obj = objectContainer->objectAt(objectIndex); + bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 + || obj->signalCount() != 0 || obj->functionCount() != 0 || obj->enumCount() != 0 + || (((obj->flags & QV4::CompiledData::Object::IsComponent) + || (objectIndex == 0 && isAddressable(objectContainer->url()))) + && !objectContainer->resolvedType(obj->inheritedTypeNameIndex)->isFullyDynamicType); - bool needVMEMetaObject = obj->propertyCount() != 0 || obj->aliasCount() != 0 || obj->signalCount() != 0 || obj->functionCount() != 0 || obj->enumCount() != 0; if (!needVMEMetaObject) { auto binding = obj->bindingsBegin(); auto end = obj->bindingsEnd(); diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 79ec507388..1d2fa42b75 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -222,12 +222,12 @@ void tst_qqmlcomponent::qmlCreateObjectAutoParent() QVERIFY(window_item); QVERIFY(window_window); - QCOMPARE(qtobject_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(qtobject_window->metaObject()->className(), "QQuickWindow"); - QCOMPARE(item_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(item_window->metaObject()->className(), "QQuickWindow"); - QCOMPARE(window_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(window_window->metaObject()->className(), "QQuickWindow"); + QVERIFY(QByteArray(qtobject_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(qtobject_window->metaObject()->className()).startsWith("QQuickWindow")); + QVERIFY(QByteArray(item_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(item_window->metaObject()->className()).startsWith("QQuickWindow")); + QVERIFY(QByteArray(window_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(window_window->metaObject()->className()).startsWith("QQuickWindow")); QCOMPARE(qtobject_qtobject->parent(), qtobjectParent); QCOMPARE(qtobject_item->parent(), qtobjectParent); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 8adacd8829..007fb5cef2 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -2500,7 +2500,15 @@ void tst_qqmllanguage::testType(const QString& qml, const QString& type, const Q VERIFY_ERRORS(0); QScopedPointer object(component.create()); QVERIFY(object != nullptr); - QCOMPARE(QString(object->metaObject()->className()), type); + const QMetaObject *meta = object->metaObject(); + for (; meta; meta = meta->superClass()) { + const QString className(meta->className()); + if (!className.contains("_QMLTYPE_") && !className.contains("_QML_")) { + QCOMPARE(className, type); + break; + } + } + QVERIFY(meta != nullptr); } engine.setImportPathList(defaultImportPathList); @@ -4043,10 +4051,12 @@ void tst_qqmllanguage::implicitImportsLast() VERIFY_ERRORS(0); QScopedPointer object(component.create()); QVERIFY(object != nullptr); - QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QQuickMouseArea"))); + QVERIFY(QString(object->metaObject()->superClass()->superClass()->className()) + .startsWith(QLatin1String("QQuickMouseArea"))); QObject* object2 = object->property("item").value(); QVERIFY(object2 != nullptr); - QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QQuickRectangle")); + QCOMPARE(QString(object2->metaObject()->superClass()->className()), + QLatin1String("QQuickRectangle")); engine.setImportPathList(defaultImportPathList); } @@ -5030,7 +5040,6 @@ void tst_qqmllanguage::instanceof() if (QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomRectangle") || QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomImport.CustomRectangle")) - QEXPECT_FAIL("", "QTBUG-58477: QML type rules are a little lax", Continue); QCOMPARE(returnValue, expectedValue.toBool()); } else { QVERIFY(expr.hasError()); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 67da768f73..bc407e97a2 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -35,6 +35,9 @@ #include #include #include +#if QT_CONFIG(regularexpression) +#include +#endif #include #include "../../shared/util.h" @@ -2015,9 +2018,13 @@ void tst_qqmlproperty::warnOnInvalidBinding() expectedWarning = testUrl.toString() + QString::fromLatin1(":7:5: Unable to assign QQuickText to QQuickRectangle"); QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); +#if QT_CONFIG(regularexpression) // V8 error message for invalid binding to anchor - expectedWarning = testUrl.toString() + QString::fromLatin1(":14:9: Unable to assign QQuickItem_QML_8 to QQuickAnchorLine"); - QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); + const QRegularExpression warning( + "^" + testUrl.toString() + + ":14:9: Unable to assign QQuickItem_QML_\\d+ to QQuickAnchorLine$"); + QTest::ignoreMessage(QtWarningMsg, warning); +#endif QQmlComponent component(&engine, testUrl); QObject *obj = component.create(); diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml new file mode 100644 index 0000000000..9559bc0b5f --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + readonly property bool fakeProperty: false +} diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml new file mode 100644 index 0000000000..ed4ad04fef --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + objectName: "special" +} diff --git a/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml new file mode 100644 index 0000000000..5e1ea233b9 --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml @@ -0,0 +1,7 @@ +import QtQml 2.9 + +QtObject { + property SpecialObject1 obj1: SpecialObject1 {} + property SpecialObject2 obj2: SpecialObject2 {} + property string result: (obj1 instanceof SpecialObject2) ? "bad" : "good" +} diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index 9a1e4667dd..c9e92cd3c9 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -54,6 +54,7 @@ private slots: void metaObjectSize_data(); void metaObjectSize(); void metaObjectChecksum(); + void metaObjectsForRootElements(); private: QQmlEngine engine; @@ -543,4 +544,14 @@ void tst_qqmlpropertycache::metaObjectChecksum() } } +void tst_qqmlpropertycache::metaObjectsForRootElements() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("noDuckType.qml")); + QVERIFY(c.isReady()); + QScopedPointer obj(c.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("result").toString(), QString::fromLatin1("good")); +} + QTEST_MAIN(tst_qqmlpropertycache) -- cgit v1.2.3 From 43a6970ce328109d9d367978fa09e838bbac8596 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Sat, 14 Sep 2019 14:54:24 +0200 Subject: doc: Add missing directories to qdocconf files These might not be complete yet, but they do fix the qdoc errors. Change-Id: I75b0f0f7709a371149a6f7c82adfff9fe88408ea Reviewed-by: Paul Wicking --- src/qml/doc/qtqml.qdocconf | 10 ++++++++-- src/qmlmodels/qqmlitemmodels.qdoc | 2 +- src/qmlmodels/qqmltablemodel.cpp | 2 +- src/quick/doc/qtquick.qdocconf | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index cb9fb575b2..74d0a3b27c 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -37,11 +37,17 @@ tagfile = ../../../doc/qtqml/qtqml.tags depends += qtcore qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols headerdirs += .. \ - ../../imports/models + ../../imports/models \ + ../../qmlmodels \ + ../../qml \ + ../../qmlworkerscript sourcedirs += .. \ ../../imports/models \ - ../../imports/statemachine + ../../imports/statemachine \ + ../../qmlmodels \ + ../../qml \ + ../../qmlworkerscript exampledirs += ../../../examples/qml \ ../ \ diff --git a/src/qmlmodels/qqmlitemmodels.qdoc b/src/qmlmodels/qqmlitemmodels.qdoc index f6e1b0b1b9..2e12dbf656 100644 --- a/src/qmlmodels/qqmlitemmodels.qdoc +++ b/src/qmlmodels/qqmlitemmodels.qdoc @@ -62,7 +62,7 @@ \section1 QModelIndexList Type - \l QModelIndexList is exposed in QML as a JavaScript array. Conversions are + QModelIndexList is exposed in QML as a JavaScript array. Conversions are automatically made from and to C++. In fact, any JavaScript array can be converted back to QModelIndexList, with non-QModelIndex objects replaced by invalid \l{QModelIndex}es. diff --git a/src/qmlmodels/qqmltablemodel.cpp b/src/qmlmodels/qqmltablemodel.cpp index 4a96e7a46b..f190ad86b1 100644 --- a/src/qmlmodels/qqmltablemodel.cpp +++ b/src/qmlmodels/qqmltablemodel.cpp @@ -64,7 +64,7 @@ Q_LOGGING_CATEGORY(lcTableModel, "qt.qml.tablemodel") The model's initial row data is set with either the \l rows property or by calling \l appendRow(). Each column in the model is specified by declaring a \l TableModelColumn instance, where the order of each instance determines - its column index. Once the model's \l Component.completed() signal has been + its column index. Once the model's \l Component::completed() signal has been emitted, the columns and roles will have been established and are then fixed for the lifetime of the model. diff --git a/src/quick/doc/qtquick.qdocconf b/src/quick/doc/qtquick.qdocconf index 13746b13de..6a4300c1bd 100644 --- a/src/quick/doc/qtquick.qdocconf +++ b/src/quick/doc/qtquick.qdocconf @@ -41,9 +41,11 @@ tagfile = ../../../doc/qtquick/qtquick.tags depends += qtcore qtqml qtqmltest qtgui qtlinguist qtquickcontrols1 qtquickcontrols qtdoc qtquickdialogs qtsensors qtwidgets qmake qtmultimedia qtgraphicaleffects qtsql qtxmlpatterns headerdirs += ..\ + ../../quick \ ../../quickwidgets sourcedirs += .. \ + ../../quick \ ../../quickwidgets exampledirs += ../../../examples/quick \ -- cgit v1.2.3 From b7e5b0c25b7c02b40c2072f45a0a0feb8bd2a977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Mon, 16 Sep 2019 14:12:50 +0200 Subject: Fix qmlobject_{dis}connect macros to require semicolon at the end Just do the typical do { [..stuff..] } while(0) in the macros Fix the places that didn't have semicolons. This should eliminate some compiler warnings complaining about excessive semicolons Change-Id: I6b0e7a55badfd0f80c3cd0e9e1da42dc41945485 Reviewed-by: Shawn Rutledge --- src/qml/qml/qqmlglobal_p.h | 8 ++++---- src/quick/items/qquickborderimage.cpp | 2 +- src/quick/items/qquickborderimage_p_p.h | 2 +- src/quick/items/qquickflickable.cpp | 4 ++-- src/quick/items/qquickitem.cpp | 2 +- src/quick/items/qquickpathview.cpp | 4 ++-- tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 96891af416..3c540a6124 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -90,7 +90,7 @@ QT_BEGIN_NAMESPACE \endcode */ #define qmlobject_connect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ -{ \ +do { \ SenderType *sender = (Sender); \ ReceiverType *receiver = (Receiver); \ const char *signal = (Signal); \ @@ -111,7 +111,7 @@ QT_BEGIN_NAMESPACE } \ Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ QMetaObject::connect(sender, signalIdx, receiver, methodIdx, Qt::DirectConnection); \ -} +} while (0) /*! Disconnect \a Signal of \a Sender from \a Method of \a Receiver. \a Signal must be @@ -129,7 +129,7 @@ QT_BEGIN_NAMESPACE \endcode */ #define qmlobject_disconnect(Sender, SenderType, Signal, Receiver, ReceiverType, Method) \ -{ \ +do { \ SenderType *sender = (Sender); \ ReceiverType *receiver = (Receiver); \ const char *signal = (Signal); \ @@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE } \ Q_ASSERT(signalIdx != -1 && methodIdx != -1); \ QMetaObject::disconnect(sender, signalIdx, receiver, methodIdx); \ -} +} while (0) /*! This method is identical to qobject_cast() except that it does not require lazy diff --git a/src/quick/items/qquickborderimage.cpp b/src/quick/items/qquickborderimage.cpp index 430fa1b094..462a44634e 100644 --- a/src/quick/items/qquickborderimage.cpp +++ b/src/quick/items/qquickborderimage.cpp @@ -327,7 +327,7 @@ void QQuickBorderImage::load() QNetworkRequest req(d->url); d->sciReply = qmlEngine(this)->networkAccessManager()->get(req); qmlobject_connect(d->sciReply, QNetworkReply, SIGNAL(finished()), - this, QQuickBorderImage, SLOT(sciRequestFinished())) + this, QQuickBorderImage, SLOT(sciRequestFinished())); #endif } } else { diff --git a/src/quick/items/qquickborderimage_p_p.h b/src/quick/items/qquickborderimage_p_p.h index 0f4e7acc05..17dab7d121 100644 --- a/src/quick/items/qquickborderimage_p_p.h +++ b/src/quick/items/qquickborderimage_p_p.h @@ -86,7 +86,7 @@ public: if (!border) { border = new QQuickScaleGrid(q); qmlobject_connect(border, QQuickScaleGrid, SIGNAL(borderChanged()), - q, QQuickBorderImage, SLOT(doUpdate())) + q, QQuickBorderImage, SLOT(doUpdate())); } return border; } diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index cf3cd9f48e..d9ec7de611 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -266,9 +266,9 @@ void QQuickFlickablePrivate::init() QQml_setParent_noEvent(contentItem, q); contentItem->setParentItem(q); qmlobject_connect(&timeline, QQuickTimeLine, SIGNAL(completed()), - q, QQuickFlickable, SLOT(timelineCompleted())) + q, QQuickFlickable, SLOT(timelineCompleted())); qmlobject_connect(&velocityTimeline, QQuickTimeLine, SIGNAL(completed()), - q, QQuickFlickable, SLOT(velocityTimelineCompleted())) + q, QQuickFlickable, SLOT(velocityTimelineCompleted())); q->setAcceptedMouseButtons(Qt::LeftButton); q->setAcceptTouchEvents(false); // rely on mouse events synthesized from touch q->setFiltersChildMouseEvents(true); diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 52a1d59e77..c1ab8716f3 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5083,7 +5083,7 @@ QQuickStateGroup *QQuickItemPrivate::_states() if (!componentComplete) _stateGroup->classBegin(); qmlobject_connect(_stateGroup, QQuickStateGroup, SIGNAL(stateChanged(QString)), - q, QQuickItem, SIGNAL(stateChanged(QString))) + q, QQuickItem, SIGNAL(stateChanged(QString))); } return _stateGroup; diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 35b8a872ec..8091a28a6c 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -118,10 +118,10 @@ void QQuickPathViewPrivate::init() q->setFlag(QQuickItem::ItemIsFocusScope); q->setFiltersChildMouseEvents(true); qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(updated()), - q, QQuickPathView, SLOT(ticked())) + q, QQuickPathView, SLOT(ticked())); timer.invalidate(); qmlobject_connect(&tl, QQuickTimeLine, SIGNAL(completed()), - q, QQuickPathView, SLOT(movementEnding())) + q, QQuickPathView, SLOT(movementEnding())); } QQuickItem *QQuickPathViewPrivate::getItem(int modelIndex, qreal z, bool async) diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp index 99cabb4b09..13e4d4c53b 100644 --- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -71,7 +71,7 @@ void tst_qqmlcpputils::fastConnect() { MyObject obj; - qmlobject_connect(&obj, MyObject, SIGNAL(signal1()), &obj, MyObject, SLOT(slot1())) + qmlobject_connect(&obj, MyObject, SIGNAL(signal1()), &obj, MyObject, SLOT(slot1())); obj.signal1(); QCOMPARE(obj.slotCount, 1); -- cgit v1.2.3 From 6d95a228d85c5a805899f9cf8216f435c5e38442 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 16 Sep 2019 13:40:31 +0200 Subject: Re-add documentation for QtQml.WorkerScript It was lost when moving the classes and the import URI was wrong. Change-Id: Ic01f5c327ac53e58874f54399dc0434a23bed7b8 Reviewed-by: Simon Hausmann --- src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf | 37 ++++++++++++++++++++++ src/qmlworkerscript/qmlworkerscript.pro | 2 ++ src/qmlworkerscript/qquickworkerscript.cpp | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf diff --git a/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf b/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf new file mode 100644 index 0000000000..bb883cf39f --- /dev/null +++ b/src/qmlworkerscript/doc/qtqmlworkerscript.qdocconf @@ -0,0 +1,37 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtdeclarative.qdocconf) + +project = QtQmlWorkerScript +description = Qt Qml WorkerScript Reference Documentation +version = $QT_VERSION +moduleheader = QtQmlWorkerScript +qhp.projects = QtQmlWorkerScript + +qhp.QtQmlWorkerScript.file = qtqmlworkerscript.qhp +qhp.QtQmlWorkerScript.namespace = org.qt-project.qtqmlworkerscript.$QT_VERSION_TAG +qhp.QtQmlWorkerScript.virtualFolder = qtqmlworkerscript +qhp.QtQmlWorkerScript.indexRoot = + +qhp.QtQmlWorkerScript.filterAttributes = qtqmlworkerscript $QT_VERSION qtrefdoc +qhp.QtQmlWorkerScript.customFilters.Qt.name = QtQmlWorkerScript $QT_VERSION +qhp.QtQmlWorkerScript.customFilters.Qt.filterAttributes = qtqmlworkerscript $QT_VERSION + +qhp.QtQmlWorkerScript.title = QML Types +qhp.QtQmlWorkerScript.indexTitle = Qt QML WorkerScript QML Types +qhp.QtQmlWorkerScript.selectors = qmlclass +qhp.QtQmlWorkerScript.sortPages = true + +tagfile = qtqmlworkerscript.tags + +depends += qtcore qtqml qtdoc + +headerdirs += .. + +sourcedirs += .. \ + ../../imports/workerscript + +exampledirs += ../../../examples/qml \ + ../ \ + snippets + +navigation.qmltypespage = "Qt Qml WorkerScript QML Types" diff --git a/src/qmlworkerscript/qmlworkerscript.pro b/src/qmlworkerscript/qmlworkerscript.pro index 908caa4ed4..9f5e0e809a 100644 --- a/src/qmlworkerscript/qmlworkerscript.pro +++ b/src/qmlworkerscript/qmlworkerscript.pro @@ -1,6 +1,8 @@ TARGET = QtQmlWorkerScript QT = core-private qml-private +QMAKE_DOCS = $$PWD/doc/qtqmlworkerscript.qdocconf + DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FOREACH HEADERS += \ diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp index 4da1def5f5..b93e297b61 100644 --- a/src/qmlworkerscript/qquickworkerscript.cpp +++ b/src/qmlworkerscript/qquickworkerscript.cpp @@ -441,7 +441,7 @@ void QQuickWorkerScriptEngine::run() \qmltype WorkerScript \instantiates QQuickWorkerScript \ingroup qtquick-threading - \inqmlmodule QtQml + \inqmlmodule QtQml.WorkerScript \brief Enables the use of threads in a Qt Quick application. Use WorkerScript to run operations in a new thread. -- cgit v1.2.3 From be478ea886b8b4867cd8832f4f848bcce96c4512 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 16 Sep 2019 11:51:22 +0200 Subject: Re-add documentation for Qt Qml Models It got lost when moving the classes. Change-Id: I7b3a9fec8fe9439c548da570e430d3b82613b816 Reviewed-by: Simon Hausmann --- .../doc/snippets/delegatemodel/delegatemodel.qml | 75 ------------ .../delegatemodel/delegatemodel_rootindex/main.cpp | 72 ----------- .../delegatemodel/delegatemodel_rootindex/view.qml | 76 ------------ .../snippets/delegatemodel/delegatemodelgroup.qml | 92 -------------- src/qml/doc/snippets/package/Delegate.qml | 88 -------------- src/qml/doc/snippets/package/view.qml | 103 ---------------- .../doc/snippets/qml/listmodel/listelements.qml | 87 ------------- .../snippets/qml/listmodel/listmodel-modify.qml | 106 ---------------- .../snippets/qml/listmodel/listmodel-nested.qml | 112 ----------------- .../snippets/qml/listmodel/listmodel-simple.qml | 89 -------------- src/qml/doc/snippets/qml/listmodel/listmodel.qml | 69 ----------- .../qml/tablemodel/fruit-example-complex.qml | 134 --------------------- .../tablemodel/fruit-example-delegatechooser.qml | 130 -------------------- .../tablemodel/fruit-example-simpledelegate.qml | 119 ------------------ src/qmlmodels/doc/qtqmlmodels.qdocconf | 37 ++++++ .../doc/snippets/delegatemodel/delegatemodel.qml | 75 ++++++++++++ .../delegatemodel/delegatemodel_rootindex/main.cpp | 72 +++++++++++ .../delegatemodel/delegatemodel_rootindex/view.qml | 76 ++++++++++++ .../snippets/delegatemodel/delegatemodelgroup.qml | 92 ++++++++++++++ src/qmlmodels/doc/snippets/package/Delegate.qml | 88 ++++++++++++++ src/qmlmodels/doc/snippets/package/view.qml | 103 ++++++++++++++++ .../doc/snippets/qml/listmodel/listelements.qml | 87 +++++++++++++ .../snippets/qml/listmodel/listmodel-modify.qml | 106 ++++++++++++++++ .../snippets/qml/listmodel/listmodel-nested.qml | 112 +++++++++++++++++ .../snippets/qml/listmodel/listmodel-simple.qml | 89 ++++++++++++++ .../doc/snippets/qml/listmodel/listmodel.qml | 69 +++++++++++ .../qml/tablemodel/fruit-example-complex.qml | 134 +++++++++++++++++++++ .../tablemodel/fruit-example-delegatechooser.qml | 130 ++++++++++++++++++++ .../tablemodel/fruit-example-simpledelegate.qml | 119 ++++++++++++++++++ src/qmlmodels/qmlmodels.pro | 2 + 30 files changed, 1391 insertions(+), 1352 deletions(-) delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel.qml delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml delete mode 100644 src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml delete mode 100644 src/qml/doc/snippets/package/Delegate.qml delete mode 100644 src/qml/doc/snippets/package/view.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listelements.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml delete mode 100644 src/qml/doc/snippets/qml/listmodel/listmodel.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml delete mode 100644 src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml create mode 100644 src/qmlmodels/doc/qtqmlmodels.qdocconf create mode 100644 src/qmlmodels/doc/snippets/delegatemodel/delegatemodel.qml create mode 100644 src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp create mode 100644 src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml create mode 100644 src/qmlmodels/doc/snippets/delegatemodel/delegatemodelgroup.qml create mode 100644 src/qmlmodels/doc/snippets/package/Delegate.qml create mode 100644 src/qmlmodels/doc/snippets/package/view.qml create mode 100644 src/qmlmodels/doc/snippets/qml/listmodel/listelements.qml create mode 100644 src/qmlmodels/doc/snippets/qml/listmodel/listmodel-modify.qml create mode 100644 src/qmlmodels/doc/snippets/qml/listmodel/listmodel-nested.qml create mode 100644 src/qmlmodels/doc/snippets/qml/listmodel/listmodel-simple.qml create mode 100644 src/qmlmodels/doc/snippets/qml/listmodel/listmodel.qml create mode 100644 src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-complex.qml create mode 100644 src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml create mode 100644 src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel.qml deleted file mode 100644 index 1a7baa6b1e..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -Rectangle { - width: 200; height: 100 - - DelegateModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - delegate: Rectangle { - height: 25 - width: 100 - Text { text: "Name: " + name} - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp deleted file mode 100644 index a56eb69616..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QQuickView view; - - QDirModel model; - view.rootContext()->setContextProperty("dirModel", &model); - - view.setSource(QUrl::fromLocalFile("view.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml b/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml deleted file mode 100644 index 2e17eed8f0..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -ListView { - id: view - width: 300 - height: 400 - - model: DelegateModel { - model: dirModel - - delegate: Rectangle { - width: 200; height: 25 - Text { text: filePath } - - MouseArea { - anchors.fill: parent - onClicked: { - if (model.hasModelChildren) - view.model.rootIndex = view.model.modelIndex(index) - } - } - } - } -} -//![0] diff --git a/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml b/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml deleted file mode 100644 index 8562deeeda..0000000000 --- a/src/qml/doc/snippets/delegatemodel/delegatemodelgroup.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQml.Models 2.2 - -Rectangle { - width: 200; height: 100 - - DelegateModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - - groups: [ - DelegateModelGroup { name: "selected" } - ] - - delegate: Rectangle { - id: item - height: 25 - width: 200 - Text { - text: { - var text = "Name: " + name - if (item.DelegateModel.inSelected) - text += " (" + item.DelegateModel.selectedIndex + ")" - return text; - } - } - MouseArea { - anchors.fill: parent - onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected - } - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/src/qml/doc/snippets/package/Delegate.qml b/src/qml/doc/snippets/package/Delegate.qml deleted file mode 100644 index 7c73f35c3d..0000000000 --- a/src/qml/doc/snippets/package/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//! [0] -Package { - Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: parent.width; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - state: root.upTo > index ? 'inGrid' : 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//! [0] diff --git a/src/qml/doc/snippets/package/view.qml b/src/qml/doc/snippets/package/view.qml deleted file mode 100644 index 311cc3be8e..0000000000 --- a/src/qml/doc/snippets/package/view.qml +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQml.Models 2.1 - -Rectangle { - id: root - color: "white" - width: 320 - height: 480 - property int upTo: 0 - SequentialAnimation on upTo { - loops: -1 - NumberAnimation { to: 8; duration: 3500 } - NumberAnimation { to: 0; duration: 3500 } - } - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - DelegateModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - id: lv - height: parent.height/2 - width: parent.width - - model: visualModel.parts.list - } - GridView { - y: parent.height/2 - height: parent.height/2 - width: parent.width - cellWidth: width / 2 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] - Text { - anchors.bottom: parent.bottom - } -} diff --git a/src/qml/doc/snippets/qml/listmodel/listelements.qml b/src/qml/doc/snippets/qml/listmodel/listelements.qml deleted file mode 100644 index 12146c1420..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listelements.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 2.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] -} -//! [document] diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml deleted file mode 100644 index f293eff8ec..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-modify.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} - -//![delegate] - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$' + cost; anchors.right: parent.right } - - // Double the price when clicked. - MouseArea { - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost * 2) - } - } - } -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml deleted file mode 100644 index 8c193d6a5e..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-nested.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - -//![model] -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} -//![model] - -//![delegate] -Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { id: nameField; text: name } - Text { text: '$' + cost; anchors.left: nameField.right } - Row { - anchors.top: nameField.bottom - spacing: 5 - Text { text: "Attributes:" } - Repeater { - model: attributes - Text { text: description } - } - } - } -} -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml b/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml deleted file mode 100644 index d07f868476..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel-simple.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel -//![0] - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -//![1] - } - - Component { - id: fruitDelegate - Row { - spacing: 10 - Text { text: name } - Text { text: '$' + cost } - } - } - - ListView { - anchors.fill: parent - model: fruitModel - delegate: fruitDelegate - } -} -//![1] diff --git a/src/qml/doc/snippets/qml/listmodel/listmodel.qml b/src/qml/doc/snippets/qml/listmodel/listmodel.qml deleted file mode 100644 index c2a69d6e8f..0000000000 --- a/src/qml/doc/snippets/qml/listmodel/listmodel.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -} -//![0] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml deleted file mode 100644 index 104a2209d7..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-complex.qml +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Window 2.12 -import Qt.labs.qmlmodels 1.0 - -Window { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][0].checked } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][0].checked = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][1].amount } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][1].amount = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][2].fruitType } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][2].fruitType = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][3].fruitName } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][3].fruitName = cellData } - } - TableModelColumn { - display: function(modelIndex) { return rows[modelIndex.row][4].fruitPrice } - setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][4].fruitPrice = cellData } - } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - [ - // Each object (line) is one cell/column. - { checked: false, checkable: true }, - { amount: 1 }, - { fruitType: "Apple" }, - { fruitName: "Granny Smith" }, - { fruitPrice: 1.50 } - ], - [ - { checked: true, checkable: true }, - { amount: 4 }, - { fruitType: "Orange" }, - { fruitName: "Navel" }, - { fruitPrice: 2.50 } - ], - [ - { checked: false, checkable: false }, - { amount: 1 }, - { fruitType: "Banana" }, - { fruitName: "Cavendish" }, - { fruitPrice: 3.50 } - ] - ] -//![rows] - } -//![delegate] - delegate: TextInput { - text: model.display - padding: 12 - selectByMouse: true - - onAccepted: model.display = text - - Rectangle { - anchors.fill: parent - color: "#efefef" - z: -1 - } - } -//![delegate] - } -} -//![file] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml deleted file mode 100644 index d3f6176c70..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Controls 2.5 -import Qt.labs.qmlmodels 1.0 - -ApplicationWindow { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { display: "checked" } - TableModelColumn { display: "amount" } - TableModelColumn { display: "fruitType" } - TableModelColumn { display: "fruitName" } - TableModelColumn { display: "fruitPrice" } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - { - // Each property is one cell/column. - checked: false, - amount: 1, - fruitType: "Apple", - fruitName: "Granny Smith", - fruitPrice: 1.50 - }, - { - checked: true, - amount: 4, - fruitType: "Orange", - fruitName: "Navel", - fruitPrice: 2.50 - }, - { - checked: false, - amount: 1, - fruitType: "Banana", - fruitName: "Cavendish", - fruitPrice: 3.50 - } - ] -//![rows] - } -//![delegate] - delegate: DelegateChooser { - DelegateChoice { - column: 0 - delegate: CheckBox { - checked: model.display - onToggled: model.display = checked - } - } - DelegateChoice { - column: 1 - delegate: SpinBox { - value: model.display - onValueModified: model.display = value - } - } - DelegateChoice { - delegate: TextField { - text: model.display - selectByMouse: true - implicitWidth: 140 - onAccepted: model.display = text - } - } - } -//![delegate] - } -} -//![file] diff --git a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml b/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml deleted file mode 100644 index f51c1818c3..0000000000 --- a/src/qml/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![file] -import QtQuick 2.12 -import QtQuick.Window 2.12 -import Qt.labs.qmlmodels 1.0 - -Window { - width: 400 - height: 400 - visible: true - - TableView { - anchors.fill: parent - columnSpacing: 1 - rowSpacing: 1 - boundsBehavior: Flickable.StopAtBounds - - model: TableModel { - TableModelColumn { display: "checked" } - TableModelColumn { display: "amount" } - TableModelColumn { display: "fruitType" } - TableModelColumn { display: "fruitName" } - TableModelColumn { display: "fruitPrice" } - - // Each row is one type of fruit that can be ordered -//![rows] - rows: [ - { - // Each property is one cell/column. - checked: false, - amount: 1, - fruitType: "Apple", - fruitName: "Granny Smith", - fruitPrice: 1.50 - }, - { - checked: true, - amount: 4, - fruitType: "Orange", - fruitName: "Navel", - fruitPrice: 2.50 - }, - { - checked: false, - amount: 1, - fruitType: "Banana", - fruitName: "Cavendish", - fruitPrice: 3.50 - } - ] -//![rows] - } -//![delegate] - delegate: TextInput { - text: model.display - padding: 12 - selectByMouse: true - - onAccepted: model.display = text - - Rectangle { - anchors.fill: parent - color: "#efefef" - z: -1 - } - } -//![delegate] - } -} -//![file] diff --git a/src/qmlmodels/doc/qtqmlmodels.qdocconf b/src/qmlmodels/doc/qtqmlmodels.qdocconf new file mode 100644 index 0000000000..a4153f4a53 --- /dev/null +++ b/src/qmlmodels/doc/qtqmlmodels.qdocconf @@ -0,0 +1,37 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) +include($QT_INSTALL_DOCS/config/exampleurl-qtdeclarative.qdocconf) + +project = QtQmlModels +description = Qt Qml Models Reference Documentation +version = $QT_VERSION +moduleheader = QtQmlModels +qhp.projects = QtQmlModels + +qhp.QtQmlModels.file = qtqmlmodels.qhp +qhp.QtQmlModels.namespace = org.qt-project.qtqmlmodels.$QT_VERSION_TAG +qhp.QtQmlModels.virtualFolder = qtqmlmodels +qhp.QtQmlModels.indexRoot = + +qhp.QtQmlModels.filterAttributes = qtqmlmodels $QT_VERSION qtrefdoc +qhp.QtQmlModels.customFilters.Qt.name = QtQmlModels $QT_VERSION +qhp.QtQmlModels.customFilters.Qt.filterAttributes = qtqmlmodels $QT_VERSION + +qhp.QtQmlModels.title = QML Types +qhp.QtQmlModels.indexTitle = Qt QML Models QML Types +qhp.QtQmlModels.selectors = qmlclass +qhp.QtQmlModels.sortPages = true + +tagfile = qtqmlmodels.tags + +depends += qtcore qtqml qtdoc + +headerdirs += .. + +sourcedirs += .. \ + ../../imports/models + +exampledirs += ../../../examples/qml \ + ../ \ + snippets + +navigation.qmltypespage = "Qt Qml Models QML Types" diff --git a/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel.qml b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel.qml new file mode 100644 index 0000000000..1a7baa6b1e --- /dev/null +++ b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQml.Models 2.2 + +Rectangle { + width: 200; height: 100 + + DelegateModel { + id: visualModel + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + } + delegate: Rectangle { + height: 25 + width: 100 + Text { text: "Name: " + name} + } + } + + ListView { + anchors.fill: parent + model: visualModel + } +} +//![0] diff --git a/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp new file mode 100644 index 0000000000..a56eb69616 --- /dev/null +++ b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/main.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QQuickView view; + + QDirModel model; + view.rootContext()->setContextProperty("dirModel", &model); + + view.setSource(QUrl::fromLocalFile("view.qml")); + view.show(); + + return app.exec(); +} +//![0] + diff --git a/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml new file mode 100644 index 0000000000..2e17eed8f0 --- /dev/null +++ b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodel_rootindex/view.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQml.Models 2.2 + +ListView { + id: view + width: 300 + height: 400 + + model: DelegateModel { + model: dirModel + + delegate: Rectangle { + width: 200; height: 25 + Text { text: filePath } + + MouseArea { + anchors.fill: parent + onClicked: { + if (model.hasModelChildren) + view.model.rootIndex = view.model.modelIndex(index) + } + } + } + } +} +//![0] diff --git a/src/qmlmodels/doc/snippets/delegatemodel/delegatemodelgroup.qml b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodelgroup.qml new file mode 100644 index 0000000000..8562deeeda --- /dev/null +++ b/src/qmlmodels/doc/snippets/delegatemodel/delegatemodelgroup.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQml.Models 2.2 + +Rectangle { + width: 200; height: 100 + + DelegateModel { + id: visualModel + model: ListModel { + ListElement { name: "Apple" } + ListElement { name: "Orange" } + } + + groups: [ + DelegateModelGroup { name: "selected" } + ] + + delegate: Rectangle { + id: item + height: 25 + width: 200 + Text { + text: { + var text = "Name: " + name + if (item.DelegateModel.inSelected) + text += " (" + item.DelegateModel.selectedIndex + ")" + return text; + } + } + MouseArea { + anchors.fill: parent + onClicked: item.DelegateModel.inSelected = !item.DelegateModel.inSelected + } + } + } + + ListView { + anchors.fill: parent + model: visualModel + } +} +//![0] diff --git a/src/qmlmodels/doc/snippets/package/Delegate.qml b/src/qmlmodels/doc/snippets/package/Delegate.qml new file mode 100644 index 0000000000..7c73f35c3d --- /dev/null +++ b/src/qmlmodels/doc/snippets/package/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//! [0] +Package { + Text { id: listDelegate; width: parent.width; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: parent.width / 2; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: parent.width; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + state: root.upTo > index ? 'inGrid' : 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//! [0] diff --git a/src/qmlmodels/doc/snippets/package/view.qml b/src/qmlmodels/doc/snippets/package/view.qml new file mode 100644 index 0000000000..311cc3be8e --- /dev/null +++ b/src/qmlmodels/doc/snippets/package/view.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQml.Models 2.1 + +Rectangle { + id: root + color: "white" + width: 320 + height: 480 + property int upTo: 0 + SequentialAnimation on upTo { + loops: -1 + NumberAnimation { to: 8; duration: 3500 } + NumberAnimation { to: 0; duration: 3500 } + } + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + DelegateModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + id: lv + height: parent.height/2 + width: parent.width + + model: visualModel.parts.list + } + GridView { + y: parent.height/2 + height: parent.height/2 + width: parent.width + cellWidth: width / 2 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] + Text { + anchors.bottom: parent.bottom + } +} diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/listelements.qml b/src/qmlmodels/doc/snippets/qml/listmodel/listelements.qml new file mode 100644 index 0000000000..12146c1420 --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/listmodel/listelements.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [document] +import QtQuick 2.0 + +Item { + width: 200; height: 250 + + //! [model] + ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } + } + //! [model] + + //! [view] + ListView { + anchors.fill: parent + model: fruitModel + delegate: Row { + Text { text: "Fruit: " + name } + Text { text: "Cost: $" + cost } + } + } + //! [view] +} +//! [document] diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-modify.qml b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-modify.qml new file mode 100644 index 0000000000..f293eff8ec --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-modify.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} + +//![delegate] + Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { text: name } + Text { text: '$' + cost; anchors.right: parent.right } + + // Double the price when clicked. + MouseArea { + anchors.fill: parent + onClicked: fruitModel.setProperty(index, "cost", cost * 2) + } + } + } +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-nested.qml b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-nested.qml new file mode 100644 index 0000000000..8c193d6a5e --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-nested.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + +//![model] +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } +} +//![model] + +//![delegate] +Component { + id: fruitDelegate + Item { + width: 200; height: 50 + Text { id: nameField; text: name } + Text { text: '$' + cost; anchors.left: nameField.right } + Row { + anchors.top: nameField.bottom + spacing: 5 + Text { text: "Attributes:" } + Repeater { + model: attributes + Text { text: description } + } + } + } +} +//![delegate] + +ListView { + width: 200; height: 200 + model: fruitModel + delegate: fruitDelegate +} + +} diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-simple.qml b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-simple.qml new file mode 100644 index 0000000000..d07f868476 --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel-simple.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +Rectangle { + width: 200; height: 200 + + ListModel { + id: fruitModel +//![0] + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +//![1] + } + + Component { + id: fruitDelegate + Row { + spacing: 10 + Text { text: name } + Text { text: '$' + cost } + } + } + + ListView { + anchors.fill: parent + model: fruitModel + delegate: fruitDelegate + } +} +//![1] diff --git a/src/qmlmodels/doc/snippets/qml/listmodel/listmodel.qml b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel.qml new file mode 100644 index 0000000000..c2a69d6e8f --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/listmodel/listmodel.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 + +ListModel { + id: fruitModel + + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } +} +//![0] diff --git a/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-complex.qml b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-complex.qml new file mode 100644 index 0000000000..104a2209d7 --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-complex.qml @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![file] +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +Window { + width: 400 + height: 400 + visible: true + + TableView { + anchors.fill: parent + columnSpacing: 1 + rowSpacing: 1 + boundsBehavior: Flickable.StopAtBounds + + model: TableModel { + TableModelColumn { + display: function(modelIndex) { return rows[modelIndex.row][0].checked } + setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][0].checked = cellData } + } + TableModelColumn { + display: function(modelIndex) { return rows[modelIndex.row][1].amount } + setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][1].amount = cellData } + } + TableModelColumn { + display: function(modelIndex) { return rows[modelIndex.row][2].fruitType } + setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][2].fruitType = cellData } + } + TableModelColumn { + display: function(modelIndex) { return rows[modelIndex.row][3].fruitName } + setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][3].fruitName = cellData } + } + TableModelColumn { + display: function(modelIndex) { return rows[modelIndex.row][4].fruitPrice } + setDisplay: function(modelIndex, cellData) { rows[modelIndex.row][4].fruitPrice = cellData } + } + + // Each row is one type of fruit that can be ordered +//![rows] + rows: [ + [ + // Each object (line) is one cell/column. + { checked: false, checkable: true }, + { amount: 1 }, + { fruitType: "Apple" }, + { fruitName: "Granny Smith" }, + { fruitPrice: 1.50 } + ], + [ + { checked: true, checkable: true }, + { amount: 4 }, + { fruitType: "Orange" }, + { fruitName: "Navel" }, + { fruitPrice: 2.50 } + ], + [ + { checked: false, checkable: false }, + { amount: 1 }, + { fruitType: "Banana" }, + { fruitName: "Cavendish" }, + { fruitPrice: 3.50 } + ] + ] +//![rows] + } +//![delegate] + delegate: TextInput { + text: model.display + padding: 12 + selectByMouse: true + + onAccepted: model.display = text + + Rectangle { + anchors.fill: parent + color: "#efefef" + z: -1 + } + } +//![delegate] + } +} +//![file] diff --git a/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml new file mode 100644 index 0000000000..d3f6176c70 --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-delegatechooser.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![file] +import QtQuick 2.12 +import QtQuick.Controls 2.5 +import Qt.labs.qmlmodels 1.0 + +ApplicationWindow { + width: 400 + height: 400 + visible: true + + TableView { + anchors.fill: parent + columnSpacing: 1 + rowSpacing: 1 + boundsBehavior: Flickable.StopAtBounds + + model: TableModel { + TableModelColumn { display: "checked" } + TableModelColumn { display: "amount" } + TableModelColumn { display: "fruitType" } + TableModelColumn { display: "fruitName" } + TableModelColumn { display: "fruitPrice" } + + // Each row is one type of fruit that can be ordered +//![rows] + rows: [ + { + // Each property is one cell/column. + checked: false, + amount: 1, + fruitType: "Apple", + fruitName: "Granny Smith", + fruitPrice: 1.50 + }, + { + checked: true, + amount: 4, + fruitType: "Orange", + fruitName: "Navel", + fruitPrice: 2.50 + }, + { + checked: false, + amount: 1, + fruitType: "Banana", + fruitName: "Cavendish", + fruitPrice: 3.50 + } + ] +//![rows] + } +//![delegate] + delegate: DelegateChooser { + DelegateChoice { + column: 0 + delegate: CheckBox { + checked: model.display + onToggled: model.display = checked + } + } + DelegateChoice { + column: 1 + delegate: SpinBox { + value: model.display + onValueModified: model.display = value + } + } + DelegateChoice { + delegate: TextField { + text: model.display + selectByMouse: true + implicitWidth: 140 + onAccepted: model.display = text + } + } + } +//![delegate] + } +} +//![file] diff --git a/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml new file mode 100644 index 0000000000..f51c1818c3 --- /dev/null +++ b/src/qmlmodels/doc/snippets/qml/tablemodel/fruit-example-simpledelegate.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![file] +import QtQuick 2.12 +import QtQuick.Window 2.12 +import Qt.labs.qmlmodels 1.0 + +Window { + width: 400 + height: 400 + visible: true + + TableView { + anchors.fill: parent + columnSpacing: 1 + rowSpacing: 1 + boundsBehavior: Flickable.StopAtBounds + + model: TableModel { + TableModelColumn { display: "checked" } + TableModelColumn { display: "amount" } + TableModelColumn { display: "fruitType" } + TableModelColumn { display: "fruitName" } + TableModelColumn { display: "fruitPrice" } + + // Each row is one type of fruit that can be ordered +//![rows] + rows: [ + { + // Each property is one cell/column. + checked: false, + amount: 1, + fruitType: "Apple", + fruitName: "Granny Smith", + fruitPrice: 1.50 + }, + { + checked: true, + amount: 4, + fruitType: "Orange", + fruitName: "Navel", + fruitPrice: 2.50 + }, + { + checked: false, + amount: 1, + fruitType: "Banana", + fruitName: "Cavendish", + fruitPrice: 3.50 + } + ] +//![rows] + } +//![delegate] + delegate: TextInput { + text: model.display + padding: 12 + selectByMouse: true + + onAccepted: model.display = text + + Rectangle { + anchors.fill: parent + color: "#efefef" + z: -1 + } + } +//![delegate] + } +} +//![file] diff --git a/src/qmlmodels/qmlmodels.pro b/src/qmlmodels/qmlmodels.pro index 7d1d9bdf67..1d733f5bdb 100644 --- a/src/qmlmodels/qmlmodels.pro +++ b/src/qmlmodels/qmlmodels.pro @@ -1,6 +1,8 @@ TARGET = QtQmlModels QT = core-private qml-private +QMAKE_DOCS = $$PWD/doc/qtqmlmodels.qdocconf + DEFINES += QT_NO_URL_CAST_FROM_STRING QT_NO_INTEGER_EVENT_COORDINATES QT_NO_FOREACH HEADERS += \ -- cgit v1.2.3 From 9d89f9019ecd17d21fa491b55726d60985756a29 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 17 Sep 2019 10:21:44 +0200 Subject: Doc: add TableView \since version Task-number: QTBUG-78307 Change-Id: I71bc58ba5e4d930167f56a264e20b352244502a3 Reviewed-by: Paul Wicking --- src/quick/items/qquicktableview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 38b38ddfda..58cd80500c 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -55,6 +55,7 @@ \qmltype TableView \instantiates QQuickTableView \inqmlmodule QtQuick + \since 5.12 \ingroup qtquick-views \inherits Flickable \brief Provides a table view of items provided by the model. -- cgit v1.2.3 From 89d654fcd4f06311c69393d5a1e1fbc8932347a1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 15:51:21 +0200 Subject: Clean up GraphicsStateInfo after API review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I715ad71153151a0e6521bc182227d9fa2dc0a3ea Reviewed-by: Christian Strømme --- .../quick/scenegraph/metaltextureimport/metaltextureimport.mm | 8 ++++---- examples/quick/scenegraph/metalunderqml/metalsquircle.mm | 8 ++++---- examples/quick/scenegraph/rendernode/metalrenderer.mm | 8 ++++---- examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp | 8 ++++---- src/quick/items/qquickwindow.cpp | 6 +++--- src/quick/items/qquickwindow.h | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm index 6bb68dac44..66a39083f7 100644 --- a/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm +++ b/examples/quick/scenegraph/metaltextureimport/metaltextureimport.mm @@ -281,7 +281,7 @@ void CustomTextureNode::sync() m_vs = compileShaderFromSource(m_vert, m_vertEntryPoint); m_fs = compileShaderFromSource(m_frag, m_fragEntryPoint); - const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight; + const int framesInFlight = m_window->graphicsStateInfo().framesInFlight; m_vbuf = [m_device newBufferWithLength: sizeof(vertices) options: MTLResourceStorageModeShared]; void *p = [m_vbuf contents]; @@ -348,8 +348,8 @@ void CustomTextureNode::render() Q_ASSERT(cb); id encoder = [cb renderCommandEncoderWithDescriptor: renderpassdesc]; - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); - void *p = [m_ubuf[stateInfo->currentFrameSlot] contents]; + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); + void *p = [m_ubuf[stateInfo.currentFrameSlot] contents]; memcpy(p, &m_t, 4); MTLViewport vp; @@ -361,7 +361,7 @@ void CustomTextureNode::render() vp.zfar = 1; [encoder setViewport: vp]; - [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0]; + [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0]; [encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1]; [encoder setRenderPipelineState: m_pipeline]; [encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0]; diff --git a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm index 8a1a03dc68..5ca6daa01a 100644 --- a/examples/quick/scenegraph/metalunderqml/metalsquircle.mm +++ b/examples/quick/scenegraph/metalunderqml/metalsquircle.mm @@ -215,7 +215,7 @@ void SquircleRenderer::frameStart() prepareShader(FragmentStage); if (!m_initialized) - init(m_window->graphicsStateInfo()->framesInFlight); + init(m_window->graphicsStateInfo().framesInFlight); } static const float vertices[] = { @@ -233,7 +233,7 @@ void SquircleRenderer::mainPassRecordingStart() // the scenegraph's main renderpass. It does not create its own passes, // rendertargets, etc. so no synchronization is needed. - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); QSGRendererInterface *rif = m_window->rendererInterface(); id encoder = (id) rif->getResource( @@ -242,7 +242,7 @@ void SquircleRenderer::mainPassRecordingStart() m_window->beginExternalCommands(); - void *p = [m_ubuf[stateInfo->currentFrameSlot] contents]; + void *p = [m_ubuf[stateInfo.currentFrameSlot] contents]; float t = m_t; memcpy(p, &t, 4); @@ -255,7 +255,7 @@ void SquircleRenderer::mainPassRecordingStart() vp.zfar = 1; [encoder setViewport: vp]; - [encoder setFragmentBuffer: m_ubuf[stateInfo->currentFrameSlot] offset: 0 atIndex: 0]; + [encoder setFragmentBuffer: m_ubuf[stateInfo.currentFrameSlot] offset: 0 atIndex: 0]; [encoder setVertexBuffer: m_vbuf offset: 0 atIndex: 1]; [encoder setRenderPipelineState: m_pipeline]; [encoder drawPrimitives: MTLPrimitiveTypeTriangleStrip vertexStart: 0 vertexCount: 4 instanceCount: 1 baseInstance: 0]; diff --git a/examples/quick/scenegraph/rendernode/metalrenderer.mm b/examples/quick/scenegraph/rendernode/metalrenderer.mm index 11db276f37..b83dc62c48 100644 --- a/examples/quick/scenegraph/rendernode/metalrenderer.mm +++ b/examples/quick/scenegraph/rendernode/metalrenderer.mm @@ -131,7 +131,7 @@ void MetalRenderNodeResourceBuilder::build() g.fs = compileShaderFromSource(g.fsSource, QByteArrayLiteral("main0")); } - const int framesInFlight = m_window->graphicsStateInfo()->framesInFlight; + const int framesInFlight = m_window->graphicsStateInfo().framesInFlight; // For simplicity's sake we use shared mode (something like host visible + // host coherent) for everything. @@ -258,9 +258,9 @@ void MetalRenderNode::releaseResources() void MetalRenderNode::render(const RenderState *state) { Q_ASSERT(m_window); - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); - id vbuf = g.vbuf[stateInfo->currentFrameSlot]; - id ubuf = g.ubuf[stateInfo->currentFrameSlot]; + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); + id vbuf = g.vbuf[stateInfo.currentFrameSlot]; + id ubuf = g.ubuf[stateInfo.currentFrameSlot]; QPointF p0(m_width - 1, m_height - 1); QPointF p1(0, 0); diff --git a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp index 6e24391257..21f46a25c1 100644 --- a/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp +++ b/examples/quick/scenegraph/vulkanunderqml/vulkansquircle.cpp @@ -212,7 +212,7 @@ void SquircleRenderer::frameStart() prepareShader(FragmentStage); if (!m_initialized) - init(m_window->graphicsStateInfo()->framesInFlight); + init(m_window->graphicsStateInfo().framesInFlight); } static const float vertices[] = { @@ -230,10 +230,10 @@ void SquircleRenderer::mainPassRecordingStart() // the scenegraph's main renderpass. It does not create its own passes, // rendertargets, etc. so no synchronization is needed. - const QQuickWindow::GraphicsStateInfo *stateInfo = m_window->graphicsStateInfo(); + const QQuickWindow::GraphicsStateInfo &stateInfo(m_window->graphicsStateInfo()); QSGRendererInterface *rif = m_window->rendererInterface(); - VkDeviceSize ubufOffset = stateInfo->currentFrameSlot * m_allocPerUbuf; + VkDeviceSize ubufOffset = stateInfo.currentFrameSlot * m_allocPerUbuf; void *p = nullptr; VkResult err = m_devFuncs->vkMapMemory(m_dev, m_ubufMem, ubufOffset, m_allocPerUbuf, 0, &p); if (err != VK_SUCCESS || !p) @@ -259,7 +259,7 @@ void SquircleRenderer::mainPassRecordingStart() VkDeviceSize vbufOffset = 0; m_devFuncs->vkCmdBindVertexBuffers(cb, 0, 1, &m_vbuf, &vbufOffset); - uint32_t dynamicOffset = m_allocPerUbuf * stateInfo->currentFrameSlot; + uint32_t dynamicOffset = m_allocPerUbuf * stateInfo.currentFrameSlot; m_devFuncs->vkCmdBindDescriptorSets(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipelineLayout, 0, 1, &m_ubufDescriptor, 1, &dynamicOffset); diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 6fe2891242..cd620e3408 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -4737,7 +4737,7 @@ void QQuickWindow::resetOpenGLState() */ /*! - \return a pointer to a GraphicsStateInfo struct describing some of the + \return a reference to a GraphicsStateInfo struct describing some of the RHI's internal state, in particular, the double or tripple buffering status of the backend (such as, the Vulkan or Metal integrations). This is relevant when the underlying graphics APIs is Vulkan or Metal, and the @@ -4745,14 +4745,14 @@ void QQuickWindow::resetOpenGLState() its own often-changing resources, such as, uniform buffers, in order to avoid stalling the pipeline. */ -const QQuickWindow::GraphicsStateInfo *QQuickWindow::graphicsStateInfo() +const QQuickWindow::GraphicsStateInfo &QQuickWindow::graphicsStateInfo() { Q_D(QQuickWindow); if (d->rhi) { d->rhiStateInfo.currentFrameSlot = d->rhi->currentFrameSlot(); d->rhiStateInfo.framesInFlight = d->rhi->resourceLimit(QRhi::FramesInFlight); } - return &d->rhiStateInfo; + return d->rhiStateInfo; } /*! diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index 9dbff88f0d..56d50cec2a 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -142,10 +142,10 @@ public: void resetOpenGLState(); #endif struct GraphicsStateInfo { - int currentFrameSlot = 0; - int framesInFlight = 0; + int currentFrameSlot; + int framesInFlight; }; - const GraphicsStateInfo *graphicsStateInfo(); + const GraphicsStateInfo &graphicsStateInfo(); void beginExternalCommands(); void endExternalCommands(); QQmlIncubationController *incubationController() const; -- cgit v1.2.3 From 105c879435d4b459f4168a4aef5f74dc8a3f6016 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 17:04:36 +0200 Subject: Add missing inner struct and enum docs for rhi material shader Change-Id: Ia78012271705b3f977011a89d3156faa79a35f29 Reviewed-by: Lars Knoll --- .../scenegraph/coreapi/qsgmaterialrhishader.cpp | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp index 03f74df6b7..e3cd0f554e 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp @@ -425,6 +425,71 @@ bool QSGMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, rendering state. */ +/*! + \class QSGMaterialRhiShader::GraphicsPipelineState + + \brief Describes state changes that the material wants to apply to the + currently active graphics pipeline state. + + \inmodule QtQuick + \since 5.14 + + Unlike QSGMaterialShader, directly issuing state change commands with the + underlying graphics API is not possible with QSGMaterialRhiShader. This is + mainly because the concept of individually changeable states is considered + deprecated and not supported with modern graphics APIs. + + Therefore, it is up to QSGMaterialRhiShader to expose a data structure with + the set of supported states, which the material can change in its + updatePipelineState() implementation, if there is one. The scenegraph will + then internally apply these changes to the active graphics pipeline state, + then rolling them back as appropriate. + */ + +/*! + \enum QSGMaterialRhiShader::GraphicsPipelineState::BlendFactor + \since 5.14 + + \value Zero + \value One + \value SrcColor + \value OneMinusSrcColor + \value DstColor + \value OneMinusDstColor + \value SrcAlpha + \value OneMinusSrcAlpha + \value DstAlpha + \value OneMinusDstAlpha + \value ConstantColor + \value OneMinusConstantColor + \value ConstantAlpha + \value OneMinusConstantAlpha + \value SrcAlphaSaturate + \value Src1Color + \value OneMinusSrc1Color + \value Src1Alpha + \value OneMinusSrc1Alpha + */ + +/*! + \enum QSGMaterialRhiShader::GraphicsPipelineState::ColorMaskComponent + \since 5.14 + + \value R + \value G + \value B + \value A + */ + +/*! + \enum QSGMaterialRhiShader::GraphicsPipelineState::CullMode + \since 5.14 + + \value CullNone + \value CullFront + \value CullBack + */ + /*! Returns the accumulated opacity to be used for rendering. */ -- cgit v1.2.3 From 5d3589b30f1181d1a945902bf8915f1170e457b9 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 16:05:39 +0200 Subject: Avoid changing function signature in public header Change-Id: I0be124dfcafa2244531281ffd1ac6b559d82c604 Reviewed-by: Lars Knoll --- src/quick/items/qquickwindow.cpp | 9 ++-- .../scenegraph/coreapi/qsgabstractrenderer.cpp | 48 ++++++++++++++++++++-- src/quick/scenegraph/coreapi/qsgabstractrenderer.h | 10 ++++- src/quick/scenegraph/qsgopengllayer.cpp | 2 +- src/quick/scenegraph/qsgrhilayer.cpp | 5 ++- 5 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index cd620e3408..e00789be85 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -500,10 +500,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa renderer->setDeviceRect(rect); renderer->setViewportRect(rect); if (QQuickRenderControl::renderWindowFor(q)) { - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size), false); + renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), size)); renderer->setDevicePixelRatio(devicePixelRatio); } else { - renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size()), false); + renderer->setProjectionMatrixToRect(QRect(QPoint(0, 0), rect.size())); renderer->setDevicePixelRatio(1); } } else { @@ -520,7 +520,10 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa renderer->setDeviceRect(rect); renderer->setViewportRect(rect); const bool flipY = rhi ? !rhi->isYUpInNDC() : false; - renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), flipY); + QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0; + if (flipY) + matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY; + renderer->setProjectionMatrixToRect(QRectF(QPoint(0, 0), logicalSize), matrixFlags); renderer->setDevicePixelRatio(devicePixelRatio); } diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp b/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp index 679ad1d445..62ed342244 100644 --- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.cpp @@ -72,6 +72,22 @@ QT_BEGIN_NAMESPACE \sa setClearMode(), setClearColor() */ +/*! + \enum QSGAbstractRenderer::MatrixTransformFlag + + Used with setProjectionMatrixToRect() to indicate the expectations towards + the generated projection matrix. + + \value MatrixTransformFlipY The traditional assumption in Qt Quick is that + Y points up in the normalized device coordinate system. There is at least + one modern graphics API where this is not the case (Vulkan). This flag can + then be used to get a projection that is appropriate for such an API. + + \sa setProjectionMatrixToRect() + + \since 5.14 + */ + /*! \fn void QSGAbstractRenderer::renderScene(GLuint fboId = 0) @@ -224,14 +240,38 @@ QRect QSGAbstractRenderer::viewportRect() const Convenience method that calls setProjectionMatrix() with an orthographic matrix generated from \a rect. - \a flipY must be \c true when the graphics API uses Y down in its - normalized device coordinate system (for example, Vulkan), \c false - otherwise. + \note This function assumes that the graphics API uses Y up in its + normalized device coordinate system. \sa setProjectionMatrix(), projectionMatrix() */ -void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect, bool flipY) +void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect) +{ + QMatrix4x4 matrix; + matrix.ortho(rect.x(), + rect.x() + rect.width(), + rect.y() + rect.height(), + rect.y(), + 1, + -1); + setProjectionMatrix(matrix); + setProjectionMatrixWithNativeNDC(matrix); +} + +/*! + Convenience method that calls setProjectionMatrix() with an + orthographic matrix generated from \a rect. + + Set MatrixTransformFlipY in \a flags when the graphics API uses Y down in + its normalized device coordinate system (for example, Vulkan). + + \sa setProjectionMatrix(), projectionMatrix() + + \since 5.14 + */ +void QSGAbstractRenderer::setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags) { + const bool flipY = flags.testFlag(MatrixTransformFlipY); QMatrix4x4 matrix; matrix.ortho(rect.x(), rect.x() + rect.width(), diff --git a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h index 08e600e0b8..1594352dab 100644 --- a/src/quick/scenegraph/coreapi/qsgabstractrenderer.h +++ b/src/quick/scenegraph/coreapi/qsgabstractrenderer.h @@ -63,6 +63,13 @@ public: Q_DECLARE_FLAGS(ClearMode, ClearModeBit) Q_FLAG(ClearMode) + enum MatrixTransformFlag + { + MatrixTransformFlipY = 0x01 + }; + Q_DECLARE_FLAGS(MatrixTransformFlags, MatrixTransformFlag) + Q_FLAG(MatrixTransformFlags) + ~QSGAbstractRenderer() override; void setRootNode(QSGRootNode *node); @@ -75,7 +82,8 @@ public: inline void setViewportRect(const QSize &size) { setViewportRect(QRect(QPoint(), size)); } QRect viewportRect() const; - void setProjectionMatrixToRect(const QRectF &rect, bool flipY = false); + void setProjectionMatrixToRect(const QRectF &rect); + void setProjectionMatrixToRect(const QRectF &rect, MatrixTransformFlags flags); void setProjectionMatrix(const QMatrix4x4 &matrix); void setProjectionMatrixWithNativeNDC(const QMatrix4x4 &matrix); QMatrix4x4 projectionMatrix() const; diff --git a/src/quick/scenegraph/qsgopengllayer.cpp b/src/quick/scenegraph/qsgopengllayer.cpp index 8db4cba58a..ae5032231d 100644 --- a/src/quick/scenegraph/qsgopengllayer.cpp +++ b/src/quick/scenegraph/qsgopengllayer.cpp @@ -408,7 +408,7 @@ void QSGOpenGLLayer::grab() m_mirrorVertical ? m_rect.bottom() : m_rect.top(), m_mirrorHorizontal ? -m_rect.width() : m_rect.width(), m_mirrorVertical ? -m_rect.height() : m_rect.height()); - m_renderer->setProjectionMatrixToRect(mirrored, false); + m_renderer->setProjectionMatrixToRect(mirrored); m_renderer->setClearColor(Qt::transparent); if (m_multisampling) { diff --git a/src/quick/scenegraph/qsgrhilayer.cpp b/src/quick/scenegraph/qsgrhilayer.cpp index 80ca40d50a..757410eded 100644 --- a/src/quick/scenegraph/qsgrhilayer.cpp +++ b/src/quick/scenegraph/qsgrhilayer.cpp @@ -388,7 +388,10 @@ void QSGRhiLayer::grab() m_mirrorHorizontal ? -m_rect.width() : m_rect.width(), m_mirrorVertical ? m_rect.height() : -m_rect.height()); } - m_renderer->setProjectionMatrixToRect(mirrored, !m_rhi->isYUpInNDC()); + QSGAbstractRenderer::MatrixTransformFlags matrixFlags = 0; + if (!m_rhi->isYUpInNDC()) + matrixFlags |= QSGAbstractRenderer::MatrixTransformFlipY; + m_renderer->setProjectionMatrixToRect(mirrored, matrixFlags); m_renderer->setClearColor(Qt::transparent); m_renderer->setRenderTarget(m_rt); m_renderer->setCommandBuffer(m_context->currentFrameCommandBuffer()); -- cgit v1.2.3 From 262bf5c458f83491b7060c1d01ae37ca0cf1a457 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 16:43:53 +0200 Subject: Add some missing since and internal doc tags Change-Id: I50c6a5c7a55cfc481ff572113c58951983671cdc Reviewed-by: Lars Knoll --- .../scenegraph/coreapi/qsgrendererinterface.cpp | 34 +++++++++++++--------- src/quick/scenegraph/coreapi/qsgtexture.cpp | 3 ++ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp index bc68199e08..0fee1486cf 100644 --- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp +++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp @@ -78,11 +78,11 @@ QT_BEGIN_NAMESPACE \value OpenGL OpenGL ES 2.0 or higher \value Direct3D12 Direct3D 12 \value OpenVG OpenVG via EGL - \value OpenGLRhi OpenGL ES 2.0 or higher via a graphics abstraction layer - \value Direct3D11Rhi Direct3D 11 via a graphics abstraction layer - \value VulkanRhi Vulkan 1.0 via a graphics abstraction layer - \value MetalRhi Metal via a graphics abstraction layer - \value NullRhi Null (no output) via a graphics abstraction layer + \value OpenGLRhi OpenGL ES 2.0 or higher via a graphics abstraction layer. This value was introduced in Qt 5.14. + \value Direct3D11Rhi Direct3D 11 via a graphics abstraction layer. This value was introduced in Qt 5.14. + \value VulkanRhi Vulkan 1.0 via a graphics abstraction layer. This value was introduced in Qt 5.14. + \value MetalRhi Metal via a graphics abstraction layer. This value was introduced in Qt 5.14. + \value NullRhi Null (no output) via a graphics abstraction layer. This value was introduced in Qt 5.14. */ /*! @@ -111,33 +111,36 @@ QT_BEGIN_NAMESPACE used by the scenegraph, when running with the software backend. \value RhiResource The resource is a pointer to the QRhi instance used by - the scenegraph, when applicable. + the scenegraph, when applicable. This value was introduced in Qt 5.14. \value PhysicalDeviceResource The resource is a pointer to the pysical device object used by the scenegraph, when applicable. For example, a \c{VkPhysicalDevice *}. Note that with Vulkan the returned value is a - pointer to the VkPhysicalDevice, not the handle itself. + pointer to the VkPhysicalDevice, not the handle itself. This value was + introduced in Qt 5.14. \value OpenGLContextResource The resource is a pointer to the QOpenGLContext used by the scenegraph (on the render thread), when - applicable. + applicable. This value was introduced in Qt 5.14. \value DeviceContextResource The resource is a pointer to the device context used by the scenegraph, when applicable. For example, a - \c{ID3D11DeviceContext *}. + \c{ID3D11DeviceContext *}. This value was introduced in Qt 5.14. \value CommandEncoderResource The resource is a pointer to the currently active render command encoder object used by the scenegraph, when applicable. For example, a \c{MTLRenderCommandEncoder *}. This object has limited validity, and is only valid while the scene graph is recording a - render pass for the next frame. + render pass for the next frame. This value was introduced in Qt 5.14. \value VulkanInstanceResource The resource is a pointer to the - QVulkanInstance used by the scenegraph, when applicable. + QVulkanInstance used by the scenegraph, when applicable. This value was + introduced in Qt 5.14. \value RenderPassResource The resource is a pointer to the render pass used by the scenegraph, describing the color and depth/stecil attachments and - how they are used. For example, a \c{VkRenderPass *}. + how they are used. For example, a \c{VkRenderPass *}. This value was + introduced in Qt 5.14. */ /*! @@ -145,8 +148,9 @@ QT_BEGIN_NAMESPACE \value UnknownShadingLanguage Not yet known due to no window and scenegraph associated \value GLSL GLSL or GLSL ES \value HLSL HLSL - \value RhiShader Consumes QShader instances containing shader - variants for multiple target languages and bytecode formats + \value RhiShader Consumes QShader instances containing shader variants for + multiple target languages and intermediate formats. This value was introduced in + Qt 5.14. */ /*! @@ -222,6 +226,8 @@ void *QSGRendererInterface::getResource(QQuickWindow *window, const char *resour instead of directly calling the native graphics API. \note This function can be called on any thread. + + \since 5.14 */ bool QSGRendererInterface::isApiRhiBased(GraphicsApi api) { diff --git a/src/quick/scenegraph/coreapi/qsgtexture.cpp b/src/quick/scenegraph/coreapi/qsgtexture.cpp index c47401e5c0..edcee96bdb 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.cpp +++ b/src/quick/scenegraph/coreapi/qsgtexture.cpp @@ -717,6 +717,9 @@ void QSGTexture::updateRhiTexture(QRhi *rhi, QRhiResourceUpdateBatch *resourceUp d->updateRhiTexture(rhi, resourceUpdates); } +/*! + \internal + */ void QSGTexture::setWorkResourceUpdateBatch(QRhiResourceUpdateBatch *resourceUpdates) { Q_D(QSGTexture); -- cgit v1.2.3 From b477fff35fd347f27b56afefccbf15cfefec0886 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 16:16:49 +0200 Subject: Add missing doc entries for QSGGeometry::Type values Change-Id: Iaef8dfa6a984eb709aaae35a94641c3e0183254e Reviewed-by: Lars Knoll --- src/quick/scenegraph/coreapi/qsggeometry.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp index 5218b6b1d5..a28eee5288 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.cpp +++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp @@ -576,6 +576,10 @@ const void *QSGGeometry::indexData() const \value IntType \value UnsignedIntType \value FloatType + \value Bytes2Type Added in Qt 5.14. + \value Bytes3Type Added in Qt 5.14. + \value Bytes4Type Added in Qt 5.14. + \value DoubleType Added in Qt 5.14. */ /*! -- cgit v1.2.3 From 628b6ca43e2880f37ea208ff77d6a922dba9e283 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 11 Sep 2019 17:23:25 +0200 Subject: doc: correct the snippet for Item.scale The screenshot shows it having a transform origin at the top left, which is not the default. Task-number: QTBUG-78209 Change-Id: Id9a2d854493caba240960afa7ba400dc656ac0ab Reviewed-by: Paul Wicking --- src/quick/items/qquickitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index c1ab8716f3..4827f1ddd9 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5686,6 +5686,7 @@ void QQuickItem::setRotation(qreal r) color: "red" x: 25; y: 25; width: 50; height: 50 scale: 1.4 + transformOrigin: Item.TopLeft } } \endqml -- cgit v1.2.3 From 84a5969daf095190af1ea3c3174b31c053fcbd59 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 17 Sep 2019 11:46:04 +0200 Subject: PathView: fix warnings, oddities and whitespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - avoid runtime conversion of float->double when initializing a qreal - use qFuzzyCompare/qFuzzyIsNull to avoid direct comparison of qreal values - don't test a float value as a bool by implicit casting(!) to check whether it's zero - avoid implicit casts and old-style casts - fix whitespace around comments Change-Id: I7b0e77d38d5c86aa1a71833738deb5f0f893b507 Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickpathview.cpp | 158 ++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 8091a28a6c..01b16cf41f 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle) Q_LOGGING_CATEGORY(lcPathView, "qt.quick.pathview") -const qreal MinimumFlickVelocity = 75.0; +static const qreal MinimumFlickVelocity = 75; static QQmlOpenMetaObjectType *qPathViewAttachedType = nullptr; @@ -91,8 +91,8 @@ void QQuickPathViewAttached::setValue(const QByteArray &name, const QVariant &va } QQuickPathViewPrivate::QQuickPathViewPrivate() - : path(nullptr), currentIndex(0), currentItemOffset(0.0), startPc(0) - , offset(0.0), offsetAdj(0.0), mappedRange(1.0), mappedCache(0.0) + : path(nullptr), currentIndex(0), currentItemOffset(0), startPc(0) + , offset(0), offsetAdj(0), mappedRange(1), mappedCache(0) , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) , autoHighlight(true), highlightUp(false), layoutScheduled(false) , moving(false), flicking(false), dragging(false), inRequest(false), delegateValidated(false) @@ -164,7 +164,7 @@ void QQuickPathView::createdItem(int index, QObject *object) att->setOnPath(false); } item->setParentItem(this); - d->updateItem(item, 1.0); + d->updateItem(item, 1); } else { d->requestedIndex = -1; if (!d->inRequest) @@ -185,13 +185,13 @@ void QQuickPathView::initItem(int index, QObject *object) if (att) { att->m_view = this; qreal percent = d->positionOfIndex(index); - if (percent < 1.0 && d->path) { + if (percent < 1 && d->path) { const auto attributes = d->path->attributes(); for (const QString &attr : attributes) att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent)); item->setZ(d->requestedZ); } - att->setOnPath(percent < 1.0); + att->setOnPath(percent < 1); } } } @@ -265,17 +265,17 @@ void QQuickPathViewPrivate::updateMappedRange() mappedRange = qreal(modelCount)/pathItems; mappedCache = qreal(cacheSize)/pathItems/2; // Half of cache at each end } else { - mappedRange = 1.0; - mappedCache = 0.0; + mappedRange = 1; + mappedCache = 0; } } qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const { - qreal pos = -1.0; + qreal pos = -1; if (model && index >= 0 && index < modelCount) { - qreal start = 0.0; + qreal start = 0; if (haveHighlightRange && (highlightRangeMode != QQuickPathView::NoHighlightRange || snapMode != QQuickPathView::NoSnap)) start = highlightRangeStart; @@ -283,10 +283,10 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const globalPos = std::fmod(globalPos, qreal(modelCount)) / modelCount; if (pathItems != -1 && pathItems < modelCount) { globalPos += start / mappedRange; - globalPos = std::fmod(globalPos, qreal(1.0)); + globalPos = std::fmod(globalPos, qreal(1)); pos = globalPos * mappedRange; } else { - pos = std::fmod(globalPos + start, qreal(1.0)); + pos = std::fmod(globalPos + start, qreal(1)); } } @@ -297,7 +297,7 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const // account the circular space. bool QQuickPathViewPrivate::isInBound(qreal position, qreal lower, qreal upper) const { - if (lower == upper) + if (qFuzzyCompare(lower, upper)) return true; if (lower > upper) { if (position > upper && position > lower) @@ -359,7 +359,7 @@ void QQuickPathViewPrivate::updateHighlight() } else { qreal target = currentIndex; - offsetAdj = 0.0; + offsetAdj = 0; tl.reset(moveHighlight); moveHighlight.setValue(highlightPosition); @@ -368,14 +368,14 @@ void QQuickPathViewPrivate::updateHighlight() if (target - highlightPosition > modelCount/2) { highlightUp = false; qreal distance = modelCount - target + highlightPosition; - tl.move(moveHighlight, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance)); + tl.move(moveHighlight, 0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance)); tl.set(moveHighlight, modelCount-0.01); tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (modelCount-target) / distance)); } else if (target - highlightPosition <= -modelCount/2) { highlightUp = true; qreal distance = modelCount - highlightPosition + target; tl.move(moveHighlight, modelCount-0.01, QEasingCurve(QEasingCurve::InQuad), int(duration * (modelCount-highlightPosition) / distance)); - tl.set(moveHighlight, 0.0); + tl.set(moveHighlight, 0); tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance)); } else { highlightUp = highlightPosition - target < 0; @@ -387,9 +387,9 @@ void QQuickPathViewPrivate::updateHighlight() void QQuickPathViewPrivate::setHighlightPosition(qreal pos) { - if (pos != highlightPosition) { - qreal start = 0.0; - qreal end = 1.0; + if (!(qFuzzyCompare(pos, highlightPosition))) { + qreal start = 0; + qreal end = 1; if (haveHighlightRange && highlightRangeMode != QQuickPathView::NoHighlightRange) { start = highlightRangeStart; end = highlightRangeEnd; @@ -400,7 +400,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos) qreal relativeHighlight = std::fmod(pos + offset, range) / range; if (!highlightUp && relativeHighlight > end / mappedRange) { - qreal diff = 1.0 - relativeHighlight; + qreal diff = 1 - relativeHighlight; setOffset(offset + diff * range); } else if (highlightUp && relativeHighlight >= (end - start) / mappedRange) { qreal diff = relativeHighlight - (end - start) / mappedRange; @@ -411,7 +411,7 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos) qreal pathPos = positionOfIndex(pos); updateItem(highlightItem, pathPos); if (QQuickPathViewAttached *att = attached(highlightItem)) - att->setOnPath(pathPos < 1.0); + att->setOnPath(pathPos < 1); } } @@ -436,10 +436,10 @@ void QQuickPathViewPrivate::updateItem(QQuickItem *item, qreal percent) const auto attributes = path->attributes(); for (const QString &attr : attributes) att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); - att->setOnPath(percent < 1.0); + att->setOnPath(percent < 1); } - QQuickItemPrivate::get(item)->setCulled(percent >= 1.0); - QPointF pf = path->pointAtPercent(qMin(percent, qreal(1.0))); + QQuickItemPrivate::get(item)->setCulled(percent >= 1); + QPointF pf = path->pointAtPercent(qMin(percent, qreal(1))); item->setX(pf.x() - item->width()/2); item->setY(pf.y() - item->height()/2); } @@ -669,7 +669,7 @@ void QQuickPathView::setModel(const QVariant &m) d->currentIndex = 0; emit currentIndexChanged(); } - if (d->offset != 0.0) { + if (!(qFuzzyIsNull(d->offset))) { d->offset = 0; emit offsetChanged(); } @@ -821,7 +821,7 @@ void QQuickPathView::decrementCurrentIndex() \qmlproperty real QtQuick::PathView::offset The offset specifies how far along the path the items are from their initial positions. - This is a real number that ranges from 0.0 to the count of items in the model. + This is a real number that ranges from \c 0 to the count of items in the model. */ qreal QQuickPathView::offset() const { @@ -840,7 +840,7 @@ void QQuickPathView::setOffset(qreal offset) void QQuickPathViewPrivate::setOffset(qreal o) { Q_Q(QQuickPathView); - if (offset != o) { + if (!qFuzzyCompare(offset, o)) { if (isValid() && q->isComponentComplete()) { qreal oldOffset = offset; offset = std::fmod(o, qreal(modelCount)); @@ -883,7 +883,6 @@ void QQuickPathViewPrivate::setAdjustedOffset(qreal o) \sa highlightItem, highlightRangeMode */ - QQmlComponent *QQuickPathView::highlight() const { Q_D(const QQuickPathView); @@ -902,25 +901,26 @@ void QQuickPathView::setHighlight(QQmlComponent *highlight) } /*! - \qmlproperty Item QtQuick::PathView::highlightItem + \qmlproperty Item QtQuick::PathView::highlightItem - \c highlightItem holds the highlight item, which was created - from the \l highlight component. + \c highlightItem holds the highlight item, which was created + from the \l highlight component. - \sa highlight + \sa highlight */ QQuickItem *QQuickPathView::highlightItem() const { Q_D(const QQuickPathView); return d->highlightItem; } + /*! \qmlproperty real QtQuick::PathView::preferredHighlightBegin \qmlproperty real QtQuick::PathView::preferredHighlightEnd \qmlproperty enumeration QtQuick::PathView::highlightRangeMode These properties set the preferred range of the highlight (current item) - within the view. The preferred values must be in the range 0.0-1.0. + within the view. The preferred values must be in the range from \c 0 to \c 1. Valid values for \c highlightRangeMode are: @@ -961,7 +961,7 @@ qreal QQuickPathView::preferredHighlightBegin() const void QQuickPathView::setPreferredHighlightBegin(qreal start) { Q_D(QQuickPathView); - if (d->highlightRangeStart == start || start < 0 || start > 1.0) + if (qFuzzyCompare(d->highlightRangeStart, start) || start < 0 || start > 1) return; d->highlightRangeStart = start; d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd; @@ -978,7 +978,7 @@ qreal QQuickPathView::preferredHighlightEnd() const void QQuickPathView::setPreferredHighlightEnd(qreal end) { Q_D(QQuickPathView); - if (d->highlightRangeEnd == end || end < 0 || end > 1.0) + if (qFuzzyCompare(d->highlightRangeEnd, end) || end < 0 || end > 1) return; d->highlightRangeEnd = end; d->haveHighlightRange = d->highlightRangeStart <= d->highlightRangeEnd; @@ -1049,7 +1049,7 @@ qreal QQuickPathView::dragMargin() const void QQuickPathView::setDragMargin(qreal dragMargin) { Q_D(QQuickPathView); - if (d->dragMargin == dragMargin) + if (qFuzzyCompare(d->dragMargin, dragMargin)) return; d->dragMargin = dragMargin; emit dragMarginChanged(); @@ -1070,7 +1070,7 @@ qreal QQuickPathView::flickDeceleration() const void QQuickPathView::setFlickDeceleration(qreal dec) { Q_D(QQuickPathView); - if (d->deceleration == dec) + if (qFuzzyCompare(d->deceleration, dec)) return; d->deceleration = dec; emit flickDecelerationChanged(); @@ -1091,7 +1091,7 @@ qreal QQuickPathView::maximumFlickVelocity() const void QQuickPathView::setMaximumFlickVelocity(qreal vel) { Q_D(QQuickPathView); - if (vel == d->maximumFlickVelocity) + if (qFuzzyCompare(vel, d->maximumFlickVelocity)) return; d->maximumFlickVelocity = vel; emit maximumFlickVelocityChanged(); @@ -1581,7 +1581,7 @@ QQuickItem *QQuickPathView::itemAtIndex(int index) const QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const { const auto pathLength = path->path().length(); - qreal samples = qMin(pathLength / 5, qreal(500.0)); + qreal samples = qMin(pathLength / 5, qreal(500)); qreal res = pathLength / samples; qreal mindist = 1e10; // big number @@ -1602,7 +1602,7 @@ QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercen // now refine qreal approxPc = nearPc; - for (qreal i = approxPc-1.0; i < approxPc+1.0; i += 1/(2*res)) { + for (qreal i = approxPc-1; i < approxPc+1; i += 1/(2*res)) { QPointF pt = path->pointAtPercent(i/samples); QPointF diff = pt - point; qreal dist = diff.x()*diff.x() + diff.y()*diff.y(); @@ -1645,7 +1645,7 @@ qreal QQuickPathViewPrivate::calcVelocity() const qint64 QQuickPathViewPrivate::computeCurrentTime(QInputEvent *event) const { if (0 != event->timestamp()) - return event->timestamp(); + return qint64(event->timestamp()); return timer.elapsed(); } @@ -1672,7 +1672,7 @@ void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event) if (item->contains(item->mapFromScene(event->windowPos()))) break; } - if (idx == items.count() && dragMargin == 0.) // didn't click on an item + if (idx == items.count() && qFuzzyIsNull(dragMargin)) // didn't click on an item return; startPoint = pointNear(event->localPos(), &startPc); @@ -1733,7 +1733,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) moveReason = QQuickPathViewPrivate::Mouse; int count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount); qreal diff = (newPc - startPc)*count; - if (diff) { + if (!qFuzzyIsNull(diff)) { q->setOffset(offset + diff); if (diff > modelCount/2) @@ -1743,7 +1743,7 @@ void QQuickPathViewPrivate::handleMouseMoveEvent(QMouseEvent *event) qint64 elapsed = currentTimestamp - lastPosTime; if (elapsed > 0) - addVelocitySample(diff / (qreal(elapsed) / 1000.)); + addVelocitySample(diff / (qreal(elapsed) / 1000)); } if (!moving) { moving = true; @@ -1805,32 +1805,32 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *event) || snapMode != QQuickPathView::NoSnap)) { if (snapMode == QQuickPathView::SnapOneItem) { // encourage snapping one item in direction of motion - if (velocity > 0.) + if (velocity > 0) dist = qRound(0.5 + offset) - offset; else dist = qRound(0.5 - offset) + offset; } else { // + 0.25 to encourage moving at least one item in the flick direction - dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0) + 0.25)); + dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2) + 0.25)); // round to nearest item. - if (velocity > 0.) + if (velocity > 0) dist = qRound(dist + offset) - offset; else dist = qRound(dist - offset) + offset; } // Calculate accel required to stop on item boundary - if (dist <= 0.) { - dist = 0.; - accel = 0.; + if (dist <= 0) { + dist = 0; + accel = 0; } else { - accel = v2 / (2.0f * qAbs(dist)); + accel = v2 / (2 * qAbs(dist)); } } else { - dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0))); + dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2))); } - flickDuration = static_cast(1000 * qAbs(velocity) / accel); - offsetAdj = 0.0; + flickDuration = int(1000 * qAbs(velocity) / accel); + offsetAdj = 0; moveOffset.setValue(offset); tl.accel(moveOffset, velocity, accel, dist); tl.callback(QQuickTimeLineCallback(&moveOffset, fixOffsetCallback, this)); @@ -2004,7 +2004,7 @@ void QQuickPathView::refill() else qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item; } - if (pos < 1.0) { + if (pos < 1) { d->updateItem(item, pos); if (idx == d->currentIndex) { currentVisible = true; @@ -2014,9 +2014,9 @@ void QQuickPathView::refill() } else { d->updateItem(item, pos); if (QQuickPathViewAttached *att = d->attached(item)) - att->setOnPath(pos < 1.0); - if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) { - qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1.0 + d->mappedCache); + att->setOnPath(pos < 1); + if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1 + d->mappedCache)) { + qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1 + d->mappedCache); d->releaseItem(item); it = d->items.erase(it); } else { @@ -2032,12 +2032,12 @@ void QQuickPathView::refill() int endIdx = 0; qreal endPos; int startIdx = 0; - qreal startPos = 0.0; + qreal startPos = 0; const bool wasEmpty = d->items.isEmpty(); if (!wasEmpty) { //Find the beginning and end, items may not be in sorted order - endPos = -1.0; - startPos = 2.0; + endPos = -1; + startPos = 2; for (QQuickItem * item : qAsConst(d->items)) { int idx = d->model->indexOf(item, nullptr); @@ -2066,10 +2066,10 @@ void QQuickPathView::refill() if (idx >= d->modelCount) idx = 0; qreal nextPos = d->positionOfIndex(idx); - while ((d->isInBound(nextPos, endPos, 1.0 + d->mappedCache) || !d->items.count()) + while ((d->isInBound(nextPos, endPos, 1 + d->mappedCache) || !d->items.count()) && d->items.count() < count+d->cacheSize) { qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); - QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); + QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1); if (!item) { waiting = true; break; @@ -2101,7 +2101,7 @@ void QQuickPathView::refill() while (!waiting && d->isInBound(nextPos, d->mappedRange - d->mappedCache, startPos) && d->items.count() < count+d->cacheSize) { qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); - QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); + QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1); if (!item) { waiting = true; break; @@ -2134,9 +2134,9 @@ void QQuickPathView::refill() QQuickItem *lastItem = d->items.at(0); while (idx != endIdx) { nextPos = d->positionOfIndex(idx); - if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) { + if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1 + d->mappedCache)) { //This gets the reference from the delegate model, and will not re-create - QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0); + QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1); if (!item) { waiting = true; break; @@ -2170,13 +2170,13 @@ void QQuickPathView::refill() bool currentChanged = false; if (!currentVisible) { - d->currentItemOffset = 1.0; + d->currentItemOffset = 1; if (d->currentItem) { - d->updateItem(d->currentItem, 1.0); + d->updateItem(d->currentItem, 1); } else if (!waiting && d->currentIndex >= 0 && d->currentIndex < d->modelCount) { if ((d->currentItem = d->getItem(d->currentIndex, d->currentIndex))) { currentChanged = true; - d->updateItem(d->currentItem, 1.0); + d->updateItem(d->currentItem, 1); if (QQuickPathViewAttached *att = d->attached(d->currentItem)) att->setIsCurrentItem(true); } @@ -2370,7 +2370,7 @@ void QQuickPathViewPrivate::createCurrentItem() } } else if (currentIndex >= 0 && currentIndex < modelCount) { if ((currentItem = getItem(currentIndex, currentIndex))) { - updateItem(currentItem, 1.0); + updateItem(currentItem, 1); if (QQuickPathViewAttached *att = attached(currentItem)) att->setIsCurrentItem(true); } @@ -2404,7 +2404,7 @@ void QQuickPathViewPrivate::updateCurrent() void QQuickPathViewPrivate::fixOffsetCallback(void *d) { - ((QQuickPathViewPrivate *)d)->fixOffset(); + static_cast(d)->fixOffset(); } void QQuickPathViewPrivate::fixOffset() @@ -2429,7 +2429,7 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason) qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount)); moveReason = reason; - offsetAdj = 0.0; + offsetAdj = 0; tl.reset(moveOffset); moveOffset.setValue(offset); @@ -2441,20 +2441,20 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason) if (!duration || qAbs(offset - targetOffset) < threshold || (qFuzzyIsNull(targetOffset) && qAbs(modelCount - offset) < threshold)) { tl.set(moveOffset, targetOffset); - } else if (moveDirection == QQuickPathView::Positive || (moveDirection == QQuickPathView::Shortest && targetOffset - offset > modelCount/2.0)) { + } else if (moveDirection == QQuickPathView::Positive || (moveDirection == QQuickPathView::Shortest && targetOffset - offset > modelCount/2)) { qreal distance = modelCount - targetOffset + offset; if (targetOffset > moveOffset) { - tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); + tl.move(moveOffset, 0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); tl.set(moveOffset, modelCount); - tl.move(moveOffset, targetOffset, QEasingCurve(offset == 0.0 ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance)); + tl.move(moveOffset, targetOffset, QEasingCurve(qFuzzyIsNull(offset) ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance)); } else { tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); } - } else if (moveDirection == QQuickPathView::Negative || targetOffset - offset <= -modelCount/2.0) { + } else if (moveDirection == QQuickPathView::Negative || targetOffset - offset <= -modelCount/2) { qreal distance = modelCount - offset + targetOffset; if (targetOffset < moveOffset) { - tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance)); - tl.set(moveOffset, 0.0); + tl.move(moveOffset, modelCount, QEasingCurve(qFuzzyIsNull(targetOffset) ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance)); + tl.set(moveOffset, 0); tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance)); } else { tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); -- cgit v1.2.3 From 1cef434ae29d21bd46adb26d84ff37eec596985c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 09:25:30 +0200 Subject: Fix deprecation macros in qqml.h Give a friendly message for qmlAttachedPropertiesObject(int ...) and disable plain qmlRegisterType() if QT_DEPRECATED_SINCE(5, 14). Change-Id: I9373f38fdddcb58ec1211b6cab492e1bc5370e52 Reviewed-by: Fabian Kosmale Reviewed-by: Albert Astals Cid Reviewed-by: Simon Hausmann --- src/qml/qml/qqml.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h index 6295345fa4..b2bf1f328f 100644 --- a/src/qml/qml/qqml.h +++ b/src/qml/qml/qqml.h @@ -133,11 +133,13 @@ int qmlRegisterAnonymousType(const char *uri, int versionMajor) return QQmlPrivate::qmlregister(QQmlPrivate::TypeRegistration, &type); } +#if QT_DEPRECATED_SINCE(5, 14) template QT_DEPRECATED_VERSION_X_5_14("Use qmlRegisterAnonymousType instead") int qmlRegisterType() { return qmlRegisterAnonymousType("", 1); } +#endif int Q_QML_EXPORT qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message); @@ -586,8 +588,10 @@ namespace QtQml { Q_QML_EXPORT QQmlContext *qmlContext(const QObject *); Q_QML_EXPORT QQmlEngine *qmlEngine(const QObject *); #if QT_DEPRECATED_SINCE(5, 14) - Q_QML_EXPORT QT_DEPRECATED QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); - Q_QML_EXPORT QT_DEPRECATED QObject *qmlAttachedPropertiesObject( + Q_QML_EXPORT QT_DEPRECATED_VERSION_X_5_14("Use qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc, bool") + QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); + Q_QML_EXPORT QT_DEPRECATED_VERSION_X_5_14("Use qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc, bool") + QObject *qmlAttachedPropertiesObject( int *, const QObject *, const QMetaObject *, bool create); #endif Q_QML_EXPORT QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *, -- cgit v1.2.3 From b9ba1ed06f63053b6fe5426cc1cc726b6b85592f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 17 Sep 2019 09:22:09 +0200 Subject: Fix documentation for qmlRegisterType and qmlRegisterAnonymousType Plain qmlRegisterType() is deprecated and qmlRegisterAnonymousType() was added in 5.14 as replacement. Also, qmlRegisterAnonymousType() does take an import URI and a major version. The point about non-anonymous type registration is that it also takes an element name. Change-Id: I51fb6f9c63dcf15dc1da10c25ea6c6d3b88fd31a Reviewed-by: Kavindra Palaraja --- src/qml/doc/src/qmlfunctions.qdoc | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index c71d18418a..81aa263fa6 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -276,25 +276,14 @@ /*! \fn int qmlRegisterAnonymousType(const char *uri, int versionMajor) - This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system. + This template function registers the C++ type in the QML system as an anonymous type. The + resulting QML type does not have a name. Therefore, instances of this type cannot be created from + the QML system. You can, however, access instances of the type when they are exposed as properties + of other types. - Use this function when the type will not be referenced by name. Use \a uri and \a versionMajor to indicate to which module the type belongs. - - \sa {Choosing the Correct Integration Method Between C++ and QML} -*/ - -/*! - \fn int qmlRegisterType() - \relates QQmlEngine - \overload - - This template function registers the C++ type in the QML - system. Instances of this type cannot be created from the QML - system. - - This function should be used when the type will not be referenced by name. - Specifically, it has to be used for C++ types that are used as the left-hand - side of a property binding. + Use this function when the type will not be referenced by name, specifically for C++ types that + are used on the left-hand side of a property binding. To indicate to which module the type belongs + use \a uri and \a versionMajor. For example, consider the following two classes: @@ -354,17 +343,28 @@ \code qmlRegisterType("App", 1, 0, "Foo"); - qmlRegisterType(); + qmlRegisterAnonymousType("App", 1); \endcode As the \c Foo type is instantiated in QML, it must be registered - with the version of \l qmlRegisterType() that takes an import URI. + with the version of \l qmlRegisterType() that takes an element name. Returns the QML type id. + \since 5.14 \sa {Choosing the Correct Integration Method Between C++ and QML} */ +/*! + \fn int qmlRegisterType() + \relates QQmlEngine + \overload + \deprecated + + Do not use this function. For anonymous type registrations, use \l qmlRegisterAnonymousType(), + and make sure to provide a URI and a major version. +*/ + /*! \fn int qmlRegisterInterface(const char *typeName) \relates QQmlEngine -- cgit v1.2.3 From 9274ed77bc273330a3f202a00239dcc1b6ef8cc3 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 19 Sep 2019 07:26:44 +0200 Subject: Check if the filters are different before triggering an update If the filters list is the same as before, then there is no reason to trigger an update on the thread as the result would be the same as before. This solves a problem that was occurring with iOS 13 as it would get stuck due to repeated calls to setNameFilters() with the same filter list. Fixes: QTBUG-78468 Change-Id: I705cfaaa0a1a19b1d0397140a5831fc67557a4ee Reviewed-by: Mitch Curtis --- src/imports/folderlistmodel/qquickfolderlistmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 2040fb5f0c..51931097f3 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -539,6 +539,8 @@ QStringList QQuickFolderListModel::nameFilters() const void QQuickFolderListModel::setNameFilters(const QStringList &filters) { Q_D(QQuickFolderListModel); + if (d->nameFilters == filters) + return; d->fileInfoThread.setNameFilters(filters); d->nameFilters = filters; } -- cgit v1.2.3 From 5e96f43fe03e16d7ca68f0dd888c4518a98694f2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 12 Sep 2019 09:41:38 +0200 Subject: doc: explain more about acceptedModifiers in PointerDeviceHandler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having neither a list of all possible modifiers nor a link to Qt::KeyboardModifier was inconvenient. Clarify that bitwise OR results in logical-AND behavior, while having multiple handlers results in logical-OR behavior, and that a switch statement in JS allows you do anything you like with modifiers. Fix the manual test to test the switch statement and deal with the fact that point.event.modifiers is undefined: TapHandler can use eventPoint.modifiers, but any DeviceHandler can use point.modifiers. Fixes: QTBUG-78234 Change-Id: Iba2a03950aa1279ef454cc76fc8de1b2dab14dfb Reviewed-by: Venugopal Shivashankar Reviewed-by: Jan Arve Sæther --- src/quick/handlers/qquickpointerdevicehandler.cpp | 51 ++++++++++++++++++++++- tests/manual/pointer/tapWithModifiers.qml | 14 ++++++- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp index 246686e4f4..2964042f39 100644 --- a/src/quick/handlers/qquickpointerdevicehandler.cpp +++ b/src/quick/handlers/qquickpointerdevicehandler.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -230,6 +230,55 @@ void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QQuickPointerDevice::Po } } \endqml + + If you set \c acceptedModifiers to an OR combination of modifier keys, + it means \e all of those modifiers must be pressed to activate the handler: + + \qml + Item { + TapHandler { + acceptedModifiers: Qt.ControlModifier | Qt.AltModifier | Qt.ShiftModifier + onTapped: console.log("control-alt-shift-tapped") + } + } + \endqml + + The available modifiers are as follows: + + \value NoModifier No modifier key is allowed. + \value ShiftModifier A Shift key on the keyboard must be pressed. + \value ControlModifier A Ctrl key on the keyboard must be pressed. + \value AltModifier An Alt key on the keyboard must be pressed. + \value MetaModifier A Meta key on the keyboard must be pressed. + \value KeypadModifier A keypad button must be pressed. + \value GroupSwitchModifier X11 only (unless activated on Windows by a command line argument). + A Mode_switch key on the keyboard must be pressed. + \value KeyboardModifierMask The handler does not care which modifiers are pressed. + + If you need even more complex behavior than can be achieved with + combinations of multiple handlers with multiple modifier flags, you can + check the modifiers in JavaScript code: + + \qml + Item { + TapHandler { + onTapped: + switch (point.modifiers) { + case Qt.ControlModifier | Qt.AltModifier: + console.log("CTRL+ALT"); + break; + case Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier: + console.log("CTRL+META+ALT"); + break; + default: + console.log("other modifiers", point.modifiers); + break; + } + } + } + \endqml + + \sa Qt::KeyboardModifier */ void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers) { diff --git a/tests/manual/pointer/tapWithModifiers.qml b/tests/manual/pointer/tapWithModifiers.qml index 8ca1c1bd63..da3c0cb30a 100644 --- a/tests/manual/pointer/tapWithModifiers.qml +++ b/tests/manual/pointer/tapWithModifiers.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the manual tests of the Qt Toolkit. @@ -40,6 +40,16 @@ Item { onTapped: console.log("tapped with no modifiers") } TapHandler { - onTapped: console.log("tapped with modifiers " + point.event.modifiers) + onTapped: + switch (point.modifiers) { + case Qt.ControlModifier | Qt.AltModifier: + console.log("CTRL+ALT"); + break; + case Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier: + console.log("CTRL+META+ALT"); + break; + default: + console.log("other modifiers", point.modifiers) + } } } -- cgit v1.2.3 From 3fb574d01c106e786f9a43ef1e0d781e156d52fa Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 16 Aug 2018 11:29:29 +0200 Subject: HoverHandler: handle all device types; hovered=false on touch release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn't make sense to show hover feedback after releasing a touchpoint just because the core pointer cursor happened to move along with the touchpoint, so we explicitly set the hovered property to false when the touchpoint is released. However the next mouse movement will set it back to true again if the mouse cursor is still inside. This is especially important for touchscreen-based haptic interfaces: any hover feedback should be shown when a finger is dragged into an interface element and hidden again when the finger is released. Change-Id: Iff7f23f089466cc0da94d2a46690719f6d70cae2 Reviewed-by: Jan Arve Sæther --- src/quick/handlers/qquickhoverhandler.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/quick/handlers/qquickhoverhandler.cpp b/src/quick/handlers/qquickhoverhandler.cpp index a6325e084b..79cb288af8 100644 --- a/src/quick/handlers/qquickhoverhandler.cpp +++ b/src/quick/handlers/qquickhoverhandler.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. @@ -72,9 +72,6 @@ QQuickHoverHandler::QQuickHoverHandler(QQuickItem *parent) { // Tell QQuickPointerDeviceHandler::wantsPointerEvent() to ignore button state d_func()->acceptedButtons = Qt::NoButton; - // Rule out the touchscreen for now (can be overridden in QML in case a hover-detecting touchscreen exists) - setAcceptedDevices(static_cast( - static_cast(QQuickPointerDevice::AllDevices) ^ static_cast(QQuickPointerDevice::TouchScreen))); } QQuickHoverHandler::~QQuickHoverHandler() @@ -103,7 +100,11 @@ bool QQuickHoverHandler::wantsPointerEvent(QQuickPointerEvent *event) void QQuickHoverHandler::handleEventPoint(QQuickEventPoint *point) { - setHovered(true); + bool hovered = true; + if (point->state() == QQuickEventPoint::Released && + point->pointerEvent()->device()->pointerType() == QQuickPointerDevice::Finger) + hovered = false; + setHovered(hovered); setPassiveGrab(point); } -- cgit v1.2.3 From 36be27265d61c76b25417a25e482030e30ff380f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 20 Sep 2019 16:38:30 +0200 Subject: QMLJS: Fix exception handling in promises If an exception is thrown inside a promise's resolve or reject handler, the promise needs to resolve into a rejected state with the exceptions value. The value was previously not set. Fixes: QTBUG-78554 Change-Id: Ic22faa6ef1e519e4cae6732c69bb14f7053d13da Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot --- src/qml/jsruntime/qv4promiseobject.cpp | 1 + .../auto/qml/qqmlpromise/data/promisehandlerthrows.qml | 17 +++++++++++++++++ tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml diff --git a/src/qml/jsruntime/qv4promiseobject.cpp b/src/qml/jsruntime/qv4promiseobject.cpp index 40a0dfaa57..851fee7bd8 100644 --- a/src/qml/jsruntime/qv4promiseobject.cpp +++ b/src/qml/jsruntime/qv4promiseobject.cpp @@ -163,6 +163,7 @@ void ReactionHandler::executeReaction(ReactionEvent *event) ScopedFunctionObject reaction(scope); if (scope.hasException()) { reaction = capability->d()->reject.as(); + result = scope.engine->catchException(); } else { reaction = capability->d()->resolve.as(); } diff --git a/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml new file mode 100644 index 0000000000..d23ea43e74 --- /dev/null +++ b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml @@ -0,0 +1,17 @@ +import QtQuick 2.12 + +Item { + id: root + property string errorMessage + Component.onCompleted: () => { + let prom = Promise.reject("Some error") + .then( + o => {console.log("Never reached");}, + err => { + console.log("Rethrowing err"); + throw err; + } + ) + .catch(err => root.errorMessage = err) + } +} diff --git a/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp b/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp index 41850d0263..b430434526 100644 --- a/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp +++ b/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp @@ -83,6 +83,7 @@ private slots: void then_reject_non_callable(); void then_resolve_multiple_then(); void promiseChain(); + void promiseHandlerThrows(); private: void execute_test(QString testName); @@ -285,6 +286,17 @@ void tst_qqmlpromise::promiseChain() } +void tst_qqmlpromise::promiseHandlerThrows() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("promisehandlerthrows.qml")); + QVERIFY(component.isReady()); + QTest::ignoreMessage(QtDebugMsg, "Rethrowing err"); + QScopedPointer root(component.create()); + QVERIFY(root); + QTRY_VERIFY(root->property("errorMessage") == QLatin1String("Some error")); +} + QTEST_MAIN(tst_qqmlpromise) -- cgit v1.2.3 From d3817f4b0b42b180b36c3c5afb22eb592a7e2a91 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Fri, 13 Sep 2019 13:53:21 +0200 Subject: doc: Fix several qdoc warnings This update repares several "Can't link to...," "No such parameter...," and "Undocumented parameter..." warnings. Change-Id: I3649cf35f766e5a87ca5df48301e8063a31d7904 Reviewed-by: Paul Wicking --- src/qml/doc/src/qmlfunctions.qdoc | 2 +- src/qml/qml/qqmlapplicationengine.cpp | 2 +- src/qml/qml/qqmlcomponent.cpp | 7 ++++--- src/qml/qml/qqmlinfo.cpp | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 81aa263fa6..b083012eab 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -458,7 +458,7 @@ */ /*! - \fn template QObject *qmlAttachedPropertiesObject(const QObject *attachee, bool create = true) + \fn template QObject *qmlAttachedPropertiesObject(const QObject *attachee, bool create) \relates QQmlEngine The form of this template function is: diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index d04a89b514..adb036e2d0 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -279,7 +279,7 @@ void QQmlApplicationEngine::load(const QString &filePath) } /*! - Sets the initial properties with which the QML component gets initialized after + Sets the \a initialProperties with which the QML component gets initialized after it gets loaded. diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index ed8c41a582..b26b90d2aa 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -813,8 +813,9 @@ QObject *QQmlComponent::create(QQmlContext *context) } /*! - Create an object instance of this component, and initialize its toplevel properties according to initalPropertyValues. - + Create an object instance of this component, and initialize its toplevel + properties with \a initialProperties. \a context specifies the context + where the object instance is to be created. \sa QQmlComponent::create \since 5.14 @@ -1104,7 +1105,7 @@ void QQmlComponent::create(QQmlIncubator &incubator, QQmlContext *context, } /*! - Set toplevel properties of the component. + Set toplevel \a properties of the \a component. This method provides advanced control over component instance creation. diff --git a/src/qml/qml/qqmlinfo.cpp b/src/qml/qml/qqmlinfo.cpp index 6322302422..2bfd2d5bb4 100644 --- a/src/qml/qml/qqmlinfo.cpp +++ b/src/qml/qml/qqmlinfo.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlDebug(const QObject *object) - \relates QQmlEngine + \relates QtQml \since 5.9 Prints debug messages that include the file and line number for the @@ -91,7 +91,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlInfo(const QObject *object) - \relates QQmlEngine + \relates QtQml Prints informational messages that include the file and line number for the specified QML \a object. @@ -119,7 +119,7 @@ QT_BEGIN_NAMESPACE /*! \fn QQmlInfo QtQml::qmlWarning(const QObject *object) - \relates QQmlEngine + \relates QtQml \since 5.9 Prints warning messages that include the file and line number for the -- cgit v1.2.3 From 5f4b7f37a430135cbbf930373e0e9682e9a3a2ac Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 12 Sep 2019 11:02:43 +0200 Subject: Handle rhi device loss in the basic render loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I02cee05ce7eee2ad1c458d1a934c210c12d1dea2 Reviewed-by: Christian Strømme --- src/quick/scenegraph/qsgrenderloop.cpp | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index 25d10d37d4..a5b5fe04f5 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -190,6 +190,7 @@ public: QSGRenderContext *createRenderContext(QSGContext *) const override { return rc; } void releaseSwapchain(QQuickWindow *window); + void handleDeviceLoss(); bool eventFilter(QObject *watched, QEvent *event) override; @@ -438,6 +439,25 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) delete d->animationController; } +void QSGGuiThreadRenderLoop::handleDeviceLoss() +{ + if (!rhi || !rhi->isDeviceLost()) + return; + + qWarning("Graphics device lost, cleaning up scenegraph and releasing RHI"); + + for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it) + QQuickWindowPrivate::get(it.key())->cleanupNodesOnShutdown(); + + rc->invalidate(); + + for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it) + releaseSwapchain(it.key()); + + delete rhi; + rhi = nullptr; +} + void QSGGuiThreadRenderLoop::releaseSwapchain(QQuickWindow *window) { QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window); @@ -488,8 +508,11 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) const bool enableRhi = rhiSupport->isRhiEnabled(); if (enableRhi && !rhi) { - offscreenSurface = rhiSupport->maybeCreateOffscreenSurface(window); + if (!offscreenSurface) + offscreenSurface = rhiSupport->maybeCreateOffscreenSurface(window); + rhi = rhiSupport->createRhi(window, offscreenSurface); + if (rhi) { if (rhiSupport->isProfilingRequested()) QSGRhiProfileConnection::instance()->initialize(rhi); @@ -643,13 +666,19 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (previousOutputSize != effectiveOutputSize || cd->swapchainJustBecameRenderable) { if (cd->swapchainJustBecameRenderable) qCDebug(QSG_LOG_RENDERLOOP, "just became exposed"); - cd->swapchainJustBecameRenderable = false; - cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); + cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); cd->depthStencilForSwapchain->build(); + cd->hasActiveSwapchain = cd->swapchain->buildOrResize(); + if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) { + handleDeviceLoss(); + return; + } + cd->swapchainJustBecameRenderable = false; cd->hasRenderableSwapchain = cd->hasActiveSwapchain; + if (!cd->hasActiveSwapchain) qWarning("Failed to build or resize swapchain"); else @@ -662,7 +691,7 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) QRhi::FrameOpResult frameResult = rhi->beginFrame(cd->swapchain, frameFlags); if (frameResult != QRhi::FrameOpSuccess) { if (frameResult == QRhi::FrameOpDeviceLost) - qWarning("Device lost"); + handleDeviceLoss(); else if (frameResult == QRhi::FrameOpError) qWarning("Failed to start frame"); // out of date is not worth warning about - it may happen even during resizing on some platforms @@ -701,7 +730,13 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) QRhi::EndFrameFlags flags = 0; if (!needsPresent) flags |= QRhi::SkipPresent; - rhi->endFrame(cd->swapchain, flags); + QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); + if (frameResult != QRhi::FrameOpSuccess) { + if (frameResult == QRhi::FrameOpDeviceLost) + handleDeviceLoss(); + else if (frameResult == QRhi::FrameOpError) + qWarning("Failed to end frame"); + } } else if (needsPresent) { if (!cd->customRenderStage || !cd->customRenderStage->swap()) gl->swapBuffers(window); -- cgit v1.2.3 From 18955f3c89443d13a0b6dfa8056df1d38d5bbff6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 Sep 2019 15:50:49 +0200 Subject: Recover from device lost on the rhi path in the threaded loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I90d43d5daa75bbc52c9c10f4ef920b898bbd39d4 Reviewed-by: Christian Strømme --- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 161 +++++++++++++++---------- 1 file changed, 100 insertions(+), 61 deletions(-) diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index eb6eec342c..cbf57225b0 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -199,7 +199,7 @@ public: WMSyncEvent(QQuickWindow *c, bool inExpose, bool force) : WMWindowEvent(c, WM_RequestSync) , size(c->size()) - , dpr(c->effectiveDevicePixelRatio()) + , dpr(float(c->effectiveDevicePixelRatio())) , syncInExpose(inExpose) , forceRenderPass(force) {} @@ -306,8 +306,7 @@ public: delete offscreenSurface; } - void invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *backupSurface); - void initializeOpenGL(); + void invalidateGraphics(QQuickWindow *window, bool inDestructor, QOffscreenSurface *backupSurface); bool event(QEvent *) override; void run() override; @@ -340,6 +339,9 @@ public: ExposeRequest = 0x04 | RepaintRequest | SyncRequest }; + void ensureRhi(); + void handleDeviceLoss(); + QSGThreadedRenderLoop *wm; QOpenGLContext *gl; bool enableRhi; @@ -419,9 +421,9 @@ bool QSGRenderThread::event(QEvent *e) WMTryReleaseEvent *wme = static_cast(e); if (!window || wme->inDestructor) { qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- setting exit flag and invalidating OpenGL"); - invalidateOpenGL(wme->window, wme->inDestructor, wme->needsFallback ? offscreenSurface : nullptr); + invalidateGraphics(wme->window, wme->inDestructor, wme->needsFallback ? offscreenSurface : nullptr); active = gl || rhi; - Q_ASSERT_X(!wme->inDestructor || !active, "QSGRenderThread::invalidateOpenGL()", "Thread's active state is not set to false when shutting down"); + Q_ASSERT_X(!wme->inDestructor || !active, "QSGRenderThread::invalidateGraphics()", "Thread's active state is not set to false when shutting down"); if (sleeping) stopEventProcessing = true; } else { @@ -512,9 +514,9 @@ bool QSGRenderThread::event(QEvent *e) return QThread::event(e); } -void QSGRenderThread::invalidateOpenGL(QQuickWindow *window, bool inDestructor, QOffscreenSurface *fallback) +void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor, QOffscreenSurface *fallback) { - qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "invalidateOpenGL()"); + qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "invalidateGraphics()"); if (!gl && !rhi) return; @@ -615,7 +617,7 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab) QSGDefaultRenderContext::InitParams rcParams; rcParams.sampleCount = qMax(1, gl->format().samples()); rcParams.openGLContext = gl; - rcParams.initialSurfacePixelSize = windowSize * dpr; + rcParams.initialSurfacePixelSize = windowSize * qreal(dpr); rcParams.maybeSurface = window; sgrc->initialize(&rcParams); } @@ -658,6 +660,19 @@ void QSGRenderThread::sync(bool inExpose, bool inGrab) } } +void QSGRenderThread::handleDeviceLoss() +{ + if (!rhi || !rhi->isDeviceLost()) + return; + + qWarning("Graphics device lost, cleaning up scenegraph and releasing RHI"); + QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown(); + sgrc->invalidate(); + wm->releaseSwapchain(window); + delete rhi; + rhi = nullptr; +} + void QSGRenderThread::syncAndRender(QImage *grabImage) { bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled(); @@ -699,13 +714,20 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) if (previousOutputSize != effectiveOutputSize || cd->swapchainJustBecameRenderable) { if (cd->swapchainJustBecameRenderable) qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "just became exposed"); - cd->swapchainJustBecameRenderable = false; - cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); + cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); cd->depthStencilForSwapchain->build(); + cd->hasActiveSwapchain = cd->swapchain->buildOrResize(); + if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) { + handleDeviceLoss(); + QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest))); + return; + } + cd->swapchainJustBecameRenderable = false; cd->hasRenderableSwapchain = cd->hasActiveSwapchain; + if (!cd->hasActiveSwapchain) qWarning("Failed to build or resize swapchain"); else @@ -718,13 +740,12 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) QRhi::FrameOpResult frameResult = rhi->beginFrame(cd->swapchain, frameFlags); if (frameResult != QRhi::FrameOpSuccess) { if (frameResult == QRhi::FrameOpDeviceLost) - qWarning("Device lost"); + handleDeviceLoss(); else if (frameResult == QRhi::FrameOpError) qWarning("Failed to start frame"); // try again later if (frameResult == QRhi::FrameOpDeviceLost || frameResult == QRhi::FrameOpSwapChainOutOfDate) QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest))); - // Before returning we need to ensure the same wake up logic that // would have happened if beginFrame() had suceeded. if (exposeRequested) { @@ -810,7 +831,15 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) QRhi::EndFrameFlags flags = 0; if (grabImage) flags |= QRhi::SkipPresent; - rhi->endFrame(cd->swapchain, flags); + QRhi::FrameOpResult frameResult = rhi->endFrame(cd->swapchain, flags); + if (frameResult != QRhi::FrameOpSuccess) { + if (frameResult == QRhi::FrameOpDeviceLost) + handleDeviceLoss(); + else if (frameResult == QRhi::FrameOpError) + qWarning("Failed to end frame"); + if (frameResult == QRhi::FrameOpDeviceLost || frameResult == QRhi::FrameOpSwapChainOutOfDate) + QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest))); + } } else { if (!cd->customRenderStage || !cd->customRenderStage->swap()) gl->swapBuffers(window); @@ -884,6 +913,57 @@ void QSGRenderThread::processEventsAndWaitForMore() qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "--- done processEventsAndWaitForMore()"); } +void QSGRenderThread::ensureRhi() +{ + if (!rhi) { + QSGRhiSupport *rhiSupport = QSGRhiSupport::instance(); + rhi = rhiSupport->createRhi(window, offscreenSurface); + if (rhi) { + rhiSampleCount = rhiSupport->chooseSampleCountForWindowWithRhi(window, rhi); + if (rhiSupport->isProfilingRequested()) + QSGRhiProfileConnection::instance()->initialize(rhi); // ### this breaks down with multiple windows + } else { + qWarning("Failed to create QRhi on the render thread; scenegraph is not functional"); + return; + } + } + if (!sgrc->rhi() && windowSize.width() > 0 && windowSize.height() > 0) { + rhi->makeThreadLocalNativeContextCurrent(); + QSGDefaultRenderContext::InitParams rcParams; + rcParams.rhi = rhi; + rcParams.sampleCount = rhiSampleCount; + rcParams.openGLContext = nullptr; + rcParams.initialSurfacePixelSize = windowSize * qreal(dpr); + rcParams.maybeSurface = window; + sgrc->initialize(&rcParams); + } + QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); + if (rhi && !cd->swapchain) { + cd->rhi = rhi; + QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab + // QQ is always premul alpha. Decide based on alphaBufferSize in + // requestedFormat(). (the platform plugin can override format() but + // what matters here is what the application wanted, hence using the + // requested one) + const bool alpha = window->requestedFormat().alphaBufferSize() > 0; + if (alpha) + flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; + cd->swapchain = rhi->newSwapChain(); + cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, + QSize(), + rhiSampleCount, + QRhiRenderBuffer::UsedWithSwapChainOnly); + cd->swapchain->setWindow(window); + cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain); + qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s.", + rhiSampleCount, alpha ? "yes" : "no"); + cd->swapchain->setSampleCount(rhiSampleCount); + cd->swapchain->setFlags(flags); + cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor(); + cd->swapchain->setRenderPassDescriptor(cd->rpDescForSwapchain); + } +} + void QSGRenderThread::run() { qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "run()"); @@ -899,63 +979,20 @@ void QSGRenderThread::run() if (window) { if (enableRhi) { - if (!rhi) { - QSGRhiSupport *rhiSupport = QSGRhiSupport::instance(); - rhi = rhiSupport->createRhi(window, offscreenSurface); - if (rhi) { - rhiSampleCount = rhiSupport->chooseSampleCountForWindowWithRhi(window, rhi); - if (rhiSupport->isProfilingRequested()) - QSGRhiProfileConnection::instance()->initialize(rhi); // ### this breaks down with multiple windows - } else { - qWarning("Failed to create QRhi on the render thread; scenegraph is not functional"); - } - } - if (!sgrc->rhi() && windowSize.width() > 0 && windowSize.height() > 0) { - rhi->makeThreadLocalNativeContextCurrent(); - QSGDefaultRenderContext::InitParams rcParams; - rcParams.rhi = rhi; - rcParams.sampleCount = rhiSampleCount; - rcParams.openGLContext = gl; - rcParams.initialSurfacePixelSize = windowSize * dpr; - rcParams.maybeSurface = window; - sgrc->initialize(&rcParams); - } - QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); - if (rhi && !cd->swapchain) { - cd->rhi = rhi; - QRhiSwapChain::Flags flags = QRhiSwapChain::UsedAsTransferSource; // may be used in a grab - // QQ is always premul alpha. Decide based on alphaBufferSize in - // requestedFormat(). (the platform plugin can override format() but - // what matters here is what the application wanted, hence using the - // requested one) - const bool alpha = window->requestedFormat().alphaBufferSize() > 0; - if (alpha) - flags |= QRhiSwapChain::SurfaceHasPreMulAlpha; - cd->swapchain = rhi->newSwapChain(); - cd->depthStencilForSwapchain = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, - QSize(), - rhiSampleCount, - QRhiRenderBuffer::UsedWithSwapChainOnly); - cd->swapchain->setWindow(window); - cd->swapchain->setDepthStencil(cd->depthStencilForSwapchain); - qCDebug(QSG_LOG_INFO, "MSAA sample count for the swapchain is %d. Alpha channel requested = %s.", - rhiSampleCount, alpha ? "yes" : "no"); - cd->swapchain->setSampleCount(rhiSampleCount); - cd->swapchain->setFlags(flags); - cd->rpDescForSwapchain = cd->swapchain->newCompatibleRenderPassDescriptor(); - cd->swapchain->setRenderPassDescriptor(cd->rpDescForSwapchain); - } + ensureRhi(); + if (rhi) + syncAndRender(); } else { if (!sgrc->openglContext() && windowSize.width() > 0 && windowSize.height() > 0 && gl->makeCurrent(window)) { QSGDefaultRenderContext::InitParams rcParams; rcParams.sampleCount = qMax(1, gl->format().samples()); rcParams.openGLContext = gl; - rcParams.initialSurfacePixelSize = windowSize * dpr; + rcParams.initialSurfacePixelSize = windowSize * qreal(dpr); rcParams.maybeSurface = window; sgrc->initialize(&rcParams); } + syncAndRender(); } - syncAndRender(); } processEvents(); @@ -1362,6 +1399,8 @@ void QSGThreadedRenderLoop::maybeUpdate(Window *w) return; QThread *current = QThread::currentThread(); + if (current == w->thread && w->thread->rhi && w->thread->rhi->isDeviceLost()) + return; if (current != QCoreApplication::instance()->thread() && (current != w->thread || !m_lockedForSync)) { qWarning() << "Updates can only be scheduled from GUI thread or from QQuickItem::updatePaintNode()"; return; -- cgit v1.2.3 From 67ce1dd81014836aa8b900fd039adfc7c63414b5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 7 Sep 2019 21:03:53 +0200 Subject: Add an env var to periodically kill the device on d3d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...in order to test the handling of losing the device. The D3D11 backend of QRhi provides a convenient way to test this. Hook it up to a QSG_RHI_SIMULATE_DEVICE_LOSS environment variable. The value is the number of frames to wait before breaking the ID3D11Device. We cannot currently recover from a device loss. Hence the importance of being able to test in a simple way. The rhi code path needs to be brought up to the level of the direct OpenGL path in this respect, in separate patches. Change-Id: I66d6315dc60a9673903da9bed36de0cdd115f4a7 Reviewed-by: Christian Strømme --- src/quick/scenegraph/qsgrhisupport.cpp | 8 ++++++++ src/quick/scenegraph/qsgrhisupport_p.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index e050938cc9..2c5d8fb2ac 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -178,6 +178,10 @@ void QSGRhiSupport::applySettings() m_shaderEffectDebug = qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG"); + m_killDeviceFrameCount = qEnvironmentVariableIntValue("QSG_RHI_SIMULATE_DEVICE_LOSS"); + if (m_killDeviceFrameCount > 0 && m_rhiBackend == QRhi::D3D11) + qDebug("Graphics device will be reset every %d frames", m_killDeviceFrameCount); + const char *backendName = "unknown"; switch (m_rhiBackend) { case QRhi::Null: @@ -489,6 +493,10 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf if (backend == QRhi::D3D11) { QRhiD3D11InitParams rhiParams; rhiParams.enableDebugLayer = isDebugLayerRequested(); + if (m_killDeviceFrameCount > 0) { + rhiParams.framesUntilKillingDeviceViaTdr = m_killDeviceFrameCount; + rhiParams.repeatDeviceKill = true; + } rhi = QRhi::create(backend, &rhiParams, flags); } #endif diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index f2d5837bba..536efa55c3 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -138,6 +138,7 @@ private: uint rhi : 1; } m_requested; QRhi::Implementation m_rhiBackend = QRhi::Null; + int m_killDeviceFrameCount; uint m_set : 1; uint m_enableRhi : 1; uint m_debugLayer : 1; -- cgit v1.2.3 From 5c7e326802725a32a2426a4c1a07225c28da9af3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 16 Sep 2019 17:44:16 +0200 Subject: Change const ref to ref in QSGMaterialRhiShader as per API review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7783ed26a66f03ebe3b26bcba2f42f9fff45a417 Reviewed-by: Lars Knoll Reviewed-by: Christian Strømme --- src/particles/qquickimageparticle.cpp | 20 +++++------ src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 13 ++++--- src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 4 +-- .../scenegraph/coreapi/qsgmaterialrhishader.cpp | 40 +++++++++++----------- .../scenegraph/coreapi/qsgmaterialrhishader.h | 12 +++---- src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 28 +++++++-------- .../scenegraph/qsgdefaultinternalimagenode.cpp | 4 +-- .../scenegraph/qsgdefaultinternalrectanglenode.cpp | 4 +-- src/quick/scenegraph/qsgdefaultspritenode.cpp | 8 ++--- .../scenegraph/qsgdistancefieldglyphnode_p.cpp | 28 +++++++-------- src/quick/scenegraph/qsgrhishadereffectnode.cpp | 12 +++---- src/quick/scenegraph/util/qsgflatcolormaterial.cpp | 4 +-- src/quick/scenegraph/util/qsgtexturematerial.cpp | 6 ++-- src/quick/scenegraph/util/qsgtexturematerial_p.h | 6 ++-- .../scenegraph/util/qsgvertexcolormaterial.cpp | 4 +-- src/quickshapes/qquickshapegenericrenderer.cpp | 12 +++---- src/quickshapes/qquickshapegenericrenderer_p.h | 12 +++---- 17 files changed, 110 insertions(+), 107 deletions(-) diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index 649fbb30c2..bd3865f42f 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -179,7 +179,7 @@ public: setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_tabled.frag.qsb")); } - bool updateUniformData(const RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override + bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override { QByteArray *buf = renderState.uniformData(); Q_ASSERT(buf->size() >= 80 + 2 * (UNIFORM_ARRAY_SIZE * 4 * 4)); @@ -216,7 +216,7 @@ public: return true; } - void updateSampledImage(const RenderState &renderState, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &renderState, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) override { ImageMaterialData *state = static_cast(newMaterial)->state(); @@ -331,7 +331,7 @@ public: setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_deformed.frag.qsb")); } - bool updateUniformData(const RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override + bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override { QByteArray *buf = renderState.uniformData(); Q_ASSERT(buf->size() >= 80 + 2 * (UNIFORM_ARRAY_SIZE * 4 * 4)); @@ -357,7 +357,7 @@ public: return true; } - void updateSampledImage(const RenderState &renderState, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &renderState, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) override { ImageMaterialData *state = static_cast(newMaterial)->state(); @@ -487,7 +487,7 @@ public: setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_sprite.frag.qsb")); } - bool updateUniformData(const RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override + bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override { QByteArray *buf = renderState.uniformData(); Q_ASSERT(buf->size() >= 80 + 2 * (UNIFORM_ARRAY_SIZE * 4 * 4)); @@ -524,7 +524,7 @@ public: return true; } - void updateSampledImage(const RenderState &renderState, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &renderState, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) override { ImageMaterialData *state = static_cast(newMaterial)->state(); @@ -651,7 +651,7 @@ public: setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_colored.frag.qsb")); } - bool updateUniformData(const RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override + bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override { QByteArray *buf = renderState.uniformData(); Q_ASSERT(buf->size() >= 80 + 2 * (UNIFORM_ARRAY_SIZE * 4 * 4)); @@ -677,7 +677,7 @@ public: return true; } - void updateSampledImage(const RenderState &renderState, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &renderState, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) override { ImageMaterialData *state = static_cast(newMaterial)->state(); @@ -799,7 +799,7 @@ public: setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_simple.frag.qsb")); } - bool updateUniformData(const RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override + bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override { QByteArray *buf = renderState.uniformData(); Q_ASSERT(buf->size() >= 80 + 2 * (UNIFORM_ARRAY_SIZE * 4 * 4)); @@ -825,7 +825,7 @@ public: return true; } - void updateSampledImage(const RenderState &renderState, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &renderState, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) override { ImageMaterialData *state = static_cast(newMaterial)->state(); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index c7bc3d6abc..37deaa35dd 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -3426,7 +3426,7 @@ static void materialToRendererGraphicsState(GraphicsState *dst, } void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms, - const QSGMaterialRhiShader::RenderState &renderState, + QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, QVector *bindings, const Batch *batch, @@ -3440,6 +3440,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms, if (pd->ubufBinding >= 0) { m_current_uniform_data = &pd->masterUniformData; const bool changed = shader->updateUniformData(renderState, material, m_currentMaterial); + m_current_uniform_data = nullptr; if (changed || !batch->ubufDataValid) m_resourceUpdates->updateDynamicBuffer(batch->ubuf, ubufOffset, ubufRegionSize, pd->masterUniformData.constData()); @@ -3516,7 +3517,7 @@ void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms, } void Renderer::updateMaterialStaticData(ShaderManager::Shader *sms, - const QSGMaterialRhiShader::RenderState &renderState, + QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, Batch *batch, bool *gstateChanged) // RHI only, [prepare step] @@ -3624,7 +3625,7 @@ bool Renderer::prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *rende } } - const QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))); + QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))); bool pendingGStatePop = false; updateMaterialStaticData(sms, renderState, material, batch, &pendingGStatePop); @@ -3801,8 +3802,9 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren } } + QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))); bool pendingGStatePop = false; - updateMaterialStaticData(sms, rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))), + updateMaterialStaticData(sms, renderState, material, batch, &pendingGStatePop); int ubufOffset = 0; @@ -3821,8 +3823,9 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren m_current_projection_matrix(2, 3) = 1.0f - e->order * m_zRange; } + QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))); QVector bindings; - updateMaterialDynamicData(sms, rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))), + updateMaterialDynamicData(sms, renderState, material, &bindings, batch, ubufOffset, ubufSize); #ifndef QT_NO_DEBUG diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 4e374522d4..5390e14c77 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -796,10 +796,10 @@ private: void renderBatches(); bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms); QRhiTexture *dummyTexture(); - void updateMaterialDynamicData(ShaderManager::Shader *sms, const QSGMaterialRhiShader::RenderState &renderState, + void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, QVector *bindings, const Batch *batch, int ubufOffset, int ubufRegionSize); - void updateMaterialStaticData(ShaderManager::Shader *sms, const QSGMaterialRhiShader::RenderState &renderState, + void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, Batch *batch, bool *gstateChanged); void checkLineWidth(QSGGeometry *g); bool prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *renderBatch); diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp index e3cd0f554e..117d477f9a 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp +++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.cpp @@ -301,9 +301,9 @@ void QSGMaterialRhiShader::setFlag(Flags flags, bool on) memcpy calls) when updating material states. When \a oldMaterial is null, this shader was just activated. */ -bool QSGMaterialRhiShader::updateUniformData(const RenderState &state, - QSGMaterial *newMaterial, - QSGMaterial *oldMaterial) +bool QSGMaterialRhiShader::updateUniformData(RenderState &state, + QSGMaterial *newMaterial, + QSGMaterial *oldMaterial) { Q_UNUSED(state); Q_UNUSED(newMaterial); @@ -334,11 +334,11 @@ bool QSGMaterialRhiShader::updateUniformData(const RenderState &state, \a oldMaterial can be used to minimize changes. When \a oldMaterial is null, this shader was just activated. */ -void QSGMaterialRhiShader::updateSampledImage(const RenderState &state, - int binding, - QSGTexture **texture, - QSGMaterial *newMaterial, - QSGMaterial *oldMaterial) +void QSGMaterialRhiShader::updateSampledImage(RenderState &state, + int binding, + QSGTexture **texture, + QSGMaterial *newMaterial, + QSGMaterial *oldMaterial) { Q_UNUSED(state); Q_UNUSED(binding); @@ -367,8 +367,8 @@ void QSGMaterialRhiShader::updateSampledImage(const RenderState &state, The subclass specific state can be extracted from \a newMaterial. When \a oldMaterial is null, this shader was just activated. */ -bool QSGMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, - QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +bool QSGMaterialRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, + QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(state); Q_UNUSED(ps); @@ -496,7 +496,7 @@ bool QSGMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, float QSGMaterialRhiShader::RenderState::opacity() const { Q_ASSERT(m_data); - return static_cast(m_data)->currentOpacity(); + return float(static_cast(m_data)->currentOpacity()); } /*! @@ -505,7 +505,7 @@ float QSGMaterialRhiShader::RenderState::opacity() const float QSGMaterialRhiShader::RenderState::determinant() const { Q_ASSERT(m_data); - return static_cast(m_data)->determinant(); + return float(static_cast(m_data)->determinant()); } /*! @@ -524,7 +524,7 @@ QMatrix4x4 QSGMaterialRhiShader::RenderState::combinedMatrix() const float QSGMaterialRhiShader::RenderState::devicePixelRatio() const { Q_ASSERT(m_data); - return static_cast(m_data)->devicePixelRatio(); + return float(static_cast(m_data)->devicePixelRatio()); } /*! @@ -576,7 +576,10 @@ QRect QSGMaterialRhiShader::RenderState::deviceRect() const /*! Returns a pointer to the data for the uniform (constant) buffer in the - shader. + shader. Uniform data must only be updated from + QSGMaterialRhiShader::updateUniformData(). The return value is null in the + other reimplementable functions, such as, + QSGMaterialRhiShader::updateSampledImage(). \note It is strongly recommended to declare the uniform block with \c std140 in the shader, and to carefully study the standard uniform block @@ -590,11 +593,8 @@ QRect QSGMaterialRhiShader::RenderState::deviceRect() const \note Avoid copying from C++ POD types, such as, structs, in order to update multiple members at once, unless it has been verified that the layouts of the C++ struct and the GLSL uniform block match. - - \note Uniform data must only be updated from - QSGMaterialRhiShader::updateUniformData(). */ -QByteArray *QSGMaterialRhiShader::RenderState::uniformData() const +QByteArray *QSGMaterialRhiShader::RenderState::uniformData() { Q_ASSERT(m_data); return static_cast(m_data)->currentUniformData(); @@ -606,7 +606,7 @@ QByteArray *QSGMaterialRhiShader::RenderState::uniformData() const QSGMaterialRhiShader::updateSampledImage() to enqueue texture image content updates. */ -QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch() const +QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch() { Q_ASSERT(m_data); return static_cast(m_data)->currentResourceUpdateBatch(); @@ -615,7 +615,7 @@ QRhiResourceUpdateBatch *QSGMaterialRhiShader::RenderState::resourceUpdateBatch( /*! Returns the current QRhi. */ -QRhi *QSGMaterialRhiShader::RenderState::rhi() const +QRhi *QSGMaterialRhiShader::RenderState::rhi() { Q_ASSERT(m_data); return static_cast(m_data)->currentRhi(); diff --git a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h index 01991135ec..86208516cd 100644 --- a/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h +++ b/src/quick/scenegraph/coreapi/qsgmaterialrhishader.h @@ -76,9 +76,9 @@ public: float determinant() const; float devicePixelRatio() const; - QByteArray *uniformData() const; - QRhiResourceUpdateBatch *resourceUpdateBatch() const; - QRhi *rhi() const; + QByteArray *uniformData(); + QRhiResourceUpdateBatch *resourceUpdateBatch(); + QRhi *rhi(); private: friend class QSGRenderer; @@ -146,13 +146,13 @@ public: QSGMaterialRhiShader(); virtual ~QSGMaterialRhiShader(); - virtual bool updateUniformData(const RenderState &state, + virtual bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); - virtual void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + virtual void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); - virtual bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, + virtual bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial); Flags flags() const; diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 8fc8c711c6..4eba40b7a1 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -410,9 +410,9 @@ class QSGTextMaskRhiShader : public QSGMaterialRhiShader public: QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat); - bool updateUniformData(const RenderState &state, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; protected: @@ -428,7 +428,7 @@ QSGTextMaskRhiShader::QSGTextMaskRhiShader(QFontEngine::GlyphFormat glyphFormat) QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/textmask.frag.qsb")); } -bool QSGTextMaskRhiShader::updateUniformData(const RenderState &state, +bool QSGTextMaskRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type()); @@ -471,7 +471,7 @@ bool QSGTextMaskRhiShader::updateUniformData(const RenderState &state, return changed; } -void QSGTextMaskRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QSGTextMaskRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) { Q_UNUSED(state); @@ -498,10 +498,10 @@ public: QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/8bittextmask.frag.qsb")); } - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; -bool QSG8BitTextMaskRhiShader::updateUniformData(const RenderState &state, +bool QSG8BitTextMaskRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -532,8 +532,8 @@ public: QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/24bittextmask.frag.qsb")); } - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; @@ -544,7 +544,7 @@ public: // framebuffer update and blending always on... Could we do gamma correction in // the shader for text? (but that's bad for blending?) -bool QSG24BitTextMaskRhiShader::updateUniformData(const RenderState &state, +bool QSG24BitTextMaskRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -565,7 +565,7 @@ bool QSG24BitTextMaskRhiShader::updateUniformData(const RenderState &state, return changed; } -bool QSG24BitTextMaskRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, +bool QSG24BitTextMaskRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(state); @@ -596,10 +596,10 @@ public: QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/32bitcolortext.frag.qsb")); } - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; -bool QSG32BitColorTextRhiShader::updateUniformData(const RenderState &state, +bool QSG32BitColorTextRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSGTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -636,11 +636,11 @@ public: QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/styledtext.frag.qsb")); } - bool updateUniformData(const RenderState &state, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; -bool QSGStyledTextRhiShader::updateUniformData(const RenderState &state, +bool QSGStyledTextRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSG8BitTextMaskRhiShader::updateUniformData(state, newMaterial, oldMaterial); diff --git a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp index d1711f7524..500d4e6e95 100644 --- a/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp +++ b/src/quick/scenegraph/qsgdefaultinternalimagenode.cpp @@ -66,7 +66,7 @@ class SmoothTextureMaterialRhiShader : public QSGTextureMaterialRhiShader public: SmoothTextureMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; @@ -136,7 +136,7 @@ SmoothTextureMaterialRhiShader::SmoothTextureMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/smoothtexture.frag.qsb")); } -bool SmoothTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +bool SmoothTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = false; QByteArray *buf = state.uniformData(); diff --git a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp index 417b63dee3..5e4affbf90 100644 --- a/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp +++ b/src/quick/scenegraph/qsgdefaultinternalrectanglenode.cpp @@ -111,7 +111,7 @@ class SmoothColorMaterialRhiShader : public QSGMaterialRhiShader public: SmoothColorMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; SmoothColorMaterialRhiShader::SmoothColorMaterialRhiShader() @@ -120,7 +120,7 @@ SmoothColorMaterialRhiShader::SmoothColorMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/smoothcolor.frag.qsb")); } -bool SmoothColorMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *, QSGMaterial *oldMaterial) +bool SmoothColorMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *oldMaterial) { bool changed = false; QByteArray *buf = state.uniformData(); diff --git a/src/quick/scenegraph/qsgdefaultspritenode.cpp b/src/quick/scenegraph/qsgdefaultspritenode.cpp index 4d4d9f6971..6422a252d9 100644 --- a/src/quick/scenegraph/qsgdefaultspritenode.cpp +++ b/src/quick/scenegraph/qsgdefaultspritenode.cpp @@ -141,9 +141,9 @@ class SpriteMaterialRhiShader : public QSGMaterialRhiShader public: SpriteMaterialRhiShader(); - bool updateUniformData(const RenderState &state, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; @@ -153,7 +153,7 @@ SpriteMaterialRhiShader::SpriteMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/sprite.frag.qsb")); } -bool SpriteMaterialRhiShader::updateUniformData(const RenderState &state, +bool SpriteMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { #ifdef QT_NO_DEBUG @@ -186,7 +186,7 @@ bool SpriteMaterialRhiShader::updateUniformData(const RenderState &state, return changed; } -void SpriteMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void SpriteMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { if (binding != 1) diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index 9121363159..e8e9f76d04 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -212,10 +212,10 @@ class QSGDistanceFieldTextMaterialRhiShader : public QSGMaterialRhiShader public: QSGDistanceFieldTextMaterialRhiShader(bool alphaTexture); - bool updateUniformData(const RenderState &state, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; protected: @@ -235,7 +235,7 @@ QSGDistanceFieldTextMaterialRhiShader::QSGDistanceFieldTextMaterialRhiShader(boo QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldtext.frag.qsb")); } -bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState &state, +bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type()); @@ -291,7 +291,7 @@ bool QSGDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState return changed; } -void QSGDistanceFieldTextMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QSGDistanceFieldTextMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) { Q_UNUSED(state); @@ -432,7 +432,7 @@ class DistanceFieldStyledTextMaterialRhiShader : public QSGDistanceFieldTextMate public: DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; DistanceFieldStyledTextMaterialRhiShader::DistanceFieldStyledTextMaterialRhiShader(bool alphaTexture) @@ -440,7 +440,7 @@ DistanceFieldStyledTextMaterialRhiShader::DistanceFieldStyledTextMaterialRhiShad { } -bool DistanceFieldStyledTextMaterialRhiShader::updateUniformData(const RenderState &state, +bool DistanceFieldStyledTextMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSGDistanceFieldTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -548,7 +548,7 @@ class DistanceFieldOutlineTextMaterialRhiShader : public DistanceFieldStyledText public: DistanceFieldOutlineTextMaterialRhiShader(bool alphaTexture); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; DistanceFieldOutlineTextMaterialRhiShader::DistanceFieldOutlineTextMaterialRhiShader(bool alphaTexture) @@ -564,7 +564,7 @@ DistanceFieldOutlineTextMaterialRhiShader::DistanceFieldOutlineTextMaterialRhiSh QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldoutlinetext.frag.qsb")); } -bool DistanceFieldOutlineTextMaterialRhiShader::updateUniformData(const RenderState &state, +bool DistanceFieldOutlineTextMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = DistanceFieldStyledTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -670,7 +670,7 @@ class DistanceFieldShiftedStyleTextMaterialRhiShader : public DistanceFieldStyle public: DistanceFieldShiftedStyleTextMaterialRhiShader(bool alphaTexture); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; DistanceFieldShiftedStyleTextMaterialRhiShader::DistanceFieldShiftedStyleTextMaterialRhiShader(bool alphaTexture) @@ -686,7 +686,7 @@ DistanceFieldShiftedStyleTextMaterialRhiShader::DistanceFieldShiftedStyleTextMat QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/distancefieldshiftedtext.frag.qsb")); } -bool DistanceFieldShiftedStyleTextMaterialRhiShader::updateUniformData(const RenderState &state, +bool DistanceFieldShiftedStyleTextMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = DistanceFieldStyledTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -809,8 +809,8 @@ class QSGHiQSubPixelDistanceFieldTextMaterialRhiShader : public QSGDistanceField public: QSGHiQSubPixelDistanceFieldTextMaterialRhiShader(bool alphaTexture); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; @@ -829,7 +829,7 @@ QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::QSGHiQSubPixelDistanceFieldTex QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/hiqsubpixeldistancefieldtext.frag.qsb")); } -bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(const RenderState &state, +bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = QSGDistanceFieldTextMaterialRhiShader::updateUniformData(state, newMaterial, oldMaterial); @@ -855,7 +855,7 @@ bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateUniformData(const R return changed; } -bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, +bool QSGHiQSubPixelDistanceFieldTextMaterialRhiShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(state); diff --git a/src/quick/scenegraph/qsgrhishadereffectnode.cpp b/src/quick/scenegraph/qsgrhishadereffectnode.cpp index fe9cecb51b..6f6544548c 100644 --- a/src/quick/scenegraph/qsgrhishadereffectnode.cpp +++ b/src/quick/scenegraph/qsgrhishadereffectnode.cpp @@ -211,9 +211,9 @@ class QSGRhiShaderEffectMaterialShader : public QSGMaterialRhiShader public: QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - bool updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; QSGRhiShaderEffectMaterialShader::QSGRhiShaderEffectMaterialShader(const QSGRhiShaderEffectMaterial *material) @@ -228,7 +228,7 @@ static inline QColor qsg_premultiply_color(const QColor &c) return QColor::fromRgbF(c.redF() * c.alphaF(), c.greenF() * c.alphaF(), c.blueF() * c.alphaF(), c.alphaF()); } -bool QSGRhiShaderEffectMaterialShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +bool QSGRhiShaderEffectMaterialShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(oldMaterial); QSGRhiShaderEffectMaterial *mat = static_cast(newMaterial); @@ -381,7 +381,7 @@ bool QSGRhiShaderEffectMaterialShader::updateUniformData(const RenderState &stat return changed; } -void QSGRhiShaderEffectMaterialShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QSGRhiShaderEffectMaterialShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(oldMaterial); @@ -426,7 +426,7 @@ void QSGRhiShaderEffectMaterialShader::updateSampledImage(const RenderState &sta *texture = mat->m_dummyTexture; } -bool QSGRhiShaderEffectMaterialShader::updateGraphicsPipelineState(const RenderState &state, GraphicsPipelineState *ps, +bool QSGRhiShaderEffectMaterialShader::updateGraphicsPipelineState(RenderState &state, GraphicsPipelineState *ps, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_UNUSED(state); diff --git a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp index f121d2a9e2..87941bf31a 100644 --- a/src/quick/scenegraph/util/qsgflatcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgflatcolormaterial.cpp @@ -121,7 +121,7 @@ class FlatColorMaterialRhiShader : public QSGMaterialRhiShader public: FlatColorMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; FlatColorMaterialRhiShader::FlatColorMaterialRhiShader() @@ -130,7 +130,7 @@ FlatColorMaterialRhiShader::FlatColorMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/flatcolor.frag.qsb")); } -bool FlatColorMaterialRhiShader::updateUniformData(const RenderState &state, +bool FlatColorMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { diff --git a/src/quick/scenegraph/util/qsgtexturematerial.cpp b/src/quick/scenegraph/util/qsgtexturematerial.cpp index df4e5cfde2..67b8748119 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial.cpp +++ b/src/quick/scenegraph/util/qsgtexturematerial.cpp @@ -125,7 +125,7 @@ QSGOpaqueTextureMaterialRhiShader::QSGOpaqueTextureMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/opaquetexture.frag.qsb")); } -bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *, QSGMaterial *) +bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) { bool changed = false; QByteArray *buf = state.uniformData(); @@ -139,7 +139,7 @@ bool QSGOpaqueTextureMaterialRhiShader::updateUniformData(const RenderState &sta return changed; } -void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QSGOpaqueTextureMaterialRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { if (binding != 1) @@ -473,7 +473,7 @@ QSGTextureMaterialRhiShader::QSGTextureMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/texture.frag.qsb")); } -bool QSGTextureMaterialRhiShader::updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) +bool QSGTextureMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { bool changed = false; QByteArray *buf = state.uniformData(); diff --git a/src/quick/scenegraph/util/qsgtexturematerial_p.h b/src/quick/scenegraph/util/qsgtexturematerial_p.h index 7ef17af526..d1ef7d1d7f 100644 --- a/src/quick/scenegraph/util/qsgtexturematerial_p.h +++ b/src/quick/scenegraph/util/qsgtexturematerial_p.h @@ -75,8 +75,8 @@ class Q_QUICK_PRIVATE_EXPORT QSGOpaqueTextureMaterialRhiShader : public QSGMater public: QSGOpaqueTextureMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; class QSGTextureMaterialShader : public QSGOpaqueTextureMaterialShader @@ -96,7 +96,7 @@ class QSGTextureMaterialRhiShader : public QSGOpaqueTextureMaterialRhiShader public: QSGTextureMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp index 23f57141a6..c27dd7d1f0 100644 --- a/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/quick/scenegraph/util/qsgvertexcolormaterial.cpp @@ -100,7 +100,7 @@ class QSGVertexColorMaterialRhiShader : public QSGMaterialRhiShader public: QSGVertexColorMaterialRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; + bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; }; QSGVertexColorMaterialRhiShader::QSGVertexColorMaterialRhiShader() @@ -109,7 +109,7 @@ QSGVertexColorMaterialRhiShader::QSGVertexColorMaterialRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/scenegraph/shaders_ng/vertexcolor.frag.qsb")); } -bool QSGVertexColorMaterialRhiShader::updateUniformData(const RenderState &state, +bool QSGVertexColorMaterialRhiShader::updateUniformData(RenderState &state, QSGMaterial * /*newEffect*/, QSGMaterial * /*oldEffect*/) { diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp index 6ddd055d85..06cc442fc7 100644 --- a/src/quickshapes/qquickshapegenericrenderer.cpp +++ b/src/quickshapes/qquickshapegenericrenderer.cpp @@ -795,7 +795,7 @@ QQuickShapeLinearGradientRhiShader::QQuickShapeLinearGradientRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/lineargradient.frag.qsb")); } -bool QQuickShapeLinearGradientRhiShader::updateUniformData(const RenderState &state, +bool QQuickShapeLinearGradientRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type()); @@ -834,7 +834,7 @@ bool QQuickShapeLinearGradientRhiShader::updateUniformData(const RenderState &st return changed; } -void QQuickShapeLinearGradientRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QQuickShapeLinearGradientRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) { if (binding != 1) @@ -968,7 +968,7 @@ QQuickShapeRadialGradientRhiShader::QQuickShapeRadialGradientRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/radialgradient.frag.qsb")); } -bool QQuickShapeRadialGradientRhiShader::updateUniformData(const RenderState &state, +bool QQuickShapeRadialGradientRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type()); @@ -1026,7 +1026,7 @@ bool QQuickShapeRadialGradientRhiShader::updateUniformData(const RenderState &st return changed; } -void QQuickShapeRadialGradientRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QQuickShapeRadialGradientRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) { if (binding != 1) @@ -1158,7 +1158,7 @@ QQuickShapeConicalGradientRhiShader::QQuickShapeConicalGradientRhiShader() setShaderFileName(FragmentStage, QStringLiteral(":/qt-project.org/shapes/shaders_ng/conicalgradient.frag.qsb")); } -bool QQuickShapeConicalGradientRhiShader::updateUniformData(const RenderState &state, +bool QQuickShapeConicalGradientRhiShader::updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) { Q_ASSERT(oldMaterial == nullptr || newMaterial->type() == oldMaterial->type()); @@ -1200,7 +1200,7 @@ bool QQuickShapeConicalGradientRhiShader::updateUniformData(const RenderState &s return changed; } -void QQuickShapeConicalGradientRhiShader::updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, +void QQuickShapeConicalGradientRhiShader::updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *) { if (binding != 1) diff --git a/src/quickshapes/qquickshapegenericrenderer_p.h b/src/quickshapes/qquickshapegenericrenderer_p.h index 3398159bf6..4590c662c1 100644 --- a/src/quickshapes/qquickshapegenericrenderer_p.h +++ b/src/quickshapes/qquickshapegenericrenderer_p.h @@ -267,9 +267,9 @@ class QQuickShapeLinearGradientRhiShader : public QSGMaterialRhiShader public: QQuickShapeLinearGradientRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; private: @@ -328,9 +328,9 @@ class QQuickShapeRadialGradientRhiShader : public QSGMaterialRhiShader public: QQuickShapeRadialGradientRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; private: @@ -384,9 +384,9 @@ class QQuickShapeConicalGradientRhiShader : public QSGMaterialRhiShader public: QQuickShapeConicalGradientRhiShader(); - bool updateUniformData(const RenderState &state, QSGMaterial *newMaterial, + bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; - void updateSampledImage(const RenderState &state, int binding, QSGTexture **texture, + void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; private: -- cgit v1.2.3 From e2df4233a77ce8a37d2c8ef26b7b42fc0d33a24b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 5 Sep 2019 13:57:19 +0200 Subject: PathView: grab mouse on press if already moving A side effect of 8fd398c9d2f5f54e446e0b402bc63a2edb50da6f is that it became possible for the highlight to stop between items, rather than snapping to a specific item, if the user taps, clicks or drags an additional time while the movement is ongoing. That was because it didn't get a mouse grab, so it missed the release event. QQuickPathViewPrivate::handleMouseReleaseEvent() needs to take care of the snapping behavior after the user stops dragging. This only affects behavior in the case that the PathView is already moving and the mouse is pressed again: we assume the user wants to alter the PathView's velocity, not interact with any delegate inside or with any parent item. Task-number: QTBUG-77173 Task-number: QTBUG-59620 Change-Id: I7b2f69a6ef8d8022d7c917a5bf9e8fb40c8848db Reviewed-by: Mitch Curtis --- src/quick/items/qquickpathview.cpp | 7 +- tests/auto/qml/ecmascripttests/test262 | 2 +- .../quick/qquickpathview/data/nestedmousearea2.qml | 101 +++++++++++++++++++++ .../quick/qquickpathview/tst_qquickpathview.cpp | 27 ++++++ 4 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 tests/auto/quick/qquickpathview/data/nestedmousearea2.qml diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 01b16cf41f..6976665134 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -1683,11 +1683,12 @@ void QQuickPathViewPrivate::handleMousePressEvent(QMouseEvent *event) return; } - - if (tl.isActive() && flicking && flickDuration && qreal(tl.time())/flickDuration < 0.8) + if (tl.isActive() && flicking && flickDuration && qreal(tl.time()) / flickDuration < 0.8) { stealMouse = true; // If we've been flicked then steal the click. - else + q->grabMouse(); // grab it right now too, just to be sure (QTBUG-77173) + } else { stealMouse = false; + } q->setKeepMouseGrab(stealMouse); timer.start(); diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 index 3c69133cc4..6b0c42c63c 160000 --- a/tests/auto/qml/ecmascripttests/test262 +++ b/tests/auto/qml/ecmascripttests/test262 @@ -1 +1 @@ -Subproject commit 3c69133cc419840c1be34638039cd8c48a7ef581 +Subproject commit 6b0c42c63c2492bd0a7a96d3179d122b5f71793f diff --git a/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml b/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml new file mode 100644 index 0000000000..ff11002552 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +PathView { + id: view + width: 400; height: 240 + highlight: Rectangle { width: 80; height: 80; color: "lightsteelblue" } + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + model: ListModel { + id: appModel + ListElement { name: "Music" } + ListElement { name: "Movies" } + ListElement { name: "Camera" } + ListElement { name: "Calendar" } + ListElement { name: "Messaging" } + ListElement { name: "Todo List" } + ListElement { name: "Contacts" } + } + delegate: Rectangle { + width: 100; height: 100 + scale: PathView.iconScale + border.color: "lightgrey" + color: "transparent" + Text { + anchors { horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + color: ma.pressed ? "red" : "black" + } + + MouseArea { + id: ma + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "iconScale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "iconScale"; value: 0.5 } + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + y: 20 + text: view.currentIndex + " @ " + offset.toFixed(2) + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 8b963117ed..8a1ab40475 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -120,6 +120,7 @@ private slots: void undefinedPath(); void mouseDrag(); void nestedMouseAreaDrag(); + void flickNClick(); void treeModel(); void changePreferredHighlight(); void missingPercent(); @@ -1601,6 +1602,32 @@ void tst_QQuickPathView::nestedMouseAreaDrag() QVERIFY(pathview->isMoving()); } +void tst_QQuickPathView::flickNClick() // QTBUG-77173 +{ + QScopedPointer window(createView()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->setSource(testFileUrl("nestedmousearea2.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); + + QQuickPathView *pathview = qobject_cast(window->rootObject()); + QVERIFY(pathview != nullptr); + + for (int duration = 100; duration > 0; duration -= 20) { + // Dragging the child mouse area should animate the PathView (MA has no drag target) + flick(window.data(), QPoint(200,200), QPoint(400,200), duration); + QVERIFY(pathview->isMoving()); + + // Now while it's still moving, click it. + // The PathView should stop at a position such that offset is a whole number. + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(200, 200)); + QTRY_VERIFY(!pathview->isMoving()); + QVERIFY(qFuzzyIsNull(pathview->offset() - int(pathview->offset()))); + } +} + void tst_QQuickPathView::treeModel() { QScopedPointer window(createView()); -- cgit v1.2.3 From 8f1857f907153c4a98c73d572ea76c2b7ca33b5d Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Thu, 19 Sep 2019 18:04:55 +0800 Subject: QQuickMouseArea: fix containsMouse when mousearea become visible If enabled is false, then containsMouse will not become true when hovering on mousearea, even if hoverEnabled is true. However when an invisible mousearea become visible, the value of enabled isn't checked. In this case, the value of containsMouse is not affected by enabled. [ChangeLog][QtQuick][QQuickMouseArea] containsMouse property will not become true when the an invisible mousearea become visible, if the enabled property is false or its parent item is not enabled Fixes: QTBUG-77983 Change-Id: I923bdcf3eda813aea51a04515d530093d6eb77b2 Reviewed-by: Shawn Rutledge --- src/quick/items/qquickmousearea.cpp | 2 +- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp index a0c46d0bc6..ddf34798d7 100644 --- a/src/quick/items/qquickmousearea.cpp +++ b/src/quick/items/qquickmousearea.cpp @@ -1069,7 +1069,7 @@ void QQuickMouseArea::itemChange(ItemChange change, const ItemChangeData &value) Q_D(QQuickMouseArea); switch (change) { case ItemVisibleHasChanged: - if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) { + if (d->effectiveEnable && d->enabled && acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) { if (!d->hovered) { QPointF cursorPos = QGuiApplicationPrivate::lastCursorPosition; d->lastScenePos = d->window->mapFromGlobal(cursorPos.toPoint()); diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 5844720aa4..17553ee6c4 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -1359,6 +1359,34 @@ void tst_QQuickMouseArea::hoverVisible() QCOMPARE(enteredSpy.count(), 1); QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33)); + + // QTBUG-77983 + mouseTracker->setVisible(false); + mouseTracker->setEnabled(false); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the enabled property is false, the containsMouse property shouldn't become true + // when an invisible mousearea become visible + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(false); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the parent item is not enabled, the containsMouse property will be false, even if + // the mousearea is enabled + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(true); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + QCOMPARE(mouseTracker->hovered(), true); } void tst_QQuickMouseArea::hoverAfterPress() -- cgit v1.2.3 From a439a25f468d8c5623f2e0949b55a0c85c850f5f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 24 Sep 2019 09:11:04 +0200 Subject: Ensure AnimatedImage currentFrame/onCurrentFrameChanged 2.0 compatibility Change 5d995ae122aa07486ead849560b74d2b62b883bb did not make the actual QQuickImageBase::currentFrameChanged signal accessible to the Qt Quick 2.0 revision. Normally the QML engine would implement a JS onCurrentFrameChanged handler by connecting to the currentFrame property's frameChanged notifier signal; but in this case it tried to connect to the explicit QQuickImageBase::currentFrameChanged signal instead (because the name is a better match), and failed because of the revision. So we need another duplicate unrevisioned signal QQuickAnimatedImage::currentFrameChanged for use when the import is less than Qt Quick 2.14. As pointed out during review, an autotest for the revisioning is good to have anyway. Fixes: QTBUG-78713 Task-number: QTBUG-77506 Change-Id: I121508acac81d47e3c0a4c0ed12257c10b30970b Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- src/quick/items/qquickanimatedimage.cpp | 3 +- src/quick/items/qquickanimatedimage_p.h | 1 + .../qquickanimatedimage/data/currentframe.qml | 13 ++++++ .../tst_qquickanimatedimage.cpp | 46 ++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qquickanimatedimage/data/currentframe.qml diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp index bebefc1b22..18d492cd68 100644 --- a/src/quick/items/qquickanimatedimage.cpp +++ b/src/quick/items/qquickanimatedimage.cpp @@ -140,6 +140,7 @@ QQuickAnimatedImage::QQuickAnimatedImage(QQuickItem *parent) { connect(this, &QQuickImageBase::cacheChanged, this, &QQuickAnimatedImage::onCacheChanged); connect(this, &QQuickImageBase::currentFrameChanged, this, &QQuickAnimatedImage::frameChanged); + connect(this, &QQuickImageBase::currentFrameChanged, this, &QQuickAnimatedImage::currentFrameChanged); connect(this, &QQuickImageBase::frameCountChanged, this, &QQuickAnimatedImage::frameCountChanged); } @@ -466,7 +467,7 @@ void QQuickAnimatedImage::movieUpdate() if (d->movie) { d->setPixmap(*d->infoForCurrentFrame(qmlEngine(this))); - emit currentFrameChanged(); + emit QQuickImageBase::currentFrameChanged(); } } diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h index ef5af6b387..13eae83350 100644 --- a/src/quick/items/qquickanimatedimage_p.h +++ b/src/quick/items/qquickanimatedimage_p.h @@ -101,6 +101,7 @@ Q_SIGNALS: void playingChanged(); void pausedChanged(); void frameChanged(); + void currentFrameChanged(); void frameCountChanged(); Q_REVISION(11) void speedChanged(); diff --git a/tests/auto/quick/qquickanimatedimage/data/currentframe.qml b/tests/auto/quick/qquickanimatedimage/data/currentframe.qml new file mode 100644 index 0000000000..b679da2a99 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/currentframe.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +AnimatedImage { + property int currentFrameChangeCount: 0 + property int frameChangeCount: 0 + source: "stickman.gif" + onCurrentFrameChanged: if (currentFrame > 0) ++currentFrameChangeCount; + onFrameChanged: if (currentFrame > 0) ++frameChangeCount; + function scriptedSetCurrentFrame(frame) { + currentFrame = frame; + } +} + diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index 8026bafb9e..31c3fb9946 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include #include +#include #include #include #include @@ -40,6 +41,23 @@ Q_DECLARE_METATYPE(QQuickImageBase::Status) +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + QVariant result = expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result.value(); +} + +template <> void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); +} + class tst_qquickanimatedimage : public QQmlDataTest { Q_OBJECT @@ -68,6 +86,7 @@ private slots: void playingAndPausedChanges(); void noCaching(); void sourceChangesOnFrameChanged(); + void currentFrame(); }; void tst_qquickanimatedimage::cleanup() @@ -618,6 +637,33 @@ void tst_qquickanimatedimage::sourceChangesOnFrameChanged() qDeleteAll(images); } +void tst_qquickanimatedimage::currentFrame() +{ + QQuickView window; + window.setSource(testFileUrl("currentframe.qml")); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QQuickAnimatedImage *anim = qobject_cast(window.rootObject()); + QVERIFY(anim); + QSignalSpy frameChangedSpy(anim, SIGNAL(frameChanged())); + QSignalSpy currentFrameChangedSpy(anim, SIGNAL(currentFrameChanged())); + + anim->setCurrentFrame(1); + QCOMPARE(anim->currentFrame(), 1); + QCOMPARE(frameChangedSpy.count(), 1); + QCOMPARE(currentFrameChangedSpy.count(), 1); + QCOMPARE(anim->property("currentFrameChangeCount"), 1); + QCOMPARE(anim->property("frameChangeCount"), 1); + + evaluate(anim, "scriptedSetCurrentFrame(2)"); + QCOMPARE(anim->currentFrame(), 2); + QCOMPARE(frameChangedSpy.count(), 2); + QCOMPARE(currentFrameChangedSpy.count(), 2); + QCOMPARE(anim->property("currentFrameChangeCount"), 2); + QCOMPARE(anim->property("frameChangeCount"), 2); +} + QTEST_MAIN(tst_qquickanimatedimage) #include "tst_qquickanimatedimage.moc" -- cgit v1.2.3 From 7782a211d1c503d9634589e4ab837e6e53f343c0 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 16 Sep 2019 14:40:53 +0200 Subject: Add missing QSGDynamicTexture default constructor In 341ab7708049b1a3f559b76f16393e688951a938, an internal QSGDynamicTexture::QSGDynamicTexture(QSGTexturePrivate &dd) constructor was added, which means QSGDynamicTexture now doesn't have a (formerly implicit) default constructor anymore. Fixes: QTBUG-78312 Change-Id: I34a918942d87ca522aa7131580b9e08a1445d635 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgtexture.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/quick/scenegraph/coreapi/qsgtexture.h b/src/quick/scenegraph/coreapi/qsgtexture.h index 4cd2a5cddd..2efdd8b7c3 100644 --- a/src/quick/scenegraph/coreapi/qsgtexture.h +++ b/src/quick/scenegraph/coreapi/qsgtexture.h @@ -141,6 +141,7 @@ class Q_QUICK_EXPORT QSGDynamicTexture : public QSGTexture Q_OBJECT public: + QSGDynamicTexture() = default; virtual bool updateTexture() = 0; protected: -- cgit v1.2.3 From ae346195efaca5d01b67c5df1209512c7edaddb0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 12 Sep 2019 20:44:43 +0200 Subject: Handle "interesting" stationary touchpoints as if they moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt Quick will not receive "uninteresting" stationary touchpoints, but only those in which some property has changed. So MultiPointTouchArea should react to stationary touchpoints in the same way as if they moved, so that UIs can react to changes in touchpoint velocity, pressure etc. And QQuickWindow has to be willing to delivery stationary touchpoints to make this possible. However when a QTouchEvent is customized for delivery to a specific Item, by including only the touchpoints that are inside the Item, then if those touchpoints are all stationary, the event only needs to be delivered if at least one of them is an "interesting" stationary touchpoint. So we need to depend on a new per-touchpoint flag that QGuiApplication will set when it discovers that some property of the touchpoint has changed. That is QTouchEventTouchPointPrivate::stationaryWithModifiedProperty. Fixes: QTBUG-77142 Change-Id: I763d56ff55c048b258dca40d88283ed016447c35 Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickevents.cpp | 7 +++- src/quick/items/qquickmultipointtoucharea.cpp | 4 ++- .../tst_qquickmultipointtoucharea.cpp | 37 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 161ef17e1f..f9a8c77a7f 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -1828,6 +1829,7 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i // but that would require changing tst_qquickwindow::touchEvent_velocity(): it expects transformed velocity bool anyPressOrReleaseInside = false; + bool anyStationaryWithModifiedPropertyInside = false; bool anyGrabber = false; QMatrix4x4 transformMatrix(QQuickItemPrivate::get(item)->windowToItemTransform()); for (int i = 0; i < m_pointCount; ++i) { @@ -1860,6 +1862,8 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i anyPressOrReleaseInside = true; const QTouchEvent::TouchPoint *tp = touchPointById(p->pointId()); if (tp) { + if (isInside && tp->d->stationaryWithModifiedProperty) + anyStationaryWithModifiedPropertyInside = true; eventStates |= tp->state(); QTouchEvent::TouchPoint tpCopy = *tp; tpCopy.setPos(item->mapFromScene(tpCopy.scenePos())); @@ -1873,7 +1877,8 @@ QTouchEvent *QQuickPointerTouchEvent::touchEventForItem(QQuickItem *item, bool i // Now touchPoints will have only points which are inside the item. // But if none of them were just pressed inside, and the item has no other reason to care, ignore them anyway. - if (eventStates == Qt::TouchPointStationary || touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering)) + if ((eventStates == Qt::TouchPointStationary && !anyStationaryWithModifiedPropertyInside) || + touchPoints.isEmpty() || (!anyPressOrReleaseInside && !anyGrabber && !isFiltering)) return nullptr; // if all points have the same state, set the event type accordingly diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp index 70426a6a8c..b02e58fae4 100644 --- a/src/quick/items/qquickmultipointtoucharea.cpp +++ b/src/quick/items/qquickmultipointtoucharea.cpp @@ -40,6 +40,7 @@ #include "qquickmultipointtoucharea_p.h" #include #include +#include #include #include #include @@ -655,7 +656,8 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event) // (we may have just obtained enough points to start tracking them -- in that case moved or stationary count as newly pressed) addTouchPoint(&p); started = true; - } else if (touchPointState & Qt::TouchPointMoved) { + } else if ((touchPointState & Qt::TouchPointMoved) || p.d->stationaryWithModifiedProperty) { + // React to a stationary point with a property change (velocity, pressure) as if the point moved. (QTBUG-77142) QQuickTouchPoint* dtp = static_cast(_touchPoints.value(id)); Q_ASSERT(dtp); _movedTouchPoints.append(dtp); diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index cd66fc4ede..e96b892b54 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -72,6 +72,7 @@ private slots: void mouseGestureStarted_data(); void mouseGestureStarted(); void cancel(); + void stationaryTouchWithChangingPressure(); private: QQuickView *createAndShowView(const QString &file); @@ -1305,6 +1306,42 @@ void tst_QQuickMultiPointTouchArea::cancel() } +void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTBUG-77142 +{ + QScopedPointer window(createAndShowView("basic.qml")); + QVERIFY(window->rootObject() != nullptr); + + QQuickTouchPoint *point1 = window->rootObject()->findChild("point1"); + QCOMPARE(point1->pressed(), false); + + QPoint p1(20,100); + QTouchEvent::TouchPoint tp1(1); + + tp1.setScreenPos(window->mapToGlobal(p1)); + tp1.setState(Qt::TouchPointPressed); + tp1.setPressure(0.5); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressed(), true); + QCOMPARE(point1->pressure(), 0.5); + + tp1.setState(Qt::TouchPointStationary); + tp1.setPressure(0.6); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressure(), 0.6); + + tp1.setState(Qt::TouchPointReleased); + tp1.setPressure(0); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressed(), false); + QCOMPARE(point1->pressure(), 0); +} + QTEST_MAIN(tst_QQuickMultiPointTouchArea) -- cgit v1.2.3 From bd7df60ac506226ab9f4eb6be3dcebf14253244a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Sep 2019 10:58:41 +0200 Subject: Move documentation for Instantiator and Package into QtQml.Models Change-Id: Ie086399104de51ce0ae741f6fef316633ed47aa9 Reviewed-by: Martin Smith --- src/qmlmodels/qqmlinstantiator.cpp | 5 ++++- src/qmlmodels/qquickpackage.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qmlmodels/qqmlinstantiator.cpp b/src/qmlmodels/qqmlinstantiator.cpp index af1b526e1d..f9d5762f6e 100644 --- a/src/qmlmodels/qqmlinstantiator.cpp +++ b/src/qmlmodels/qqmlinstantiator.cpp @@ -220,7 +220,8 @@ void QQmlInstantiatorPrivate::makeModel() /*! \qmltype Instantiator \instantiates QQmlInstantiator - \inqmlmodule QtQml + \inqmlmodule QtQml.Models + \ingroup qtquick-models \brief Dynamically creates objects. A Instantiator can be used to control the dynamic creation of objects, or to dynamically @@ -231,6 +232,8 @@ void QQmlInstantiatorPrivate::makeModel() can also be destroyed dynamically through other means, and the Instantiator will not recreate them unless the properties of the Instantiator change. + \note Instantiator is part of QtQml.Models since version 2.14 and part of QtQml since + version 2.1. Importing Instantiator via QtQml is deprecated since Qt 5.14. */ QQmlInstantiator::QQmlInstantiator(QObject *parent) : QObject(*(new QQmlInstantiatorPrivate), parent) diff --git a/src/qmlmodels/qquickpackage.cpp b/src/qmlmodels/qquickpackage.cpp index 03539d8737..567381e5ab 100644 --- a/src/qmlmodels/qquickpackage.cpp +++ b/src/qmlmodels/qquickpackage.cpp @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE /*! \qmltype Package \instantiates QQuickPackage - \inqmlmodule QtQuick - \ingroup qtquick-views + \inqmlmodule QtQml.Models + \ingroup qtquick-models \brief Specifies a collection of named items. The Package type is used in conjunction with @@ -71,6 +71,9 @@ QT_BEGIN_NAMESPACE \snippet package/view.qml 0 + \note Package is part of QtQml.Models since version 2.14 and part of QtQuick since version 2.0. + Importing Package via QtQuick is deprecated since Qt 5.14. + \sa {Qt Quick Examples - Views}, {Qt Quick Demo - Photo Viewer}, {Qt QML} */ -- cgit v1.2.3 From c734eb3a8bda3b24721d80c380189c5e754a9b38 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 25 Sep 2019 13:49:10 +0200 Subject: qmlplugindump: fix prototypeNameForComposite We do not put the objects we encounter in defaultReachaleNames. Thus, the check in prototypeNameForComposite will fail most of the time. Instead, we now use the same check as in collectReachableMetaObjects (that is, does the type belong to the module). Then, we once again only collect the metaobjects belonging to the module in objectsToMerge, and only dump the relevant properties from there. Fixes: QTBUG-78744 Change-Id: I78cae1e56b6f59e277198f9bcd0d826c4e0978a7 Reviewed-by: Ulf Hermann --- tools/qmlplugindump/main.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index f0ed1f8ebe..4733a8f676 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -436,10 +436,11 @@ public: } QString getPrototypeNameForCompositeType(const QMetaObject *metaObject, QSet &defaultReachableNames, - QList *objectsToMerge) + QList *objectsToMerge, const QmlVersionInfo &versionInfo) { + auto ty = QQmlMetaType::qmlType(metaObject); QString prototypeName; - if (!defaultReachableNames.contains(metaObject->className())) { + if (matchingImportUri(ty, versionInfo)) { // dynamic meta objects can break things badly // but extended types are usually fine const QMetaObjectPrivate *mop = reinterpret_cast(metaObject->d.data); @@ -451,20 +452,20 @@ public: prototypeName = "QObject"; else prototypeName = getPrototypeNameForCompositeType( - superMetaObject, defaultReachableNames, objectsToMerge); + superMetaObject, defaultReachableNames, objectsToMerge, versionInfo); } else { prototypeName = convertToId(metaObject->className()); } return prototypeName; } - void dumpComposite(QQmlEngine *engine, const QSet &compositeType, QSet &defaultReachableNames) + void dumpComposite(QQmlEngine *engine, const QSet &compositeType, QSet &defaultReachableNames, const QmlVersionInfo &versionInfo) { for (const QQmlType &type : compositeType) - dumpCompositeItem(engine, type, defaultReachableNames); + dumpCompositeItem(engine, type, defaultReachableNames, versionInfo); } - void dumpCompositeItem(QQmlEngine *engine, const QQmlType &compositeType, QSet &defaultReachableNames) + void dumpCompositeItem(QQmlEngine *engine, const QQmlType &compositeType, QSet &defaultReachableNames, const QmlVersionInfo &versionInfo) { QQmlComponent e(engine, compositeType.sourceUrl()); if (!e.isReady()) { @@ -486,7 +487,7 @@ public: KnownAttributes knownAttributes; // Get C++ base class name for the composite type QString prototypeName = getPrototypeNameForCompositeType(mainMeta, defaultReachableNames, - &objectsToMerge); + &objectsToMerge, versionInfo); qml->writeScriptBinding(QLatin1String("prototype"), enquote(prototypeName)); QString qmlTyName = compositeType.qmlTypeName(); @@ -1228,6 +1229,7 @@ int main(int argc, char *argv[]) QMap> compositeTypes; int majorVersion = qtQmlMajorVersion, minorVersion = qtQmlMinorVersion; + QmlVersionInfo info; if (action == Builtins) { QSet builtins = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, defaultCompositeTypes, {QLatin1String("Qt"), majorVersion, minorVersion}); Q_ASSERT(builtins.size() == 1); @@ -1289,8 +1291,8 @@ int main(int argc, char *argv[]) return EXIT_IMPORTERROR; } } - - QSet candidates = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, compositeTypes, {pluginImportUri, majorVersion, minorVersion}, defaultTypes); + info = {pluginImportUri, majorVersion, minorVersion}; + QSet candidates = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, compositeTypes, info, defaultTypes); for (QString iter: compositeTypes.keys()) { if (defaultCompositeTypes.contains(iter)) { @@ -1350,7 +1352,7 @@ int main(int argc, char *argv[]) QMap >::const_iterator iter = compositeTypes.constBegin(); for (; iter != compositeTypes.constEnd(); ++iter) - dumper.dumpComposite(&engine, iter.value(), defaultReachableNames); + dumper.dumpComposite(&engine, iter.value(), defaultReachableNames, info); // define QEasingCurve as an extension of QQmlEasingValueType, this way // properties using the QEasingCurve type get useful type information. -- cgit v1.2.3 From d9e7e24c6635a6cafaff681981ff0579d5313418 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Sep 2019 11:39:25 +0200 Subject: Don't leak resolved types of failed compilations If the compilation fails QQmlTypeCompiler::compile() returns nullptr. In that case, there is no ExecutableCompilationUnit to own the resolved types. Therefore, delete them. Change-Id: Ia8f4ef78438642cb064538c7266ca636ec7eb0c1 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypecompiler.cpp | 9 ++++----- src/qml/qml/qqmltypedata.cpp | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp index 9a6bd73326..bbeaf7be9a 100644 --- a/src/qml/qml/qqmltypecompiler.cpp +++ b/src/qml/qml/qqmltypecompiler.cpp @@ -158,6 +158,9 @@ QQmlRefPointer QQmlTypeCompiler::compile() QmlIR::QmlUnitGenerator qmlGenerator; qmlGenerator.generate(*document, dependencyHasher); + if (!errors.isEmpty()) + return nullptr; + QQmlRefPointer compilationUnit = QV4::ExecutableCompilationUnit::create(std::move( document->javaScriptCompilationUnit)); @@ -165,11 +168,7 @@ QQmlRefPointer QQmlTypeCompiler::compile() compilationUnit->resolvedTypes = *resolvedTypes; compilationUnit->propertyCaches = std::move(m_propertyCaches); Q_ASSERT(compilationUnit->propertyCaches.count() == static_cast(compilationUnit->objectCount())); - - if (errors.isEmpty()) - return compilationUnit; - else - return nullptr; + return compilationUnit; } void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description) diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index b9fbf40e96..5e85d7f692 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -614,6 +614,8 @@ void QQmlTypeData::compile(const QQmlRefPointer &typeNameCach QQmlTypeCompiler compiler(enginePrivate, this, m_document.data(), typeNameCache, resolvedTypeCache, dependencyHasher); m_compiledData = compiler.compile(); if (!m_compiledData) { + qDeleteAll(*resolvedTypeCache); + resolvedTypeCache->clear(); setError(compiler.compilationErrors()); return; } -- cgit v1.2.3 From a44cb389d3e59baaf0e3e85c682a49df7b90fad4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 25 Sep 2019 11:07:34 +0200 Subject: Don't leak references to QQmlTypePrivate Change-Id: I1cad0d8aa81b26a91e97a869f3c8539ae3cf1ad6 Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlmetatypedata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp index 5dc0083f54..41a7778da3 100644 --- a/src/qml/qml/qqmlmetatypedata.cpp +++ b/src/qml/qml/qqmlmetatypedata.cpp @@ -69,6 +69,7 @@ void QQmlMetaTypeData::registerType(QQmlTypePrivate *priv) if (!types.at(i).isValid()) { types[i] = QQmlType(priv); priv->index = i; + priv->release(); return; } } -- cgit v1.2.3 From 8af52c803b2d7d5084d51f48a827a12c4b348ce2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 26 Sep 2019 11:21:13 +0200 Subject: Loosen qmlplugindump's checking of URI and major version If not given a "--strict" argument, qmlplugindump will ignore the given major version and only check the URI as prefix, not as exact match. This is in line with what qmlplugindump did in version 5.13 and before. Fixes: QTBUG-78745 Change-Id: Ib2803d47e6cb60c797fec8dfaa628278307d4cd4 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- tools/qmlplugindump/main.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 4733a8f676..196d6e39e6 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -105,12 +105,18 @@ struct QmlVersionInfo QString pluginImportUri; int majorVersion; int minorVersion; + bool strict; }; static bool matchingImportUri(const QQmlType &ty, const QmlVersionInfo& versionInfo) { - return (versionInfo.pluginImportUri == ty.module() - && (ty.majorVersion() == versionInfo.majorVersion || ty.majorVersion() == -1)) - || ty.module().isEmpty(); + if (versionInfo.strict) { + return (versionInfo.pluginImportUri == ty.module() + && (ty.majorVersion() == versionInfo.majorVersion || ty.majorVersion() == -1)) + || ty.module().isEmpty(); + } + return ty.module().isEmpty() + || versionInfo.pluginImportUri == ty.module() + || ty.module().startsWith(versionInfo.pluginImportUri + QLatin1Char('.')); } void collectReachableMetaObjects(const QMetaObject *meta, QSet *metas, const QmlVersionInfo &info, bool extended = false, bool alreadyChangedModule = false) @@ -1057,6 +1063,7 @@ int main(int argc, char *argv[]) QString dependenciesFile; QString mergeFile; bool forceQtQuickDependency = true; + bool strict = false; enum Action { Uri, Path, Builtins }; Action action = Uri; { @@ -1121,6 +1128,10 @@ int main(int argc, char *argv[]) } else if (arg == QLatin1String("--qapp") || arg == QLatin1String("-qapp")) { continue; + } else if (arg == QLatin1String("--strict") + || arg == QLatin1String("-strict")) { + strict = true; + continue; } else { std::cerr << "Invalid argument: " << qPrintable(arg) << std::endl; return EXIT_INVALIDARGUMENTS; @@ -1231,7 +1242,7 @@ int main(int argc, char *argv[]) int majorVersion = qtQmlMajorVersion, minorVersion = qtQmlMinorVersion; QmlVersionInfo info; if (action == Builtins) { - QSet builtins = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, defaultCompositeTypes, {QLatin1String("Qt"), majorVersion, minorVersion}); + QSet builtins = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, defaultCompositeTypes, {QLatin1String("Qt"), majorVersion, minorVersion, strict}); Q_ASSERT(builtins.size() == 1); metas.insert(*builtins.begin()); } else { @@ -1291,7 +1302,7 @@ int main(int argc, char *argv[]) return EXIT_IMPORTERROR; } } - info = {pluginImportUri, majorVersion, minorVersion}; + info = {pluginImportUri, majorVersion, minorVersion, strict}; QSet candidates = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, compositeTypes, info, defaultTypes); for (QString iter: compositeTypes.keys()) { -- cgit v1.2.3 From a0ad2cbdf27d0d23727b09609e127ac17e414a22 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Thu, 26 Sep 2019 13:21:25 +0200 Subject: Doc: Fix typo Fixes: QTBUG-78784 Change-Id: Idc156088fdae4782b4970c3211b8248f8c333e9a Reviewed-by: Leena Miettinen --- src/quick/items/qquickitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index ec6bf5a1b8..396012e1e6 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -8455,7 +8455,7 @@ void QQuickItemLayer::setMipmap(bool mipmap) \note ShaderEffectSource.RGB and ShaderEffectSource.Alpha should be used with caution, as support for these formats in the underlying - hardare and driver is often not present. + hardware and driver is often not present. \sa {Item Layers} */ -- cgit v1.2.3 From 1da49d8493de7180a9db38d4614ba6fbbe898276 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 24 Sep 2019 09:53:20 +0200 Subject: Update plugins.qmltypes for 5.14 Task-number: QTBUG-78690 Change-Id: Iaee681cc10ae33c582806900a041d79bc0cc8d1d Reviewed-by: Ulf Hermann --- src/imports/builtins/builtins.qmltypes | 11 ++ src/imports/folderlistmodel/plugins.qmltypes | 274 +++++++++++++++++++++++++++ src/imports/labsanimation/plugins.qmltypes | 4 +- src/imports/models/plugins.qmltypes | 52 +++++ src/imports/particles/plugins.qmltypes | 50 +++++ src/imports/qtqml/plugins.qmltypes | 22 +-- src/imports/qtquick2/plugins.qmltypes | 268 +++++++++++++++++++++++++- src/imports/window/plugins.qmltypes | 6 + 8 files changed, 661 insertions(+), 26 deletions(-) diff --git a/src/imports/builtins/builtins.qmltypes b/src/imports/builtins/builtins.qmltypes index c783c63caf..765c92fcb9 100644 --- a/src/imports/builtins/builtins.qmltypes +++ b/src/imports/builtins/builtins.qmltypes @@ -1685,6 +1685,17 @@ Module { "ChecksumItuV41": 1 } } + Enum { + name: "HighDpiScaleFactorRoundingPolicy" + values: { + "Unset": 0, + "Round": 1, + "Ceil": 2, + "Floor": 3, + "RoundPreferFloor": 4, + "PassThrough": 5 + } + } } Component { name: "QEasingCurve"; prototype: "QQmlEasingValueType" } } diff --git a/src/imports/folderlistmodel/plugins.qmltypes b/src/imports/folderlistmodel/plugins.qmltypes index 0fdbae66d3..7c53c99665 100644 --- a/src/imports/folderlistmodel/plugins.qmltypes +++ b/src/imports/folderlistmodel/plugins.qmltypes @@ -8,6 +8,280 @@ import QtQuick.tooling 1.2 Module { dependencies: ["QtQuick 2.0"] + Component { + name: "QAbstractItemModel" + prototype: "QObject" + Enum { + name: "LayoutChangeHint" + values: { + "NoLayoutChangeHint": 0, + "VerticalSortHint": 1, + "HorizontalSortHint": 2 + } + } + Enum { + name: "CheckIndexOption" + values: { + "NoOption": 0, + "IndexIsValid": 1, + "DoNotUseParent": 2, + "ParentIsInvalid": 4 + } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + Parameter { name: "roles"; type: "QVector" } + } + Signal { + name: "dataChanged" + Parameter { name: "topLeft"; type: "QModelIndex" } + Parameter { name: "bottomRight"; type: "QModelIndex" } + } + Signal { + name: "headerDataChanged" + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutChanged" + Parameter { name: "parents"; type: "QList" } + } + Signal { name: "layoutChanged" } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList" } + Parameter { name: "hint"; type: "QAbstractItemModel::LayoutChangeHint" } + } + Signal { + name: "layoutAboutToBeChanged" + Parameter { name: "parents"; type: "QList" } + } + Signal { name: "layoutAboutToBeChanged" } + Signal { + name: "rowsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "rowsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsInserted" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsAboutToBeRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { + name: "columnsRemoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "first"; type: "int" } + Parameter { name: "last"; type: "int" } + } + Signal { name: "modelAboutToBeReset" } + Signal { name: "modelReset" } + Signal { + name: "rowsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationRow"; type: "int" } + } + Signal { + name: "rowsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "row"; type: "int" } + } + Signal { + name: "columnsAboutToBeMoved" + Parameter { name: "sourceParent"; type: "QModelIndex" } + Parameter { name: "sourceStart"; type: "int" } + Parameter { name: "sourceEnd"; type: "int" } + Parameter { name: "destinationParent"; type: "QModelIndex" } + Parameter { name: "destinationColumn"; type: "int" } + } + Signal { + name: "columnsMoved" + Parameter { name: "parent"; type: "QModelIndex" } + Parameter { name: "start"; type: "int" } + Parameter { name: "end"; type: "int" } + Parameter { name: "destination"; type: "QModelIndex" } + Parameter { name: "column"; type: "int" } + } + Method { name: "submit"; type: "bool" } + Method { name: "revert" } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "hasIndex" + type: "bool" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "index" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + } + Method { + name: "parent" + type: "QModelIndex" + Parameter { name: "child"; type: "QModelIndex" } + } + Method { + name: "sibling" + type: "QModelIndex" + Parameter { name: "row"; type: "int" } + Parameter { name: "column"; type: "int" } + Parameter { name: "idx"; type: "QModelIndex" } + } + Method { + name: "rowCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "rowCount"; type: "int" } + Method { + name: "columnCount" + type: "int" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "columnCount"; type: "int" } + Method { + name: "hasChildren" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { name: "hasChildren"; type: "bool" } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "data" + type: "QVariant" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "setData" + type: "bool" + Parameter { name: "index"; type: "QModelIndex" } + Parameter { name: "value"; type: "QVariant" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + Parameter { name: "role"; type: "int" } + } + Method { + name: "headerData" + type: "QVariant" + Parameter { name: "section"; type: "int" } + Parameter { name: "orientation"; type: "Qt::Orientation" } + } + Method { + name: "fetchMore" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "canFetchMore" + type: "bool" + Parameter { name: "parent"; type: "QModelIndex" } + } + Method { + name: "flags" + type: "Qt::ItemFlags" + Parameter { name: "index"; type: "QModelIndex" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + Parameter { name: "flags"; type: "Qt::MatchFlags" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + Parameter { name: "hits"; type: "int" } + } + Method { + name: "match" + type: "QModelIndexList" + Parameter { name: "start"; type: "QModelIndex" } + Parameter { name: "role"; type: "int" } + Parameter { name: "value"; type: "QVariant" } + } + } + Component { name: "QAbstractListModel"; prototype: "QAbstractItemModel" } Component { name: "QQuickFolderListModel" prototype: "QAbstractListModel" diff --git a/src/imports/labsanimation/plugins.qmltypes b/src/imports/labsanimation/plugins.qmltypes index 065e65ad7a..2ecc5e6f5d 100644 --- a/src/imports/labsanimation/plugins.qmltypes +++ b/src/imports/labsanimation/plugins.qmltypes @@ -4,10 +4,10 @@ import QtQuick.tooling 1.2 // It is used for QML tooling purposes only. // // This file was auto-generated by: -// 'qmlplugindump -nonrelocatable Qt.labs.animation 1.0' +// 'qmlplugindump -nonrelocatable -dependencies dependencies.json Qt.labs.animation 1.0' Module { - dependencies: ["QtQuick 2.0"] + dependencies: [] Component { name: "QQuickBoundaryRule" prototype: "QObject" diff --git a/src/imports/models/plugins.qmltypes b/src/imports/models/plugins.qmltypes index 0d8b94df23..58122b9b45 100644 --- a/src/imports/models/plugins.qmltypes +++ b/src/imports/models/plugins.qmltypes @@ -483,6 +483,58 @@ Module { } } Component { name: "QQmlDelegateModelParts"; prototype: "QObject" } + Component { + name: "QQmlInstanceModel" + prototype: "QObject" + Property { name: "count"; type: "int"; isReadonly: true } + Signal { + name: "modelUpdated" + Parameter { name: "changeSet"; type: "QQmlChangeSet" } + Parameter { name: "reset"; type: "bool" } + } + Signal { + name: "createdItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "initItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "destroyingItem" + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + } + Component { + name: "QQmlInstantiator" + defaultProperty: "delegate" + prototype: "QObject" + exports: ["QtQml.Models/Instantiator 2.14"] + exportMetaObjectRevisions: [0] + Property { name: "active"; type: "bool" } + Property { name: "asynchronous"; type: "bool" } + Property { name: "model"; type: "QVariant" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } + Property { name: "object"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { + name: "objectAdded" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "objectRemoved" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Method { + name: "objectAt" + type: "QObject*" + Parameter { name: "index"; type: "int" } + } + } Component { name: "QQmlListElement" prototype: "QObject" diff --git a/src/imports/particles/plugins.qmltypes b/src/imports/particles/plugins.qmltypes index 0fe5dc808c..0a5e124c3c 100644 --- a/src/imports/particles/plugins.qmltypes +++ b/src/imports/particles/plugins.qmltypes @@ -996,6 +996,56 @@ Module { Parameter { name: "arg"; type: "bool" } } } + Component { + name: "QQuickStochasticState" + prototype: "QObject" + Property { name: "duration"; type: "int" } + Property { name: "durationVariation"; type: "int" } + Property { name: "randomStart"; type: "bool" } + Property { name: "to"; type: "QVariantMap" } + Property { name: "name"; type: "string" } + Signal { + name: "durationChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "nameChanged" + Parameter { name: "arg"; type: "string" } + } + Signal { + name: "toChanged" + Parameter { name: "arg"; type: "QVariantMap" } + } + Signal { + name: "durationVariationChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { name: "entered" } + Signal { + name: "randomStartChanged" + Parameter { name: "arg"; type: "bool" } + } + Method { + name: "setDuration" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setName" + Parameter { name: "arg"; type: "string" } + } + Method { + name: "setTo" + Parameter { name: "arg"; type: "QVariantMap" } + } + Method { + name: "setDurationVariation" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setRandomStart" + Parameter { name: "arg"; type: "bool" } + } + } Component { name: "QQuickTargetDirection" prototype: "QQuickDirection" diff --git a/src/imports/qtqml/plugins.qmltypes b/src/imports/qtqml/plugins.qmltypes index 63f5bada9b..7bccfea26a 100644 --- a/src/imports/qtqml/plugins.qmltypes +++ b/src/imports/qtqml/plugins.qmltypes @@ -10,8 +10,8 @@ Module { dependencies: [] Component { name: "QObject" - exports: ["QML/QtObject 1.0", "QtQml/QtObject 2.0"] - exportMetaObjectRevisions: [0, 0] + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] Property { name: "objectName"; type: "string" } Signal { name: "objectNameChanged" @@ -52,8 +52,8 @@ Module { Component { name: "QQmlComponent" prototype: "QObject" - exports: ["QML/Component 1.0", "QtQml/Component 2.0"] - exportMetaObjectRevisions: [0, 0] + exports: ["QtQml/Component 2.0"] + exportMetaObjectRevisions: [0] attachedType: "QQmlComponentAttached" Enum { name: "CompilationMode" @@ -242,18 +242,4 @@ Module { Method { name: "stop" } Method { name: "restart" } } - Component { - name: "QQuickMouseEvent" - prototype: "QObject" - Property { name: "x"; type: "double"; isReadonly: true } - Property { name: "y"; type: "double"; isReadonly: true } - Property { name: "button"; type: "int"; isReadonly: true } - Property { name: "buttons"; type: "int"; isReadonly: true } - Property { name: "modifiers"; type: "int"; isReadonly: true } - Property { name: "source"; revision: 7; type: "int"; isReadonly: true } - Property { name: "wasHeld"; type: "bool"; isReadonly: true } - Property { name: "isClick"; type: "bool"; isReadonly: true } - Property { name: "accepted"; type: "bool" } - Property { name: "flags"; revision: 11; type: "int"; isReadonly: true } - } } diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index c8aae2087d..0ba918e34e 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -448,6 +448,22 @@ Module { } } } + Component { + name: "QObject" + exports: ["QtQuick/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } Component { name: "QPointingDeviceUniqueId" exports: ["QtQuick/PointingDeviceUniqueId 2.9"] @@ -481,6 +497,92 @@ Module { Parameter { name: "arg"; type: "string" } } } + Component { + name: "QQmlBind" + prototype: "QObject" + exports: ["QtQuick/Binding 2.0", "QtQuick/Binding 2.8"] + exportMetaObjectRevisions: [0, 8] + Enum { + name: "RestorationMode" + values: { + "RestoreNone": 0, + "RestoreBinding": 1, + "RestoreValue": 2, + "RestoreBindingOrValue": 3 + } + } + Property { name: "target"; type: "QObject"; isPointer: true } + Property { name: "property"; type: "string" } + Property { name: "value"; type: "QVariant" } + Property { name: "when"; type: "bool" } + Property { name: "delayed"; revision: 8; type: "bool" } + Property { name: "restoreMode"; revision: 14; type: "RestorationMode" } + } + Component { + name: "QQmlComponent" + prototype: "QObject" + exports: ["QtQuick/Component 2.0"] + exportMetaObjectRevisions: [0] + attachedType: "QQmlComponentAttached" + Enum { + name: "CompilationMode" + values: { + "PreferSynchronous": 0, + "Asynchronous": 1 + } + } + Enum { + name: "Status" + values: { + "Null": 0, + "Ready": 1, + "Loading": 2, + "Error": 3 + } + } + Property { name: "progress"; type: "double"; isReadonly: true } + Property { name: "status"; type: "Status"; isReadonly: true } + Property { name: "url"; type: "QUrl"; isReadonly: true } + Signal { + name: "statusChanged" + Parameter { type: "QQmlComponent::Status" } + } + Signal { + name: "progressChanged" + Parameter { type: "double" } + } + Method { + name: "loadUrl" + Parameter { name: "url"; type: "QUrl" } + } + Method { + name: "loadUrl" + Parameter { name: "url"; type: "QUrl" } + Parameter { name: "mode"; type: "CompilationMode" } + } + Method { + name: "setData" + Parameter { type: "QByteArray" } + Parameter { name: "baseUrl"; type: "QUrl" } + } + Method { name: "errorString"; type: "string" } + } + Component { + name: "QQmlComponentAttached" + prototype: "QObject" + Signal { name: "completed" } + Signal { name: "destruction" } + } + Component { + name: "QQmlConnections" + prototype: "QObject" + exports: ["QtQuick/Connections 2.0", "QtQuick/Connections 2.7"] + exportMetaObjectRevisions: [0, 3] + Property { name: "target"; type: "QObject"; isPointer: true } + Property { name: "enabled"; revision: 3; type: "bool" } + Property { name: "ignoreUnknownSignals"; type: "bool" } + Signal { name: "enabledChanged"; revision: 3 } + } Component { name: "QQmlDelegateModel" defaultProperty: "delegate" @@ -633,6 +735,58 @@ Module { Property { name: "period"; type: "double" } Property { name: "bezierCurve"; type: "QVariantList" } } + Component { + name: "QQmlInstanceModel" + prototype: "QObject" + Property { name: "count"; type: "int"; isReadonly: true } + Signal { + name: "modelUpdated" + Parameter { name: "changeSet"; type: "QQmlChangeSet" } + Parameter { name: "reset"; type: "bool" } + } + Signal { + name: "createdItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "initItem" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "destroyingItem" + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + } + Component { + name: "QQmlInstantiator" + defaultProperty: "delegate" + prototype: "QObject" + exports: ["QtQuick/Instantiator 2.1"] + exportMetaObjectRevisions: [0] + Property { name: "active"; type: "bool" } + Property { name: "asynchronous"; type: "bool" } + Property { name: "model"; type: "QVariant" } + Property { name: "count"; type: "int"; isReadonly: true } + Property { name: "delegate"; type: "QQmlComponent"; isPointer: true } + Property { name: "object"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { + name: "objectAdded" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "objectRemoved" + Parameter { name: "index"; type: "int" } + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Method { + name: "objectAt" + type: "QObject*" + Parameter { name: "index"; type: "int" } + } + } Component { name: "QQmlListElement" prototype: "QObject" @@ -732,6 +886,70 @@ Module { } Method { name: "sync" } } + Component { + name: "QQmlLocale" + exports: ["QtQuick/Locale 2.0"] + isCreatable: false + exportMetaObjectRevisions: [0] + Enum { + name: "MeasurementSystem" + values: { + "MetricSystem": 0, + "ImperialSystem": 1, + "ImperialUSSystem": 1, + "ImperialUKSystem": 2 + } + } + Enum { + name: "FormatType" + values: { + "LongFormat": 0, + "ShortFormat": 1, + "NarrowFormat": 2 + } + } + Enum { + name: "CurrencySymbolFormat" + values: { + "CurrencyIsoCode": 0, + "CurrencySymbol": 1, + "CurrencyDisplayName": 2 + } + } + Enum { + name: "DayOfWeek" + values: { + "Sunday": 0, + "Monday": 1, + "Tuesday": 2, + "Wednesday": 3, + "Thursday": 4, + "Friday": 5, + "Saturday": 6 + } + } + } + Component { + name: "QQmlLoggingCategory" + prototype: "QObject" + exports: [ + "QtQuick/LoggingCategory 2.12", + "QtQuick/LoggingCategory 2.8" + ] + exportMetaObjectRevisions: [12, 0] + Enum { + name: "DefaultLogLevel" + values: { + "Debug": 0, + "Info": 4, + "Warning": 1, + "Critical": 2, + "Fatal": 3 + } + } + Property { name: "name"; type: "string" } + Property { name: "defaultLogLevel"; revision: 12; type: "DefaultLogLevel" } + } Component { name: "QQmlObjectModel" defaultProperty: "children" @@ -788,6 +1006,21 @@ Module { prototype: "QObject" Property { name: "index"; type: "int"; isReadonly: true } } + Component { + name: "QQmlTimer" + prototype: "QObject" + exports: ["QtQuick/Timer 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "interval"; type: "int" } + Property { name: "running"; type: "bool" } + Property { name: "repeat"; type: "bool" } + Property { name: "triggeredOnStart"; type: "bool" } + Property { name: "parent"; type: "QObject"; isReadonly: true; isPointer: true } + Signal { name: "triggered" } + Method { name: "start" } + Method { name: "stop" } + Method { name: "restart" } + } Component { name: "QQuickAbstractAnimation" prototype: "QObject" @@ -1527,8 +1760,8 @@ Module { Component { name: "QQuickDragHandler" prototype: "QQuickMultiPointHandler" - exports: ["QtQuick/DragHandler 2.12"] - exportMetaObjectRevisions: [0] + exports: ["QtQuick/DragHandler 2.12", "QtQuick/DragHandler 2.14"] + exportMetaObjectRevisions: [0, 14] Enum { name: "SnapMode" values: { @@ -1541,7 +1774,8 @@ Module { Property { name: "xAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true } Property { name: "yAxis"; type: "QQuickDragAxis"; isReadonly: true; isPointer: true } Property { name: "translation"; type: "QVector2D"; isReadonly: true } - Property { name: "snapMode"; type: "SnapMode" } + Property { name: "snapMode"; revision: 14; type: "SnapMode" } + Signal { name: "snapModeChanged"; revision: 14 } } Component { name: "QQuickDropArea" @@ -2194,10 +2428,11 @@ Module { prototype: "QQuickImageBase" exports: [ "QtQuick/Image 2.0", + "QtQuick/Image 2.14", "QtQuick/Image 2.3", "QtQuick/Image 2.5" ] - exportMetaObjectRevisions: [0, 3, 5] + exportMetaObjectRevisions: [0, 14, 3, 5] Enum { name: "HAlignment" values: { @@ -2253,6 +2488,9 @@ Module { name: "QQuickImageBase" defaultProperty: "data" prototype: "QQuickImplicitSizeItem" + exports: ["QtQuick/ImageBase 2.14"] + isCreatable: false + exportMetaObjectRevisions: [14] Enum { name: "Status" values: { @@ -2269,6 +2507,8 @@ Module { Property { name: "cache"; type: "bool" } Property { name: "sourceSize"; type: "QSize" } Property { name: "mirror"; type: "bool" } + Property { name: "currentFrame"; revision: 14; type: "int" } + Property { name: "frameCount"; revision: 14; type: "int"; isReadonly: true } Signal { name: "sourceChanged" Parameter { type: "QUrl" } @@ -2281,6 +2521,8 @@ Module { name: "progressChanged" Parameter { name: "progress"; type: "double" } } + Signal { name: "currentFrameChanged"; revision: 14 } + Signal { name: "frameCountChanged"; revision: 14 } } Component { name: "QQuickImplicitSizeItem" @@ -3078,6 +3320,20 @@ Module { Signal { name: "containsPressChanged"; revision: 4 } Signal { name: "pressAndHoldIntervalChanged"; revision: 9 } } + Component { + name: "QQuickMouseEvent" + prototype: "QObject" + Property { name: "x"; type: "double"; isReadonly: true } + Property { name: "y"; type: "double"; isReadonly: true } + Property { name: "button"; type: "int"; isReadonly: true } + Property { name: "buttons"; type: "int"; isReadonly: true } + Property { name: "modifiers"; type: "int"; isReadonly: true } + Property { name: "source"; revision: 7; type: "int"; isReadonly: true } + Property { name: "wasHeld"; type: "bool"; isReadonly: true } + Property { name: "isClick"; type: "bool"; isReadonly: true } + Property { name: "accepted"; type: "bool" } + Property { name: "flags"; revision: 11; type: "int"; isReadonly: true } + } Component { name: "QQuickMultiPointHandler" prototype: "QQuickPointerDeviceHandler" @@ -3401,7 +3657,7 @@ Module { exports: ["QtQuick/PathMultiline 2.14"] exportMetaObjectRevisions: [0] Property { name: "start"; type: "QPointF"; isReadonly: true } - Property { name: "paths"; type: "QVariantList" } + Property { name: "paths"; type: "QVariant" } } Component { name: "QQuickPathPercent" @@ -3416,7 +3672,7 @@ Module { exports: ["QtQuick/PathPolyline 2.14"] exportMetaObjectRevisions: [0] Property { name: "start"; type: "QPointF"; isReadonly: true } - Property { name: "path"; type: "QVariantList" } + Property { name: "path"; type: "QVariant" } } Component { name: "QQuickPathQuad" diff --git a/src/imports/window/plugins.qmltypes b/src/imports/window/plugins.qmltypes index 82b7ce0fc5..693673c4cd 100644 --- a/src/imports/window/plugins.qmltypes +++ b/src/imports/window/plugins.qmltypes @@ -100,6 +100,12 @@ Module { "NativeTextRendering": 1 } } + Enum { + name: "NativeObjectType" + values: { + "NativeObjectTexture": 0 + } + } Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } Property { name: "color"; type: "QColor" } Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true } -- cgit v1.2.3 From 3f44e0fc5f1d55498ce7fb93a7841198a7583a08 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 24 Sep 2019 12:24:16 +0200 Subject: Convert QTime to V4 Date on a date with no DST in force Sadly the third centennary of Cassini's birth isn't such a good date after all, since round-tripping will ignore DST on the QDateTime leg but include it in V4's implementation of ES's ill-conceived spec for handling DST and time-zone transitions; and June 8th is in summer for much of the world. So use a date which (as far as I can tell) appears to have been DST-free everywhere; and after the start of 1970 so that, even if we find ourselves working with a zone in which it did have DST, we'll apply DST consistently during round-tripping. Fixes: QTBUG-78706 Change-Id: I25be2548e2c97eae2c4f6c5bbe661dea2f35aaba Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4dateobject.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index bba88e5c9a..5616b1450b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -729,14 +729,16 @@ void Heap::DateObject::init(const QTime &time) * time from it, which shall (via toQDateTime(), below) discard the date * part. We need a date for which time-zone data is likely to be sane (so * MakeDay(0, 0, 0) was a bad choice; 2 BC, December 31st is before - * time-zones were standardized), with no transition nearby in date. We - * ignore DST transitions before 1970, but even then zone transitions did - * happen. Some do happen at new year, others on DST transitions in spring - * and autumn; so pick the three hundredth anniversary of the birth of - * Giovanni Domenico Cassini (1625-06-08), whose work first let us - * synchronize clocks tolerably accurately at distant locations. + * time-zones were standardized), with no transition nearby in date. + * QDateTime ignores DST transitions before 1970, but even then zone + * transitions did happen; and DaylightSavingTA() will include DST, at odds + * with QDateTime. So pick a date since 1970 and prefer one when no zone + * was in DST. One such interval (according to the Olson database, at + * least) was 1971 March 15th to April 17th. Since converting a time to a + * date-time without specifying a date is foolish, let's use April Fools' + * day. */ - static const double d = MakeDay(1925, 5, 8); + static const double d = MakeDay(1971, 3, 1); double t = MakeTime(time.hour(), time.minute(), time.second(), time.msec()); date = TimeClip(UTC(MakeDate(d, t), internalClass->engine->localTZA)); } -- cgit v1.2.3 From 6bb678bad25eafe76dcebcd1ff184be9de9125bb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Sep 2019 16:10:21 +0200 Subject: Add a QSG env var for QRhi::PreferSoftwareRenderer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also extend the docs. And while we are at it get rid of some clang warnings. Task-number: QTBUG-78669 Change-Id: I4ef15d2d066098ba7bbbd34e80d4e61efe7fba23 Reviewed-by: Christian Strømme --- src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc | 13 +++++++++++++ src/quick/scenegraph/qsgrhisupport.cpp | 17 ++++++++++++----- src/quick/scenegraph/qsgrhisupport_p.h | 2 ++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc index 864d90274c..e09c430e43 100644 --- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc +++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc @@ -1016,6 +1016,14 @@ with multiple windows. \li Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug and/or validation layers, if available. + \row + \li \c QSG_RHI_PREFER_SOFTWARE_RENDERER + \li \c 1 + \li Requests choosing an adapter or physical device that uses software-based + rasterization. Applicable only when the underlying API has support for + enumerating adapters (for example, Direct3D or Vulkan), and is ignored + otherwise. + \endtable Applications wishing to always run with a single given graphics API, can @@ -1031,4 +1039,9 @@ with multiple windows. equivalent in effect to running with both \c QSG_RHI and \c QSG_RHI_BACKEND set. + All QRhi backends will choose the system default GPU adapter or physical + device, unless overridden by \c{QSG_RHI_PREFER_SOFTWARE_RENDERER} or a + backend-specific variable, such as, \c{QT_D3D_ADAPTER_INDEX} or + \c{QT_VK_PHYSICAL_DEVICE_INDEX}. No further adapter configurability is + provided at this time. */ diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 2c5d8fb2ac..12c6742342 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -101,7 +101,8 @@ QSGRhiSupport::QSGRhiSupport() m_enableRhi(false), m_debugLayer(false), m_profile(false), - m_shaderEffectDebug(false) + m_shaderEffectDebug(false), + m_preferSoftwareRenderer(false) { } @@ -140,7 +141,7 @@ void QSGRhiSupport::applySettings() } } else { // check env.vars., fall back to platform-specific defaults when backend is not set - m_enableRhi = qEnvironmentVariableIntValue("QSG_RHI"); + m_enableRhi = uint(qEnvironmentVariableIntValue("QSG_RHI")); const QByteArray rhiBackend = qgetenv("QSG_RHI_BACKEND"); if (rhiBackend == QByteArrayLiteral("gl") || rhiBackend == QByteArrayLiteral("gles2") @@ -171,12 +172,14 @@ void QSGRhiSupport::applySettings() return; // validation layers (Vulkan) or debug layer (D3D) - m_debugLayer = qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER"); + m_debugLayer = uint(qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER")); // EnableProfiling + DebugMarkers - m_profile = qEnvironmentVariableIntValue("QSG_RHI_PROFILE"); + m_profile = uint(qEnvironmentVariableIntValue("QSG_RHI_PROFILE")); - m_shaderEffectDebug = qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG"); + m_shaderEffectDebug = uint(qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG")); + + m_preferSoftwareRenderer = uint(qEnvironmentVariableIntValue("QSG_RHI_PREFER_SOFTWARE_RENDERER")); m_killDeviceFrameCount = qEnvironmentVariableIntValue("QSG_RHI_SIMULATE_DEVICE_LOSS"); if (m_killDeviceFrameCount > 0 && m_rhiBackend == QRhi::D3D11) @@ -205,6 +208,8 @@ void QSGRhiSupport::applySettings() qCDebug(QSG_LOG_INFO, "Using QRhi with backend %s\n graphics API debug/validation layers: %d\n QRhi profiling and debug markers: %d", backendName, m_debugLayer, m_profile); + if (m_preferSoftwareRenderer) + qCDebug(QSG_LOG_INFO, "Prioritizing software renderers"); } QSGRhiSupport *QSGRhiSupport::staticInst() @@ -463,6 +468,8 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf QRhi::Flags flags = 0; if (isProfilingRequested()) flags |= QRhi::EnableProfiling | QRhi::EnableDebugMarkers; + if (isSoftwareRendererRequested()) + flags |= QRhi::PreferSoftwareRenderer; QRhi::Implementation backend = rhiBackend(); if (backend == QRhi::Null) { diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h index 536efa55c3..d008ecd0af 100644 --- a/src/quick/scenegraph/qsgrhisupport_p.h +++ b/src/quick/scenegraph/qsgrhisupport_p.h @@ -114,6 +114,7 @@ public: bool isDebugLayerRequested() const { return m_debugLayer; } bool isProfilingRequested() const { return m_profile; } bool isShaderEffectDebuggingRequested() const { return m_shaderEffectDebug; } + bool isSoftwareRendererRequested() const { return m_preferSoftwareRenderer; } QSurface::SurfaceType windowSurfaceType() const; @@ -144,6 +145,7 @@ private: uint m_debugLayer : 1; uint m_profile : 1; uint m_shaderEffectDebug : 1; + uint m_preferSoftwareRenderer : 1; }; // Sends QRhi resource statistics over a QTcpSocket. To be initialized by the -- cgit v1.2.3 From cf51a723ffbddc5338628b99fa4a5b5b4d17295c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 23 Sep 2019 14:43:43 +0200 Subject: Remove depth-stencil buffer sizing on the rhi path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...as this will be done automatically by QRhiSwapChain after the corresponding QtGui changes. Task-number: QTBUG-78641 Change-Id: I8edeb728f3aba07bfa6bc6331966fba4bdee71f4 Reviewed-by: Tor Arne Vestbø --- src/quick/scenegraph/qsgrenderloop.cpp | 14 ++++++++------ src/quick/scenegraph/qsgthreadedrenderloop.cpp | 8 +++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index a5b5fe04f5..e69d25aab3 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -667,9 +667,6 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) if (cd->swapchainJustBecameRenderable) qCDebug(QSG_LOG_RENDERLOOP, "just became exposed"); - cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); - cd->depthStencilForSwapchain->build(); - cd->hasActiveSwapchain = cd->swapchain->buildOrResize(); if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) { handleDeviceLoss(); @@ -679,10 +676,15 @@ void QSGGuiThreadRenderLoop::renderWindow(QQuickWindow *window) cd->swapchainJustBecameRenderable = false; cd->hasRenderableSwapchain = cd->hasActiveSwapchain; - if (!cd->hasActiveSwapchain) - qWarning("Failed to build or resize swapchain"); - else + if (cd->hasActiveSwapchain) { + // surface size atomicity: now that buildOrResize() succeeded, + // query the size that was used in there by the swapchain, and + // that is the size we will use while preparing the next frame. + effectiveOutputSize = cd->swapchain->currentPixelSize(); qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << effectiveOutputSize; + } else { + qWarning("Failed to build or resize swapchain"); + } } Q_ASSERT(rhi == cd->rhi); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index cbf57225b0..3689f6501f 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -715,9 +715,6 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) if (cd->swapchainJustBecameRenderable) qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "just became exposed"); - cd->depthStencilForSwapchain->setPixelSize(effectiveOutputSize); - cd->depthStencilForSwapchain->build(); - cd->hasActiveSwapchain = cd->swapchain->buildOrResize(); if (!cd->hasActiveSwapchain && rhi->isDeviceLost()) { handleDeviceLoss(); @@ -731,7 +728,7 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) if (!cd->hasActiveSwapchain) qWarning("Failed to build or resize swapchain"); else - qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << effectiveOutputSize; + qCDebug(QSG_LOG_RENDERLOOP) << "rhi swapchain size" << cd->swapchain->currentPixelSize(); } Q_ASSERT(rhi == cd->rhi); @@ -810,8 +807,9 @@ void QSGRenderThread::syncAndRender(QImage *grabImage) } } if (current) { + const QSize outputSize = rhi ? cd->swapchain->currentPixelSize() : windowSize; - d->renderSceneGraph(windowSize); + d->renderSceneGraph(outputSize); if (profileFrames) renderTime = threadTimer.nsecsElapsed(); -- cgit v1.2.3 From 224f053eba157fb908f08909d8e2015d76b08295 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 16:20:19 +0200 Subject: Use a QQmlRefPointer for QQmlScriptData::typeNameCache The cache can get overwritten. We want the reference to the old one to be dropped then. Fixes: QTBUG-78865 Change-Id: I8ebba4ae242c3bf8ae4db5cffc65b26bab265b8a Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlscriptblob.cpp | 4 ++-- src/qml/qml/qqmlscriptdata.cpp | 6 +----- src/qml/qml/qqmlscriptdata_p.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/qml/qml/qqmlscriptblob.cpp b/src/qml/qml/qqmlscriptblob.cpp index 69b26894a8..6ac30d3ab5 100644 --- a/src/qml/qml/qqmlscriptblob.cpp +++ b/src/qml/qml/qqmlscriptblob.cpp @@ -177,7 +177,7 @@ void QQmlScriptBlob::done() } if (!m_isModule) { - m_scriptData->typeNameCache = new QQmlTypeNameCache(m_importCache); + m_scriptData->typeNameCache.adopt(new QQmlTypeNameCache(m_importCache)); QSet ns; @@ -195,7 +195,7 @@ void QQmlScriptBlob::done() m_scriptData->typeNameCache->add(script.qualifier, scriptIndex, script.nameSpace); } - m_importCache.populateCache(m_scriptData->typeNameCache); + m_importCache.populateCache(m_scriptData->typeNameCache.data()); } m_scripts.clear(); } diff --git a/src/qml/qml/qqmlscriptdata.cpp b/src/qml/qml/qqmlscriptdata.cpp index 0725f40d2a..ae268ca904 100644 --- a/src/qml/qml/qqmlscriptdata.cpp +++ b/src/qml/qml/qqmlscriptdata.cpp @@ -156,11 +156,7 @@ QV4::ReturnedValue QQmlScriptData::scriptValueForContext(QQmlContextData *parent void QQmlScriptData::clear() { - if (typeNameCache) { - typeNameCache->release(); - typeNameCache = nullptr; - } - + typeNameCache = nullptr; scripts.clear(); // An addref() was made when the QQmlCleanup was added to the engine. diff --git a/src/qml/qml/qqmlscriptdata_p.h b/src/qml/qml/qqmlscriptdata_p.h index 273ba3691f..80b65b699c 100644 --- a/src/qml/qml/qqmlscriptdata_p.h +++ b/src/qml/qml/qqmlscriptdata_p.h @@ -82,7 +82,7 @@ private: public: QUrl url; QString urlString; - QQmlTypeNameCache *typeNameCache; + QQmlRefPointer typeNameCache; QVector> scripts; QV4::ReturnedValue scriptValueForContext(QQmlContextData *parentCtxt); -- cgit v1.2.3 From e0334d05c00cfe6140ac55f8b6aa8ee83795b940 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 13:24:57 +0200 Subject: Don't leak the context property in tst_qqmllanguage::accessDeletedObject Change-Id: I27baef97537bb8fda7fcc00d934f0b2568b4284e Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 007fb5cef2..12ed50137b 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -5075,7 +5075,8 @@ void tst_qqmllanguage::accessDeletedObject() { QQmlEngine engine; - engine.rootContext()->setContextProperty("objectCreator", new ObjectCreator); + QScopedPointer creator(new ObjectCreator); + engine.rootContext()->setContextProperty("objectCreator", creator.get()); QQmlComponent component(&engine, testFileUrl("accessDeletedObject.qml")); VERIFY_ERRORS(0); -- cgit v1.2.3 From fcae2d13e43eab1ea60092194667939f85269bde Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 14:40:57 +0200 Subject: Fix property cache leaks Leaks happened when using unqualified context property lookups and when looking up properties of singletons. We need to release the caches when unlinking. Fixes: QTBUG-78859 Change-Id: I8b86bcf72f71a463fb259eb6ae6c46be62729d72 Reviewed-by: Simon Hausmann Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4executablecompilationunit.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index 58cd581eae..79e2ec2a5d 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -291,15 +292,18 @@ void ExecutableCompilationUnit::unlink() if (runtimeLookups) { for (uint i = 0; i < data->lookupTableSize; ++i) { QV4::Lookup &l = runtimeLookups[i]; - if (l.getter == QV4::QObjectWrapper::lookupGetter) { + if (l.getter == QV4::QObjectWrapper::lookupGetter + || l.getter == QQmlTypeWrapper::lookupSingletonProperty) { if (QQmlPropertyCache *pc = l.qobjectLookup.propertyCache) pc->release(); - } else if (l.getter == QQmlValueTypeWrapper::lookupGetter) { + } else if (l.getter == QQmlValueTypeWrapper::lookupGetter + || l.getter == QQmlTypeWrapper::lookupSingletonProperty) { if (QQmlPropertyCache *pc = l.qgadgetLookup.propertyCache) pc->release(); } - if (l.qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty) { + if (l.qmlContextPropertyGetter == QQmlContextWrapper::lookupScopeObjectProperty + || l.qmlContextPropertyGetter == QQmlContextWrapper::lookupContextObjectProperty) { if (QQmlPropertyCache *pc = l.qobjectLookup.propertyCache) pc->release(); } -- cgit v1.2.3 From 56926c6628978e349316066342e6d55369bbe373 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:24:25 +0200 Subject: Delete type half-built type resolution caches on compile errors Otherwise they leak. Change-Id: I744f67e039ffb9cacbf16394bd5558ee72028177 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- src/qml/qml/qqmltypedata.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp index 5e85d7f692..99fe069685 100644 --- a/src/qml/qml/qqmltypedata.cpp +++ b/src/qml/qml/qqmltypedata.cpp @@ -305,6 +305,7 @@ void QQmlTypeData::done() QQmlJS::DiagnosticMessage error = buildTypeResolutionCaches(&typeNameCache, &resolvedTypeCache); if (error.isValid()) { setError(error); + qDeleteAll(resolvedTypeCache); return; } } -- cgit v1.2.3 From 45a6b25cc3bc62668097945d2569070e0be9a0e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:36:27 +0200 Subject: tst_qqmllanguage: Fix singleton tests The JavaScript pragma test expected the dynamic signal test to run before. Therefore, it would fail when run in isolation. Move the two tests into one function. Change-Id: I0edb1f091c6a845110c3f741cbb48e846c423005 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 55 ++++++++++++------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 12ed50137b..ad96b1438f 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -243,12 +243,11 @@ private slots: void compositeSingletonModuleQualified(); void compositeSingletonInstantiateError(); void compositeSingletonDynamicPropertyError(); - void compositeSingletonDynamicSignal(); + void compositeSingletonDynamicSignalAndJavaScriptPragma(); void compositeSingletonQmlRegisterTypeError(); void compositeSingletonQmldirNoPragmaError(); void compositeSingletonQmlDirError(); void compositeSingletonRemote(); - void compositeSingletonJavaScriptPragma(); void compositeSingletonSelectors(); void compositeSingletonRegistered(); void compositeSingletonCircular(); @@ -4277,16 +4276,35 @@ void tst_qqmllanguage::compositeSingletonDynamicPropertyError() VERIFY_ERRORS(0); } -// Having a composite singleton type as dynamic signal parameter succeeds -// (like C++ singleton) -void tst_qqmllanguage::compositeSingletonDynamicSignal() +void tst_qqmllanguage::compositeSingletonDynamicSignalAndJavaScriptPragma() { - QQmlComponent component(&engine, testFileUrl("singletonTest11.qml")); - VERIFY_ERRORS(0); - QScopedPointer o(component.create()); - QVERIFY(o != nullptr); + { + // Having a composite singleton type as dynamic signal parameter succeeds + // (like C++ singleton) + + QQmlComponent component(&engine, testFileUrl("singletonTest11.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(o != nullptr); + + verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", -55); + } + { + // Load a composite singleton type and a javascript file that has .pragma library + // in it. This will make sure that the javascript .pragma does not get mixed with + // the pragma Singleton changes. - verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", -55); + QQmlComponent component(&engine, testFileUrl("singletonTest16.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(o != nullptr); + + // The value1 that is read from the SingletonType was changed from 125 to 99 + // above. As the type is a singleton and + // the engine has not been destroyed, we just retrieve the old instance and + // the value is still 99. + verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", 333); + } } // Use qmlRegisterType to register a qml composite type with pragma Singleton defined in it. @@ -4338,23 +4356,6 @@ void tst_qqmllanguage::compositeSingletonRemote() verifyCompositeSingletonPropertyValues(o.data(), "value1", 525, "value2", 355); } -// Load a composite singleton type and a javascript file that has .pragma library -// in it. This will make sure that the javascript .pragma does not get mixed with -// the pragma Singleton changes. -void tst_qqmllanguage::compositeSingletonJavaScriptPragma() -{ - QQmlComponent component(&engine, testFileUrl("singletonTest16.qml")); - VERIFY_ERRORS(0); - QScopedPointer o(component.create()); - QVERIFY(o != nullptr); - - // The value1 that is read from the SingletonType was changed from 125 to 99 - // in compositeSingletonDynamicSignal() above. As the type is a singleton and - // the engine has not been destroyed, we just retrieve the old instance and - // the value is still 99. - verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", 333); -} - // Reads values from a Singleton accessed through selectors. void tst_qqmllanguage::compositeSingletonSelectors() { -- cgit v1.2.3 From 85bf1c438b36d91a77e3371d8fe2d8c3750c4858 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 18:06:57 +0200 Subject: WorkerScript: Directly delete QQuickWorkerScriptEnginePrivate QQuickWorkerScriptEnginePrivate lives in the worker thread. Therefore, once the thread has finished there is no way to send it a deferred delete event. The object and all its children would always leak. As there is no event loop running in the worker thread anymore and this is the dtor of QQuickWorkerScript, it's safe to assume that no one can access the private object anymore afterwards. Change-Id: I51f583ea47060d967403639196247882ff7d2905 Reviewed-by: Simon Hausmann --- src/qmlworkerscript/qquickworkerscript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp index b93e297b61..8b236697b9 100644 --- a/src/qmlworkerscript/qquickworkerscript.cpp +++ b/src/qmlworkerscript/qquickworkerscript.cpp @@ -374,7 +374,7 @@ QQuickWorkerScriptEngine::~QQuickWorkerScriptEngine() yieldCurrentThread(); } - d->deleteLater(); + delete d; } WorkerScript::WorkerScript(int id, QQuickWorkerScriptEnginePrivate *parent) -- cgit v1.2.3 From 702249777f9052c0f26793187f36fa0301dee105 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 18:09:22 +0200 Subject: tst_qqmlecmascript: Don't leak created objects The result from component.create() has to be deleted somewhere. Change-Id: I23135cb639fc316641e399decc740d9f5d445a84 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/testtypes.h | 8 +- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 101 +++++++++++---------- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 730dc7cab8..3233e7f105 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1098,13 +1098,11 @@ class MyItemUsingRevisionedObject : public QObject Q_PROPERTY(MyRevisionedClass *revisioned READ revisioned) public: - MyItemUsingRevisionedObject() { - m_revisioned = new MyRevisionedClass; - } + MyItemUsingRevisionedObject() : m_revisioned (new MyRevisionedClass) {} - MyRevisionedClass *revisioned() const { return m_revisioned; } + MyRevisionedClass *revisioned() const { return m_revisioned.get(); } private: - MyRevisionedClass *m_revisioned; + QScopedPointer m_revisioned; }; QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index fa78e60bba..05ad5e2f22 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1693,10 +1693,10 @@ void tst_qqmlecmascript::componentCreation() } QQmlComponent component(&engine, testUrl); - MyTypeObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); - QMetaObject::invokeMethod(object, method.toUtf8()); + QMetaObject::invokeMethod(object.get(), method.toUtf8()); QQmlComponent *created = object->componentProperty(); if (creationError.isEmpty()) { @@ -1704,7 +1704,7 @@ void tst_qqmlecmascript::componentCreation() QObject *expectedParent = reinterpret_cast(quintptr(-1)); if (createdParent == QLatin1String("obj")) { - expectedParent = object; + expectedParent = object.get(); } else if ((createdParent == QLatin1String("null")) || createdParent.isEmpty()) { expectedParent = nullptr; } @@ -3124,13 +3124,13 @@ void tst_qqmlecmascript::callQtInvokables() void tst_qqmlecmascript::resolveClashingProperties() { - ClashingNames *o = new ClashingNames(); + QScopedPointer o(new ClashingNames()); QQmlEngine qmlengine; QV4::ExecutionEngine *engine = qmlengine.handle(); QV4::Scope scope(engine); - QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o)); + QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o.get())); QV4::ObjectIterator it(scope, object->as(), QV4::ObjectIterator::EnumerableOnly); QV4::ScopedValue name(scope); QV4::ScopedValue value(scope); @@ -6093,7 +6093,7 @@ void tst_qqmlecmascript::variants() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("variants.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); QCOMPARE(object->property("undefinedVariant").type(), QVariant::Invalid); @@ -6102,13 +6102,13 @@ void tst_qqmlecmascript::variants() QCOMPARE(object->property("doubleVariant").type(), QVariant::Double); QVariant result; - QMetaObject::invokeMethod(object, "checkNull", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkNull", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); - QMetaObject::invokeMethod(object, "checkUndefined", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkUndefined", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); - QMetaObject::invokeMethod(object, "checkNumber", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkNumber", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); } @@ -6998,12 +6998,12 @@ void tst_qqmlecmascript::realToInt() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("realToInt.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); - QMetaObject::invokeMethod(object, "test1"); + QMetaObject::invokeMethod(object.get(), "test1"); QCOMPARE(object->value(), int(4)); - QMetaObject::invokeMethod(object, "test2"); + QMetaObject::invokeMethod(object.get(), "test2"); QCOMPARE(object->value(), int(7)); } @@ -7012,7 +7012,7 @@ void tst_qqmlecmascript::urlProperty() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); object->setStringProperty("http://qt-project.org"); QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html")); @@ -7027,7 +7027,7 @@ void tst_qqmlecmascript::urlPropertyWithEncoding() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); object->setStringProperty("http://qt-project.org"); const QUrl encoded = QUrl::fromEncoded("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); @@ -7062,7 +7062,7 @@ void tst_qqmlecmascript::dynamicString() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("dynamicString.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); QCOMPARE(object->property("stringProperty").toString(), QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!")); @@ -7072,7 +7072,7 @@ void tst_qqmlecmascript::deleteLaterObjectMethodCall() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("deleteLaterObjectMethodCall.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7080,7 +7080,7 @@ void tst_qqmlecmascript::automaticSemicolon() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7088,7 +7088,7 @@ void tst_qqmlecmascript::compatibilitySemicolon() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("compatibilitySemicolon.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7096,7 +7096,7 @@ void tst_qqmlecmascript::incrDecrSemicolon1() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon1.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7104,7 +7104,7 @@ void tst_qqmlecmascript::incrDecrSemicolon2() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon2.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7120,7 +7120,7 @@ void tst_qqmlecmascript::unaryExpression() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("unaryExpression.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7260,7 +7260,7 @@ void tst_qqmlecmascript::switchStatement() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7283,7 +7283,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7306,7 +7306,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.3.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7333,7 +7333,7 @@ void tst_qqmlecmascript::switchStatement() QString warning = component.url().toString() + ":4:5: Unable to assign [undefined] to int"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7357,7 +7357,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.5.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7380,7 +7380,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.6.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7408,7 +7408,7 @@ void tst_qqmlecmascript::withStatement() { QUrl url = testFileUrl("withStatement.1.qml"); QQmlComponent component(&engine, url); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 123); @@ -7420,7 +7420,7 @@ void tst_qqmlecmascript::tryStatement() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 123); @@ -7428,7 +7428,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 321); @@ -7436,7 +7436,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.3.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QVERIFY(object->qjsvalue().isUndefined()); @@ -7444,7 +7444,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.4.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QVERIFY(object->qjsvalue().isUndefined()); @@ -7585,7 +7585,7 @@ void tst_qqmlecmascript::onDestruction() // component instance. This shouldn't crash. QQmlEngine engine; QQmlComponent c(&engine, testFileUrl("onDestruction.qml")); - QObject *obj = c.create(); + QScopedPointer obj(c.create()); QVERIFY(obj != nullptr); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); } @@ -7926,19 +7926,19 @@ void tst_qqmlecmascript::dateParse() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("date.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; - QMetaObject::invokeMethod(object, "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q)); QVERIFY(q.toBool()); - QMetaObject::invokeMethod(object, "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); QVERIFY(q.toBool()); - QMetaObject::invokeMethod(object, "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); QCOMPARE(q.toLongLong(), 1379512851000LL); } @@ -7947,14 +7947,14 @@ void tst_qqmlecmascript::utcDate() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("utcdate.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; QVariant val = QString::fromLatin1("2014-07-16T23:30:31"); - QMetaObject::invokeMethod(object, "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val)); + QMetaObject::invokeMethod(object.get(), "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val)); QVERIFY(q.toBool()); } @@ -7963,20 +7963,20 @@ void tst_qqmlecmascript::negativeYear() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("negativeyear.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; - QMetaObject::invokeMethod(object, "check_negative_tostring", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "check_negative_tostring", Q_RETURN_ARG(QVariant, q)); // Only check for the year. We hope that every language writes the year in arabic numerals and // in relation to a specific dude's date of birth. We also hope that no language adds a "-2001" // junk string somewhere in the middle. QVERIFY(q.toString().indexOf(QStringLiteral("-2001")) != -1); - QMetaObject::invokeMethod(object, "check_negative_toisostring", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "check_negative_toisostring", Q_RETURN_ARG(QVariant, q)); QCOMPARE(q.toString().left(16), QStringLiteral("result: -002000-")); } @@ -8019,6 +8019,7 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() QCOMPARE(spy1.count(), 1); QCOMPARE(spy2.count(), 1); + deleteObject.deleteNestedObject(); delete object; } @@ -8030,7 +8031,7 @@ void tst_qqmlecmascript::updateCall() QString file("updateCall.qml"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl(file)); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -8041,7 +8042,7 @@ void tst_qqmlecmascript::numberParsing() QString file("numberParsing.%1.qml"); file = file.arg(i); QQmlComponent component(&engine, testFileUrl(file)); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } for (int i = 1; i < 3; ++i) { @@ -8224,8 +8225,8 @@ void tst_qqmlecmascript::idsAsLValues() QString err = QString(QLatin1String("%1:5: Error: left-hand side of assignment operator is not an lvalue")).arg(testFileUrl("idAsLValue.qml").toString()); QQmlComponent component(&engine, testFileUrl("idAsLValue.qml")); QTest::ignoreMessage(QtWarningMsg, qPrintable(err)); - MyQmlObject *object = qobject_cast(component.create()); - QVERIFY(!object); + QScopedPointer object(component.create()); + QVERIFY(!qobject_cast(object.get())); } void tst_qqmlecmascript::qtbug_34792() @@ -8440,10 +8441,10 @@ void tst_qqmlecmascript::readUnregisteredQObjectProperty() qmlRegisterType("Test", 1, 0, "ObjectContainer"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("accessUnregisteredQObjectProperty.qml")); - QObject *root = component.create(); + QScopedPointer root(component.create()); QVERIFY(root); - QMetaObject::invokeMethod(root, "readProperty"); + QMetaObject::invokeMethod(root.get(), "readProperty"); QCOMPARE(root->property("container").value()->mGetterCalled, true); } @@ -8452,10 +8453,10 @@ void tst_qqmlecmascript::writeUnregisteredQObjectProperty() qmlRegisterType("Test", 1, 0, "ObjectContainer"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("accessUnregisteredQObjectProperty.qml")); - QObject *root = component.create(); + QScopedPointer root(component.create()); QVERIFY(root); - QMetaObject::invokeMethod(root, "writeProperty"); + QMetaObject::invokeMethod(root.get(), "writeProperty"); QCOMPARE(root->property("container").value()->mSetterCalled, true); } -- cgit v1.2.3 From b1b25db63b465a17d7834d388916bf89f426fe35 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:45:51 +0200 Subject: tst_qqmlecmascript: import QtQuick when using color properties QtQuick defines the color provider necessary to use colors. If QtQuick is not loaded at that point, the test fails. Change-Id: I7d2eb25f7482d18b304d9274bce4a6bd6fa34741 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 54d29dfc94..9fdb7f92f3 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -1,4 +1,5 @@ import Qt.test 1.0 +import QtQuick 2.0 // We need the the QtQuick color provider for colorProperty MyQmlObject { -- cgit v1.2.3 From 670fdcc3f23493bc039a2676ce69892cc152dc6b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 17 Sep 2019 10:48:10 +0300 Subject: Android: Load QML plugins directly from APK libs dir Also register qrc:/android_rcc_bundle/qml as the folder where declarative engine finds the other QML files (qmldir, *.qml, *.js, etc.). [ChangeLog][Android] load QML plugins directly from APK libs dir and use qrc:/android_rcc_bundle/qml to search for QML files. Change-Id: I9552121411d21537befc41646cdd161ce0cec760 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/qml/qml/qqmlimport.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 31a7004407..5feea9daa8 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1751,6 +1751,16 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) addImportPath(QStringLiteral("qrc:/qt-project.org/imports")); addImportPath(QCoreApplication::applicationDirPath()); +#if defined(Q_OS_ANDROID) + addImportPath(QStringLiteral("qrc:/android_rcc_bundle/qml")); + if (Q_UNLIKELY(!qEnvironmentVariableIsEmpty("QT_BUNDLED_LIBS_PATH"))) { + const QString envImportPath = qEnvironmentVariable("QT_BUNDLED_LIBS_PATH"); + QLatin1Char pathSep(':'); + QStringList paths = envImportPath.split(pathSep, QString::SkipEmptyParts); + for (int ii = paths.count() - 1; ii >= 0; --ii) + addPluginPath(paths.at(ii)); + } +#endif } QQmlImportDatabase::~QQmlImportDatabase() @@ -1798,6 +1808,18 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader, if (!resolvedPath.endsWith(Slash)) resolvedPath += Slash; +#if defined(Q_OS_ANDROID) + if (qmldirPath.size() > 25 && qmldirPath.at(0) == QLatin1Char(':') && qmldirPath.at(1) == QLatin1Char('/') && + qmldirPath.startsWith(QStringLiteral(":/android_rcc_bundle/qml/"), Qt::CaseInsensitive)) { + QString pluginName = qmldirPath.mid(21) + Slash + baseName; + auto bundledPath = resolvedPath + QLatin1String("lib") + pluginName.replace(QLatin1Char('/'), QLatin1Char('_')); + for (const QString &suffix : suffixes) { + const QString absolutePath = typeLoader->absoluteFilePath(bundledPath + suffix); + if (!absolutePath.isEmpty()) + return absolutePath; + } + } +#endif resolvedPath += prefix + baseName; for (const QString &suffix : suffixes) { const QString absolutePath = typeLoader->absoluteFilePath(resolvedPath + suffix); -- cgit v1.2.3 From 50e76d84bf6935e5d517c64c46b32c50d1e14ba9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 10:53:49 +0200 Subject: qml: Make sure the qml tool deletes its application Otherwise the shutdown mechanism for debug services doesn't work. Fixes: QTBUG-78828 Change-Id: I4ede5861a300d5b5007036d71ed84409ec4d450f Reviewed-by: Shawn Rutledge Reviewed-by: Fabian Kosmale --- tools/qml/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 9edc90e050..daa278457d 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -60,6 +60,7 @@ #include #include +#include #include #if QT_CONFIG(qml_animation) #include @@ -68,6 +69,7 @@ #include #include #include +#include #define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms @@ -398,23 +400,23 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) int main(int argc, char *argv[]) { getAppFlags(argc, argv); - QCoreApplication *app = nullptr; + std::unique_ptr app; switch (applicationType) { #ifdef QT_GUI_LIB case QmlApplicationTypeGui: - app = new LoaderApplication(argc, argv); + app = qt_make_unique(argc, argv); break; #ifdef QT_WIDGETS_LIB case QmlApplicationTypeWidget: - app = new QApplication(argc, argv); - static_cast(app)->setWindowIcon(QIcon(iconResourcePath)); + app = qt_make_unique(argc, argv); + static_cast(app.get())->setWindowIcon(QIcon(iconResourcePath)); break; #endif // QT_WIDGETS_LIB #endif // QT_GUI_LIB case QmlApplicationTypeCore: Q_FALLTHROUGH(); default: // QmlApplicationTypeUnknown: not allowed, but we'll exit after checking apptypeOption below - app = new QCoreApplication(argc, argv); + app = qt_make_unique(argc, argv); break; } @@ -598,7 +600,7 @@ int main(int argc, char *argv[]) if (files.count() <= 0) { #if defined(Q_OS_DARWIN) if (applicationType == QmlApplicationTypeGui) - exitTimerId = static_cast(app)->startTimer(FILE_OPEN_EVENT_WAIT_TIME); + exitTimerId = static_cast(app.get())->startTimer(FILE_OPEN_EVENT_WAIT_TIME); else #endif noFilesGiven(); -- cgit v1.2.3 From abc0fc64b3d797af4d47cd2f7e3df68a3114c120 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 13:21:47 +0200 Subject: QQuickWindow: Don't leak the animation controller There are ways to close the window without hitting the code paths in the render loops that delete the animation controller. Probably if no frame was ever rendered. Change-Id: If3e9d2051525c4ff50eda19084c967578fe4f4b0 Reviewed-by: Simon Hausmann --- src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp | 2 +- src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp | 4 ++-- src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp | 2 +- src/quick/items/qquickrendercontrol.cpp | 3 +-- src/quick/items/qquickwindow.cpp | 2 +- src/quick/items/qquickwindow_p.h | 2 +- src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp | 2 +- .../adaptations/software/qsgsoftwarethreadedrenderloop.cpp | 5 +++-- src/quick/scenegraph/qsgrenderloop.cpp | 2 +- src/quick/scenegraph/qsgthreadedrenderloop.cpp | 5 +++-- src/quick/scenegraph/qsgwindowsrenderloop.cpp | 2 +- src/quick/util/qquickanimatorjob.cpp | 2 +- 12 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp index 0d501f48c0..4a6894e69e 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp @@ -148,7 +148,7 @@ void QSGD3D12RenderLoop::windowDestroyed(QQuickWindow *window) delete rc; delete engine; - delete wd->animationController; + wd->animationController.reset(); } void QSGD3D12RenderLoop::exposeWindow(QQuickWindow *window) diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp index f505df1e5a..4302a9119b 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp @@ -373,7 +373,7 @@ bool QSGD3D12RenderThread::event(QEvent *e) QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); if (wme->destroying) - delete wd->animationController; + wd->animationController.reset(); } if (wme->destroying) active = false; @@ -1006,7 +1006,7 @@ void QSGD3D12ThreadedRenderLoop::handleExposure(QQuickWindow *window) if (Q_UNLIKELY(debug_loop())) qDebug("starting render thread"); // Push a few things to the render thread. - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController.data(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); if (w->thread->thread() == QThread::currentThread()) { diff --git a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp index 94f7f76036..69b10fcdee 100644 --- a/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp +++ b/src/plugins/scenegraph/openvg/qsgopenvgrenderloop.cpp @@ -96,7 +96,7 @@ void QSGOpenVGRenderLoop::windowDestroyed(QQuickWindow *window) vg->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } void QSGOpenVGRenderLoop::exposureChanged(QQuickWindow *window) diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index 83b3372ed9..addd52cb1d 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -188,8 +188,7 @@ void QQuickRenderControlPrivate::windowDestroyed() if (window) { rc->invalidate(); - delete QQuickWindowPrivate::get(window)->animationController; - QQuickWindowPrivate::get(window)->animationController = nullptr; + QQuickWindowPrivate::get(window)->animationController.reset(); #if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl) if (QOpenGLContext::currentContext()) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index e00789be85..98f5d8a8c1 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -644,7 +644,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) q->setVulkanInstance(QSGRhiSupport::vulkanInstance()); #endif - animationController = new QQuickAnimatorController(q); + animationController.reset(new QQuickAnimatorController(q)); QObject::connect(context, SIGNAL(initialized()), q, SIGNAL(sceneGraphInitialized()), Qt::DirectConnection); QObject::connect(context, SIGNAL(invalidated()), q, SIGNAL(sceneGraphInvalidated()), Qt::DirectConnection); diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index becbae7fe3..7d1767c40e 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -254,7 +254,7 @@ public: QSGRenderLoop *windowManager; QQuickRenderControl *renderControl; - QQuickAnimatorController *animationController; + QScopedPointer animationController; QScopedPointer delayedTouch; int pointerEventRecursionGuard; diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp index f5a41410ee..c97dcb9326 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderloop.cpp @@ -100,7 +100,7 @@ void QSGSoftwareRenderLoop::windowDestroyed(QQuickWindow *window) rc->invalidate(); } - delete d->animationController; + d->animationController.reset(); } void QSGSoftwareRenderLoop::renderWindow(QQuickWindow *window, bool isNewExpose) diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp index 2d4dcd928d..c6b463bb02 100644 --- a/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp +++ b/src/quick/scenegraph/adaptations/software/qsgsoftwarethreadedrenderloop.cpp @@ -292,7 +292,7 @@ bool QSGSoftwareRenderThread::event(QEvent *e) QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); if (wme->destroying) - delete wd->animationController; + wd->animationController.reset(); } if (wme->destroying) active = false; @@ -844,7 +844,8 @@ void QSGSoftwareThreadedRenderLoop::handleExposure(QQuickWindow *window) if (!w->thread->isRunning()) { qCDebug(QSG_RASTER_LOG_RENDERLOOP, "starting render thread"); // Push a few things to the render thread. - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller + = QQuickWindowPrivate::get(w->window)->animationController.get(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); if (w->thread->thread() == QThread::currentThread()) { diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index e69d25aab3..ba231f8159 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -436,7 +436,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) gl->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } void QSGGuiThreadRenderLoop::handleDeviceLoss() diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 3689f6501f..86d9590863 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -564,7 +564,7 @@ void QSGRenderThread::invalidateGraphics(QQuickWindow *window, bool inDestructor QCoreApplication::processEvents(); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); if (inDestructor) - delete dd->animationController; + dd->animationController.reset(); if (current && gl) gl->doneCurrent(); qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- invalidating scene graph"); @@ -1302,7 +1302,8 @@ void QSGThreadedRenderLoop::handleExposure(QQuickWindow *window) } } - QQuickAnimatorController *controller = QQuickWindowPrivate::get(w->window)->animationController; + QQuickAnimatorController *controller + = QQuickWindowPrivate::get(w->window)->animationController.get(); if (controller->thread() != w->thread) controller->moveToThread(w->thread); diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 220c70c299..5b48b86568 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -269,7 +269,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window) m_gl->doneCurrent(); } - delete d->animationController; + d->animationController.reset(); } bool QSGWindowsRenderLoop::anyoneShowing() const diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp index 03be78ab15..a9caedec4f 100644 --- a/src/quick/util/qquickanimatorjob.cpp +++ b/src/quick/util/qquickanimatorjob.cpp @@ -207,7 +207,7 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window) stop(); } else if (!m_controller && m_job) { - m_controller = QQuickWindowPrivate::get(window)->animationController; + m_controller = QQuickWindowPrivate::get(window)->animationController.get(); if (window->isSceneGraphInitialized()) readyToAnimate(); else -- cgit v1.2.3 From 291d118b0f4cc2f53e2fb8ca0778d421fcf5c845 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 27 Sep 2019 17:01:27 +0200 Subject: Examples: Avoid Qt.createQmlObject() We don't want to encourage Qt.createQmlObject(). It's the equivalent of eval() in JavaScript. This has the added benefit that the shapes actually react to changes in the parameters now. Before, once a shape was drawn, it didn't get updated when you manipulated the line width or fill controls. Change-Id: I8d5b7598799b52043f86fd1f617e31de09331891 Reviewed-by: Simon Hausmann Reviewed-by: Fabian Kosmale --- examples/quick/shapes/content/interactive.qml | 113 ++++++++++++++++++++------ 1 file changed, 86 insertions(+), 27 deletions(-) diff --git a/examples/quick/shapes/content/interactive.qml b/examples/quick/shapes/content/interactive.qml index 55a1d16299..78413db3f9 100644 --- a/examples/quick/shapes/content/interactive.qml +++ b/examples/quick/shapes/content/interactive.qml @@ -170,14 +170,45 @@ Rectangle { property variant resizers: [] property variant funcs + property Component mouseArea: Component { + Rectangle { + id: rr + + property variant obj + property string xprop + property string yprop + + width: 20 + height: 20 + + MouseArea { + property bool a: false + + anchors.fill: parent + hoverEnabled: true + onEntered: color = "yellow" + onExited: color = rr.color + onPressed: a = true + onReleased: a = false + onPositionChanged: { + if (a) { + var pt = mapToItem(rr.parent, mouse.x, mouse.y); + rr.obj[rr.xprop] = pt.x + rr.obj[rr.yprop] = pt.y + rr.x = pt.x - 10 + rr.y = pt.y - 10 + } + } + } + } + } + function genResizer(obj, x, y, xprop, yprop, color) { - var ma = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; Rectangle { id: rr; property variant obj; color: "' + color + '"; width: 20; height: 20;'+ - 'MouseArea { anchors.fill: parent; hoverEnabled: true;' + - 'onEntered: color = "yellow"; onExited: color = "' + color + '";' + - 'property bool a: false; onPressed: a = true; onReleased: a = false; ' + - 'onPositionChanged: if (a) { var pt = mapToItem(rr.parent, mouse.x, mouse.y);' + - 'obj.' + xprop + ' = pt.x; obj.' + yprop + ' = pt.y; rr.x = pt.x - 10; rr.y = pt.y - 10; } } }', - canvas, "resizer_item"); + var ma = mouseArea.createObject(canvas, { + color: color, + xprop: xprop, + yprop: yprop + }); ma.visible = root.showResizers; ma.obj = obj; ma.x = x - 10; @@ -186,15 +217,55 @@ Rectangle { return ma; } + property Component linePath: Component { + ShapePath { + id: lineShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: "transparent" + PathLine { + x: lineShapePath.startX + 1 + y: lineShapePath.startY + 1 + } + } + } + + property Component cubicPath: Component { + ShapePath { + id: cubicShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: root.fill ? 'green' : 'transparent' + PathCubic { + x: cubicShapePath.startX + 1 + y: cubicShapePath.startY + 1 + control1X: cubicShapePath.startX + 50; + control1Y: cubicShapePath.startY + 50; + control2X: cubicShapePath.startX + 150; + control2Y: cubicShapePath.startY + 50; + } + } + } + + property Component quadPath: Component { + ShapePath { + id: quadShapePath + strokeColor: "black" + strokeWidth: widthSlider.value + fillColor: root.fill ? 'green' : 'transparent' + PathQuad { + x: quadShapePath.startx + 1 + y: quadShapePath.startY + 1 + controlX: quadShapePath.startX + 50 + controlY: quadShapePath.startY + 50 + } + } + } + Component.onCompleted: { funcs = [ { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "transparent";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathLine { x: ' + x + ' + 1; y: ' + y + ' + 1 } }', - root, "dynamic_visual_path"); + var p = linePath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { @@ -211,13 +282,7 @@ Rectangle { } }, { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "' + (root.fill ? 'green' : 'transparent') + '";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathCubic { x: ' + x + ' + 1; y: ' + y + ' + 1;' + - 'control1X: ' + x + ' + 50; control1Y: ' + y + ' + 50; control2X: ' + x + ' + 150; control2Y: ' + y + ' + 50; } }', - root, "dynamic_visual_path"); + var p = cubicPath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { @@ -236,13 +301,7 @@ Rectangle { } }, { "start": function(x, y) { - var p = Qt.createQmlObject('import QtQuick 2.9; import QtQuick.Shapes 1.0; ShapePath {' + - 'strokeColor: "black"; fillColor: "' + (root.fill ? 'green' : 'transparent') + '";'+ - 'strokeWidth: ' + widthSlider.value + ';' + - 'startX: ' + x + '; startY: ' + y + ';' + - 'PathQuad { x: ' + x + ' + 1; y: ' + y + ' + 1;' + - 'controlX: ' + x + ' + 50; controlY: ' + y + ' + 50 } }', - root, "dynamic_visual_path"); + var p = quadPath.createObject(root, { startX: x, startY: y }); shape.data.push(p); activePath = p; }, "move": function(x, y) { -- cgit v1.2.3 From dae5bc672eb177ec858f035e0976e8ad93ca59b3 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 27 Sep 2019 15:55:36 +0200 Subject: qmlplugindump: Consistently sort composite types Previously the sorting depended on qHash(QQmlType), which hashes a pointer to QQmlTypePrivate. That was not very useful. Also, the defaultCompositeTypes were only populated when dumping builtins, and only used when dumping regular types. Therefore, whenever they were used, they were empty. We don't have to bother with that. Change-Id: Ibfbfc7e14bee900d617bab58cbe39d05f5fe91c3 Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- tools/qmlplugindump/main.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index 196d6e39e6..5e999c557a 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -236,14 +236,14 @@ QByteArray convertToId(const QMetaObject *mo) // Collect all metaobjects for types registered with qmlRegisterType() without parameters void collectReachableMetaObjectsWithoutQmlName(QQmlEnginePrivate *engine, QSet& metas, - QMap> &compositeTypes, const QmlVersionInfo &info) { + QMap> &compositeTypes, const QmlVersionInfo &info) { const auto qmlAllTypes = QQmlMetaType::qmlAllTypes(); for (const QQmlType &ty : qmlAllTypes) { if (!metas.contains(ty.baseMetaObject())) { if (!ty.isComposite()) { collectReachableMetaObjects(engine, ty, &metas, info); } else if (matchingImportUri(ty, info)) { - compositeTypes[ty.elementName()].insert(ty); + compositeTypes[ty.elementName()].append(ty); } } } @@ -252,7 +252,7 @@ void collectReachableMetaObjectsWithoutQmlName(QQmlEnginePrivate *engine, QSet collectReachableMetaObjects(QQmlEngine *engine, QSet &noncreatables, QSet &singletons, - QMap> &compositeTypes, + QMap> &compositeTypes, const QmlVersionInfo &info, const QList &skip = QList() ) @@ -272,7 +272,7 @@ QSet collectReachableMetaObjects(QQmlEngine *engine, qmlTypesByCppName[ty.baseMetaObject()->className()].insert(ty); collectReachableMetaObjects(QQmlEnginePrivate::get(engine), ty, &metas, info); } else { - compositeTypes[ty.elementName()].insert(ty); + compositeTypes[ty.elementName()].append(ty); } } @@ -465,7 +465,7 @@ public: return prototypeName; } - void dumpComposite(QQmlEngine *engine, const QSet &compositeType, QSet &defaultReachableNames, const QmlVersionInfo &versionInfo) + void dumpComposite(QQmlEngine *engine, const QList &compositeType, QSet &defaultReachableNames, const QmlVersionInfo &versionInfo) { for (const QQmlType &type : compositeType) dumpCompositeItem(engine, type, defaultReachableNames, versionInfo); @@ -998,6 +998,16 @@ void printDebugMessage(QtMsgType, const QMessageLogContext &, const QString &msg // In case of QtFatalMsg the calling code will abort() when appropriate. } +QT_BEGIN_NAMESPACE +static bool operator<(const QQmlType &a, const QQmlType &b) +{ + return a.qmlTypeName() < b.qmlTypeName() + || (a.qmlTypeName() == b.qmlTypeName() + && ((a.majorVersion() < b.majorVersion()) + || (a.majorVersion() == b.majorVersion() + && a.minorVersion() < b.minorVersion()))); +} +QT_END_NAMESPACE int main(int argc, char *argv[]) { @@ -1228,7 +1238,6 @@ int main(int argc, char *argv[]) // find all QMetaObjects reachable from the builtin module QSet uncreatableMetas; QSet singletonMetas; - QMap> defaultCompositeTypes; // QQuickKeyEvent, QQuickPinchEvent, QQuickDropEvent are not exported QSet defaultReachableNames; @@ -1237,11 +1246,12 @@ int main(int argc, char *argv[]) QSet metas; // composite types we want to dump information of - QMap> compositeTypes; + QMap> compositeTypes; int majorVersion = qtQmlMajorVersion, minorVersion = qtQmlMinorVersion; QmlVersionInfo info; if (action == Builtins) { + QMap> defaultCompositeTypes; QSet builtins = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, defaultCompositeTypes, {QLatin1String("Qt"), majorVersion, minorVersion, strict}); Q_ASSERT(builtins.size() == 1); metas.insert(*builtins.begin()); @@ -1305,12 +1315,9 @@ int main(int argc, char *argv[]) info = {pluginImportUri, majorVersion, minorVersion, strict}; QSet candidates = collectReachableMetaObjects(&engine, uncreatableMetas, singletonMetas, compositeTypes, info, defaultTypes); - for (QString iter: compositeTypes.keys()) { - if (defaultCompositeTypes.contains(iter)) { - QSet compositeTypesByName = compositeTypes.value(iter); - compositeTypesByName.subtract(defaultCompositeTypes.value(iter)); - compositeTypes[iter] = compositeTypesByName; - } + for (auto it = compositeTypes.begin(), end = compositeTypes.end(); it != end; ++it) { + std::sort(it->begin(), it->end()); + it->erase(std::unique(it->begin(), it->end()), it->end()); } for (const QMetaObject *mo : qAsConst(candidates)) { @@ -1361,7 +1368,7 @@ int main(int argc, char *argv[]) dumper.dump(QQmlEnginePrivate::get(&engine), meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta)); } - QMap >::const_iterator iter = compositeTypes.constBegin(); + QMap>::const_iterator iter = compositeTypes.constBegin(); for (; iter != compositeTypes.constEnd(); ++iter) dumper.dumpComposite(&engine, iter.value(), defaultReachableNames, info); -- cgit v1.2.3 From ee9319f63c2e9d307bcda41669aaed9934d013ad Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 2 Oct 2019 15:04:53 +0200 Subject: QQmlBind: Mark restoreMode as explicitly also when set to default value Change-Id: I8aa36cbba95a64498b34c689086e45c115ce542b Reviewed-by: Simon Hausmann --- src/qml/types/qqmlbind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 861243987f..9d305cd24c 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -382,10 +382,10 @@ QQmlBind::RestorationMode QQmlBind::restoreMode() const void QQmlBind::setRestoreMode(RestorationMode newMode) { Q_D(QQmlBind); + d->restoreModeExplicit = true; if (newMode != restoreMode()) { d->restoreValue = (newMode & RestoreValue); d->restoreBinding = (newMode & RestoreBinding); - d->restoreModeExplicit = true; emit restoreModeChanged(); } } -- cgit v1.2.3 From 5bc1ae578ed79ef295e86901e4620d9c37687ed7 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 2 Oct 2019 16:42:33 +0200 Subject: Fix device pixel ratio with QRhi for native text Calculating values based on the dpr is not possible in the sync phase, because the strictly correct dpr (that takes redirections into textures into account) is not known until QQuickWindowPrivate::renderSceneGraph(). The text material implementation attempts to dig out something directly from the context's associated surface, but this does not match the way QQuickWindow calculates the value (although it would work without causing any trouble in many cases). This is of course incompatible with the QRhi-based abstraction since neither the context nor the associated window (if there is one even) is known to materials. To solve this, create a proper solution that makes the QQuickWindow-calculated dpr available already in the sync phase (so in updatePaintNode() implementations): have QQuickWindow calculate calculate the dpr in syncSceneGraph(), and pass it down via the rendercontext. Only the rhi-based code path is touched in this patch. The direct OpenGL path could be fixed in a similar manner (by migrating to rc->devicePixelRatio() in the sync phase and state.devicePixelRatio() in the render phase), but that is left as a future exercise. Task-number: QTBUG-78610 Change-Id: Id9d9d4b1fd5b9730a64834fbbf61c74af4a8ed07 Reviewed-by: Paul Olav Tvete --- src/quick/items/qquickwindow.cpp | 7 +++++++ src/quick/scenegraph/qsgcontext.cpp | 5 +++++ src/quick/scenegraph/qsgcontext_p.h | 1 + src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 10 +++++----- src/quick/scenegraph/qsgdefaultrendercontext.cpp | 5 +++++ src/quick/scenegraph/qsgdefaultrendercontext_p.h | 13 +++++++++++++ 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 98f5d8a8c1..1b766de007 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -424,6 +424,13 @@ void QQuickWindowPrivate::syncSceneGraph() { Q_Q(QQuickWindow); + // Calculate the dpr the same way renderSceneGraph() will. + qreal devicePixelRatio = q->effectiveDevicePixelRatio(); + if (renderTargetId && !QQuickRenderControl::renderWindowFor(q)) + devicePixelRatio = 1; + + context->prepareSync(devicePixelRatio); + animationController->beforeNodeSync(); emit q->beforeSynchronizing(); diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 97fd49e4c7..17eb1e312c 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -341,6 +341,11 @@ void QSGRenderContext::invalidate() { } +void QSGRenderContext::prepareSync(qreal devicePixelRatio) +{ + Q_UNUSED(devicePixelRatio); +} + void QSGRenderContext::beginNextFrame(QSGRenderer *renderer, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h index 4e712ab7c3..244bcfabd1 100644 --- a/src/quick/scenegraph/qsgcontext_p.h +++ b/src/quick/scenegraph/qsgcontext_p.h @@ -174,6 +174,7 @@ public: using RenderPassCallback = void (*)(void *); + virtual void prepareSync(qreal devicePixelRatio); virtual void beginNextFrame(QSGRenderer *renderer, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 4eba40b7a1..be6ef25feb 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -751,15 +751,15 @@ void QSGTextMaskMaterial::updateCache(QFontEngine::GlyphFormat glyphFormat) void *cacheKey; if (m_rhi) { cacheKey = m_rhi; - // ### no idea what the QWindow is (esp. since we are not even - // rendering at this point), and anyway is the original logic correct - // even... - devicePixelRatio = qGuiApp->devicePixelRatio(); + // Get the dpr the modern way. This value retrieved via the + // rendercontext matches what RenderState::devicePixelRatio() + // exposes to the material shaders later on. + devicePixelRatio = m_rc->currentDevicePixelRatio(); } else { ctx = const_cast(QOpenGLContext::currentContext()); Q_ASSERT(ctx != nullptr); cacheKey = ctx; - devicePixelRatio = qsg_device_pixel_ratio(ctx); + devicePixelRatio = qsg_device_pixel_ratio(ctx); // this is technically incorrect, see other branch above } QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio); diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp index 4ccaa91cce..2bf4a83a8e 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp +++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp @@ -200,6 +200,11 @@ void QSGDefaultRenderContext::invalidate() emit invalidated(); } +void QSGDefaultRenderContext::prepareSync(qreal devicePixelRatio) +{ + m_currentDevicePixelRatio = devicePixelRatio; +} + static QBasicMutex qsg_framerender_mutex; void QSGDefaultRenderContext::beginNextFrame(QSGRenderer *renderer, diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h index 6a3462ae2b..2fdb3a48dd 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h +++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h @@ -104,6 +104,7 @@ public: void initialize(const QSGRenderContext::InitParams *params) override; void invalidate() override; + void prepareSync(qreal devicePixelRatio) override; void beginNextFrame(QSGRenderer *renderer, RenderPassCallback mainPassRecordingStart, RenderPassCallback mainPassRecordingEnd, @@ -151,6 +152,17 @@ public: return m_currentFrameRenderPass; } + qreal currentDevicePixelRatio() const + { + // Valid starting from QQuickWindow::syncSceneGraph(). This takes the + // redirections, e.g. QQuickWindow::setRenderTarget(), into account. + // This calculation logic matches what the renderer does, so this is + // the same value that gets exposed in RenderState::devicePixelRatio() + // to material shaders. This getter is useful to perform dpr-related + // operations in the sync phase (in updatePaintNode()). + return m_currentDevicePixelRatio; + } + protected: static QString fontKey(const QRawFont &font); @@ -166,6 +178,7 @@ protected: QSGRhiAtlasTexture::Manager *m_rhiAtlasManager; QRhiCommandBuffer *m_currentFrameCommandBuffer; QRhiRenderPassDescriptor *m_currentFrameRenderPass; + qreal m_currentDevicePixelRatio; }; QT_END_NAMESPACE -- cgit v1.2.3 From f500bd1609c685347a0435c9d3887bfcd65e41a6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 28 Sep 2019 17:21:03 +0200 Subject: Drop QVector for srb and shader stage descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow the QRhi changes that move away from QVector in QRhiShaderResourceBindings and QRhiGraphicsPipeline. This, together with QRhi's de-d-pointering of QRhiShaderResourceBinding, is bringing significant performance improvements for scenes with a lot (thousands) of unbatched items, since a large number of allocations are now avoided due to not having to create a QVector of d-pointered classes just to do a lookup in the srb cache. Change-Id: I612ab2d9449a9e0ce79f7169b942b95d55af61ff Reviewed-by: Christian Strømme --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 12 ++++++------ src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h | 10 ++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 37deaa35dd..c30ed7cef4 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -400,14 +400,14 @@ void ShaderManager::clearCachedRendererData() } } -QRhiShaderResourceBindings *ShaderManager::srb(const QVector &bindings) +QRhiShaderResourceBindings *ShaderManager::srb(const ShaderResourceBindingList &bindings) { auto it = srbCache.constFind(bindings); if (it != srbCache.constEnd()) return *it; QRhiShaderResourceBindings *srb = context->rhi()->newShaderResourceBindings(); - srb->setBindings(bindings); + srb->setBindings(bindings.cbegin(), bindings.cend()); if (srb->build()) { srbCache.insert(bindings, srb); } else { @@ -3253,7 +3253,7 @@ bool Renderer::ensurePipelineState(Element *e, const ShaderManager::Shader *sms) // Build a new one. This is potentially expensive. QRhiGraphicsPipeline *ps = m_rhi->newGraphicsPipeline(); - ps->setShaderStages(sms->programRhi.shaderStages); + ps->setShaderStages(sms->programRhi.shaderStages.cbegin(), sms->programRhi.shaderStages.cend()); ps->setVertexInputLayout(sms->programRhi.inputLayout); ps->setShaderResourceBindings(e->srb); ps->setRenderPassDescriptor(renderPassDescriptor()); @@ -3428,7 +3428,7 @@ static void materialToRendererGraphicsState(GraphicsState *dst, void Renderer::updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, - QVector *bindings, + ShaderManager::ShaderResourceBindingList *bindings, const Batch *batch, int ubufOffset, int ubufRegionSize) // RHI only, [prepare step] @@ -3630,7 +3630,7 @@ bool Renderer::prepareRenderMergedBatch(Batch *batch, PreparedRenderBatch *rende bool pendingGStatePop = false; updateMaterialStaticData(sms, renderState, material, batch, &pendingGStatePop); - QVector bindings; + ShaderManager::ShaderResourceBindingList bindings; updateMaterialDynamicData(sms, renderState, material, &bindings, batch, 0, ubufSize); #ifndef QT_NO_DEBUG @@ -3824,7 +3824,7 @@ bool Renderer::prepareRenderUnmergedBatch(Batch *batch, PreparedRenderBatch *ren } QSGMaterialRhiShader::RenderState renderState = rhiState(QSGMaterialRhiShader::RenderState::DirtyStates(int(dirty))); - QVector bindings; + ShaderManager::ShaderResourceBindingList bindings; updateMaterialDynamicData(sms, renderState, material, &bindings, batch, ubufOffset, ubufSize); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 5390e14c77..297df2232a 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -642,7 +642,7 @@ public: struct { QSGMaterialRhiShader *program = nullptr; QRhiVertexInputLayout inputLayout; - QVector shaderStages; + QVarLengthArray shaderStages; } programRhi; float lastOpacity; @@ -656,7 +656,9 @@ public: void clearCachedRendererData(); - QRhiShaderResourceBindings *srb(const QVector &bindings); + using ShaderResourceBindingList = QVarLengthArray; + + QRhiShaderResourceBindings *srb(const ShaderResourceBindingList &bindings); public Q_SLOTS: void invalidated(); @@ -672,7 +674,7 @@ private: QOpenGLShaderProgram *blitProgram; QSGDefaultRenderContext *context; - QHash, QRhiShaderResourceBindings *> srbCache; + QHash srbCache; }; struct GraphicsState @@ -797,7 +799,7 @@ private: bool ensurePipelineState(Element *e, const ShaderManager::Shader *sms); QRhiTexture *dummyTexture(); void updateMaterialDynamicData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState, - QSGMaterial *material, QVector *bindings, + QSGMaterial *material, ShaderManager::ShaderResourceBindingList *bindings, const Batch *batch, int ubufOffset, int ubufRegionSize); void updateMaterialStaticData(ShaderManager::Shader *sms, QSGMaterialRhiShader::RenderState &renderState, QSGMaterial *material, Batch *batch, bool *gstateChanged); -- cgit v1.2.3 From c211b93bb87308601fe1c808634eb648d1949c40 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 3 Oct 2019 17:09:13 +0200 Subject: Temporarily drop a debug mode check in rhi-based stenciling ...to avoid blocking the next submodule update. Can be restored afterwards. There is no temporary compatibility function for the QVector-based getters in qtbase. This got overlooked probably because it is in a block that is there in debug builds only. Change-Id: I3de3f48934e6a31cc14a90f306fddfa04ac56f41 Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index c30ed7cef4..29923b5d20 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -2849,8 +2849,10 @@ void Renderer::updateClipState(const QSGClipNode *clipList, Batch *batch) // RHI else { if (qsg_topology(g->drawingMode()) != m_stencilClipCommon.topology) qWarning("updateClipState: Clip list entries have different primitive topologies, this is not currently supported."); +#if 0 // ### restore once the 5.14 submodule update is done if (qsg_vertexInputFormat(*a) != m_stencilClipCommon.inputLayout.attributes().first().format()) qWarning("updateClipState: Clip list entries have different vertex input layouts, this is must not happen."); +#endif } #endif -- cgit v1.2.3