[Psi-Devel] Minor misbehaviour of language selection dialog

Jan Niehusmann jan at gondor.com
Sun Apr 6 08:54:27 PDT 2008


In a bug report on the debian BTS, Stephan Windmüller noticed that the
language selection in the 'change profile' window doesn't always work as
expected:

If you never chose a language from within psi, it will select the
language based on environment variables, which is fine. 

But if you then want to switch back to English from within psi, select
'change profile', see that 'English' is already selected and press
'open', it does not work: As you didn't change the selected option in the
select box, ProfileOpenDlg::langChange wasn't called and no new language
got activated.

This only happens if your environment specifies a language like de_DE,
but your translation is only called 'de'. QTranslator::load() does strip
the part after _ automatically, but the comparison logic inside
ProfileOpenDlg::ProfileOpenDlg() doesn't.

A fix could look like this:

diff --git a/src/profiledlg.cpp b/src/profiledlg.cpp
index a8912ef..2913f8f 100644
--- a/src/profiledlg.cpp
+++ b/src/profiledlg.cpp
@@ -94,7 +94,7 @@ ProfileOpenDlg::ProfileOpenDlg(const QString &def, const VarList &_langs, const
 	langSel = x;
 	for(VarList::ConstIterator it = langs.begin(); it != langs.end(); ++it) {
 		cb_lang->insertItem((*it).data());
-		if((curLang.isEmpty() && x == 0) || (curLang == (*it).key())) {
+		if((curLang.isEmpty() && x == 0) || curLang.startsWith((*it).key()) && (langSel == 0 || ((*(langs.findByNum(langSel))).key().length() < (*it).key().length()))) {
 			cb_lang->setCurrentItem(x);
 			langSel = x;
 		}


The ugly if clause does select an item if it's key is a prefix of the
currently selected language (eg. it selects item 'de' if the current
language is 'de_DE'), but only of no more specific item has been
selected before (ie., it would prefer an item de_DE if it also existed).

Perhaps somebody of you has an idea how to achieve this behaviour without
such an ugly expression... :-)

Jan



More information about the Psi-Devel mailing list