-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathkey_dropper.cpp
More file actions
40 lines (35 loc) · 840 Bytes
/
key_dropper.cpp
File metadata and controls
40 lines (35 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "key_dropper.h"
#include "itemscene.h"
#include <QKeyEvent>
#include <QApplication>
KeyDropper::KeyDropper(QWidget *parent) :
QDockWidget(parent)
{
setFocusPolicy(Qt::StrongFocus);
setFocusProxy(parent);
}
void KeyDropper::keyPressEvent(QKeyEvent *event)
{
switch(event->key())
{
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Up:
case Qt::Key_Down:
if(parent())
{
ItemScene *s = qobject_cast<ItemScene *>(parent());
qApp->setActiveWindow(s);
s->setFocus(Qt::MouseFocusReason);
s->keyPressEvent(event);
return;
}/* fallthrough */
default:
break;
}
QDockWidget::keyPressEvent(event);
}
void KeyDropper::keyReleaseEvent(QKeyEvent *event)
{
QDockWidget::keyReleaseEvent(event);
}