~joel-auterson/ubuntu/maverick/ibus/newmenuname

« back to all changes in this revision

Viewing changes to client/qt4/im-ibus-qt.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing
  • Date: 2009-10-05 20:45:18 UTC
  • mfrom: (1.1.5 upstream) (6.1.15 sid)
  • Revision ID: james.westby@ubuntu.com-20091005204518-069vlwrl3r8v7bbr
Tags: 1.2.0.20090927-2
* create po template when build (LP: #188690)
  - debian/rules: updated.
  - debian/clean: remove pot file when clean.
* debian/control: build depends on python-rsvg (LP: #432375)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* vim:set noet ts=4: */
2
 
/*
3
 
 * ibus - The Input Bus
4
 
 *
5
 
 * Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
6
 
 *
7
 
 * This library is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU Lesser General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2 of the License, or (at your option) any later version.
11
 
 *
12
 
 * This library is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU Lesser General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with this program; if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
 
 * Boston, MA  02111-1307  USA
21
 
 */
22
 
#include <cassert>
23
 
#include <Qt>
24
 
#include <QInputContextPlugin>
25
 
#include "ibus-client.h"
26
 
 
27
 
using namespace Qt;
28
 
 
29
 
#define IBUS_IDENTIFIER_NAME "ibus"
30
 
 
31
 
static IBusClient *client;
32
 
 
33
 
/* The class Definition */
34
 
class IBusInputContextPlugin: public QInputContextPlugin
35
 
{
36
 
 
37
 
private:
38
 
        /**
39
 
         * The language list for SCIM.
40
 
         */
41
 
        static QStringList ibus_languages;
42
 
 
43
 
public:
44
 
 
45
 
        IBusInputContextPlugin (QObject *parent = 0);
46
 
 
47
 
        ~IBusInputContextPlugin ();
48
 
 
49
 
        QStringList keys () const;
50
 
 
51
 
        QStringList languages (const QString &key);
52
 
 
53
 
        QString description (const QString &key);
54
 
        
55
 
        QInputContext *create (const QString &key);
56
 
 
57
 
        QString displayName (const QString &key);
58
 
 
59
 
};
60
 
 
61
 
 
62
 
/* Implementations */
63
 
QStringList IBusInputContextPlugin::ibus_languages;
64
 
 
65
 
 
66
 
IBusInputContextPlugin::IBusInputContextPlugin (QObject *parent)
67
 
        :QInputContextPlugin (parent)
68
 
{
69
 
}
70
 
 
71
 
 
72
 
IBusInputContextPlugin::~IBusInputContextPlugin ()
73
 
{
74
 
        if (client != NULL) {
75
 
                delete client;
76
 
                client = NULL;
77
 
        }
78
 
}
79
 
 
80
 
QStringList 
81
 
IBusInputContextPlugin::keys () const 
82
 
{
83
 
        QStringList identifiers;
84
 
        identifiers.push_back (IBUS_IDENTIFIER_NAME);
85
 
        return identifiers;
86
 
}
87
 
 
88
 
 
89
 
QStringList
90
 
IBusInputContextPlugin::languages (const QString & key)
91
 
{
92
 
        if (key.toLower () != IBUS_IDENTIFIER_NAME) {
93
 
                return QStringList ();
94
 
        }
95
 
 
96
 
        if (ibus_languages.empty ()) {
97
 
                ibus_languages.push_back ("zh_CN");
98
 
                ibus_languages.push_back ("zh_TW");
99
 
                ibus_languages.push_back ("zh_HK");
100
 
                ibus_languages.push_back ("ja");
101
 
                ibus_languages.push_back ("ko");
102
 
        }
103
 
        return ibus_languages;
104
 
}
105
 
 
106
 
 
107
 
QString
108
 
IBusInputContextPlugin::description (const QString &key)
109
 
{
110
 
        if (key.toLower () != IBUS_IDENTIFIER_NAME) {
111
 
                return QString ("");
112
 
        }
113
 
 
114
 
        return QString::fromUtf8 ("Qt immodule plugin for IBus");
115
 
}
116
 
 
117
 
 
118
 
QInputContext *
119
 
IBusInputContextPlugin::create (const QString &key)
120
 
{
121
 
        if (key.toLower () != IBUS_IDENTIFIER_NAME) {
122
 
                return NULL;
123
 
        } else {
124
 
                if (client == NULL) {
125
 
                        client = new IBusClient ();
126
 
                }
127
 
                return client->createInputContext ();
128
 
        }
129
 
}
130
 
 
131
 
 
132
 
QString IBusInputContextPlugin::displayName (const QString &key)
133
 
{
134
 
        return key;
135
 
}
136
 
 
137
 
Q_EXPORT_PLUGIN2 (IBusInputContextPlugin, IBusInputContextPlugin)