233void QQStyleKitStyle::setFallbackStyle(QQStyleKitStyle *fallbackStyle)
235 if (m_fallbackStyle == fallbackStyle)
238 m_fallbackStyle = fallbackStyle;
239 emit fallbackStyleChanged();
242 palettes()->setFallbackPalette(m_fallbackStyle ? m_fallbackStyle->palettes() :
nullptr);
245 fonts()->setFallbackFont(m_fallbackStyle ? m_fallbackStyle->fonts() :
nullptr);
345void QQStyleKitStyle::recreateTheme()
347 QString effectiveThemeName;
348 QQmlComponent *effectiveThemeComponent =
nullptr;
350 if (QString::compare(m_themeName, kSystem, Qt::CaseInsensitive) == 0) {
351 const auto scheme = QGuiApplication::styleHints()->colorScheme();
352 if (scheme == Qt::ColorScheme::Light) {
353 effectiveThemeName = kLight;
354 effectiveThemeComponent = m_light;
356 else if (scheme == Qt::ColorScheme::Dark) {
357 effectiveThemeName = kDark;
358 effectiveThemeComponent = m_dark;
360 }
else if (QString::compare(m_themeName, kLight, Qt::CaseInsensitive) == 0) {
361 effectiveThemeName = kLight;
362 effectiveThemeComponent = m_light;
363 }
else if (QString::compare(m_themeName,kDark, Qt::CaseInsensitive) == 0) {
364 effectiveThemeName =kDark;
365 effectiveThemeComponent = m_dark;
366 }
else if (!m_themeName.isEmpty()){
367 for (
auto *customTheme : customThemes()) {
368 if (QString::compare(m_themeName, customTheme->name(), Qt::CaseInsensitive) == 0) {
369 effectiveThemeName = customTheme->name();
370 effectiveThemeComponent = customTheme->theme();
374 if (effectiveThemeName.isEmpty())
375 qmlWarning(
this) <<
"No theme found with name:" << m_themeName;
376 else if (!effectiveThemeComponent)
377 qmlWarning(
this) <<
"Custom theme '" << effectiveThemeName <<
"' has no theme component set";
380 if (m_effectiveThemeName == effectiveThemeName)
384 m_theme->deleteLater();
388 m_effectiveThemeName = effectiveThemeName;
389 m_currentThemeComponent = effectiveThemeComponent;
391 if (effectiveThemeComponent) {
392 if (effectiveThemeComponent->status() != QQmlComponent::Ready) {
393 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
396
397
398
399
400 QVariant themeAsVariant;
401 QMetaObject::invokeMethod(
this,
"createThemeInsideStyle", Qt::DirectConnection,
402 qReturnArg(themeAsVariant), QVariant::fromValue(effectiveThemeComponent));
403 m_theme = qvariant_cast<QQStyleKitTheme *>(themeAsVariant);
405 if (!m_theme || !effectiveThemeComponent->errorString().isEmpty()) {
406 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
408 m_theme->setParent(
this);
415 m_theme =
new QQStyleKitTheme(
this);
416 m_theme->setObjectName(
"<empty theme>"_L1);
417 m_theme->m_completed =
true;
419 m_theme->setParent(
this);
422 if (m_theme->fonts())
423 m_theme->fonts()->setFallbackFont(fonts());
424 if (m_theme->palettes())
425 m_theme->palettes()->setFallbackPalette(palettes());
427 m_theme->updateThemePalettes();
428 m_theme->updateThemeFonts();
430 QQStyleKitVariation::resetVariationsForStyle(
this);
431 QQStyleKitReader::resetReadersForStyle(
this);