diff options
author | Elena Zaretskaya <sweetiebrier@yandex.ru> | 2019-01-11 10:11:03 -0500 |
---|---|---|
committer | Elena Zaretskaya <sweetiebrier@yandex.ru> | 2019-01-25 15:00:07 +0000 |
commit | c9b9a0ea2f274688da26af20102d349336fdb2a0 (patch) | |
tree | 53168ab420947b6ac5388e87c0e601b8f590f5e5 /src/platformsupport | |
parent | c4e7f3ab6555c87fb41c5f341524445283720e6a (diff) |
Ability to switch language under platform eglfs/linuxfb
I need to change keymap under platforms eglfs and linuxfb (without wayland).
I use the function QEglFSFunctions::loadKeymap(const QString&), but there's
no way to switch between english and another language than to press AltGr as
a modifier. I added the function that allows to change the language. And also
added the ability to switch the keymap and language for the platform linuxfb
and also added the ability to switch the keymap and language for the platform linuxfb
Task-number: QTBUG-72452
Change-Id: I37432cf60d375555bea2bf668ec1387322b4964f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/platformsupport')
4 files changed, 20 insertions, 1 deletions
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index b21d5d9ef5..ad134a825f 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -76,7 +76,7 @@ void QFdContainer::reset() Q_DECL_NOTHROW QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile) : m_device(device), m_fd(fd.release()), m_notify(nullptr), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff), - m_no_zap(disableZap), m_do_compose(enableCompose), + m_langLock(0), m_no_zap(disableZap), m_do_compose(enableCompose), m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0) { qCDebug(qLcEvdevKey) << "Create keyboard handler with for device" << device; @@ -253,6 +253,8 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint quint8 testmods = m_modifiers; if (m_locks[0] /*CapsLock*/ && (m->flags & QEvdevKeyboardMap::IsLetter)) testmods ^= QEvdevKeyboardMap::ModShift; + if (m_langLock) + testmods ^= QEvdevKeyboardMap::ModAltGr; if (m->modifiers == testmods) map_withmod = m; } @@ -509,6 +511,8 @@ void QEvdevKeyboardHandler::unloadKeymap() m_locks[2] = 1; qCDebug(qLcEvdevKey, "numlock=%d , capslock=%d, scrolllock=%d", m_locks[1], m_locks[0], m_locks[2]); } + + m_langLock = 0; } bool QEvdevKeyboardHandler::loadKeymap(const QString &file) @@ -570,4 +574,9 @@ bool QEvdevKeyboardHandler::loadKeymap(const QString &file) return true; } +void QEvdevKeyboardHandler::switchLang() +{ + m_langLock ^= 1; +} + QT_END_NAMESPACE diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h index 7c64c4febb..5498a3e4f0 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h @@ -192,6 +192,8 @@ public: void readKeycode(); KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat); + void switchLang(); + private: void processKeyEvent(int nativecode, int unicode, int qtcode, Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat); @@ -206,6 +208,7 @@ private: quint8 m_locks[3]; int m_composing; quint16 m_dead_unicode; + quint8 m_langLock; bool m_no_zap; bool m_do_compose; diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp index 85e6a80879..e1659bc0d9 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp @@ -153,4 +153,10 @@ void QEvdevKeyboardManager::loadKeymap(const QString &file) } } +void QEvdevKeyboardManager::switchLang() +{ + foreach (QEvdevKeyboardHandler *handler, m_keyboards) + handler->switchLang(); +} + QT_END_NAMESPACE diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h index 27ea7e468e..326e438a7c 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h @@ -68,6 +68,7 @@ public: ~QEvdevKeyboardManager(); void loadKeymap(const QString &file); + void switchLang(); void addKeyboard(const QString &deviceNode = QString()); void removeKeyboard(const QString &deviceNode); |