diff options
author | Paul Lemire <paul.lemire.ecortex@kdab.com> | 2014-11-12 09:26:06 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2014-11-14 20:29:12 +0100 |
commit | b50e545211a35f676387c185376cc7a54cb9587e (patch) | |
tree | ac7f45e3afe3e51efc7374e8f2c563178d9e5da7 /src/input | |
parent | 132fa4f431b834eeb1e124b1e96ef5c13bb9618b (diff) |
InputHandler: install KeyboardEventFilter on QWindow
Change-Id: I83a72ad3f05ec7932ba97ba10cf996cf357499cf
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/inputhandler.cpp | 9 | ||||
-rw-r--r-- | src/input/inputhandler_p.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/input/inputhandler.cpp b/src/input/inputhandler.cpp index 47a8705fa..28299e357 100644 --- a/src/input/inputhandler.cpp +++ b/src/input/inputhandler.cpp @@ -41,6 +41,8 @@ #include "inputhandler_p.h" #include "inputmanagers_p.h" +#include "keyboardeventfilter_p.h" +#include <QWindow> QT_BEGIN_NAMESPACE @@ -52,13 +54,20 @@ InputHandler::InputHandler() : m_keyboardControllerManager(new KeyboardControllerManager()) , m_keyboardInputManager(new KeyboardInputManager()) , m_window(Q_NULLPTR) + , m_keyboardEventFilter(new KeyboardEventFilter()) { + m_keyboardEventFilter->setInputHandler(this); } +// Called in MainThread void InputHandler::setWindow(QWindow *window) { if (window != m_window) { + if (m_window) + m_window->removeEventFilter(m_keyboardEventFilter); m_window = window; + if (m_window) + m_window->installEventFilter(m_keyboardEventFilter); } } diff --git a/src/input/inputhandler_p.h b/src/input/inputhandler_p.h index 186c140bc..4f7cb02e1 100644 --- a/src/input/inputhandler_p.h +++ b/src/input/inputhandler_p.h @@ -54,6 +54,7 @@ namespace Input { class KeyboardInputManager; class KeyboardControllerManager; +class KeyboardEventFilter; class InputHandler { @@ -70,6 +71,7 @@ private: KeyboardControllerManager *m_keyboardControllerManager; KeyboardInputManager *m_keyboardInputManager; QWindow *m_window; + KeyboardEventFilter *m_keyboardEventFilter; }; } // Input |