aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
Commit message (Collapse)AuthorAgeFilesLines
* Mark QQmlListProperty as a QML list in QMetaTypeFabian Kosmale2020-11-241-1/+6
| | | | | | Pick-to: 6.0.0 dev Change-Id: Icd92121bb65ffca1135c1ef69b90d8a8955c1df0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqml.h: Add QML_IMPLEMENTS_INTERFACESMaximilian Goldstein2020-11-231-0/+4
| | | | | | | | | | | Needed in order to allow for the declarative registration of classes implementing interfaces. Fixes: QTBUG-88623 Change-Id: Id9c1ae92774dd9c316ceaa737cb48ef28f56545c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 87533900738d65ad278722b292852c998e987c10) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QtQml: document qmlExecuteDeferred as internalFabian Kosmale2020-11-191-0/+3
| | | | | Change-Id: If3640ef5cbb6df4b199b481410e79e94ea763645 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove compatibility shim from qmlinfo.{cpp|h}Ulf Hermann2020-11-193-53/+19
| | | | | | | | | | | | We don't need to handle symbol clashes with QtQuick1 anymore. [ChangeLog][QtQml] The functions qmlDebug, qmlInfo, and qmlWarning are no longer available in the QtQml namespace. Use their counterparts in the global namespace. Fixes: QTBUG-88637 Change-Id: Ia74510bd711790cebf55de4cd668891712f6835e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qqmlproperty: Fix interfaceBinding crash on MSVC 2019Maximilian Goldstein2020-11-181-2/+6
| | | | | | | Change-Id: I4bb4a66b7ccca838e058962bbc297659b273c78e Done-with: Fabian Kosmale <fabian.kosmale@qt.io> Fixes: QTBUG-84416 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlEngine::captureProperty(): Don't capture constant propertiesUlf Hermann2020-11-121-1/+1
| | | | | | | That is a noop and produces a warning. Change-Id: I75787aee66b55522005247524140e3f3a7dd56ba Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Integrate sequences with registration macrosUlf Hermann2020-11-114-8/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | You get to write QML_SEQUENTIAL_CONTAINER(value_type) now, and qmltyperegistrar will generate a sensible registration call from that. A registration might look like this: struct MyStringListForeign { Q_GADGET QML_ANONYMOUS QML_SEQUENTIAL_CONTAINER(QString) QML_FOREIGN(MyStringList) QML_ADDED_IN_VERSION(3, 1) }; It's unfortunate that we need to use a metaobject to transfer all of this information, but there is no other sensible way. Transform the containers defined in qv4sequenceobject.cpp to use the new style, and move them out of the builtins, into QtQml. Recognize that only one of them was ever tested, and add tests for the rest. Task-number: QTBUG-82443 Change-Id: I3a30f9e27266bb575eea26c5daf5dad1ec461cc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlPropery: Add seed to qHashFabian Kosmale2020-11-111-2/+2
| | | | | | | | As a driveby, enhance the hash function's properties by using qHashMulti. Change-Id: Id8add6047530f07ed44f50f46ffe68bb563fdd6b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add debug trace when a static plugin is loadedAlexandru Croitor2020-11-101-0/+5
| | | | | Change-Id: Icc4ff1f78bca75c59af1c2550fae15a2489a8bf1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove assert in QQmlPropertyThomas Hartmann2020-11-101-1/+0
| | | | | | | | | | The constructor for "font.capitalization" asserts Q_ASSERT(vtProp.userType() <= 0x0000FFFF). This was enough to trigger the assert: QQmlProperty property(text, "font.capitalization") Users are allowed to register value types. Change-Id: Ie10f22b7c9d70bd194cf72f287ec6d8d1ff8b028 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Rewrite Qt object in actual C++Ulf Hermann2020-11-096-762/+542
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Quite obviously, the Qt object is a singleton, extended with a namespace, backed by a member of the JavaScript global object. Defining all the methods as JavaScript functions is unnecessary and duplicates the general type transformation code. Also, it makes it hard to use those same methods from a C++ context as we cannot properly set up the arguments outside the JS engine. Rewriting the Qt object reveals some deficiencies in the old implementation that we need to fix now: 1. The enums of the Qt type were listed as properties of the Qt object, which means you could iterate them with a for..in loop in in JavaScript. This is just wrong. Enums are not properties. This functionality is deleted and the test adapted to check for each enum value separately. The commit message for the change that introduced the iterability already mentioned that the author had failed to find any occurrence of this in the real world. 2. Parsing time objects from strings was done by parsing the string as a date/time and then picking the time from that. We still support that for now, but output a (categorized) warning. Parsing the time directly is preferred where possible. 3. Previously you could create (invalid) dates and times from various kinds of QML types, like int and color. This does not work anymore as we now validate the types before calling the functions. 4. Passing more arguments to a function than the function accepted was unconditionally ignored before. Now, a Q_CLASSINFO on the surrounding class can specify that the arguments should be checked, in which case a JavaScript error is thrown if too many arguments are passed. In order for this to work correctly we also have to ignore JS undefined values as trailing arguments for overload resolution. This way, if a method matching the defined arguments exists, it will be preferred over a method that matches the full argument count, but possibly cannot accept undefined as parameter. Consequently a number of error messages change, which is reflected in the qqmlqt test. [ChangeLog][QtQMl][Important Behavior Changes] You can not iterate the enumerations of the Qt object in JavaScript anymore. This does not work with any other enumeration type either. You can of course still access them by name, for example as Qt.LeftButton or similar. [ChangeLog][QtQMl][Important Behavior Changes] The time formatting functions of the Qt object in QML now allow you to pass an actual time string, rather than a date/time string as argument. Passing a date/time string results in a warning now. [ChangeLog][QtQml][Important Behavior Changes] Functions in the Qt object for formatting date and time will now throw a JavaScript error when presented with a value of an incompatible type, such as int or color. [ChangeLog][QtQml][Important Behavior Changes] The Qt.resolvedUrl() function now returns a URL rather than a string. This follows the documentation. [ChangeLog][QtQml][Important Behavior Changes] The GlobalColor enum of the Qt namespace is not exposed to QML anymore. It did not make any sense before as the enum values could not be used as colors. Change-Id: I7fc2f24377eb2fde8f63a1ffac5548d652de7b12 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlListProperty: Use qsizetype rather than int for sizesUlf Hermann2020-11-096-31/+31
| | | | | | | | | | [ChangeLog][QtQml] The QQmlListProperty callback functions use qsizetype now as type for the size of a list. This is in line with the containers that you might use to back the list. Fixes: QTBUG-88269 Change-Id: Ia38403cb32f241e6c70e1a580dbeff1d6d694331 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc:: Fix documentation warnings for Qt QMLTopi Reinio2020-11-054-6/+7
| | | | | | Task-number: QTBUG-88156 Change-Id: Ic6127c6128b4c7736cb4b5ab8ce51629388b59ca Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Adjust to QPropertyBindingPrivate not using std::function anymoreFabian Kosmale2020-11-042-9/+44
| | | | | Change-Id: Id197f3d4bf8ab60256040e0a177d5596ce78a0a8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Expose QQmlPlatform and QQmlApplication to QMLUlf Hermann2020-11-032-0/+5
| | | | | | | | As properties of the Qt object they need to be visible. Change-Id: Ic6357b92f4fae36240e8dbce8976eeb6f9f41bf0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QML: Allow singleton types to be extendedUlf Hermann2020-11-028-44/+109
| | | | | | | | | It seems we never stated that singletons can not be extended in our documentation. Therefore this is technically a bug fix and doesn't need separate documentation. Change-Id: I7877289bd5a52ecf709f80ba1975137981ec65f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Allow singletons to be created with a factory functionUlf Hermann2020-11-021-8/+56
| | | | | | | | | | This is in line with what we do on qmlRegisterSingletonType(), and it allows us to return singleton objects created independently of the instantiation mechanism. Change-Id: Ia6a077f5d22241593acd8cc87b3f65ae20f95667 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* QML: Allow namespaces as extensions to typesUlf Hermann2020-11-026-16/+44
| | | | | | | | | | | | | | | | | This way we can access the enums of namespaces as properties of the primary type. This is achieved by: 1. Making enums of extended types available in the base type 2. Allowing the extension to be specified as plain metaObject rather than as type name. 3. Refraining from creating the extension if the create function does not exist. The goal of this is to declare the Qt namespace in a civilized way, but will also help with cleaning up the QtQuick value types and their enums. Change-Id: I13399741d30ce38d1bff753cfa1b11e72ccfbf6a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace old Q_DECL statements with modern C++Allan Sandfeld Jensen2020-10-312-2/+2
| | | | | | | Since we depend on C++17 now, all of these can go. Change-Id: I0484fd4bb99e4367ec211c29146c316453729959 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Standardize QJsonArray iterationDavid Skoland2020-10-281-2/+2
| | | | | | | | | When using refs as loop variables, the clang compiler complains (with default settings). This prevents that. Note that QJsonValueRef is used "behind the scenes", which makes this iteration method correct. Change-Id: I5a5f58ca8ad3887bce2009231cbae5a57c107697 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QML: Drop thisObject from writeToConsoleUlf Hermann2020-10-281-11/+11
| | | | | | | It's unused. Change-Id: I629bfb4ae9775f3f7c97be7789c84a15205cc29e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Inline components: Fix custom parser supportFabian Kosmale2020-10-281-0/+6
| | | | | | | | | Fixes: QTBUG-85713 Fixes: QTBUG-87464 Pick-to: 5.15 5.15.2 Change-Id: I5c190ad2d02190de90260042cc06e51c1da01c63 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmlmetatypemodule: Fix maximumMinorVersion() returning bad valuesMaximilian Goldstein2020-10-272-2/+5
| | | | | | | | maximumMinorVersion() needs to ignore unspecified values as they are not versions in themselves. Change-Id: I7c91cf4b8320fd6636eb1be10b069cf885797ee1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: Move more types into builtins.qmltypesMaximilian Goldstein2020-10-261-1/+0
| | | | | Change-Id: Id2795f16af99870f32266f81228890a9d12c86a7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove usage of deprecated QStandardPaths::DataLocationKarsten Heimrich2020-10-231-1/+1
| | | | | | Task-number: QTBUG-87037 Change-Id: I1969dba3b6edfaf202a316576674efed481bb1e4 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQmlEngine: Add method to explicitly capture a propertyUlf Hermann2020-10-233-9/+22
| | | | | | | | | | Also, use that method to capture the uiLanguage notify signal. Previously the wrong signal was captured. The test still happened to pass because we manually re-evaluated all bindings when the uiLanguage property changed. Add a test which avoid that. Change-Id: I3961b60b365a8705930936f20881421bd4ceffe5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlvaluetypes: Add a few missing toString methodsMaximilian Goldstein2020-10-232-0/+19
| | | | | | | | Implements toString for QQmlPointValueType, QQmlRectValueType and QQmlSizeValueType. Change-Id: Ia8dad072453caea24f6f351cf3da9d0ed085b2a1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlIR: Make sure that all objects receive a locationUlf Hermann2020-10-222-4/+6
| | | | | | | For grouped properties, this is the location of binding now. Change-Id: I7148ba92150e3569d47c382ef78794bfa3b75fce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adjust to QMetaObjectBuilder::MetaObjectFlags changeFabian Kosmale2020-10-213-3/+3
| | | | | Change-Id: I2f9b39fda6c25e57985a32864c85a50b7d6d0231 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Adapt QMutexLocker to qtbase changeFabian Kosmale2020-10-182-2/+2
| | | | | Change-Id: Ica9561a42217f5a509a6e84e9e48036ec6348e48 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QProperty property interaction with aliasesFabian Kosmale2020-10-125-5/+24
| | | | | | | | | | | | | | | | With this change, an alias of a bindable property is also bindable, and shares its bindable interface with the target. Moreover, the logic in QQmlTypeCompiler is adjusted so that a change handler of an alias uses the bindable interface if possible, instead of connecting to the alias' change signal. That would never be emitted if the target is a QProperty without a notify signal. Alias properties still have a change signal, but those never get emitted. Change-Id: I857dfdbe51048a2b604ad632982e7f4adac6b907 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlMetaType: Cast the type interfaces to const when deletingUlf Hermann2020-10-121-2/+2
| | | | | | | | We don't need them to be mutable, and the return type of the function will become const soon. Change-Id: I3016d80df31db981d47296e468e93336d3a79ce1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPropertyChangeTrigger: Inherit directly from QPropertyObserverFabian Kosmale2020-10-123-11/+15
| | | | | | Change-Id: If2ffeef14d33200e39fb8b3e7fd88c232164a241 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update QStringConverter usageMÃ¥rten Nordheim2020-10-091-2/+2
| | | | | | | Following fa8d021fa6fcb040fb702b6ffd2deee52a3b748a Change-Id: I89c0231655ec853cef9465e5a88a92d7e0085d30 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlPropertyValidator: only use string converter for stringsFabian Kosmale2020-10-091-10/+26
| | | | | | | | | | | | | A recent change in fromIsoTimeString exposed the fact that we are using QML's string converters to check whether a binding expression is valid for a given property. However, while we begrudgingly accept that string representations shall be converted to value types via the string converters, the same shouldn't hold true for things that aren't actually strings - for instance, numbers. Fixes: QTBUG-87299 Change-Id: Iefd390efae7c193dc32d37e63943b39e09c9295a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow optional imports in qmldir filesUlf Hermann2020-10-083-7/+9
| | | | | | | | | | This is useful for modules that select their imports at runtime using qmlRegisterModuleImport(). We can list all possible variants as optional imports so that tools can see what types might be available. Task-number: QTBUG-87130 Change-Id: I8a37bdde79aef3619fd1f05e5ea6781d521afa88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* XHR: allow the user to set the User-Agent headerGiuseppe D'Angelo2020-10-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | The Fetch spec has allowed it for a while (in other words, it's no longer forbidden): * https://fetch.spec.whatwg.org/#terminology-headers * https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name Cf. also * https://github.com/whatwg/fetch/issues/37 * https://github.com/whatwg/fetch/commit/dab09b0c483c46324082df1e54b29ed4c9c02162 [ChangeLog][QtQml][XmlHttpRequest] It is now possible to set the User-Agent header. Change-Id: I1d5bd785223e9df2883011f873d440a63e363a24 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlMetaType: Grudgingly accept uppercase value typesUlf Hermann2020-10-051-3/+7
| | | | | | | We throw a warning instead of an error. Change-Id: I0f5886a2d46582405ae1d57879ccb3937e27950f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlProperty::write: historical reason does not hold in Qt 6Fabian Kosmale2020-10-031-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | There was a codepath which checked after a failed QVariant conversion whether the variant is valid and is null at the same time. In that case, the conversion would be treated as successful. The motivation for this can be traced back to QTBUG-37197, and our handling of strings. However, since those times various things have changed: - QVariant::isNull() does not return true anymore if its contained type is null. Thus the conversion of a QVariant holding a null QString will not lead to a conversion failure (as long as the target type is actually a conversion target for a QString). - A failed conversion will always leave the resulting variant in a state in which it is valid. The latter is rather problematic, as we would thus always enter the code path when the source QVariant happened to be null; even in the case where the source and target types are really incompatible. This can for instance be observed in tst_qjsonbinding, where assigning null to a QJsonArray would suddenly "work", thus leading to a test failure. However, thanks to the first point, it is safe to completely remove this code. Change-Id: I176a5c4b04295d128919cab8a333b8a5a2c2345d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <hausmann@gmail.com>
* Use factory functions and ctors for creating value typesUlf Hermann2020-10-0214-80/+101
| | | | | | | | | | As you can extend value types with QML_EXTENDED we may as well allow a factory function in the extended type. Furthermore, if the original type allows construction from QJSValue, we may just use that. In turn, we can get rid of the value type providers now. Change-Id: I9124ea47537eab6c33d7451080ab2fff942eaa7b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Rewrite qv4sequenceobject based on QMetaSequenceUlf Hermann2020-10-029-2/+96
| | | | | | | | | | This avoids the template explosion and makes the mechanism extendable. You can now register additional anonymous sequential containers. Fixes: QTBUG-71574 Task-number: QTBUG-82443 Change-Id: I5b9ed9af1533a3b7df8fc5bb37bbb73b8304e592 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlimport: Use stable_partition instead of stable_sortFabian Kosmale2020-09-281-2/+2
| | | | | | | | | | | | We do not actually need to sort the imports list, we just require that all inline component imports come before all other imports. This avoids triggering a MSVC STL debug assertion about the used Compare function not actually creating a strict ordering. Fixes: QTBUG-86989 Pick-to: 5.15 Change-Id: I381852392545287ec02b186fcb4f33be3ae95b33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Export QQmlLocale symbolsVolker Hilsheimer2020-09-281-4/+4
| | | | | | | | | After 8e222a70d19d5eef616e1d6306415da64fbab4cb, QQmlLocale is a namespace and doesn't export any symbols. Export the member functions explicitly, as they are needed by Qt Quick Controls. Change-Id: I867cb5c0325c6c19200408b514c086c8057c82a9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlTypeCompiler: Resolve aliases earlierFabian Kosmale2020-09-231-11/+12
| | | | | | | | | This is a prequisite for determining whether a change handler of an alias should use its change signal, or whether it can use the alias target's bindable interface. Change-Id: I6f5220a6889601327cb478479c7c9e58f1a64d97 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Condense the different value type creation functions into oneUlf Hermann2020-09-236-51/+26
| | | | | | | They all did the same thing. Change-Id: I7661b19ad16c0713d46c4df337899e3897349b2e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::storeValueType()Ulf Hermann2020-09-233-23/+4
| | | | | | | | | | | | It was only used for QColor. The string representation of QColor was funneled through the color provider to get a numerical RGBA value and that one was passed to storeValueType() which would create a QColor object. The RGBA value was retrieved by creating a QColor object. We can just directly create the QColor from the string, and we can use the generic create() method for that. Change-Id: If36775830882237e5e36f748872ce23530c3bb71 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::createVariantFromString()Ulf Hermann2020-09-233-23/+1
| | | | | | | This can be expressed as constructing the variant from a QJSValue. Change-Id: I3140958469423acdc498e26129e349bcfb601198 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::createFromStringUlf Hermann2020-09-236-99/+29
| | | | | | | It can be expressed as a special case of create() with a QJSValue. Change-Id: I7342026ad694077d2780dd8a852714fa72dd68d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove QQmlValueTypeProvider::variantFromJsObjectUlf Hermann2020-09-233-9/+9
| | | | | | | This can be expressed in terms of create(). Change-Id: Id1950390bf4a1c9dfd9364ea351b81c75eb7e28f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlValueTypeProvider: Pass arguments as QJSValueUlf Hermann2020-09-233-74/+26
| | | | | | | | This is so that we can replace them with factory functions as a next step. Change-Id: Ic8619e4e779bd3e47471642c556601555758697b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>