215void QQStyleKitStyle::setFallbackStyle(QQStyleKitStyle *fallbackStyle)
217 if (m_fallbackStyle == fallbackStyle)
220 m_fallbackStyle = fallbackStyle;
221 emit fallbackStyleChanged();
224 palettes()->setFallbackPalette(m_fallbackStyle ? m_fallbackStyle->palettes() :
nullptr);
227 fonts()->setFallbackFont(m_fallbackStyle ? m_fallbackStyle->fonts() :
nullptr);
319void QQStyleKitStyle::recreateTheme()
321 QString effectiveThemeName;
322 QQmlComponent *effectiveThemeComponent =
nullptr;
324 if (QString::compare(m_themeName, kSystem, Qt::CaseInsensitive) == 0) {
325 switch (QGuiApplication::styleHints()->colorScheme()) {
326 case Qt::ColorScheme::Dark:
327 effectiveThemeName = kDark;
328 effectiveThemeComponent = m_dark;
330 case Qt::ColorScheme::Light:
331 case Qt::ColorScheme::Unknown:
332 effectiveThemeName = kLight;
333 effectiveThemeComponent = m_light;
339 }
else if (QString::compare(m_themeName, kLight, Qt::CaseInsensitive) == 0) {
340 effectiveThemeName = kLight;
341 effectiveThemeComponent = m_light;
342 }
else if (QString::compare(m_themeName,kDark, Qt::CaseInsensitive) == 0) {
343 effectiveThemeName =kDark;
344 effectiveThemeComponent = m_dark;
345 }
else if (!m_themeName.isEmpty()){
346 for (
auto *customTheme : customThemes()) {
347 if (QString::compare(m_themeName, customTheme->name(), Qt::CaseInsensitive) == 0) {
348 effectiveThemeName = customTheme->name();
349 effectiveThemeComponent = customTheme->theme();
353 if (effectiveThemeName.isEmpty())
354 qmlWarning(
this) <<
"No theme found with themeName '" << m_themeName <<
"'";
355 else if (!effectiveThemeComponent)
356 qmlWarning(
this) <<
"Custom theme '" << effectiveThemeName <<
"' has no theme component set";
360 if (m_effectiveThemeName == effectiveThemeName)
363 m_theme->deleteLater();
367 m_effectiveThemeName = effectiveThemeName;
368 m_currentThemeComponent = effectiveThemeComponent;
370 if (effectiveThemeComponent) {
371 if (effectiveThemeComponent->status() != QQmlComponent::Ready) {
372 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
375
376
377
378
379 QVariant themeAsVariant;
380 QMetaObject::invokeMethod(
this,
"createThemeInsideStyle", Qt::DirectConnection,
381 qReturnArg(themeAsVariant), QVariant::fromValue(effectiveThemeComponent));
382 m_theme = qvariant_cast<QQStyleKitTheme *>(themeAsVariant);
384 if (!m_theme || !effectiveThemeComponent->errorString().isEmpty()) {
385 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
387 m_theme->setParent(
this);
394 m_theme =
new QQStyleKitTheme(
this);
395 m_theme->setObjectName(
"<empty theme>"_L1);
396 m_theme->m_completed =
true;
398 m_theme->setParent(
this);
401 if (m_theme->fonts())
402 m_theme->fonts()->setFallbackFont(fonts());
403 if (m_theme->palettes())
404 m_theme->palettes()->setFallbackPalette(palettes());