Merge lp:~cosmos-door/ubuntu-keyboard/japanese-keyboard-rebooted into lp:ubuntu-keyboard

Proposed by Mitsuya Shibata
Status: Merged
Approved by: Michael Sheldon
Approved revision: 418
Merged at revision: 447
Proposed branch: lp:~cosmos-door/ubuntu-keyboard/japanese-keyboard-rebooted
Merge into: lp:ubuntu-keyboard
Diff against target: 2321 lines (+1925/-4)
38 files modified
debian/control (+11/-0)
debian/server.conf (+1/-0)
debian/ubuntu-keyboard-japanese.install (+1/-0)
plugins/ja/ja.pro (+9/-0)
plugins/ja/qml/Keyboard_ja.qml (+118/-0)
plugins/ja/qml/Keyboard_ja_email.qml (+121/-0)
plugins/ja/qml/Keyboard_ja_url.qml (+121/-0)
plugins/ja/qml/Keyboard_ja_url_search.qml (+121/-0)
plugins/ja/qml/keys/CommitKey.qml (+40/-0)
plugins/ja/qml/keys/CursorKey.qml (+58/-0)
plugins/ja/qml/keys/DomainKey.qml (+42/-0)
plugins/ja/qml/keys/FlickArea.qml (+79/-0)
plugins/ja/qml/keys/FlickCharKey.qml (+178/-0)
plugins/ja/qml/keys/FlickPop.qml (+70/-0)
plugins/ja/qml/keys/FlickPopKey.qml (+42/-0)
plugins/ja/qml/keys/KanaSwitchKey.qml (+85/-0)
plugins/ja/qml/keys/ModifierKey.qml (+79/-0)
plugins/ja/qml/keys/UndoKey.qml (+25/-0)
plugins/ja/qml/keys/key_constants.js (+31/-0)
plugins/ja/qml/keys/modifier.js (+102/-0)
plugins/ja/qml/qml.pro (+31/-0)
plugins/ja/src/anthyadapter.cpp (+117/-0)
plugins/ja/src/anthyadapter.h (+45/-0)
plugins/ja/src/japaneselanguagefeatures.cpp (+92/-0)
plugins/ja/src/japaneselanguagefeatures.h (+42/-0)
plugins/ja/src/japaneseplugin.cpp (+59/-0)
plugins/ja/src/japaneseplugin.h (+43/-0)
plugins/ja/src/japaneseplugin.json (+7/-0)
plugins/ja/src/src.pro (+39/-0)
plugins/plugins.pro (+1/-0)
qml/keys/languages.js (+1/-0)
src/lib/logic/abstractlanguagefeatures.h (+2/-0)
src/lib/logic/eventhandler.cpp (+2/-0)
src/plugin/inputmethod.cpp (+29/-0)
src/plugin/inputmethod.h (+9/-0)
src/plugin/inputmethod_p.h (+3/-0)
src/view/abstracttexteditor.cpp (+65/-4)
src/view/abstracttexteditor.h (+4/-0)
To merge this branch: bzr merge lp:~cosmos-door/ubuntu-keyboard/japanese-keyboard-rebooted
Reviewer Review Type Date Requested Status
Michael Sheldon (community) Approve
Mitsuya Shibata (community) Needs Resubmitting
Ken VanDine packaging Approve
Review via email: mp+268158@code.launchpad.net

Commit message

Implement Japanese keyboard layout

Description of the change

This is rewrite code to input Japanese from ubuntu-keyboard.

How to try it:

1. install ubuntu-keyboard this branch

2. setup japanese environment and enable japanese input method
    1. launch System Settings and select Language & Text
    2. set "Display language" to "日本語(日本)" (most bottom in list)
    3. set "Keyboard layouts" to "[Ja] 日本語"

3. return to home scope and tap search icon

4. enjoy japanese input!
    - Japanese input method use "Flick input" which is commonly used japanese
      smartphones.
    - please refer following video about how to input.
      http://www.youtube.com/watch?v=pbGdEeHzFnk

Note about this branch:

1. support single kana-kanji conversion only
    - does not support resize segment.

2. publish preedit and cursor_position property to QML
    - Japanese input method use preedit hardly.
    - So needs to edit preedit from QML before commit it.
    - This branch add properties preedit and cursor_position to maliit_input_method.
    - And emit signal by changed this property from abstracttexteditor.
      src/plugin/inputmethod.{h,cpp}
      src/plugin/inputmethod_p.h
      src/view/abstracttexteditor.cpp
      src/view/abstracttexteditor.{h,cpp}
      src/lib/logic/eventhandler.cpp

Thanks!

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 Thanks for updating this, I've only just started reviewing it so there'll be some more comments to come later, but the most immediate issue with this branch is that it doesn't install the japanese plugin's "keys" directory (plugins/ja/qml/keys).

 I've also made a couple of inline comments at locations where it's still using the old relative path imports for the global keys directory, this should now be done as "import keys 1.0" as this we allow the plugin to be installed separately from the rest of maliit in the future (e.g. as part of a custom tarball, or possibly as a click package at some point)

Thanks!

review: Needs Fixing
404. By Mitsuya Shibata

Install customized qml files for Japanese layout.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

> Thanks for updating this, I've only just started reviewing it so there'll be
> some more comments to come later, but the most immediate issue with this
> branch is that it doesn't install the japanese plugin's "keys" directory
> (plugins/ja/qml/keys).

oh, sorry... I fixed qml.pro, it will install plugins/ja/qml/keys too.

> I've also made a couple of inline comments at locations where it's still
> using the old relative path imports for the global keys directory, this should
> now be done as "import keys 1.0" as this we allow the plugin to be installed
> separately from the rest of maliit in the future (e.g. as part of a custom
> tarball, or possibly as a click package at some point)

Changed to "import keys 1.0".

Thank you for your review!

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Looking really good, just a few small things needing fixing:

1) The cursor keys move two characters at a time (it looks like they're moving the cursor on both the press and release events)

2) In the character selection pop-over the characters that aren't currently selected should use the same colour as the selection pop-over on the other keyboard layouts (this is done by setting the opacity to 0.6 when not selected)

3) If touch feedback is enabled in settings then sliding between characters on the selection pop-over should trigger haptic feedback via pressEffect.start() (same as on other keyboard layouts)

4) The copyright year on a lot of the added files is listed as 2012/2013/2014, this should be 2015 since these are new files

5) Is it correct that the URL and email layouts should be a non-Japanese qwerty layout? (If so it might be worth populating the URL key with useful Japanese TLDs like .jp, .co.jp, etc.)

6) Could you add a comment to the modifier.js explaining the purpose of the map and normalize arrays?

review: Needs Fixing
405. By Mitsuya Shibata

fixes copyright year and add some comments

406. By Mitsuya Shibata

fixes double key released for cursor keys

407. By Mitsuya Shibata

set the text opacity to 0.6 when not selected in the selection pop-over

408. By Mitsuya Shibata

trigger haptic feedback on the selection pop-over too.

409. By Mitsuya Shibata

add email/url layout for japanese.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Thank you for more reviewing!

I fixed all of your pointed out. Please check it.

> 1) The cursor keys move two characters at a time (it looks like they're moving
> the cursor on both the press and release events)

Fixed typo (s/Released/Pressed/)

> 2) In the character selection pop-over the characters that aren't currently
> selected should use the same colour as the selection pop-over on the other
> keyboard layouts (this is done by setting the opacity to 0.6 when not
> selected)

Set opacity for unselected Text element.

> 3) If touch feedback is enabled in settings then sliding between characters on
> the selection pop-over should trigger haptic feedback via pressEffect.start()
> (same as on other keyboard layouts)

Add haptic feedback and not audio feedback (same as original extended key).

> 4) The copyright year on a lot of the added files is listed as 2012/2013/2014,
> this should be 2015 since these are new files

Set all 2015.

> 5) Is it correct that the URL and email layouts should be a non-Japanese
> qwerty layout? (If so it might be worth populating the URL key with useful
> Japanese TLDs like .jp, .co.jp, etc.)

Change email/url layout to same as normal Japanese layout.
Commonly used Japanese TLD is ".com" and ".jp".
Indeed ".co.jp" is used too, but doesn't manual typewith frequently as url/email .

Additionally to this, set email/url default layout alphabet instead of kana.

> 6) Could you add a comment to the modifier.js explaining the purpose of the
> map and normalize arrays?

Add comment.

Thanks!

review: Needs Resubmitting
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

Is there any chance to be merged for OTA-8 or OTA-9?

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 Sorry for the delay in replying, I hadn't spotted your updates; I'll try to get it re-reviewed and included for OTA-9

Cheers,
 Mike

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 I've just been re-reviewing this, and it looks great; but I've found one last issue, whereby the cursor keys don't work correctly whilst still in pre-edit. I'm wondering if it might be best to simply call Qt.inputMethod.commit() when pressing the cursor keys?

review: Needs Fixing
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

It looks like the cursor does get moved internally within maliit (so deletions and insertions occur in the correct place) but the visual cursor doesn't move. I think just committing the text prior to moving the cursor would be the simplest solution for this.

410. By Mitsuya Shibata

Merge upstream's changes

411. By Mitsuya Shibata

Switch to Ubuntu.Components 1.3 and QtQuick 2.4

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

I rebased newer ubuntu-keyboard code.

About cursor key:
I think "commit" is just commit current preedit, then clear preedit and predictions.
In this means, a preedit in Japanese should not be cleared by cursor key,
should be moved just cursor position.

Can I move visible cursor position without commit?

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Perhaps I can use cursor_pos_override argument of setPreedit() in src/lib/models/text.h.

However AbstractTextEditor::replacePreedit() uses text->setPreedit() without 2nd argument.
I will try to customize replacePreedit().

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Umm... cursor_pos_override just updates m_cursor_position...
Anyway, when exists preedit, press twice left and insert any character, then update cursor position.
I hope there are any hint in this behaviour.

412. By Mitsuya Shibata

fix moving cursor position in preedit by cursor key

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

Finally fixed cursor key problem in rev412. Could you review it?

IMPORTANT NOTE:
Revision 412 modify code in singleBackspace() in src/view/abstracttexteditor.cpp.
It will affect other language not only Japanese.
I believe this modification does not change behaviours of backspace.

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 The changes appear to have fixed the cursor issue nicely, and I haven't seen any negative effects on other layouts, so that's looking good, great work :).

 Unfortunately I've found one more issue: if an ideographic space character (second function from the normal space) is inserted and then committed without any other characters, all predictions are broken until the user switches to another layout and back (effectively unloading and then reloading the Japanese word engine).

 One other quick question, is it normal in Japanese input methods for the return key to be used for committing pre-edit strings? For all other layouts this is done by the space key. I'm happy to leave it with the return key if that's what most Japanese users would already expect, but otherwise it would be good to keep consistent with other layouts if possible.

Thanks!
 Mike.

review: Needs Fixing
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Actually after a bit of further testing it doesn't appear to be directly related to the ideographic space, it seems it can happen with any string if you type it quickly and the commit (presumably whilst anthy is still processing predictions?)

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Thank you your review!

> quickly typing problem

I can't reproduce yet. Could you tell me any typing sample word (and any apps)?

> enter key

Yes, Japanese users expect return key as "commit preedit".
Additionally, in desktop, space key means "change next candidate of the preedit".
I think return key label should not be changed.

More generally, Japanese input method change label of return key
to "確定" ("commit" in Japanease) if in preedit.
I would like to implement this feature in the future.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hmm... it seems that plugins/ja/src/anthyadapter.cpp isn't reentrant.
I'll check more deeply. Thanks!

413. By Mitsuya Shibata

fix problem with parsePredictionText signal on parse()

If parsePredictionText signal is issued when AnthyAdapter::parse() in
procedure, new preedit is saved to JapanesePlugin::m_nextWord then return back.

When AnthyAdapter::parse() is finished, JapanesePlugin::finishedProcessing() is
called. And if parsed text is differ from m_nextWord, retry to parse().

This commit fix to pass wrong old word to new parse() call.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Micahel,

I found a problem in plugins/ja/src/japaneseplugin.cpp and fixed it.
Perhaps it will be related you found quickly typing problem.
Could you retry it?

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 That seems to have fixed it, great work! I'm just waiting on some fixes to unity8 that are causing some issues with the autopilot tests and then we can see about getting your branch landed :)

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 I'm afraid during my final run through the test plan for this I spotted another issue, the bottom row of keys isn't positioned correctly in the landscape view, here's a screenshot showing the issue: http://mikeasoft.com/~mike/jp-landscape.png

 Once that's fixed we should be able to land this :)

