aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine.h
Commit message (Collapse)AuthorAgeFilesLines
* QQmlEngine: Introduce markCurrentFunctionAsTranslationBindingFabian Kosmale2023-04-241-0/+2
| | | | | | | | | | | | | | | The general recommendation to handle language changes in QML is to handle the LanguageChange event. However, if one is willing to tie themselves to the QQmlEngine, we can offer a way to ensure that calling a function will result in a traslation binding. This might also be helpful for anyone implementing a translation system different from Qt's, e.g. KDE's i18n. Fixes: QTBUG-102393 Change-Id: Id4d7a401e0be9d65e1769c8471b26689f44bf66a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlEngine: Add module + type based singletonInstance overloadFabian Kosmale2022-12-081-0/+12
| | | | | | | | | This makes it consistent with QQmlComponent::loadFromModule. It also avoids the issue the qmlTypeId does currently only work if the module has been imported; though that will be fixed in a separate commit. Change-Id: Id284f7ed2de7af461b782c5b5d71d9bfc0039844 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QQmlEngine: add signal for offlineStoragePathFabian Kosmale2022-10-041-1/+4
| | | | | | | | | | | That might be helpful if someone wishes to heed the advise in the documentation, and to always call mkdir (in a slot) on offlineStoragePath change). Change-Id: I3970b2ff9104f4966fddf67b02754e123a87c6cd Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QtQml: Uncruftify QQmlImportsUlf Hermann2022-03-241-1/+0
| | | | | | | | | QQmlImports is a refcounted datastructure. Therefore, use QQmlRefPointer for it, and avoid all the pointless indirection. Also, make the flags type safe and document the mutability of the import namespaces. Change-Id: I54a0db42b2b7cdfb516e9f90c2264edfa800bfe6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Deprecate QQmlEngine::importPlugin()Ulf Hermann2022-01-151-0/+3
| | | | | | | | It's a bad idea to import a plugin without loading the module it belongs to. Change-Id: I878e7aa9320285c1061b223db5a8399c774f7583 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Provide a method to clear the singletons from a QQmlEngineUlf Hermann2021-08-201-0/+1
| | | | | | | | | | | This is handy for cases where you want to clearComponentCache(). Singletons may hold on to old types, and using them after clearComponentCache() can produce surprising results. Task-number: QTBUG-95788 Change-Id: I390ff78cf9be9c034573ae848c8ccefa6d6a8817 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QtQml: Move locateLocalQmldir and make it a templateUlf Hermann2021-06-291-0/+1
| | | | | | | | | | | | | | | It conceptually belongs into QQmlImportDatabase because it messes with the qmldir cache. This way, if we reject a qmldir file for whatever reason, we can still check for further matching qmldir files in other places. We might, for example determine that we need to load a plugin, but we have been given a qmldir file in the resource file system. In that case, we want to check for other instances of the same module in the host file system. Pick-to: 6.2 Change-Id: I8fe4a0f188f3732b9d10d017a94562e8bd1fb242 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlEngine: Add method to explicitly capture a propertyUlf Hermann2020-10-231-0/+2
| | | | | | | | | | 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>
* QQuickImageProvider: Remove reliance on RTTIFabian Kosmale2020-09-011-1/+2
| | | | | | | | | | | | | Using staticCast is unsafe, because in theory you can derive from QQmlImageProviderBase instead of QQuickImageProvider. But using dynamicCast runs into issues, because while Qt needs to be compiled with RTTI, user code does not. We thus turn the baseclass into a QObject so that qobject_cast does work. Fixes: QTBUG-84127 Change-Id: Id40d8a13eaa0101d80bd5742a23996354d70c72a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QQmlImageProviderBase: Address Qt 6 TODOFabian Kosmale2020-08-311-4/+3
| | | | | | | | | Reorder the enum entries to make Invalid the zero value, so that we can extend it in the future. Change-Id: I6903d25c8f5d84c88bcfbfdbff55723da6c21eb9 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move object onwership functions from QQmlEngine to QJSEngineFabian Kosmale2020-04-241-3/+0
| | | | | | | | | | | | [ChangeLog][QML] The setObjectOwnership and objectOwnership functions have been moved from QQmlEngine to QJSEngine. This reflects the fact that they have an effect on objects passed not only to a QQmlEngine, but also to a QJSEngine. As QQmlEngine is a subclass of QJSEngine, existing code continues to work. Fixes: QTBUG-83657 Change-Id: Ib29cdb4a9884e1f1b68fcba64d32b1cb2e5a4297 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow multiple URL interceptors per engineUlf Hermann2020-03-171-4/+12
| | | | | | | | | | | We may want to have, for example, a QQmlFileSelector and a component-specific interceptor that chooses a theme or similar. Also, make the API public. We want to propose this as alternative to dynamically registering QML files via qmlRegisterType(QUrl, ...). Change-Id: I4a535d3ea556da6710fde816579ec188b3f57099 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove BC shim for QQmlEngine::addNamedBundle()Ulf Hermann2020-02-121-1/+3
| | | | | | | | Unfortunately we failed to deprecated it in Qt5, but now we can provide it inline. Change-Id: I89e418829ce08e7d0da68e91106ba12a24c8b02a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up the QT_CONFIG(library) conditionsUlf Hermann2019-06-261-0/+2
| | | | | | | | | | | | | We can clear the engine plugins when compiled without library support as those might be static plugins. However, explicitly loading a dynamic plugin is pointless if compiled without library support. We can just disable the whole function. Furthermore, the ability to load dynamic qmldir plugins does not depend on Qt being compiled as shared library but rather on library support being available. Change-Id: I8553706f0f8f5bd4e98cc130bf56c4526f81b85f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move creation and management of singletons to QQmlEnginePrivateRichard Weickelt2019-04-241-6/+1
| | | | | | | | | | | | | | | | | | | | | | Singleton object instances were previously managed by QQmlType::SingletonInstanceInfo and kept in a shared storage. This caused concurrency problems when instantiating singleton instances from different QML engines in different threads. This patch moves the singleton house-keeping infrastructure to QQmlEnginePrivate and makes SingletonInstanceInfo immutable. Singleton objects are stored in a QHash with QQmlType as the key because the qml type id might be 0 for composite singletons. The public API of QQmlType is extended to provide more information about singleton types so that access to SingletonInstanceInfo is not needed. All internal accesses of singleton objects must now take the same code path via QQmlEnginePrivate::singletonInstance<T>() which simplifies overall usage of singletons and scatters less implementation details throughout the code base. Task-number: QTBUG-75007 Change-Id: I13c5fd21cac2eb7291f2cbcf2c2b504f0f51a07c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Provide API to access singletons associated with a QQmlEngineRichard Weickelt2018-06-211-0/+16
| | | | | | | | | | | | | | | | | | | This patch adds allows C++ code to retrieve the instance of a registered singleton type. Until now this required a deturn via QML expression. Two methods are added to QQmlEngine: A generic one that encapsulates all singleton objects in a QJSValue and a template function for QObject-derived singleton types. An additional convenience function is added to query the QML type id. This function may also be used for other purposes in the future. [ChangeLog][QtQml][QQmlEngine] Added API to access singletons associated with a QQmlEngine. Task-number: QTBUG-39970 Change-Id: I67c132ede35f80b9aaf1c5e5456715cf4f1b0848 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use the override keyword consistently and correctly (clang-tidy)Shawn Rutledge2018-02-271-1/+1
| | | | | Change-Id: If9e28d143f8cba3df3c757476b4f2265e2eb8b2a Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* Move qqmldebug.h includes into the right placesUlf Hermann2017-11-091-1/+0
| | | | | | | | We want then in qjsengine.h and qquickwindow.h, as that are the base classes relevant to QML debugging and profiling. Change-Id: Ic4b19b492cd1ec67649f40e2b7e01137aae74baf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Q_NULLPTR with nullptrKevin Funk2017-09-271-1/+1
| | | | | Change-Id: I0c01862dbb475494c84e39c695cb563df8cbcfa8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add support for QEvent::LanguageChangeSimon Hausmann2017-07-141-0/+4
| | | | | | | | | | | | | | | | | | | Respond to the language change event by refreshing all binding expressions. For constant string translation bindings we must now create special QQmlBinding instances instead of a one-time property write meta-call upon instantiation. Those however are more lightweight than an entire JavaScript expression. In addition this provides a slot to explicitly trigger a re-evaluation of bindings, to make it a little easier to discover for the developer. [ChangeLog][QtQml][QQmlEngine] Added retranslate() slot and QEvent::LanguageChange support to refresh bindings when changing the language at run-time. Task-number: QTBUG-15602 Change-Id: Ide174648e1d8a5738acb88e15495018d0869d7bc Reviewed-by: Michael Brasser <michael.brasser@live.com>
* add QQmlEngine::offlineStorageDatabaseFilePath(db), use in LocalStorageShawn Rutledge2017-02-021-0/+1
| | | | | | | | | | | This is C++ API to get the actual storage path for a particular database. [ChangeLog][QtQml] Added QQmlEngine::offlineStorageDatabaseFilePath(dbName) to allow getting the actual storage path for a particular database. Task-number: QTBUG-52013 Change-Id: I1cbd9454c537f08c97f4dafc06fd6b14e81c51af Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-10-181-2/+2
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4variantobject.cpp src/qml/types/qquickworkerscript.cpp src/quick/scenegraph/util/qsgdefaultpainternode_p.h tools/qmljs/qmljs.cpp Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
| * Turn the no-network support into a configurable featureLars Knoll2016-10-101-2/+2
| | | | | | | | | | | | Change-Id: Ic70f60c124fe166b37fbe9b853735be3c5e0d46d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Qml: add missing 'override'Anton Kudryavtsev2016-10-071-1/+1
|/ | | | | | | ... and drop redundant 'virtual' Change-Id: Ib1f68c1ebd0468cb4a77eecc986bbf718f6bf789 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qt object: Add exit(int)Cavit Sina Dogru2016-08-091-0/+1
| | | | | | | | | | | | This is similar to the Qt.quit() function but also specifies the return code that the event loop will return. [ChangeLog][QtQml] Added exit(int retCode) method to the Qt global object. An application can call Qt.exit to specify a return code of the engine. Task-number: QTBUG-54360 Change-Id: Iaa319e6dc4d6b99dc3a5c01845e87b936fd2cab0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devAndy Nichols2016-04-051-1/+1
|\ | | | | | | Change-Id: I57b06e2e98beb010a56dd0593d93e078ecf76eea
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-071-1/+1
| |\ | | | | | | | | | Change-Id: Icfa1d61fcc286c3418d4a625de11d2191336fa60
| | * Make more ctors explicitMarc Mutz2016-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Added explicit where it was missing. This is not a source- incompatible change, because code that breaks by this is a bug. Let's not have this sitting around in an LTS. Change-Id: Ic198750717799126b4e37817845a8ee4684d631f Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
| | * Make public headers compile with -Wzero-as-null-pointer-constantMarc Mutz2016-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... or equivalent. QtBase 5.6 headers already compile that way, so let the other modules follow suit. Task-number: QTBUG-45291 Change-Id: Ied526fb2d7adc3a68946d6843a6bd6f475ebf864 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | | QtLite: no_network option for QtDeclarativePaolo Angelelli2016-03-041-0/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | This patch adds the support for a no_network option for QtDeclarative, and the necessary #ifndef all around the code. no_network changes the interface of some classes, therefore using it breaks source compatibility. Change-Id: Iff612fb07041b8a7db99bd595bf038efaac2dd8a Reviewed-by: Risto Avila <risto.avila@theqtcompany.com> Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
* | Include qqml.h in qqmlengine.h for convenienceMitch Curtis2016-02-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a user creates a Qt Quick Application Project in Creator, they get this main.cpp: int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); } According to the current documentation, if they then want to register a C++ type for use in QML, they need to add a separate "#include <QtQml>" (which is actually a module-wide include and brings a lot of unnecessary files with it). If the most common (or perhaps only) use case for that function (and all of the others declared in qqml.h but documented as requiring QtQml) is related to QQmlEngine, then it makes sense for qqmlengine.h to include qqml.h. This change makes it so that users can use these functions with no changes to the code that Creator provides, as QQmlApplicationEngine includes QQmlEngine. Change-Id: I9d6be2e1abfd4cc831ca04dab4c2a9e50021f748 Task-number: QTBUG-50343 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | 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>
* Add QQuickAsyncImageProviderAlbert Astals Cid2015-03-261-1/+3
| | | | | | | It allows for providers to implement threading on their side Change-Id: I34042b213ce7697a3e39470387357d733e15723c Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Remove forward declaration of QScriptContextLars Knoll2015-03-181-1/+0
| | | | | Change-Id: I2ab642b73bf7fdd5d82085b0dc0f61d32a5c1fb5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.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>
* 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>
* Add a URL interceptor to the QML engineAlan Alpert2013-05-071-0/+4
| | | | | | | | Allows for custom file handling to a greater extent than the QNetworkAccessManager. Change-Id: Ifd3946bf33530c40ca2edeeb9f441f712e4941f6 Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
* Add QQmlApplicationEngineAlan Alpert2013-03-201-0/+1
| | | | | | | | This helper class exposes QML application functionality that QML-only applications want to have, but QML-using applications may not. Change-Id: If91c3f55ffa2a4aecdd9d6cc62f6ad09fd35b0dd Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-281-4/+0
| | | | | | | | | | | The macro was made empty in qtbase/ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Ia07e99676e0134fde5e32880edb95e57c779a7ff Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Alan Alpert <aalpert@rim.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>
* 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>
* Remove obsolete overload of QQmlEngine::importPlugin()Matthew Vogt2012-05-291-1/+0
| | | | | | | Task-number: QTBUG-25122 Change-Id: I63fb462192e6d8292c00755a7d37e72e9110293a Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Remove QQmlEngine::collectGarbage() overloadKent Hansen2012-05-241-2/+0
| | | | | | | | | | | QQmlEngine inherits from QJSEngine, which has a collectGarbage() function that does exactly the same. Also remove doc references to non-existing function reportAdditionalMemoryCost(). Change-Id: Iff12d2cf940f3afcd88967eb9a841c2f6082ca37 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Add QQmlEngine::trimComponentCache()Matthew Vogt2012-05-171-0/+1
| | | | | | | | | | | | Allow unused data in the engine's component cache to be safely discarded so that the memory can be freed for other purposes. Unloading of scripts that are no longer required after trimming unused components is not yet supported. Task-number: QTBUG-25653 Change-Id: I37bc9d5592eeb5edceeb34d010a555dcffd11cea Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Allow image providers to force their loading to be asynchronousTor Arne Vestbø2012-05-111-0/+7
| | | | | | | | | | | | | | | | | | The request methods of an image provider are assumed to be synchronous, but sometimes the provider will be implemented in an async manner, eg. through network request or doing the I/O on a different thread. In that case, the provider can't expose this async behavior to clients, but needs to block in the request method. This is less then ideal for clients, since the default behvior of an image element is to load synchronously, so we introduce a new flag to image providers that let's the provider force the loading to happen on the async image loading thread. Similar to network requests (which are always async), this does not affect the 'asynchronous' property of the image element. Change-Id: I9542abbcc594b9aab565210bc3005a95592c1e9c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com> Reviewed-by: Michalina Ziemba <michalina.ziemba@nokia.com>
* Initial bundle supportAaron Kennedy2012-05-041-1/+2
| | | | | Change-Id: I095249f64ecf4ef1e3fbfb164e3d50edffab61e8 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Provide imageType() from QQmlImageProviderBaseMatthew Vogt2012-03-211-0/+13
| | | | | | | | | | | | | Clients who are only interested in the type of image data provided by an image provider should not need to cast the base pointer to a QQuickImageProvider to access this information. Also make the QQmlImageProviderBase constructor private to prevent unwanted inheritance; all implementors should use the QQuickImageProvider class. Change-Id: Ia2dd2595c2711fa7df47265c9857f45ef0f4cc41 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Remove uses of QtGui symbols in QQmlEngine.Matthew Vogt2012-03-071-3/+8
| | | | | | | | | Move the code dealing with QImage and QPixmap out of QQmlEngine and into the QtQuick library. QQmlEngine remains the owner of image provider resources, but does not use them directly. Change-Id: I52083581394d9c308db446372883eb7479ccf807 Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Rename QDeclarative symbols to QQuick and QQmlMatthew Vogt2012-02-241-0/+138
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>