Merge lp:~thomas-moenicke/phablet-extras/maliit-plugins-pinyin into lp:phablet-extras/maliit-plugins

Proposed by Thomas Moenicke
Status: Merged
Merged at revision: 2132
Proposed branch: lp:~thomas-moenicke/phablet-extras/maliit-plugins-pinyin
Merge into: lp:phablet-extras/maliit-plugins
Diff against target: 1376 lines (+522/-189)
31 files modified
debian/control (+4/-1)
debian/rules (+1/-0)
maliit-keyboard/data/languages/de.xml (+3/-0)
maliit-keyboard/data/languages/en_gb.xml (+4/-1)
maliit-keyboard/data/languages/en_us.xml (+4/-1)
maliit-keyboard/data/languages/es.xml (+5/-2)
maliit-keyboard/data/languages/zh_cn_pinyin.xml (+18/-168)
maliit-keyboard/lib/lib.pro (+5/-0)
maliit-keyboard/lib/logic/chineselanguagefeatures.cpp (+42/-0)
maliit-keyboard/lib/logic/chineselanguagefeatures.h (+39/-0)
maliit-keyboard/lib/logic/dynamiclayout.cpp (+15/-1)
maliit-keyboard/lib/logic/dynamiclayout.h (+16/-0)
maliit-keyboard/lib/logic/eventhandler.cpp (+7/-0)
maliit-keyboard/lib/logic/eventhandler.h (+3/-0)
maliit-keyboard/lib/logic/layoutupdater.cpp (+1/-0)
maliit-keyboard/lib/logic/layoutupdater.h (+1/-0)
maliit-keyboard/lib/logic/logic.pri (+6/-2)
maliit-keyboard/lib/logic/pinyinadapter.cpp (+103/-0)
maliit-keyboard/lib/logic/pinyinadapter.h (+50/-0)
maliit-keyboard/lib/logic/wordengine.cpp (+67/-12)
maliit-keyboard/lib/logic/wordengine.h (+3/-0)
maliit-keyboard/plugin/editor.cpp (+2/-0)
maliit-keyboard/plugin/inputmethod.cpp (+18/-0)
maliit-keyboard/plugin/inputmethod.h (+2/-0)
maliit-keyboard/qml/Keyboard.qml (+13/-0)
maliit-keyboard/qml/LanguageMenu.qml (+53/-0)
maliit-keyboard/qml/qml.pro (+2/-1)
maliit-keyboard/view/abstracttexteditor.cpp (+20/-0)
maliit-keyboard/view/abstracttexteditor.h (+3/-0)
maliit-keyboard/word-prediction.pri (+7/-0)
maliit-plugins.pro (+5/-0)
To merge this branch: bzr merge lp:~thomas-moenicke/phablet-extras/maliit-plugins-pinyin
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Thomas Moenicke (community) Abstain
Bill Filler Pending
Review via email: mp+169238@code.launchpad.net

Commit message

adding Chinese - pinyin support

Description of the change

adding Chinese - pinyin support

To post a comment you must log in.
Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

work in progress

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2133. By Thomas Moenicke

switch wordengine backend according to language

2134. By Thomas Moenicke

typo

Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

the head of /etc/xdg/maliit.org/server.conf should look like this:

[maliit]
onscreen\active=libmaliit-keyboard-plugin.so:zh_cn_pinyin

pluginsettings\libmaliit-keyboard-plugin.so\current_style = ubuntu
pluginsettings\libmaliit-keyboard-plugin.so\word_engine_enabled = true

...

Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

these steps also should be done in order to set the phone to chinese:

1) sudo apt-get install fonts-droid
2) sudo locale-gen zh_CN.UTF-8
3) sudo vi /etc/default/local change LANG="en_US.UTF-8" to LANG="zh_CN.UTF-8"
4) sudo vi /etc/environment change LANG="zh_CN.UTF-8" and LANGUAGE="zh_CN"
5) reboot

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Thomas Moenicke (thomas-moenicke) wrote :

Logic::LanguageFeatures appends a space to every commit string, which is not correct for pinyin. Needs to be fixed

2135. By Thomas Moenicke

added chinese language features: no space after word suggestion, no upper/lowercase

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2136. By Thomas Moenicke

adding dependency to glib-2.0-dev

2137. By Thomas Moenicke

