31void QQuickStylePlugin::registerTypes(
const char *uri)
33 qCDebug(lcStylePlugin).nospace() <<
"registerTypes called with uri " << uri <<
"; plugin name is " << name();
35 const QTypeRevision latestControlsRevision = QQmlMetaType::latestModuleVersion(QLatin1String(
"QtQuick.Controls"));
38 QString styleName = QQuickStylePrivate::style();
39 if (!latestControlsRevision.isValid() && styleName.isEmpty()) {
41 qCDebug(lcStylePlugin).nospace() << uri <<
" imported before QtQuick.Controls; using compile-time style selection";
42 QQuickStyle::setStyle(name());
51 const QString effectiveCurrentStyleName = QQuickStylePrivate::effectiveStyleName(styleName);
52 auto theme = QQuickTheme::instance();
54 qCDebug(lcStylePlugin) <<
"creating theme";
55 theme = createTheme(effectiveCurrentStyleName);
62 const bool thisPluginBelongsToCurrentStyle = name() == effectiveCurrentStyleName;
63 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
64 if (!thisPluginBelongsToCurrentStyle && !isPrimaryFallback) {
65 qCDebug(lcStylePlugin).nospace() <<
"this style plugin does not belong to the current ("
66 << effectiveCurrentStyleName <<
") or fallback (" << QQuickStylePrivate::fallbackStyle()
67 <<
") style; not calling initializeTheme()";
71 if (thisPluginBelongsToCurrentStyle) {
72 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the current style "
73 << effectiveCurrentStyleName <<
"; calling initializeTheme()";
75 qCDebug(lcStylePlugin).nospace() <<
"this style plugin belongs to the fallback style "
76 << QQuickStylePrivate::fallbackStyle() <<
"; calling initializeTheme()";
78 initializeTheme(theme);
79 connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged,
80 this, &QQuickStylePlugin::updateTheme);
82 if (!isPrimaryFallback && !styleName.isEmpty())
83 QFileSelectorPrivate::addStatics(QStringList() << styleName);
86void QQuickStylePlugin::unregisterTypes()
88 qCDebug(lcStylePlugin) <<
"unregisterTypes called; plugin name is" << name();
89 if (!QQuickThemePrivate::instance)
92 disconnect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged,
93 this, &QQuickStylePlugin::updateTheme);
95 const bool isPrimaryFallback = name() == QQuickStylePrivate::fallbackStyle();
96 const QString styleName = QQuickStylePrivate::style();
97 if (!isPrimaryFallback && !styleName.isEmpty())
98 QFileSelectorPrivate::removeStatics(QStringList() << styleName);
103 QQuickThemePrivate::instance.reset();
104 QQuickStylePrivate::reset();