[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/kcontrol/locale
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2007-12-19 21:47:17
Message-ID: 1198100837.010515.18882.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 750693 by aacid:

allow the languages that don't have systemsettings translations to set the language \
too.

we need to mantain our own language list instead of using KLocale's  because KLocale \
does not add a language if there is no translation for the current application so it \
would not be posible to set a language which has no systemsettings/kcontrol module \
translation

Patch idea suggested by Chusslove tested and approved by him too


 M  +20 -23    kcmlocale.cpp  
 M  +5 -0      kcmlocale.h  


--- trunk/KDE/kdebase/runtime/kcontrol/locale/kcmlocale.cpp #750692:750693
@@ -69,27 +69,28 @@
     m_downButton->setIcon(KIcon("arrow-down"));
 
     languageAdd->loadAllLanguages();
+    
+    KConfigGroup configGroup = KGlobal::config()->group("Locale");
+    m_languageList = configGroup.readEntry("Language").split(":");
 }
 
 void KLocaleConfig::slotAddLanguage(const QString & code)
 {
-  QStringList languageList = m_locale->languageList();
-
   int pos = m_languages->currentRow();
   if ( pos < 0 )
     pos = 0;
 
   // If it's already in list, just move it (delete the old, then insert a new)
-  int oldPos = languageList.indexOf( code );
+  int oldPos = m_languageList.indexOf( code );
   if ( oldPos != -1 )
-    languageList.removeAll( languageList.at(oldPos) );
+    m_languageList.removeAll( code );
 
   if ( oldPos != -1 && oldPos < pos )
     --pos;
 
-  languageList.insert( pos, code );
+  m_languageList.insert( pos, code );
 
-  m_locale->setLanguage( languageList );
+  m_locale->setLanguage( m_languageList );
 
   emit localeChanged();
   if ( pos == 0 )
@@ -98,14 +99,13 @@
 
 void KLocaleConfig::slotRemoveLanguage()
 {
-  QStringList languageList = m_locale->languageList();
   int pos = m_languages->currentRow();
 
   if (pos != -1)
   {
-    languageList.removeAt(pos);
+    m_languageList.removeAt(pos);
 
-    m_locale->setLanguage( languageList );
+    m_locale->setLanguage( m_languageList );
 
     emit localeChanged();
     if ( pos == 0 )
@@ -115,19 +115,18 @@
 
 void KLocaleConfig::slotLanguageUp()
 {
-  QStringList languageList = m_locale->languageList();
   int pos = m_languages->currentRow();
 
-  QStringList::Iterator it1 = languageList.begin() + pos - 1;
-  QStringList::Iterator it2 = languageList.begin() + pos;
+  QStringList::Iterator it1 = m_languageList.begin() + pos - 1;
+  QStringList::Iterator it2 = m_languageList.begin() + pos;
 
-  if ( it1 != languageList.end() && it2 != languageList.end()  )
+  if ( it1 != m_languageList.end() && it2 != m_languageList.end()  )
   {
     QString str = *it1;
     *it1 = *it2;
     *it2 = str;
 
-    m_locale->setLanguage( languageList );
+    m_locale->setLanguage( m_languageList );
 
     emit localeChanged();
     if ( pos == 1 ) // at the lang before the top
@@ -137,19 +136,18 @@
 
 void KLocaleConfig::slotLanguageDown()
 {
-  QStringList languageList = m_locale->languageList();
   int pos = m_languages->currentRow();
 
-  QStringList::Iterator it1 = languageList.begin() + pos;
-  QStringList::Iterator it2 = languageList.begin() + pos + 1;
+  QStringList::Iterator it1 = m_languageList.begin() + pos;
+  QStringList::Iterator it2 = m_languageList.begin() + pos + 1;
 
-  if ( it1 != languageList.end() && it2 != languageList.end()  )
+  if ( it1 != m_languageList.end() && it2 != m_languageList.end()  )
     {
       QString str = *it1;
       *it1 = *it2;
       *it2 = str;
 
-      m_locale->setLanguage( languageList );
+      m_locale->setLanguage( m_languageList );
 
       emit localeChanged();
       if ( pos == 0 ) // at the top
@@ -186,7 +184,7 @@
 
   configGroup.writeEntry("Country", m_locale->country(), \
KConfig::Persistent|KConfig::Global);  configGroup.writeEntry("Language",
-                         m_locale->languageList().join(":"), \
KConfig::Persistent|KConfig::Global); +                         \
m_languageList.join(":"), KConfig::Persistent|KConfig::Global);  
   config->sync();
 }
@@ -203,9 +201,8 @@
 {
   // update language widget
   m_languages->clear();
-  QStringList languageList = m_locale->languageList();
-  for ( QStringList::Iterator it = languageList.begin();
-        it != languageList.end();
+  for ( QStringList::Iterator it = m_languageList.begin();
+        it != m_languageList.end();
         ++it )
   {
     QString name;
--- trunk/KDE/kdebase/runtime/kcontrol/locale/kcmlocale.h #750692:750693
@@ -70,6 +70,11 @@
 private:
   QStringList languageList() const;
 
+  // NOTE: we need to mantain our own language list instead of using KLocale's
+  // because KLocale does not add a language if there is no translation
+  // for the current application so it would not be posible to set
+  // a language which has no systemsettings/kcontrol module translation
+  QStringList m_languageList;
   KControlLocale *m_locale;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic