62void QQuickStylePlugin::registerTypes(
const char *uri)
64 qCDebug(lcStylePlugin).nospace() <<
"registerTypes called with uri " << uri <<
"; plugin name is " << name();
66 const QTypeRevision latestControlsRevision = QQmlMetaType::latestModuleVersion(QLatin1String(
"QtQuick.Controls"));
69 QString styleName = QQuickStylePrivate::style();
70 if (!latestControlsRevision.isValid() && styleName.isEmpty()) {
72 qCDebug(lcStylePlugin).nospace() << uri <<
" imported before QtQuick.Controls; using compile-time style selection";
73 QQuickStyle::setStyle(name());
82 const QString effectiveCurrentStyleName = QQuickStylePrivate::effectiveStyleName(styleName);
83 auto theme = QQuickTheme::instance();
85 qCDebug(lcStylePlugin) <<
"creating theme";
86 theme = createTheme(effectiveCurrentStyleName);
93 const bool thisPluginBelongsToCurrentStyle = name() == effectiveCurrentStyleName;
94 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
95 if (!thisPluginBelongsToCurrentStyle && !isPrimaryFallback) {
96 qCDebug(lcStylePlugin).nospace() <<
"this style plugin does not belong to the current ("
97 << effectiveCurrentStyleName <<
") or fallback (" << QQuickStylePrivate::fallbackStyle()
98 <<
") style; not calling initializeTheme()";
102 if (thisPluginBelongsToCurrentStyle) {
103 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the current style "
104 << effectiveCurrentStyleName <<
"; calling initializeTheme()";
106 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the fallback style "
107 << QQuickStylePrivate::fallbackStyle() <<
"; calling initializeTheme()";
110 if (!isPrimaryFallback && !styleName.isEmpty())
111 QFileSelectorPrivate::addStatics(QStringList() << styleName);
121 initializeTheme(theme);
125 themeChangeObserver.reset(
new QQuickThemeChangeObserver);
126 connect(themeChangeObserver.get(), &QQuickThemeChangeObserver::paletteOrThemeChanged,
127 this, &QQuickStylePlugin::updateTheme, Qt::DirectConnection);
130void QQuickStylePlugin::unregisterTypes()
132 qCDebug(lcStylePlugin) <<
"unregisterTypes called; plugin name is" << name();
133 if (!QQuickThemePrivate::instance)
136 themeChangeObserver.reset();
138 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
139 const QString styleName = QQuickStylePrivate::style();
140 if (!isPrimaryFallback && !styleName.isEmpty())
141 QFileSelectorPrivate::removeStatics(QStringList() << styleName);
146 QQuickThemePrivate::instance.reset();
147 QQuickStylePrivate::reset();