]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiCommandEdit.cpp
* fix spelling in comments to please John.
[lyx.git] / src / frontends / qt4 / GuiCommandEdit.cpp
1 /**
2  * \file GuiCommandEdit.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiCommandEdit.h"
14
15 #include <QKeyEvent>
16 #include <QEvent>
17
18 #undef KeyPress
19
20 namespace lyx {
21 namespace frontend {
22
23 GuiCommandEdit::GuiCommandEdit(QWidget * parent)
24         : QLineEdit(parent)
25 {
26         setFocusPolicy(Qt::ClickFocus);
27 }
28
29
30 void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
31 {
32         switch (e->key()) {
33         case Qt::Key_Escape:
34                 // emit signal
35                 escapePressed();
36                 break;
37
38         case Qt::Key_Up:
39                 // emit signal
40                 upPressed();
41                 break;
42
43         case Qt::Key_Down:
44                 // emit signal
45                 downPressed();
46                 break;
47
48         case Qt::Key_X:
49                 if (e->modifiers() == Qt::AltModifier
50                    || e->modifiers() == Qt::MetaModifier) {
51                         // emit signal
52                         hidePressed();
53                         break;
54                 }
55
56         default:
57                 QLineEdit::keyPressEvent(e);
58                 break;
59         }
60 }
61
62
63 bool GuiCommandEdit::event(QEvent * e)
64 {
65         if (e->type() != QEvent::KeyPress)
66                 return QLineEdit::event(e);
67
68         QKeyEvent * ev = (QKeyEvent *)e;
69
70         if (ev->key() != Qt::Key_Tab)
71                 return QLineEdit::event(e);
72
73         // emit signal
74         tabPressed();
75         return true;
76 }
77
78 } // namespace frontend
79 } // namespace lyx
80
81 #include "moc_GuiCommandEdit.cpp"