]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/GuiCommandEdit.cpp
Properly scale some icons for HiDPI (#12695)
[lyx.git] / src / frontends / qt / 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         if (e->modifiers() == Qt::NoModifier) {
33                 switch (e->key()) {
34                 case Qt::Key_Escape:
35                         // emit signal
36                         escapePressed();
37                         return;
38
39                 case Qt::Key_Up:
40                         // emit signal
41                         upPressed();
42                         return;
43
44                 case Qt::Key_Down:
45                         // emit signal
46                         downPressed();
47                         return;
48
49                 default:
50                         // do nothing
51                         break;
52                 }
53         }
54         QLineEdit::keyPressEvent(e);
55 }
56
57
58 bool GuiCommandEdit::event(QEvent * e)
59 {
60         if (e->type() != QEvent::KeyPress)
61                 return QLineEdit::event(e);
62
63         QKeyEvent * ev = (QKeyEvent *)e;
64
65         if (ev->key() != Qt::Key_Tab)
66                 return QLineEdit::event(e);
67
68         // emit signal
69         tabPressed();
70         return true;
71 }
72
73 } // namespace frontend
74 } // namespace lyx
75
76 #include "moc_GuiCommandEdit.cpp"