Merge lp:~cardinot/stellarium/languageList into lp:stellarium

Proposed by Marcos Cardinot
Status: Merged
Merged at revision: 6401
Proposed branch: lp:~cardinot/stellarium/languageList
Merge into: lp:stellarium
Diff against target: 82 lines (+26/-14)
3 files modified
src/gui/ConfigurationDialog.cpp (+23/-12)
src/gui/ConfigurationDialog.hpp (+2/-1)
src/gui/configurationDialog.ui (+1/-1)
To merge this branch: bzr merge lp:~cardinot/stellarium/languageList
Reviewer Review Type Date Requested Status
Alexander Wolf Approve
Review via email: mp+199208@code.launchpad.net

Description of the change

This fix is actually an improvement for the list of languages​​.
The list of languages ​​is very large and the task of searching for the language can be exhausting. So with this commit, the user can type the name of the language and the field is filled simultaneously. If you type a nonexistent language, the field just redisplays the current language.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/gui/ConfigurationDialog.cpp'
--- src/gui/ConfigurationDialog.cpp 2013-12-14 18:41:34 +0000
+++ src/gui/ConfigurationDialog.cpp 2013-12-17 00:41:46 +0000
@@ -134,21 +134,12 @@
134134
135 // Main tab135 // Main tab
136 // Fill the language list widget from the available list136 // Fill the language list widget from the available list
137 QString appLang = StelApp::getInstance().getLocaleMgr().getAppLanguage();137 QComboBox* cb = ui->programLanguageComboBox;
138 QComboBox* cb = ui->programLanguageComboBox;
139 cb->clear();138 cb->clear();
140 cb->addItems(StelTranslator::globalTranslator->getAvailableLanguagesNamesNative(StelFileMgr::getLocaleDir()));139 cb->addItems(StelTranslator::globalTranslator->getAvailableLanguagesNamesNative(StelFileMgr::getLocaleDir()));
141 cb->model()->sort(0);140 cb->model()->sort(0);
142 QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang);141 updateCurrentLanguage();
143 int lt = cb->findText(l2, Qt::MatchExactly);142 connect(cb->lineEdit(), SIGNAL(editingFinished()), this, SLOT(updateCurrentLanguage()));
144 if (lt == -1 && appLang.contains('_'))
145 {
146 l2 = appLang.left(appLang.indexOf('_'));
147 l2=StelTranslator::iso639_1CodeToNativeName(l2);
148 lt = cb->findText(l2, Qt::MatchExactly);
149 }
150 if (lt!=-1)
151 cb->setCurrentIndex(lt);
152 connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectLanguage(const QString&)));143 connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectLanguage(const QString&)));
153144
154 connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars()));145 connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars()));
@@ -285,6 +276,26 @@
285 updateTabBarListWidgetWidth();276 updateTabBarListWidgetWidth();
286}277}
287278
279void ConfigurationDialog::updateCurrentLanguage()
280{
281 QComboBox* cb = ui->programLanguageComboBox;
282 QString appLang = StelApp::getInstance().getLocaleMgr().getAppLanguage();
283 QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang);
284
285 if (cb->currentText() == l2)
286 return;
287
288 int lt = cb->findText(l2, Qt::MatchExactly);
289 if (lt == -1 && appLang.contains('_'))
290 {
291 l2 = appLang.left(appLang.indexOf('_'));
292 l2=StelTranslator::iso639_1CodeToNativeName(l2);
293 lt = cb->findText(l2, Qt::MatchExactly);
294 }
295 if (lt!=-1)
296 cb->setCurrentIndex(lt);
297}
298
288void ConfigurationDialog::selectLanguage(const QString& langName)299void ConfigurationDialog::selectLanguage(const QString& langName)
289{300{
290 QString code = StelTranslator::nativeNameToIso639_1Code(langName);301 QString code = StelTranslator::nativeNameToIso639_1Code(langName);
291302
=== modified file 'src/gui/ConfigurationDialog.hpp'
--- src/gui/ConfigurationDialog.hpp 2013-10-14 09:33:41 +0000
+++ src/gui/ConfigurationDialog.hpp 2013-12-17 00:41:46 +0000
@@ -80,7 +80,8 @@
80 //! Called when any of the boxes has been clicked. Sets the80 //! Called when any of the boxes has been clicked. Sets the
81 //! "selected info" mode to "Custom".81 //! "selected info" mode to "Custom".
82 void setSelectedInfoFromCheckBoxes();82 void setSelectedInfoFromCheckBoxes();
83 83
84 void updateCurrentLanguage();
84 void selectLanguage(const QString& languageCode);85 void selectLanguage(const QString& languageCode);
85 void setStartupTimeMode();86 void setStartupTimeMode();
86 //! Show/bring to foreground the shortcut editor window.87 //! Show/bring to foreground the shortcut editor window.
8788
=== modified file 'src/gui/configurationDialog.ui'
--- src/gui/configurationDialog.ui 2013-12-15 09:54:44 +0000
+++ src/gui/configurationDialog.ui 2013-12-17 00:41:46 +0000
@@ -206,7 +206,7 @@
206 </size>206 </size>
207 </property>207 </property>
208 <property name="editable">208 <property name="editable">
209 <bool>false</bool>209 <bool>true</bool>
210 </property>210 </property>
211 <property name="insertPolicy">211 <property name="insertPolicy">
212 <enum>QComboBox::NoInsert</enum>212 <enum>QComboBox::NoInsert</enum>