60void QQuickStylePlugin::registerTypes(
const char *uri)
62 qCDebug(lcStylePlugin).nospace() <<
"registerTypes called with uri " << uri <<
"; plugin name is " << name();
64 const QTypeRevision latestControlsRevision = QQmlMetaType::latestModuleVersion(QLatin1String(
"QtQuick.Controls"));
67 QString styleName = QQuickStylePrivate::style();
68 if (!latestControlsRevision.isValid() && styleName.isEmpty()) {
70 qCDebug(lcStylePlugin).nospace() << uri <<
" imported before QtQuick.Controls; using compile-time style selection";
71 QQuickStyle::setStyle(name());
80 const QString effectiveCurrentStyleName = QQuickStylePrivate::effectiveStyleName(styleName);
81 auto theme = QQuickTheme::instance();
83 qCDebug(lcStylePlugin) <<
"creating theme";
84 theme = createTheme(effectiveCurrentStyleName);
91 const bool thisPluginBelongsToCurrentStyle = name() == effectiveCurrentStyleName;
92 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
93 if (!thisPluginBelongsToCurrentStyle && !isPrimaryFallback) {
94 qCDebug(lcStylePlugin).nospace() <<
"this style plugin does not belong to the current ("
95 << effectiveCurrentStyleName <<
") or fallback (" << QQuickStylePrivate::fallbackStyle()
96 <<
") style; not calling initializeTheme()";
100 if (thisPluginBelongsToCurrentStyle) {
101 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the current style "
102 << effectiveCurrentStyleName <<
"; calling initializeTheme()";
104 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the fallback style "
105 << QQuickStylePrivate::fallbackStyle() <<
"; calling initializeTheme()";
107 initializeTheme(theme);
109 themeChangeObserver.reset(
new QQuickThemeChangeObserver);
110 connect(themeChangeObserver.get(), &QQuickThemeChangeObserver::paletteOrThemeChanged,
111 this, &QQuickStylePlugin::updateTheme);
113 if (!isPrimaryFallback && !styleName.isEmpty())
114 QFileSelectorPrivate::addStatics(QStringList() << styleName);
117void QQuickStylePlugin::unregisterTypes()
119 qCDebug(lcStylePlugin) <<
"unregisterTypes called; plugin name is" << name();
120 if (!QQuickThemePrivate::instance)
123 themeChangeObserver.reset();
125 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
126 const QString styleName = QQuickStylePrivate::style();
127 if (!isPrimaryFallback && !styleName.isEmpty())
128 QFileSelectorPrivate::removeStatics(QStringList() << styleName);
133 QQuickThemePrivate::instance.reset();
134 QQuickStylePrivate::reset();