From 8be11227100498d7098eb7f39bbbe1e7ac6b01cf Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Thu, 8 Sep 2011 17:22:55 +0300 Subject: Add plugin mechanism to load platform input contexts Change-Id: I6e74fd395325445420efce4adf13e89abe8177ee Reviewed-on: http://codereview.qt-project.org/4482 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- src/gui/kernel/qguiapplication_p.h | 2 - src/gui/kernel/qinputpanel.cpp | 1 - src/gui/kernel/qplatforminputcontext_qpa.h | 3 +- src/platformsupport/inputcontext/inputcontext.pri | 6 + .../qplatforminputcontextfactory_qpa.cpp | 83 ++++++ .../qplatforminputcontextfactory_qpa_p.h | 78 +++++ .../qplatforminputcontextplugin_qpa.cpp | 55 ++++ .../qplatforminputcontextplugin_qpa_p.h | 92 ++++++ src/platformsupport/inputmethods/ibus/ibus.pri | 11 - .../org.freedesktop.IBus.InputContext.xml | 80 ----- .../ibus/interfaces/org.freedesktop.IBus.xml | 30 -- .../inputmethods/ibus/qibusinputcontextproxy.cpp | 26 -- .../inputmethods/ibus/qibusinputcontextproxy.h | 144 --------- .../ibus/qibusplatforminputcontext.cpp | 329 --------------------- .../inputmethods/ibus/qibusplatforminputcontext.h | 74 ----- .../inputmethods/ibus/qibusproxy.cpp | 26 -- src/platformsupport/inputmethods/ibus/qibusproxy.h | 88 ------ .../inputmethods/ibus/qibustypes.cpp | 209 ------------- src/platformsupport/inputmethods/ibus/qibustypes.h | 116 -------- src/platformsupport/inputmethods/inputmethods.pri | 5 - src/platformsupport/platformsupport.pro | 2 +- src/plugins/platforminputcontexts/ibus/ibus.pro | 19 ++ .../org.freedesktop.IBus.InputContext.xml | 80 +++++ .../ibus/interfaces/org.freedesktop.IBus.xml | 30 ++ src/plugins/platforminputcontexts/ibus/main.cpp | 71 +++++ .../ibus/qibusinputcontextproxy.cpp | 26 ++ .../ibus/qibusinputcontextproxy.h | 144 +++++++++ .../ibus/qibusplatforminputcontext.cpp | 329 +++++++++++++++++++++ .../ibus/qibusplatforminputcontext.h | 74 +++++ .../platforminputcontexts/ibus/qibusproxy.cpp | 26 ++ .../platforminputcontexts/ibus/qibusproxy.h | 88 ++++++ .../platforminputcontexts/ibus/qibustypes.cpp | 209 +++++++++++++ .../platforminputcontexts/ibus/qibustypes.h | 116 ++++++++ .../platforminputcontexts.pro | 4 + src/plugins/platforms/xcb/qxcbintegration.cpp | 16 +- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 19 +- src/plugins/plugins.pro | 5 +- 37 files changed, 1562 insertions(+), 1154 deletions(-) create mode 100644 src/platformsupport/inputcontext/inputcontext.pri create mode 100644 src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa.cpp create mode 100644 src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa_p.h create mode 100644 src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa.cpp create mode 100644 src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa_p.h delete mode 100644 src/platformsupport/inputmethods/ibus/ibus.pri delete mode 100644 src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml delete mode 100644 src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml delete mode 100644 src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp delete mode 100644 src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h delete mode 100644 src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp delete mode 100644 src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h delete mode 100644 src/platformsupport/inputmethods/ibus/qibusproxy.cpp delete mode 100644 src/platformsupport/inputmethods/ibus/qibusproxy.h delete mode 100644 src/platformsupport/inputmethods/ibus/qibustypes.cpp delete mode 100644 src/platformsupport/inputmethods/ibus/qibustypes.h delete mode 100644 src/platformsupport/inputmethods/inputmethods.pri create mode 100644 src/plugins/platforminputcontexts/ibus/ibus.pro create mode 100644 src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml create mode 100644 src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.xml create mode 100644 src/plugins/platforminputcontexts/ibus/main.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h create mode 100644 src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h create mode 100644 src/plugins/platforminputcontexts/ibus/qibusproxy.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibusproxy.h create mode 100644 src/plugins/platforminputcontexts/ibus/qibustypes.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibustypes.h create mode 100644 src/plugins/platforminputcontexts/platforminputcontexts.pro diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 9f64911399..97cf7d371e 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -59,8 +59,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -class QPlatformIntegration; - class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate { Q_DECLARE_PUBLIC(QGuiApplication) diff --git a/src/gui/kernel/qinputpanel.cpp b/src/gui/kernel/qinputpanel.cpp index 233ac93cb8..b6160dc71a 100644 --- a/src/gui/kernel/qinputpanel.cpp +++ b/src/gui/kernel/qinputpanel.cpp @@ -53,7 +53,6 @@ QInputPanel::~QInputPanel() { } - QObject *QInputPanel::inputItem() const { Q_D(const QInputPanel); diff --git a/src/gui/kernel/qplatforminputcontext_qpa.h b/src/gui/kernel/qplatforminputcontext_qpa.h index 1720e634c7..804200708a 100644 --- a/src/gui/kernel/qplatforminputcontext_qpa.h +++ b/src/gui/kernel/qplatforminputcontext_qpa.h @@ -53,8 +53,9 @@ QT_MODULE(Gui) class QWindow; class QMouseEvent; -class Q_GUI_EXPORT QPlatformInputContext +class Q_GUI_EXPORT QPlatformInputContext : public QObject { + Q_OBJECT public: QPlatformInputContext(); virtual ~QPlatformInputContext(); diff --git a/src/platformsupport/inputcontext/inputcontext.pri b/src/platformsupport/inputcontext/inputcontext.pri new file mode 100644 index 0000000000..e1a44684ba --- /dev/null +++ b/src/platformsupport/inputcontext/inputcontext.pri @@ -0,0 +1,6 @@ +HEADERS += \ + $$PWD/qplatforminputcontextplugin_qpa_p.h \ + $$PWD/qplatforminputcontextfactory_qpa_p.h +SOURCES += \ + $$PWD/qplatforminputcontextplugin_qpa.cpp \ + $$PWD/qplatforminputcontextfactory_qpa.cpp diff --git a/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa.cpp b/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa.cpp new file mode 100644 index 0000000000..255ed71fe2 --- /dev/null +++ b/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatforminputcontextfactory_qpa_p.h" +#include "qplatforminputcontextplugin_qpa_p.h" +#include +#include "private/qfactoryloader_p.h" + +#include "qguiapplication.h" +#include "qdebug.h" + +QT_BEGIN_NAMESPACE + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, + (QPlatformInputContextFactoryInterface_iid, QLatin1String("/platforminputcontexts"), Qt::CaseInsensitive)) +Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, + (QPlatformInputContextFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif + +QStringList QPlatformInputContextFactory::keys() +{ +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + QStringList list = loader()->keys(); +#else + QStringList list; +#endif + return list; +} + +QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key) +{ + QPlatformInputContext *ret = 0; + QStringList paramList = key.split(QLatin1Char(':')); + QString platform = paramList.takeFirst().toLower(); + +#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) + if (QPlatformInputContextFactoryInterface *factory = qobject_cast(loader()->instance(platform))) + ret = factory->create(platform, paramList); +#endif + return ret; +} + +QT_END_NAMESPACE + diff --git a/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa_p.h b/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa_p.h new file mode 100644 index 0000000000..ea7f4f1319 --- /dev/null +++ b/src/platformsupport/inputcontext/qplatforminputcontextfactory_qpa_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINPUTCONTEXTFACTORY_H +#define QPLATFORMINPUTCONTEXTFACTORY_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformInputContext; + +class QPlatformInputContextFactory +{ +public: + static QStringList keys(); + static QPlatformInputContext *create(const QString &key); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINPUTCONTEXTFACTORY_H + diff --git a/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa.cpp b/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa.cpp new file mode 100644 index 0000000000..380ab06d9c --- /dev/null +++ b/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qplatforminputcontextplugin_qpa_p.h" + +QT_BEGIN_NAMESPACE + +QPlatformInputContextPlugin::QPlatformInputContextPlugin(QObject *parent) + : QObject(parent) +{ +} + +QPlatformInputContextPlugin::~QPlatformInputContextPlugin() +{ +} + +QT_END_NAMESPACE diff --git a/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa_p.h b/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa_p.h new file mode 100644 index 0000000000..1dfb759682 --- /dev/null +++ b/src/platformsupport/inputcontext/qplatforminputcontextplugin_qpa_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMINPUTCONTEXTPLUGIN_H +#define QPLATFORMINPUTCONTEXTPLUGIN_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPlatformInputContext; + + struct QPlatformInputContextFactoryInterface : public QFactoryInterface +{ + virtual QPlatformInputContext *create(const QString &key, const QStringList ¶mList) = 0; +}; + +#define QPlatformInputContextFactoryInterface_iid "com.nokia.Qt.QPlatformInputContextFactoryInterface" + +Q_DECLARE_INTERFACE(QPlatformInputContextFactoryInterface, QPlatformInputContextFactoryInterface_iid) + +class Q_GUI_EXPORT QPlatformInputContextPlugin : public QObject, public QPlatformInputContextFactoryInterface +{ + Q_OBJECT + Q_INTERFACES(QPlatformInputContextFactoryInterface:QFactoryInterface) +public: + explicit QPlatformInputContextPlugin(QObject *parent = 0); + ~QPlatformInputContextPlugin(); + + virtual QStringList keys() const = 0; + virtual QPlatformInputContext *create(const QString &key, const QStringList ¶mList) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QPLATFORMINPUTCONTEXTPLUGIN_H diff --git a/src/platformsupport/inputmethods/ibus/ibus.pri b/src/platformsupport/inputmethods/ibus/ibus.pri deleted file mode 100644 index c6e59aa484..0000000000 --- a/src/platformsupport/inputmethods/ibus/ibus.pri +++ /dev/null @@ -1,11 +0,0 @@ -QT += dbus - -SOURCES += $$PWD/qibusplatforminputcontext.cpp \ - $$PWD/qibusproxy.cpp \ - $$PWD/qibusinputcontextproxy.cpp \ - $$PWD/qibustypes.cpp - -HEADERS += $$PWD/qibusplatforminputcontext.h \ - $$PWD/qibusproxy.h \ - $$PWD/qibusinputcontextproxy.h \ - $$PWD/qibustypes.h diff --git a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml deleted file mode 100644 index dbc79c178b..0000000000 --- a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.InputContext.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml b/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml deleted file mode 100644 index 6ac4891771..0000000000 --- a/src/platformsupport/inputmethods/ibus/interfaces/org.freedesktop.IBus.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp deleted file mode 100644 index 7adffbc2e2..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml - * - * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "qibusinputcontextproxy.h" - -/* - * Implementation of interface class QIBusInputContextProxy - */ - -QIBusInputContextProxy::QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -QIBusInputContextProxy::~QIBusInputContextProxy() -{ -} - diff --git a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h b/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h deleted file mode 100644 index 9a91c4e484..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusinputcontextproxy.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml - * - * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef QIBUSINPUTCONTEXTPROXY_H_1308831153 -#define QIBUSINPUTCONTEXTPROXY_H_1308831153 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface org.freedesktop.IBus.InputContext - */ -class QIBusInputContextProxy: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "org.freedesktop.IBus.InputContext"; } - -public: - QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~QIBusInputContextProxy(); - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<> Destroy() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); - } - - inline QDBusPendingReply<> Disable() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("Disable"), argumentList); - } - - inline QDBusPendingReply<> Enable() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("Enable"), argumentList); - } - - inline QDBusPendingReply<> FocusIn() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList); - } - - inline QDBusPendingReply<> FocusOut() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList); - } - - inline QDBusPendingReply GetEngine() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("GetEngine"), argumentList); - } - - inline QDBusPendingReply IsEnabled() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("IsEnabled"), argumentList); - } - - inline QDBusPendingReply ProcessKeyEvent(uint keyval, uint keycode, uint state) - { - QList argumentList; - argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state); - return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList); - } - - inline QDBusPendingReply<> PropertyActivate(const QString &name, int state) - { - QList argumentList; - argumentList << QVariant::fromValue(name) << QVariant::fromValue(state); - return asyncCallWithArgumentList(QLatin1String("PropertyActivate"), argumentList); - } - - inline QDBusPendingReply<> Reset() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList); - } - - inline QDBusPendingReply<> SetCapabilities(uint caps) - { - QList argumentList; - argumentList << QVariant::fromValue(caps); - return asyncCallWithArgumentList(QLatin1String("SetCapabilities"), argumentList); - } - - inline QDBusPendingReply<> SetCursorLocation(int x, int y, int w, int h) - { - QList argumentList; - argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); - return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList); - } - - inline QDBusPendingReply<> SetEngine(const QString &name) - { - QList argumentList; - argumentList << QVariant::fromValue(name); - return asyncCallWithArgumentList(QLatin1String("SetEngine"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void CommitText(const QDBusVariant &text); - void CursorDownLookupTable(); - void CursorUpLookupTable(); - void Disabled(); - void Enabled(); - void ForwardKeyEvent(uint keyval, uint keycode, uint state); - void HideAuxiliaryText(); - void HideLookupTable(); - void HidePreeditText(); - void PageDownLookupTable(); - void PageUpLookupTable(); - void RegisterProperties(const QDBusVariant &props); - void ShowAuxiliaryText(); - void ShowLookupTable(); - void ShowPreeditText(); - void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); - void UpdateLookupTable(const QDBusVariant &table, bool visible); - void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); - void UpdateProperty(const QDBusVariant &prop); -}; - -#endif diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp deleted file mode 100644 index af8fd5a1f1..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "qibusplatforminputcontext.h" - -#include -#include -#include -#include -#include - -#include "qibusproxy.h" -#include "qibusinputcontextproxy.h" -#include "qibustypes.h" - -#include -#include - -#include - -enum { debug = 0 }; - -class QIBusPlatformInputContextPrivate -{ -public: - QIBusPlatformInputContextPrivate(); - ~QIBusPlatformInputContextPrivate() - { - delete context; - delete bus; - delete connection; - } - - static QDBusConnection *createConnection(); - - QDBusConnection *connection; - QIBusProxy *bus; - QIBusInputContextProxy *context; - - bool valid; -}; - - -QIBusPlatformInputContext::QIBusPlatformInputContext () - : d(new QIBusPlatformInputContextPrivate()) -{ - if (d->context) { - connect(d->context, SIGNAL(CommitText(QDBusVariant)), SLOT(commitText(QDBusVariant))); - connect(d->context, SIGNAL(UpdatePreeditText(QDBusVariant,uint,bool)), this, SLOT(updatePreeditText(QDBusVariant,uint,bool))); - } - QInputPanel *p = qApp->inputPanel(); - connect(p, SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged())); - connect(p, SIGNAL(cursorRectangleChanged()), this, SLOT(cursorRectChanged())); -} - -QIBusPlatformInputContext::~QIBusPlatformInputContext (void) -{ - delete d; -} - -bool QIBusPlatformInputContext::isValid() const -{ - return d->valid; -} - -void QIBusPlatformInputContext::invokeAction(QInputPanel::Action a, int x) -{ - QPlatformInputContext::invokeAction(a, x); - - if (!d->valid) - return; -} - -void QIBusPlatformInputContext::reset() -{ - QPlatformInputContext::reset(); - - if (!d->valid) - return; - - d->context->Reset(); -} - -void QIBusPlatformInputContext::update(Qt::InputMethodQueries q) -{ - QPlatformInputContext::update(q); -} - -void QIBusPlatformInputContext::cursorRectChanged() -{ - if (!d->valid) - return; - - QRect r = qApp->inputPanel()->cursorRectangle().toRect(); - if(!r.isValid()) - return; - - QWindow *inputWindow = qApp->inputPanel()->inputWindow(); - r.moveTopLeft(inputWindow->mapToGlobal(r.topLeft())); - if (debug) - qDebug() << "microFocus" << r; - d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height()); -} - -void QIBusPlatformInputContext::inputItemChanged() -{ - if (!d->valid) - return; - - QObject *input = qApp->inputPanel()->inputItem(); - if (debug) - qDebug() << "setFocusObject" << input; - if (input) - d->context->FocusIn(); - else - d->context->FocusOut(); -} - - -void QIBusPlatformInputContext::commitText(const QDBusVariant &text) -{ - QObject *input = qApp->inputPanel()->inputItem(); - if (!input) - return; - - const QDBusArgument arg = text.variant().value(); - - QIBusText t; - if (debug) - qDebug() << arg.currentSignature(); - t.fromDBusArgument(arg); - if (debug) - qDebug() << "commit text:" << t.text; - - QInputMethodEvent event; - event.setCommitString(t.text); - QCoreApplication::sendEvent(input, &event); -} - -void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint cursorPos, bool visible) -{ - QObject *input = qApp->inputPanel()->inputItem(); - if (!input) - return; - - const QDBusArgument arg = text.variant().value(); - - QIBusText t; - t.fromDBusArgument(arg); - if (debug) - qDebug() << "preedit text:" << t.text; - - QList attributes = t.attributes.imAttributes(); - attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0, QVariant()); - - QInputMethodEvent event(t.text, attributes); - QCoreApplication::sendEvent(input, &event); -} - - -/* Kernel keycode -> X keycode table */ -static const unsigned int keycode_table[256] = { - 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 111, 221, 94, 95, 96, 211, 128, 127, 129, 208, 131, 126, - 108, 109, 112, 111, 113, 181, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, - 239, 160, 174, 176, 222, 157, 123, 110, 139, 134, 209, 210, 133, 115, 116, 117, - 232, 133, 134, 135, 140, 248, 191, 192, 122, 188, 245, 158, 161, 193, 223, 227, - 198, 199, 200, 147, 159, 151, 178, 201, 146, 203, 166, 236, 230, 235, 234, 233, - 163, 204, 253, 153, 162, 144, 164, 177, 152, 190, 208, 129, 130, 231, 209, 210, - 136, 220, 143, 246, 251, 137, 138, 182, 183, 184, 93, 184, 247, 132, 170, 219, - 249, 205, 207, 149, 150, 154, 155, 167, 168, 169, 171, 172, 173, 165, 175, 179, - 180, 0, 185, 186, 187, 118, 119, 120, 121, 229, 194, 195, 196, 197, 148, 202, - 101, 212, 237, 214, 215, 216, 217, 218, 228, 142, 213, 240, 241, 242, 243, 244, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -bool -QIBusPlatformInputContext::x11FilterEvent(uint keyval, uint keycode, uint state, bool press) -{ - if (!d->valid) - return false; - - if (!press) - return false; - - keycode -= 8; // ### - QDBusReply reply = d->context->ProcessKeyEvent(keyval, keycode, state); - -// qDebug() << "x11FilterEvent return" << reply.value(); - - return reply.value(); -} - -QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() - : connection(createConnection()), - bus(0), - context(0), - valid(false) -{ - if (!connection || !connection->isConnected()) { - qDebug("QIBusPlatformInputContext: not connected."); - return; - } - - bus = new QIBusProxy(QLatin1String("org.freedesktop.IBus"), - QLatin1String("/org/freedesktop/IBus"), - *connection); - if (!bus->isValid()) { - qWarning("QIBusPlatformInputContext: invalid bus."); - return; - } - - QDBusReply ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); - if (!ic.isValid()) { - qWarning("QIBusPlatformInputContext: CreateInputContext failed."); - return; - } - - context = new QIBusInputContextProxy(QLatin1String("org.freedesktop.IBus"), ic.value().path(), *connection); - - if (!context->isValid()) { - qWarning("QIBusPlatformInputContext: invalid input context."); - return; - } - - enum Capabilities { - IBUS_CAP_PREEDIT_TEXT = 1 << 0, - IBUS_CAP_AUXILIARY_TEXT = 1 << 1, - IBUS_CAP_LOOKUP_TABLE = 1 << 2, - IBUS_CAP_FOCUS = 1 << 3, - IBUS_CAP_PROPERTY = 1 << 4, - IBUS_CAP_SURROUNDING_TEXT = 1 << 5 - }; - context->SetCapabilities(IBUS_CAP_PREEDIT_TEXT|IBUS_CAP_FOCUS); - - if (debug) - qDebug(">>>> valid!"); - valid = true; -} - -QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() -{ - QByteArray display(getenv("DISPLAY")); - QByteArray host = "unix"; - QByteArray displayNumber = "0"; - - int pos = display.indexOf(':'); - if (pos > 0) - host = display.left(pos); - ++pos; - int pos2 = display.indexOf('.', pos); - if (pos2 > 0) - displayNumber = display.mid(pos, pos2 - pos); - if (debug) - qDebug() << "host=" << host << "displayNumber" << displayNumber; - - QFile file(QDir::homePath() + QLatin1String("/.config/ibus/bus/") + - QLatin1String(QDBusConnection::localMachineId()) + - QLatin1Char('-') + QString::fromLocal8Bit(host) + QLatin1Char('-') + QString::fromLocal8Bit(displayNumber)); - - if (!file.exists()) { - qWarning("QIBusPlatformInputContext: ibus config file '%s' does not exist.", qPrintable(file.fileName())); - return 0; - } - - file.open(QFile::ReadOnly); - - QByteArray address; - int pid = -1; - - while (!file.atEnd()) { - QByteArray line = file.readLine().trimmed(); - if (line.startsWith('#')) - continue; - - if (line.startsWith("IBUS_ADDRESS=")) - address = line.mid(sizeof("IBUS_ADDRESS=") - 1); - if (line.startsWith("IBUS_DAEMON_PID=")) - pid = line.mid(sizeof("IBUS_DAEMON_PID=") - 1).toInt(); - } - - if (debug) - qDebug() << "IBUS_ADDRESS=" << address << "PID=" << pid; - if (address.isEmpty() || pid < 0 || kill(pid, 0) != 0) - return 0; - - return new QDBusConnection(QDBusConnection::connectToBus(QString::fromLatin1(address), QLatin1String("QIBusProxy"))); -} diff --git a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h b/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h deleted file mode 100644 index 8583118306..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusplatforminputcontext.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QIBUSPLATFORMINPUTCONTEXT_H -#define QIBUSPLATFORMINPUTCONTEXT_H - -#include - -class QIBusPlatformInputContextPrivate; -class QDBusVariant; - -class QIBusPlatformInputContext : public QObject, public QPlatformInputContext -{ - Q_OBJECT -public: - QIBusPlatformInputContext(); - ~QIBusPlatformInputContext(); - - bool isValid() const; - - void invokeAction(QInputPanel::Action a, int x); - void reset(void); - void update(Qt::InputMethodQueries); - - bool x11FilterEvent(uint keyval, uint keycode, uint state, bool press); - -public Q_SLOTS: - void commitText(const QDBusVariant &text); - void updatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); - void inputItemChanged(); - void cursorRectChanged(); - -private: - QIBusPlatformInputContextPrivate *d; -}; - -#endif diff --git a/src/platformsupport/inputmethods/ibus/qibusproxy.cpp b/src/platformsupport/inputmethods/ibus/qibusproxy.cpp deleted file mode 100644 index 9d64b603f3..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusproxy.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml - * - * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "qibusproxy.h" - -/* - * Implementation of interface class QIBusProxy - */ - -QIBusProxy::QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -QIBusProxy::~QIBusProxy() -{ -} - diff --git a/src/platformsupport/inputmethods/ibus/qibusproxy.h b/src/platformsupport/inputmethods/ibus/qibusproxy.h deleted file mode 100644 index 389eec3175..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibusproxy.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml - * - * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef QIBUSPROXY_H_1308831142 -#define QIBUSPROXY_H_1308831142 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface org.freedesktop.IBus - */ -class QIBusProxy: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "org.freedesktop.IBus"; } - -public: - QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~QIBusProxy(); - -public Q_SLOTS: // METHODS - inline QDBusPendingReply CreateInputContext(const QString &name) - { - QList argumentList; - argumentList << QVariant::fromValue(name); - return asyncCallWithArgumentList(QLatin1String("CreateInputContext"), argumentList); - } - - inline QDBusPendingReply<> Exit(bool restart) - { - QList argumentList; - argumentList << QVariant::fromValue(restart); - return asyncCallWithArgumentList(QLatin1String("Exit"), argumentList); - } - - inline QDBusPendingReply GetAddress() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("GetAddress"), argumentList); - } - - inline QDBusPendingReply ListActiveEngines() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("ListActiveEngines"), argumentList); - } - - inline QDBusPendingReply ListEngines() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("ListEngines"), argumentList); - } - - inline QDBusPendingReply Ping(const QDBusVariant &data) - { - QList argumentList; - argumentList << QVariant::fromValue(data); - return asyncCallWithArgumentList(QLatin1String("Ping"), argumentList); - } - - inline QDBusPendingReply<> RegisterComponent(const QDBusVariant &components) - { - QList argumentList; - argumentList << QVariant::fromValue(components); - return asyncCallWithArgumentList(QLatin1String("RegisterComponent"), argumentList); - } - -Q_SIGNALS: // SIGNALS -}; - -#endif diff --git a/src/platformsupport/inputmethods/ibus/qibustypes.cpp b/src/platformsupport/inputmethods/ibus/qibustypes.cpp deleted file mode 100644 index 8d8c61afb7..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibustypes.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qibustypes.h" -#include -#include - -QIBusSerializable::QIBusSerializable() -{ -} - -QIBusSerializable::~QIBusSerializable() -{ -} - -void QIBusSerializable::fromDBusArgument(const QDBusArgument &arg) -{ - arg >> name; - arg.beginMap(); - while (!arg.atEnd()) { - arg.beginMapEntry(); - QString key; - QDBusVariant value; - arg >> key; - arg >> value; - arg.endMapEntry(); - attachments[key] = value.variant().value(); - } - arg.endMap(); -} - - - -QIBusAttribute::QIBusAttribute() - : type(Invalid), - value(0), - start(0), - end(0) -{ -} - -QIBusAttribute::~QIBusAttribute() -{ - -} - -void QIBusAttribute::fromDBusArgument(const QDBusArgument &arg) -{ -// qDebug() << "QIBusAttribute::fromDBusArgument()" << arg.currentSignature(); - arg.beginStructure(); - - QIBusSerializable::fromDBusArgument(arg); - - quint32 t; - arg >> t; - type = (Type)t; - arg >> value; - arg >> start; - arg >> end; - - arg.endStructure(); -} - -QTextFormat QIBusAttribute::format() const -{ - QTextCharFormat fmt; - switch (type) { - case Invalid: - break; - case Underline: { - QTextCharFormat::UnderlineStyle style = QTextCharFormat::NoUnderline; - - switch (value) { - case UnderlineNone: - break; - case UnderlineSingle: - style = QTextCharFormat::SingleUnderline; - break; - case UnderlineDouble: - style = QTextCharFormat::DashUnderline; - break; - case UnderlineLow: - style = QTextCharFormat::DashDotLine; - break; - case UnderlineError: - style = QTextCharFormat::WaveUnderline; - fmt.setUnderlineColor(Qt::red); - break; - } - - fmt.setUnderlineStyle(style); - break; - } - case Foreground: - fmt.setForeground(QColor(value)); - break; - case Background: - fmt.setBackground(QColor(value)); - break; - } - return fmt; -} - - -QIBusAttributeList::QIBusAttributeList() -{ - -} - -QIBusAttributeList::~QIBusAttributeList() -{ - -} - -void QIBusAttributeList::fromDBusArgument(const QDBusArgument &arg) -{ -// qDebug() << "QIBusAttributeList::fromDBusArgument()" << arg.currentSignature(); - arg.beginStructure(); - - QIBusSerializable::fromDBusArgument(arg); - - arg.beginArray(); - while(!arg.atEnd()) { - QDBusVariant var; - arg >> var; - - QIBusAttribute attr; - attr.fromDBusArgument(var.variant().value()); - attributes.append(attr); - } - arg.endArray(); - - arg.endStructure(); -} - -QList QIBusAttributeList::imAttributes() const -{ - QList imAttrs; - for (int i = 0; i < attributes.size(); ++i) { - const QIBusAttribute &attr = attributes.at(i); - imAttrs += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, attr.start, attr.end - attr.start, attr.format()); - } - return imAttrs; -} - - -QIBusText::QIBusText() -{ - -} - -QIBusText::~QIBusText() -{ - -} - -void QIBusText::fromDBusArgument(const QDBusArgument &arg) -{ -// qDebug() << "QIBusText::fromDBusArgument()" << arg.currentSignature(); - arg.beginStructure(); - - QIBusSerializable::fromDBusArgument(arg); - - arg >> text; - QDBusVariant variant; - arg >> variant; - attributes.fromDBusArgument(variant.variant().value()); - - arg.endStructure(); -} - diff --git a/src/platformsupport/inputmethods/ibus/qibustypes.h b/src/platformsupport/inputmethods/ibus/qibustypes.h deleted file mode 100644 index c426ff7eda..0000000000 --- a/src/platformsupport/inputmethods/ibus/qibustypes.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QIBUSTYPES_H -#define QIBUSTYPES_H - -#include -#include - -class QDBusArgument; - -class QIBusSerializable -{ -public: - QIBusSerializable(); - virtual ~QIBusSerializable(); - - virtual void fromDBusArgument(const QDBusArgument &arg); - - QString name; - QHash attachments; -}; - -class QIBusAttribute : public QIBusSerializable -{ -public: - enum Type { - Invalid = 0, - Underline = 1, - Foreground = 2, - Background = 3, - }; - - enum Underline { - UnderlineNone = 0, - UnderlineSingle = 1, - UnderlineDouble = 2, - UnderlineLow = 3, - UnderlineError = 4, - }; - - QIBusAttribute(); - ~QIBusAttribute(); - - void fromDBusArgument(const QDBusArgument &arg); - QTextFormat format() const; - - Type type; - quint32 value; - quint32 start; - quint32 end; -}; - -class QIBusAttributeList : public QIBusSerializable -{ -public: - QIBusAttributeList(); - ~QIBusAttributeList(); - - void fromDBusArgument(const QDBusArgument &arg); - - QList imAttributes() const; - - QVector attributes; -}; - -class QIBusText : public QIBusSerializable -{ -public: - QIBusText(); - ~QIBusText(); - - void fromDBusArgument(const QDBusArgument &arg); - - QString text; - QIBusAttributeList attributes; -}; - -#endif diff --git a/src/platformsupport/inputmethods/inputmethods.pri b/src/platformsupport/inputmethods/inputmethods.pri deleted file mode 100644 index 0c3a40bb9d..0000000000 --- a/src/platformsupport/inputmethods/inputmethods.pri +++ /dev/null @@ -1,5 +0,0 @@ -contains(QT_CONFIG, dbus) { - !mac:unix: { - include($$PWD/ibus/ibus.pri) - } -} diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 126cff823a..9d6f8dcd41 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -30,4 +30,4 @@ include(fb_base/fb_base.pri) include(fontdatabases/fontdatabases.pri) include(glxconvenience/glxconvenience.pri) include(printersupport/printersupport.pri) -include(inputmethods/inputmethods.pri) +include(inputcontext/inputcontext.pri) diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro new file mode 100644 index 0000000000..193dad0018 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/ibus.pro @@ -0,0 +1,19 @@ +TARGET = ibusplatforminputcontextplugin +load(qt_plugin) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/platforminputcontexts + +QT += dbus platformsupport-private +SOURCES += $$PWD/qibusplatforminputcontext.cpp \ + $$PWD/qibusproxy.cpp \ + $$PWD/qibusinputcontextproxy.cpp \ + $$PWD/qibustypes.cpp \ + $$PWD/main.cpp + +HEADERS += $$PWD/qibusplatforminputcontext.h \ + $$PWD/qibusproxy.h \ + $$PWD/qibusinputcontextproxy.h \ + $$PWD/qibustypes.h + +target.path += $$[QT_INSTALL_PLUGINS]/platforminputcontexts +INSTALLS += target diff --git a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml new file mode 100644 index 0000000000..dbc79c178b --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.InputContext.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.xml b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.xml new file mode 100644 index 0000000000..6ac4891771 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/platforminputcontexts/ibus/main.cpp b/src/plugins/platforminputcontexts/ibus/main.cpp new file mode 100644 index 0000000000..eb773c8856 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/main.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (info@qt.nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include "qibusplatforminputcontext.h" + +QT_BEGIN_NAMESPACE + +class QIbusPlatformInputContextPlugin : public QPlatformInputContextPlugin +{ +public: + QStringList keys() const; + QIBusPlatformInputContext *create(const QString&, const QStringList&); +}; + +QStringList QIbusPlatformInputContextPlugin::keys() const +{ + return QStringList(QStringLiteral("ibus")); +} + +QIBusPlatformInputContext *QIbusPlatformInputContextPlugin::create(const QString& system, const QStringList& paramList) +{ + Q_UNUSED(paramList); + + if (system.compare(system, QStringLiteral("ibus"), Qt::CaseInsensitive) == 0) + return new QIBusPlatformInputContext; + return 0; +} + +Q_EXPORT_PLUGIN2(ibusplatforminputcontextplugin, QIbusPlatformInputContextPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp new file mode 100644 index 0000000000..7adffbc2e2 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "qibusinputcontextproxy.h" + +/* + * Implementation of interface class QIBusInputContextProxy + */ + +QIBusInputContextProxy::QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +QIBusInputContextProxy::~QIBusInputContextProxy() +{ +} + diff --git a/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h new file mode 100644 index 0000000000..9a91c4e484 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusinputcontextproxy.h @@ -0,0 +1,144 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusinputcontextproxy -c QIBusInputContextProxy interfaces/org.freedesktop.IBus.InputContext.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef QIBUSINPUTCONTEXTPROXY_H_1308831153 +#define QIBUSINPUTCONTEXTPROXY_H_1308831153 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.freedesktop.IBus.InputContext + */ +class QIBusInputContextProxy: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.IBus.InputContext"; } + +public: + QIBusInputContextProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~QIBusInputContextProxy(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> Destroy() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Destroy"), argumentList); + } + + inline QDBusPendingReply<> Disable() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Disable"), argumentList); + } + + inline QDBusPendingReply<> Enable() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Enable"), argumentList); + } + + inline QDBusPendingReply<> FocusIn() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList); + } + + inline QDBusPendingReply<> FocusOut() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList); + } + + inline QDBusPendingReply GetEngine() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetEngine"), argumentList); + } + + inline QDBusPendingReply IsEnabled() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("IsEnabled"), argumentList); + } + + inline QDBusPendingReply ProcessKeyEvent(uint keyval, uint keycode, uint state) + { + QList argumentList; + argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state); + return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList); + } + + inline QDBusPendingReply<> PropertyActivate(const QString &name, int state) + { + QList argumentList; + argumentList << QVariant::fromValue(name) << QVariant::fromValue(state); + return asyncCallWithArgumentList(QLatin1String("PropertyActivate"), argumentList); + } + + inline QDBusPendingReply<> Reset() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList); + } + + inline QDBusPendingReply<> SetCapabilities(uint caps) + { + QList argumentList; + argumentList << QVariant::fromValue(caps); + return asyncCallWithArgumentList(QLatin1String("SetCapabilities"), argumentList); + } + + inline QDBusPendingReply<> SetCursorLocation(int x, int y, int w, int h) + { + QList argumentList; + argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h); + return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList); + } + + inline QDBusPendingReply<> SetEngine(const QString &name) + { + QList argumentList; + argumentList << QVariant::fromValue(name); + return asyncCallWithArgumentList(QLatin1String("SetEngine"), argumentList); + } + +Q_SIGNALS: // SIGNALS + void CommitText(const QDBusVariant &text); + void CursorDownLookupTable(); + void CursorUpLookupTable(); + void Disabled(); + void Enabled(); + void ForwardKeyEvent(uint keyval, uint keycode, uint state); + void HideAuxiliaryText(); + void HideLookupTable(); + void HidePreeditText(); + void PageDownLookupTable(); + void PageUpLookupTable(); + void RegisterProperties(const QDBusVariant &props); + void ShowAuxiliaryText(); + void ShowLookupTable(); + void ShowPreeditText(); + void UpdateAuxiliaryText(const QDBusVariant &text, bool visible); + void UpdateLookupTable(const QDBusVariant &table, bool visible); + void UpdatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + void UpdateProperty(const QDBusVariant &prop); +}; + +#endif diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp new file mode 100644 index 0000000000..af8fd5a1f1 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -0,0 +1,329 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qibusplatforminputcontext.h" + +#include +#include +#include +#include +#include + +#include "qibusproxy.h" +#include "qibusinputcontextproxy.h" +#include "qibustypes.h" + +#include +#include + +#include + +enum { debug = 0 }; + +class QIBusPlatformInputContextPrivate +{ +public: + QIBusPlatformInputContextPrivate(); + ~QIBusPlatformInputContextPrivate() + { + delete context; + delete bus; + delete connection; + } + + static QDBusConnection *createConnection(); + + QDBusConnection *connection; + QIBusProxy *bus; + QIBusInputContextProxy *context; + + bool valid; +}; + + +QIBusPlatformInputContext::QIBusPlatformInputContext () + : d(new QIBusPlatformInputContextPrivate()) +{ + if (d->context) { + connect(d->context, SIGNAL(CommitText(QDBusVariant)), SLOT(commitText(QDBusVariant))); + connect(d->context, SIGNAL(UpdatePreeditText(QDBusVariant,uint,bool)), this, SLOT(updatePreeditText(QDBusVariant,uint,bool))); + } + QInputPanel *p = qApp->inputPanel(); + connect(p, SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged())); + connect(p, SIGNAL(cursorRectangleChanged()), this, SLOT(cursorRectChanged())); +} + +QIBusPlatformInputContext::~QIBusPlatformInputContext (void) +{ + delete d; +} + +bool QIBusPlatformInputContext::isValid() const +{ + return d->valid; +} + +void QIBusPlatformInputContext::invokeAction(QInputPanel::Action a, int x) +{ + QPlatformInputContext::invokeAction(a, x); + + if (!d->valid) + return; +} + +void QIBusPlatformInputContext::reset() +{ + QPlatformInputContext::reset(); + + if (!d->valid) + return; + + d->context->Reset(); +} + +void QIBusPlatformInputContext::update(Qt::InputMethodQueries q) +{ + QPlatformInputContext::update(q); +} + +void QIBusPlatformInputContext::cursorRectChanged() +{ + if (!d->valid) + return; + + QRect r = qApp->inputPanel()->cursorRectangle().toRect(); + if(!r.isValid()) + return; + + QWindow *inputWindow = qApp->inputPanel()->inputWindow(); + r.moveTopLeft(inputWindow->mapToGlobal(r.topLeft())); + if (debug) + qDebug() << "microFocus" << r; + d->context->SetCursorLocation(r.x(), r.y(), r.width(), r.height()); +} + +void QIBusPlatformInputContext::inputItemChanged() +{ + if (!d->valid) + return; + + QObject *input = qApp->inputPanel()->inputItem(); + if (debug) + qDebug() << "setFocusObject" << input; + if (input) + d->context->FocusIn(); + else + d->context->FocusOut(); +} + + +void QIBusPlatformInputContext::commitText(const QDBusVariant &text) +{ + QObject *input = qApp->inputPanel()->inputItem(); + if (!input) + return; + + const QDBusArgument arg = text.variant().value(); + + QIBusText t; + if (debug) + qDebug() << arg.currentSignature(); + t.fromDBusArgument(arg); + if (debug) + qDebug() << "commit text:" << t.text; + + QInputMethodEvent event; + event.setCommitString(t.text); + QCoreApplication::sendEvent(input, &event); +} + +void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint cursorPos, bool visible) +{ + QObject *input = qApp->inputPanel()->inputItem(); + if (!input) + return; + + const QDBusArgument arg = text.variant().value(); + + QIBusText t; + t.fromDBusArgument(arg); + if (debug) + qDebug() << "preedit text:" << t.text; + + QList attributes = t.attributes.imAttributes(); + attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0, QVariant()); + + QInputMethodEvent event(t.text, attributes); + QCoreApplication::sendEvent(input, &event); +} + + +/* Kernel keycode -> X keycode table */ +static const unsigned int keycode_table[256] = { + 0, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 76, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 111, 221, 94, 95, 96, 211, 128, 127, 129, 208, 131, 126, + 108, 109, 112, 111, 113, 181, 97, 98, 99, 100, 102, 103, 104, 105, 106, 107, + 239, 160, 174, 176, 222, 157, 123, 110, 139, 134, 209, 210, 133, 115, 116, 117, + 232, 133, 134, 135, 140, 248, 191, 192, 122, 188, 245, 158, 161, 193, 223, 227, + 198, 199, 200, 147, 159, 151, 178, 201, 146, 203, 166, 236, 230, 235, 234, 233, + 163, 204, 253, 153, 162, 144, 164, 177, 152, 190, 208, 129, 130, 231, 209, 210, + 136, 220, 143, 246, 251, 137, 138, 182, 183, 184, 93, 184, 247, 132, 170, 219, + 249, 205, 207, 149, 150, 154, 155, 167, 168, 169, 171, 172, 173, 165, 175, 179, + 180, 0, 185, 186, 187, 118, 119, 120, 121, 229, 194, 195, 196, 197, 148, 202, + 101, 212, 237, 214, 215, 216, 217, 218, 228, 142, 213, 240, 241, 242, 243, 244, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +bool +QIBusPlatformInputContext::x11FilterEvent(uint keyval, uint keycode, uint state, bool press) +{ + if (!d->valid) + return false; + + if (!press) + return false; + + keycode -= 8; // ### + QDBusReply reply = d->context->ProcessKeyEvent(keyval, keycode, state); + +// qDebug() << "x11FilterEvent return" << reply.value(); + + return reply.value(); +} + +QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() + : connection(createConnection()), + bus(0), + context(0), + valid(false) +{ + if (!connection || !connection->isConnected()) { + qDebug("QIBusPlatformInputContext: not connected."); + return; + } + + bus = new QIBusProxy(QLatin1String("org.freedesktop.IBus"), + QLatin1String("/org/freedesktop/IBus"), + *connection); + if (!bus->isValid()) { + qWarning("QIBusPlatformInputContext: invalid bus."); + return; + } + + QDBusReply ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); + if (!ic.isValid()) { + qWarning("QIBusPlatformInputContext: CreateInputContext failed."); + return; + } + + context = new QIBusInputContextProxy(QLatin1String("org.freedesktop.IBus"), ic.value().path(), *connection); + + if (!context->isValid()) { + qWarning("QIBusPlatformInputContext: invalid input context."); + return; + } + + enum Capabilities { + IBUS_CAP_PREEDIT_TEXT = 1 << 0, + IBUS_CAP_AUXILIARY_TEXT = 1 << 1, + IBUS_CAP_LOOKUP_TABLE = 1 << 2, + IBUS_CAP_FOCUS = 1 << 3, + IBUS_CAP_PROPERTY = 1 << 4, + IBUS_CAP_SURROUNDING_TEXT = 1 << 5 + }; + context->SetCapabilities(IBUS_CAP_PREEDIT_TEXT|IBUS_CAP_FOCUS); + + if (debug) + qDebug(">>>> valid!"); + valid = true; +} + +QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() +{ + QByteArray display(getenv("DISPLAY")); + QByteArray host = "unix"; + QByteArray displayNumber = "0"; + + int pos = display.indexOf(':'); + if (pos > 0) + host = display.left(pos); + ++pos; + int pos2 = display.indexOf('.', pos); + if (pos2 > 0) + displayNumber = display.mid(pos, pos2 - pos); + if (debug) + qDebug() << "host=" << host << "displayNumber" << displayNumber; + + QFile file(QDir::homePath() + QLatin1String("/.config/ibus/bus/") + + QLatin1String(QDBusConnection::localMachineId()) + + QLatin1Char('-') + QString::fromLocal8Bit(host) + QLatin1Char('-') + QString::fromLocal8Bit(displayNumber)); + + if (!file.exists()) { + qWarning("QIBusPlatformInputContext: ibus config file '%s' does not exist.", qPrintable(file.fileName())); + return 0; + } + + file.open(QFile::ReadOnly); + + QByteArray address; + int pid = -1; + + while (!file.atEnd()) { + QByteArray line = file.readLine().trimmed(); + if (line.startsWith('#')) + continue; + + if (line.startsWith("IBUS_ADDRESS=")) + address = line.mid(sizeof("IBUS_ADDRESS=") - 1); + if (line.startsWith("IBUS_DAEMON_PID=")) + pid = line.mid(sizeof("IBUS_DAEMON_PID=") - 1).toInt(); + } + + if (debug) + qDebug() << "IBUS_ADDRESS=" << address << "PID=" << pid; + if (address.isEmpty() || pid < 0 || kill(pid, 0) != 0) + return 0; + + return new QDBusConnection(QDBusConnection::connectToBus(QString::fromLatin1(address), QLatin1String("QIBusProxy"))); +} diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h new file mode 100644 index 0000000000..322eca4b89 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QIBUSPLATFORMINPUTCONTEXT_H +#define QIBUSPLATFORMINPUTCONTEXT_H + +#include + +class QIBusPlatformInputContextPrivate; +class QDBusVariant; + +class QIBusPlatformInputContext : public QPlatformInputContext +{ + Q_OBJECT +public: + QIBusPlatformInputContext(); + ~QIBusPlatformInputContext(); + + bool isValid() const; + + void invokeAction(QInputPanel::Action a, int x); + void reset(void); + void update(Qt::InputMethodQueries); + + bool x11FilterEvent(uint keyval, uint keycode, uint state, bool press); + +public Q_SLOTS: + void commitText(const QDBusVariant &text); + void updatePreeditText(const QDBusVariant &text, uint cursor_pos, bool visible); + void inputItemChanged(); + void cursorRectChanged(); + +private: + QIBusPlatformInputContextPrivate *d; +}; + +#endif diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp new file mode 100644 index 0000000000..9d64b603f3 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "qibusproxy.h" + +/* + * Implementation of interface class QIBusProxy + */ + +QIBusProxy::QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +QIBusProxy::~QIBusProxy() +{ +} + diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.h b/src/plugins/platforminputcontexts/ibus/qibusproxy.h new file mode 100644 index 0000000000..389eec3175 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.h @@ -0,0 +1,88 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -N -p qibusproxy -c QIBusProxy interfaces/org.freedesktop.IBus.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef QIBUSPROXY_H_1308831142 +#define QIBUSPROXY_H_1308831142 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.freedesktop.IBus + */ +class QIBusProxy: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.IBus"; } + +public: + QIBusProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~QIBusProxy(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply CreateInputContext(const QString &name) + { + QList argumentList; + argumentList << QVariant::fromValue(name); + return asyncCallWithArgumentList(QLatin1String("CreateInputContext"), argumentList); + } + + inline QDBusPendingReply<> Exit(bool restart) + { + QList argumentList; + argumentList << QVariant::fromValue(restart); + return asyncCallWithArgumentList(QLatin1String("Exit"), argumentList); + } + + inline QDBusPendingReply GetAddress() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetAddress"), argumentList); + } + + inline QDBusPendingReply ListActiveEngines() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("ListActiveEngines"), argumentList); + } + + inline QDBusPendingReply ListEngines() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("ListEngines"), argumentList); + } + + inline QDBusPendingReply Ping(const QDBusVariant &data) + { + QList argumentList; + argumentList << QVariant::fromValue(data); + return asyncCallWithArgumentList(QLatin1String("Ping"), argumentList); + } + + inline QDBusPendingReply<> RegisterComponent(const QDBusVariant &components) + { + QList argumentList; + argumentList << QVariant::fromValue(components); + return asyncCallWithArgumentList(QLatin1String("RegisterComponent"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp new file mode 100644 index 0000000000..8d8c61afb7 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qibustypes.h" +#include +#include + +QIBusSerializable::QIBusSerializable() +{ +} + +QIBusSerializable::~QIBusSerializable() +{ +} + +void QIBusSerializable::fromDBusArgument(const QDBusArgument &arg) +{ + arg >> name; + arg.beginMap(); + while (!arg.atEnd()) { + arg.beginMapEntry(); + QString key; + QDBusVariant value; + arg >> key; + arg >> value; + arg.endMapEntry(); + attachments[key] = value.variant().value(); + } + arg.endMap(); +} + + + +QIBusAttribute::QIBusAttribute() + : type(Invalid), + value(0), + start(0), + end(0) +{ +} + +QIBusAttribute::~QIBusAttribute() +{ + +} + +void QIBusAttribute::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusAttribute::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + quint32 t; + arg >> t; + type = (Type)t; + arg >> value; + arg >> start; + arg >> end; + + arg.endStructure(); +} + +QTextFormat QIBusAttribute::format() const +{ + QTextCharFormat fmt; + switch (type) { + case Invalid: + break; + case Underline: { + QTextCharFormat::UnderlineStyle style = QTextCharFormat::NoUnderline; + + switch (value) { + case UnderlineNone: + break; + case UnderlineSingle: + style = QTextCharFormat::SingleUnderline; + break; + case UnderlineDouble: + style = QTextCharFormat::DashUnderline; + break; + case UnderlineLow: + style = QTextCharFormat::DashDotLine; + break; + case UnderlineError: + style = QTextCharFormat::WaveUnderline; + fmt.setUnderlineColor(Qt::red); + break; + } + + fmt.setUnderlineStyle(style); + break; + } + case Foreground: + fmt.setForeground(QColor(value)); + break; + case Background: + fmt.setBackground(QColor(value)); + break; + } + return fmt; +} + + +QIBusAttributeList::QIBusAttributeList() +{ + +} + +QIBusAttributeList::~QIBusAttributeList() +{ + +} + +void QIBusAttributeList::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusAttributeList::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + arg.beginArray(); + while(!arg.atEnd()) { + QDBusVariant var; + arg >> var; + + QIBusAttribute attr; + attr.fromDBusArgument(var.variant().value()); + attributes.append(attr); + } + arg.endArray(); + + arg.endStructure(); +} + +QList QIBusAttributeList::imAttributes() const +{ + QList imAttrs; + for (int i = 0; i < attributes.size(); ++i) { + const QIBusAttribute &attr = attributes.at(i); + imAttrs += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, attr.start, attr.end - attr.start, attr.format()); + } + return imAttrs; +} + + +QIBusText::QIBusText() +{ + +} + +QIBusText::~QIBusText() +{ + +} + +void QIBusText::fromDBusArgument(const QDBusArgument &arg) +{ +// qDebug() << "QIBusText::fromDBusArgument()" << arg.currentSignature(); + arg.beginStructure(); + + QIBusSerializable::fromDBusArgument(arg); + + arg >> text; + QDBusVariant variant; + arg >> variant; + attributes.fromDBusArgument(variant.variant().value()); + + arg.endStructure(); +} + diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.h b/src/plugins/platforminputcontexts/ibus/qibustypes.h new file mode 100644 index 0000000000..c426ff7eda --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.h @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QIBUSTYPES_H +#define QIBUSTYPES_H + +#include +#include + +class QDBusArgument; + +class QIBusSerializable +{ +public: + QIBusSerializable(); + virtual ~QIBusSerializable(); + + virtual void fromDBusArgument(const QDBusArgument &arg); + + QString name; + QHash attachments; +}; + +class QIBusAttribute : public QIBusSerializable +{ +public: + enum Type { + Invalid = 0, + Underline = 1, + Foreground = 2, + Background = 3, + }; + + enum Underline { + UnderlineNone = 0, + UnderlineSingle = 1, + UnderlineDouble = 2, + UnderlineLow = 3, + UnderlineError = 4, + }; + + QIBusAttribute(); + ~QIBusAttribute(); + + void fromDBusArgument(const QDBusArgument &arg); + QTextFormat format() const; + + Type type; + quint32 value; + quint32 start; + quint32 end; +}; + +class QIBusAttributeList : public QIBusSerializable +{ +public: + QIBusAttributeList(); + ~QIBusAttributeList(); + + void fromDBusArgument(const QDBusArgument &arg); + + QList imAttributes() const; + + QVector attributes; +}; + +class QIBusText : public QIBusSerializable +{ +public: + QIBusText(); + ~QIBusText(); + + void fromDBusArgument(const QDBusArgument &arg); + + QString text; + QIBusAttributeList attributes; +}; + +#endif diff --git a/src/plugins/platforminputcontexts/platforminputcontexts.pro b/src/plugins/platforminputcontexts/platforminputcontexts.pro new file mode 100644 index 0000000000..198060a96b --- /dev/null +++ b/src/plugins/platforminputcontexts/platforminputcontexts.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS += ibus + diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 3d181dcf0c..316d28ea3f 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -63,7 +63,8 @@ #endif #if defined(XCB_USE_IBUS) -#include "QtPlatformSupport/qibusplatforminputcontext.h" +#include +#include #endif #if defined(XCB_USE_GLX) @@ -102,12 +103,15 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters) m_inputContext = 0; #if defined(XCB_USE_IBUS) - QIBusPlatformInputContext *context = new QIBusPlatformInputContext; - if (context->isValid()) { - m_inputContext = context; - } else { - delete context; + QPlatformInputContext *platformInputContext = QPlatformInputContextFactory::create("ibus"); + if (platformInputContext) { + QVariant value; + QMetaObject::invokeMethod(platformInputContext, "isValid", Qt::DirectConnection, Q_RETURN_ARG(QVariant, value)); + if (value.toBool()) + m_inputContext = platformInputContext; } + if (platformInputContext && !m_inputContext) + delete platformInputContext; #endif } diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 6f37c078a1..18080dbb0c 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -50,7 +50,7 @@ #include #if defined(XCB_USE_IBUS) -#include "QtPlatformSupport/qibusplatforminputcontext.h" +#include #endif #ifndef XK_ISO_Left_Tab @@ -1029,9 +1029,20 @@ void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycod QByteArray chars; xcb_keysym_t sym = lookupString(window, state, code, type, &chars); - QIBusPlatformInputContext *ic = static_cast(QGuiApplicationPrivate::platformIntegration()->inputContext()); - if (ic && ic->x11FilterEvent(sym, code, state, type == QEvent::KeyPress)) - return; + +#if defined(XCB_USE_IBUS) + if (QObject* inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext()) { + QVariant value; + QMetaObject::invokeMethod(inputContext, "x11FilterEvent", Qt::DirectConnection, + Q_RETURN_ARG(QVariant, value), + Q_ARG(uint, sym), + Q_ARG(uint, code), + Q_ARG(uint, state), + Q_ARG(bool, type == QEvent::KeyPress)); + if (value.toBool()) + return; + } +#endif Qt::KeyboardModifiers modifiers; int qtcode = 0; diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 0936cd2102..5203daccdf 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -9,4 +9,7 @@ unix:!symbian { !contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats !symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible symbian:SUBDIRS += s60 -qpa:SUBDIRS += platforms +qpa: { + SUBDIRS += platforms + SUBDIRS += platforminputcontexts +} -- cgit v1.2.3