diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-06-14 13:58:33 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-06-14 13:58:33 +0800 |
| commit | c8d37e33e4f4598f434dd3d04fdfb990bda36a22 (patch) | |
| tree | a4b9e886ab6cee41e9ba631e7cdc137d4607ecf7 | |
| parent | a9123f28b410713b91a605f059a0c08a14315563 (diff) | |
| download | ibus-c8d37e33e4f4598f434dd3d04fdfb990bda36a22.tar.gz ibus-c8d37e33e4f4598f434dd3d04fdfb990bda36a22.tar.xz ibus-c8d37e33e4f4598f434dd3d04fdfb990bda36a22.zip | |
Add im-ibus-qt.cpp.
| -rw-r--r-- | qt/im-ibus-qt.cpp | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/qt/im-ibus-qt.cpp b/qt/im-ibus-qt.cpp new file mode 100644 index 0000000..e44e9e5 --- /dev/null +++ b/qt/im-ibus-qt.cpp @@ -0,0 +1,131 @@ +/* + * SCIM Bridge + * + * Copyright (c) 2006 Ryo Dairiki <ryo-dairiki@users.sourceforge.net> + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation and + * appearing in the file LICENSE.LGPL included in the package of this file. + * You can also redistribute it and/or modify it under the terms of + * the GNU General Public License as published by the Free Software Foundation and + * appearing in the file LICENSE.GPL included in the package of this file. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include <cassert> + +#ifdef QT4 +#include <Qt> +#include <QInputContextPlugin> + +using namespace Qt; +#else +#include <qinputcontextplugin.h> +#endif + +/* Static Variables */ +static IBusClientQt *client = NULL; + +/* The class Definition */ +class IBusInputContextPlugin: public QInputContextPlugin +{ + + private: + + /** + * The language list for SCIM. + */ + static QStringList ibus_languages; + + public: + + IBusInputContextPlugin (); + + ~IBusInputContextPlugin (); + + QStringList keys () const; + + QStringList languages (const QString &key); + + QString description (const QString &key); + + QInputContext *create (const QString &key); + + QString displayName (const QString &key); + +}; + + +/* Implementations */ +QStringList IBusInputContextPlugin::ibus_languages; + + +IBusInputContextPlugin::IBusInputContextPlugin () +{ +} + + +IBusInputContextPlugin::~IBusInputContextPlugin () +{ + delete client; + client = NULL; +} + +QStringList +IBusInputContextPlugin::keys () const +{ + QStringList identifiers; + identifiers.push_back (IBUS_IDENTIFIER_NAME); + return identifiers; +} + + +QStringList ScimBridgeInputContextPlugin::languages (const QString &key) +{ + if (ibus_languages.empty ()) { + ibus_languages.push_back ("zh_CN"); + ibus_languages.push_back ("zh_TW"); + ibus_languages.push_back ("zh_HK"); + ibus_languages.push_back ("ja"); + ibus_languages.push_back ("ko"); + } + return ibus_languages; +} + + +QString ScimBridgeInputContextPlugin::description (const QString &key) +{ + return QString::fromUtf8 ("Qt immodule plugin for IBus"); +} + + +QInputContext *ScimBridgeInputContextPlugin::create (const QString &key) +{ +#ifdef QT4 + if (key.toLower () != IBUS_IDENTIFIER_NAME) { +#else + if (key.lower () != IBUS_IDENTIFIER_NAME) { +#endif + return NULL; + } else { + if (client == NULL) client = new IBusClientQt (); + return IBusClientIMContext::alloc (); + } +} + + +QString IBusInputContextPlugin::displayName (const QString &key) +{ + return key; +} + +#ifdef QT4 +Q_EXPORT_PLUGIN2 (IBusInputContextPlugin, IBusInputContextPlugin) +#else +Q_EXPORT_PLUGIN (IBusInputContextPlugin) +#endif |
