]> git.lyx.org Git - features.git/commitdiff
Menus.cpp: priorize capitals as language accelerators.
authorJürgen Spitzmüller <spitz@lyx.org>
Thu, 25 Feb 2010 12:56:12 +0000 (12:56 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Thu, 25 Feb 2010 12:56:12 +0000 (12:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33566 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/Menus.cpp

index b2a887d06e0bee33d1861aea84e8da1925c33a37..11f59fbe6d8acb28c5fdc7d0b405b971f6a425b9 100644 (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);