Menus.cpp: priorize capitals as language accelerators.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33566 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-02-25 12:56:12 +00:00
parent ea6b96dfc5
commit 9f67cede58

View File

@ -780,16 +780,32 @@ void MenuDefinition::expandLanguageSelector(Buffer const * buf)
cit != languages.end(); ++cit) {
QString label = qt_((*cit)->display());
// try to add an accelerator
bool success = false;
// try capitals first
for (int i = 0; i < label.size(); ++i) {
if (label[i].isSpace())
if (!label[i].isUpper())
continue;
QString const ch = QString(label[i]);
if (!accelerators.contains(ch, Qt::CaseInsensitive)) {
label = label + toqstr("|") + ch;
accelerators.append(ch);
success = true;
break;
}
}
// if all capitals are taken, try the rest
if (!success) {
for (int i = 0; i < label.size(); ++i) {
if (label[i].isSpace())
continue;
QString const ch = QString(label[i]);
if (!accelerators.contains(ch, Qt::CaseInsensitive)) {
label = label + toqstr("|") + ch;
accelerators.append(ch);
break;
}
}
}
MenuItem w(MenuItem::Command, label,
FuncRequest(LFUN_LANGUAGE, (*cit)->lang()));
item.submenu().addWithStatusCheck(w);