Cocoa Integration: Support non-native input context plugins

This is useful, for example, when we want to test the virtual
keyboard on OS X. It uses the usual QT_IM_MODULE code path
provided by QPlatformInputContextFactory if that environment
variable is set. If not, it defaults to QCocoaInputContext.

Change-Id: Ib917d7bd2f4e86eacbc50dd7592cc288a9a702de
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Gabriel de Dietrich 2015-07-27 15:59:44 +02:00
parent b4f266c4e4
commit 0193d6d5bb
2 changed files with 8 additions and 4 deletions

View File

@ -113,7 +113,7 @@ public:
QCoreTextFontDatabase *fontDatabase() const;
QCocoaNativeInterface *nativeInterface() const;
QCocoaInputContext *inputContext() const;
QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
QCocoaAccessibility *accessibility() const;
QCocoaClipboard *clipboard() const;
QCocoaDrag *drag() const;
@ -144,7 +144,7 @@ private:
QScopedPointer<QCoreTextFontDatabase> mFontDb;
QScopedPointer<QCocoaInputContext> mInputContext;
QScopedPointer<QPlatformInputContext> mInputContext;
#ifndef QT_NO_ACCESSIBILITY
QScopedPointer<QCocoaAccessibility> mAccessibility;
#endif

View File

@ -48,6 +48,7 @@
#include "qcocoaaccessibility.h"
#include <qpa/qplatformaccessibility.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <QtCore/qcoreapplication.h>
#include <IOKit/graphics/IOGraphicsLib.h>
@ -247,7 +248,6 @@ QCocoaIntegration *QCocoaIntegration::mInstance = 0;
QCocoaIntegration::QCocoaIntegration()
: mFontDb(new QCoreTextFontDatabase())
, mInputContext(new QCocoaInputContext)
#ifndef QT_NO_ACCESSIBILITY
, mAccessibility(new QCocoaAccessibility)
#endif
@ -261,6 +261,10 @@ QCocoaIntegration::QCocoaIntegration()
qWarning("Creating multiple Cocoa platform integrations is not supported");
mInstance = this;
mInputContext.reset(QPlatformInputContextFactory::create());
if (mInputContext.isNull())
mInputContext.reset(new QCocoaInputContext());
initResources();
QMacAutoReleasePool pool;
@ -462,7 +466,7 @@ QCocoaNativeInterface *QCocoaIntegration::nativeInterface() const
return mNativeInterface.data();
}
QCocoaInputContext *QCocoaIntegration::inputContext() const
QPlatformInputContext *QCocoaIntegration::inputContext() const
{
return mInputContext.data();
}