From 9de498939803332028bd79108db4a1e5d7cba1d7 Mon Sep 17 00:00:00 2001 From: liule Date: Thu, 21 Nov 2024 11:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liule --- .../resmgr/include/theme_pack_resource.h | 2 ++ frameworks/resmgr/src/theme_pack_resource.cpp | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/frameworks/resmgr/include/theme_pack_resource.h b/frameworks/resmgr/include/theme_pack_resource.h index 38b2947..9514b0d 100644 --- a/frameworks/resmgr/include/theme_pack_resource.h +++ b/frameworks/resmgr/include/theme_pack_resource.h @@ -172,6 +172,8 @@ private: std::shared_ptr themeConfig, const std::string &resTypeStr); const std::string GetThemeAppIconByAbilityName(const std::pair &bundleInfo, const std::string &name, const std::string &abilityName = ""); + static void AddIconValue(const std::string &bundleName, const std::string &moduleName, + const std::string &iconName, const std::string &path, const std::string &abilityName = ""); static ThemeResource *themeRes; }; } // namespace Resource diff --git a/frameworks/resmgr/src/theme_pack_resource.cpp b/frameworks/resmgr/src/theme_pack_resource.cpp index bc468e2..cfd7b8d 100644 --- a/frameworks/resmgr/src/theme_pack_resource.cpp +++ b/frameworks/resmgr/src/theme_pack_resource.cpp @@ -343,6 +343,13 @@ std::string GetIconsBundleName(const std::string& iconPath) return iconPath.substr(pos + 1); } +void ThemeResource::AddIconValue(const std::string &bundleName, const std::string &moduleName, + const std::string &iconName, const std::string &path, const std::string &abilityName) +{ + ThemeKey themeKey = ThemeKey(bundleName, moduleName, ResType::MEDIA, iconName, abilityName); + themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); +} + const std::shared_ptr ThemeResource::LoadThemeIconResource(const std::string& iconPath) { if (iconPath.empty()) { @@ -365,28 +372,24 @@ const std::shared_ptr ThemeResource::LoadThemeIconResource(const continue; } std::string dynamicBundle = path.substr(iconPath.length() + 1, pos3 - iconPath.length() - 1); - ThemeKey themeKey = ThemeKey(bundleName, dynamicBundle, ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, dynamicBundle, iconName, path); continue; } auto pos3 = path.find('/', iconPath.length() + 1); if (pos3 == std::string::npos || pos3 < iconPath.length() + 1) { - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path); continue; } auto pos4 = path.find('/', pos3 + 1); if (pos4 == std::string::npos || pos4 < pos3 + 1 || pos4 != pos2) { - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path); continue; } std::string abilityName = path.substr(pos3 + 1, pos4 - pos3 - 1); - ThemeKey themeKey = ThemeKey(bundleName, "", ResType::MEDIA, iconName, abilityName); - themeRes->iconValues_.emplace_back(std::make_pair(themeKey, path)); + AddIconValue(bundleName, "", iconName, path, abilityName); } return themeResource; } -- Gitee