jmarc's shortcut patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5681 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-11-20 16:46:17 +00:00
parent d4ee5b69d0
commit 4e18f2cccd
3 changed files with 39 additions and 4 deletions

View 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> 2002-11-20 John Levon <levon@movementarian.org>
* ui/QDelimiterDialog.ui: geometry fix * ui/QDelimiterDialog.ui: geometry fix

View File

@ -14,19 +14,23 @@
#pragma implementation #pragma implementation
#endif #endif
#include "support/lstrings.h"
#include "MenuBackend.h" #include "MenuBackend.h"
#include "lyxfunc.h" #include "lyxfunc.h"
#include "kbmap.h"
#include "debug.h" #include "debug.h"
#include "QtView.h" #include "QtView.h"
#include "QLPopupMenu.h" #include "QLPopupMenu.h"
#include "support/lstrings.h" #include <boost/scoped_ptr.hpp>
using std::pair; using std::pair;
using std::make_pair; using std::make_pair;
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
namespace { namespace {
string const getLabel(MenuItem const & mi) string const getLabel(MenuItem const & mi)
@ -41,6 +45,21 @@ string const getLabel(MenuItem const & mi)
if (pos == string::npos) if (pos == string::npos)
return label; return label;
label.insert(pos, "&"); 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; return label;
} }

View File

@ -57,7 +57,9 @@ int string_to_qkey(string const & str)
if (str == "Return") return Qt::Key_Return; if (str == "Return") return Qt::Key_Return;
if (str == "KP_Enter") return Qt::Key_Enter; // correct ? if (str == "KP_Enter") return Qt::Key_Enter; // correct ?
if (str == "Insert") return Qt::Key_Insert; if (str == "Insert") return Qt::Key_Insert;
if (str == "KP_Insert") return Qt::Key_Insert;
if (str == "Delete") return Qt::Key_Delete; if (str == "Delete") return Qt::Key_Delete;
if (str == "KP_Delete") return Qt::Key_Delete;
if (str == "Pause") return Qt::Key_Pause; if (str == "Pause") return Qt::Key_Pause;
if (str == "Print") return Qt::Key_Print; if (str == "Print") return Qt::Key_Print;
if (str == "Sys_Req") return Qt::Key_SysReq; 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 == "Down") return Qt::Key_Down;
if (str == "Prior") return Qt::Key_Prior; if (str == "Prior") return Qt::Key_Prior;
if (str == "Next") return Qt::Key_Next; 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 == "Shift_L") return Qt::Key_Shift;
if (str == "Control_L") return Qt::Key_Control; if (str == "Control_L") return Qt::Key_Control;
if (str == "Alt_L") return Qt::Key_Meta; // correct ? if (str == "Alt_L") return Qt::Key_Meta; // correct ?