fix: Error when using custom theme

This commit is contained in:
Roy Qu 2024-01-18 09:57:11 +08:00
parent edf1424ce3
commit 5ae88452a9
2 changed files with 9 additions and 8 deletions

View File

@ -35,6 +35,7 @@ Red Panda C++ Version 2.26
- Enhancement: Better support for macros.
- Enhancement: Better type induction for auto in foreach loop of maps.
- Enhancement: Better contrast for scroller slider in dark theme.
- Enhancement: Using lua script in themes.
Red Panda C++ Version 2.25

View File

@ -44,17 +44,17 @@ PAppTheme ThemeManager::theme(const QString &themeName)
if (mUseCustomTheme)
prepareCustomeTheme();
PAppTheme appTheme = std::make_shared<AppTheme>();
QString themeDir;
if (mUseCustomTheme) {
QString themeDir = pSettings->dirs().config(Settings::Dirs::DataType::Theme);
appTheme->load(QString("%1/%2.json").arg(themeDir, themeName), AppTheme::ThemeType::JSON);
themeDir = pSettings->dirs().config(Settings::Dirs::DataType::Theme);
} else {
QString themeDir = pSettings->dirs().data(Settings::Dirs::DataType::Theme);
#ifdef ENABLE_LUA_ADDON
appTheme->load(QString("%1/%2.lua").arg(themeDir, themeName), AppTheme::ThemeType::Lua);
#else
appTheme->load(QString("%1/%2.json").arg(themeDir, themeName), AppTheme::ThemeType::JSON);
#endif
themeDir = pSettings->dirs().data(Settings::Dirs::DataType::Theme);
}
#ifdef ENABLE_LUA_ADDON
appTheme->load(QString("%1/%2.lua").arg(themeDir, themeName), AppTheme::ThemeType::Lua);
#else
appTheme->load(QString("%1/%2.json").arg(themeDir, themeName), AppTheme::ThemeType::JSON);
#endif
return appTheme;
}