Cheers,
 Mike.

review: Needs Fixing
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

OK, I can reproduce it. However layout is changed English layout then back to Japanese layout, bottom row is positioned correctly. Umm...

414. By Mitsuya Shibata

fix layout in landscape mode.

The height of Language key should be keyHeight.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Ah, OK. Language key is wrong height. Fixed.

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Great, thanks, one last little thing I spotted, the backspace icon is offset slightly, this actually looks like a bug in the leftSide/rightSide handling for action keys, so for now I'd suggest you just set the width of that key to "panel.keyWidth". Then as a separate task I'll fix the action key icon positioning at a later date and also update all the existing layouts to use leftSide/rightSide for shift and backspace (which they don't currently do).

review: Needs Fixing
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

One other thing, would it not make more sense for the "." to be the primary key on the URL layout's url key instead of the ","?

Revision history for this message
Ken VanDine (ken-vandine) wrote :

packaging looks good

review: Approve (packaging)
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

> I'd suggest you just set the width of that key to "panel.keyWidth".

If set width or remove "rightSide", then first row will be right offset.
This is caused by no rightMargin in CharKey.
Should I push the code to remain the layout corruption?

https://goo.gl/photos/bG5ZxHxfyMhExc926

> would it not make more sense for the "." to be the primary key on the URL layout's url key instead of the ","?

Indeed. To operation coherency, I will swap "," and "." at all keyboard.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hi Mitsuya,

 Just did a quick test, you can work around that by setting the width on the UndoKey as well as the width on the BackspaceKey, then everything will align correctly.

Cheers,
 Mike.

415. By Mitsuya Shibata

add workaround for backspace icon misalignment

416. By Mitsuya Shibata

swap "," and "." which is mainly used to input url and email.

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

Thanks you for nice advice!
I pushed codes to fix problems which you pointed out.

Thanks,

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Great, thanks; I'll run that through the test plan one last time on Monday and then hopefully we can get it landed :)

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Hey Mitsuya,

 Sorry! Spotted another issue, you must be getting really tired of me saying "one last thing..." ;)

 The commit key isn't inserting the primary candidate (the bold candidate) when in auto-complete mode, instead it inserts the user's input unmodified. Is this deliberate (i.e. does the Japanese keyboard not really support auto-complete at all)? If so then we shouldn't be highlighting a primary candidate for Japanese, otherwise pressing the commit key should input the primary candidate instead of the user input.

review: Needs Fixing
417. By Mitsuya Shibata

set primary candidate to user input string

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Hi Michael,

Indeed. Generally in Japanese, the commit key should insert the preedit string (primary purpose to input Hiragana).
To clarify which candidate will be committed, I set the primary candidate to the preedit string.

Is it okay?

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Okay, that sounds good; I'll kick off a rebuild now and retest when it's done

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Unfortunately I found an extra issue, one of the changes made to the core breaks both the email detection and mid-word insertion based disabling of pre-edit for all the other plugins.

const bool enablePreeditAtInsertion = d->word_engine->languageFeature()->wordEngineAvailable();

^ wordEngineAvailable isn't really an appropriate feature to check for this, as that's going to be true for pretty much all plugins. I think you really need to explicitly add a new language feature for this (which could be called enablePreeditAtInsertion), that's true for Japanese but false for all other plugins.

review: Needs Fixing
418. By Mitsuya Shibata

fix calling wrong method

Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Sorry for my numerous failure...

I fixed wordEngineAvailable() bug. Could you check it?

review: Needs Resubmitting
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

That's great thanks, and no are apologies necessary :) This is by far the most advanced keyboard we've had contributed, so it's natural that there be a few issues in the review.

I've completed a full test now and everything looks good, so I'll propose it for landing now :)

Thanks for all your hard work on this!

review: Approve
Revision history for this message
Mitsuya Shibata (cosmos-door) wrote :

