* @brief Reloads user themes when a new addon is installed. */
| 561 | * @brief Reloads user themes when a new addon is installed. |
| 562 | */ |
| 563 | void Misc::ThemeManager::onExtensionInstalled(const QString& id) |
| 564 | { |
| 565 | const auto previousUserThemes = m_userThemeNames; |
| 566 | |
| 567 | m_availableThemes.removeAll(QStringLiteral("System")); |
| 568 | loadUserThemes(); |
| 569 | m_availableThemes.append(QStringLiteral("System")); |
| 570 | |
| 571 | const auto& ext = Misc::ExtensionManager::instance(); |
| 572 | const auto info = ext.selectedExtension(); |
| 573 | const bool isTheme = id.isEmpty() || info.value("type").toString() == QStringLiteral("theme"); |
| 574 | |
| 575 | if (isTheme) { |
| 576 | for (const auto& name : std::as_const(m_userThemeNames)) { |
| 577 | if (previousUserThemes.contains(name)) |
| 578 | continue; |
| 579 | |
| 580 | const int idx = m_availableThemes.indexOf(name); |
| 581 | if (idx < 0) |
| 582 | continue; |
| 583 | |
| 584 | setTheme(idx); |
| 585 | updateLocalizedThemeNames(); |
| 586 | Q_EMIT languageChanged(); |
| 587 | return; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | const int idx = m_availableThemes.indexOf(m_themeName); |
| 592 | if (idx >= 0) |
| 593 | m_theme = idx; |
| 594 | |
| 595 | updateLocalizedThemeNames(); |
| 596 | Q_EMIT languageChanged(); |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * @brief Reloads user themes when an addon is uninstalled. |