Don't make new ThemeManager instance.

Took 8 minutes
This commit is contained in:
Lukas Brübach 2026-06-19 15:56:40 +02:00
parent 2e754f6ec0
commit c1098399da
2 changed files with 4 additions and 13 deletions

View file

@ -267,7 +267,7 @@ void PaletteEditorDialog::onSave()
}
// Record the active scheme in the user dir — never touch the system (read-only) dir
ThemeConfig globalCfg = ThemeConfig::fromThemeDir(themeDirPath);
ThemeConfig globalCfg = themeManager->effectiveThemeConfig(themeName);
globalCfg.colorScheme = loadedScheme;
globalCfg.save(userThemeDirPath);

View file

@ -190,7 +190,7 @@ QStringMap &ThemeManager::getAvailableThemes()
ThemeConfig ThemeManager::effectiveThemeConfig(const QString &themeName)
{
const QString dirPath = ThemeManager().getAvailableThemes().value(themeName);
const QString dirPath = getAvailableThemes().value(themeName);
const QString userDirPath = userThemeDirFor(themeName);
ThemeConfig userCfg = ThemeConfig::fromThemeDir(userDirPath);
@ -310,14 +310,8 @@ void ThemeManager::reloadCurrentTheme()
void ThemeManager::previewPalette(const PaletteConfig &cfg, const QString &scheme)
{
const QString themeName = SettingsCache::instance().getThemeName();
const QString dirPath = getAvailableThemes().value(themeName);
const QString userDirPath = userThemeDirFor(themeName);
ThemeConfig themeCfg = ThemeConfig::fromThemeDir(userDirPath);
if (themeCfg.colorScheme.isEmpty() && themeCfg.styleName.isEmpty()) {
themeCfg = ThemeConfig::fromThemeDir(dirPath);
}
ThemeConfig themeCfg = effectiveThemeConfig(themeName);
applyStyleAndPalette(themeName, themeCfg, cfg, scheme);
}
@ -401,10 +395,7 @@ void ThemeManager::themeChangedSlot()
}
// ThemeConfig — user override first, then system
ThemeConfig themeCfg = ThemeConfig::fromThemeDir(userDirPath);
if (themeCfg.colorScheme.isEmpty() && themeCfg.styleName.isEmpty()) {
themeCfg = ThemeConfig::fromThemeDir(dirPath);
}
ThemeConfig themeCfg = effectiveThemeConfig(themeName);
const QString activeScheme = isDarkMode(dirPath, userDirPath) ? "Dark" : "Light";