MCPcopy Create free account
hub / github.com/davy7125/polyphone / initComboLanguage

Method initComboLanguage

sources/context/interface/configsectioninterface.cpp:81–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void ConfigSectionInterface::initComboLanguage()
82{
83 // Load the different languages
84 ui->comboLangue->blockSignals(true);
85 QMap<QString, QString> languages = ContextManager::translation()->getLanguages();
86 QStringList languageNames = languages.values();
87 std::sort(languageNames.begin(), languageNames.end(), caseInsensitiveLessThan);
88
89 foreach (QString languageName, languageNames)
90 ui->comboLangue->addItem(languageName, languages.key(languageName));
91
92 // Selection of the current language
93 QString locale = QLocale::system().name().section('_', 0, 0);
94 locale = ContextManager::configuration()->getValue(ConfManager::SECTION_NONE, "language", locale).toString();
95 bool found = false;
96 for (int i = 0; i < ui->comboLangue->count(); i++)
97 {
98 if (ui->comboLangue->itemData(i).toString() == locale)
99 {
100 found = true;
101 ui->comboLangue->setCurrentIndex(i);
102 break;
103 }
104 }
105
106 // If not found, english is the default
107 if (!found)
108 {
109 for (int i = 0; i < ui->comboLangue->count(); i++)
110 {
111 if (ui->comboLangue->itemData(i).toString() == "en")
112 {
113 ui->comboLangue->setCurrentIndex(i);
114 break;
115 }
116 }
117 }
118
119 ui->comboLangue->blockSignals(false);
120}
121
122void ConfigSectionInterface::initialize()
123{

Callers 1

Calls 6

getLanguagesMethod · 0.80
valuesMethod · 0.80
addItemMethod · 0.80
toStringMethod · 0.45
getValueMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected