aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update to latest qml CMake APICraig Scott2021-06-051-80/+0
| | | | | | | | | | | | | | The new qml CMake API places a closer relationship between the backing target and the plugin target. Both are typically created together and they share a lot of common details. Instead of creating them in different parts of the source tree, they are now specified together. The src/imports area has effectively been absorbed into the other corresponding subdirectories below src with this change. Task-number: QTBUG-91621 Change-Id: I9bd32e9eb78c198ccc9db04e2829303cac323502 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix static buildEskil Abrahamsen Blomfeldt2020-10-091-0/+4
| | | | | | | | The register_types() function was optimized away by the linker and the imports would not be found. Change-Id: I3d98602daf78996399630b7b1296cc5dc0d3da05 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix fallback styles overwriting themesMitch Curtis2020-09-241-9/+3
| | | | | | | | | | | | | | | | | | | | | In Qt 5, QtQuickControls2Plugin::registerTypes() was responsible for calling initializeTheme() on each style plugin. Now that we delegate more work to the QML engine, each style plugin calls initializeTheme() via registerTypes(). To avoid fallback styles overwriting font and palette data set by the current style, we need to check if the theme has been intialized before calling initializeTheme(). To do this, we add a static "themeInitialized" bool that QQuickStylePlugin sets to true after calling intializeTheme() for the first time. It checks this value and avoids calling intializeTheme() if it's true. We also need to make QQuickStylePlugin ensure that the theme it's initializing belongs to the current style. Fixes: QTBUG-86303 Change-Id: Ie65e646677c78622829f4949c41cb79204cf5786 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Fix crash when importing a style without first importing ControlsMitch Curtis2020-08-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following code import QtQuick import QtQuick.Controls.Material ApplicationWindow { width: 200 height: 200 visible: true } produced an error in Qt 5: QQmlApplicationEngine failed to load component qrc:/main.qml:4 ApplicationWindow is not a type In Qt 6, the types are provided by the qmldir, so the import will work, but as QtQuickControls2Plugin has not been loaded, there is no QQuickTheme object yet, and so the style will not work as expected (any colors, fonts, etc. from the theme will not be used by the style). Produce a warning for this scenario, and test each style to make sure that we don't crash. Fixes: QTBUG-86280 Change-Id: I99f940255f56da0522ad192ae5da4c9110ea308e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use qmlRegisterModuleImport() to register stylesMitch Curtis2020-08-261-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch completes the cumulative work done in previous patches. - Uses qmlRegisterModuleImport() to register styles. This has some added requirements: - Each style must now be a QML module -- that is, it must have a qmldir file. - As a result of the above, the module must be available within the QML import path in order to be found. - The various forms of accepted style names have been reduced down to one ("Material", "MyStyle", etc). See below for an explanation of why. - The following API in QQuickStyle is removed: addStylePath(), availableStyles(), path(), stylePathList(). These no longer make sense now that we reuse the existing QML import system. - Adds the tst_qquickstyleselector auto test back as "styleimports". qmlRegisterModuleImport() vs resolvedUrl() Previously we would use QQuickStyleSelector to select individual QML files based on which style was set. We'd do this once when QtQuick.Controls was first imported. With Qt 6, and the requirement that each style be a proper QML module, qmlRegisterModuleImport() was introduced. This allows us to "link" one import with another. For an example of what this looks like in practice, suppose the style was set to "MyStyle", and the fallback to "Material". The "QtQuick.Controls" import will be linked to "MyStyle", "MyStyle" to "QtQuick.Controls.Material", and as a final fallback (for controls like Action which only the Default style implements), "QtQuick.Controls.Material" to "QtQuick.Controls.Default". This is the same behavior as in Qt 5 (see qquickstyleselector.cpp): // 1) requested style (e.g. "MyStyle", included in d->selectors) // 2) fallback style (e.g. "Material", included in d->selectors) // 3) default style (empty selector, not in d->selectors) This is a necessary step to enable compilation of QML to C++. Reducing the set of accepted style names The problem In QtQuickControls2Plugin() we need to call QQuickStylePrivate::init(baseUrl()) in order to detect if the style is a custom style in QQuickStyleSpec::resolve() (by checking if the style path starts with the base URL). In Qt 5, init() is called in QtQuickControls2Plugin::registerTypes(), but in Qt 6 that's too late, because we need to call qmlRegisterModuleImport() in the constructor. qmlRegisterModuleImport() itself requires the style to have already been set in order to create the correct import URI ("QtQuick.Controls.X" for built-in styles, "MyCustomStyle" for custom styles). The solution By reducing the valid forms for style names down to one: ./myapp -style MyStyle we solve the problem of needing baseUrl() to determine if the style is a custom style or not, but needing to call it too early (since we now call qmlRegisterModuleImport() in QtQuickControls2Plugin(), which itself requires the style to have already been set). baseUrl() can't have been set before the constructor is finished. All of the various forms for _setting_ a style are still valid; environment variables, qtquickcontrols2.conf, etc. [ChangeLog][Important Behavior Changes] Custom styles must now have a qmldir that lists the files that the style implements. For example, for a style that only implements Button: --- module MyStyle Button 1.0 Button.qml --- In addition, there is now only one valid, case-sensitive form for style names: "Material", "MyStyle", etc. These changes are done to help enable the compilation of QML code to C++, as well as improve tooling capabilities. [ChangeLog][Important Behavior Changes] The following API was removed: - QQuickStyle::addStylePath() - QQuickStyle::availableStyles() - QQuickStyle::path() - QQuickStyle::stylePathList() - QT_QUICK_CONTROLS_STYLE_PATH This API is no longer necessary and/or able to be provided now that styles are treated as regular QML modules. Task-number: QTBUG-82922 Change-Id: I3b281131903c7c3c1cf0616eb7486a872dccd730 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Convert remaining imperative type registration to declarativeMitch Curtis2020-08-261-12/+0
| | | | | | Task-number: QTBUG-82922 Change-Id: I34e9f32d5f695aaac7acf6b4aac30e8a2311e0cf Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Register C++ types declarativelyMitch Curtis2020-08-261-11/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Adapt to the new way of registering C++ types. The types need to be seen at compile time so that code can be generated that invokes them. This patch: - Adds QML_* macros where applicable. - Adapts the build system files to the new way of registering modules. - Splits up the QtQuick.Controls[.*].impl files into their own plugins, as we can only register one QML module per .pro file. - Removes C++ type registration calls in every plugin. - Moves private types from src/quickcontrols2/quickcontrols2.pro to src/quickcontrols2/impl/quickcontrols2-impl.pro. Some of these types need to be exposed to QML, but quickcontrols2.pro is already in use to declare the QtQuick.Controls import (and also provides the public C++ QQuickStyle API), and the new QML_IMPORT_NAME/VERSION syntax only allows one module per project. As some of the types that need to be exposed to QML are also referenced by some C++ code (e.g. tests, etc.), we just move all of the private types to the new library. Follow-up patches will register the QML types declaratively. Task-number: QTBUG-82922 Change-Id: Iaf9ee106237d61701d57a8896f3822304c8151a6 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix Qt6 buildAlexandru Croitor2019-08-051-2/+2
| | | | | | | | | | | Modify all the qmlRegisterModule calls to use minor version 15 because minor version zero from 6.0.0 would make tests fail. This is similar to what was done in qtdeclarative in c147b20a2c1299b2d659fe7c9472ae3866b6a425. Change-Id: I0ef33024ead0f7b4782023e34ce1232ba987e62a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Tie minor version of all imports to Qt's minor versionMitch Curtis2018-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes all Qt Quick Controls 2 imports match the current Qt minor version, which is 12 as of this patch. It also updates all other Qt Quick imports to match. This will also make future version bumps easier as all version numbers in existing code/docs will match. The following commands were used to verify that no old versions remain: for i in `seq 0 11`; do git grep "import QtGraphicalEffects.*1.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick 2.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick.Layouts 1.$i$"; done for i in `seq 0 5`; do git grep "import QtQuick.Controls.*2.$i$"; done for i in `seq 0 11`; do git grep "import QtQuick.Templates 2.$i as T$"; done [ChangeLog] From Qt 5.12 onwards, all import versions in Qt Quick Controls 2 follow the same minor version as Qt's minor version number. For example, the import version for Qt 5.12 is: "import QtQuick.Controls 2.12". Change-Id: I6d87573f20912e041d9c3b7c773cc7bf7b152ec3 Fixes: QTBUG-71095 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Create and init QQuickTheme from QtQuickControls2PluginJ-P Nurmi2018-05-221-3/+3
| | | | | | | | | | | | | | | Instead of creating and setting the QQuickTheme instance from each style plugin (e.g. QtQuickControls2MaterialStylePlugin), create the QQuickTheme instance in QtQuickControls2Plugin when the style is being resolved, and just pass the instance to be initialized by the style plugin(s). This avoids the problem that QQuickTheme API was virtual, and sub-classes created from plugins would have vtables destroyed before the QQuickTheme was destroyed. Task-number: QTBUG-67062 Task-number: QTBUG-68087 Change-Id: I19e9ced5296b708c2668c30163389cb3da6be7cf Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QQuickStylePlugin: prepare for Qt Quick CompilerJ-P Nurmi2018-05-121-3/+3
| | | | | | | | | | Don't hardcode the URL (QRC in static vs. FS in dynamic), but make use of QQuickFileSelector so the appropriate URL gets chosen "for free". This way, we can later add Qt Quick Compiler support for the internal QML files, such as CheckIndicator.qml. Change-Id: Ie1c55f3d82fbf92d0116966b354298338ef5ace6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Remove the code to manually initialize resources in static buildsSimon Hausmann2018-04-271-9/+0
| | | | | | | | | After commit be9a56e5e3ced5d0d668fa24e4c65ae928f2e25a in qtbase, this is not needed anymore. Instead the resource system injects the plugin entry point with a reference to all resources. Change-Id: Ic3fa0827ee6719b0a22f73b48667deb129089a6f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devJ-P Nurmi2018-02-151-6/+1
|\ | | | | | | Change-Id: Id3333e9bb67ced4c6dbae5845512fe1927a7b858
| * QQuickUniversalStyle: init the globals from the pluginJ-P Nurmi2018-02-121-0/+1
| | | | | | | | | | Change-Id: I9df13f980b565b4f846edc3bce8333b74f5366b9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
| * Fix memory leak in QQC2Simon Hausmann2018-02-071-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When repeatedly creating a QQuickView, loading a QML file that imports QQC2 and deleting the view again, we would leak memory that was allocated as a consequence of QML type registration in initializeEngine() callbacks that were called on every iteration. After the limitation of namespacing in the registerTypes() callback of QML module plugins has been lifted, we can move the type registrations into registerTypes() where they belong and which is called only once. Change-Id: I7e314663a69fd8c8529195b56c128b61392c0042 Reviewed-by: J-P Nurmi <jpnurmi@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Michael Winkelmann <michael.winkelmann@qt.io>
* | Read :/qtquickcontrols2.conf in QQuickStylePluginJ-P Nurmi2018-02-151-3/+3
|/ | | | | | | | | | | | | | | | | QQuickTheme is going to be promoted from libQQC2 to libQQT2 so that it can provide dark and light palettes (and later, icons). The first step is to refactor out the :/qtquickcontrols2.conf reading code, which cannot be in style-agnostic libQQT2. Read the conf file in QQuickStyle Plugin instead. The additional benefit is that we don't need duplicate name() methods for styles and their themes. Even though QQuickStyle Plugin's name handling is case-insensitive, QSetting is case-sensitive. Therefore all QQuickStylePlugin::name() overrides have been updated to use capital first letter. This name is used to lookup the correct section in :/qtquickcontrols2.conf. Task-number: QTBUG-63331 Change-Id: I07b1269d9dbc2c9568e6f22f2da75951fde7b669 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Replace QQuickColorImageProvider with QQuickColorImageJ-P Nurmi2017-04-181-4/+0
| | | | | | | | | | | | | | | | | Now that QQuickImage is exported, we can colorize images using a simple QQuickImage subclass instead of using an image provider. The main issue with QQuickColorImageProvider was that it was based on QGuiApplication::devicePixelRatio(). Now each QQuickColorImage handles its device pixel ratio correctly depending on which screen it is on. Even though we now have to use two bindings (color and source) instead of encoding the color to the source, at the same time we can remove the sourceSize bindings that were added as image provider specific high DPI workarounds (ca87ab8). Task-number: QTBUG-58925 Change-Id: Iba14d2afe3bda540189682ba5be7c58d907d88f7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-101-0/+2
|\ | | | | | | | | | | | | | | | | Conflicts: src/imports/controls/universal/qtquickcontrols2universalstyleplugin.cpp src/quicktemplates2/qquicktextarea.cpp src/quicktemplates2/qquicktextfield.cpp Change-Id: Ie80a2d3bcbb961a38e3dffa247547d3d860c231a
| * Add missing QML type registrationsJ-P Nurmi2017-02-201-0/+1
| | | | | | | | | | | | | | | | For the internal Radio and CheckIndicator types. Task-number: QTBUG-59026 Change-Id: I7e34f29e33ebd3d748892df0ba1592fe8ae5ed44 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Merge remote-tracking branch 'origin/5.8' into devJ-P Nurmi2017-01-111-1/+1
|\| | | | | | | Change-Id: If797ac58344b20e8de4379343131c097247ba2f2
| * Welcome to 2017J-P Nurmi2017-01-091-1/+1
| | | | | | | | | | Change-Id: If68cff4efacc7dc5719c8b8e61937e85e9076870 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Make sure the appropriate import versions are always availableJ-P Nurmi2016-11-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Utilize the newly introduced qmlRegisterModule() to automatically register the import version that matches the Qt version that is used to build the module. Now we can remove the artificial qmlRegisterRevision() calls, which were added just to make certain import versions available, even if there was no such revision. Change-Id: Ic3887c221c69b6cd299853d8d5869b8af7a314ec Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Universal: rewrite the indeterminate progress bar animationJ-P Nurmi2016-10-191-3/+2
| | | | | | | | | | | | | | | | Use a simple animated node instead of using the private animator API. Task-number: QTBUG-56601 Change-Id: I74387eddc41ac1ed6f3ae9466674276f6a9ae5c2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Universal: rewrite the busy indicator animationJ-P Nurmi2016-10-181-3/+2
|/ | | | | | | | Use a simple animated node instead of using the private animator API. Task-number: QTBUG-56601 Change-Id: I0ff6c8b55bc4a0a991bcbef8fc18086226beb6b2 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Restore version 2.0 for the .impl importsJ-P Nurmi2016-08-101-9/+10
| | | | | | | | | | | It's a bit of extra hassle, but the type registration can be done so that we keep the old version available to avoid deliberately breaking apps that have had to import .impl to gain access to the internal goodies. For example, someone may have made a copy of one of the controls as our documentation suggests. :) Change-Id: I5308d7e74ecebf69da7fe9c6912380f72c3c9a2b Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Bump up all controls and templates imports to version 2.1J-P Nurmi2016-07-081-8/+8
| | | | | | | | | | | | Controls must import templates version 2.1 in order to "inherit" 1-revisioned properties, methods, and signals. So far, this has been done case by case, but it's less error prone and more clear to change them all. For example, if you ever see a source file pasted/linked somewhere, it's easy to identify the version it belongs to. Change-Id: I41609ec1a22bc05ac3e79f953a147ca42d9e0786 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Make import version 2.1 available for Material & UniversalJ-P Nurmi2016-06-211-0/+1
| | | | | Change-Id: Ia3ab14fdb67e32907396329ab9034a429c7b536e Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-1/+1
| | | | | | | | | | | | | | | Conflicts: .qmake.conf src/imports/controls/doc/qtlabscontrols.qdocconf src/imports/controls/doc/qtquickcontrols2.qdocconf src/imports/controls/material/qtlabsmaterialstyleplugin.cpp src/imports/controls/material/qtquickcontrols2materialstyleplugin.cpp src/imports/controls/qtlabscontrolsplugin.cpp src/imports/controls/qtquickcontrols2plugin.cpp src/imports/templates/qtlabstemplatesplugin.cpp src/imports/templates/qtquicktemplates2plugin.cpp Change-Id: I6159e681b77e4a0a293b6bd7fb11a46d58873da0
* Fix Q_INIT_RESOURCE() for static buildsJ-P Nurmi2016-04-261-1/+1
| | | | | | Change-Id: Ibf864c5c145065fe13dfb958bc4f5fa6a887a1be Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
* Rename the style pluginsJ-P Nurmi2016-04-221-0/+111
Mention controls2 in the plugin names for the sake of consistency and to achieve a clear deployment structure where all plugin names match with their deployment folder. Change-Id: I73cac5eec341f0d2e6ebaadfaa1796808fcb80e5 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>