Thank you for your review and merge!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2016-01-12 11:35:18 +0000
+++ debian/control 2016-02-19 18:07:05 +0000
@@ -5,6 +5,7 @@
5XSBC-Original-Maintainer: Michael Hasselmann <michaelh@openismus.com>5XSBC-Original-Maintainer: Michael Hasselmann <michaelh@openismus.com>
6Build-Depends: debhelper (>= 9),6Build-Depends: debhelper (>= 9),
7 doxygen,7 doxygen,
8 libanthy-dev,
8 libgl1-mesa-dev | libgl-dev,9 libgl1-mesa-dev | libgl-dev,
9 libgles2-mesa-dev,10 libgles2-mesa-dev,
10 libglib2.0-dev,11 libglib2.0-dev,
@@ -98,6 +99,7 @@
98 ubuntu-keyboard-hungarian (>= ${source:Version}),99 ubuntu-keyboard-hungarian (>= ${source:Version}),
99 ubuntu-keyboard-icelandic (>= ${source:Version}),100 ubuntu-keyboard-icelandic (>= ${source:Version}),
100 ubuntu-keyboard-italian (>= ${source:Version}),101 ubuntu-keyboard-italian (>= ${source:Version}),
102 ubuntu-keyboard-japanese (>= ${source:Version}),
101 ubuntu-keyboard-norwegian-bokmal (>= ${source:Version}),103 ubuntu-keyboard-norwegian-bokmal (>= ${source:Version}),
102 ubuntu-keyboard-polish (>= ${source:Version}),104 ubuntu-keyboard-polish (>= ${source:Version}),
103 ubuntu-keyboard-portuguese (>= ${source:Version}),105 ubuntu-keyboard-portuguese (>= ${source:Version}),
@@ -280,6 +282,15 @@
280Description: Ubuntu on-screen keyboard data files - Italian282Description: Ubuntu on-screen keyboard data files - Italian
281 Data files for the Ubuntu virtual keyboard - Italian283 Data files for the Ubuntu virtual keyboard - Italian
282284
285Package: ubuntu-keyboard-japanese
286Architecture: any
287Depends: ubuntu-keyboard (= ${binary:Version}),
288 anthy,
289 ${misc:Depends},
290 ${shlibs:Depends},
291Description: Ubuntu on-screen keyboard data files - Japanese
292 Data files for the Ubuntu virtual keyboard - Japanese
293
283Package: ubuntu-keyboard-norwegian-bokmal294Package: ubuntu-keyboard-norwegian-bokmal
284Architecture: any295Architecture: any
285Depends: ubuntu-keyboard (= ${binary:Version}),296Depends: ubuntu-keyboard (= ${binary:Version}),
286297
=== modified file 'debian/server.conf'
--- debian/server.conf 2015-05-11 10:53:43 +0000
+++ debian/server.conf 2016-02-19 18:07:05 +0000
@@ -10,6 +10,7 @@
10libubuntu-keyboard-plugin.so:el, \10libubuntu-keyboard-plugin.so:el, \
11libubuntu-keyboard-plugin.so:es, \11libubuntu-keyboard-plugin.so:es, \
12libubuntu-keyboard-plugin.so:ca, \12libubuntu-keyboard-plugin.so:ca, \
13libubuntu-keyboard-plugin.so:ja, \
13libubuntu-keyboard-plugin.so:zh_cn_cangjie, \14libubuntu-keyboard-plugin.so:zh_cn_cangjie, \
14libubuntu-keyboard-plugin.so:zh_cn_pinyin, \15libubuntu-keyboard-plugin.so:zh_cn_pinyin, \
15libubuntu-keyboard-plugin.so:zh_cn_zhuyin,16libubuntu-keyboard-plugin.so:zh_cn_zhuyin,
1617
=== added file 'debian/ubuntu-keyboard-japanese.install'
--- debian/ubuntu-keyboard-japanese.install 1970-01-01 00:00:00 +0000
+++ debian/ubuntu-keyboard-japanese.install 2016-02-19 18:07:05 +0000
@@ -0,0 +1,1 @@
1usr/share/maliit/plugins/com/ubuntu/lib/ja/
02
=== added directory 'plugins/ja'
=== added file 'plugins/ja/ja.pro'
--- plugins/ja/ja.pro 1970-01-01 00:00:00 +0000
+++ plugins/ja/ja.pro 2016-02-19 18:07:05 +0000
@@ -0,0 +1,9 @@
1CONFIG += ordered
2TEMPLATE = subdirs
3SUBDIRS = \
4 src \
5 qml
6
7QMAKE_EXTRA_TARGETS += check
8check.target = check
9check.CONFIG = recursive
010
=== added directory 'plugins/ja/qml'
=== added file 'plugins/ja/qml/Keyboard_ja.qml'
--- plugins/ja/qml/Keyboard_ja.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/Keyboard_ja.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,118 @@
1/*
2 * Copyright 2015 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.4
18import "keys/"
19import keys 1.0
20
21KeyPad {
22 anchors.fill: parent
23
24 content: c1
25
26 Column {
27 id: c1
28 anchors.fill: parent
29 spacing: 0
30
31 Row {
32 anchors.horizontalCenter: parent.horizontalCenter;
33 spacing: 0
34
35 UndoKey { leftSide: true; width: panel.keyWidth; }
36 FlickCharKey {
37 label: layout.state == "kana" ? "あ" : "@ / : _";
38 leaves: layout.state == "kana" ? ["あ", "い", "う", "え", "お"] : ["@", "/", ":", "_", "1"];
39 annotation: layout.state == "kana" ? "" : "1";
40 }
41 FlickCharKey {
42 label: layout.state == "kana" ? "か" : "ABC";
43 leaves: layout.state == "kana" ? ["か", "き", "く", "け", "こ"] : ["a", "b", "c", "#", "2"];
44 annotation: layout.state == "kana" ? "" : "2#";
45 }
46 FlickCharKey {
47 label: layout.state == "kana" ? "さ" : "DEF";
48 leaves: layout.state == "kana" ? ["さ", "し", "す", "せ", "そ"] : ["d", "e", "f", "$", "3"];
49 annotation: layout.state == "kana" ? "" : "3$";
50 }
51 BackspaceKey { rightSide: true; width: panel.keyWidth; }
52 }
53
54 Row {
55 anchors.horizontalCenter: parent.horizontalCenter;
56 spacing: 0
57
58 CursorKey { action: "left"; }
59 FlickCharKey {
60 label: layout.state == "kana" ? "た" : "GHI";
61 leaves: layout.state == "kana" ? ["た", "ち", "つ", "て", "と"] : ["g", "h", "i", "(", "4"];
62 annotation: layout.state == "kana" ? "" : "4(";
63 }
64 FlickCharKey {
65 label: layout.state == "kana" ? "な" : "JKL";
66 leaves: layout.state == "kana" ? ["な", "に", "ぬ", "ね", "の"] : ["j", "k", "l", "\"", "5"];
67 annotation: layout.state == "kana" ? "" : "5\"";
68 }
69 FlickCharKey {
70 label: layout.state == "kana" ? "は" : "MNO";
71 leaves: layout.state == "kana" ? ["は", "ひ", "ふ", "へ", "ほ"] : ["m", "n", "o", ")", "6"];
72 annotation: layout.state == "kana" ? "" : "6)";
73 }
74 CursorKey { action: "right"; }
75 }
76
77 Row {
78 anchors.horizontalCenter: parent.horizontalCenter;
79 spacing: 0
80
81 LanguageKey { id: languageMenuButton; height: panel.keyHeight; }
82 FlickCharKey {
83 label: layout.state == "kana" ? "ま" : "PQRS"
84 leaves: layout.state == "kana" ? ["ま", "み", "む", "め", "も"] : ["p", "q", "r", "s", "7"]
85 annotation: layout.state == "kana" ? "" : "7"
86 }
87 FlickCharKey {
88 label: layout.state == "kana" ? "や" : "TUV"
89 leaves: layout.state == "kana" ? ["や", "(", "ゆ", ")", "よ"] : ["t", "u", "v", "'", "8"]
90 annotation: layout.state == "kana" ? "" : "8'"
91 }
92 FlickCharKey {
93 label: layout.state == "kana" ? "ら" : "WXYZ"
94 leaves: layout.state == "kana" ? ["ら", "り", "る", "れ", "ろ"] : ["w", "x", "y", "z", "9"]
95 annotation: layout.state == "kana" ? "" : "9"
96 }
97 ActionKey { label: "記号"; action: "symbol"; width: panel.keyWidth; }
98 }
99
100 Row {
101 anchors.horizontalCenter: parent.horizontalCenter;
102 spacing: 0
103
104 KanaSwitchKey { id: layout; }
105 ModifierKey { layoutState: layout.state; }
106 FlickCharKey {
107 label: layout.state == "kana" ? "わ" : "- + *"
108 leaves: layout.state == "kana" ? ["わ", "を", "ん", "ー"] : ["-", "+", "0", "*"];
109 annotation: layout.state == "kana" ? "" : "0";
110 }
111 FlickCharKey {
112 label: layout.state == "kana" ? "、。" : ". , ! ?";
113 leaves: layout.state == "kana" ? ["、", "。", "!", "?"] : [".", ",", "!", "?"];
114 }
115 CommitKey { id: enterKey; width: panel.keyWidth; }
116 }
117 } // column
118}
0119
=== added file 'plugins/ja/qml/Keyboard_ja_email.qml'
--- plugins/ja/qml/Keyboard_ja_email.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/Keyboard_ja_email.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright 2015 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.4
18import "keys/"
19import keys 1.0
20
21KeyPad {
22 anchors.fill: parent
23
24 content: c1
25
26 Column {
27 id: c1
28 anchors.fill: parent
29 spacing: 0
30
31 Row {
32 anchors.horizontalCenter: parent.horizontalCenter;
33 spacing: 0
34
35 UndoKey { leftSide: true; width: panel.keyWidth; }
36 FlickCharKey {
37 label: layout.state == "kana" ? "あ" : "@ / : _";
38 leaves: layout.state == "kana" ? ["あ", "い", "う", "え", "お"] : ["@", "/", ":", "_", "1"];
39 annotation: layout.state == "kana" ? "" : "1";
40 }
41 FlickCharKey {
42 label: layout.state == "kana" ? "か" : "ABC";
43 leaves: layout.state == "kana" ? ["か", "き", "く", "け", "こ"] : ["a", "b", "c", "#", "2"];
44 annotation: layout.state == "kana" ? "" : "2#";
45 }
46 FlickCharKey {
47 label: layout.state == "kana" ? "さ" : "DEF";
48 leaves: layout.state == "kana" ? ["さ", "し", "す", "せ", "そ"] : ["d", "e", "f", "$", "3"];
49 annotation: layout.state == "kana" ? "" : "3$";
50 }
51 BackspaceKey { rightSide: true; width: panel.keyWidth; }
52 }
53
54 Row {
55 anchors.horizontalCenter: parent.horizontalCenter;
56 spacing: 0
57
58 CursorKey { action: "left"; }
59 FlickCharKey {
60 label: layout.state == "kana" ? "た" : "GHI";
61 leaves: layout.state == "kana" ? ["た", "ち", "つ", "て", "と"] : ["g", "h", "i", "(", "4"];
62 annotation: layout.state == "kana" ? "" : "4(";
63 }
64 FlickCharKey {
65 label: layout.state == "kana" ? "な" : "JKL";
66 leaves: layout.state == "kana" ? ["な", "に", "ぬ", "ね", "の"] : ["j", "k", "l", "\"", "5"];
67 annotation: layout.state == "kana" ? "" : "5\"";
68 }
69 FlickCharKey {
70 label: layout.state == "kana" ? "は" : "MNO";
71 leaves: layout.state == "kana" ? ["は", "ひ", "ふ", "へ", "ほ"] : ["m", "n", "o", ")", "6"];
72 annotation: layout.state == "kana" ? "" : "6)";
73 }
74 CursorKey { action: "right"; }
75 }
76
77 Row {
78 anchors.horizontalCenter: parent.horizontalCenter;
79 spacing: 0
80
81 LanguageKey { id: languageMenuButton; height: panel.keyHeight; }
82 FlickCharKey {
83 label: layout.state == "kana" ? "ま" : "PQRS"
84 leaves: layout.state == "kana" ? ["ま", "み", "む", "め", "も"] : ["p", "q", "r", "s", "7"]
85 annotation: layout.state == "kana" ? "" : "7"
86 }
87 FlickCharKey {
88 label: layout.state == "kana" ? "や" : "TUV"
89 leaves: layout.state == "kana" ? ["や", "(", "ゆ", ")", "よ"] : ["t", "u", "v", "'", "8"]
90 annotation: layout.state == "kana" ? "" : "8'"
91 }
92 FlickCharKey {
93 label: layout.state == "kana" ? "ら" : "WXYZ"
94 leaves: layout.state == "kana" ? ["ら", "り", "る", "れ", "ろ"] : ["w", "x", "y", "z", "9"]
95 annotation: layout.state == "kana" ? "" : "9"
96 }
97 ActionKey { label: "記号"; action: "symbol"; width: panel.keyWidth; }
98 }
99
100 Row {
101 anchors.horizontalCenter: parent.horizontalCenter;
102 spacing: 0
103
104 KanaSwitchKey { id: layout; default_state: "alnum" }
105 ModifierKey { layoutState: layout.state; }
106 FlickCharKey {
107 label: layout.state == "kana" ? "わ" : "- + *"
108 leaves: layout.state == "kana" ? ["わ", "を", "ん", "ー"] : ["-", "+", "0", "*"];
109 annotation: layout.state == "kana" ? "" : "0";
110 }
111 DomainKey {
112 label: layout.state == "kana" ? "、。" : ". ,";
113 leaves: layout.state == "kana" ? ["、", "。", "!", "?"] :
114 [".", ",", "<font size=\"1\">.com</font>", "<font size=\"1\">.jp</font>"];
115 unstyledLeaves: layout.state == "kana" ? ["、", "。", "!", "?"] : [".", ",", ".com", ".jp"];
116 annotation: layout.state == "kana" ? "" : ".com .jp"
117 }
118 CommitKey { id: enterKey; width: panel.keyWidth; }
119 }
120 } // column
121}
0122
=== added file 'plugins/ja/qml/Keyboard_ja_url.qml'
--- plugins/ja/qml/Keyboard_ja_url.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/Keyboard_ja_url.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright 2015 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.4
18import "keys/"
19import keys 1.0
20
21KeyPad {
22 anchors.fill: parent
23
24 content: c1
25
26 Column {
27 id: c1
28 anchors.fill: parent
29 spacing: 0
30
31 Row {
32 anchors.horizontalCenter: parent.horizontalCenter;
33 spacing: 0
34
35 UndoKey { leftSide: true; width: panel.keyWidth; }
36 FlickCharKey {
37 label: layout.state == "kana" ? "あ" : "@ / : _";
38 leaves: layout.state == "kana" ? ["あ", "い", "う", "え", "お"] : ["@", "/", ":", "_", "1"];
39 annotation: layout.state == "kana" ? "" : "1";
40 }
41 FlickCharKey {
42 label: layout.state == "kana" ? "か" : "ABC";
43 leaves: layout.state == "kana" ? ["か", "き", "く", "け", "こ"] : ["a", "b", "c", "#", "2"];
44 annotation: layout.state == "kana" ? "" : "2#";
45 }
46 FlickCharKey {
47 label: layout.state == "kana" ? "さ" : "DEF";
48 leaves: layout.state == "kana" ? ["さ", "し", "す", "せ", "そ"] : ["d", "e", "f", "$", "3"];
49 annotation: layout.state == "kana" ? "" : "3$";
50 }
51 BackspaceKey { rightSide: true; width: panel.keyWidth; }
52 }
53
54 Row {
55 anchors.horizontalCenter: parent.horizontalCenter;
56 spacing: 0
57
58 CursorKey { action: "left"; }
59 FlickCharKey {
60 label: layout.state == "kana" ? "た" : "GHI";
61 leaves: layout.state == "kana" ? ["た", "ち", "つ", "て", "と"] : ["g", "h", "i", "(", "4"];
62 annotation: layout.state == "kana" ? "" : "4(";
63 }
64 FlickCharKey {
65 label: layout.state == "kana" ? "な" : "JKL";
66 leaves: layout.state == "kana" ? ["な", "に", "ぬ", "ね", "の"] : ["j", "k", "l", "\"", "5"];
67 annotation: layout.state == "kana" ? "" : "5\"";
68 }
69 FlickCharKey {
70 label: layout.state == "kana" ? "は" : "MNO";
71 leaves: layout.state == "kana" ? ["は", "ひ", "ふ", "へ", "ほ"] : ["m", "n", "o", ")", "6"];
72 annotation: layout.state == "kana" ? "" : "6)";
73 }
74 CursorKey { action: "right"; }
75 }
76
77 Row {
78 anchors.horizontalCenter: parent.horizontalCenter;
79 spacing: 0
80
81 LanguageKey { id: languageMenuButton; height: panel.keyHeight; }
82 FlickCharKey {
83 label: layout.state == "kana" ? "ま" : "PQRS"
84 leaves: layout.state == "kana" ? ["ま", "み", "む", "め", "も"] : ["p", "q", "r", "s", "7"]
85 annotation: layout.state == "kana" ? "" : "7"
86 }
87 FlickCharKey {
88 label: layout.state == "kana" ? "や" : "TUV"
89 leaves: layout.state == "kana" ? ["や", "(", "ゆ", ")", "よ"] : ["t", "u", "v", "'", "8"]
90 annotation: layout.state == "kana" ? "" : "8'"
91 }
92 FlickCharKey {
93 label: layout.state == "kana" ? "ら" : "WXYZ"
94 leaves: layout.state == "kana" ? ["ら", "り", "る", "れ", "ろ"] : ["w", "x", "y", "z", "9"]
95 annotation: layout.state == "kana" ? "" : "9"
96 }
97 ActionKey { label: "記号"; action: "symbol"; width: panel.keyWidth; }
98 }
99
100 Row {
101 anchors.horizontalCenter: parent.horizontalCenter;
102 spacing: 0
103
104 KanaSwitchKey { id: layout; default_state: "alnum" }
105 ModifierKey { layoutState: layout.state; }
106 FlickCharKey {
107 label: layout.state == "kana" ? "わ" : "- + *"
108 leaves: layout.state == "kana" ? ["わ", "を", "ん", "ー"] : ["-", "+", "0", "*"];
109 annotation: layout.state == "kana" ? "" : "0";
110 }
111 DomainKey {
112 label: layout.state == "kana" ? "、。" : ". ,";
113 leaves: layout.state == "kana" ? ["、", "。", "!", "?"] :
114 [".", ",", "<font size=\"1\">.com</font>", "<font size=\"1\">.jp</font>"];
115 unstyledLeaves: layout.state == "kana" ? ["、", "。", "!", "?"] : [".", ",", ".com", ".jp"];
116 annotation: layout.state == "kana" ? "" : ".com .jp"
117 }
118 CommitKey { id: enterKey; width: panel.keyWidth; }
119 }
120 } // column
121}
0122
=== added file 'plugins/ja/qml/Keyboard_ja_url_search.qml'
--- plugins/ja/qml/Keyboard_ja_url_search.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/Keyboard_ja_url_search.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright 2015 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.4
18import "keys/"
19import keys 1.0
20
21KeyPad {
22 anchors.fill: parent
23
24 content: c1
25
26 Column {
27 id: c1
28 anchors.fill: parent
29 spacing: 0
30
31 Row {
32 anchors.horizontalCenter: parent.horizontalCenter;
33 spacing: 0
34
35 UndoKey { leftSide: true; width: panel.keyWidth; }
36 FlickCharKey {
37 label: layout.state == "kana" ? "あ" : "@ / : _";
38 leaves: layout.state == "kana" ? ["あ", "い", "う", "え", "お"] : ["@", "/", ":", "_", "1"];
39 annotation: layout.state == "kana" ? "" : "1";
40 }
41 FlickCharKey {
42 label: layout.state == "kana" ? "か" : "ABC";
43 leaves: layout.state == "kana" ? ["か", "き", "く", "け", "こ"] : ["a", "b", "c", "#", "2"];
44 annotation: layout.state == "kana" ? "" : "2#";
45 }
46 FlickCharKey {
47 label: layout.state == "kana" ? "さ" : "DEF";
48 leaves: layout.state == "kana" ? ["さ", "し", "す", "せ", "そ"] : ["d", "e", "f", "$", "3"];
49 annotation: layout.state == "kana" ? "" : "3$";
50 }
51 BackspaceKey { rightSide: true; width: panel.keyWidth; }
52 }
53
54 Row {
55 anchors.horizontalCenter: parent.horizontalCenter;
56 spacing: 0
57
58 CursorKey { action: "left"; }
59 FlickCharKey {
60 label: layout.state == "kana" ? "た" : "GHI";
61 leaves: layout.state == "kana" ? ["た", "ち", "つ", "て", "と"] : ["g", "h", "i", "(", "4"];
62 annotation: layout.state == "kana" ? "" : "4(";
63 }
64 FlickCharKey {
65 label: layout.state == "kana" ? "な" : "JKL";
66 leaves: layout.state == "kana" ? ["な", "に", "ぬ", "ね", "の"] : ["j", "k", "l", "\"", "5"];
67 annotation: layout.state == "kana" ? "" : "5\"";
68 }
69 FlickCharKey {
70 label: layout.state == "kana" ? "は" : "MNO";
71 leaves: layout.state == "kana" ? ["は", "ひ", "ふ", "へ", "ほ"] : ["m", "n", "o", ")", "6"];
72 annotation: layout.state == "kana" ? "" : "6)";
73 }
74 CursorKey { action: "right"; }
75 }
76
77 Row {
78 anchors.horizontalCenter: parent.horizontalCenter;
79 spacing: 0
80
81 LanguageKey { id: languageMenuButton; height: panel.keyHeight; }
82 FlickCharKey {
83 label: layout.state == "kana" ? "ま" : "PQRS"
84 leaves: layout.state == "kana" ? ["ま", "み", "む", "め", "も"] : ["p", "q", "r", "s", "7"]
85 annotation: layout.state == "kana" ? "" : "7"
86 }
87 FlickCharKey {
88 label: layout.state == "kana" ? "や" : "TUV"
89 leaves: layout.state == "kana" ? ["や", "(", "ゆ", ")", "よ"] : ["t", "u", "v", "'", "8"]
90 annotation: layout.state == "kana" ? "" : "8'"
91 }
92 FlickCharKey {
93 label: layout.state == "kana" ? "ら" : "WXYZ"
94 leaves: layout.state == "kana" ? ["ら", "り", "る", "れ", "ろ"] : ["w", "x", "y", "z", "9"]
95 annotation: layout.state == "kana" ? "" : "9"
96 }
97 ActionKey { label: "記号"; action: "symbol"; width: panel.keyWidth; }
98 }
99
100 Row {
101 anchors.horizontalCenter: parent.horizontalCenter;
102 spacing: 0
103
104 KanaSwitchKey { id: layout; default_state: "alnum" }
105 ModifierKey { layoutState: layout.state; }
106 FlickCharKey {
107 label: layout.state == "kana" ? "わ" : "- + *"
108 leaves: layout.state == "kana" ? ["わ", "を", "ん", "ー"] : ["-", "+", "0", "*"];
109 annotation: layout.state == "kana" ? "" : "0";
110 }
111 DomainKey {
112 label: layout.state == "kana" ? "、。" : ". ,";
113 leaves: layout.state == "kana" ? ["、", "。", "!", "?"] :
114 [".", ",", "<font size=\"1\">.com</font>", "<font size=\"1\">.jp</font>"];
115 unstyledLeaves: layout.state == "kana" ? ["、", "。", "!", "?"] : [".", ",", ".com", ".jp"];
116 annotation: layout.state == "kana" ? "" : ".com .jp"
117 }
118 CommitKey { id: enterKey; width: panel.keyWidth; }
119 }
120 } // column
121}
0122
=== added directory 'plugins/ja/qml/keys'
=== added file 'plugins/ja/qml/keys/CommitKey.qml'
--- plugins/ja/qml/keys/CommitKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/CommitKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright 2015 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.4
18import "key_constants.js" as UI
19import keys 1.0
20
21ActionKey {
22 property var actionKeyOverride: maliit_input_method.actionKeyOverride
23 property string overrideIconName: actionKeyOverride && actionKeyOverride.icon ? actionKeyOverride.icon : ""
24 property string overrideLabel: actionKeyOverride && actionKeyOverride.label ? actionKeyOverride.label : ""
25
26 enabled: actionKeyOverride ? actionKeyOverride.enabled : true
27 // overrideIcon has high priority over label
28 label: overrideIconName == "" ? overrideLabel : ""
29 // Scale the font so the label fits if a long word is set
30 fontSize: units.gu(UI.symbolShiftKeyFontSize) * (4 / (label.length >= 4 ? (label.length <= 6 ? label.length : 6) : 4));
31 shifted: label
32
33 iconNormal: (overrideIconName == "") && (overrideLabel == "") ? "keyboard-return" : overrideIconName
34 iconShifted: iconNormal
35 iconCapsLock: iconNormal
36
37 action: maliit_input_method.preedit != "" ? "commit" : "return"
38 switchBackFromSymbols: true
39 // TODO: input_method.actionKeyOverride.highlighted
40}
041
=== added file 'plugins/ja/qml/keys/CursorKey.qml'
--- plugins/ja/qml/keys/CursorKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/CursorKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright 2015 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.4
18import "key_constants.js" as UI
19import keys 1.0
20
21ActionKey {
22 label: action == "left" ? "⬅" : "➡";
23 leftSide: action == "left";
24 rightSide: action == "right";
25
26 property string preedit: maliit_input_method.preedit
27 property int cursorPosition: maliit_input_method.cursorPosition
28 property bool isPreedit: preedit != ""
29
30 overridePressArea: true;
31
32 onReleased: {
33 if (isPreedit) {
34 if (action == "left" && cursorPosition > 0) {
35 maliit_input_method.cursorPosition--
36 } else if (action == "right" && cursorPosition < preedit.length) {
37 maliit_input_method.cursorPosition++
38 }
39 } else {
40 event_handler.onKeyReleased("", action);
41 }
42 }
43
44 onPressed: {
45 if (maliit_input_method.useAudioFeedback)
46 audioFeedback.play();
47
48 if (maliit_input_method.useHapticFeedback)
49 pressEffect.start();
50
51 if (!isPreedit)
52 event_handler.onKeyPressed("", action);
53 }
54
55 onPressAndHold: {
56 return;
57 }
58}
059
=== added file 'plugins/ja/qml/keys/DomainKey.qml'
--- plugins/ja/qml/keys/DomainKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/DomainKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2015 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.4
18import QtMultimedia 5.0
19import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.3
21
22import "key_constants.js" as UI
23
24FlickCharKey {
25 property var unstyledLeaves: ["", "", "", "", ""];
26
27 overridePressArea: true
28
29 onReleased: {
30 event_handler.onKeyReleased(unstyledLeaves[index], action);
31 }
32
33 onPressed: {
34 if (maliit_input_method.useAudioFeedback)
35 audioFeedback.play();
36
37 if (maliit_input_method.useHapticFeedback)
38 pressEffect.start();
39
40 event_handler.onKeyPressed(unstyledLeaves[index], action);
41 }
42}
043
=== added file 'plugins/ja/qml/keys/FlickArea.qml'
--- plugins/ja/qml/keys/FlickArea.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/FlickArea.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18
19MultiPointTouchArea {
20 id: root
21
22 /// Is true while the area is touched, and the finger did not yet lift
23 property bool pressed: false
24
25 /// Cancels the current pressed state of the mouse are
26 function cancelPress() {
27 pressed = false;
28 }
29
30 onPressed: {
31 index = 0;
32 pressed = true;
33 rad = 0
34 }
35
36 onReleased: {
37 pressed = false;
38 }
39
40 property int index: 0 // 0:center, 1:left, 2:top, 3:right, 4:bottom
41 property int old_index: 0
42 property real posX: point.x - parent.width / 2
43 property real posY: point.y - parent.height / 2
44 property real rad: 0
45
46 touchPoints: [
47 TouchPoint { id: point }
48 ]
49
50 onUpdated: {
51 rad = Math.atan2(posY, posX)
52 if ((posX * posX + posY * posY) < (0.5 * parent.height * 0.5 * parent.height)) {
53 index = 0
54 } else {
55 if (rad < -Math.PI / 4.0) {
56 if (rad < -Math.PI * 3.0 / 4.0) {
57 index = 1
58 } else {
59 index = 2
60 }
61 } else if (rad > Math.PI / 4.0) {
62 if (rad > Math.PI * 3.0 / 4.0) {
63 index = 1
64 } else {
65 index = 4
66 }
67 } else {
68 index = 3
69 }
70 }
71
72 if (old_index != index) {
73 old_index = index
74
75 if (maliit_input_method.useHapticFeedback)
76 pressEffect.start();
77 }
78 }
79}
080
=== added file 'plugins/ja/qml/keys/FlickCharKey.qml'
--- plugins/ja/qml/keys/FlickCharKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/FlickCharKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,178 @@
1/*
2 * Copyright 2015 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.4
18import QtMultimedia 5.0
19import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.3
21
22import "key_constants.js" as UI
23
24Item {
25 id: key
26
27 property int padding: 0
28
29 width: leftSide || rightSide ? panel.keyWidth * 2 : panel.keyWidth
30 height: panel.keyHeight
31
32 /* to be set in keyboard layouts */
33 property string label: "";
34 property var leaves: ["", "", "", "", ""];
35 property int index: keyFlickArea.index;
36 property bool highlight: false;
37
38 property string action
39 property bool noMagnifier: false
40 property bool skipAutoCaps: false
41 property bool switchBackFromSymbols: false
42
43 property bool leftSide: false
44 property bool rightSide: false
45
46 property double rowMargin: fullScreenItem.tablet ? units.gu(UI.tabletRowMargin)
47 : (fullScreenItem.landscape ? units.dp(UI.phoneRowMarginLandscape)
48 : units.dp(UI.phoneRowMarginPortrait))
49 property double keyMargin: fullScreenItem.tablet ? units.gu(UI.tabletKeyMargins)
50 : units.gu(UI.phoneKeyMargins)
51
52 // These properties are used by autopilot to determine the visible
53 // portion of the key to press
54 readonly property double leftOffset: buttonRect.anchors.leftMargin
55 readonly property double rightOffset: buttonRect.anchors.rightMargin
56
57 /* design */
58 property string normalColor: UI.charKeyColor
59 property string pressedColor: UI.charKeyPressedColor
60 property int fontSize: (fullScreenItem.landscape ? (height / 2) : (height / 2.8));
61
62 /// annotation shows a small label in the upper right corner
63 // if the annotiation property is set, it will be used. If not, the first position in extended[] list or extendedShifted[] list will
64 // be used, depending on the state. If no extended/extendedShifted arrays exist, no annotation is shown
65 property string annotation: ""
66
67 /*! indicates if te key is currently pressed/down*/
68 property alias currentlyPressed: keyFlickArea.pressed
69
70 property string oskState: panel.activeKeypadState
71
72 // Allow action keys to override the standard key behaviour
73 property bool overridePressArea: false
74
75 signal pressed()
76 signal released()
77
78 // Make it possible for the visible area of the key to differ from the
79 // actual key size. This allows us to extend the touch area of the bottom
80 // row of keys all the way to the bottom of the keyboard, whilst
81 // maintaining the same visual appearance.
82 Item {
83 anchors.top: parent.top
84 height: panel.keyHeight
85 width: parent.width
86
87 Rectangle {
88 id: buttonRect
89 color: key.currentlyPressed || key.highlight ? pressedColor : normalColor
90 anchors.fill: parent
91 anchors.leftMargin: key.leftSide ? (parent.width - panel.keyWidth) + key.keyMargin : key.keyMargin
92 anchors.rightMargin: key.rightSide ? (parent.width - panel.keyWidth) + key.keyMargin : key.keyMargin
93 anchors.bottomMargin: key.rowMargin
94 radius: units.dp(4)
95
96 /// label of the key
97 // the label is also the value subitted to the app
98
99 Column {
100 spacing: units.gu( UI.annotationMargins )
101 anchors.centerIn: parent
102
103 Text {
104 id: keyLabel
105 text: label
106 anchors.horizontalCenter: parent.horizontalCenter
107 font.family: UI.fontFamily
108 font.pixelSize: fontSize
109 font.weight: Font.Light
110 color: UI.fontColor
111 textFormat: Text.StyledText
112 }
113
114 Text {
115 id: annotationLabel
116 text: annotation
117
118 anchors.horizontalCenter: parent.horizontalCenter
119 anchors.bottomMargin: units.gu( UI.annotationMargins )
120
121 font.family: UI.annotationFont
122 font.pixelSize: fullScreenItem.tablet ? units.dp(UI.tabletAnnotationFontSize) : units.dp(UI.phoneAnnotationFontSize)
123 font.weight: Font.Light
124 color: UI.annotationFontColor
125 visible: annotation != ""
126 }
127 }
128 }
129
130 FlickPop {
131 anchors.horizontalCenter: buttonRect.horizontalCenter
132 anchors.bottom: buttonRect.top
133 anchors.bottomMargin: key.height * 0.5
134 width: units.gu((UI.fontSize + UI.flickMargin) * 3)
135 height: units.gu((UI.fontSize + UI.flickMargin) * 3)
136 chars: leaves
137 index: keyFlickArea.index
138 visible: key.currentlyPressed && chars.length > 1
139 }
140 }
141
142 FlickArea {
143 id: keyFlickArea
144 anchors.fill: key
145
146 onReleased: {
147 if (overridePressArea) {
148 key.released();
149 return;
150 }
151
152 event_handler.onKeyReleased(leaves[index], action);
153 }
154
155 onPressed: {
156 if (overridePressArea) {
157 key.pressed();
158 return;
159 }
160
161 if (maliit_input_method.useAudioFeedback)
162 audioFeedback.play();
163
164 if (maliit_input_method.useHapticFeedback)
165 pressEffect.start();
166
167 event_handler.onKeyPressed(leaves[index], action);
168 }
169 }
170
171 Connections {
172 target: swipeArea.drag
173 onActiveChanged: {
174 if (swipeArea.drag.active)
175 keyFlickArea.cancelPress();
176 }
177 }
178}
0179
=== added file 'plugins/ja/qml/keys/FlickPop.qml'
--- plugins/ja/qml/keys/FlickPop.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/FlickPop.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20import "key_constants.js" as UI
21
22/*!
23 Item to show a "bubble" with a text in the center.
24 The bottom center is where the bubble points to, and it animates to that position
25 when hiding it.
26 */
27Item {
28 id: root
29
30 property var chars
31 property int index: 0
32
33 visible: false
34
35 FlickPopKey {
36 id: center
37 labelChar: chars[0]
38 anchors.centerIn: parent
39 labelOpacity: index == 0 ? 1.0 : 0.6
40 labelColor: index == 0 ? UbuntuColors.orange : UI.fontColor
41 }
42 FlickPopKey {
43 labelChar: chars[1] ? chars[1] : ""
44 anchors.verticalCenter: center.verticalCenter
45 anchors.right: center.left
46 labelOpacity: index == 1 ? 1.0 : 0.6
47 labelColor: index == 1 ? UbuntuColors.orange : UI.fontColor
48 }
49 FlickPopKey {
50 labelChar: chars[2] ? chars[2] : ""
51 anchors.horizontalCenter: center.horizontalCenter
52 anchors.bottom: center.top
53 labelOpacity: index == 2 ? 1.0 : 0.6
54 labelColor: index == 2 ? UbuntuColors.orange : UI.fontColor
55 }
56 FlickPopKey {
57 labelChar: chars[3] ? chars[3] : ""
58 anchors.verticalCenter: center.verticalCenter
59 anchors.left: center.right
60 labelOpacity: index == 3 ? 1.0 : 0.6
61 labelColor: index == 3 ? UbuntuColors.orange : UI.fontColor
62 }
63 FlickPopKey {
64 labelChar: chars[4] ? chars[4] : ""
65 anchors.horizontalCenter: center.horizontalCenter
66 anchors.top: center.bottom
67 labelOpacity: index == 4 ? 1.0 : 0.6
68 labelColor: index == 4 ? UbuntuColors.orange : UI.fontColor
69 }
70}
071
=== added file 'plugins/ja/qml/keys/FlickPopKey.qml'
--- plugins/ja/qml/keys/FlickPopKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/FlickPopKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import "key_constants.js" as UI
19
20Rectangle {
21 width: units.gu(UI.fontSize + UI.flickMargin)
22 height: units.gu(UI.fontSize + UI.flickMargin)
23
24 property string labelChar
25 property color labelColor: UI.fontColor
26 property real labelOpacity: 1.0
27 visible: labelChar ? true : false
28
29 border.width: units.gu(UI.flickBorderWidth)
30 border.color: UI.flickBorderColor
31 radius: width / 10
32
33 Text {
34 anchors.centerIn: parent
35 text: parent.labelChar
36 font.family: UI.fontFamily
37 font.pixelSize: units.gu(UI.fontSize)
38 font.bold: UI.fontBold
39 color: parent.labelColor
40 opacity: parent.labelOpacity
41 }
42}
043
=== added file 'plugins/ja/qml/keys/KanaSwitchKey.qml'
--- plugins/ja/qml/keys/KanaSwitchKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/KanaSwitchKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,85 @@
1/*
2 * Copyright 2015 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.4
18import QtMultimedia 5.0
19import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.3
21
22import "key_constants.js" as UI
23
24FlickCharKey {
25 padding: UI.actionKeyPadding
26 label: kana.label
27 leaves: ["↻", "", "あ", "A"]
28 normalColor: UI.actionKeyColor
29 pressedColor: UI.actionKeyPressedColor
30
31 overridePressArea: true
32
33 property bool isPreedit: maliit_input_method.preedit.length > 0
34 property string default_state: "kana"
35
36 state: kana.state
37
38 Item {
39 id: kana
40 property string label: "あ/A"
41
42 state: parent.default_state;
43 states: [
44 State {
45 name: "kana"
46 PropertyChanges {
47 target: kana;
48 label: "<font color=\"" + UbuntuColors.orange + "\">あ</font>/A";
49 state: "kana";
50 }
51 },
52 State {
53 name: "alnum"
54 PropertyChanges {
55 target: kana;
56 label: "あ/<font color=\"" + UbuntuColors.orange + "\">A</font>";
57 state: "alnum";
58 }
59 }
60 ]
61 }
62
63 onReleased: {
64 if (isPreedit) {
65 event_handler.onKeyReleased("", "commit");
66 }
67 if (index == 0) {
68 kana.state = kana.state == "kana" ? "alnum" : "kana"
69 } else {
70 if (index == 2) {
71 kana.state = "kana"
72 } else if (index == 3) {
73 kana.state = "alnum"
74 }
75 }
76 }
77
78 onPressed: {
79 if (maliit_input_method.useAudioFeedback)
80 audioFeedback.play();
81
82 if (maliit_input_method.useHapticFeedback)
83 pressEffect.start();
84 }
85}
086
=== added file 'plugins/ja/qml/keys/ModifierKey.qml'
--- plugins/ja/qml/keys/ModifierKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/ModifierKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,79 @@
1/*
2 * Copyright 2015 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.4
18import QtMultimedia 5.0
19import Ubuntu.Components 1.3
20import Ubuntu.Components.Popups 1.3
21
22import "modifier.js" as Modifier
23import "key_constants.js" as UI
24
25FlickCharKey {
26 label: (isPreedit && layoutState == "kana") ? " ゛ ゜" : "␣"
27 leaves: isPreedit ? preeditLeaves : ["␣", "□"]
28 annotation: isPreedit ? "大⇔小" : ""
29 fontSize: isPreedit ? units.gu( UI.fontSize ) * 0.8 : units.gu( UI.fontSize )
30
31 overridePressArea: true
32
33 property string layoutState: "kana"
34 property string preedit: maliit_input_method.preedit
35 property int cursorPosition: maliit_input_method.cursorPosition
36 property bool isPreedit: preedit != ""
37 property string lastChar: ""
38 property var preeditLeaves: Modifier.map[lastChar] ? Modifier.map[lastChar] : [lastChar]
39
40 onReleased: {
41 if (isPreedit) {
42 if (layoutState == "alnum") {
43 if (index != 0) {
44 event_handler.onKeyReleased("", "space");
45 } else {
46 var pos = cursorPosition
47 var newChar = lastChar.charCodeAt(0) < 91 ? lastChar.toLowerCase() : lastChar.toUpperCase()
48 maliit_input_method.preedit = preedit.substr(0, cursorPosition-1) + newChar + preedit.substr(cursorPosition)
49 maliit_input_method.cursorPosition = pos
50 }
51 } else if (preeditLeaves[index] && preeditLeaves[index] != "") {
52 var pos = cursorPosition
53 maliit_input_method.preedit = preedit.substr(0, cursorPosition-1) + preeditLeaves[index] + preedit.substr(cursorPosition)
54 maliit_input_method.cursorPosition = pos
55 }
56 } else {
57 if (index == 0) {
58 event_handler.onKeyReleased("", "space");
59 } else {
60 event_handler.onKeyReleased(" ", "");
61 }
62 }
63 }
64
65 onPressed: {
66 if (maliit_input_method.useAudioFeedback)
67 audioFeedback.play();
68
69 if (maliit_input_method.useHapticFeedback)
70 pressEffect.start();
71
72 if (isPreedit) {
73 lastChar = preedit.charAt(cursorPosition-1)
74 if (!Modifier.map[lastChar] && Modifier.normalize[lastChar]) {
75 lastChar = Modifier.normalize[lastChar]
76 }
77 }
78 }
79}
080
=== added file 'plugins/ja/qml/keys/UndoKey.qml'
--- plugins/ja/qml/keys/UndoKey.qml 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/UndoKey.qml 2016-02-19 18:07:05 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2015 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.4
18import "key_constants.js" as UI
19import keys 1.0
20
21ActionKey {
22 label: "戻す";
23 action: "undo";
24 fontSize: units.gu(UI.undoFontSize);
25}
026
=== added file 'plugins/ja/qml/keys/key_constants.js'
--- plugins/ja/qml/keys/key_constants.js 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/key_constants.js 2016-02-19 18:07:05 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17.pragma library
18
19Qt.include("../../../keys/key_constants.js")
20
21/* ActionKey layout */
22var undoFontSize = 2;
23
24/* FlickCharKey layout */
25var annotationFontSize = 1.5; // gu
26var annotationMargins = 0.3; // gu
27
28/* FlickPop layout */
29var flickMargin = 1.5 // gu
30var flickBorderWidth = 0.1 // gu
31var flickBorderColor = "#999999"
032
=== added file 'plugins/ja/qml/keys/modifier.js'
--- plugins/ja/qml/keys/modifier.js 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/keys/modifier.js 2016-02-19 18:07:05 +0000
@@ -0,0 +1,102 @@
1/*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17.pragma library
18
19/*
20 * Modified character map for ModifierKey
21 *
22 * ModifierKey modify a charcter by left/right/up swipe. This is character map
23 * and swipe direction.
24 * map[ORIGIN KEY] = [NO MODIFY, LEFT, UP, RIGHT]
25 */
26var map = {}
27map["あ"] = ["あ", "", "ぁ", ""]
28map["い"] = ["い", "", "ぃ", ""]
29map["う"] = ["う", "ヴ", "ぅ", ""]
30map["え"] = ["え", "", "ぇ", ""]
31map["お"] = ["お", "", "ぉ", ""]
32map["か"] = ["か", "が", "", ""]
33map["き"] = ["き", "ぎ", "", ""]
34map["く"] = ["く", "ぐ", "", ""]
35map["け"] = ["け", "げ", "", ""]
36map["こ"] = ["こ", "ご", "", ""]
37map["さ"] = ["さ", "ざ", "", ""]
38map["し"] = ["し", "じ", "", ""]
39map["す"] = ["す", "ず", "", ""]
40map["せ"] = ["せ", "ぜ", "", ""]
41map["そ"] = ["そ", "ぞ", "", ""]
42map["た"] = ["た", "だ", "", ""]
43map["ち"] = ["ち", "ぢ", "", ""]
44map["つ"] = ["つ", "づ", "っ", ""]
45map["て"] = ["て", "で", "", ""]
46map["と"] = ["と", "ど", "", ""]
47map["は"] = ["は", "ば", "", "ぱ"]
48map["ひ"] = ["ひ", "び", "", "ぴ"]
49map["ふ"] = ["ふ", "ぶ", "", "ぷ"]
50map["へ"] = ["へ", "べ", "", "ぺ"]
51map["ほ"] = ["ほ", "ぼ", "", "ぽ"]
52map["や"] = ["や", "", "ゃ", ""]
53map["("] = ["(", "「", "『", "【"]
54map["ゆ"] = ["ゆ", "", "ゅ", ""]
55map[")"] = [")", "」", "』", "】"]
56map["よ"] = ["よ", "", "ょ", ""]
57map["わ"] = ["わ", "ゐ", "ゎ", "ゑ"]
58map["ー"] = ["ー", "=", "~", "+"]
59map["、"] = ["、", "・", "…", "@"]
60map["。"] = ["。", ":", ";", "♪"]
61
62/*
63 * Reverse map for ModifierKey map
64 *
65 * This map is reverse map for modified characters.
66 */
67var normalize = {}
68normalize["ぁ"] = "あ"
69normalize["ぃ"] = "い"
70normalize["ヴ"] = "う"; normalize["ぅ"] = "う"
71normalize["ぇ"] = "え"
72normalize["ぉ"] = "お"
73normalize["が"] = "か"
74normalize["ぎ"] = "き"
75normalize["ぐ"] = "く"
76normalize["げ"] = "け"
77normalize["ご"] = "こ"
78normalize["ざ"] = "さ"
79normalize["じ"] = "し"
80normalize["ず"] = "す"
81normalize["ぜ"] = "せ"
82normalize["ぞ"] = "そ"
83normalize["だ"] = "た"
84normalize["ぢ"] = "ち"
85normalize["づ"] = "つ"; normalize["っ"] = "つ"
86normalize["で"] = "て"
87normalize["ど"] = "と"
88normalize["ば"] = "は"; normalize["ぱ"] = "は"
89normalize["び"] = "ひ"; normalize["ぴ"] = "ひ"
90normalize["ぶ"] = "ふ"; normalize["ぷ"] = "ふ"
91normalize["べ"] = "へ"; normalize["ぺ"] = "へ"
92normalize["ぼ"] = "ほ"; normalize["ぽ"] = "ほ"
93normalize["ゃ"] = "や"
94normalize["「"] = "("; normalize["『"] = "("; normalize["【"] = "("
95normalize["ゅ"] = "ゆ"
96normalize["」"] = ")"; normalize["』"] = ")"; normalize["】"] = ")"
97normalize["ょ"] = "よ"
98normalize["ゐ"] = "わ"; normalize["ゎ"] = "わ"; normalize["ゑ"] = "わ"
99normalize["="] = "ー"; normalize["~"] = "ー"; normalize["+"] = "ー"
100normalize["・"] = "、"; normalize["…"] = "、"; normalize["@"] = "、"
101normalize[":"] = "。"; normalize[";"] = "。"; normalize["♪"] = "。"
102
0103
=== added file 'plugins/ja/qml/qml.pro'
--- plugins/ja/qml/qml.pro 1970-01-01 00:00:00 +0000
+++ plugins/ja/qml/qml.pro 2016-02-19 18:07:05 +0000
@@ -0,0 +1,31 @@
1TOP_BUILDDIR = $$OUT_PWD/../../..
2TOP_SRCDIR = $$PWD/../../..
3
4include($${TOP_SRCDIR}/config.pri)
5
6TARGET = dummy
7TEMPLATE = lib
8
9lang_ja.path = "$$UBUNTU_KEYBOARD_LIB_DIR/ja/"
10lang_ja.files = *.qml *.js
11
12lang_ja_keys.path = "$$UBUNTU_KEYBOARD_LIB_DIR/ja/keys"
13lang_ja_keys.files = keys/*.qml keys/*.js
14
15INSTALLS += lang_ja lang_ja_keys
16
17# for QtCreator
18OTHER_FILES += \
19 Keyboard_ja.qml \
20 Keyboard_ja_email.qml \
21 Keyboard_ja_url.qml \
22 Keyboard_ja_url_search.qml \
23 keys/CommitKey.qml \
24 keys/CursorKey.qml \
25 keys/FlickArea.qml \
26 keys/FlickCharKey.qml \
27 keys/FlickPop.qml \
28 keys/FlickPopKey.qml \
29 keys/KanaSwitchKey.qml \
30 keys/ModifierKey.qml \
31 keys/UndoKey.qml
032
=== added directory 'plugins/ja/src'
=== added file 'plugins/ja/src/anthyadapter.cpp'
--- plugins/ja/src/anthyadapter.cpp 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/anthyadapter.cpp 2016-02-19 18:07:05 +0000
@@ -0,0 +1,117 @@
1/*
2 * Copyright 2015 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 "anthyadapter.h"
18
19#include <QDebug>
20
21#ifdef JA_DEBUG
22static void anthy_log(int level, const char *log)
23{
24 Q_UNUSED(level)
25
26 qWarning() << "[anthy]: " << QString(log);
27}
28#endif
29
30AnthyAdapter::AnthyAdapter(QObject *parent) :
31 QObject(parent)
32{
33#ifdef JA_DEBUG
34 anthy_set_logger(anthy_log, 0);
35#endif
36 if (anthy_init() < 0)
37 qCritical() << "[anthy] failed to init.";
38
39 m_context = anthy_create_context();
40 if (m_context == 0)
41 qCritical() << "[anthy] failed to create anthy context.";
42
43 anthy_context_set_encoding(m_context, ANTHY_UTF8_ENCODING);
44}
45
46AnthyAdapter::~AnthyAdapter()
47{
48 anthy_release_context(m_context);
49 anthy_quit();
50}
51
52#define CANDIDATE_SIZE 1024
53void AnthyAdapter::parse(const QString& string)
54{
55 struct anthy_conv_stat cs;
56 struct anthy_segment_stat ss;
57 char buf[CANDIDATE_SIZE];
58 QString candidate, trail;
59
60 if (anthy_set_string(m_context, string.toUtf8().constData()) != 0) {
61 qCritical() << "[anthy] failed to set string: " << string;
62 }
63
64 if (anthy_get_stat(m_context, &cs) != 0) {
65 qCritical() << "[anthy] failed to get stat: " << string;
66 }
67
68 if (anthy_get_segment_stat(m_context, 0, &ss) != 0) {
69
70 qCritical() << "[anthy] failed to get segment stat: " << string;
71 }
72
73 /* Nth segment (N > 0) use only first candidate */
74 if (cs.nr_segment > 1) {
75 for (int i = 1; i < cs.nr_segment; ++i) {
76 if (anthy_get_segment(m_context, i, 0, NULL, 0) > CANDIDATE_SIZE - 1) {
77 qCritical() << "[anthy] buffer overflow: " << string;
78 continue;
79 }
80
81 if (anthy_get_segment(m_context, i, 0, buf, sizeof(buf)) < 0) {
82 qCritical() << "[anthy] failed to get segment: " << string;
83 continue;
84 }
85
86 trail.append(buf);
87 }
88 }
89
90 /* Create candidate list for 1st segment */
91 candidates.clear();
92 candidates.append(string);
93 for (int i = 0; i < ss.nr_candidate; ++i) {
94 if (anthy_get_segment(m_context, 0, i, NULL, 0) > CANDIDATE_SIZE - 1) {
95 qCritical() << "[anthy] buffer overflow: " << string;
96 continue;
97 }
98
99 if (anthy_get_segment(m_context, 0, i, buf, sizeof(buf)) < 0) {
100 qCritical() << "[anthy] failed to get segment: " << string;
101 continue;
102 }
103
104 candidate = QString(buf);
105 candidate.append(trail);
106 candidates.append(candidate);
107 }
108
109 Q_EMIT newPredictionSuggestions(string, candidates);
110}
111
112void AnthyAdapter::wordCandidateSelected(const QString& word)
113{
114 Q_UNUSED(word)
115
116 anthy_reset_context(m_context);
117}
0118
=== added file 'plugins/ja/src/anthyadapter.h'
--- plugins/ja/src/anthyadapter.h 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/anthyadapter.h 2016-02-19 18:07:05 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright 2015 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 ANTHYADAPTER_H
18#define ANTHYADAPTER_H
19
20#include <QObject>
21#include <QStringList>
22
23#include "anthy/anthy.h"
24
25class AnthyAdapter : public QObject
26{
27 Q_OBJECT
28
29public:
30 explicit AnthyAdapter(QObject *parent = 0);
31 ~AnthyAdapter();
32
33 QStringList candidates;
34
35signals:
36 void newPredictionSuggestions(QString, QStringList);
37
38public slots:
39 void parse(const QString& string);
40 void wordCandidateSelected(const QString& word);
41
42private:
43 anthy_context_t m_context;
44};
45#endif // ANTHYADAPTER_H
046
=== added file 'plugins/ja/src/japaneselanguagefeatures.cpp'
--- plugins/ja/src/japaneselanguagefeatures.cpp 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/japaneselanguagefeatures.cpp 2016-02-19 18:07:05 +0000
@@ -0,0 +1,92 @@
1/*
2 * Copyright 2015 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 "japaneselanguagefeatures.h"
18
19JapaneseLanguageFeatures::JapaneseLanguageFeatures(QObject *parent) :
20 QObject(parent)
21{
22}
23
24JapaneseLanguageFeatures::~JapaneseLanguageFeatures()
25{
26}
27
28bool JapaneseLanguageFeatures::alwaysShowSuggestions() const
29{
30 // Japanese characters can only be entered via suggestions.
31 return true;
32}
33
34bool JapaneseLanguageFeatures::autoCapsAvailable() const
35{
36 return false;
37}
38
39bool JapaneseLanguageFeatures::activateAutoCaps(const QString &preedit) const
40{
41 Q_UNUSED(preedit)
42 return false;
43}
44
45QString JapaneseLanguageFeatures::appendixForReplacedPreedit(const QString &preedit) const
46{
47 Q_UNUSED(preedit)
48 // auto add a character in any event?
49 return QString("");
50}
51
52bool JapaneseLanguageFeatures::isSeparator(const QString &text) const
53{
54 static const QString separators = QString::fromUtf8("。、,!?:;.\r\n");
55
56 if (text.isEmpty()) {
57 return false;
58 }
59
60 if (separators.contains(text.right(1))) {
61 return true;
62 }
63
64 return false;
65}
66
67bool JapaneseLanguageFeatures::isSymbol(const QString &text) const
68{
69 Q_UNUSED(text)
70
71 return false;
72}
73
74bool JapaneseLanguageFeatures::ignoreSimilarity() const
75{
76 return true;
77}
78
79bool JapaneseLanguageFeatures::wordEngineAvailable() const
80{
81 return true;
82}
83
84bool JapaneseLanguageFeatures::enablePreeditAtInsertion() const
85{
86 return true;
87}
88
89bool JapaneseLanguageFeatures::restorePreedit() const
90{
91 return false;
92}
093
=== added file 'plugins/ja/src/japaneselanguagefeatures.h'
--- plugins/ja/src/japaneselanguagefeatures.h 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/japaneselanguagefeatures.h 2016-02-19 18:07:05 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright 2015 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 JAPANESELANGUAGEFEATURES_H
18#define JAPANESELANGUAGEFEATURES_H
19
20#include "abstractlanguagefeatures.h"
21#include <QObject>
22
23class JapaneseLanguageFeatures : public QObject, public AbstractLanguageFeatures
24{
25 Q_OBJECT
26public:
27 explicit JapaneseLanguageFeatures(QObject *parent = 0);
28 virtual ~JapaneseLanguageFeatures();
29
30 virtual bool alwaysShowSuggestions() const;
31 virtual bool autoCapsAvailable() const;
32 virtual bool activateAutoCaps(const QString &preedit) const;
33 virtual QString appendixForReplacedPreedit(const QString &preedit) const;
34 virtual bool isSeparator(const QString &text) const;
35 virtual bool isSymbol(const QString &text) const;
36 virtual bool ignoreSimilarity() const;
37 virtual bool wordEngineAvailable() const;
38 virtual bool enablePreeditAtInsertion() const;
39 virtual bool restorePreedit() const;
40};
41
42#endif // JAPANESELANGUAGEFEATURES_H
043
=== added file 'plugins/ja/src/japaneseplugin.cpp'
--- plugins/ja/src/japaneseplugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/japaneseplugin.cpp 2016-02-19 18:07:05 +0000
@@ -0,0 +1,59 @@
1#include "japaneseplugin.h"
2#include "japaneselanguagefeatures.h"
3
4#include <QDebug>
5
6JapanesePlugin::JapanesePlugin(QObject *parent) :
7 AbstractLanguagePlugin(parent)
8 , m_japaneseLanguageFeatures(new JapaneseLanguageFeatures)
9 , m_processingWord(false)
10{
11 m_anthyThread = new QThread();
12 m_anthyAdapter = new AnthyAdapter();
13 m_anthyAdapter->moveToThread(m_anthyThread);
14
15 connect(m_anthyAdapter, SIGNAL(newPredictionSuggestions(QString, QStringList)), this, SLOT(finishedProcessing(QString, QStringList)));
16 connect(this, SIGNAL(parsePredictionText(QString)), m_anthyAdapter, SLOT(parse(const QString&)));
17 connect(this, SIGNAL(candidateSelected(QString)), m_anthyAdapter, SLOT(wordCandidateSelected(const QString&)));
18
19 m_anthyThread->start();
20}
21
22JapanesePlugin::~JapanesePlugin()
23{
24 m_anthyAdapter->deleteLater();
25 m_anthyThread->quit();
26 m_anthyThread->wait();
27}
28
29AbstractLanguageFeatures* JapanesePlugin::languageFeature()
30{
31 return m_japaneseLanguageFeatures;
32}
33
34void JapanesePlugin::predict(const QString& surroundingLeft, const QString& preedit)
35{
36 Q_UNUSED(surroundingLeft)
37
38 m_nextWord = preedit;
39 if (!m_processingWord) {
40 m_processingWord = true;
41 Q_EMIT parsePredictionText(preedit);
42 }
43}
44
45void JapanesePlugin::wordCandidateSelected(QString word)
46{
47 Q_EMIT candidateSelected(word);
48}
49
50void JapanesePlugin::finishedProcessing(QString word, QStringList suggestions)
51{
52 Q_EMIT newPredictionSuggestions(word, suggestions);
53 if (word != m_nextWord) {
54 Q_EMIT parsePredictionText(m_nextWord);
55 } else {
56 m_processingWord = false;
57 }
58}
59
060
=== added file 'plugins/ja/src/japaneseplugin.h'
--- plugins/ja/src/japaneseplugin.h 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/japaneseplugin.h 2016-02-19 18:07:05 +0000
@@ -0,0 +1,43 @@
1#ifndef JAPANESEPLUGIN_H
2#define JAPANESEPLUGIN_H
3
4#include <QObject>
5#include <QThread>
6#include "languageplugininterface.h"
7#include "abstractlanguageplugin.h"
8
9#include "anthyadapter.h"
10
11class JapaneseLanguageFeatures;
12
13class JapanesePlugin : public AbstractLanguagePlugin
14{
15 Q_OBJECT
16 Q_INTERFACES(LanguagePluginInterface)
17 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.JapanesePlugin" FILE "japaneseplugin.json")
18
19public:
20 explicit JapanesePlugin(QObject* parent = 0);
21 virtual ~JapanesePlugin();
22 virtual AbstractLanguageFeatures* languageFeature();
23
24 virtual void predict(const QString& surroundingLeft, const QString& preedit);
25 virtual void wordCandidateSelected(QString word);
26
27signals:
28 void newPredictionSuggestions(QString word, QStringList suggestions);
29 void parsePredictionText(QString preedit);
30 void candidateSelected(QString word);
31
32public slots:
33 void finishedProcessing(QString word, QStringList suggestions);
34
35private:
36 JapaneseLanguageFeatures* m_japaneseLanguageFeatures;
37 QThread *m_anthyThread;
38 AnthyAdapter *m_anthyAdapter;
39 QString m_nextWord;
40 bool m_processingWord;
41};
42
43#endif // JAPANESEPLUGIN_H
044
=== added file 'plugins/ja/src/japaneseplugin.json'
--- plugins/ja/src/japaneseplugin.json 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/japaneseplugin.json 2016-02-19 18:07:05 +0000
@@ -0,0 +1,7 @@
1{
2 "IID": "org.qt-project.Qt.Examples.JapanesePlugin",
3 "MetaData": {
4 },
5 "className": "JapanesePlugin",
6 "debug": true
7}
08
=== added file 'plugins/ja/src/src.pro'
--- plugins/ja/src/src.pro 1970-01-01 00:00:00 +0000
+++ plugins/ja/src/src.pro 2016-02-19 18:07:05 +0000
@@ -0,0 +1,39 @@
1TOP_BUILDDIR = $$OUT_PWD/../../..
2TOP_SRCDIR = $$PWD/../../..
3
4include($${TOP_SRCDIR}/config.pri)
5
6TEMPLATE = lib
7CONFIG += plugin
8QT += widgets
9INCLUDEPATH += \
10 $${TOP_SRCDIR}/src/ \
11 $${TOP_SRCDIR}/src/lib/ \
12 $${TOP_SRCDIR}/src/lib/logic/
13
14HEADERS = \
15 japaneseplugin.h \
16 japaneselanguagefeatures.h \
17 anthyadapter.h \
18 $${TOP_SRCDIR}/src/lib/logic/abstractlanguageplugin.h
19
20SOURCES = \
21 japaneseplugin.cpp \
22 japaneselanguagefeatures.cpp \
23 anthyadapter.cpp \
24 $${TOP_SRCDIR}/src/lib/logic/abstractlanguageplugin.cpp
25
26TARGET = $$qtLibraryTarget(japlugin)
27
28EXAMPLE_FILES = japaneseplugin.json
29
30# generate database for presage:
31PLUGIN_INSTALL_PATH = $${UBUNTU_KEYBOARD_LIB_DIR}/ja/
32
33target.path = $$PLUGIN_INSTALL_PATH
34INSTALLS += target
35
36OTHER_FILES += \
37 jaglishplugin.json
38
39LIBS += -lpresage -lanthy -lanthydic
040
=== added directory 'plugins/ja/tests'
=== modified file 'plugins/plugins.pro'
--- plugins/plugins.pro 2015-05-11 12:52:42 +0000
+++ plugins/plugins.pro 2016-02-19 18:07:05 +0000
@@ -21,6 +21,7 @@
21 hu \21 hu \
22 is \22 is \
23 it \23 it \
24 ja \
24 nb \25 nb \
25 nl \26 nl \
26 pl \27 pl \
2728
=== modified file 'qml/keys/languages.js'
--- qml/keys/languages.js 2016-01-18 13:19:13 +0000
+++ qml/keys/languages.js 2016-02-19 18:07:05 +0000
@@ -35,6 +35,7 @@
35 if (languageId == "hu") return i18n.tr("Hungarian");35 if (languageId == "hu") return i18n.tr("Hungarian");
36 if (languageId == "is") return i18n.tr("Icelandic");36 if (languageId == "is") return i18n.tr("Icelandic");
37 if (languageId == "it") return i18n.tr("Italian");37 if (languageId == "it") return i18n.tr("Italian");
38 if (languageId == "ja") return i18n.tr("Japanese");
38 if (languageId == "nl") return i18n.tr("Dutch");39 if (languageId == "nl") return i18n.tr("Dutch");
39 if (languageId == "nb") return i18n.tr("Norwegian");40 if (languageId == "nb") return i18n.tr("Norwegian");
40 if (languageId == "pl") return i18n.tr("Polish");41 if (languageId == "pl") return i18n.tr("Polish");
4142
=== modified file 'src/lib/logic/abstractlanguagefeatures.h'
--- src/lib/logic/abstractlanguagefeatures.h 2014-12-08 14:26:19 +0000
+++ src/lib/logic/abstractlanguagefeatures.h 2016-02-19 18:07:05 +0000
@@ -54,6 +54,8 @@
54 // can be disabled by implementing this method to return true.54 // can be disabled by implementing this method to return true.
55 virtual bool ignoreSimilarity() const { return false; }55 virtual bool ignoreSimilarity() const { return false; }
56 virtual bool wordEngineAvailable() const { return false; }56 virtual bool wordEngineAvailable() const { return false; }
57 virtual bool enablePreeditAtInsertion() const { return false; }
58 virtual bool restorePreedit() const { return true; }
5759
58 Maliit::TextContentType contentType() const { return m_contentType; }60 Maliit::TextContentType contentType() const { return m_contentType; }
59 void setContentType(Maliit::TextContentType contentType) { m_contentType = contentType; }61 void setContentType(Maliit::TextContentType contentType) { m_contentType = contentType; }
6062
=== modified file 'src/lib/logic/eventhandler.cpp'
--- src/lib/logic/eventhandler.cpp 2015-07-16 13:55:08 +0000
+++ src/lib/logic/eventhandler.cpp 2016-02-19 18:07:05 +0000
@@ -84,6 +84,8 @@
8484
85 if (action == "return")85 if (action == "return")
86 key.setAction(Key::ActionReturn);86 key.setAction(Key::ActionReturn);
87 else if (action == "commit")
88 key.setAction(Key::ActionCommit);
87 else if (action == "backspace")89 else if (action == "backspace")
88 key.setAction(Key::ActionBackspace);90 key.setAction(Key::ActionBackspace);
89 else if (action == "space")91 else if (action == "space")
9092
=== modified file 'src/plugin/inputmethod.cpp'
--- src/plugin/inputmethod.cpp 2015-06-02 10:22:09 +0000
+++ src/plugin/inputmethod.cpp 2016-02-19 18:07:05 +0000
@@ -110,6 +110,10 @@
110 connect(this, SIGNAL(keyboardStateChanged(QString)), &d->editor, SLOT(onKeyboardStateChanged(QString)));110 connect(this, SIGNAL(keyboardStateChanged(QString)), &d->editor, SLOT(onKeyboardStateChanged(QString)));
111 connect(d->m_geometry, SIGNAL(visibleRectChanged()), this, SLOT(onVisibleRectChanged()));111 connect(d->m_geometry, SIGNAL(visibleRectChanged()), this, SLOT(onVisibleRectChanged()));
112 connect(&d->m_settings, SIGNAL(disableHeightChanged(bool)), this, SLOT(onVisibleRectChanged()));112 connect(&d->m_settings, SIGNAL(disableHeightChanged(bool)), this, SLOT(onVisibleRectChanged()));
113
114 connect(&d->editor, SIGNAL(preeditChanged(QString)), this, SIGNAL(preeditChanged(QString)));
115 connect(&d->editor, SIGNAL(cursorPositionChanged(int)), this, SIGNAL(cursorPositionChanged(int)));
116
113 d->registerAudioFeedbackSoundSetting();117 d->registerAudioFeedbackSoundSetting();
114 d->registerAudioFeedbackSetting();118 d->registerAudioFeedbackSetting();
115 d->registerHapticFeedbackSetting();119 d->registerHapticFeedbackSetting();
@@ -643,6 +647,31 @@
643 return d->currentPluginPath;647 return d->currentPluginPath;
644}648}
645649
650const QString &InputMethod::preedit()
651{
652 Q_D(InputMethod);
653 d->preedit = d->editor.text()->preedit();
654 return d->preedit;
655}
656
657int InputMethod::cursorPosition() const
658{
659 Q_D(const InputMethod);
660 return d->editor.text()->cursorPosition();
661}
662
663void InputMethod::replacePreedit(const QString &preedit)
664{
665 Q_D(InputMethod);
666 d->editor.replacePreedit(preedit);
667}
668
669void InputMethod::setCursorPosition(const int pos)
670{
671 Q_D(InputMethod);
672 d->editor.setCursorPosition(pos);
673}
674
646bool InputMethod::languageIsSupported(const QString plugin) {675bool InputMethod::languageIsSupported(const QString plugin) {
647 Q_D(const InputMethod);676 Q_D(const InputMethod);
648 foreach(QString pluginPath, d->pluginPaths) {677 foreach(QString pluginPath, d->pluginPaths) {
649678
=== modified file 'src/plugin/inputmethod.h'
--- src/plugin/inputmethod.h 2015-04-15 14:03:42 +0000
+++ src/plugin/inputmethod.h 2016-02-19 18:07:05 +0000
@@ -59,6 +59,8 @@
59 Q_PROPERTY(QString keyboardState READ keyboardState WRITE setKeyboardState NOTIFY keyboardStateChanged)59 Q_PROPERTY(QString keyboardState READ keyboardState WRITE setKeyboardState NOTIFY keyboardStateChanged)
60 Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY hasSelectionChanged)60 Q_PROPERTY(bool hasSelection READ hasSelection NOTIFY hasSelectionChanged)
61 Q_PROPERTY(QString currentPluginPath READ currentPluginPath NOTIFY currentPluginPathChanged)61 Q_PROPERTY(QString currentPluginPath READ currentPluginPath NOTIFY currentPluginPathChanged)
62 Q_PROPERTY(QString preedit READ preedit WRITE replacePreedit NOTIFY preeditChanged)
63 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
6264
63 Q_ENUMS(TextContentType)65 Q_ENUMS(TextContentType)
6466
@@ -126,6 +128,11 @@
126128
127 const QString currentPluginPath() const;129 const QString currentPluginPath() const;
128130
131 const QString &preedit();
132 void replacePreedit(const QString &preedit);
133 int cursorPosition() const;
134 void setCursorPosition(const int pos);
135
129 QObject* actionKeyOverride() const;136 QObject* actionKeyOverride() const;
130137
131 Q_SLOT void close();138 Q_SLOT void close();
@@ -154,6 +161,8 @@
154 void hasSelectionChanged(bool hasSelection);161 void hasSelectionChanged(bool hasSelection);
155 void currentPluginPathChanged(QString currentPluginPath);162 void currentPluginPathChanged(QString currentPluginPath);
156 void languagePluginChanged(QString pluginPath, QString languageId);163 void languagePluginChanged(QString pluginPath, QString languageId);
164 void preeditChanged(QString preedit);
165 void cursorPositionChanged(int cursor_position);
157166
158private:167private:
159 Q_SLOT void onAutoCorrectSettingChanged();168 Q_SLOT void onAutoCorrectSettingChanged();
160169
=== modified file 'src/plugin/inputmethod_p.h'
--- src/plugin/inputmethod_p.h 2015-04-15 14:03:42 +0000
+++ src/plugin/inputmethod_p.h 2016-02-19 18:07:05 +0000
@@ -61,6 +61,8 @@
61 QString keyboardState;61 QString keyboardState;
62 bool hasSelection;62 bool hasSelection;
6363
64 QString preedit;
65
64 KeyboardGeometry *m_geometry;66 KeyboardGeometry *m_geometry;
65 KeyboardSettings m_settings;67 KeyboardSettings m_settings;
66 GreeterStatus *m_greeterStatus;68 GreeterStatus *m_greeterStatus;
@@ -89,6 +91,7 @@
89 , appsCurrentOrientation(qGuiApp->primaryScreen()->orientation())91 , appsCurrentOrientation(qGuiApp->primaryScreen()->orientation())
90 , keyboardState("CHARACTERS")92 , keyboardState("CHARACTERS")
91 , hasSelection(false)93 , hasSelection(false)
94 , preedit("")
92 , m_geometry(new KeyboardGeometry(q))95 , m_geometry(new KeyboardGeometry(q))
93 , m_settings()96 , m_settings()
94 , m_greeterStatus(new GreeterStatus())97 , m_greeterStatus(new GreeterStatus())
9598
=== modified file 'src/view/abstracttexteditor.cpp'
--- src/view/abstracttexteditor.cpp 2015-07-16 13:55:08 +0000
+++ src/view/abstracttexteditor.cpp 2016-02-19 18:07:05 +0000
@@ -126,6 +126,14 @@
126//! \brief Emitted when preedit setting changes.126//! \brief Emitted when preedit setting changes.
127//! \param enabled New setting.127//! \param enabled New setting.
128128
129//! \fn void AbstractTextEditor::preeditChanged(const QString &preedit)
130//! \brief Emitted when preedit string changes.
131//! \param enabled New string.
132
133//! \fn void AbstractTextEditor::cursorPositionChanged(int pos)
134//! \brief Emitted when preedit cusor position changes.
135//! \param enabled New position.
136
129//! \fn void AbstractTextEditor::wordCandidatesChanged(const WordCandidateList &word_candidates)137//! \fn void AbstractTextEditor::wordCandidatesChanged(const WordCandidateList &word_candidates)
130//! \brief Emitted when new word candidates are generated.138//! \brief Emitted when new word candidates are generated.
131//! \param word_candidates New word candidates.139//! \param word_candidates New word candidates.
@@ -373,11 +381,13 @@
373 const bool isSymbol = d->word_engine->languageFeature()->isSymbol(text);381 const bool isSymbol = d->word_engine->languageFeature()->isSymbol(text);
374 const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty() && 382 const bool replace_preedit = d->auto_correct_enabled && not d->text->primaryCandidate().isEmpty() &&
375 not d->text->preedit().isEmpty() && isSeparator;383 not d->text->preedit().isEmpty() && isSeparator;
384 const bool enablePreeditAtInsertion = d->word_engine->languageFeature()->enablePreeditAtInsertion();
376385
377 d->previous_preedit = "";386 d->previous_preedit = "";
378387
379 if (d->preedit_enabled) {388 if (d->preedit_enabled) {
380 if (d->text->surroundingRight().left(1).contains(QRegExp("[\\w]")) || email_detected) {389 if (!enablePreeditAtInsertion &&
390 (d->text->surroundingRight().left(1).contains(QRegExp("[\\w]")) || email_detected)) {
381 // We're editing in the middle of a word or entering an email address, so just insert characters directly391 // We're editing in the middle of a word or entering an email address, so just insert characters directly
382 d->text->appendToPreedit(text);392 d->text->appendToPreedit(text);
383 commitPreedit();393 commitPreedit();
@@ -429,6 +439,9 @@
429 // standard input (like certain separators, e.g. '.' in western languages) can also trigger autoCaps439 // standard input (like certain separators, e.g. '.' in western languages) can also trigger autoCaps
430 Q_EMIT autoCapsActivated();440 Q_EMIT autoCapsActivated();
431 }441 }
442
443 Q_EMIT preeditChanged(d->text->preedit());
444 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
432 } break;445 } break;
433446
434 case Key::ActionBackspace: {447 case Key::ActionBackspace: {
@@ -505,6 +518,9 @@
505 d->text->appendToPreedit(space);518 d->text->appendToPreedit(space);
506 commitPreedit();519 commitPreedit();
507520
521 Q_EMIT preeditChanged(d->text->preedit());
522 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
523
508 if (auto_caps_activated && d->auto_caps_enabled) {524 if (auto_caps_activated && d->auto_caps_enabled) {
509 Q_EMIT autoCapsActivated();525 Q_EMIT autoCapsActivated();
510 }526 }
@@ -515,6 +531,13 @@
515 keyText = QString("\r");531 keyText = QString("\r");
516 } break;532 } break;
517533
534 case Key::ActionCommit: {
535 commitPreedit();
536
537 Q_EMIT preeditChanged(d->text->preedit());
538 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
539 } break;
540
518 case Key::ActionClose:541 case Key::ActionClose:
519 Q_EMIT keyboardClosed();542 Q_EMIT keyboardClosed();
520 break;543 break;
@@ -561,6 +584,9 @@
561 if (event_key != Qt::Key_unknown) {584 if (event_key != Qt::Key_unknown) {
562 commitPreedit();585 commitPreedit();
563 sendKeyPressAndReleaseEvents(event_key, Qt::NoModifier, keyText);586 sendKeyPressAndReleaseEvents(event_key, Qt::NoModifier, keyText);
587
588 Q_EMIT preeditChanged(d->text->preedit());
589 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
564 }590 }
565}591}
566592
@@ -614,6 +640,9 @@
614 // before sending preedit:640 // before sending preedit:
615 d->word_engine->computeCandidates(d->text.data());641 d->word_engine->computeCandidates(d->text.data());
616 sendPreeditString(d->text->preedit(), d->text->preeditFace());642 sendPreeditString(d->text->preedit(), d->text->preeditFace());
643
644 Q_EMIT preeditChanged(d->text->preedit());
645 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
617}646}
618647
619void AbstractTextEditor::replaceTextWithPreedit(const QString &replacement, int start, int len, int pos)648void AbstractTextEditor::replaceTextWithPreedit(const QString &replacement, int start, int len, int pos)
@@ -629,6 +658,9 @@
629 Replacement word_r(start, len, pos);658 Replacement word_r(start, len, pos);
630 sendPreeditString(d->text->preedit(), d->text->preeditFace(),659 sendPreeditString(d->text->preedit(), d->text->preeditFace(),
631 word_r);660 word_r);
661
662 Q_EMIT preeditChanged(d->text->preedit());
663 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
632}664}
633665
634//! \brief Replaces current preedit with given replacement and then666//! \brief Replaces current preedit with given replacement and then
@@ -662,6 +694,9 @@
662 Q_EMIT autoCapsDeactivated();694 Q_EMIT autoCapsDeactivated();
663 }695 }
664 }696 }
697
698 Q_EMIT preeditChanged(d->text->preedit());
699 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
665}700}
666701
667//! \brief Clears preedit.702//! \brief Clears preedit.
@@ -702,6 +737,27 @@
702 }737 }
703}738}
704739
740//! \brief Set cursor position of preedit.
741void AbstractTextEditor::setCursorPosition(int pos)
742{
743 Q_D(AbstractTextEditor);
744
745 if (not d->valid()) {
746 return;
747 }
748
749 if (pos == d->text->cursorPosition()) {
750 return;
751 }
752
753 d->text->setCursorPosition(pos);
754
755 sendPreeditString(d->text->preedit(), d->text->preeditFace(),
756 Replacement(d->text->cursorPosition()));
757 Q_EMIT preeditChanged(d->text->preedit());
758 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
759}
760
705//! \brief Returns whether auto-correct functionality is enabled.761//! \brief Returns whether auto-correct functionality is enabled.
706//! \sa autoCorrectEnabled762//! \sa autoCorrectEnabled
707bool AbstractTextEditor::isAutoCorrectEnabled() const763bool AbstractTextEditor::isAutoCorrectEnabled() const
@@ -906,7 +962,10 @@
906 // Clear previous word candidates962 // Clear previous word candidates
907 Q_EMIT wordCandidatesChanged(WordCandidateList());963 Q_EMIT wordCandidatesChanged(WordCandidateList());
908 sendPreeditString(d->text->preedit(), d->text->preeditFace(),964 sendPreeditString(d->text->preedit(), d->text->preeditFace(),
909 Replacement());965 Replacement(d->text->cursorPosition()));
966
967 Q_EMIT preeditChanged(d->text->preedit());
968 Q_EMIT cursorPositionChanged(d->text->cursorPosition());
910969
911 if (d->text->preedit().isEmpty()) {970 if (d->text->preedit().isEmpty()) {
912 d->word_engine->clearCandidates();971 d->word_engine->clearCandidates();
@@ -983,6 +1042,10 @@
983 return;1042 return;
984 }1043 }
9851044
1045 if(!d->word_engine->languageFeature()->restorePreedit()) {
1046 return;
1047 }
1048
986 int currentOffset = text()->surroundingOffset();1049 int currentOffset = text()->surroundingOffset();
987 if(currentOffset > 1 && currentOffset <= text()->surrounding().size()) {1050 if(currentOffset > 1 && currentOffset <= text()->surrounding().size()) {
988 QString lastChar;1051 QString lastChar;
@@ -1023,10 +1086,8 @@
1023 }1086 }
1024 d->previous_preedit = "";1087 d->previous_preedit = "";
1025 }1088 }
1026
1027 replaceTextWithPreedit(recreatedPreedit, 0, 0, recreatedPreedit.size());1089 replaceTextWithPreedit(recreatedPreedit, 0, 0, recreatedPreedit.size());
1028 }1090 }
1029
1030 }1091 }
10311092
1032 d->word_engine->computeCandidates(d->text.data());1093 d->word_engine->computeCandidates(d->text.data());
10331094
=== modified file 'src/view/abstracttexteditor.h'
--- src/view/abstracttexteditor.h 2015-03-16 13:06:42 +0000
+++ src/view/abstracttexteditor.h 2016-02-19 18:07:05 +0000
@@ -129,6 +129,10 @@
129 Q_SLOT void setPreeditEnabled(bool enabled);129 Q_SLOT void setPreeditEnabled(bool enabled);
130 Q_SIGNAL void preeditEnabledChanged(bool enabled);130 Q_SIGNAL void preeditEnabledChanged(bool enabled);
131131
132 Q_SIGNAL void preeditChanged(const QString &preedit);
133 Q_SLOT void setCursorPosition(int pos);
134 Q_SIGNAL void cursorPositionChanged(int pos);
135
132 bool isAutoCorrectEnabled() const;136 bool isAutoCorrectEnabled() const;
133 Q_SLOT void setAutoCorrectEnabled(bool enabled);137 Q_SLOT void setAutoCorrectEnabled(bool enabled);
134 Q_SIGNAL void autoCorrectEnabledChanged(bool enabled);138 Q_SIGNAL void autoCorrectEnabledChanged(bool enabled);

Subscribers

People subscribed via source and target branches