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()";
108 if (!isPrimaryFallback && !styleName.isEmpty())
109 QFileSelectorPrivate::addStatics(QStringList() << styleName);
119 initializeTheme(theme);
123 themeChangeObserver.reset(
new QQuickThemeChangeObserver);
124 connect(themeChangeObserver.get(), &QQuickThemeChangeObserver::paletteOrThemeChanged,
125 this, &QQuickStylePlugin::updateTheme, Qt::DirectConnection);
128void QQuickStylePlugin::unregisterTypes()
130 qCDebug(lcStylePlugin) <<
"unregisterTypes called; plugin name is" << name();
131 if (!QQuickThemePrivate::instance)
134 themeChangeObserver.reset();
136 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
137 const QString styleName = QQuickStylePrivate::style();
138 if (!isPrimaryFallback && !styleName.isEmpty())
139 QFileSelectorPrivate::removeStatics(QStringList() << styleName);
144 QQuickThemePrivate::instance.reset();
145 QQuickStylePrivate::reset();