]> git.lyx.org Git - features.git/commitdiff
jmarc's shortcut patch
authorJohn Levon <levon@movementarian.org>
Wed, 20 Nov 2002 16:46:17 +0000 (16:46 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 20 Nov 2002 16:46:17 +0000 (16:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5681 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/QLPopupMenu.C
src/frontends/qt2/qlkey.h

index 7357bd87d37050f24a963bf56a7174cb15198969..ab1ef0c62aa7a9a4f247193cdf298bc697382d71 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-20  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * QLPopupMenu.C (getLabel): show labels for menu entries
+
+       * qlkey.h (string_to_qkey): add support for KP_xxx keysyms
+
 2002-11-20  John Levon  <levon@movementarian.org>
 
        * ui/QDelimiterDialog.ui: geometry fix
index be720517a5621db003ccd3eda3709436b43def8d..9a623b0131cad32b56e1a75f7f5c9c810fef8899 100644 (file)
 #pragma implementation
 #endif
 
+#include "support/lstrings.h"
 #include "MenuBackend.h"
 #include "lyxfunc.h"
+#include "kbmap.h"
 #include "debug.h"
-
 #include "QtView.h"
 
 #include "QLPopupMenu.h"
 
-#include "support/lstrings.h"
-
+#include <boost/scoped_ptr.hpp>
 using std::pair;
 using std::make_pair;
-
+extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 namespace {
 
 string const getLabel(MenuItem const & mi)
@@ -41,6 +45,21 @@ string const getLabel(MenuItem const & mi)
        if (pos == string::npos)
                return label;
        label.insert(pos, "&");
+       if (mi.kind() == MenuItem::Command) {
+               // FIXME: backend should do this
+               string const accel(toplevel_keymap->findbinding(mi.action()));
+               
+               if (!accel.empty()) {
+                       label += "\t" + accel.substr(1, accel.find(']') - 1);
+               }
+               
+               lyxerr[Debug::GUI] << "Label: " << mi.label()
+                                  << " Shortcut: " << mi.shortcut()
+                                  << " Accel: " << accel << endl;
+       } else
+               lyxerr[Debug::GUI] << "Label: " << mi.label()
+                                  << " Shortcut: " << mi.shortcut() << endl;
 
        return label;
 }
index 6b0a0708294124fe991bd00cd9c840ec3a055465..43e34bce3c955739c4d125000a5c55a3310696e2 100644 (file)
@@ -57,7 +57,9 @@ int string_to_qkey(string const & str)
        if (str == "Return") return Qt::Key_Return;
        if (str == "KP_Enter") return Qt::Key_Enter; // correct ?
        if (str == "Insert") return Qt::Key_Insert;
+       if (str == "KP_Insert") return Qt::Key_Insert;
        if (str == "Delete") return Qt::Key_Delete;
+       if (str == "KP_Delete") return Qt::Key_Delete;
        if (str == "Pause") return Qt::Key_Pause;
        if (str == "Print") return Qt::Key_Print;
        if (str == "Sys_Req") return Qt::Key_SysReq;
@@ -69,6 +71,14 @@ int string_to_qkey(string const & str)
        if (str == "Down") return Qt::Key_Down;
        if (str == "Prior") return Qt::Key_Prior;
        if (str == "Next") return Qt::Key_Next;
+       if (str == "KP_Home") return Qt::Key_Home;
+       if (str == "KP_End") return Qt::Key_End;
+       if (str == "KP_Left") return Qt::Key_Left;
+       if (str == "KP_Up") return Qt::Key_Up;
+       if (str == "KP_Right") return Qt::Key_Right;
+       if (str == "KP_Down") return Qt::Key_Down;
+       if (str == "KP_Prior") return Qt::Key_Prior;
+       if (str == "KP_Next") return Qt::Key_Next;
        if (str == "Shift_L") return Qt::Key_Shift;
        if (str == "Control_L") return Qt::Key_Control;
        if (str == "Alt_L") return Qt::Key_Meta; // correct ?