+// -*- C++ -*-
/**
* \file qlkey.h
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
*/
#ifndef QLKEY_H
#define QLKEY_H
-
-#include <config.h>
-#include <qnamespace.h>
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <qnamespace.h>
#include "LString.h"
-
-int q_is_modifier(int qkey)
+
+/**
+ * Return true if the key event is a modifier.
+ */
+bool q_is_modifier(int qkey)
{
switch (qkey) {
case Qt::Key_Hyper_L:
case Qt::Key_Meta:
case Qt::Key_Alt:
return true;
+
+ // AltGr becomes Key_unknown on at least one keyboard
+ case Qt::Key_unknown:
+ return true;
}
return false;
}
-
-// FIXME
+
+/**
+ * Return the numeric Qt Key corresponding to the
+ * given symbol name.
+ */
int string_to_qkey(string const & str)
{
+ // FIX! (Lgb)
+
if (str == "Escape") return Qt::Key_Escape;
if (str == "Tab") return Qt::Key_Tab;
if (str == "BackSpace") return Qt::Key_BackSpace;
if (str == "Return") return Qt::Key_Return;
- if (str == "KP_Enter") // correct ?? return Qt::Key_Enter;
+ 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;
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") // correct ? return Qt::Key_Meta;
- if (str == "Alt_L") return Qt::Key_Alt;
+ if (str == "Alt_L") return Qt::Key_Meta; // correct ?
+ if (str == "Alt_R") return Qt::Key_Alt;
if (str == "Caps_Lock") return Qt::Key_CapsLock;
if (str == "Num_Lock") return Qt::Key_NumLock;
if (str == "Scroll_Lock") return Qt::Key_ScrollLock;
if (str == "greater") return Qt::Key_Greater;
if (str == "question") return Qt::Key_Question;
if (str == "at") return Qt::Key_At;
+ if (str == "A") return Qt::Key_A;
+ if (str == "B") return Qt::Key_B;
+ if (str == "C") return Qt::Key_C;
+ if (str == "D") return Qt::Key_D;
+ if (str == "E") return Qt::Key_E;
+ if (str == "F") return Qt::Key_F;
+ if (str == "G") return Qt::Key_G;
+ if (str == "H") return Qt::Key_H;
+ if (str == "I") return Qt::Key_I;
+ if (str == "J") return Qt::Key_J;
+ if (str == "K") return Qt::Key_K;
+ if (str == "L") return Qt::Key_L;
+ if (str == "M") return Qt::Key_M;
+ if (str == "N") return Qt::Key_N;
+ if (str == "O") return Qt::Key_O;
+ if (str == "P") return Qt::Key_P;
+ if (str == "Q") return Qt::Key_Q;
+ if (str == "R") return Qt::Key_R;
+ if (str == "S") return Qt::Key_S;
+ if (str == "T") return Qt::Key_T;
+ if (str == "U") return Qt::Key_U;
+ if (str == "V") return Qt::Key_V;
+ if (str == "W") return Qt::Key_W;
+ if (str == "X") return Qt::Key_X;
+ if (str == "Y") return Qt::Key_Y;
+ if (str == "Z") return Qt::Key_Z;
if (str == "a") return Qt::Key_A;
if (str == "b") return Qt::Key_B;
if (str == "c") return Qt::Key_C;
if (str == "asciitilde") return Qt::Key_AsciiTilde;
if (str == "braceleft") return Qt::Key_BraceLeft;
if (str == "braceright") return Qt::Key_BraceRight;
- if (str == "grave") // ??? return Qt::Key_QuoteLeft;
+ if (str == "grave") return Qt::Key_QuoteLeft; // ???
if (str == "notsign") return Qt::Key_notsign;
if (str == "nobreakspace") return Qt::Key_nobreakspace;
if (str == "exclamdown") return Qt::Key_exclamdown;
if (str == "thorn") return Qt::Key_thorn;
if (str == "ydiaeresis") return Qt::Key_ydiaeresis;
- // FIXME: these ones I don't know the names of ... help !
- // what's here is basically guesses ...
+ // FIXME, correct for all these ?
if (str == "Super_L") return Qt::Key_Super_L;
if (str == "Super_R") return Qt::Key_Super_R;
if (str == "Menu") return Qt::Key_Menu;
if (str == "Help") return Qt::Key_Help;
if (str == "Bar") return Qt::Key_Bar;
if (str == "BackTab") return Qt::Key_Backtab;
-
+
return Qt::Key_unknown;
}
-
+
/**
- * q_to_lkey - convert Qt keypress into LyX
+ * qkey_to_string - convert Qt keypress into LyX
*
* Convert the Qt keypress into a string understandable
- * by the LyX core (same as XKeysymToString)
+ * by the LyX core (same as XKeysymToString).
*/
-string const qkey_to_string(int lkey)
+string const qkey_to_string(int lkey)
{
- switch(lkey) {
+ switch (lkey) {
case Qt::Key_Escape: return "Escape";
- case Qt::Key_Tab: return "Tab";
case Qt::Key_BackSpace: return "BackSpace";
- case Qt::Key_Return: return "Return";
- case Qt::Key_Enter: return "KP_Enter"; // correct ??
case Qt::Key_Insert: return "Insert";
case Qt::Key_Delete: return "Delete";
case Qt::Key_Pause: return "Pause";
case Qt::Key_Shift: return "Shift_L";
case Qt::Key_Control: return "Control_L";
case Qt::Key_Meta: return "Alt_L"; // correct ?
- case Qt::Key_Alt: return "Alt_L";
+ case Qt::Key_Alt: return "Alt_R";
case Qt::Key_CapsLock: return "Caps_Lock";
case Qt::Key_NumLock: return "Num_Lock";
case Qt::Key_ScrollLock: return "Scroll_Lock";
case Qt::Key_F33: return "F33";
case Qt::Key_F34: return "F34";
case Qt::Key_F35: return "F35";
- case Qt::Key_0: return "0";
- case Qt::Key_1: return "1";
- case Qt::Key_2: return "2";
- case Qt::Key_3: return "3";
- case Qt::Key_4: return "4";
- case Qt::Key_5: return "5";
- case Qt::Key_6: return "6";
- case Qt::Key_7: return "7";
- case Qt::Key_8: return "8";
- case Qt::Key_9: return "9";
case Qt::Key_Colon: return "colon";
case Qt::Key_Semicolon: return "semicolon";
case Qt::Key_Less: return "less";
case Qt::Key_Greater: return "greater";
case Qt::Key_Question: return "question";
case Qt::Key_At: return "at";
- case Qt::Key_A: return "a";
- case Qt::Key_B: return "b";
- case Qt::Key_C: return "c";
- case Qt::Key_D: return "d";
- case Qt::Key_E: return "e";
- case Qt::Key_F: return "f";
- case Qt::Key_G: return "g";
- case Qt::Key_H: return "h";
- case Qt::Key_I: return "i";
- case Qt::Key_J: return "j";
- case Qt::Key_K: return "k";
- case Qt::Key_L: return "l";
- case Qt::Key_M: return "m";
- case Qt::Key_N: return "n";
- case Qt::Key_O: return "o";
- case Qt::Key_P: return "p";
- case Qt::Key_Q: return "q";
- case Qt::Key_R: return "r";
- case Qt::Key_S: return "s";
- case Qt::Key_T: return "t";
- case Qt::Key_U: return "u";
- case Qt::Key_V: return "v";
- case Qt::Key_W: return "w";
- case Qt::Key_X: return "x";
- case Qt::Key_Y: return "y";
- case Qt::Key_Z: return "z";
case Qt::Key_BracketLeft: return "bracketleft";
case Qt::Key_Backslash: return "backslash";
case Qt::Key_BracketRight: return "bracketright";
case Qt::Key_Backtab: return "BackTab";
default:
- case Qt::Key_unknown: return "unknown";
+ case Qt::Key_unknown: return "";
}
-}
+}
#endif // QLKEY_H