diff options
| author | Stefan Wildemann <metalstrolch@users.noreply.github.com> | 2017-04-10 19:20:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-10 19:20:08 +0200 |
| commit | 6c7688b74364681bcaf034be15ae039cbf72c50b (patch) | |
| tree | dc033705f0753dbf541105b55235860b42ad5af5 /navit/graphics/qt5/QNavitQuick.cpp | |
| parent | f466ed624c282e30869fa1cc04f191812e0b4888 (diff) | |
| download | navit-6c7688b74364681bcaf034be15ae039cbf72c50b.tar.gz | |
graphics Qt5 keyboard (#214)R7384
* Fix: Enable keyboard on graphics_qt5:QML
* Fix: Enable keyboard on graphics_qt5:QWidget
* Fix: register the QML RRC.
To not let the resources be optimized out if you compile navit without
modules, they need to be registered on module init.
Diffstat (limited to 'navit/graphics/qt5/QNavitQuick.cpp')
| -rw-r--r-- | navit/graphics/qt5/QNavitQuick.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/navit/graphics/qt5/QNavitQuick.cpp b/navit/graphics/qt5/QNavitQuick.cpp index 127ea2113..d2664be27 100644 --- a/navit/graphics/qt5/QNavitQuick.cpp +++ b/navit/graphics/qt5/QNavitQuick.cpp @@ -31,6 +31,7 @@ #include "debug.h" #include "window.h" #include "callback.h" +#include "keys.h" #if defined(WINDOWS) || defined(WIN32) || defined (HAVE_API_WIN32_CE) #include <windows.h> #endif @@ -95,7 +96,68 @@ void QNavitQuick::paint(QPainter *painter) void QNavitQuick::keyPressEvent(QKeyEvent *event) { - dbg(lvl_debug,"enter\n"); + dbg(lvl_debug,"enter\n"); + char key[2]; + int keycode; + char * text = NULL; + + keycode = event->key(); + key[0] = '\0'; + key[1] = '\0'; + switch (keycode) { + case Qt::Key_Up: + key[0]=NAVIT_KEY_UP; + break; + case Qt::Key_Down: + key[0]=NAVIT_KEY_DOWN; + break; + case Qt::Key_Left: + key[0]=NAVIT_KEY_LEFT; + break; + case Qt::Key_Right: + key[0]=NAVIT_KEY_RIGHT; + break; + case Qt::Key_Backspace: + key[0]=NAVIT_KEY_BACKSPACE; + break; + case Qt::Key_Tab: + key[0]=NAVIT_KEY_TAB; + break; + case Qt::Key_Delete: + key[0]=NAVIT_KEY_DELETE; + break; + case Qt::Key_Escape: + key[0]=NAVIT_KEY_BACK; + break; + case Qt::Key_Return: + case Qt::Key_Enter: + key[0]=NAVIT_KEY_RETURN; + break; + case Qt::Key_ZoomIn: + key[0]=NAVIT_KEY_ZOOM_IN; + break; + case Qt::Key_ZoomOut: + key[0]=NAVIT_KEY_ZOOM_OUT; + break; + case Qt::Key_PageUp: + key[0]=NAVIT_KEY_PAGE_UP; + break; + case Qt::Key_PageDown: + key[0]=NAVIT_KEY_PAGE_DOWN; + break; + default: + QString str=event->text(); + if((str != NULL) && (str.size() != 0)) + { + text=str.toUtf8().data(); + } + } + if(text != NULL) + callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void *)text); + else if (key[0]) + callback_list_call_attr_1(graphics_priv->callbacks, attr_keypress, (void *)key); + else + dbg(lvl_debug,"keyval 0x%x\n", keycode); } void QNavitQuick::keyReleaseEvent(QKeyEvent *event) |
