From c9b9a0ea2f274688da26af20102d349336fdb2a0 Mon Sep 17 00:00:00 2001 From: Elena Zaretskaya Date: Fri, 11 Jan 2019 10:11:03 -0500 Subject: 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 --- .../platforms/linuxfb/qlinuxfbintegration.cpp | 49 +++++++++++++++++++--- .../platforms/linuxfb/qlinuxfbintegration.h | 8 +++- 2 files changed, 51 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/linuxfb') 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 #endif +#include + 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(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(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(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 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 m_fontDb; QScopedPointer m_services; QScopedPointer m_vtHandler; - QScopedPointer m_nativeInterface; + + QEvdevKeyboardManager *m_kbdMgr; }; QT_END_NAMESPACE -- cgit v1.2.3