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
=== modified file 'debian/control'
--- debian/control 2013-06-06 10:29:18 +0000
+++ debian/control 2013-06-17 15:53:36 +0000
@@ -14,7 +14,9 @@
14 maliit-framework-dev (>= 0.94.0-w03-springbok1phablet15), 14 maliit-framework-dev (>= 0.94.0-w03-springbok1phablet15),
15 libhunspell-dev, 15 libhunspell-dev,
16 libpresage-dev,16 libpresage-dev,
17 libubuntu-platform-api1-dev17 libubuntu-platform-api1-dev,
18 libpinyin2-dev,
19 libglib2.0-dev
18Standards-Version: 3.9.320Standards-Version: 3.9.3
1921
20Package: nemo-keyboard22Package: nemo-keyboard
@@ -39,6 +41,7 @@
39Architecture: armhf41Architecture: armhf
40Depends: maliit-framework, 42Depends: maliit-framework,
41 libpresage1, 43 libpresage1,
44 libpinyin2,
42 ${misc:Depends}, 45 ${misc:Depends},
43 ${shlibs:Depends}, 46 ${shlibs:Depends},
44 qtdeclarative5-window-plugin47 qtdeclarative5-window-plugin
4548
=== modified file 'debian/rules'
--- debian/rules 2013-06-07 08:43:47 +0000
+++ debian/rules 2013-06-17 15:53:36 +0000
@@ -16,6 +16,7 @@
16 CONFIG+=enable-presage \16 CONFIG+=enable-presage \
17 CONFIG+=enable-hunspell \17 CONFIG+=enable-hunspell \
18 CONFIG+=enable-preedit \18 CONFIG+=enable-preedit \
19 CONFIG+=enable-pinyin \
19 CONFIG+=enable-qt-mobility \20 CONFIG+=enable-qt-mobility \
20 CONFIG+=enable-maliit-keyboard \21 CONFIG+=enable-maliit-keyboard \
21 CONFIG+=enable-nemo-keyboard22 CONFIG+=enable-nemo-keyboard
2223
=== modified file 'maliit-keyboard/data/languages/de.xml'
--- maliit-keyboard/data/languages/de.xml 2013-04-26 13:05:20 +0000
+++ maliit-keyboard/data/languages/de.xml 2013-06-17 15:53:36 +0000
@@ -490,6 +490,9 @@
490 </key>490 </key>
491 </row>491 </row>
492 <row>492 <row>
493 <key id="actionKey" style="special" width="large">
494 <binding action="layout_menu" label="de" />
495 </key>
493 <key style="special" width="large">496 <key style="special" width="large">
494 <binding action="sym" label="?123" />497 <binding action="sym" label="?123" />
495 </key>498 </key>
496499
=== modified file 'maliit-keyboard/data/languages/en_gb.xml'
--- maliit-keyboard/data/languages/en_gb.xml 2013-04-26 13:05:20 +0000
+++ maliit-keyboard/data/languages/en_gb.xml 2013-06-17 15:53:36 +0000
@@ -463,7 +463,10 @@
463 </key>463 </key>
464 </row>464 </row>
465 <row>465 <row>
466 <key style="special" width="x-large">466 <key id="actionKey" style="special" width="large">
467 <binding action="layout_menu" label="en" />
468 </key>
469 <key style="special" width="large">
467 <binding action="sym" label="?123" />470 <binding action="sym" label="?123" />
468 </key>471 </key>
469 <spacer />472 <spacer />
470473
=== modified file 'maliit-keyboard/data/languages/en_us.xml'
--- maliit-keyboard/data/languages/en_us.xml 2013-04-26 13:05:20 +0000
+++ maliit-keyboard/data/languages/en_us.xml 2013-06-17 15:53:36 +0000
@@ -460,7 +460,10 @@
460 </key>460 </key>
461 </row>461 </row>
462 <row>462 <row>
463 <key style="special" width="x-large">463 <key id="actionKey" style="special" width="large">
464 <binding action="layout_menu" label="en" />
465 </key>
466 <key style="special" width="large">
464 <binding action="sym" label="?123" />467 <binding action="sym" label="?123" />
465 </key>468 </key>
466 <spacer />469 <spacer />
467470
=== modified file 'maliit-keyboard/data/languages/es.xml'
--- maliit-keyboard/data/languages/es.xml 2012-08-17 12:00:21 +0000
+++ maliit-keyboard/data/languages/es.xml 2013-06-17 15:53:36 +0000
@@ -466,7 +466,10 @@
466 </key>466 </key>
467 </row>467 </row>
468 <row>468 <row>
469 <key style="special" width="x-large">469 <key id="actionKey" style="special" width="large">
470 <binding action="layout_menu" label="es" />
471 </key>
472 <key style="special" width="large">
470 <binding action="sym" label="?123" />473 <binding action="sym" label="?123" />
471 </key>474 </key>
472 <key style="special">475 <key style="special">
@@ -475,7 +478,7 @@
475 <key id="emailUrlKey">478 <key id="emailUrlKey">
476 <binding label="," />479 <binding label="," />
477 </key>480 </key>
478 <key width="stretched">481 <key width="xx-large">
479 <binding action="space" label="" />482 <binding action="space" label="" />
480 </key>483 </key>
481 <key>484 <key>
482485
=== modified file 'maliit-keyboard/data/languages/zh_cn_pinyin.xml'
--- maliit-keyboard/data/languages/zh_cn_pinyin.xml 2012-08-17 12:00:21 +0000
+++ maliit-keyboard/data/languages/zh_cn_pinyin.xml 2013-06-17 15:53:36 +0000
@@ -7,72 +7,42 @@
7 <row>7 <row>
8 <key>8 <key>
9 <binding label="q">9 <binding label="q">
10 <modifiers keys="shift">
11 <binding label="Q" />
12 </modifiers>
13 </binding>10 </binding>
14 </key>11 </key>
15 <key>12 <key>
16 <binding label="w">13 <binding label="w">
17 <modifiers keys="shift">
18 <binding label="W" />
19 </modifiers>
20 </binding>14 </binding>
21 </key>15 </key>
22 <key>16 <key>
23 <binding label="e">17 <binding label="e">
24 <modifiers keys="shift">
25 <binding label="E" />
26 </modifiers>
27 </binding>18 </binding>
28 </key>19 </key>
29 <key>20 <key>
30 <binding label="r">21 <binding label="r">
31 <modifiers keys="shift">
32 <binding label="R" />
33 </modifiers>
34 </binding>22 </binding>
35 </key>23 </key>
36 <key>24 <key>
37 <binding label="t">25 <binding label="t">
38 <modifiers keys="shift">
39 <binding label="T" />
40 </modifiers>
41 </binding>26 </binding>
42 </key>27 </key>
43 <key>28 <key>
44 <binding label="y">29 <binding label="y">
45 <modifiers keys="shift">
46 <binding label="Y" />
47 </modifiers>
48 </binding>30 </binding>
49 </key>31 </key>
50 <key>32 <key>
51 <binding label="u">33 <binding label="u">
52 <modifiers keys="shift">
53 <binding label="U" />
54 </modifiers>
55 </binding>34 </binding>
56 </key>35 </key>
57 <key>36 <key>
58 <binding label="i">37 <binding label="i">
59 <modifiers keys="shift">
60 <binding label="I" />
61 </modifiers>
62 </binding>38 </binding>
63 </key>39 </key>
64 <key>40 <key>
65 <binding label="o">41 <binding label="o">
66 <modifiers keys="shift">
67 <binding label="O" />
68 </modifiers>
69 </binding>42 </binding>
70 </key>43 </key>
71 <key>44 <key>
72 <binding label="p">45 <binding label="p">
73 <modifiers keys="shift">
74 <binding label="P" />
75 </modifiers>
76 </binding>46 </binding>
77 </key>47 </key>
78 </row>48 </row>
@@ -80,143 +50,100 @@
80 <spacer />50 <spacer />
81 <key>51 <key>
82 <binding label="a">52 <binding label="a">
83 <modifiers keys="shift">
84 <binding label="A" />
85 </modifiers>
86 </binding>53 </binding>
87 </key>54 </key>
88 <key>55 <key>
89 <binding label="s">56 <binding label="s">
90 <modifiers keys="shift">
91 <binding label="S" />
92 </modifiers>
93 </binding>57 </binding>
94 </key>58 </key>
95 <key>59 <key>
96 <binding label="d">60 <binding label="d">
97 <modifiers keys="shift">
98 <binding label="D" />
99 </modifiers>
100 </binding>61 </binding>
101 </key>62 </key>
102 <key>63 <key>
103 <binding label="f">64 <binding label="f">
104 <modifiers keys="shift">
105 <binding label="F" />
106 </modifiers>
107 </binding>65 </binding>
108 </key>66 </key>
109 <key>67 <key>
110 <binding label="g">68 <binding label="g">
111 <modifiers keys="shift">
112 <binding label="G" />
113 </modifiers>
114 </binding>69 </binding>
115 </key>70 </key>
116 <key>71 <key>
117 <binding label="h">72 <binding label="h">
118 <modifiers keys="shift">
119 <binding label="H" />
120 </modifiers>
121 </binding>73 </binding>
122 </key>74 </key>
123 <key>75 <key>
124 <binding label="j">76 <binding label="j">
125 <modifiers keys="shift">
126 <binding label="J" />
127 </modifiers>
128 </binding>77 </binding>
129 </key>78 </key>
130 <key>79 <key>
131 <binding label="k">80 <binding label="k">
132 <modifiers keys="shift">
133 <binding label="K" />
134 </modifiers>
135 </binding>81 </binding>
136 </key>82 </key>
137 <key>83 <key>
138 <binding label="l">84 <binding label="l">
139 <modifiers keys="shift">
140 <binding label="L" />
141 </modifiers>
142 </binding>85 </binding>
143 </key>86 </key>
144 <spacer />87 <spacer />
145 </row>88 </row>
146 <row>89 <row>
147 <key style="special" width="large">90<!-- <key style="special" width="large">
148 <binding action="shift" label="" />91 <binding action="shift" label="" />
149 </key>92 </key>//-->
93 <spacer />
150 <spacer />94 <spacer />
151 <key>95 <key>
152 <binding label="z">96 <binding label="z">
153 <modifiers keys="shift">
154 <binding label="Z" />
155 </modifiers>
156 </binding>97 </binding>
157 </key>98 </key>
158 <key>99 <key>
159 <binding label="x">100 <binding label="x">
160 <modifiers keys="shift">
161 <binding label="X" />
162 </modifiers>
163 </binding>101 </binding>
164 </key>102 </key>
165 <key>103 <key>
166 <binding label="c">104 <binding label="c">
167 <modifiers keys="shift">
168 <binding label="C" />
169 </modifiers>
170 </binding>105 </binding>
171 </key>106 </key>
172 <key>107 <key>
173 <binding label="v">108 <binding label="v">
174 <modifiers keys="shift">
175 <binding label="V" />
176 </modifiers>
177 </binding>109 </binding>
178 </key>110 </key>
179 <key>111 <key>
180 <binding label="b">112 <binding label="b">
181 <modifiers keys="shift">
182 <binding label="B" />
183 </modifiers>
184 </binding>113 </binding>
185 </key>114 </key>
186 <key>115 <key>
187 <binding label="n">116 <binding label="n">
188 <modifiers keys="shift">
189 <binding label="N" />
190 </modifiers>
191 </binding>117 </binding>
192 </key>118 </key>
193 <key>119 <key>
194 <binding label="m">120 <binding label="m">
195 <modifiers keys="shift">
196 <binding label="M" />
197 </modifiers>
198 </binding>121 </binding>
199 </key>122 </key>
200 <spacer />123 <spacer />
201 <key style="special" width="large">124 <key style="special" width="large">
202 <binding action="backspace" label="" />125 <binding action="backspace" label="" />
203 </key>126 </key>
127 <spacer />
204 </row>128 </row>
205 <row>129 <row>
206 <key style="special" width="x-large">130 <key id="actionKey" style="special" width="large">
131 <binding action="layout_menu" label="cn" />
132 </key>
133 <key style="special" width="large">
207 <binding action="sym" label="符号" />134 <binding action="sym" label="符号" />
208 </key>135 </key>
209 <key id="emailUrlKey">136 <key id="emailUrlKey" width="small">
210 <binding label="," />137 <binding label="," />
211 </key>138 </key>
212 <key width="stretched">139 <key width="xx-large">
213 <binding action="space" label="" />140 <binding action="space" label="" />
214 </key>141 </key>
215 <key id="emailUrlDotKey">142 <key id="emailUrlDotKey" width="small">
216 <binding label="。" />143 <binding label="。" />
217 </key>144 </key>
218 <key id="actionKey" style="special" width="x-large">145 <key id="actionKey" style="special" width="x-large">
219 <binding action="compose" label="输入" />146 <binding action="return" label="输入" />
220 </key>147 </key>
221 </row>148 </row>
222 </section>149 </section>
@@ -226,72 +153,42 @@
226 <row>153 <row>
227 <key>154 <key>
228 <binding label="q">155 <binding label="q">
229 <modifiers keys="shift">
230 <binding label="Q" />
231 </modifiers>
232 </binding>156 </binding>
233 </key>157 </key>
234 <key>158 <key>
235 <binding label="w">159 <binding label="w">
236 <modifiers keys="shift">
237 <binding label="W" />
238 </modifiers>
239 </binding>160 </binding>
240 </key>161 </key>
241 <key>162 <key>
242 <binding label="e">163 <binding label="e">
243 <modifiers keys="shift">
244 <binding label="E" />
245 </modifiers>
246 </binding>164 </binding>
247 </key>165 </key>
248 <key>166 <key>
249 <binding label="r">167 <binding label="r">
250 <modifiers keys="shift">
251 <binding label="R" />
252 </modifiers>
253 </binding>168 </binding>
254 </key>169 </key>
255 <key>170 <key>
256 <binding label="t">171 <binding label="t">
257 <modifiers keys="shift">
258 <binding label="T" />
259 </modifiers>
260 </binding>172 </binding>
261 </key>173 </key>
262 <key>174 <key>
263 <binding label="y">175 <binding label="y">
264 <modifiers keys="shift">
265 <binding label="Y" />
266 </modifiers>
267 </binding>176 </binding>
268 </key>177 </key>
269 <key>178 <key>
270 <binding label="u">179 <binding label="u">
271 <modifiers keys="shift">
272 <binding label="U" />
273 </modifiers>
274 </binding>180 </binding>
275 </key>181 </key>
276 <key>182 <key>
277 <binding label="i">183 <binding label="i">
278 <modifiers keys="shift">
279 <binding label="I" />
280 </modifiers>
281 </binding>184 </binding>
282 </key>185 </key>
283 <key>186 <key>
284 <binding label="o">187 <binding label="o">
285 <modifiers keys="shift">
286 <binding label="O" />
287 </modifiers>
288 </binding>188 </binding>
289 </key>189 </key>
290 <key>190 <key>
291 <binding label="p">191 <binding label="p">
292 <modifiers keys="shift">
293 <binding label="P" />
294 </modifiers>
295 </binding>192 </binding>
296 </key>193 </key>
297 </row>194 </row>
@@ -299,65 +196,38 @@
299 <spacer />196 <spacer />
300 <key>197 <key>
301 <binding label="a">198 <binding label="a">
302 <modifiers keys="shift">
303 <binding label="A" />
304 </modifiers>
305 </binding>199 </binding>
306 </key>200 </key>
307 <key>201 <key>
308 <binding label="s">202 <binding label="s">
309 <modifiers keys="shift">
310 <binding label="S" />
311 </modifiers>
312 </binding>203 </binding>
313 </key>204 </key>
314 <key>205 <key>
315 <binding label="d">206 <binding label="d">
316 <modifiers keys="shift">
317 <binding label="D" />
318 </modifiers>
319 </binding>207 </binding>
320 </key>208 </key>
321 <key>209 <key>
322 <binding label="f">210 <binding label="f">
323 <modifiers keys="shift">
324 <binding label="F" />
325 </modifiers>
326 </binding>211 </binding>
327 </key>212 </key>
328 <key>213 <key>
329 <binding label="g">214 <binding label="g">
330 <modifiers keys="shift">
331 <binding label="G" />
332 </modifiers>
333 </binding>215 </binding>
334 </key>216 </key>
335 <key>217 <key>
336 <binding label="h">218 <binding label="h">
337 <modifiers keys="shift">
338 <binding label="H" />
339 </modifiers>
340 </binding>219 </binding>
341 </key>220 </key>
342 <key>221 <key>
343 <binding label="j">222 <binding label="j">
344 <modifiers keys="shift">
345 <binding label="J" />
346 </modifiers>
347 </binding>223 </binding>
348 </key>224 </key>
349 <key>225 <key>
350 <binding label="k">226 <binding label="k">
351 <modifiers keys="shift">
352 <binding label="K" />
353 </modifiers>
354 </binding>227 </binding>
355 </key>228 </key>
356 <key>229 <key>
357 <binding label="l">230 <binding label="l">
358 <modifiers keys="shift">
359 <binding label="L" />
360 </modifiers>
361 </binding>231 </binding>
362 </key>232 </key>
363 <spacer />233 <spacer />
@@ -369,73 +239,53 @@
369 <spacer />239 <spacer />
370 <key>240 <key>
371 <binding label="z">241 <binding label="z">
372 <modifiers keys="shift">
373 <binding label="Z" />
374 </modifiers>
375 </binding>242 </binding>
376 </key>243 </key>
377 <key>244 <key>
378 <binding label="x">245 <binding label="x">
379 <modifiers keys="shift">
380 <binding label="X" />
381 </modifiers>
382 </binding>246 </binding>
383 </key>247 </key>
384 <key>248 <key>
385 <binding label="c">249 <binding label="c">
386 <modifiers keys="shift">
387 <binding label="C" />
388 </modifiers>
389 </binding>250 </binding>
390 </key>251 </key>
391 <key>252 <key>
392 <binding label="v">253 <binding label="v">
393 <modifiers keys="shift">
394 <binding label="V" />
395 </modifiers>
396 </binding>254 </binding>
397 </key>255 </key>
398 <key>256 <key>
399 <binding label="b">257 <binding label="b">
400 <modifiers keys="shift">
401 <binding label="B" />
402 </modifiers>
403 </binding>258 </binding>
404 </key>259 </key>
405 <key>260 <key>
406 <binding label="n">261 <binding label="n">
407 <modifiers keys="shift">
408 <binding label="N" />
409 </modifiers>
410 </binding>262 </binding>
411 </key>263 </key>
412 <key>264 <key>
413 <binding label="m">265 <binding label="m">
414 <modifiers keys="shift">
415 <binding label="M" />
416 </modifiers>
417 </binding>266 </binding>
418 </key>267 </key>
419 <spacer />268 <spacer />
420 <key style="special" width="large">269 <key style="special" width="large">
421 <binding action="backspace" label="" />270 <binding action="backspace" label="" />
422 </key>271 </key>
272 <spacer />
423 </row>273 </row>
424 <row>274 <row>
425 <key style="special" width="x-large">275 <key style="special" width="large">
426 <binding action="sym" label="符号" />276 <binding action="sym" label="符号" />
427 </key>277 </key>
428 <key id="emailUrlKey">278 <key id="emailUrlKey" width="small">
429 <binding label="," />279 <binding label="," />
430 </key>280 </key>
431 <key width="stretched">281 <key width="xx-large">
432 <binding action="space" label="" />282 <binding action="space" label="" />
433 </key>283 </key>
434 <key id="emailUrlDotKey">284 <key id="emailUrlDotKey" width="small">
435 <binding label="。" />285 <binding label="。" />
436 </key>286 </key>
437 <key id="actionKey" style="special" width="x-large">287 <key id="actionKey" style="special" width="x-large">
438 <binding action="compose" label="输入" />288 <binding action="return" label="输入" />
439 </key>289 </key>
440 </row>290 </row>
441 </section>291 </section>
442292
=== modified file 'maliit-keyboard/lib/lib.pro'
--- maliit-keyboard/lib/lib.pro 2013-04-11 06:57:11 +0000
+++ maliit-keyboard/lib/lib.pro 2013-06-17 15:53:36 +0000
@@ -6,6 +6,11 @@
6QT += core gui quick6QT += core gui quick
7CONFIG += staticlib7CONFIG += staticlib
88
9CONFIG += link_pkgconfig
10PKGCONFIG += glib-2.0
11PKGCONFIG += libpinyin
12LIBS += libpinyin
13
9include(models/models.pri)14include(models/models.pri)
10include(logic/logic.pri)15include(logic/logic.pri)
11include(parser/parser.pri)16include(parser/parser.pri)
1217
=== added file 'maliit-keyboard/lib/logic/chineselanguagefeatures.cpp'
--- maliit-keyboard/lib/logic/chineselanguagefeatures.cpp 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/lib/logic/chineselanguagefeatures.cpp 2013-06-17 15:53:36 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "chineselanguagefeatures.h"
18
19namespace MaliitKeyboard {
20namespace Logic {
21
22ChineseLanguageFeatures::ChineseLanguageFeatures(QObject *parent) :
23 AbstractLanguageFeatures(parent)
24{
25}
26
27ChineseLanguageFeatures::~ChineseLanguageFeatures()
28{
29}
30
31bool ChineseLanguageFeatures::activateAutoCaps(const QString &preedit) const
32{
33 return false;
34}
35
36QString ChineseLanguageFeatures::appendixForReplacedPreedit(const QString &preedit) const
37{
38 return "";
39}
40
41} // namespace Logic
42} // namespace MaliitKeyboard
043
=== added file 'maliit-keyboard/lib/logic/chineselanguagefeatures.h'
--- maliit-keyboard/lib/logic/chineselanguagefeatures.h 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/lib/logic/chineselanguagefeatures.h 2013-06-17 15:53:36 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef CHINESELANGUAGEFEATURES_H
18#define CHINESELANGUAGEFEATURES_H
19
20#include "abstractlanguagefeatures.h"
21
22namespace MaliitKeyboard {
23namespace Logic {
24
25class ChineseLanguageFeatures : public AbstractLanguageFeatures
26{
27 Q_OBJECT
28public:
29 explicit ChineseLanguageFeatures(QObject *parent = 0);
30 virtual ~ChineseLanguageFeatures();
31
32 virtual bool activateAutoCaps(const QString &preedit) const;
33 virtual QString appendixForReplacedPreedit(const QString &preedit) const;
34};
35
36} // namespace Logic
37} // namespace MaliitKeyboard
38
39#endif // CHINESELANGUAGEFEATURES_H
040
=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.cpp'
--- maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-06-05 13:00:26 +0000
+++ maliit-keyboard/lib/logic/dynamiclayout.cpp 2013-06-17 15:53:36 +0000
@@ -1,4 +1,18 @@
11/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
216
3#include "dynamiclayout.h"17#include "dynamiclayout.h"
4#include "dynamiclayout_p.h"18#include "dynamiclayout_p.h"
519
=== modified file 'maliit-keyboard/lib/logic/dynamiclayout.h'
--- maliit-keyboard/lib/logic/dynamiclayout.h 2013-06-05 13:00:26 +0000
+++ maliit-keyboard/lib/logic/dynamiclayout.h 2013-06-17 15:53:36 +0000
@@ -1,3 +1,19 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
1#ifndef DYNAMICLAYOUT_H17#ifndef DYNAMICLAYOUT_H
2#define DYNAMICLAYOUT_H18#define DYNAMICLAYOUT_H
319
420
=== modified file 'maliit-keyboard/lib/logic/eventhandler.cpp'
--- maliit-keyboard/lib/logic/eventhandler.cpp 2013-05-29 09:54:04 +0000
+++ maliit-keyboard/lib/logic/eventhandler.cpp 2013-06-17 15:53:36 +0000
@@ -206,4 +206,11 @@
206 Q_EMIT wordCandidateReleased(candidate);206 Q_EMIT wordCandidateReleased(candidate);
207}207}
208208
209void EventHandler::onLanguageChangeRequested(QString languageId)
210{
211 Q_D(EventHandler);
212
213 d->updater->setActiveKeyboardId(languageId);
214}
215
209}} // namespace Logic, MaliitKeyboard216}} // namespace Logic, MaliitKeyboard
210217
=== modified file 'maliit-keyboard/lib/logic/eventhandler.h'
--- maliit-keyboard/lib/logic/eventhandler.h 2013-05-24 11:16:27 +0000
+++ maliit-keyboard/lib/logic/eventhandler.h 2013-06-17 15:53:36 +0000
@@ -73,6 +73,7 @@
7373
74 Q_INVOKABLE void onWordCandidatePressed(QString word);74 Q_INVOKABLE void onWordCandidatePressed(QString word);
75 Q_INVOKABLE void onWordCandidateReleased(QString word);75 Q_INVOKABLE void onWordCandidateReleased(QString word);
76 Q_INVOKABLE void onLanguageChangeRequested(QString languageId);
7677
77 // Key signals:78 // Key signals:
78 Q_SIGNAL void keyPressed(const Key &key);79 Q_SIGNAL void keyPressed(const Key &key);
@@ -84,6 +85,8 @@
84 Q_SIGNAL void wordCandidatePressed(const WordCandidate &candidate);85 Q_SIGNAL void wordCandidatePressed(const WordCandidate &candidate);
85 Q_SIGNAL void wordCandidateReleased(const WordCandidate &candidate);86 Q_SIGNAL void wordCandidateReleased(const WordCandidate &candidate);
8687
88 Q_SIGNAL void languageChangeRequested(QString languageId);
89
87private:90private:
88 const QScopedPointer<EventHandlerPrivate> d_ptr;91 const QScopedPointer<EventHandlerPrivate> d_ptr;
89};92};
9093
=== modified file 'maliit-keyboard/lib/logic/layoutupdater.cpp'
--- maliit-keyboard/lib/logic/layoutupdater.cpp 2013-05-29 15:51:40 +0000
+++ maliit-keyboard/lib/logic/layoutupdater.cpp 2013-06-17 15:53:36 +0000
@@ -301,6 +301,7 @@
301{301{
302 Q_D(LayoutUpdater);302 Q_D(LayoutUpdater);
303 d->loader.setActiveId(id);303 d->loader.setActiveId(id);
304 Q_EMIT languageChanged(id);
304}305}
305306
306QString LayoutUpdater::keyboardTitle(const QString &id) const307QString LayoutUpdater::keyboardTitle(const QString &id) const
307308
=== modified file 'maliit-keyboard/lib/logic/layoutupdater.h'
--- maliit-keyboard/lib/logic/layoutupdater.h 2013-03-22 16:40:29 +0000
+++ maliit-keyboard/lib/logic/layoutupdater.h 2013-06-17 15:53:36 +0000
@@ -104,6 +104,7 @@
104 Q_SIGNAL void addToUserDictionary();104 Q_SIGNAL void addToUserDictionary();
105105
106 Q_SIGNAL void keyboardTitleChanged(const QString &title);106 Q_SIGNAL void keyboardTitleChanged(const QString &title);
107 Q_SIGNAL void languageChanged(const QString& languageId);
107108
108private:109private:
109 Q_SIGNAL void shiftPressed();110 Q_SIGNAL void shiftPressed();
110111
=== modified file 'maliit-keyboard/lib/logic/logic.pri'
--- maliit-keyboard/lib/logic/logic.pri 2013-06-03 12:20:12 +0000
+++ maliit-keyboard/lib/logic/logic.pri 2013-06-17 15:53:36 +0000
@@ -13,7 +13,9 @@
13 logic/abstractlanguagefeatures.h \13 logic/abstractlanguagefeatures.h \
14 logic/languagefeatures.h \14 logic/languagefeatures.h \
15 logic/eventhandler.h \15 logic/eventhandler.h \
16 logic/dynamiclayout.h16 logic/dynamiclayout.h \
17 logic/pinyinadapter.h \
18 logic/chineselanguagefeatures.h
1719
18SOURCES += \20SOURCES += \
19 logic/hitlogic.cpp \21 logic/hitlogic.cpp \
@@ -28,7 +30,9 @@
28 logic/abstractlanguagefeatures.cpp \30 logic/abstractlanguagefeatures.cpp \
29 logic/languagefeatures.cpp \31 logic/languagefeatures.cpp \
30 logic/eventhandler.cpp \32 logic/eventhandler.cpp \
31 logic/dynamiclayout.cpp33 logic/dynamiclayout.cpp \
34 logic/pinyinadapter.cpp \
35 logic/chineselanguagefeatures.cpp
3236
33DEFINES += HUNSPELL_DICT_PATH=\\\"$$HUNSPELL_DICT_PATH\\\"37DEFINES += HUNSPELL_DICT_PATH=\\\"$$HUNSPELL_DICT_PATH\\\"
3438
3539
=== added file 'maliit-keyboard/lib/logic/pinyinadapter.cpp'
--- maliit-keyboard/lib/logic/pinyinadapter.cpp 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/lib/logic/pinyinadapter.cpp 2013-06-17 15:53:36 +0000
@@ -0,0 +1,103 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifdef HAVE_PINYIN
18
19#include "pinyinadapter.h"
20
21#include <iostream>
22
23#include <iconv.h>
24#include <string>
25#include <string.h>
26
27#include <QDebug>
28
29PinyinAdapter::PinyinAdapter(QObject *parent) :
30 QObject(parent)
31{
32 m_context = pinyin_init("/usr/lib/arm-linux-gnueabihf/libpinyin/data/", ".");
33 m_instance = pinyin_alloc_instance(m_context);
34
35 pinyin_set_options(m_context, IS_PINYIN | USE_DIVIDED_TABLE | USE_RESPLIT_TABLE);
36}
37
38PinyinAdapter::~PinyinAdapter()
39{
40 g_array_free(m_array, TRUE);
41 pinyin_free_instance(m_instance);
42 pinyin_fini(m_context);
43}
44
45QString PinyinAdapter::parse(const QString& string)
46{
47 pinyin_parse_more_full_pinyins(m_instance, string.toLatin1().data());
48
49 int cursor = 0;
50
51#ifdef PINYIN_DEBUG
52 for (int i = 0; i < m_instance->m_pinyin_keys->len; i ++)
53 {
54 PinyinKey* pykey = &g_array_index(m_instance->m_pinyin_keys, PinyinKey, i);
55 gchar* py = pykey->get_pinyin_string();
56 std::cout << py << " ";
57 g_free(py);
58 }
59 std::cout << std::endl;
60#endif
61
62 m_array = g_array_new(FALSE, FALSE, sizeof(lookup_candidate_t));
63 pinyin_get_candidates(m_instance, 0, m_array);
64
65 pinyin_guess_sentence(m_instance);
66
67 char* sentence = NULL;
68 pinyin_get_sentence(m_instance, &sentence);
69
70 candidates.clear();
71 for (int i = 0 ; i < m_array->len; i ++ )
72 {
73 lookup_candidate_t token = g_array_index(m_array, lookup_candidate_t, i);
74 char* word = NULL;
75 // Translate the token to utf-8 phrase.
76 pinyin_translate_token(m_instance, token.m_token, &word);
77 if (word) {
78 candidates.append(QString(word));
79 }
80 g_free(word);
81 }
82
83 QString unicode(sentence);
84 g_free(sentence);
85 return unicode;
86}
87
88QStringList PinyinAdapter::getWordCandidates() const
89{
90 return candidates;
91}
92
93void PinyinAdapter::wordCandidateSelected(const QString& word)
94{
95 pinyin_choose_candidate(m_instance, 0, &g_array_index(m_array, lookup_candidate_t, 1));
96}
97
98void PinyinAdapter::reset()
99{
100 pinyin_reset(m_instance);
101}
102
103#endif
0104
=== added file 'maliit-keyboard/lib/logic/pinyinadapter.h'
--- maliit-keyboard/lib/logic/pinyinadapter.h 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/lib/logic/pinyinadapter.h 2013-06-17 15:53:36 +0000
@@ -0,0 +1,50 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef PINYINADAPTER_H
18#define PINYINADAPTER_H
19
20#ifdef HAVE_PINYIN
21
22#include <QObject>
23#include <QStringList>
24
25#include "pinyin.h"
26
27class PinyinAdapter : public QObject
28{
29 Q_OBJECT
30
31 QStringList candidates;
32
33 pinyin_context_t* m_context;
34 pinyin_instance_t* m_instance;
35
36 GArray* m_array;
37
38public:
39 explicit PinyinAdapter(QObject *parent = 0);
40 ~PinyinAdapter();
41
42 QString parse(const QString& string);
43 QStringList getWordCandidates() const;
44 void wordCandidateSelected(const QString& word);
45 void reset();
46};
47
48#endif
49
50#endif // PINYINADAPTER_H
051
=== modified file 'maliit-keyboard/lib/logic/wordengine.cpp'
--- maliit-keyboard/lib/logic/wordengine.cpp 2012-07-25 09:49:30 +0000
+++ maliit-keyboard/lib/logic/wordengine.cpp 2013-06-17 15:53:36 +0000
@@ -36,6 +36,11 @@
36#include <presage.h>36#include <presage.h>
37#endif37#endif
3838
39#ifdef HAVE_PINYIN
40#include "pinyinadapter.h"
41#include <iostream>
42#endif
43
39namespace MaliitKeyboard {44namespace MaliitKeyboard {
40namespace Logic {45namespace Logic {
4146
@@ -105,6 +110,14 @@
105class WordEnginePrivate110class WordEnginePrivate
106{111{
107public:112public:
113
114 enum PredictiveBackend {
115 PresageBackend = 1,
116 PinyinBackend
117 };
118
119 PredictiveBackend predictiveBackend;
120
108 SpellChecker spell_checker;121 SpellChecker spell_checker;
109#ifdef HAVE_PRESAGE122#ifdef HAVE_PRESAGE
110 std::string candidates_context;123 std::string candidates_context;
@@ -112,11 +125,16 @@
112 Presage presage;125 Presage presage;
113#endif126#endif
114127
128 // TODO there is too many ifdef in this class
129#ifdef HAVE_PINYIN
130 PinyinAdapter* pinyinAdapter;
131#endif
115 explicit WordEnginePrivate();132 explicit WordEnginePrivate();
116};133};
117134
118WordEnginePrivate::WordEnginePrivate()135WordEnginePrivate::WordEnginePrivate()
119 : spell_checker()136 : predictiveBackend(PresageBackend)
137 , spell_checker()
120#ifdef HAVE_PRESAGE138#ifdef HAVE_PRESAGE
121 , candidates_context()139 , candidates_context()
122 , presage_candidates(CandidatesCallback(candidates_context))140 , presage_candidates(CandidatesCallback(candidates_context))
@@ -128,6 +146,10 @@
128 presage.config("Presage.Selector.SUGGESTIONS", "6");146 presage.config("Presage.Selector.SUGGESTIONS", "6");
129 presage.config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");147 presage.config("Presage.Selector.REPEAT_SUGGESTIONS", "yes");
130#endif148#endif
149
150#ifdef HAVE_PINYIN
151 pinyinAdapter = new PinyinAdapter;
152#endif
131}153}
132154
133155
@@ -159,6 +181,15 @@
159 AbstractWordEngine::setEnabled(enabled);181 AbstractWordEngine::setEnabled(enabled);
160}182}
161183
184void WordEngine::onWordCandidateSelected(QString word)
185{
186 Q_D(WordEngine);
187
188#ifdef HAVE_PINYIN
189 if (d->predictiveBackend == WordEnginePrivate::PinyinBackend)
190 d->pinyinAdapter->wordCandidateSelected(word);
191#endif
192}
162193
163WordCandidateList WordEngine::fetchCandidates(Model::Text *text)194WordCandidateList WordEngine::fetchCandidates(Model::Text *text)
164{195{
@@ -168,19 +199,33 @@
168 const QString &preedit(text->preedit());199 const QString &preedit(text->preedit());
169 const bool is_preedit_capitalized(not preedit.isEmpty() && preedit.at(0).isUpper());200 const bool is_preedit_capitalized(not preedit.isEmpty() && preedit.at(0).isUpper());
170201
202#ifdef HAVE_PINYIN
203 if (d->predictiveBackend == WordEnginePrivate::PinyinBackend) {
204 QString sentence = d->pinyinAdapter->parse(preedit);
205
206 QStringList suggestions = d->pinyinAdapter->getWordCandidates();
207
208 Q_FOREACH(const QString &suggestion, suggestions) {
209 appendToCandidates(&candidates, WordCandidate::SourcePrediction, suggestion, is_preedit_capitalized);
210 }
211 }
212#endif
213
171#ifdef HAVE_PRESAGE214#ifdef HAVE_PRESAGE
172 const QString &context = (text->surroundingLeft() + preedit);215 if (d->predictiveBackend == WordEnginePrivate::PresageBackend) {
173 d->candidates_context = context.toStdString();216 const QString &context = (text->surroundingLeft() + preedit);
174 const std::vector<std::string> predictions = d->presage.predict();217 d->candidates_context = context.toStdString();
218 const std::vector<std::string> predictions = d->presage.predict();
175219
176 // TODO: Fine-tune presage behaviour to also perform error correction, not just word prediction.220 // TODO: Fine-tune presage behaviour to also perform error correction, not just word prediction.
177 if (not context.isEmpty()) {221 if (not context.isEmpty()) {
178 // FIXME: max_candidates should come from style, too:222 // FIXME: max_candidates should come from style, too:
179 const static unsigned int max_candidates = 7;223 const static unsigned int max_candidates = 7;
180 const int count(qMin<int>(predictions.size(), max_candidates));224 const int count(qMin<int>(predictions.size(), max_candidates));
181 for (int index = 0; index < count; ++index) {225 for (int index = 0; index < count; ++index) {
182 appendToCandidates(&candidates, WordCandidate::SourcePrediction, QString::fromStdString(predictions.at(index)),226 appendToCandidates(&candidates, WordCandidate::SourcePrediction, QString::fromStdString(predictions.at(index)),
183 is_preedit_capitalized);227 is_preedit_capitalized);
228 }
184 }229 }
185 }230 }
186#endif231#endif
@@ -210,4 +255,14 @@
210 d->spell_checker.addToUserWordlist(word);255 d->spell_checker.addToUserWordlist(word);
211}256}
212257
258void WordEngine::onLanguageChanged(const QString &languageId)
259{
260 Q_D(WordEngine);
261
262 if (languageId == "zh_cn_pinyin")
263 d->predictiveBackend = WordEnginePrivate::PinyinBackend;
264 else
265 d->predictiveBackend = WordEnginePrivate::PresageBackend;
266}
267
213}} // namespace Logic, MaliitKeyboard268}} // namespace Logic, MaliitKeyboard
214269
=== modified file 'maliit-keyboard/lib/logic/wordengine.h'
--- maliit-keyboard/lib/logic/wordengine.h 2012-07-25 09:49:30 +0000
+++ maliit-keyboard/lib/logic/wordengine.h 2013-06-17 15:53:36 +0000
@@ -59,6 +59,9 @@
59 virtual void addToUserDictionary(const QString &word);59 virtual void addToUserDictionary(const QString &word);
60 //! \reimp_end60 //! \reimp_end
6161
62 Q_SLOT void onWordCandidateSelected(QString word);
63 Q_SLOT void onLanguageChanged(const QString& languageId);
64
62private:65private:
63 //! \reimp66 //! \reimp
64 virtual WordCandidateList fetchCandidates(Model::Text *text);67 virtual WordCandidateList fetchCandidates(Model::Text *text);
6568
=== modified file 'maliit-keyboard/plugin/editor.cpp'
--- maliit-keyboard/plugin/editor.cpp 2012-08-06 12:58:44 +0000
+++ maliit-keyboard/plugin/editor.cpp 2013-06-17 15:53:36 +0000
@@ -36,6 +36,8 @@
36#include <QTimer>36#include <QTimer>
37#include <maliit/namespace.h>37#include <maliit/namespace.h>
3838
39#include "logic/abstractlanguagefeatures.h"
40
39namespace MaliitKeyboard {41namespace MaliitKeyboard {
4042
41Editor::Editor(const EditorOptions &options,43Editor::Editor(const EditorOptions &options,
4244
=== modified file 'maliit-keyboard/plugin/inputmethod.cpp'
--- maliit-keyboard/plugin/inputmethod.cpp 2013-06-06 16:47:16 +0000
+++ maliit-keyboard/plugin/inputmethod.cpp 2013-06-17 15:53:36 +0000
@@ -225,6 +225,15 @@
225 QObject::connect(&editor, SIGNAL(preeditEnabledChanged(bool)),225 QObject::connect(&editor, SIGNAL(preeditEnabledChanged(bool)),
226 &layout.updater, SLOT(setWordRibbonVisible(bool)));226 &layout.updater, SLOT(setWordRibbonVisible(bool)));
227227
228 QObject::connect(&layout.updater, SIGNAL(wordCandidateSelected(QString)),
229 editor.wordEngine(), SLOT(onWordCandidateSelected(QString)));
230
231 QObject::connect(&layout.updater, SIGNAL(languageChanged(QString)),
232 editor.wordEngine(), SLOT(onLanguageChanged(QString)));
233
234 QObject::connect(&layout.updater, SIGNAL(languageChanged(QString)),
235 &editor, SLOT(onLanguageChanged(const QString&)));
236
228 // just for now237 // just for now
229 layout.updater.setWordRibbonVisible(true);238 layout.updater.setWordRibbonVisible(true);
230239
@@ -441,6 +450,9 @@
441 connect(d->surface_factory, SIGNAL(screenSizeChanged(QSize)),450 connect(d->surface_factory, SIGNAL(screenSizeChanged(QSize)),
442 this, SLOT(onScreenSizeChange(QSize)));451 this, SLOT(onScreenSizeChange(QSize)));
443452
453 connect(&d->editor, SIGNAL(layoutMenuRequested()),
454 this, SLOT(onLayoutMenuRequested()));
455
444 connect(this, SIGNAL(wordEngineEnabledChanged(bool)), uiConst, SLOT(onWordEngineSettingsChanged(bool)));456 connect(this, SIGNAL(wordEngineEnabledChanged(bool)), uiConst, SLOT(onWordEngineSettingsChanged(bool)));
445457
446 registerStyleSetting(host);458 registerStyleSetting(host);
@@ -913,4 +925,10 @@
913 d->updateKeyboardOrientation();925 d->updateKeyboardOrientation();
914}926}
915927
928void InputMethod::onLayoutMenuRequested()
929{
930 Q_D(InputMethod);
931 d->qmlRootItem->setProperty("languageMenuVisible", true);
932}
933
916} // namespace MaliitKeyboard934} // namespace MaliitKeyboard
917935
=== modified file 'maliit-keyboard/plugin/inputmethod.h'
--- maliit-keyboard/plugin/inputmethod.h 2013-06-03 15:41:05 +0000
+++ maliit-keyboard/plugin/inputmethod.h 2013-06-17 15:53:36 +0000
@@ -104,6 +104,8 @@
104 Q_SLOT void onMagnifierLayoutOriginChanged(const QPoint &origin);104 Q_SLOT void onMagnifierLayoutOriginChanged(const QPoint &origin);
105#endif105#endif
106106
107 Q_SLOT void onLayoutMenuRequested();
108
107 Q_SLOT void onHideAnimationFinished();109 Q_SLOT void onHideAnimationFinished();
108 Q_SIGNAL void wordEngineEnabledChanged(bool wordEngineEnabled);110 Q_SIGNAL void wordEngineEnabledChanged(bool wordEngineEnabled);
109111
110112
=== modified file 'maliit-keyboard/qml/Keyboard.qml'
--- maliit-keyboard/qml/Keyboard.qml 2013-06-06 16:47:16 +0000
+++ maliit-keyboard/qml/Keyboard.qml 2013-06-17 15:53:36 +0000
@@ -45,6 +45,8 @@
45 property int pressedKeyIndex: -1;45 property int pressedKeyIndex: -1;
46 property Item pressedKey;46 property Item pressedKey;
4747
48 property bool languageMenuVisible: false
49
48 RotationHelper {50 RotationHelper {
4951
50 Connections {52 Connections {
@@ -55,6 +57,17 @@
55 }57 }
56 }58 }
5759
60 LanguageMenu {
61 id: languageMenu
62
63 visible: languageMenuVisible
64 anchors.centerIn: parent
65 width: 500
66 height: 600
67
68 z: 20
69 }
70
58 MouseArea {71 MouseArea {
59 id: keyboardSurface72 id: keyboardSurface
60 property int jumpBackThreshold: 17073 property int jumpBackThreshold: 170
6174
=== added file 'maliit-keyboard/qml/LanguageMenu.qml'
--- maliit-keyboard/qml/LanguageMenu.qml 1970-01-01 00:00:00 +0000
+++ maliit-keyboard/qml/LanguageMenu.qml 2013-06-17 15:53:36 +0000
@@ -0,0 +1,53 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1 as ListItem
20
21Item {
22
23 Rectangle {
24 anchors.fill: parent
25 color: "lightGray"
26 }
27
28 // tempor., will come from settings
29 ListModel {
30 id: availableLanguagesModel
31 ListElement { language: "English - US"; languageId: "en_us"; }
32 ListElement { language: "English - UK"; languageId: "en_gb"; }
33 ListElement { language: "Chinese - Pinyin"; languageId: "zh_cn_pinyin"; }
34 ListElement { language: "Spanish"; languageId: "es"; }
35 ListElement { language: "German"; languageId: "de"; }
36 }
37
38 ListView {
39 id: menuList
40 anchors.fill: parent
41 interactive: false
42
43 model: availableLanguagesModel
44
45 delegate: ListItem.Standard {
46 text: language
47 onClicked: {
48 event_handler.onLanguageChangeRequested(languageId);
49 canvas.languageMenuVisible = false;
50 }
51 }
52 }
53}
054
=== modified file 'maliit-keyboard/qml/qml.pro'
--- maliit-keyboard/qml/qml.pro 2013-06-05 14:58:50 +0000
+++ maliit-keyboard/qml/qml.pro 2013-06-17 15:53:36 +0000
@@ -14,6 +14,7 @@
14 Keyboard.qml \14 Keyboard.qml \
15 maliit-ui-constants.qml \15 maliit-ui-constants.qml \
16 RotationHelper.qml \16 RotationHelper.qml \
17 WordRibbon.qml17 WordRibbon.qml \
18 LanguageMenu.qml
18 Popper.qml19 Popper.qml
1920
2021
=== modified file 'maliit-keyboard/view/abstracttexteditor.cpp'
--- maliit-keyboard/view/abstracttexteditor.cpp 2012-11-21 15:19:50 +0000
+++ maliit-keyboard/view/abstracttexteditor.cpp 2013-06-17 15:53:36 +0000
@@ -32,6 +32,9 @@
32#include "abstracttexteditor.h"32#include "abstracttexteditor.h"
33#include "models/wordribbon.h"33#include "models/wordribbon.h"
3434
35#include "logic/chineselanguagefeatures.h"
36#include "logic/languagefeatures.h"
37
35namespace MaliitKeyboard {38namespace MaliitKeyboard {
3639
37//! \class EditorOptions40//! \class EditorOptions
@@ -490,6 +493,10 @@
490 Q_EMIT rightLayoutSelected();493 Q_EMIT rightLayoutSelected();
491 break;494 break;
492495
496 case Key::ActionLayoutMenu:
497 Q_EMIT layoutMenuRequested();
498 break;
499
493 default:500 default:
494 break;501 break;
495 }502 }
@@ -752,4 +759,17 @@
752 }759 }
753}760}
754761
762//! \brief sets language features
763//! \param language id as string (as found in settings file)
764//!
765void AbstractTextEditor::onLanguageChanged(const QString& languageId)
766{
767 Q_D(AbstractTextEditor);
768
769 if (languageId == "zh_cn_pinyin")
770 d->language_features.reset(new Logic::ChineseLanguageFeatures);
771 else
772 d->language_features.reset(new Logic::LanguageFeatures);
773}
774
755} // namespace MaliitKeyboard775} // namespace MaliitKeyboard
756776
=== modified file 'maliit-keyboard/view/abstracttexteditor.h'
--- maliit-keyboard/view/abstracttexteditor.h 2012-11-21 15:19:50 +0000
+++ maliit-keyboard/view/abstracttexteditor.h 2013-06-17 15:53:36 +0000
@@ -138,6 +138,9 @@
138 Q_SIGNAL void autoCapsActivated();138 Q_SIGNAL void autoCapsActivated();
139 Q_SIGNAL void leftLayoutSelected();139 Q_SIGNAL void leftLayoutSelected();
140 Q_SIGNAL void rightLayoutSelected();140 Q_SIGNAL void rightLayoutSelected();
141 Q_SIGNAL void layoutMenuRequested();
142
143 Q_SLOT virtual void onLanguageChanged(const QString& languageId);
141144
142private:145private:
143 const QScopedPointer<AbstractTextEditorPrivate> d_ptr;146 const QScopedPointer<AbstractTextEditorPrivate> d_ptr;
144147
=== modified file 'maliit-keyboard/word-prediction.pri'
--- maliit-keyboard/word-prediction.pri 2012-07-23 09:40:25 +0000
+++ maliit-keyboard/word-prediction.pri 2013-06-17 15:53:36 +0000
@@ -13,3 +13,10 @@
13disable-preedit|!enable-presage:!enable-hunspell {13disable-preedit|!enable-presage:!enable-hunspell {
14 DEFINES += DISABLE_PREEDIT14 DEFINES += DISABLE_PREEDIT
15}15}
16
17enable-pinyin {
18 CONFIG += link_pkgconfig
19 PKGCONFIG += glib-2.0
20 PKGCONFIG += libpinyin
21 DEFINES += HAVE_PINYIN
22}
1623
=== modified file 'maliit-plugins.pro'
--- maliit-plugins.pro 2013-01-30 19:53:34 +0000
+++ maliit-plugins.pro 2013-06-17 15:53:36 +0000
@@ -13,6 +13,7 @@
13 \\n\\t enable-presage: Use presage to calculate word candidates (maliit-keyboard-plugin only) \13 \\n\\t enable-presage: Use presage to calculate word candidates (maliit-keyboard-plugin only) \
14 \\n\\t enable-hunspell: Use hunspell for error correction (maliit-keyboard-plugin only) \14 \\n\\t enable-hunspell: Use hunspell for error correction (maliit-keyboard-plugin only) \
15 \\n\\t disable-preedit: Always commit characters and never use preedit (maliit-keyboard-plugin only) \15 \\n\\t disable-preedit: Always commit characters and never use preedit (maliit-keyboard-plugin only) \
16 \\n\\t enable-pinyin: Use libpinyin as chinese input method \
16 \\n\\t enable-qt-mobility: Enable use of QtMobility (enables sound and haptic feedback) \17 \\n\\t enable-qt-mobility: Enable use of QtMobility (enables sound and haptic feedback) \
17 \\n\\t notests: Do not attempt to build tests \18 \\n\\t notests: Do not attempt to build tests \
18 \\n\\t nodoc: Do not build documentation \19 \\n\\t nodoc: Do not build documentation \
@@ -68,6 +69,10 @@
68 COVERAGE_CONFIG_STRING += CONFIG+=disable-preedit69 COVERAGE_CONFIG_STRING += CONFIG+=disable-preedit
69}70}
7071
72enable-pinyin {
73 COVERAGE_CONFIG_STRING += CONFIG+=enable-pinyin
74}
75
71enable-qt-mobility {76enable-qt-mobility {
72 COVERAGE_CONFIG_STRING += CONFIG+=enable-qt-mobility77 COVERAGE_CONFIG_STRING += CONFIG+=enable-qt-mobility
73}78}

Subscribers

People subscribed via source and target branches