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);
327void QQStyleKitStyle::recreateTheme()
329 QString effectiveThemeName;
330 QQmlComponent *effectiveThemeComponent =
nullptr;
332 if (QString::compare(m_themeName, kSystem, Qt::CaseInsensitive) == 0) {
333 switch (QGuiApplication::styleHints()->colorScheme()) {
334 case Qt::ColorScheme::Dark:
335 effectiveThemeName = kDark;
336 effectiveThemeComponent = m_dark;
338 case Qt::ColorScheme::Light:
339 case Qt::ColorScheme::Unknown:
340 effectiveThemeName = kLight;
341 effectiveThemeComponent = m_light;
347 }
else if (QString::compare(m_themeName, kLight, Qt::CaseInsensitive) == 0) {
348 effectiveThemeName = kLight;
349 effectiveThemeComponent = m_light;
350 }
else if (QString::compare(m_themeName,kDark, Qt::CaseInsensitive) == 0) {
351 effectiveThemeName =kDark;
352 effectiveThemeComponent = m_dark;
353 }
else if (!m_themeName.isEmpty()){
354 for (
auto *customTheme : customThemes()) {
355 if (QString::compare(m_themeName, customTheme->name(), Qt::CaseInsensitive) == 0) {
356 effectiveThemeName = customTheme->name();
357 effectiveThemeComponent = customTheme->theme();
361 if (effectiveThemeName.isEmpty())
362 qmlWarning(
this) <<
"No theme found with themeName '" << m_themeName <<
"'";
363 else if (!effectiveThemeComponent)
364 qmlWarning(
this) <<
"Custom theme '" << effectiveThemeName <<
"' has no theme component set";
368 if (m_effectiveThemeName == effectiveThemeName)
371 m_theme->deleteLater();
375 m_effectiveThemeName = effectiveThemeName;
376 m_currentThemeComponent = effectiveThemeComponent;
378 if (effectiveThemeComponent) {
379 if (effectiveThemeComponent->status() != QQmlComponent::Ready) {
380 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
383
384
385
386
387 QVariant themeAsVariant;
388 QMetaObject::invokeMethod(
this,
"createThemeInsideStyle", Qt::DirectConnection,
389 qReturnArg(themeAsVariant), QVariant::fromValue(effectiveThemeComponent));
390 m_theme = qvariant_cast<QQStyleKitTheme *>(themeAsVariant);
392 if (!m_theme || !effectiveThemeComponent->errorString().isEmpty()) {
393 qmlWarning(
this) <<
"failed to create theme '" << effectiveThemeName <<
"': " << effectiveThemeComponent->errorString();
395 m_theme->setParent(
this);
402 m_theme =
new QQStyleKitTheme(
this);
403 m_theme->setObjectName(
"<empty theme>"_L1);
404 m_theme->m_completed =
true;
406 m_theme->setParent(
this);
409 if (m_theme->fonts())
410 m_theme->fonts()->setFallbackFont(fonts());
411 if (m_theme->palettes())
412 m_theme->palettes()->setFallbackPalette(palettes());