polished layout:
- removed uppercase, not needed for pinyin
- removed redundant return key
- fixed spacing

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2013-06-06 10:29:18 +0000
3+++ debian/control 2013-06-17 15:53:36 +0000
4@@ -14,7 +14,9 @@
5 maliit-framework-dev (>= 0.94.0-w03-springbok1phablet15),
6 libhunspell-dev,
7 libpresage-dev,
8- libubuntu-platform-api1-dev
9+ libubuntu-platform-api1-dev,
10+ libpinyin2-dev,
11+ libglib2.0-dev
12 Standards-Version: 3.9.3
13
14 Package: nemo-keyboard
15@@ -39,6 +41,7 @@
16 Architecture: armhf
17 Depends: maliit-framework,
18 libpresage1,
19+ libpinyin2,
20 ${misc:Depends},
21 ${shlibs:Depends},
22 qtdeclarative5-window-plugin
23
24=== modified file 'debian/rules'
25--- debian/rules 2013-06-07 08:43:47 +0000
26+++ debian/rules 2013-06-17 15:53:36 +0000
27@@ -16,6 +16,7 @@
28 CONFIG+=enable-presage \
29 CONFIG+=enable-hunspell \
30 CONFIG+=enable-preedit \
31+ CONFIG+=enable-pinyin \
32 CONFIG+=enable-qt-mobility \
33 CONFIG+=enable-maliit-keyboard \
34 CONFIG+=enable-nemo-keyboard
35
36=== modified file 'maliit-keyboard/data/languages/de.xml'
37--- maliit-keyboard/data/languages/de.xml 2013-04-26 13:05:20 +0000
38+++ maliit-keyboard/data/languages/de.xml 2013-06-17 15:53:36 +0000
39@@ -490,6 +490,9 @@
40 </key>
41 </row>
42 <row>
43+ <key id="actionKey" style="special" width="large">
44+ <binding action="layout_menu" label="de" />
45+ </key>
46 <key style="special" width="large">
47 <binding action="sym" label="?123" />
48 </key>
49
50=== modified file 'maliit-keyboard/data/languages/en_gb.xml'
51--- maliit-keyboard/data/languages/en_gb.xml 2013-04-26 13:05:20 +0000
52+++ maliit-keyboard/data/languages/en_gb.xml 2013-06-17 15:53:36 +0000
53@@ -463,7 +463,10 @@
54 </key>
55 </row>
56 <row>
57- <key style="special" width="x-large">
58+ <key id="actionKey" style="special" width="large">
59+ <binding action="layout_menu" label="en" />
60+ </key>
61+ <key style="special" width="large">
62 <binding action="sym" label="?123" />
63 </key>
64 <spacer />
65
66=== modified file 'maliit-keyboard/data/languages/en_us.xml'
67--- maliit-keyboard/data/languages/en_us.xml 2013-04-26 13:05:20 +0000
68+++ maliit-keyboard/data/languages/en_us.xml 2013-06-17 15:53:36 +0000
69@@ -460,7 +460,10 @@
70 </key>
71 </row>
72 <row>
73- <key style="special" width="x-large">
74+ <key id="actionKey" style="special" width="large">
75+ <binding action="layout_menu" label="en" />
76+ </key>
77+ <key style="special" width="large">
78 <binding action="sym" label="?123" />
79 </key>
80 <spacer />
81
82=== modified file 'maliit-keyboard/data/languages/es.xml'
83--- maliit-keyboard/data/languages/es.xml 2012-08-17 12:00:21 +0000
84+++ maliit-keyboard/data/languages/es.xml 2013-06-17 15:53:36 +0000
85@@ -466,7 +466,10 @@
86 </key>
87 </row>
88 <row>
89- <key style="special" width="x-large">
90+ <key id="actionKey" style="special" width="large">
91+ <binding action="layout_menu" label="es" />
92+ </key>
93+ <key style="special" width="large">
94 <binding action="sym" label="?123" />
95 </key>
96 <key style="special">
97@@ -475,7 +478,7 @@
98 <key id="emailUrlKey">
99 <binding label="," />
100 </key>
101- <key width="stretched">
102+ <key width="xx-large">
103 <binding action="space" label="" />
104 </key>
105 <key>
106
107=== modified file 'maliit-keyboard/data/languages/zh_cn_pinyin.xml'
108--- maliit-keyboard/data/languages/zh_cn_pinyin.xml 2012-08-17 12:00:21 +0000
109+++ maliit-keyboard/data/languages/zh_cn_pinyin.xml 2013-06-17 15:53:36 +0000
110@@ -7,72 +7,42 @@
111 <row>
112 <key>
113 <binding label="q">
114- <modifiers keys="shift">
115- <binding label="Q" />
116- </modifiers>
117 </binding>
118 </key>
119 <key>
120 <binding label="w">
121- <modifiers keys="shift">
122- <binding label="W" />
123- </modifiers>
124 </binding>
125 </key>
126 <key>
127 <binding label="e">
128- <modifiers keys="shift">
129- <binding label="E" />
130- </modifiers>
131 </binding>
132 </key>
133 <key>
134 <binding label="r">
135- <modifiers keys="shift">
136- <binding label="R" />
137- </modifiers>
138 </binding>
139 </key>
140 <key>
141 <binding label="t">
142- <modifiers keys="shift">
143- <binding label="T" />
144- </modifiers>
145 </binding>
146 </key>
147 <key>
148 <binding label="y">
149- <modifiers keys="shift">
150- <binding label="Y" />
151- </modifiers>
152 </binding>
153 </key>
154 <key>
155 <binding label="u">
156- <modifiers keys="shift">
157- <binding label="U" />
158- </modifiers>
159 </binding>
160 </key>
161 <key>
162 <binding label="i">
163- <modifiers keys="shift">
164- <binding label="I" />
165- </modifiers>
166 </binding>
167 </key>
168 <key>
169 <binding label="o">
170- <modifiers keys="shift">
171- <binding label="O" />
172- </modifiers>
173 </binding>
174 </key>
175 <key>
176 <binding label="p">
177- <modifiers keys="shift">
178- <binding label="P" />
179- </modifiers>
180 </binding>
181 </key>
182 </row>
183@@ -80,143 +50,100 @@
184 <spacer />
185 <key>
186 <binding label="a">
187- <modifiers keys="shift">
188- <binding label="A" />
189- </modifiers>
190 </binding>
191 </key>
192 <key>
193 <binding label="s">
194- <modifiers keys="shift">
195- <binding label="S" />
196- </modifiers>
197 </binding>
198 </key>
199 <key>
200 <binding label="d">
201- <modifiers keys="shift">
202- <binding label="D" />
203- </modifiers>
204 </binding>
205 </key>
206 <key>
207 <binding label="f">
208- <modifiers keys="shift">
209- <binding label="F" />
210- </modifiers>
211 </binding>
212 </key>
213 <key>
214 <binding label="g">
215- <modifiers keys="shift">
216- <binding label="G" />
217- </modifiers>
218 </binding>
219 </key>
220 <key>
221 <binding label="h">
222- <modifiers keys="shift">
223- <binding label="H" />
224- </modifiers>
225 </binding>
226 </key>
227 <key>
228 <binding label="j">
229- <modifiers keys="shift">
230- <binding label="J" />
231- </modifiers>
232 </binding>
233 </key>
234 <key>
235 <binding label="k">
236- <modifiers keys="shift">
237- <binding label="K" />
238- </modifiers>
239 </binding>
240 </key>
241 <key>
242 <binding label="l">
243- <modifiers keys="shift">
244- <binding label="L" />
245- </modifiers>
246 </binding>
247 </key>
248 <spacer />
249 </row>
250 <row>
251- <key style="special" width="large">
252+<!-- <key style="special" width="large">
253 <binding action="shift" label="" />
254- </key>
255+ </key>//-->
256+ <spacer />
257 <spacer />
258 <key>
259 <binding label="z">
260- <modifiers keys="shift">
261- <binding label="Z" />
262- </modifiers>
263 </binding>
264 </key>
265 <key>
266 <binding label="x">
267- <modifiers keys="shift">
268- <binding label="X" />
269- </modifiers>
270 </binding>
271 </key>
272 <key>
273 <binding label="c">
274- <modifiers keys="shift">
275- <binding label="C" />
276- </modifiers>
277 </binding>
278 </key>
279 <key>
280 <binding label="v">
281- <modifiers keys="shift">
282- <binding label="V" />
283- </modifiers>
284 </binding>
285 </key>
286 <key>
287 <binding label="b">
288- <modifiers keys="shift">
289- <binding label="B" />
290- </modifiers>
291 </binding>
292 </key>
293 <key>
294 <binding label="n">
295- <modifiers keys="shift">
296- <binding label="N" />
297- </modifiers>
298 </binding>
299 </key>
300 <key>
301 <binding label="m">
302- <modifiers keys="shift">
303- <binding label="M" />
304- </modifiers>
305 </binding>
306 </key>
307 <spacer />
308 <key style="special" width="large">
309 <binding action="backspace" label="" />
310 </key>
311+ <spacer />
312 </row>
313 <row>
314- <key style="special" width="x-large">
315+ <key id="actionKey" style="special" width="large">
316+ <binding action="layout_menu" label="cn" />
317+ </key>
318+ <key style="special" width="large">
319 <binding action="sym" label="符号" />
320 </key>
321- <key id="emailUrlKey">
322+ <key id="emailUrlKey" width="small">
323 <binding label="," />
324 </key>
325- <key width="stretched">
326+ <key width="xx-large">
327 <binding action="space" label="" />
328 </key>
329- <key id="emailUrlDotKey">
330+ <key id="emailUrlDotKey" width="small">
331 <binding label="。" />
332 </key>
333 <key id="actionKey" style="special" width="x-large">
334- <binding action="compose" label="输入" />
335+ <binding action="return" label="输入" />
336 </key>
337 </row>
338 </section>
339@@ -226,72 +153,42 @@
340 <row>
341 <key>
342 <binding label="q">
343- <modifiers keys="shift">
344- <binding label="Q" />
345- </modifiers>
346 </binding>
347 </key>
348 <key>
349 <binding label="w">
350- <modifiers keys="shift">
351- <binding label="W" />
352- </modifiers>
353 </binding>
354 </key>
355 <key>
356 <binding label="e">
357- <modifiers keys="shift">
358- <binding label="E" />
359- </modifiers>
360 </binding>
361 </key>
362 <key>
363 <binding label="r">
364- <modifiers keys="shift">
365- <binding label="R" />
366- </modifiers>
367 </binding>
368 </key>
369 <key>
370 <binding label="t">
371- <modifiers keys="shift">
372- <binding label="T" />
373- </modifiers>
374 </binding>
375 </key>
376 <key>
377 <binding label="y">
378- <modifiers keys="shift">
379- <binding label="Y" />
380- </modifiers>
381 </binding>
382 </key>
383 <key>
384 <binding label="u">
385- <modifiers keys="shift">
386- <binding label="U" />
387- </modifiers>
388 </binding>
389 </key>
390 <key>
391 <binding label="i">
392- <modifiers keys="shift">
393- <binding label="I" />
394- </modifiers>
395 </binding>
396 </key>
397 <key>
398 <binding label="o">
399- <modifiers keys="shift">
400- <binding label="O" />
401- </modifiers>
402 </binding>
403 </key>
404 <key>
405 <binding label="p">
406- <modifiers keys="shift">
407- <binding label="P" />
408- </modifiers>
409 </binding>
410 </key>
411 </row>
412@@ -299,65 +196,38 @@
413 <spacer />
414 <key>
415 <binding label="a">
416- <modifiers keys="shift">
417- <binding label="A" />
418- </modifiers>
419 </binding>
420 </key>
421 <key>
422 <binding label="s">
423- <modifiers keys="shift">
424- <binding label="S" />
425- </modifiers>
426 </binding>
427 </key>
428 <key>
429 <binding label="d">
430- <modifiers keys="shift">
431- <binding label="D" />
432- </modifiers>
433 </binding>
434 </key>
435 <key>
436 <binding label="f">
437- <modifiers keys="shift">
438- <binding label="F" />
439- </modifiers>
440 </binding>
441 </key>
442 <key>
443 <binding label="g">
444- <modifiers keys="shift">
445- <binding label="G" />
446- </modifiers>
447 </binding>
448 </key>
449 <key>
450 <binding label="h">
451- <modifiers keys="shift">
452- <binding label="H" />
453- </modifiers>
454 </binding>
455 </key>
456 <key>
457 <binding label="j">
458- <modifiers keys="shift">
459- <binding label="J" />
460- </modifiers>
461 </binding>
462 </key>
463 <key>
464 <binding label="k">
465- <modifiers keys="shift">
466- <binding label="K" />
467- </modifiers>
468 </binding>
469 </key>
470 <key>
471 <binding label="l">
472- <modifiers keys="shift">
473- <binding label="L" />
474- </modifiers>
475 </binding>
476 </key>
477 <spacer />
478@@ -369,73 +239,53 @@
479 <spacer />
480 <key>
481 <binding label="z">
482- <modifiers keys="shift">
483- <binding label="Z" />
484- </modifiers>
485 </binding>
486 </key>
487 <key>
488 <binding label="x">
489- <modifiers keys="shift">
490- <binding label="X" />
491- </modifiers>
492 </binding>
493 </key>
494 <key>
495 <binding label="c">
496- <modifiers keys="shift">
497- <binding label="C" />
498- </modifiers>
499 </binding>
500 </key>
501 <key>
502 <binding label="v">
503- <modifiers keys="shift">
504- <binding label="V" />
505- </modifiers>
506 </binding>
507 </key>
508 <key>
509 <binding label="b">
510- <modifiers keys="shift">
511- <binding label="B" />
512- </modifiers>
513 </binding>
514 </key>
515 <key>
516 <binding label="n">
517- <modifiers keys="shift">
518- <binding label="N" />
519- </modifiers>
520 </binding>
521 </key>
522 <key>
523 <binding label="m">
524- <modifiers keys="shift">
525- <binding label="M" />
526- </modifiers>
527 </binding>
528 </key>
529 <spacer />
530 <key style="special" width="large">
531 <binding action="backspace" label="" />
532 </key>
533+ <spacer />
534 </row>
535 <row>
536- <key style="special" width="x-large">
537+ <key style="special" width="large">
538 <binding action="sym" label="符号" />
539 </key>
540- <key id="emailUrlKey">
541+ <key id="emailUrlKey" width="small">
542 <binding label="," />
543 </key>
544- <key width="stretched">
545+ <key width="xx-large">
546 <binding action="space" label="" />
547 </key>
548- <key id="emailUrlDotKey">
549+ <key id="emailUrlDotKey" width="small">
550 <binding label="。" />
551 </key>
552 <key id="actionKey" style="special" width="x-large">
553- <binding action="compose" label="输入" />
554+ <binding action="return" label="输入" />
555 </key>
556 </row>
557 </section>
558
559=== modified file 'maliit-keyboard/lib/lib.pro'
560--- maliit-keyboard/lib/lib.pro 2013-04-11 06:57:11 +0000
561+++ maliit-keyboard/lib/lib.pro 2013-06-17 15:53:36 +0000
562@@ -6,6 +6,11 @@
563 QT += core gui quick
564 CONFIG += staticlib
565
566+CONFIG += link_pkgconfig
567+PKGCONFIG += glib-2.0
568+PKGCONFIG += libpinyin
569+LIBS += libpinyin
570+
571 include(models/models.pri)
572 include(logic/logic.pri)
573 include(parser/parser.pri)
574
575=== added file 'maliit-keyboard/lib/logic/chineselanguagefeatures.cpp'
576--- maliit-keyboard/lib/logic/chineselanguagefeatures.cpp 1970-01-01 00:00:00 +0000
577+++ maliit-keyboard/lib/logic/chineselanguagefeatures.cpp 2013-06-17 15:53:36 +0000
578@@ -0,0 +1,42 @@
579+/*
580+ * Copyright 2013 Canonical Ltd.
581+ *
582+ * This program is free software; you can redistribute it and/or modify
583+ * it under the terms of the GNU Lesser General Public License as published by
584+ * the Free Software Foundation; version 3.
585+ *
586+ * This program is distributed in the hope that it will be useful,
587+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
588+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
589+ * GNU Lesser General Public License for more details.
590+ *
591+ * You should have received a copy of the GNU Lesser General Public License
592+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
593+ */
594+
595+#include "chineselanguagefeatures.h"
596+
597+namespace MaliitKeyboard {
598+namespace Logic {
599+
600+ChineseLanguageFeatures::ChineseLanguageFeatures(QObject *parent) :
601+ AbstractLanguageFeatures(parent)
602+{
603+}
604+
605+ChineseLanguageFeatures::~ChineseLanguageFeatures()
606+{
607+}
608+
609+bool ChineseLanguageFeatures::activateAutoCaps(const QString &preedit) const
610+{
611+ return false;
612+}
613+
614+QString ChineseLanguageFeatures::appendixForReplacedPreedit(const QString &preedit) const
615+{
616+ return "";
617+}
618+
619+} // namespace Logic
620+} // namespace MaliitKeyboard
621
622=== added file 'maliit-keyboard/lib/logic/chineselanguagefeatures.h'
623--- maliit-keyboard/lib/logic/chineselanguagefeatures.h 1970-01-01 00:00:00 +0000
624+++ maliit-keyboard/lib/logic/chineselanguagefeatures.h 2013-06-17 15:53:36 +0000
625@@ -0,0 +1,39 @@
626+/*
627+ * Copyright 2013 Canonical Ltd.
628+ *
629+ * This program is free software; you can redistribute it and/or modify
630+ * it under the terms of the GNU Lesser General Public License as published by
631+ * the Free Software Foundation; version 3.
632+ *
633+ * This program is distributed in the hope that it will be useful,
634+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
635+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
636+ * GNU Lesser General Public License for more details.
637+ *
638+ * You should have received a copy of the GNU Lesser General Public License
639+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
640+ */
641+
642+#ifndef CHINESELANGUAGEFEATURES_H
643+#define CHINESELANGUAGEFEATURES_H
644+
645+#include "abstractlanguagefeatures.h"
646+
647+namespace MaliitKeyboard {
648+namespace Logic {
649+
650+class ChineseLanguageFeatures : public AbstractLanguageFeatures
651+{
652+ Q_OBJECT
653+public:
654+ explicit ChineseLanguageFeatures(QObject *parent = 0);
655+ virtual ~ChineseLanguageFeatures();
656+
657+ virtual bool activateAutoCaps(const QString &preedit) const;
658+ virtual QString appendixForReplacedPreedit(const QString &preedit) const;
659+};
660+
661+} // namespace Logic
662+} // namespace MaliitKeyboard
663+
664+#endif // CHINESELANGUAGEFEATURES_H
665
666=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.cpp'
667--- maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-06-05 13:00:26 +0000
668+++ maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-06-17 15:53:36 +0000
669@@ -1,4 +1,18 @@
670-
671+/*
672+ * Copyright 2013 Canonical Ltd.
673+ *
674+ * This program is free software; you can redistribute it and/or modify
675+ * it under the terms of the GNU Lesser General Public License as published by
676+ * the Free Software Foundation; version 3.
677+ *
678+ * This program is distributed in the hope that it will be useful,
679+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
680+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
681+ * GNU Lesser General Public License for more details.
682+ *
683+ * You should have received a copy of the GNU Lesser General Public License
684+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
685+ */
686
687 #include "dynamiclayout.h"
688 #include "dynamiclayout_p.h"
689
690=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.h'
691--- maliit-keyboard/lib/logic/dynamiclayout.h 2013-06-05 13:00:26 +0000
692+++ maliit-keyboard/lib/logic/dynamiclayout.h 2013-06-17 15:53:36 +0000
693@@ -1,3 +1,19 @@
694+/*
695+ * Copyright 2013 Canonical Ltd.
696+ *
697+ * This program is free software; you can redistribute it and/or modify
698+ * it under the terms of the GNU Lesser General Public License as published by
699+ * the Free Software Foundation; version 3.
700+ *
701+ * This program is distributed in the hope that it will be useful,
702+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
703+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
704+ * GNU Lesser General Public License for more details.
705+ *
706+ * You should have received a copy of the GNU Lesser General Public License
707+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
708+ */
709+
710 #ifndef DYNAMICLAYOUT_H
711 #define DYNAMICLAYOUT_H
712
713
714=== modified file 'maliit-keyboard/lib/logic/eventhandler.cpp'
715--- maliit-keyboard/lib/logic/eventhandler.cpp 2013-05-29 09:54:04 +0000
716+++ maliit-keyboard/lib/logic/eventhandler.cpp 2013-06-17 15:53:36 +0000
717@@ -206,4 +206,11 @@
718 Q_EMIT wordCandidateReleased(candidate);
719 }
720
721+void EventHandler::onLanguageChangeRequested(QString languageId)
722+{
723+ Q_D(EventHandler);
724+
725+ d->updater->setActiveKeyboardId(languageId);
726+}
727+
728 }} // namespace Logic, MaliitKeyboard
729
730=== modified file 'maliit-keyboard/lib/logic/eventhandler.h'
731--- maliit-keyboard/lib/logic/eventhandler.h 2013-05-24 11:16:27 +0000
732+++ maliit-keyboard/lib/logic/eventhandler.h 2013-06-17 15:53:36 +0000
733@@ -73,6 +73,7 @@
734
735 Q_INVOKABLE void onWordCandidatePressed(QString word);
736 Q_INVOKABLE void onWordCandidateReleased(QString word);
737+ Q_INVOKABLE void onLanguageChangeRequested(QString languageId);
738
739 // Key signals:
740 Q_SIGNAL void keyPressed(const Key &key);
741@@ -84,6 +85,8 @@
742 Q_SIGNAL void wordCandidatePressed(const WordCandidate &candidate);
743 Q_SIGNAL void wordCandidateReleased(const WordCandidate &candidate);
744
745+ Q_SIGNAL void languageChangeRequested(QString languageId);
746+
747 private:
748 const QScopedPointer<EventHandlerPrivate> d_ptr;
749 };
750
751=== modified file 'maliit-keyboard/lib/logic/layoutupdater.cpp'
752--- maliit-keyboard/lib/logic/layoutupdater.cpp 2013-05-29 15:51:40 +0000
753+++ maliit-keyboard/lib/logic/layoutupdater.cpp 2013-06-17 15:53:36 +0000
754@@ -301,6 +301,7 @@
755 {
756 Q_D(LayoutUpdater);
757 d->loader.setActiveId(id);
758+ Q_EMIT languageChanged(id);
759 }
760
761 QString LayoutUpdater::keyboardTitle(const QString &id) const
762
763=== modified file 'maliit-keyboard/lib/logic/layoutupdater.h'
764--- maliit-keyboard/lib/logic/layoutupdater.h 2013-03-22 16:40:29 +0000
765+++ maliit-keyboard/lib/logic/layoutupdater.h 2013-06-17 15:53:36 +0000
766@@ -104,6 +104,7 @@
767 Q_SIGNAL void addToUserDictionary();
768
769 Q_SIGNAL void keyboardTitleChanged(const QString &title);
770+ Q_SIGNAL void languageChanged(const QString& languageId);
771
772 private:
773 Q_SIGNAL void shiftPressed();
774
775=== modified file 'maliit-keyboard/lib/logic/logic.pri'
776--- maliit-keyboard/lib/logic/logic.pri 2013-06-03 12:20:12 +0000
777+++ maliit-keyboard/lib/logic/logic.pri 2013-06-17 15:53:36 +0000
778@@ -13,7 +13,9 @@
779 logic/abstractlanguagefeatures.h \
780 logic/languagefeatures.h \
781 logic/eventhandler.h \
782- logic/dynamiclayout.h
783+ logic/dynamiclayout.h \
784+ logic/pinyinadapter.h \
785+ logic/chineselanguagefeatures.h
786
787 SOURCES += \
788 logic/hitlogic.cpp \
789@@ -28,7 +30,9 @@
790 logic/abstractlanguagefeatures.cpp \
791 logic/languagefeatures.cpp \
792 logic/eventhandler.cpp \
793- logic/dynamiclayout.cpp
794+ logic/dynamiclayout.cpp \
795+ logic/pinyinadapter.cpp \
796+ logic/chineselanguagefeatures.cpp
797
798 DEFINES += HUNSPELL_DICT_PATH=\\\"$$HUNSPELL_DICT_PATH\\\"
799
800
801=== added file 'maliit-keyboard/lib/logic/pinyinadapter.cpp'
802--- maliit-keyboard/lib/logic/pinyinadapter.cpp 1970-01-01 00:00:00 +0000
803+++ maliit-keyboard/lib/logic/pinyinadapter.cpp 2013-06-17 15:53:36 +0000
804@@ -0,0 +1,103 @@
805+/*
806+ * Copyright 2013 Canonical Ltd.
807+ *
808+ * This program is free software; you can redistribute it and/or modify
809+ * it under the terms of the GNU Lesser General Public License as published by
810+ * the Free Software Foundation; version 3.
811+ *
812+ * This program is distributed in the hope that it will be useful,
813+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
814+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
815+ * GNU Lesser General Public License for more details.
816+ *
817+ * You should have received a copy of the GNU Lesser General Public License
818+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
819+ */
820+
821+#ifdef HAVE_PINYIN
822+
823+#include "pinyinadapter.h"
824+
825+#include <iostream>
826+
827+#include <iconv.h>
828+#include <string>
829+#include <string.h>
830+
831+#include <QDebug>
832+
833+PinyinAdapter::PinyinAdapter(QObject *parent) :
834+ QObject(parent)
835+{
836+ m_context = pinyin_init("/usr/lib/arm-linux-gnueabihf/libpinyin/data/", ".");
837+ m_instance = pinyin_alloc_instance(m_context);
838+
839+ pinyin_set_options(m_context, IS_PINYIN | USE_DIVIDED_TABLE | USE_RESPLIT_TABLE);
840+}
841+
842+PinyinAdapter::~PinyinAdapter()
843+{
844+ g_array_free(m_array, TRUE);
845+ pinyin_free_instance(m_instance);
846+ pinyin_fini(m_context);
847+}
848+
849+QString PinyinAdapter::parse(const QString& string)
850+{
851+ pinyin_parse_more_full_pinyins(m_instance, string.toLatin1().data());
852+
853+ int cursor = 0;
854+
855+#ifdef PINYIN_DEBUG
856+ for (int i = 0; i < m_instance->m_pinyin_keys->len; i ++)
857+ {
858+ PinyinKey* pykey = &g_array_index(m_instance->m_pinyin_keys, PinyinKey, i);
859+ gchar* py = pykey->get_pinyin_string();
860+ std::cout << py << " ";
861+ g_free(py);
862+ }
863+ std::cout << std::endl;
864+#endif
865+
866+ m_array = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
867+ pinyin_get_candidates(m_instance, 0, m_array);
868+
869+ pinyin_guess_sentence(m_instance);
870+
871+ char* sentence = NULL;
872+ pinyin_get_sentence(m_instance, &sentence);
873+
874+ candidates.clear();
875+ for (int i = 0 ; i < m_array->len; i ++ )
876+ {
877+ lookup_candidate_t token = g_array_index(m_array, lookup_candidate_t, i);
878+ char* word = NULL;
879+ // Translate the token to utf-8 phrase.
880+ pinyin_translate_token(m_instance, token.m_token, &word);
881+ if (word) {
882+ candidates.append(QString(word));
883+ }
884+ g_free(word);
885+ }
886+
887+ QString unicode(sentence);
888+ g_free(sentence);
889+ return unicode;
890+}
891+
892+QStringList PinyinAdapter::getWordCandidates() const
893+{
894+ return candidates;
895+}
896+
897+void PinyinAdapter::wordCandidateSelected(const QString& word)
898+{
899+ pinyin_choose_candidate(m_instance, 0, &g_array_index(m_array, lookup_candidate_t, 1));
900+}
901+
902+void PinyinAdapter::reset()
903+{
904+ pinyin_reset(m_instance);
905+}
906+
907+#endif
908
909=== added file 'maliit-keyboard/lib/logic/pinyinadapter.h'
910--- maliit-keyboard/lib/logic/pinyinadapter.h 1970-01-01 00:00:00 +0000
911+++ maliit-keyboard/lib/logic/pinyinadapter.h 2013-06-17 15:53:36 +0000
912@@ -0,0 +1,50 @@
913+/*
914+ * Copyright 2013 Canonical Ltd.
915+ *
916+ * This program is free software; you can redistribute it and/or modify
917+ * it under the terms of the GNU Lesser General Public License as published by
918+ * the Free Software Foundation; version 3.
919+ *
920+ * This program is distributed in the hope that it will be useful,
921+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
922+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
923+ * GNU Lesser General Public License for more details.
924+ *
925+ * You should have received a copy of the GNU Lesser General Public License
926+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
927+ */
928+
929+#ifndef PINYINADAPTER_H
930+#define PINYINADAPTER_H
931+
932+#ifdef HAVE_PINYIN
933+
934+#include <QObject>
935+#include <QStringList>
936+
937+#include "pinyin.h"
938+
939+class PinyinAdapter : public QObject
940+{
941+ Q_OBJECT
942+
943+ QStringList candidates;
944+
945+ pinyin_context_t* m_context;
946+ pinyin_instance_t* m_instance;
947+
948+ GArray* m_array;
949+
950+public:
951+ explicit PinyinAdapter(QObject *parent = 0);
952+ ~PinyinAdapter();
953+
954+ QString parse(const QString& string);
955+ QStringList getWordCandidates() const;
956+ void wordCandidateSelected(const QString& word);
957+ void reset();
958+};
959+
960+#endif
961+
962+#endif // PINYINADAPTER_H
963
964=== modified file 'maliit-keyboard/lib/logic/wordengine.cpp'
965--- maliit-keyboard/lib/logic/wordengine.cpp 2012-07-25 09:49:30 +0000
966+++ maliit-keyboard/lib/logic/wordengine.cpp 2013-06-17 15:53:36 +0000
967@@ -36,6 +36,11 @@
968 #include <presage.h>
969 #endif
970
971+#ifdef HAVE_PINYIN
972+#include "pinyinadapter.h"
973+#include <iostream>
974+#endif
975+
976 namespace MaliitKeyboard {
977 namespace Logic {
978
979@@ -105,6 +110,14 @@
980 class WordEnginePrivate
981 {
982 public:
983+
984+ enum PredictiveBackend {
985+ PresageBackend = 1,
986+ PinyinBackend
987+ };
988+
989+ PredictiveBackend predictiveBackend;
990+
991 SpellChecker spell_checker;
992 #ifdef HAVE_PRESAGE
993 std::string candidates_context;
994@@ -112,11 +125,16 @@
995 Presage presage;
996 #endif
997
998+ // TODO there is too many ifdef in this class
999+#ifdef HAVE_PINYIN
1000+ PinyinAdapter* pinyinAdapter;
1001+#endif
1002 explicit WordEnginePrivate();
1003 };
1004
1005 WordEnginePrivate::WordEnginePrivate()
1006- : spell_checker()
1007+ : predictiveBackend(PresageBackend)
1008+ , spell_checker()
1009 #ifdef HAVE_PRESAGE
1010 , candidates_context()
1011 , presage_candidates(CandidatesCallback(candidates_context))
1012@@ -128,6 +146,10 @@
1013 presage.config("Presage.Selector.SUGGESTIONS", "6");
1014 presage.config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");
1015 #endif
1016+
1017+#ifdef HAVE_PINYIN
1018+ pinyinAdapter = new PinyinAdapter;
1019+#endif
1020 }
1021
1022
1023@@ -159,6 +181,15 @@
1024 AbstractWordEngine::setEnabled(enabled);
1025 }
1026
1027+void WordEngine::onWordCandidateSelected(QString word)
1028+{
1029+ Q_D(WordEngine);
1030+
1031+#ifdef HAVE_PINYIN
1032+ if (d->predictiveBackend == WordEnginePrivate::PinyinBackend)
1033+ d->pinyinAdapter->wordCandidateSelected(word);
1034+#endif
1035+}
1036
1037 WordCandidateList WordEngine::fetchCandidates(Model::Text *text)
1038 {
1039@@ -168,19 +199,33 @@
1040 const QString &preedit(text->preedit());
1041 const bool is_preedit_capitalized(not preedit.isEmpty() && preedit.at(0).isUpper());
1042
1043+#ifdef HAVE_PINYIN
1044+ if (d->predictiveBackend == WordEnginePrivate::PinyinBackend) {
1045+ QString sentence = d->pinyinAdapter->parse(preedit);
1046+
1047+ QStringList suggestions = d->pinyinAdapter->getWordCandidates();
1048+
1049+ Q_FOREACH(const QString &suggestion, suggestions) {
1050+ appendToCandidates(&candidates, WordCandidate::SourcePrediction, suggestion, is_preedit_capitalized);
1051+ }
1052+ }
1053+#endif
1054+
1055 #ifdef HAVE_PRESAGE
1056- const QString &context = (text->surroundingLeft() + preedit);
1057- d->candidates_context = context.toStdString();
1058- const std::vector<std::string> predictions = d->presage.predict();
1059+ if (d->predictiveBackend == WordEnginePrivate::PresageBackend) {
1060+ const QString &context = (text->surroundingLeft() + preedit);
1061+ d->candidates_context = context.toStdString();
1062+ const std::vector<std::string> predictions = d->presage.predict();
1063
1064- // TODO: Fine-tune presage behaviour to also perform error correction, not just word prediction.
1065- if (not context.isEmpty()) {
1066- // FIXME: max_candidates should come from style, too:
1067- const static unsigned int max_candidates = 7;
1068- const int count(qMin<int>(predictions.size(), max_candidates));
1069- for (int index = 0; index < count; ++index) {
1070- appendToCandidates(&candidates, WordCandidate::SourcePrediction, QString::fromStdString(predictions.at(index)),
1071- is_preedit_capitalized);
1072+ // TODO: Fine-tune presage behaviour to also perform error correction, not just word prediction.
1073+ if (not context.isEmpty()) {
1074+ // FIXME: max_candidates should come from style, too:
1075+ const static unsigned int max_candidates = 7;
1076+ const int count(qMin<int>(predictions.size(), max_candidates));
1077+ for (int index = 0; index < count; ++index) {
1078+ appendToCandidates(&candidates, WordCandidate::SourcePrediction, QString::fromStdString(predictions.at(index)),
1079+ is_preedit_capitalized);
1080+ }
1081 }
1082 }
1083 #endif
1084@@ -210,4 +255,14 @@
1085 d->spell_checker.addToUserWordlist(word);
1086 }
1087
1088+void WordEngine::onLanguageChanged(const QString &languageId)
1089+{
1090+ Q_D(WordEngine);
1091+
1092+ if (languageId == "zh_cn_pinyin")
1093+ d->predictiveBackend = WordEnginePrivate::PinyinBackend;
1094+ else
1095+ d->predictiveBackend = WordEnginePrivate::PresageBackend;
1096+}
1097+
1098 }} // namespace Logic, MaliitKeyboard
1099
1100=== modified file 'maliit-keyboard/lib/logic/wordengine.h'
1101--- maliit-keyboard/lib/logic/wordengine.h 2012-07-25 09:49:30 +0000
1102+++ maliit-keyboard/lib/logic/wordengine.h 2013-06-17 15:53:36 +0000
1103@@ -59,6 +59,9 @@
1104 virtual void addToUserDictionary(const QString &word);
1105 //! \reimp_end
1106
1107+ Q_SLOT void onWordCandidateSelected(QString word);
1108+ Q_SLOT void onLanguageChanged(const QString& languageId);
1109+
1110 private:
1111 //! \reimp
1112 virtual WordCandidateList fetchCandidates(Model::Text *text);
1113
1114=== modified file 'maliit-keyboard/plugin/editor.cpp'
1115--- maliit-keyboard/plugin/editor.cpp 2012-08-06 12:58:44 +0000
1116+++ maliit-keyboard/plugin/editor.cpp 2013-06-17 15:53:36 +0000
1117@@ -36,6 +36,8 @@
1118 #include <QTimer>
1119 #include <maliit/namespace.h>
1120
1121+#include "logic/abstractlanguagefeatures.h"
1122+
1123 namespace MaliitKeyboard {
1124
1125 Editor::Editor(const EditorOptions &options,
1126
1127=== modified file 'maliit-keyboard/plugin/inputmethod.cpp'
1128--- maliit-keyboard/plugin/inputmethod.cpp 2013-06-06 16:47:16 +0000
1129+++ maliit-keyboard/plugin/inputmethod.cpp 2013-06-17 15:53:36 +0000
1130@@ -225,6 +225,15 @@
1131 QObject::connect(&editor, SIGNAL(preeditEnabledChanged(bool)),
1132 &layout.updater, SLOT(setWordRibbonVisible(bool)));
1133
1134+ QObject::connect(&layout.updater, SIGNAL(wordCandidateSelected(QString)),
1135+ editor.wordEngine(), SLOT(onWordCandidateSelected(QString)));
1136+
1137+ QObject::connect(&layout.updater, SIGNAL(languageChanged(QString)),
1138+ editor.wordEngine(), SLOT(onLanguageChanged(QString)));
1139+
1140+ QObject::connect(&layout.updater, SIGNAL(languageChanged(QString)),
1141+ &editor, SLOT(onLanguageChanged(const QString&)));
1142+
1143 // just for now
1144 layout.updater.setWordRibbonVisible(true);
1145
1146@@ -441,6 +450,9 @@
1147 connect(d->surface_factory, SIGNAL(screenSizeChanged(QSize)),
1148 this, SLOT(onScreenSizeChange(QSize)));
1149
1150+ connect(&d->editor, SIGNAL(layoutMenuRequested()),
1151+ this, SLOT(onLayoutMenuRequested()));
1152+
1153 connect(this, SIGNAL(wordEngineEnabledChanged(bool)), uiConst, SLOT(onWordEngineSettingsChanged(bool)));
1154
1155 registerStyleSetting(host);
1156@@ -913,4 +925,10 @@
1157 d->updateKeyboardOrientation();
1158 }
1159
1160+void InputMethod::onLayoutMenuRequested()
1161+{
1162+ Q_D(InputMethod);
1163+ d->qmlRootItem->setProperty("languageMenuVisible", true);
1164+}
1165+
1166 } // namespace MaliitKeyboard
1167
1168=== modified file 'maliit-keyboard/plugin/inputmethod.h'
1169--- maliit-keyboard/plugin/inputmethod.h 2013-06-03 15:41:05 +0000
1170+++ maliit-keyboard/plugin/inputmethod.h 2013-06-17 15:53:36 +0000
1171@@ -104,6 +104,8 @@
1172 Q_SLOT void onMagnifierLayoutOriginChanged(const QPoint &origin);
1173 #endif
1174
1175+ Q_SLOT void onLayoutMenuRequested();
1176+
1177 Q_SLOT void onHideAnimationFinished();
1178 Q_SIGNAL void wordEngineEnabledChanged(bool wordEngineEnabled);
1179
1180
1181=== modified file 'maliit-keyboard/qml/Keyboard.qml'
1182--- maliit-keyboard/qml/Keyboard.qml 2013-06-06 16:47:16 +0000
1183+++ maliit-keyboard/qml/Keyboard.qml 2013-06-17 15:53:36 +0000
1184@@ -45,6 +45,8 @@
1185 property int pressedKeyIndex: -1;
1186 property Item pressedKey;
1187
1188+ property bool languageMenuVisible: false
1189+
1190 RotationHelper {
1191
1192 Connections {
1193@@ -55,6 +57,17 @@
1194 }
1195 }
1196
1197+ LanguageMenu {
1198+ id: languageMenu
1199+
1200+ visible: languageMenuVisible
1201+ anchors.centerIn: parent
1202+ width: 500
1203+ height: 600
1204+
1205+ z: 20
1206+ }
1207+
1208 MouseArea {
1209 id: keyboardSurface
1210 property int jumpBackThreshold: 170
1211
1212=== added file 'maliit-keyboard/qml/LanguageMenu.qml'
1213--- maliit-keyboard/qml/LanguageMenu.qml 1970-01-01 00:00:00 +0000
1214+++ maliit-keyboard/qml/LanguageMenu.qml 2013-06-17 15:53:36 +0000
1215@@ -0,0 +1,53 @@
1216+/*
1217+ * Copyright 2013 Canonical Ltd.
1218+ *
1219+ * This program is free software; you can redistribute it and/or modify
1220+ * it under the terms of the GNU Lesser General Public License as published by
1221+ * the Free Software Foundation; version 3.
1222+ *
1223+ * This program is distributed in the hope that it will be useful,
1224+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1225+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1226+ * GNU Lesser General Public License for more details.
1227+ *
1228+ * You should have received a copy of the GNU Lesser General Public License
1229+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1230+ */
1231+
1232+import QtQuick 2.0
1233+import Ubuntu.Components 0.1
1234+import Ubuntu.Components.ListItems 0.1 as ListItem
1235+
1236+Item {
1237+
1238+ Rectangle {
1239+ anchors.fill: parent
1240+ color: "lightGray"
1241+ }
1242+
1243+ // tempor., will come from settings
1244+ ListModel {
1245+ id: availableLanguagesModel
1246+ ListElement { language: "English - US"; languageId: "en_us"; }
1247+ ListElement { language: "English - UK"; languageId: "en_gb"; }
1248+ ListElement { language: "Chinese - Pinyin"; languageId: "zh_cn_pinyin"; }
1249+ ListElement { language: "Spanish"; languageId: "es"; }
1250+ ListElement { language: "German"; languageId: "de"; }
1251+ }
1252+
1253+ ListView {
1254+ id: menuList
1255+ anchors.fill: parent
1256+ interactive: false
1257+
1258+ model: availableLanguagesModel
1259+
1260+ delegate: ListItem.Standard {
1261+ text: language
1262+ onClicked: {
1263+ event_handler.onLanguageChangeRequested(languageId);
1264+ canvas.languageMenuVisible = false;
1265+ }
1266+ }
1267+ }
1268+}
1269
1270=== modified file 'maliit-keyboard/qml/qml.pro'
1271--- maliit-keyboard/qml/qml.pro 2013-06-05 14:58:50 +0000
1272+++ maliit-keyboard/qml/qml.pro 2013-06-17 15:53:36 +0000
1273@@ -14,6 +14,7 @@
1274 Keyboard.qml \
1275 maliit-ui-constants.qml \
1276 RotationHelper.qml \
1277- WordRibbon.qml
1278+ WordRibbon.qml \
1279+ LanguageMenu.qml
1280 Popper.qml
1281
1282
1283=== modified file 'maliit-keyboard/view/abstracttexteditor.cpp'
1284--- maliit-keyboard/view/abstracttexteditor.cpp 2012-11-21 15:19:50 +0000
1285+++ maliit-keyboard/view/abstracttexteditor.cpp 2013-06-17 15:53:36 +0000
1286@@ -32,6 +32,9 @@
1287 #include "abstracttexteditor.h"
1288 #include "models/wordribbon.h"
1289
1290+#include "logic/chineselanguagefeatures.h"
1291+#include "logic/languagefeatures.h"
1292+
1293 namespace MaliitKeyboard {
1294
1295 //! \class EditorOptions
1296@@ -490,6 +493,10 @@
1297 Q_EMIT rightLayoutSelected();
1298 break;
1299
1300+ case Key::ActionLayoutMenu:
1301+ Q_EMIT layoutMenuRequested();
1302+ break;
1303+
1304 default:
1305 break;
1306 }
1307@@ -752,4 +759,17 @@
1308 }
1309 }
1310
1311+//! \brief sets language features
1312+//! \param language id as string (as found in settings file)
1313+//!
1314+void AbstractTextEditor::onLanguageChanged(const QString& languageId)
1315+{
1316+ Q_D(AbstractTextEditor);
1317+
1318+ if (languageId == "zh_cn_pinyin")
1319+ d->language_features.reset(new Logic::ChineseLanguageFeatures);
1320+ else
1321+ d->language_features.reset(new Logic::LanguageFeatures);
1322+}
1323+
1324 } // namespace MaliitKeyboard
1325
1326=== modified file 'maliit-keyboard/view/abstracttexteditor.h'
1327--- maliit-keyboard/view/abstracttexteditor.h 2012-11-21 15:19:50 +0000
1328+++ maliit-keyboard/view/abstracttexteditor.h 2013-06-17 15:53:36 +0000
1329@@ -138,6 +138,9 @@
1330 Q_SIGNAL void autoCapsActivated();
1331 Q_SIGNAL void leftLayoutSelected();
1332 Q_SIGNAL void rightLayoutSelected();
1333+ Q_SIGNAL void layoutMenuRequested();
1334+
1335+ Q_SLOT virtual void onLanguageChanged(const QString& languageId);
1336
1337 private:
1338 const QScopedPointer<AbstractTextEditorPrivate> d_ptr;
1339
1340=== modified file 'maliit-keyboard/word-prediction.pri'
1341--- maliit-keyboard/word-prediction.pri 2012-07-23 09:40:25 +0000
1342+++ maliit-keyboard/word-prediction.pri 2013-06-17 15:53:36 +0000
1343@@ -13,3 +13,10 @@
1344 disable-preedit|!enable-presage:!enable-hunspell {
1345 DEFINES += DISABLE_PREEDIT
1346 }
1347+
1348+enable-pinyin {
1349+ CONFIG += link_pkgconfig
1350+ PKGCONFIG += glib-2.0
1351+ PKGCONFIG += libpinyin
1352+ DEFINES += HAVE_PINYIN
1353+}
1354
1355=== modified file 'maliit-plugins.pro'
1356--- maliit-plugins.pro 2013-01-30 19:53:34 +0000
1357+++ maliit-plugins.pro 2013-06-17 15:53:36 +0000
1358@@ -13,6 +13,7 @@
1359 \\n\\t enable-presage: Use presage to calculate word candidates (maliit-keyboard-plugin only) \
1360 \\n\\t enable-hunspell: Use hunspell for error correction (maliit-keyboard-plugin only) \
1361 \\n\\t disable-preedit: Always commit characters and never use preedit (maliit-keyboard-plugin only) \
1362+ \\n\\t enable-pinyin: Use libpinyin as chinese input method \
1363 \\n\\t enable-qt-mobility: Enable use of QtMobility (enables sound and haptic feedback) \
1364 \\n\\t notests: Do not attempt to build tests \
1365 \\n\\t nodoc: Do not build documentation \
1366@@ -68,6 +69,10 @@
1367 COVERAGE_CONFIG_STRING += CONFIG+=disable-preedit
1368 }
1369
1370+enable-pinyin {
1371+ COVERAGE_CONFIG_STRING += CONFIG+=enable-pinyin
1372+}
1373+
1374 enable-qt-mobility {
1375 COVERAGE_CONFIG_STRING += CONFIG+=enable-qt-mobility
1376 }

Subscribers

People subscribed via source and target branches