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
1=== modified file 'src/gui/ConfigurationDialog.cpp'
2--- src/gui/ConfigurationDialog.cpp 2013-12-14 18:41:34 +0000
3+++ src/gui/ConfigurationDialog.cpp 2013-12-17 00:41:46 +0000
4@@ -134,21 +134,12 @@
5
6 // Main tab
7 // Fill the language list widget from the available list
8- QString appLang = StelApp::getInstance().getLocaleMgr().getAppLanguage();
9- QComboBox* cb = ui->programLanguageComboBox;
10+ QComboBox* cb = ui->programLanguageComboBox;
11 cb->clear();
12 cb->addItems(StelTranslator::globalTranslator->getAvailableLanguagesNamesNative(StelFileMgr::getLocaleDir()));
13 cb->model()->sort(0);
14- QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang);
15- int lt = cb->findText(l2, Qt::MatchExactly);
16- if (lt == -1 && appLang.contains('_'))
17- {
18- l2 = appLang.left(appLang.indexOf('_'));
19- l2=StelTranslator::iso639_1CodeToNativeName(l2);
20- lt = cb->findText(l2, Qt::MatchExactly);
21- }
22- if (lt!=-1)
23- cb->setCurrentIndex(lt);
24+ updateCurrentLanguage();
25+ connect(cb->lineEdit(), SIGNAL(editingFinished()), this, SLOT(updateCurrentLanguage()));
26 connect(cb, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(selectLanguage(const QString&)));
27
28 connect(ui->getStarsButton, SIGNAL(clicked()), this, SLOT(downloadStars()));
29@@ -285,6 +276,26 @@
30 updateTabBarListWidgetWidth();
31 }
32
33+void ConfigurationDialog::updateCurrentLanguage()
34+{
35+ QComboBox* cb = ui->programLanguageComboBox;
36+ QString appLang = StelApp::getInstance().getLocaleMgr().getAppLanguage();
37+ QString l2 = StelTranslator::iso639_1CodeToNativeName(appLang);
38+
39+ if (cb->currentText() == l2)
40+ return;
41+
42+ int lt = cb->findText(l2, Qt::MatchExactly);
43+ if (lt == -1 && appLang.contains('_'))
44+ {
45+ l2 = appLang.left(appLang.indexOf('_'));
46+ l2=StelTranslator::iso639_1CodeToNativeName(l2);
47+ lt = cb->findText(l2, Qt::MatchExactly);
48+ }
49+ if (lt!=-1)
50+ cb->setCurrentIndex(lt);
51+}
52+
53 void ConfigurationDialog::selectLanguage(const QString& langName)
54 {
55 QString code = StelTranslator::nativeNameToIso639_1Code(langName);
56
57=== modified file 'src/gui/ConfigurationDialog.hpp'
58--- src/gui/ConfigurationDialog.hpp 2013-10-14 09:33:41 +0000
59+++ src/gui/ConfigurationDialog.hpp 2013-12-17 00:41:46 +0000
60@@ -80,7 +80,8 @@
61 //! Called when any of the boxes has been clicked. Sets the
62 //! "selected info" mode to "Custom".
63 void setSelectedInfoFromCheckBoxes();
64-
65+
66+ void updateCurrentLanguage();
67 void selectLanguage(const QString& languageCode);
68 void setStartupTimeMode();
69 //! Show/bring to foreground the shortcut editor window.
70
71=== modified file 'src/gui/configurationDialog.ui'
72--- src/gui/configurationDialog.ui 2013-12-15 09:54:44 +0000
73+++ src/gui/configurationDialog.ui 2013-12-17 00:41:46 +0000
74@@ -206,7 +206,7 @@
75 </size>
76 </property>
77 <property name="editable">
78- <bool>false</bool>
79+ <bool>true</bool>
80 </property>
81 <property name="insertPolicy">
82 <enum>QComboBox::NoInsert</enum>