~ubuntu-branches/ubuntu/trusty/fcitx/trusty-proposed

« back to all changes in this revision

Viewing changes to src/frontend/qt/qfcitxinputcontextplugin.cpp

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-02-10 17:03:56 UTC
  • mfrom: (1.3.18) (33.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130210170356-2yuv6xy3ed378kn0
Tags: 1:4.2.7-1
* New upstream release.
* New binary packages:
  - fcitx-libs-gclient: D-Bus client library for Glib
  - fcitx-libs-qt: D-Bus client library for Qt
  - fcitx-module-quickphrase-editor: Quick Phrase editor module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2011~2012 by CSSlayer                                   *
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 *   This program is distributed in the hope that it will be useful,       *
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
12
 *   GNU General Public License for more details.                          *
 
13
 *                                                                         *
 
14
 *   You should have received a copy of the GNU General Public License     *
 
15
 *   along with this program; if not, write to the                         *
 
16
 *   Free Software Foundation, Inc.,                                       *
 
17
 *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.              *
 
18
 ***************************************************************************/
 
19
 
 
20
#include <QInputContextPlugin>
 
21
#include <QDBusConnection>
 
22
#include "qfcitxinputcontext.h"
 
23
 
 
24
/* The class Definition */
 
25
class QFcitxInputContextPlugin: public QInputContextPlugin
 
26
{
 
27
 
 
28
private:
 
29
    /**
 
30
     * The language list for Fcitx.
 
31
     */
 
32
    static QStringList fcitx_languages;
 
33
 
 
34
public:
 
35
 
 
36
    QFcitxInputContextPlugin(QObject *parent = 0);
 
37
 
 
38
    ~QFcitxInputContextPlugin();
 
39
 
 
40
    QStringList keys() const;
 
41
 
 
42
    QStringList languages(const QString &key);
 
43
 
 
44
    QString description(const QString &key);
 
45
 
 
46
    QInputContext *create(const QString &key);
 
47
 
 
48
    QString displayName(const QString &key);
 
49
 
 
50
private:
 
51
};
 
52
 
 
53
 
 
54
/* Implementations */
 
55
QStringList QFcitxInputContextPlugin::fcitx_languages;
 
56
 
 
57
 
 
58
QFcitxInputContextPlugin::QFcitxInputContextPlugin(QObject *parent)
 
59
    : QInputContextPlugin(parent)
 
60
{
 
61
}
 
62
 
 
63
 
 
64
QFcitxInputContextPlugin::~QFcitxInputContextPlugin()
 
65
{
 
66
}
 
67
 
 
68
QStringList
 
69
QFcitxInputContextPlugin::keys() const
 
70
{
 
71
    QStringList identifiers;
 
72
    identifiers.push_back(FCITX_IDENTIFIER_NAME);
 
73
    return identifiers;
 
74
}
 
75
 
 
76
 
 
77
QStringList
 
78
QFcitxInputContextPlugin::languages(const QString & key)
 
79
{
 
80
    if (key.toLower() != FCITX_IDENTIFIER_NAME) {
 
81
        return QStringList();
 
82
    }
 
83
 
 
84
    if (fcitx_languages.empty()) {
 
85
        fcitx_languages.push_back("zh");
 
86
        fcitx_languages.push_back("ja");
 
87
        fcitx_languages.push_back("ko");
 
88
    }
 
89
    return fcitx_languages;
 
90
}
 
91
 
 
92
 
 
93
QString
 
94
QFcitxInputContextPlugin::description(const QString &key)
 
95
{
 
96
    if (key.toLower() != FCITX_IDENTIFIER_NAME) {
 
97
        return QString("");
 
98
    }
 
99
 
 
100
    return QString::fromUtf8("Qt immodule plugin for Fcitx");
 
101
}
 
102
 
 
103
 
 
104
QInputContext *
 
105
QFcitxInputContextPlugin::create(const QString &key)
 
106
{
 
107
    if (key.toLower() != FCITX_IDENTIFIER_NAME) {
 
108
        return NULL;
 
109
    }
 
110
 
 
111
    return static_cast<QInputContext *>(new QFcitxInputContext());
 
112
}
 
113
 
 
114
 
 
115
QString QFcitxInputContextPlugin::displayName(const QString &key)
 
116
{
 
117
    return key;
 
118
}
 
119
 
 
120
Q_EXPORT_PLUGIN2(QFcitxInputContextPlugin, QFcitxInputContextPlugin)
 
121
 
 
122
// kate: indent-mode cstyle; space-indent on; indent-width 0;