MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / onExtensionInstalled

Method onExtensionInstalled

app/src/Misc/ThemeManager.cpp:563–597  ·  view source on GitHub ↗

* @brief Reloads user themes when a new addon is installed. */

Source from the content-addressed store, hash-verified

561 * @brief Reloads user themes when a new addon is installed.
562 */
563void 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.

Callers

nothing calls this directly

Calls 6

selectedExtensionMethod · 0.80
isEmptyMethod · 0.80
appendMethod · 0.45
valueMethod · 0.45
containsMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected