diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-04-01 15:37:07 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-08-26 11:45:55 +0200 |
commit | 9aafea810b8867fb31f9ec27a238628467e7ab56 (patch) | |
tree | 061b16374195312e6df496e15430f540b76057d9 /src/quickcontrols2 | |
parent | ef771a0fd70f05d7204fb8cbd8789aa1ed6eff4b (diff) |
Move Default style out into its own plugin
In upcoming patches, we start registering C++ types declaratively.
A condition of doing so requires that each .pro corresponds to one
QML module. This conflicts with the QtQuick.Controls import, which
currently does quite a lot:
- Registers (and selects) QML files for the style that was set
- Registers private C++ utility types (such as IconLabel) that are
useful for all styles under the QtQuick.Controls.impl import
- Registers private C++ types that are only useful for the Default
style (such as BusyIndicatorImpl).
The reason it does so much can probably be explained by the
intended usage of Qt Quick Controls 2; when you do
import QtQuick.Controls 2.0
you get access to the QML types (e.g. Button) that the style
you're using provides. So if you're using the Material style,
you'll get a Material style button. API-wise, the button is
identical to any other button, because the types in
QtQuick.Templates are what we advertise as the public API.
If we didn't have this functionality, users would need to
import specific style imports to use controls, and the
convenience of being able to simply start the application
with a different style by e.g. passing an application argument
would be lost.
To support declarative registration of types while also supporting
the existing use cases, we split out the Default-style-specific
stuff into a QtQuick.Controls.Default import.
Task-number: QTBUG-82922
Change-Id: Ib4f1620cae78d7acdc13d9ac0752a020bc22f3ea
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 9 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin_p.h | 2 | ||||
-rw-r--r-- | src/quickcontrols2/quickcontrols2.pro | 7 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp index 067d8dff..b387b378 100644 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ b/src/quickcontrols2/qquickstyleplugin.cpp @@ -57,13 +57,4 @@ QString QQuickStylePlugin::name() const return QString(); } -void QQuickStylePlugin::initializeTheme(QQuickTheme *theme) -{ - Q_UNUSED(theme); -} - -void QQuickStylePlugin::registerTypes(const char */*uri*/) -{ -} - QT_END_NAMESPACE diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h index a9700c15..f5c5705c 100644 --- a/src/quickcontrols2/qquickstyleplugin_p.h +++ b/src/quickcontrols2/qquickstyleplugin_p.h @@ -64,7 +64,7 @@ public: ~QQuickStylePlugin(); virtual QString name() const; - virtual void initializeTheme(QQuickTheme *theme); + virtual void initializeTheme(QQuickTheme *theme) = 0; void registerTypes(const char *uri) override; diff --git a/src/quickcontrols2/quickcontrols2.pro b/src/quickcontrols2/quickcontrols2.pro index 8aec9953..5a11dcd2 100644 --- a/src/quickcontrols2/quickcontrols2.pro +++ b/src/quickcontrols2/quickcontrols2.pro @@ -11,4 +11,11 @@ HEADERS += \ $$PWD/qtquickcontrols2global_p.h include(quickcontrols2.pri) + +QMLTYPES_FILENAME = plugins.qmltypes +QMLTYPES_INSTALL_DIR = $$[QT_INSTALL_QML]/QtQuick/Controls.2 +QML_IMPORT_NAME = QtQuick.Controls +QML_IMPORT_VERSION = 2.15 +CONFIG += qmltypes install_qmltypes install_metatypes + load(qt_module) |