aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Borges de Freitas <92enen@gmail.com>2023-03-01 10:35:27 +0000
committerGitHub <noreply@github.com>2023-03-01 10:35:27 +0000
commitfd81b368303c54c73d10563a5e4d6ad1f7134828 (patch)
tree0db46339770fb8fdc79a1f23cb4059546d2b47e1
parent564249f53467d6d80cb30d44d5fbdce2003a8f4d (diff)
parent5ebb6e5d5d3944738d3c2cf7f1c7e0ab6f46f82b (diff)
Merge pull request #22841 from smfontes/Fontset-in-Theme
[gui, skin] When theme changes, also change to matching fontset
-rw-r--r--xbmc/application/ApplicationSkinHandling.cpp19
-rw-r--r--xbmc/interfaces/builtins/SkinBuiltins.cpp12
2 files changed, 18 insertions, 13 deletions
diff --git a/xbmc/application/ApplicationSkinHandling.cpp b/xbmc/application/ApplicationSkinHandling.cpp
index edca76b962..bf73f14363 100644
--- a/xbmc/application/ApplicationSkinHandling.cpp
+++ b/xbmc/application/ApplicationSkinHandling.cpp
@@ -474,15 +474,24 @@ bool CApplicationSkinHandling::OnSettingChanged(const CSetting& setting)
std::shared_ptr<CSettingString> skinColorsSetting = std::static_pointer_cast<CSettingString>(
CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(
CSettings::SETTING_LOOKANDFEEL_SKINCOLORS));
+ std::shared_ptr<CSettingString> skinFontSetting = std::static_pointer_cast<CSettingString>(
+ CServiceBroker::GetSettingsComponent()->GetSettings()->GetSetting(
+ CSettings::SETTING_LOOKANDFEEL_FONT));
m_ignoreSkinSettingChanges = true;
- // we also need to adjust the skin color setting
- std::string colorTheme = static_cast<const CSettingString&>(setting).GetValue();
- URIUtils::RemoveExtension(colorTheme);
- if (setting.IsDefault() || StringUtils::EqualsNoCase(colorTheme, "Textures"))
+ // we also need to adjust the skin color theme and fontset
+ std::string theme = static_cast<const CSettingString&>(setting).GetValue();
+ if (setting.IsDefault() || StringUtils::EqualsNoCase(theme, "Textures.xbt"))
+ {
skinColorsSetting->Reset();
+ skinFontSetting->Reset();
+ }
else
- skinColorsSetting->SetValue(colorTheme);
+ {
+ URIUtils::RemoveExtension(theme);
+ skinColorsSetting->SetValue(theme);
+ skinFontSetting->SetValue(theme);
+ }
}
m_ignoreSkinSettingChanges = false;
diff --git a/xbmc/interfaces/builtins/SkinBuiltins.cpp b/xbmc/interfaces/builtins/SkinBuiltins.cpp
index 5b2b4c2fd9..5ffab72669 100644
--- a/xbmc/interfaces/builtins/SkinBuiltins.cpp
+++ b/xbmc/interfaces/builtins/SkinBuiltins.cpp
@@ -420,15 +420,11 @@ static int SetTheme(const std::vector<std::string>& params)
if (iTheme != -1 && iTheme < (int)vecTheme.size())
strSkinTheme = vecTheme[iTheme];
+ // Because of the way callbacks are implemented, calling settings->SetString(...)
+ // causes ApplicationSkinHandling::OnSettingChanged(...) to be called.
+ // The ApplicationSkinHandling::OnSettingChanged method will do all the work of
+ // changing to the new theme, including reloading the skin.
settings->SetString(CSettings::SETTING_LOOKANDFEEL_SKINTHEME, strSkinTheme);
- // also set the default color theme
- std::string colorTheme(URIUtils::ReplaceExtension(strSkinTheme, ".xml"));
- if (StringUtils::EqualsNoCase(colorTheme, "Textures.xml"))
- colorTheme = "defaults.xml";
- settings->SetString(CSettings::SETTING_LOOKANDFEEL_SKINCOLORS, colorTheme);
- auto& components = CServiceBroker::GetAppComponents();
- const auto appSkin = components.GetComponent<CApplicationSkinHandling>();
- appSkin->ReloadSkin();
return 0;
}