settings: move SetLanguage from CGUISettings to CApplication
authormontellese <montellese@xbmc.org>
Sat, 16 Mar 2013 16:28:32 +0000 (17:28 +0100)
committermontellese <montellese@xbmc.org>
Thu, 4 Apr 2013 21:26:14 +0000 (23:26 +0200)
xbmc/Application.cpp
xbmc/Application.h
xbmc/ApplicationMessenger.cpp
xbmc/settings/GUISettings.cpp
xbmc/settings/GUISettings.h
xbmc/settings/windows/GUIWindowSettingsCategory.cpp

index 1f6ed5d..b0b8f31 100644 (file)
 #include "utils/SaveFileStateJob.h"
 #include "utils/AlarmClock.h"
 #include "utils/StringUtils.h"
+#include "utils/Weather.h"
 #include "DatabaseManager.h"
 
 #ifdef _LINUX
@@ -5892,3 +5893,38 @@ CPerformanceStats &CApplication::GetPerformanceStats()
 }
 #endif
 
+bool CApplication::SetLanguage(const CStdString &strLanguage)
+{
+  CStdString strPreviousLanguage = g_guiSettings.GetString("locale.language");
+  CStdString strNewLanguage = strLanguage;
+  if (strNewLanguage != strPreviousLanguage)
+  {
+    CStdString strLangInfoPath;
+    strLangInfoPath.Format("special://xbmc/language/%s/langinfo.xml", strNewLanguage.c_str());
+    if (!g_langInfo.Load(strLangInfoPath))
+      return false;
+
+    if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode())
+    {
+      CLog::Log(LOGINFO, "Language needs a ttf font, loading first ttf font available");
+      CStdString strFontSet;
+      if (g_fontManager.GetFirstFontSetUnicode(strFontSet))
+        strNewLanguage = strFontSet;
+      else
+        CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str());
+    }
+    g_guiSettings.SetString("locale.language", strNewLanguage);
+
+    g_charsetConverter.reset();
+
+    if (!g_localizeStrings.Load("special://xbmc/language/", strNewLanguage))
+      return false;
+
+    // also tell our weather and skin to reload as these are localized
+    g_weatherManager.Refresh();
+    g_PVRManager.LocalizationChanged();
+    ReloadSkin();
+  }
+
+  return true;
+}
index ef31d06..0b4dc4d 100644 (file)
@@ -368,6 +368,8 @@ public:
 
   CSplash* GetSplash() { return m_splash; }
   void SetRenderGUI(bool renderGUI);
+
+  bool SetLanguage(const CStdString &strLanguage);
 protected:
   virtual bool OnSettingsSaving() const;
 
index e55d69c..dc44a38 100644 (file)
@@ -468,7 +468,7 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
       break;
 
     case TMSG_SETLANGUAGE:
-      g_guiSettings.SetLanguage(pMsg->strParam);
+      g_application.SetLanguage(pMsg->strParam);
       break;
     case TMSG_MEDIA_STOP:
       {
index 8e2f8fb..040caed 100644 (file)
@@ -48,7 +48,6 @@
   #include "cores/AudioEngine/Engines/CoreAudio/CoreAudioHardware.h"
 #endif
 #include "guilib/GUIFontManager.h"
-#include "utils/Weather.h"
 #include "LangInfo.h"
 #include "pvr/PVRManager.h"
 #include "utils/XMLUtils.h"
@@ -1573,39 +1572,3 @@ void CGUISettings::Clear()
 
   SetChanged();
 }
-
-bool CGUISettings::SetLanguage(const CStdString &strLanguage)
-{
-  CStdString strPreviousLanguage = GetString("locale.language");
-  CStdString strNewLanguage = strLanguage;
-  if (strNewLanguage != strPreviousLanguage)
-  {
-    CStdString strLangInfoPath;
-    strLangInfoPath.Format("special://xbmc/language/%s/langinfo.xml", strNewLanguage.c_str());
-    if (!g_langInfo.Load(strLangInfoPath))
-      return false;
-
-    if (g_langInfo.ForceUnicodeFont() && !g_fontManager.IsFontSetUnicode())
-    {
-      CLog::Log(LOGINFO, "Language needs a ttf font, loading first ttf font available");
-      CStdString strFontSet;
-      if (g_fontManager.GetFirstFontSetUnicode(strFontSet))
-        strNewLanguage = strFontSet;
-      else
-        CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str());
-    }
-    SetString("locale.language", strNewLanguage);
-
-    g_charsetConverter.reset();
-
-    if (!g_localizeStrings.Load("special://xbmc/language/", strNewLanguage))
-      return false;
-
-    // also tell our weather and skin to reload as these are localized
-    g_weatherManager.Refresh();
-    g_PVRManager.LocalizationChanged();
-    g_application.ReloadSkin();
-  }
-
-  return true;
-}
index 38aaf58..f195663 100644 (file)
@@ -496,8 +496,6 @@ public:
   void SaveXML(TiXmlNode *pRootNode);
   void LoadMasterLock(TiXmlElement *pRootElement);
 
-  bool SetLanguage(const CStdString &strLanguage);
-
   ReplayGainSettings m_replayGain;
 
   void Clear();
index 5d3b89a..01baf6f 100644 (file)
@@ -1485,7 +1485,7 @@ void CGUIWindowSettingsCategory::OnSettingChanged(BaseSettingControlPtr pSetting
     CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
     CStdString strLanguage = pControl->GetCurrentLabel();
     if (strLanguage != ".svn" && strLanguage != pSettingString->GetData())
-      g_guiSettings.SetLanguage(strLanguage);
+      g_application.SetLanguage(strLanguage);
 
     // user set language, no longer use the TV's language
     vector<CPeripheral *> cecDevices;