Codebase list fcitx-qt5 / af1bc62
Imported Upstream version 1.0.5 Aron Xu 8 years ago
12 changed file(s) with 203 addition(s) and 185 deletion(s). Raw diff Collapse all Expand all
1515 include(ECMSetupVersion)
1616 include(ECMGenerateHeaders)
1717
18 include(CheckCXXCompilerFlag)
19
20 check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)
21
22 if(NOT SUPPORT_CXX11)
23 message(FATAL_ERROR "need c++ 11 compatible compiler to compile")
24 endif()
25
26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
27
1828 find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core DBus Widgets)
1929 find_package(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED Private)
2030 find_package(XKBCommon 0.5.0 REQUIRED COMPONENTS XKBCommon)
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * This file may have been hand-edited. Look for HAND-EDIT comments
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * Do not edit! All changes made to it will be lost.
88 */
99
10 #ifndef FCITXQTINPUTCONTEXTPROXY_H_1409252990
11 #define FCITXQTINPUTCONTEXTPROXY_H_1409252990
10 #ifndef FCITXQTINPUTCONTEXTPROXY_H
11 #define FCITXQTINPUTCONTEXTPROXY_H
1212
1313 #include <QtCore/QObject>
1414 #include <QtCore/QByteArray>
4040 inline QDBusPendingReply<> CloseIC()
4141 {
4242 QList<QVariant> argumentList;
43 return asyncCallWithArgumentList(QLatin1String("CloseIC"), argumentList);
43 return asyncCallWithArgumentList(QStringLiteral("CloseIC"), argumentList);
4444 }
4545
4646 inline QDBusPendingReply<> DestroyIC()
4747 {
4848 QList<QVariant> argumentList;
49 return asyncCallWithArgumentList(QLatin1String("DestroyIC"), argumentList);
49 return asyncCallWithArgumentList(QStringLiteral("DestroyIC"), argumentList);
5050 }
5151
5252 inline QDBusPendingReply<> EnableIC()
5353 {
5454 QList<QVariant> argumentList;
55 return asyncCallWithArgumentList(QLatin1String("EnableIC"), argumentList);
55 return asyncCallWithArgumentList(QStringLiteral("EnableIC"), argumentList);
5656 }
5757
5858 inline QDBusPendingReply<> FocusIn()
5959 {
6060 QList<QVariant> argumentList;
61 return asyncCallWithArgumentList(QLatin1String("FocusIn"), argumentList);
61 return asyncCallWithArgumentList(QStringLiteral("FocusIn"), argumentList);
6262 }
6363
6464 inline QDBusPendingReply<> FocusOut()
6565 {
6666 QList<QVariant> argumentList;
67 return asyncCallWithArgumentList(QLatin1String("FocusOut"), argumentList);
67 return asyncCallWithArgumentList(QStringLiteral("FocusOut"), argumentList);
6868 }
6969
7070 inline QDBusPendingReply<> MouseEvent(int x)
7171 {
7272 QList<QVariant> argumentList;
7373 argumentList << QVariant::fromValue(x);
74 return asyncCallWithArgumentList(QLatin1String("MouseEvent"), argumentList);
74 return asyncCallWithArgumentList(QStringLiteral("MouseEvent"), argumentList);
7575 }
7676
7777 inline QDBusPendingReply<int> ProcessKeyEvent(uint keyval, uint keycode, uint state, int type, uint time)
7878 {
7979 QList<QVariant> argumentList;
8080 argumentList << QVariant::fromValue(keyval) << QVariant::fromValue(keycode) << QVariant::fromValue(state) << QVariant::fromValue(type) << QVariant::fromValue(time);
81 return asyncCallWithArgumentList(QLatin1String("ProcessKeyEvent"), argumentList);
81 return asyncCallWithArgumentList(QStringLiteral("ProcessKeyEvent"), argumentList);
8282 }
8383
8484 inline QDBusPendingReply<> Reset()
8585 {
8686 QList<QVariant> argumentList;
87 return asyncCallWithArgumentList(QLatin1String("Reset"), argumentList);
87 return asyncCallWithArgumentList(QStringLiteral("Reset"), argumentList);
8888 }
8989
9090 inline QDBusPendingReply<> SetCapacity(uint caps)
9191 {
9292 QList<QVariant> argumentList;
9393 argumentList << QVariant::fromValue(caps);
94 return asyncCallWithArgumentList(QLatin1String("SetCapacity"), argumentList);
94 return asyncCallWithArgumentList(QStringLiteral("SetCapacity"), argumentList);
9595 }
9696
9797 inline QDBusPendingReply<> SetCursorLocation(int x, int y)
9898 {
9999 QList<QVariant> argumentList;
100100 argumentList << QVariant::fromValue(x) << QVariant::fromValue(y);
101 return asyncCallWithArgumentList(QLatin1String("SetCursorLocation"), argumentList);
101 return asyncCallWithArgumentList(QStringLiteral("SetCursorLocation"), argumentList);
102102 }
103103
104104 inline QDBusPendingReply<> SetCursorRect(int x, int y, int w, int h)
105105 {
106106 QList<QVariant> argumentList;
107107 argumentList << QVariant::fromValue(x) << QVariant::fromValue(y) << QVariant::fromValue(w) << QVariant::fromValue(h);
108 return asyncCallWithArgumentList(QLatin1String("SetCursorRect"), argumentList);
108 return asyncCallWithArgumentList(QStringLiteral("SetCursorRect"), argumentList);
109109 }
110110
111111 inline QDBusPendingReply<> SetSurroundingText(const QString &text, uint cursor, uint anchor)
112112 {
113113 QList<QVariant> argumentList;
114114 argumentList << QVariant::fromValue(text) << QVariant::fromValue(cursor) << QVariant::fromValue(anchor);
115 return asyncCallWithArgumentList(QLatin1String("SetSurroundingText"), argumentList);
115 return asyncCallWithArgumentList(QStringLiteral("SetSurroundingText"), argumentList);
116116 }
117117
118118 inline QDBusPendingReply<> SetSurroundingTextPosition(uint cursor, uint anchor)
119119 {
120120 QList<QVariant> argumentList;
121121 argumentList << QVariant::fromValue(cursor) << QVariant::fromValue(anchor);
122 return asyncCallWithArgumentList(QLatin1String("SetSurroundingTextPosition"), argumentList);
122 return asyncCallWithArgumentList(QStringLiteral("SetSurroundingTextPosition"), argumentList);
123123 }
124124
125125 Q_SIGNALS: // SIGNALS
126126 void CloseIM();
127127 void CommitString(const QString &str);
128 void CurrentIM(const QString &name, const QString &uniqueName, const QString &langCode);
128129 void DeleteSurroundingText(int offset, uint nchar);
129130 void EnableIM();
130131 void ForwardKey(uint keyval, uint state, int type);
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * This file may have been hand-edited. Look for HAND-EDIT comments
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * Do not edit! All changes made to it will be lost.
88 */
99
10 #ifndef FCITXQTINPUTMETHODPROXY_H_1409252990
11 #define FCITXQTINPUTMETHODPROXY_H_1409252990
10 #ifndef FCITXQTINPUTMETHODPROXY_H
11 #define FCITXQTINPUTMETHODPROXY_H
1212
1313 #include <QtCore/QObject>
1414 #include <QtCore/QByteArray>
5252 inline QDBusPendingReply<> ActivateIM()
5353 {
5454 QList<QVariant> argumentList;
55 return asyncCallWithArgumentList(QLatin1String("ActivateIM"), argumentList);
55 return asyncCallWithArgumentList(QStringLiteral("ActivateIM"), argumentList);
5656 }
5757
5858 inline QDBusPendingReply<> Configure()
5959 {
6060 QList<QVariant> argumentList;
61 return asyncCallWithArgumentList(QLatin1String("Configure"), argumentList);
61 return asyncCallWithArgumentList(QStringLiteral("Configure"), argumentList);
6262 }
6363
6464 inline QDBusPendingReply<> ConfigureAddon(const QString &addon)
6565 {
6666 QList<QVariant> argumentList;
6767 argumentList << QVariant::fromValue(addon);
68 return asyncCallWithArgumentList(QLatin1String("ConfigureAddon"), argumentList);
68 return asyncCallWithArgumentList(QStringLiteral("ConfigureAddon"), argumentList);
6969 }
7070
7171 inline QDBusPendingReply<> ConfigureIM(const QString &im)
7272 {
7373 QList<QVariant> argumentList;
7474 argumentList << QVariant::fromValue(im);
75 return asyncCallWithArgumentList(QLatin1String("ConfigureIM"), argumentList);
75 return asyncCallWithArgumentList(QStringLiteral("ConfigureIM"), argumentList);
7676 }
7777
7878 inline QDBusPendingReply<int, uint, uint, uint, uint> CreateIC()
7979 {
8080 QList<QVariant> argumentList;
81 return asyncCallWithArgumentList(QLatin1String("CreateIC"), argumentList);
81 return asyncCallWithArgumentList(QStringLiteral("CreateIC"), argumentList);
8282 }
8383 inline QDBusReply<int> CreateIC(uint &keyval1, uint &state1, uint &keyval2, uint &state2)
8484 {
8585 QList<QVariant> argumentList;
86 QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateIC"), argumentList);
86 QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateIC"), argumentList);
8787 if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 5) {
8888 keyval1 = qdbus_cast<uint>(reply.arguments().at(1));
8989 state1 = qdbus_cast<uint>(reply.arguments().at(2));
9797 {
9898 QList<QVariant> argumentList;
9999 argumentList << QVariant::fromValue(appname);
100 return asyncCallWithArgumentList(QLatin1String("CreateICv2"), argumentList);
100 return asyncCallWithArgumentList(QStringLiteral("CreateICv2"), argumentList);
101101 }
102102 inline QDBusReply<int> CreateICv2(const QString &appname, bool &enable, uint &keyval1, uint &state1, uint &keyval2, uint &state2)
103103 {
104104 QList<QVariant> argumentList;
105105 argumentList << QVariant::fromValue(appname);
106 QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateICv2"), argumentList);
106 QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateICv2"), argumentList);
107107 if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 6) {
108108 enable = qdbus_cast<bool>(reply.arguments().at(1));
109109 keyval1 = qdbus_cast<uint>(reply.arguments().at(2));
118118 {
119119 QList<QVariant> argumentList;
120120 argumentList << QVariant::fromValue(appname) << QVariant::fromValue(pid);
121 return asyncCallWithArgumentList(QLatin1String("CreateICv3"), argumentList);
121 return asyncCallWithArgumentList(QStringLiteral("CreateICv3"), argumentList);
122122 }
123123 inline QDBusReply<int> CreateICv3(const QString &appname, int pid, bool &enable, uint &keyval1, uint &state1, uint &keyval2, uint &state2)
124124 {
125125 QList<QVariant> argumentList;
126126 argumentList << QVariant::fromValue(appname) << QVariant::fromValue(pid);
127 QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateICv3"), argumentList);
127 QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("CreateICv3"), argumentList);
128128 if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 6) {
129129 enable = qdbus_cast<bool>(reply.arguments().at(1));
130130 keyval1 = qdbus_cast<uint>(reply.arguments().at(2));
138138 inline QDBusPendingReply<> Exit()
139139 {
140140 QList<QVariant> argumentList;
141 return asyncCallWithArgumentList(QLatin1String("Exit"), argumentList);
141 return asyncCallWithArgumentList(QStringLiteral("Exit"), argumentList);
142142 }
143143
144144 inline QDBusPendingReply<QString> GetCurrentIM()
145145 {
146146 QList<QVariant> argumentList;
147 return asyncCallWithArgumentList(QLatin1String("GetCurrentIM"), argumentList);
147 return asyncCallWithArgumentList(QStringLiteral("GetCurrentIM"), argumentList);
148148 }
149149
150150 inline QDBusPendingReply<int> GetCurrentState()
151151 {
152152 QList<QVariant> argumentList;
153 return asyncCallWithArgumentList(QLatin1String("GetCurrentState"), argumentList);
153 return asyncCallWithArgumentList(QStringLiteral("GetCurrentState"), argumentList);
154154 }
155155
156156 inline QDBusPendingReply<QString> GetCurrentUI()
157157 {
158158 QList<QVariant> argumentList;
159 return asyncCallWithArgumentList(QLatin1String("GetCurrentUI"), argumentList);
159 return asyncCallWithArgumentList(QStringLiteral("GetCurrentUI"), argumentList);
160160 }
161161
162162 inline QDBusPendingReply<QString> GetIMAddon(const QString &im)
163163 {
164164 QList<QVariant> argumentList;
165165 argumentList << QVariant::fromValue(im);
166 return asyncCallWithArgumentList(QLatin1String("GetIMAddon"), argumentList);
166 return asyncCallWithArgumentList(QStringLiteral("GetIMAddon"), argumentList);
167167 }
168168
169169 inline QDBusPendingReply<> InactivateIM()
170170 {
171171 QList<QVariant> argumentList;
172 return asyncCallWithArgumentList(QLatin1String("InactivateIM"), argumentList);
172 return asyncCallWithArgumentList(QStringLiteral("InactivateIM"), argumentList);
173173 }
174174
175175 inline QDBusPendingReply<> ReloadAddonConfig(const QString &addon)
176176 {
177177 QList<QVariant> argumentList;
178178 argumentList << QVariant::fromValue(addon);
179 return asyncCallWithArgumentList(QLatin1String("ReloadAddonConfig"), argumentList);
179 return asyncCallWithArgumentList(QStringLiteral("ReloadAddonConfig"), argumentList);
180180 }
181181
182182 inline QDBusPendingReply<> ReloadConfig()
183183 {
184184 QList<QVariant> argumentList;
185 return asyncCallWithArgumentList(QLatin1String("ReloadConfig"), argumentList);
185 return asyncCallWithArgumentList(QStringLiteral("ReloadConfig"), argumentList);
186186 }
187187
188188 inline QDBusPendingReply<> ResetIMList()
189189 {
190190 QList<QVariant> argumentList;
191 return asyncCallWithArgumentList(QLatin1String("ResetIMList"), argumentList);
191 return asyncCallWithArgumentList(QStringLiteral("ResetIMList"), argumentList);
192192 }
193193
194194 inline QDBusPendingReply<> Restart()
195195 {
196196 QList<QVariant> argumentList;
197 return asyncCallWithArgumentList(QLatin1String("Restart"), argumentList);
197 return asyncCallWithArgumentList(QStringLiteral("Restart"), argumentList);
198198 }
199199
200200 inline QDBusPendingReply<> SetCurrentIM(const QString &im)
201201 {
202202 QList<QVariant> argumentList;
203203 argumentList << QVariant::fromValue(im);
204 return asyncCallWithArgumentList(QLatin1String("SetCurrentIM"), argumentList);
204 return asyncCallWithArgumentList(QStringLiteral("SetCurrentIM"), argumentList);
205205 }
206206
207207 inline QDBusPendingReply<> ToggleIM()
208208 {
209209 QList<QVariant> argumentList;
210 return asyncCallWithArgumentList(QLatin1String("ToggleIM"), argumentList);
210 return asyncCallWithArgumentList(QStringLiteral("ToggleIM"), argumentList);
211211 }
212212
213213 Q_SIGNALS: // SIGNALS
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * This file may have been hand-edited. Look for HAND-EDIT comments
00 /*
11 * This file was generated by qdbusxml2cpp version 0.8
2 * Command line was: qdbusxml2cpp -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqt_export.h
2 * Command line was: qdbusxml2cpp -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqtdbusaddons_export.h
33 *
4 * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 * qdbusxml2cpp is Copyright (C) 2015 The Qt Company Ltd.
55 *
66 * This is an auto-generated file.
77 * Do not edit! All changes made to it will be lost.
88 */
99
10 #ifndef FCITXQTKEYBOARDPROXY_H_1409252990
11 #define FCITXQTKEYBOARDPROXY_H_1409252990
10 #ifndef FCITXQTKEYBOARDPROXY_H
11 #define FCITXQTKEYBOARDPROXY_H
1212
1313 #include <QtCore/QObject>
1414 #include <QtCore/QByteArray>
4141 {
4242 QList<QVariant> argumentList;
4343 argumentList << QVariant::fromValue(im);
44 return asyncCallWithArgumentList(QLatin1String("GetLayoutForIM"), argumentList);
44 return asyncCallWithArgumentList(QStringLiteral("GetLayoutForIM"), argumentList);
4545 }
4646 inline QDBusReply<QString> GetLayoutForIM(const QString &im, QString &variant)
4747 {
4848 QList<QVariant> argumentList;
4949 argumentList << QVariant::fromValue(im);
50 QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("GetLayoutForIM"), argumentList);
50 QDBusMessage reply = callWithArgumentList(QDBus::Block, QStringLiteral("GetLayoutForIM"), argumentList);
5151 if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 2) {
5252 variant = qdbus_cast<QString>(reply.arguments().at(1));
5353 }
5757 inline QDBusPendingReply<FcitxQtKeyboardLayoutList> GetLayouts()
5858 {
5959 QList<QVariant> argumentList;
60 return asyncCallWithArgumentList(QLatin1String("GetLayouts"), argumentList);
60 return asyncCallWithArgumentList(QStringLiteral("GetLayouts"), argumentList);
6161 }
6262
6363 inline QDBusPendingReply<> SetLayoutForIM(const QString &im, const QString &layout, const QString &variant)
6464 {
6565 QList<QVariant> argumentList;
6666 argumentList << QVariant::fromValue(im) << QVariant::fromValue(layout) << QVariant::fromValue(variant);
67 return asyncCallWithArgumentList(QLatin1String("SetLayoutForIM"), argumentList);
67 return asyncCallWithArgumentList(QStringLiteral("SetLayoutForIM"), argumentList);
6868 }
6969
7070 Q_SIGNALS: // SIGNALS
00 #!/bin/sh
11
2 qdbusxml2cpp-qt5 -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqt_export.h
3 qdbusxml2cpp-qt5 -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqt_export.h
4 qdbusxml2cpp-qt5 -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqt_export.h
2 qdbusxml2cpp-qt5 -N -p fcitxqtinputcontextproxy -c FcitxQtInputContextProxy interfaces/org.fcitx.Fcitx.InputContext.xml -i fcitxqtformattedpreedit.h -i fcitxqtdbusaddons_export.h
3 qdbusxml2cpp-qt5 -N -p fcitxqtinputmethodproxy -c FcitxQtInputMethodProxy interfaces/org.fcitx.Fcitx.InputMethod.xml -i fcitxqtinputmethoditem.h -i fcitxqtdbusaddons_export.h
4 qdbusxml2cpp-qt5 -N -p fcitxqtkeyboardproxy -c FcitxQtKeyboardProxy interfaces/org.fcitx.Fcitx.Keyboard.xml -i fcitxqtkeyboardlayout.h -i fcitxqtdbusaddons_export.h
5353 <signal name="CommitString">
5454 <arg name="str" type="s"/>
5555 </signal>
56 <signal name="CurrentIM">
57 <arg name="name" type="s"/>
58 <arg name="uniqueName" type="s"/>
59 <arg name="langCode" type="s"/>
60 </signal>
5661 <signal name="UpdateFormattedPreedit">
5762 <arg name="str" type="a(si)" />
5863 <arg name="cursorpos" type="i"/>
4848 {
4949 const char *value = getenv(name);
5050
51 if (value == NULL)
51 if (value == nullptr)
5252 return defval;
5353
5454 if (strcmp(value, "") == 0 ||
8787
8888 QFcitxPlatformInputContext::QFcitxPlatformInputContext() :
8989 m_connection(new FcitxQtConnection(this)),
90 m_improxy(0),
91 m_n_compose(0),
90 m_improxy(nullptr),
9291 m_cursorPos(0),
9392 m_useSurroundingText(false),
94 m_syncMode(true),
93 m_syncMode(get_boolean_env("FCITX_QT_USE_SYNC", false)),
9594 m_lastWId(0),
9695 m_destroy(false),
9796 m_xkbContext(_xkb_context_new_helper()),
10099 {
101100 FcitxQtFormattedPreedit::registerMetaType();
102101
103 memset(m_compose_buffer, 0, sizeof(uint) * (MAX_COMPOSE_LEN + 1));
104102 connect(m_connection, SIGNAL(connected()), this, SLOT(connected()));
105103 connect(m_connection, SIGNAL(disconnected()), this, SLOT(cleanUp()));
106104
121119 // qDebug() << "create Input Context" << m_connection->name();
122120 if (m_improxy) {
123121 delete m_improxy;
124 m_improxy = 0;
122 m_improxy = nullptr;
125123 }
126124 m_improxy = new FcitxQtInputMethodProxy(m_connection->serviceName(), QLatin1String("/inputmethod"), *m_connection->connection(), this);
127125
132130
133131 void QFcitxPlatformInputContext::cleanUp()
134132 {
135 for(QHash<WId, FcitxQtICData *>::const_iterator i = m_icMap.constBegin(),
136 e = m_icMap.constEnd(); i != e; ++i) {
137 FcitxQtICData* data = i.value();
138
139 if (data->proxy)
140 delete data->proxy;
141 }
142
143133 m_icMap.clear();
144134
145135 if (m_improxy) {
146136 delete m_improxy;
147 m_improxy = 0;
137 m_improxy = nullptr;
148138 }
149139
150140 if (!m_destroy) {
201191 if (!proxy)
202192 return;
203193
204 FcitxQtICData* data = m_icMap.value(window->winId());
205
206 QInputMethod *method = qApp->inputMethod();
194 auto &data = m_icMap[window->winId()];
195
207196 QObject *input = qApp->focusObject();
208197 if (!input)
209198 return;
244233 break;
245234 if (!((queries & Qt::ImSurroundingText) && (queries & Qt::ImCursorPosition)))
246235 break;
247 if (data->capacity.testFlag(CAPACITY_PASSWORD))
236 if (data.capacity.testFlag(CAPACITY_PASSWORD))
248237 break;
249238 QVariant var = query.value(Qt::ImSurroundingText);
250239 QVariant var1 = query.value(Qt::ImCursorPosition);
264253 anchor = var2.toInt();
265254 else
266255 anchor = cursor;
267 if (data->surroundingText != text) {
268 data->surroundingText = text;
256 if (data.surroundingText != text) {
257 data.surroundingText = text;
269258 proxy->SetSurroundingText(text, cursor, anchor);
270259 }
271260 else {
272 if (data->surroundingAnchor != anchor ||
273 data->surroundingCursor != cursor)
261 if (data.surroundingAnchor != anchor ||
262 data.surroundingCursor != cursor)
274263 proxy->SetSurroundingTextPosition(cursor, anchor);
275264 }
276 data->surroundingCursor = cursor;
277 data->surroundingAnchor = anchor;
265 data.surroundingCursor = cursor;
266 data.surroundingAnchor = anchor;
278267 setSurrounding = true;
279268 }
280269 }
281270 if (!setSurrounding) {
282 data->surroundingAnchor = -1;
283 data->surroundingCursor = -1;
284 data->surroundingText = QString::null;
271 data.surroundingAnchor = -1;
272 data.surroundingCursor = -1;
273 data.surroundingText = QString::null;
285274 removeCapacity(data, CAPACITY_SURROUNDING_TEXT);
286275 }
287276 } while(0);
310299 if (proxy)
311300 proxy->FocusIn();
312301 else {
313 FcitxQtICData* data = m_icMap.value(window->winId());
314 if (!data) {
315 createICData(window);
316 return;
317 }
302 createICData(window);
318303 }
319304 }
320305
321306 void QFcitxPlatformInputContext::windowDestroyed(QObject* object)
322307 {
323308 /* access QWindow is not possible here, so we use our own map to do so */
324 WId wid = m_windowToWidMap.take(object);
325 if (!wid)
326 return;
327 FcitxQtICData* data = m_icMap.take(wid);
328 if (!data)
329 return;
330
331 delete data;
309 auto iter = m_windowToWidMap.find(object);
310 if (iter == m_windowToWidMap.end())
311 return;
312 auto wid = iter->second;
313 m_windowToWidMap.erase(iter);
314 m_icMap.erase(wid);
332315 // qDebug() << "Window Destroyed and we destroy IC correctly, horray!";
333316 }
334317
341324 if (!proxy)
342325 return;
343326
344 FcitxQtICData* data = m_icMap.value(inputWindow->winId());
327 auto& data = m_icMap[inputWindow->winId()];
345328
346329 QRect r = qApp->inputMethod()->cursorRectangle().toRect();
347330 if(!r.isValid())
350333 r.moveTopLeft(inputWindow->mapToGlobal(r.topLeft()));
351334
352335 qreal scale = inputWindow->devicePixelRatio();
353 if (data->rect != r) {
354 data->rect = r;
336 if (data.rect != r) {
337 data.rect = r;
355338 proxy->SetCursorRect(r.x() * scale, r.y() * scale,
356339 r.width() * scale, r.height() * scale);
357340 }
364347
365348 // qDebug() << "create Input Context" << m_connection->connection()->name();
366349
367 if (m_improxy) {
368 delete m_improxy;
369 m_improxy = NULL;
370 }
371 m_improxy = new FcitxQtInputMethodProxy(m_connection->serviceName(), QLatin1String("/inputmethod"), *m_connection->connection(), this);
350 if (!m_improxy) {
351 m_improxy = new FcitxQtInputMethodProxy(m_connection->serviceName(), QLatin1String("/inputmethod"), *m_connection->connection(), this);
352 }
372353
373354 if (!m_improxy->isValid())
374355 return;
383364 void QFcitxPlatformInputContext::createInputContextFinished(QDBusPendingCallWatcher* watcher)
384365 {
385366 WId w = watcher->property("wid").toULongLong();
386 FcitxQtICData* data = m_icMap.value(w);
387 if (!data)
388 return;
367 auto iter = m_icMap.find(w);
368 if (iter == m_icMap.end()) {
369 return;
370 }
371
372 auto &data = iter->second;
389373
390374 QDBusPendingReply< int, bool, uint, uint, uint, uint > result = *watcher;
391375
399383
400384 int id = qdbus_cast<int>(result.argumentAt(0));
401385 QString path = QString("/inputcontext_%1").arg(id);
402 if (data->proxy) {
403 delete data->proxy;
404 }
405 data->proxy = new FcitxQtInputContextProxy(m_connection->serviceName(), path, *m_connection->connection(), this);
406 connect(data->proxy, SIGNAL(CommitString(QString)), this, SLOT(commitString(QString)));
407 connect(data->proxy, SIGNAL(ForwardKey(uint, uint, int)), this, SLOT(forwardKey(uint, uint, int)));
408 connect(data->proxy, SIGNAL(UpdateFormattedPreedit(FcitxQtFormattedPreeditList,int)), this, SLOT(updateFormattedPreedit(FcitxQtFormattedPreeditList,int)));
409 connect(data->proxy, SIGNAL(DeleteSurroundingText(int,uint)), this, SLOT(deleteSurroundingText(int,uint)));
410
411 if (data->proxy->isValid()) {
386 if (data.proxy) {
387 delete data.proxy;
388 }
389 data.proxy = new FcitxQtInputContextProxy(m_connection->serviceName(), path, *m_connection->connection(), this);
390 connect(data.proxy, SIGNAL(CommitString(QString)), this, SLOT(commitString(QString)));
391 connect(data.proxy, SIGNAL(ForwardKey(uint, uint, int)), this, SLOT(forwardKey(uint, uint, int)));
392 connect(data.proxy, SIGNAL(UpdateFormattedPreedit(FcitxQtFormattedPreeditList,int)), this, SLOT(updateFormattedPreedit(FcitxQtFormattedPreeditList,int)));
393 connect(data.proxy, SIGNAL(DeleteSurroundingText(int,uint)), this, SLOT(deleteSurroundingText(int,uint)));
394 connect(data.proxy, SIGNAL(CurrentIM(QString,QString,QString)), this, SLOT(updateCurrentIM(QString,QString,QString)));
395
396 if (data.proxy->isValid()) {
412397 QWindow* window = qApp->focusWindow();
413398 if (window && window->winId() == w)
414 data->proxy->FocusIn();
399 data.proxy->FocusIn();
415400 }
416401
417402 QFlags<FcitxCapacityFlags> flag;
418403 flag |= CAPACITY_PREEDIT;
419404 flag |= CAPACITY_FORMATTED_PREEDIT;
420405 flag |= CAPACITY_CLIENT_UNFOCUS_COMMIT;
406 flag |= CAPACITY_GET_IM_INFO_ON_FOCUS;
421407 m_useSurroundingText = get_boolean_env("FCITX_QT_ENABLE_SURROUNDING_TEXT", true);
422408 if (m_useSurroundingText)
423409 flag |= CAPACITY_SURROUNDING_TEXT;
424410
425 /*
426 * event loop will cause some problem, so we tries to use async way.
427 */
428 m_syncMode = get_boolean_env("FCITX_QT_USE_SYNC", false);
429
430411 addCapacity(data, flag, true);
431412 } while(0);
432413 delete watcher;
433414 }
434415
435 void QFcitxPlatformInputContext::updateCapacity(FcitxQtICData* data)
436 {
437 if (!data->proxy || !data->proxy->isValid())
438 return;
439
440 QDBusPendingReply< void > result = data->proxy->SetCapacity((uint) data->capacity);
416 void QFcitxPlatformInputContext::updateCapacity(const FcitxQtICData &data)
417 {
418 if (!data.proxy || !data.proxy->isValid())
419 return;
420
421 QDBusPendingReply< void > result = data.proxy->SetCapacity((uint) data.capacity);
441422 }
442423
443424 void QFcitxPlatformInputContext::commitString(const QString& str)
512493 void QFcitxPlatformInputContext::forwardKey(uint keyval, uint state, int type)
513494 {
514495 QObject *input = qApp->focusObject();
515 if (input != NULL) {
496 if (input != nullptr) {
516497 key_filtered = true;
517498 QKeyEvent *keyevent = createKeyEvent(keyval, state, type);
518499 QCoreApplication::sendEvent(input, keyevent);
521502 }
522503 }
523504
505 void QFcitxPlatformInputContext::updateCurrentIM(const QString& name, const QString& uniqueName, const QString& langCode)
506 {
507 Q_UNUSED(name);
508 Q_UNUSED(uniqueName);
509 QLocale newLocale(langCode);
510 if (m_locale != newLocale) {
511 m_locale = newLocale;
512 emitLocaleChanged();
513 }
514 }
515
516 QLocale QFcitxPlatformInputContext::locale() const
517 {
518 return m_locale;
519 }
520
524521 void QFcitxPlatformInputContext::createICData(QWindow* w)
525522 {
526 FcitxQtICData* data = m_icMap.value(w->winId());
527 if (!data) {
528 data = new FcitxQtICData;
529 m_icMap[w->winId()] = data;
523 auto iter = m_icMap.find(w->winId());
524 if (iter == m_icMap.end()) {
525 m_icMap.emplace(std::piecewise_construct, std::forward_as_tuple(w->winId()), std::forward_as_tuple());
530526 m_windowToWidMap[w] = w->winId();
531527 connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*)));
532528 }
697693
698694 FcitxQtInputContextProxy* QFcitxPlatformInputContext::validIC()
699695 {
700 if (m_icMap.isEmpty()) {
696 if (m_icMap.empty()) {
701697 return 0;
702698 }
703699 QWindow* window = qApp->focusWindow();
706702
707703 FcitxQtInputContextProxy* QFcitxPlatformInputContext::validICByWId(WId wid)
708704 {
709 if (m_icMap.isEmpty()) {
710 return 0;
711 }
712 FcitxQtICData* icData = m_icMap.value(wid);
713 if (!icData)
714 return 0;
715 if (icData->proxy.isNull()) {
716 return 0;
717 } else if (icData->proxy->isValid()) {
718 return icData->proxy.data();
719 }
720 return 0;
705 if (m_icMap.empty()) {
706 return nullptr;
707 }
708 auto iter = m_icMap.find(wid);
709 if (iter == m_icMap.end())
710 return nullptr;
711 auto &data = iter->second;
712 if (data.proxy.isNull()) {
713 return nullptr;
714 } else if (data.proxy->isValid()) {
715 return data.proxy.data();
716 }
717 return nullptr;
721718 }
722719
723720 FcitxQtInputContextProxy* QFcitxPlatformInputContext::validICByWindow(QWindow* w)
726723 return 0;
727724 }
728725
729 if (m_icMap.isEmpty()) {
726 if (m_icMap.empty()) {
730727 return 0;
731728 }
732729 return validICByWId(w->winId());
2727 #include <QPointer>
2828 #include <QFileSystemWatcher>
2929 #include <QRect>
30 #include <unordered_map>
3031 #include <xkbcommon/xkbcommon-compose.h>
3132 #include "fcitxqtformattedpreedit.h"
3233 #include "fcitxqtinputcontextproxy.h"
33
34 #define MAX_COMPOSE_LEN 7
3534
3635 class FcitxQtConnection;
3736 class QFileSystemWatcher;
6463 CAPACITY_UPPERCASE_WORDS = (1 << 19),
6564 CAPACITY_UPPERCASE_SENTENCES = (1 << 20),
6665 CAPACITY_ALPHA = (1 << 21),
67 CAPACITY_NAME = (1 << 22)
66 CAPACITY_NAME = (1 << 22),
67 CAPACITY_GET_IM_INFO_ON_FOCUS = (1 << 23),
6868 } ;
6969
7070 /** message type and flags */
109109
110110 struct FcitxQtICData {
111111 FcitxQtICData() : capacity(0), proxy(0), surroundingAnchor(-1), surroundingCursor(-1) {}
112 FcitxQtICData(const FcitxQtICData& that) = delete;
112113 ~FcitxQtICData() {
113 if (proxy && proxy->isValid()) {
114 proxy->DestroyIC();
114 if (proxy) {
115 if (proxy->isValid()) {
116 proxy->DestroyIC();
117 }
115118 delete proxy;
116119 }
117120 }
186189 QFcitxPlatformInputContext();
187190 virtual ~QFcitxPlatformInputContext();
188191
189 virtual bool filterEvent(const QEvent* event);
190 virtual bool isValid() const;
191 virtual void invokeAction(QInputMethod::Action , int cursorPosition);
192 virtual void reset();
193 virtual void commit();
194 virtual void update(Qt::InputMethodQueries quries );
195 virtual void setFocusObject(QObject* object);
196
192 virtual bool filterEvent(const QEvent* event) Q_DECL_OVERRIDE;
193 virtual bool isValid() const Q_DECL_OVERRIDE;
194 virtual void invokeAction(QInputMethod::Action , int cursorPosition) Q_DECL_OVERRIDE;
195 virtual void reset() Q_DECL_OVERRIDE;
196 virtual void commit() Q_DECL_OVERRIDE;
197 virtual void update(Qt::InputMethodQueries quries ) Q_DECL_OVERRIDE;
198 virtual void setFocusObject(QObject* object) Q_DECL_OVERRIDE;
199 virtual QLocale locale() const Q_DECL_OVERRIDE;
197200
198201 public Q_SLOTS:
199202 void cursorRectChanged();
205208 void connected();
206209 void cleanUp();
207210 void windowDestroyed(QObject* object);
211 void updateCurrentIM(const QString &name, const QString &uniqueName, const QString &langCode);
208212
209213
210214 private:
211215 void createInputContext(WId w);
212216 bool processCompose(uint keyval, uint state, FcitxKeyEventType event);
213 bool checkAlgorithmically();
214 bool checkCompactTable(const struct _FcitxComposeTableCompact *table);
215217 QKeyEvent* createKeyEvent(uint keyval, uint state, int type);
216218
217
218 void addCapacity(FcitxQtICData* data, QFlags<FcitxCapacityFlags> capacity, bool forceUpdate = false)
219 {
220 QFlags< FcitxCapacityFlags > newcaps = data->capacity | capacity;
221 if (data->capacity != newcaps || forceUpdate) {
222 data->capacity = newcaps;
219 void addCapacity(FcitxQtICData &data, QFlags<FcitxCapacityFlags> capacity, bool forceUpdate = false)
220 {
221 QFlags< FcitxCapacityFlags > newcaps = data.capacity | capacity;
222 if (data.capacity != newcaps || forceUpdate) {
223 data.capacity = newcaps;
223224 updateCapacity(data);
224225 }
225226 }
226227
227 void removeCapacity(FcitxQtICData* data, QFlags<FcitxCapacityFlags> capacity, bool forceUpdate = false)
228 {
229 QFlags< FcitxCapacityFlags > newcaps = data->capacity & (~capacity);
230 if (data->capacity != newcaps || forceUpdate) {
231 data->capacity = newcaps;
228 void removeCapacity(FcitxQtICData &data, QFlags<FcitxCapacityFlags> capacity, bool forceUpdate = false)
229 {
230 QFlags< FcitxCapacityFlags > newcaps = data.capacity & (~capacity);
231 if (data.capacity != newcaps || forceUpdate) {
232 data.capacity = newcaps;
232233 updateCapacity(data);
233234 }
234235 }
235236
236 void updateCapacity(FcitxQtICData* data);
237 void updateCapacity(const FcitxQtICData &data);
237238 void commitPreedit();
238239 void createICData(QWindow* w);
239240 FcitxQtInputContextProxy* validIC();
241242 FcitxQtInputContextProxy* validICByWId(WId wid);
242243 bool filterEventFallback(uint keyval, uint keycode, uint state, bool press);
243244
245 FcitxQtConnection* m_connection;
244246 FcitxQtInputMethodProxy* m_improxy;
245 uint m_compose_buffer[MAX_COMPOSE_LEN + 1];
246 int m_n_compose;
247247 QString m_preedit;
248248 QString m_commitPreedit;
249249 FcitxQtFormattedPreeditList m_preeditList;
250250 int m_cursorPos;
251251 bool m_useSurroundingText;
252252 bool m_syncMode;
253 FcitxQtConnection* m_connection;
254253 QString m_lastSurroundingText;
255254 int m_lastSurroundingAnchor;
256255 int m_lastSurroundingCursor;
257 QHash<WId, FcitxQtICData*> m_icMap;
258 QHash<QObject*, WId> m_windowToWidMap;
256 std::unordered_map<WId, FcitxQtICData> m_icMap;
257 std::unordered_map<QObject*, WId> m_windowToWidMap;
259258 WId m_lastWId;
260259 bool m_destroy;
261260 QScopedPointer<struct xkb_context, XkbContextDeleter> m_xkbContext;
262261 QScopedPointer<struct xkb_compose_table, XkbComposeTableDeleter> m_xkbComposeTable;
263262 QScopedPointer<struct xkb_compose_state, XkbComposeStateDeleter> m_xkbComposeState;
263 QLocale m_locale;
264264 private slots:
265265 void processKeyEventFinished(QDBusPendingCallWatcher*);
266266 };
0 link_directories(
1 ${FCITX_UTILS_LIBRARY_DIRS}
2 ${FCITX_CONFIG_LIBRARY_DIRS}
3 )
4
05 ecm_setup_version(${FcitxQt5_VERSION} VARIABLE_PREFIX FCITXQT5WIDGETSADDONS
16 VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fcitxqtwidgetsaddons_version.h"
27 PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/FcitxQt5WidgetsAddonsConfigVersion.cmake"