diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-12-05 15:41:52 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:34:23 +0100 |
commit | 726f0bca0d50a86ff30a367cbdd2f31190fcd30c (patch) | |
tree | fd04bf5d92f2f25d317a12af5f29a47d986f6062 /plugin/inputadapter.cpp | |
parent | ff7c7152388889da7d603b207e575e366873186d (diff) |
Add callbacks for magnitude, moves and actions
When cursor is moved, the current item is informed of the actions
via callbacks. Eg. when cursor is moved up, the item that had the
cursor will have its movedUp signal fired. It is now also possible
to inform navigable items over incomplete movement, or the magnitude
of the movement. This may be used eg. to make buttons or elements to
flip/rotate to indicate that the cursor is about to be moved.
Diffstat (limited to 'plugin/inputadapter.cpp')
-rw-r--r-- | plugin/inputadapter.cpp | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/plugin/inputadapter.cpp b/plugin/inputadapter.cpp index feb1373..52eba34 100644 --- a/plugin/inputadapter.cpp +++ b/plugin/inputadapter.cpp @@ -21,47 +21,39 @@ bool InputAdapter::eventFilter(QObject *object, QEvent *event) if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); return handleKeyEvent(keyEvent); - } else if (event->type() == QEvent::Wheel) { - QWheelEvent *wheelEvent = static_cast<QWheelEvent *>(event); - return handleWheelEvent(wheelEvent); - } else if (event->type() == QEvent::MouseMove) { - QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); - return handleMouseEvent(mouseEvent); } return false; } bool InputAdapter::handleKeyEvent(QKeyEvent *event) { - CursorNavigationCommand cmd; - //detect arrow keys, tabs, enter and esc switch (event->key()) { case Qt::Key_Left: - m_cursorNavigation->move(180, 0, true); + m_cursorNavigation->m_rootItem->moveLeft(); break; case Qt::Key_Right: - m_cursorNavigation->move(0, 0, true); + m_cursorNavigation->m_rootItem->moveRight(); break; case Qt::Key_Up: - m_cursorNavigation->move(-90, 0, true); + m_cursorNavigation->m_rootItem->moveUp(); break; case Qt::Key_Down: - m_cursorNavigation->move(90, 0, true); + m_cursorNavigation->m_rootItem->moveDown(); break; case Qt::Key_Return: case Qt::Key_Enter: - m_cursorNavigation->action(Activate); + m_cursorNavigation->m_rootItem->activate(); break; case Qt::BackButton: case Qt::Key_Escape: - m_cursorNavigation->action(Escape); + m_cursorNavigation->m_rootItem->escape(); break; case Qt::Key_Tab: - m_cursorNavigation->action(Forward); + m_cursorNavigation->m_rootItem->moveForward(); break; case Qt::Key_Backtab: - m_cursorNavigation->action(Back); + m_cursorNavigation->m_rootItem->moveBack(); break; default: return false; @@ -69,15 +61,3 @@ bool InputAdapter::handleKeyEvent(QKeyEvent *event) return true; } - -bool InputAdapter::handleMouseEvent(QMouseEvent *event) -{ - //interpret mouse movement as omnnidirectional joystick movements for testing purposes - return false; -} - -bool InputAdapter::handleWheelEvent(QWheelEvent *event) -{ - //turn wheel events into tabs - return false; -} |