aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
Commit message (Collapse)AuthorAgeFilesLines
* qmltc: export generated classesSami Shalayel2023-02-026-0/+81
| | | | | | | | | | | | | | | | | | | | | | Add QMLTC_EXPORT_MACRO_NAME and QMLTC_EXPORT_FILE_NAME arguments to qt_add_qml_module() that allows the user to export qmltc-generated code from its library. The qmltc-generated code will include the header-file specified in QMLTC_EXPORT_FILE_NAME and will be exported with the macro specified by QMLTC_EXPORT_MACRO_NAME. Leave both options unspecified to not export the code generated by qmltc. Describe the options in the documentation and write a test to see if the class really has an export macro in the generated code: 1) tst_qmltc_qprocess will test if the macro and the header are correctly inserted in the generated code. 2) tst_qmltc_{no,}diskcache will test if the generated code can still be used from a static library. Fixes: QTBUG-106840 Task-number: QTBUG-96040 Change-Id: I554f03bcdf043e8114e42f51a7289a5c00de4f89 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* loadFromModule: Properly handle QML only modulesFabian Kosmale2023-02-024-0/+16
| | | | | | | | | | | | | | | QQmlMetaType::typeModule only returns a sensible result for modules with some C++ integration. That is not the case for a pure QML module (qmldir put into an import path). Detect the missing module case by instead checking whether addImport failed to handle the module (either returning false, or returning true but with unresolved imports). Fixes: QTBUG-110882 Pick-to: 6.5 Change-Id: I7b25e225e1a34ec91f7ce4d9f4a182a24168ba47 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* add QML_UNCREATABLE in the testsSami Shalayel2023-02-024-1/+4
| | | | | | | | | Add the QML_UNCREATABLE macros in the tests where it is missing. Change-Id: I58ef5a27e15f0bb99bc94bf819b38aaad3358432 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qt_add_qml_module: Make usage of AUTO_RESOURCE_PREFIX a policyFabian Kosmale2023-02-016-0/+6
| | | | | | | | | | | | | | | | Writing AUTO_RESOURCE_PREFIX in every qt_add_qml_module call seems rather pointless. In addition: - Add documentation for QTP0001. - Adjust some of the examples to use QTP0001 policy. - Improved the error message. Pick-to: 6.5 Task-number: QTBUG-96233 Change-Id: I6e19a491acba97493893bf1953fca3462296c1ea Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* qmlcachegen: fix nonstrict equality code generationSemih Yavuz2023-01-312-1/+12
| | | | | | | | | | | | | | We should generate type checking code for only strict comparison of var against null/undefined types or vice versa cases. The non- strict comparison should be handled elsewhere. Removed pragma Strict to allow to add warning emitting tests of non-strict comparison. This amends 6a816a9e0dfc2b41a4f86c721679f2517ec27eb6 Pick-to: 6.5 Fixes: QTBUG-110769 Change-Id: I7f9a457e71a621a005f377216e841bec01667454 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlcachegen: Improve QObject comparison code generation testSemih Yavuz2023-01-312-0/+15
| | | | | | | | | | | | The code generated for QObject comparisons holds for both weak and strong comparisons. Improve tst_qmlcppcodegen by adding missing weak comparison tests. Amends afc7928d1a1e47ecbc9d101c4e5d5fb1c5b78326. Pick-to: 6.5 Change-Id: Ib6176a39b329e792b81b3d8e8a288dcea074320b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Item views: Don't create unnecessary QML contextsUlf Hermann2023-01-312-0/+25
| | | | | | | | | | | | | | | Bound components can only be instantiated in the context they're declared in. Adding a context in between before instantiating a component makes it impossible to bind the component. We want to use bound components so that we can safely use IDs of other objects from the same context inside the objects created from the component. See also commit fc683799fee933757abdd3953048f136e750690b. Pick-to: 6.5 Fixes: QTBUG-110697 Change-Id: I8ac9afe13a3d88a4c8e432f5cd701abee8a7f6ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qqmlvaluetypeproviders: Choose a date in the middle of the monthUlf Hermann2023-01-311-0/+1
| | | | | | | | | | | | If we don't set the date on the date value to be tested, it will be the current date. If the current date doesn't exist in the month we set, we get garbage. Pick-to: 6.5 Fixes: QTBUG-110793 Change-Id: I91db0974e10e11ebce5ddce60f1594285da6fb3f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML test: Fix annoying warning in tst_animatedimage.qmlVladimir Belyavsky2023-01-301-1/+1
| | | | | | | | | Fix a bunch of warnings "tst_animatedimage.qml:90:17: TypeError: Cannot read property 'width' of null" during the test run. Pick-to: 6.5 Change-Id: I9a1fcd5d8e2ff81768bed1cd1fb94f22940c617b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QmlCompiler: Fix version resolution for importsUlf Hermann2023-01-304-9/+16
| | | | | | | | | | Partially versioned imports should not be sorted useing the generic comparison operators. We have to check each component individually. Pick-to: 6.5 Fixes: QTBUG-110320 Change-Id: Id75ab73ff6a4b5b040b9fcbb426e6bcf893d3d8b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* ListModel: Use PersistentValue to keep track of objectsUlf Hermann2023-01-302-1/+42
| | | | | | | | | | | | | This is the simplest way to prevent the garbage collector from destroying the object while at the same time allowing a manual destruction. Pick-to: 6.5 6.4 6.2 Task-number: QTBUG-95895 Task-number: QTBUG-96167 Fixes: QTBUG-91390 Change-Id: Ic3f3146bc555991068ce3367971e050f745d235d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-2718-19/+4
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Turn singleton/type mismatch into a run time type errorUlf Hermann2023-01-2710-18/+74
| | | | | | | | | | | | | | | | | | | | | | | There are many ways to "hide" the qmldir from the engine at run time, which turns singletons into regular types. While all of this is invalid, we should not assert on it, but rather produce a legible warning. Furthermore, sharpen the importing of extra modules from qrc as implicit imports. We should really only import modules the file in question can ever be part of. Otherwise we needlessly produce the above situation and hide legitimate warning messages. Amends commit 7517c1b3ae9aa92f36b19d74a4b2de5e8531309b. Now we need to teach our tools about the default import paths in the resorurce file system. They cannot guess any type they may find in any resource file anymore. Pick-to: 6.5 Task-number: QTBUG-106929 Change-Id: Ic8c02396d10830a7f461e8a81649bb8c9a1add1f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlformat: Add ECMAScript class reformatterSemih Yavuz2023-01-263-0/+85
| | | | | | | | | | | qmlformat currently discards ES classes, and only reformats the element list inside that class. Implement a class declaration visitor which reformats ES classes in qml file. Pick-to: 6.5 6.2 Fixes: QTBUG-110321 Change-Id: I9fa2561902dbcfde5e8fb041bc5dedcc56bb66cc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Do not warn when accessing properties of global constructorsFabian Kosmale2023-01-262-0/+6
| | | | | | | | | | | | | | | | | | | We are treating global constructor functions as methods. But while they are callable, they also have properties that can be accessed. Accessing those should not trigger any warning. However, prior to this commit, any property access to a method would yield a warning. As we don't store the list of known properties in the jsroot.qmltypes, we cannot really validate them. Moreover, it is also possilbe to extend the prototypes, so it might never be feasible to generate warnings. Thus, for now simply don't create warnings for JS globals in QQmlJSTypePropagator::isRestricted. Fixes: QTBUG-109204 Pick-to: 6.5 6.4 Change-Id: I992365ea716827a562886d7204b2401062772f9a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Allow more conversions between different listsUlf Hermann2023-01-262-0/+24
| | | | | | | | | | You should be able to assign any list of QObjects to any other list of QObjects. Pick-to: 6.5 Fixes: QTBUG-108155 Change-Id: I6ddf0b49f7248ad56cc9560d217f3ea316c648a8 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* AnimatedImage: Add ability to configure sourceSizeVladimir Belyavsky2023-01-262-6/+13
| | | | | | | | | | | | | This allows to reduce memory consumption and improve performance when you need to load and play hi-res GIF files or animated SVG. [ChangeLog][QtQuick][AnimatedImage] It's now possible to configure sourceSize property for AnimatedImage. This might be useful when you need e.g. to play hi-res GIF files in some smaller size. Fixes: QTBUG-57501 Change-Id: I26d464855bbc20e155a8fb589a48842986a3dea4 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Binding: Accept local signal handlers againUlf Hermann2023-01-252-0/+19
| | | | | | | | Pick-to: 6.4 6.5 Fixes: QTBUG-110628 Change-Id: Ifc5023a3bfeb575df3102c3ea363903ebffa88ba Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Fix interceptors on value types ignoring fast changesUlf Hermann2023-01-252-0/+39
| | | | | | | | | | | | | | | | | | | | | | If a property is changed and reverted in short order, any animation attached to it may not get a chance to take effect in between. In such a case it looks like we don't have to update the interceptor when reverting, but we actually have to. The animation needs to be canceled, after all. We now have to fix the case of writing different properties of a value type sequentially, where one has an animation attached to it, though. If that happens, we cannot drop the animation when a _different_ property is written later on, but we do still have to update the whole value type. So, pass an additional argument in the relevant metacalls that declares the property we intended to change. Pick-to: 6.5 Fixes: QTBUG-54860 Change-Id: I3b6cad2d4707d30312cda98283928fd419c40345 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QML: Allow converting any object list to QQmlListPropertyUlf Hermann2023-01-252-0/+8
| | | | | | | | | We can use QSequentialIterable for this. Pick-to: 6.5 Fixes: QTBUG-110438 Change-Id: I7e82d0f089c9bb9eab46be46dedc2db3726e64b0 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltyperegistrar: Strip '*' from list value typesUlf Hermann2023-01-254-2/+40
| | | | | | | | | | | | | | | | | We do this for function return types, property types, and function argument types already. Formally, we would have to store some "isPointer" somewhere, but considering that we never read it anyway, let's not go there. This allows the compilers to recognize lists of QObject-derived types as proper lists. This way we can generate better code for moving them around or getting their length. Pick-to: 6.5 Task-number: QTBUG-110438 Change-Id: I35e0fc21d574afc18799e9c3cef402f05b60a3ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* tst_qmlcppcodegen: Add QML dependency for AndroidFabian Kosmale2023-01-253-4/+9
| | | | | | | | | | | | qmlimportscanner is rather limited in how it works, and does not pick up the Qt.labs.folderlistmodel dependency for Dialogs. Pick-to: 6.5 Fixes: QTBUG-103044 Change-Id: I778f5c8981f1a2603bc3a5d2fd249a83de6c9bd8 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltyperegistrar: Use base of the current major version by defaultUlf Hermann2023-01-253-1/+9
| | | | | | | | | | | We had accidentally changed it to always export the tip of the current major version by default. Amends commit aba13583ac1e42ca1a8b0c0a0fac9e0ec3d72460. Pick-to: 6.5 Change-Id: I2ab7da1136cf05041f663a14e1c67383974767b0 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Fix crash in ListView with PullBackHeader/FooterRobert Griebl2023-01-253-0/+65
| | | | | | | | | | | | | | | | | | The header/footer positioning code would otherwise call qBound() with max < min when a PullBackHeader/Footer is used and the delegates do not fill the whole content area (i.e. the list does not need scrolling). After qtbase ad5c5bb541ae20a205ac07122153b302dee1d3e1 that was causing an assertion failure. Even though relying on the old qBound() behavior seems strange, it does produce the correct header/footer positioning, while swapping the min/max values (in case max < min) does not. So we need to call qMin and qMax explicitly rather than using qBound, to avoid the assert. Task-number: QTBUG-104679 Pick-to: 6.4 6.5 Change-Id: Iefc50e347e77ed51c6d90ddbc6e1cf21d76fc62c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQuickMouseArea: do not overload pressed-signalSami Shalayel2023-01-246-43/+43
| | | | | | | | | | | Renames the pressed() getter of the pressed property in QQuickMouseArea to isPressed() to avoid overloading the pressed()-signal. Signals should not be overloaded. Also, it makes code generation in qmltc more complicated. Task-number: QTBUG-110029 Change-Id: I2373f4fe97b1e955b815825003bc746f2eaf43be Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QML: Output a warning for creatable object types without default ctorUlf Hermann2023-01-235-0/+296
| | | | | | | | Pick-to: 6.5 Fixes: QTBUG-104899 Change-Id: I237ddb68968b26c1ce41051ab3bd3c66fb1712f1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QmlCompiler: Wrap sequences with unknown elemnts in QVariantListUlf Hermann2023-01-232-0/+2
| | | | | | | | | | | Otherwise we later try to perform value type lookups on them. That won't work. Pick-to: 6.5 Task-number: QTBUG-110438 Change-Id: I1690a3375841ba5a1ff1a471a7f88bd2023ab4c4 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlImport: Handle file selectors in qmldirFabian Kosmale2023-01-236-1/+57
| | | | | | | | | | | | | With file selectors, a type can exist in the same version under different paths. Detect this case, canonicalize the filename to the selector free version, and rely on the engine to resolve a URL to the correct file. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-107797 Change-Id: I0f74fd37936abfa08547fb439bfa5264e6ca4787 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlformat: fix omitting some comments while reformattingSemih Yavuz2023-01-233-0/+29
| | | | | | | | | | | | | | | We rewrite comments associated to a node on the preVisit call (if they were marked as preComment), or postVisit( if comments were marked as postComments) of the reformatter. If the comment associated with a patternProperty kind of node, neither of these functions are called. Add missing call to previsit/postVist in the pattern property node visit. Pick-to: 6.4 6.5 Fixes: QTBUG-109074 Change-Id: If57968b3f5dbd83aa23dc2cd2bca3608ee841d49 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Move qmlControlSanity loggers into a pluginSemih Yavuz2023-01-239-40/+226
| | | | | | | | | | | | | | QmlImportVisitor has some log messages that is only used for controls sanity tests. Move these loggers into a QuickControlsSanity plugin. Move the relevant tests from tst_qmllint to tst_sanity as we link the plugin to tst_sanity. Also remove qmlControlsSanity category from the default categories of QQmlJsLogger as it should be only utilised by this plugin. Task-number: QTBUG-103276 Change-Id: Iacc624711a2cd00aeb9d89fbde7c0131896d30ce Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: Fix object countingUlf Hermann2023-01-234-0/+71
| | | | | | | | | | | | We're not actually interested in whether an object is a window, and we don't really care how many objects are created. The only thing we need to know is whether at least one object is alive after all files have been processed. Pick-to: 6.5 Fixes: QTBUG-110112 Change-Id: I8d79359f3fb7ec5a54545dc5858cf310b0f52935 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Controls: Fix module imports of fallback stylesUlf Hermann2023-01-203-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you specify an explicit fallback, it should take precedence over any implicit fallback the style might specify. If you don't, the implicit fallback should take precedence. If, however, the main style is a custom one, we cannot indirectly import QtQuick.Controls.Basic through it as the versions may not match. For that case, add a QtQuick.Controls.IndirectBasic module that does nothing but import QtQuick.Controls.Basic. Also, add a test that checks whether the expected fallback was imported and fix some mistaken test data along the way. In Qt 6.4 and earlier you could not override the implicit fallback since the precedence between imports was wrong. After that was fixed in commit a0290dcc53a14b67c0179c43ce8dc21b43cfc83b the fallback style set from QtQuick.Controls ("Basic" if not requested explicitly) would always override the implicit fallback style. Both behaviors are equally wrong. We need to actually check whether the fallback is explicitly set or not. Pick-to: 6.5 Fixes: QTBUG-110247 Change-Id: I1aeee05c1c720bebf8b1b55361fd035a5565fb1b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Add a pragma for value type behaviorUlf Hermann2023-01-204-0/+105
| | | | | | | | | | | Unfortunately value types behave differently when compiled to C++. Document the difference and introduce a pragma to make them behave one way or the other. Pick-to: 6.5 Fixes: QTBUG-109221 Change-Id: Ib2685153c0b4ae209bafbea7a01229377fdb47dd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQuickTableView: set active focus directly on the edit itemRichard Moe Gustavsen2023-01-202-0/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When starting to edit a cell, the current implementation calls editItem->nextItemInFocusChain(true) to resolve the child to get active focus. But a better way is to instead rely on the edit item being a FocusScope. That way, we can simply set active focus on the edit item directly, and rely on the FocusScope forwarding active focus to the right child. After all, that is what FocusScopes are for. This patch will therefore change the implementation to set active focus directly on the edit item. But doing so turns out to cause tabbing from one cell to the next to stop working. The reason is that QQuickItem refuses to change setActiveFocusOnTab() on an item that has active focus. Instead, the focus item will eat the tab event, and use it to transfer focus to the next control in the chain. We therefore change the implementation to use an event filter on the focus object. That way, we're are guaranteed to always get a first shot at handling all critical key events that are needed for editing to work correctly. This includes tabbing, but even more imporantant, also Qt::Key_Enter, which is needed to allow the user to commit and close the editor. Pick-to: 6.5 Change-Id: I215b7efc52093eb0bd7f6a4fb60a57f83101e288 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Test262Runner: fix -Wunused-but-set-variableMarc Mutz2023-01-201-4/+0
| | | | | | | | | | | | | | | | | | | | | The 'int line' variable is shadowed a few lines below by the 'QByteArray line' one, even in the initial commit, so it can never have been used, except for the increment in the first line of the loop's bodies. Remove the variable, fix the warning. Found by Clang 15: test262runner.cpp:380:9: warning: variable 'line' set but not used [-Wunused-but-set-variable] int line = 0; ^ Amends d9c4a527241e0ef3a30e990c518197b0ba345b50. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I2139aa4552d1ff2ddbb5737e2a1b26650d6519e7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Retire the qt_parse_all_argumentsAmir Masoud Abdol2023-01-20237-501/+501
| | | | | | Task-number: QTBUG-99238 Change-Id: Ia11c9cbd7c06347319ab3674ec0cd8da0214747e Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QQuickTableView: reposition selection handles whenever TableView updates the ↵Richard Moe Gustavsen2023-01-201-13/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | layout After TableView got support for resizable rows and columns, a side effect is that any overlay, like the selection handles, will need to be repositioned when rows and columns are resized. Currenly the selection handles will instead stay put at the initial location. This patch will make sure that SelectionRectangle listens to the layoutChanged() signal from TableView, and reposition the handles. Because the current selection rectangle implementation in TableView didn't take row and column resizing into account either, the logic that calculates the rectangle is also changed. Rather than storing the selection rectangle after each mouse drag, we now calculate the exact (and updated) rectangle when queried instead. Fixes: QTBUG-109448 Pick-to: 6.5 Change-Id: I80171f992bea1035c1410ede384a2d847ee3aa46 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QJSEngine: Fix potential JS stack overflow cauased by spread operatorFabian Kosmale2023-01-191-0/+11
| | | | | | | | | | | | createSpreadArguments could in theory allocate a (nearly) unbounded number of QV4::Values. Avoid this by checking whether we approach jsStackTop. This fixes CVE-2022-43591. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I01aecb979da47b7261688c9f185dc33a50a579a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Fix null deref in quick pluginFabian Kosmale2023-01-172-0/+11
| | | | | | | | | | | | | In certain degenerate cases (e.g. missing imports), we might end up with a composite type which does not have a base type. That so far caused a crash in the binding check. To fix this, simply detect the situation, and skip the warning – we will already warn about the unknown type anyway. Fixes: QTBUG-106562 Pick-to: 6.5 6.4 Change-Id: Iff7e202cf5bd6b5c8d7cb90a46fb2573cb74ecaa Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Handle various date and time conversions correctlyUlf Hermann2023-01-174-0/+75
| | | | | | | | | | | | | We can coerce QDateTime, QDate and QTime into each other because they would all be represented by a Date object in JavaScript. Furthermore we can coerce them all to QString. Technically, we could also coerce strings to all of them, but we don't want to because that is terrible. Fixes: QTBUG-109380 Change-Id: I176bfb5b715a6a6750cb5918c44261fa23fb8832 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Add more overloads to Qt.format{Date|Time|DateTime}()Ulf Hermann2023-01-171-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since JavaScript has no concept of time or date separate from the Date object that contains both, and since we implicitly (via QVariant::convert) or explicitly accept string arguments to all these methods, we should really accept string coercions of Date objects. We should also make all the string overloads explicit. Converting strings to QDateTime is a really obscure feature of the metatype system. We should not rely on it. Furthermore, we need to accept QDateTime, as the native representation of the JavaScript Date object, as argument to formatDate() and formatTime(). Otherwise there are two ambiguous paths to calling formatTime() or formatDate() using a Date object: Either coerce the Date into a string and call the string overload or coerce it into a QTime or QDate and call the QTime or QDate overload. The QML engine special cases this and prefers the QTime/QDate way, but this just needlessly complicates the overload resolution. Interestingly, tst_qqmlqt already tests most of those variants. We just have to add the JS string coercions. Task-number: QTBUG-109380 Change-Id: I880e622256fe115dade32bde880605df2031ff2f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* V4: Unify type conversions for date and time valuesUlf Hermann2023-01-171-9/+12
| | | | | | | | | | We should always use the same conversion to string and we shouldn't duplicate the code for the date conversion. Task-number: QTBUG-109380 Change-Id: I1b1959c8e9b5957ddcf287d252b8143511237565 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QJSEngine: Add efficient conversions for QDateTime and friendsUlf Hermann2023-01-171-0/+155
| | | | | | | | | The JavaScript date and time conversions are different from Qt's. Add them to coerceValue. Task-number: QTBUG-109380 Change-Id: Ic0d7dd8ff51fb8e29d80d9084d4415becaa76259 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Print fix suggestions for pragma ComponentBehaviorUlf Hermann2023-01-172-0/+20
| | | | | | | | | Pick-to: 6.5 Fixes: QTBUG-104576 Fixes: QTBUG-104632 Change-Id: I9e0919feb04798fb4c5d0c8c0ed2f5cbc7a0b552 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Test precedence of qmlRegisterModuleImportUlf Hermann2023-01-171-3/+36
| | | | | | | | The last call should take precedence over previous ones. Task-number: QTBUG-110247 Change-Id: Ib5e10ab539ea6eecc3ad66aed75c81d622e0eb01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Fix multiplicationFabian Kosmale2023-01-172-0/+28
| | | | | | | | | | | Ensure that negative number times positive zero yields negative zero, not positive zero. Do the same adjustment in QJSPrimitiveValue Fixes: QTBUG-104582 Pick-to: 6.5 Change-Id: I8231bfb051b7d902e5e50bbd282410a572b1628a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix masked MouseArea hovered state on visibility changeOliver Dawes2023-01-172-0/+73
| | | | | | | | | | | | | | | | | | | | This fixes the issue where given two hoverable MouseAreas A & B where B masks A, the `containsMouse` property of A will be incorrectly set to true if the cursor is positioned above both A and B and the visibility of A is toggled from true to false back to true. This patch fixes the above issue by checking if the QQuickMouseArea is marked as a hovered item in its windows QQuickDeliveryAgentPrivate(QDAP) instance. If the QQuickMouseArea is masked by another QQuickMouseArea then it will not be a in the QDAPs hovered items list and we skip setting the hovered property on QQuickMouseArea, fixing the issue. This patch also adds a test case to prevent future regressions. Fixes: QTBUG-109567 Pick-to: 6.5 6.4 Change-Id: I5f024a097b56ef5e0836ca9f8ae547983a089b44 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* tst_platform: fix shortcut test flakiness on webOSJanne Juntunen2023-01-171-0/+4
| | | | | | | | | | | | Testcase's window didn't always have the focus when a key sequence was sent to it, causing occasional test failure on webOS. After the fix we will wait for the window to become active before sending the key sequence. Fixes: QTBUG-110242 Pick-to: 6.5 Change-Id: I80504d8d249f16b677ce754ad8e673a011af8638 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickPopup: fix logic for modally blocking wheel eventsVolker Hilsheimer2023-01-172-6/+88
| | | | | | | | | | | | | | | | | | | | | | After caca7d7d4fcb7281332904c01950a66385bad0b3, QQuickOverlay ate wheel events to any item that was not a child of the top-most modal popup. This broke event delivery to children of modless popups higher up in the stack. Fix that logic so that we don't eat events if we find a popup that the item is a child of. Only eat the event if we don't find such a popup before hitting the first modal popup. Add a test with a relevant scenario, and as a drive-by, fix and simplify the helper function sending wheel events. Since the event gets delivered to the window, we have to use scene coordinates, not item coordinates. This happened to work in the wheel test case as the test sliders cover the entire window. Fixes: QTBUG-110023 Pick-to: 6.5 6.4 Change-Id: Ibc53114cf09693e23b1e66f28a0c2056f3bd810e Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Allow extraction of V4 values from QJSPrimitiveValueUlf Hermann2023-01-163-0/+28
| | | | | | | | | | Since we can produce QJSPrimitiveValue in metaTypeFromJS, we should also handle the other direction. Fixes: QTBUG-109867 Pick-to: 6.5 Change-Id: I2c7598d19eba3e78d071ca3eceb32deda4d0ead8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>