aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlglobal.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QML: Rewrite Qt object in actual C++Ulf Hermann2020-11-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use factory functions and ctors for creating value typesUlf Hermann2020-10-021-57/+10
| | | | | | | | | | 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>
* Condense the different value type creation functions into oneUlf Hermann2020-09-231-30/+1
| | | | | | | They all did the same thing. Change-Id: I7661b19ad16c0713d46c4df337899e3897349b2e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Eliminate QQmlValueTypeProvider::storeValueType()Ulf Hermann2020-09-231-15/+0
| | | | | | | | | | | | 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-231-17/+0
| | | | | | | 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-231-3/+2
| | | | | | | 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-231-4/+2
| | | | | | | 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-231-3/+3
| | | | | | | | 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>
* Allow proper registration of value typesUlf Hermann2020-09-231-12/+1
| | | | | | | | | | | | | | | | | | | | You can now have an extension object on a value type that offers additional properties. This is how we model the QtQuick value types. It allows us to retrieve the extension's metaobject without using the virtual functions in the value type provider. As before, this mechanism is still rather dangerous and not fit for public consumption. It relies on the extension object having exactly the same layout as the original value type, and it hides any properties the original value type might expose. Furthermore we enforce now that gadgets should have lowercase names. The ones that didn't before are split up into an anonymous value type and a namespace that contains all the addressable bits. Task-number: QTBUG-82443 Change-Id: Ic93d6764538d6ccc0774b3c5648eee08ba0939c0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlValueTypeProvider: Use QMetaTypeUlf Hermann2020-09-161-34/+18
| | | | | | | | We can create, compare, convert registered types without going through special virtual value type providers. Change-Id: I0431256540b8dd6861ff3a945570ea7df45ed98d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QQmlValueTypeProvider: Remove dead codeUlf Hermann2020-09-161-30/+0
| | | | | | | | | The more adventurous variant/string conversions are luckily unused. Let's remove them before anyone gets ideas. Change-Id: I6f95cbdf9ead12ab723cafdbb2b0f02a0ff461fa Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Implement Qt.alpha()Maximilian Goldstein2020-04-141-0/+4
| | | | | | | | | | | | Introduces an easy way to get a version of a color with transparency (e.g. Qt.alpha("red", 0.5)). [ChangeLog][QML][General] Added Qt.alpha for easily modifying a color's alpha value Task-number: QTBUG-77635 Change-Id: Ic724e5fa503ca2ae5157a99eed1b5c913a39239f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Remove QQmlV4HandleUlf Hermann2019-04-101-2/+3
| | | | | | | | This is just an alias for QV4::ReturnedValue. We can as well use the latter. Change-Id: Ibd2c038a3ca726b39a8f0f05e02922adb9fccbdb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Warn about non-existent providers only with the loaded QtQml libraryNodir Temirkhodjaev2019-04-101-2/+2
| | | | | | Task-number: QTBUG-74996 Change-Id: Ibc5de6e79889724850c9cdc16c8ba066a76298d1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make sure we can delete value type providers in any orderUlf Hermann2019-03-281-36/+26
| | | | | | | | | | | Previously the null provider had to be deleted last as it would leave a dangling pointer in the global static. This meant that we could not delete any other value providers on shutdown as the deletion order between different Q_GLOBAL_STATICs is undefined. Task-number: QTBUG-74348 Change-Id: I12aab6ab9ec4c71b90af69c5f824e0c6686433f5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-9/+9
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Qt.platform.pluginName propertySami Nurmenniemi2017-06-061-0/+2
| | | | | | | | | | | | This exposes QGuiApplication::platformName() for qml. It is required at least for tests that are run on the "offscreen" platform (armv7 tests on qemu). [ChangeLog][QtQuick] Added Qt.platform.pluginName property. Task-number: QTBUG-60268 Change-Id: Ie55a282485d4d76ffe7ed8e77359ad7183f579c2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Run includemocs in qtdeclarativeThiago Macieira2017-04-261-0/+2
| | | | | Change-Id: I84e363d735b443cb9beefffd14b8c023a37aa489 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of most QT_NO_FOO usagesLars Knoll2016-11-291-2/+0
| | | | | | | | Instead use QT_CONFIG(foo). This change actually detected a few mis-spelled macros and invalid usages. Change-Id: I06ac327098dd1a458e6bc379d637b8e2dac52f85 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Also remove the QQmlValueTypeProvider::destroyValueType interfaceFrank Meerkoetter2015-08-181-14/+0
| | | | | | | After the removeal of the QQmlVMEVariant there is no user left. Change-Id: I97224127aac57aba9a80827f9292018d03609b85 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Adapt the ValueTypeProvider interface and port its typesFrank Meerkoetter2015-08-181-17/+12
| | | | | | | | | The ValueTypeProvider system allows non-QML modules to add new basic QML types. It needs to be changed when porting away from QQmlVmeVariant as underlying type of properties. Change-Id: I2b52d7e6f578647a39832896c28553404b9a679f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Remove QQmlValueTypeProvider::copyValueTypeFrank Meerkoetter2015-08-181-15/+0
| | | | | | | | While reworking the QQmlValueTypeProvider interface I noticed that this code isn't used. Change-Id: I30a279ffabf3a1c70eaa1327e69b774f5e5981f0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* qml: Avoid heap allocations due to QString::fromLatin1()Sérgio Martins2015-08-131-2/+2
| | | | | | | By using QStringLiteral when the argument is a literal. Change-Id: Ib25042d10f3d9d0aca81af74cde0107aba4f9432 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add Qt.hsva() functionSean Harmer2015-02-181-0/+1
| | | | | | | | | | | | This is more convenient than the alternative hsla() function in many cases as color pickers in other applications default to the HSV color space e.g. GIMP, kcolorchooser. [ChangeLog][QtQml] Added Qt.hsva() function Change-Id: Id5c1a78173757bf9842b164d90b31682e9a41749 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* Expose QStyleHints as Qt.styleHintsJ-P Nurmi2015-01-171-0/+8
| | | | | Change-Id: I0fc94e680b011963e645bdbf51110820751e53aa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix Qt.inputMethod ownershipJ-P Nurmi2015-01-171-0/+2
| | | | | Change-Id: Ic51f9daf17742a421a810d95b2a510caf657e08f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove v8engine usage in the value type providerLars Knoll2015-01-081-2/+2
| | | | | Change-Id: I6b26a8249175a86c6e15d000b24ba3300e112715 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Initial work on gadget supportSimon Hausmann2014-12-221-6/+4
| | | | | | | | | | | | | | | | | | | | | | Changed built-in QtQml value types to use gadgets. This is in preparation for supporting external gadgets. This replaces the mostly direct inheritance of the concrete value types with gadgets and "dynamic" inheritance through QQmlValueType being generic. Over time as some of the value types may become gadgets, we can remove the ones here. It's important that these "separate" gadgets have the same memory layout as the actual types (QPointF, etc.). Also while QQmlValueType remains practically a singleton, it's not required anymore to be one. Consequently the JS wrappers for value types keep their own instance of QQmlValueType. This allows eliminating the qobject_cast in various places that dealt with the singleton nature. This comes at a cost, making the JS wrappers slightly heavier. However that is meant to be a temporary situation and finally the value type wrapper should merely store the meta-object in addition to the data and the type. Change-Id: I15071ded0a1e54203f29ec1ecf7a9ab646d1168e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Merge branch 'dev' of ssh://codereview.qt-project.org/qt/qtdeclarative into ↵Simon Hausmann2013-07-221-2/+36
|\ | | | | | | | | | | | | | | | | | | wip/v4 Conflicts: src/quick/items/context2d/qquickcontext2d.cpp tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro Change-Id: I36a4fd28b3156839aecd70039a3ba566bf19a0bc
| * Fix Qt.application.xxx notifier signalsJ-P Nurmi2013-07-041-4/+16
| | | | | | | | | | | | | | QCoreApplication now provides change notifications. Change-Id: Icd7e1247426f4b5ad124d6d9b72a2ba99225ee08 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
| * Add Qt.application.organization/domainJ-P Nurmi2013-06-291-0/+22
| | | | | | | | | | | | Change-Id: Ic4a161b59d51e621e13c960f104d1a3be2ee64f8 Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* | Rename QQmlV8Handle to QQmlV4HandleLars Knoll2013-04-191-2/+2
|/ | | | | | | | | The handle wraps a V4 Value, so this is the better name for it. Also added some accessor methods to convert to and from V4 Values. Change-Id: I327c83feb5bd3be59909001489979e5a3a9d9e67 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add core application functionality to Qt.application in QMLAlan Alpert2013-03-051-3/+50
| | | | | | | | | | | | | | This exposes some information to QML which is available on the QCoreApplication instance. A future change should make it possible to restrict this for use in scripting environments (which should not have access to the QCoreApplication). That has been left out of this change because proper support for such restrictions is not yet in place. Change-Id: Ica144fcfb0b42fa6df8d0cb1c7c03eb97282b489 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* Fix the QtQml's use of plugins for value type providersThiago Macieira2013-03-011-2/+31
| | | | | | | | | | | | | | | | | | | | When the QtQuick library is loaded, it runs a global constructor that installs the QtQuick value providers. But those providers are never uninstalled when the library is unloaded, resulting in a dangling pointer stored in QtQml's singly-linked list of value providers. Since cafb02911a29b98ac2652fde64e95870e70fd547, QLibrary will unload plugins after inspecting their plugin metadata on Mac and Windows. If QtQml is trying to load a plugin that links to QtQuick (in particular, *the* qtquick2plugin plugin), it would cause the value provider to go stale. To make matters worse, it's quite likely that the plugin would get loaded soon after, at the same address in memory, which causes the valueTypeProvider list to become cyclic. Change-Id: I6f4db5475ceeaba766d9e9c78f86266c9a65806a Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | Change-Id: I6c3bd7bebe3d62d1cfd0fa6334544c9db8398c76 Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Enable module build with QT_NO_IMTasuku Suzuki2012-11-261-0/+2
| | | | | | Change-Id: I90f8ec7e6357db7b4038bb1646fe9d3835821556 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Alan Alpert (RIM) <aalpert@rim.com>
* Fixed missing virtual destructors in qtdeclarative.Samuel Rødal2012-09-241-1/+6
| | | | | | Change-Id: I0b0e63b572617a56874e27361479de2690644aa3 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-231-24/+24
| | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Ie7f5d49ed8235d7a7845ab68f99ad1c220e64d5c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix broken value-type support by allowing property definitionChris Adams2012-07-111-12/+25
| | | | | | | | | | | | | | | | | | | | | In QtQuick 1.x the "variant" property type was supported, which could be used to allow value type properties to be defined in QML. In QtQuick 2.0, we have deprecated the "variant" property, but its replacement ("var") is not suited for defining lightweight C++ type values (such as QColor, QFont, QRectF, QVector3D etc). This commit allows those QML basic types to be used in QML once more, by supporting them in the property definition syntax. Note that since some value types are provided by QtQuick and others are provided by QtQml, if a client imports only QtQml they can define but not use properties of certain types (eg, font). Task-number: QTBUG-21034 Task-number: QTBUG-18217 Change-Id: Ia951a8522f223408d27293bb96c276281a710277 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Change uses of {to,from}Ascii to {to,from}Latin1Thiago Macieira2012-05-041-1/+1
| | | | | | | | | | This operation should be a no-op anyway, since at this point in time, the fromAscii and toAscii functions simply call their fromLatin1 and toLatin1 counterparts. Task-number: QTBUG-21872 Change-Id: I03084595ddc425a988374b8352fd23e9504ffba6 Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
* Ensure external value types are initialized before writeMatthew Vogt2012-04-301-0/+15
| | | | | | | | | Ensure that the logic used when writing to a property having a value type provided by an external module matches that used for properties of internal value types. Change-Id: I925b8b30a211ef813e2a51134411a162b0b146b5 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Migrate gui dependencies from QtQml to QtQuick.Matthew Vogt2012-03-201-0/+336
Ensure that users of declarative that have no need for functionality provided by the Qt Gui module do not have to link against it. Any use of QtGui functionality is delegated to providers that can be installed by another library; QtQuick adds default providers for this functionality when linked against QtQml. Task-number: QTBUG-24559 Change-Id: I5e6a58a4198732dc2f8f52f71abfa1152b871aa7 Reviewed-by: Martin Jones <martin.jones@nokia.com>