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/plugins/platforms/linuxfb | |
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/plugins/platforms/linuxfb')
-rw-r--r-- | src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp | 49 | ||||
-rw-r--r-- | src/plugins/platforms/linuxfb/qlinuxfbintegration.h | 8 |
2 files changed, 51 insertions, 6 deletions
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index f835dbf6d4..9e38900bcd 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -69,12 +69,15 @@ #include <QtInputSupport/private/qtslib_p.h> #endif +#include <QtPlatformHeaders/qlinuxfbfunctions.h> + QT_BEGIN_NAMESPACE QLinuxFbIntegration::QLinuxFbIntegration(const QStringList ¶mList) : m_primaryScreen(nullptr), m_fontDb(new QGenericUnixFontDatabase), - m_services(new QGenericUnixServices) + m_services(new QGenericUnixServices), + m_kbdMgr(0) { #if QT_CONFIG(kms) if (qEnvironmentVariableIntValue("QT_QPA_FB_DRM") != 0) @@ -98,8 +101,6 @@ void QLinuxFbIntegration::initialize() m_inputContext = QPlatformInputContextFactory::create(); - m_nativeInterface.reset(new QPlatformNativeInterface); - m_vtHandler.reset(new QFbVtHandler); if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT")) @@ -163,7 +164,7 @@ void QLinuxFbIntegration::createInputHandlers() #endif #if QT_CONFIG(evdev) - new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this); + m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString(), this); new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString(), this); #if QT_CONFIG(tslib) if (!useTslib) @@ -174,7 +175,45 @@ void QLinuxFbIntegration::createInputHandlers() QPlatformNativeInterface *QLinuxFbIntegration::nativeInterface() const { - return m_nativeInterface.data(); + return const_cast<QLinuxFbIntegration *>(this); +} + +QFunctionPointer QLinuxFbIntegration::platformFunction(const QByteArray &function) const +{ +#if QT_CONFIG(evdev) + if (function == QLinuxFbFunctions::loadKeymapTypeIdentifier()) + return QFunctionPointer(loadKeymapStatic); + else if (function == QLinuxFbFunctions::switchLangTypeIdentifier()) + return QFunctionPointer(switchLangStatic); +#else + Q_UNUSED(function) +#endif + + return 0; +} + +void QLinuxFbIntegration::loadKeymapStatic(const QString &filename) +{ +#if QT_CONFIG(evdev) + QLinuxFbIntegration *self = static_cast<QLinuxFbIntegration *>(QGuiApplicationPrivate::platformIntegration()); + if (self->m_kbdMgr) + self->m_kbdMgr->loadKeymap(filename); + else + qWarning("QLinuxFbIntegration: Cannot load keymap, no keyboard handler found"); +#else + Q_UNUSED(filename); +#endif +} + +void QLinuxFbIntegration::switchLangStatic() +{ +#if QT_CONFIG(evdev) + QLinuxFbIntegration *self = static_cast<QLinuxFbIntegration *>(QGuiApplicationPrivate::platformIntegration()); + if (self->m_kbdMgr) + self->m_kbdMgr->switchLang(); + else + qWarning("QLinuxFbIntegration: Cannot switch language, no keyboard handler found"); +#endif } QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index 22578bf980..7a871b3812 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -48,6 +48,7 @@ QT_BEGIN_NAMESPACE class QAbstractEventDispatcher; class QFbScreen; class QFbVtHandler; +class QEvdevKeyboardManager; class QLinuxFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface { @@ -71,15 +72,20 @@ public: QList<QPlatformScreen *> screens() const; + QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE; + private: void createInputHandlers(); + static void loadKeymapStatic(const QString &filename); + static void switchLangStatic(); QFbScreen *m_primaryScreen; QPlatformInputContext *m_inputContext; QScopedPointer<QPlatformFontDatabase> m_fontDb; QScopedPointer<QPlatformServices> m_services; QScopedPointer<QFbVtHandler> m_vtHandler; - QScopedPointer<QPlatformNativeInterface> m_nativeInterface; + + QEvdevKeyboardManager *m_kbdMgr; }; QT_END_NAMESPACE |