From 5ae88452a9c4e08d0fd163a63e9ad48a390f5723 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 18 Jan 2024 09:57:11 +0800 Subject: [PATCH] fix: Error when using custom theme --- NEWS.md | 1 + RedPandaIDE/thememanager.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6b1f62e9..7d88a11b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/RedPandaIDE/thememanager.cpp b/RedPandaIDE/thememanager.cpp index 6db7b1b1..34d4b7c4 100644 --- a/RedPandaIDE/thememanager.cpp +++ b/RedPandaIDE/thememanager.cpp @@ -44,17 +44,17 @@ PAppTheme ThemeManager::theme(const QString &themeName) if (mUseCustomTheme) prepareCustomeTheme(); PAppTheme appTheme = std::make_shared(); + 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; }