aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-06-07 00:05:42 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-07-08 19:29:01 +0000
commitf36bdfabafb5cae85ee7883181e88b39de8af779 (patch)
tree09008f800ea6bb071fe16e98ff0a0ff8d43e3dc3 /src
parentf989e76c5072f4d5c80ca05e0e52452570368d95 (diff)
Add support for Japanese handwriting (T9 Write CJK)
This change adds handwriting support for Japanese. Change-Id: Ifc8f0e32c8b3211c13aee8be5cb2e05fae09d3b7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/virtualkeyboard/content/components/InputModeKey.qml1
-rw-r--r--src/virtualkeyboard/content/layouts/ja_JP/handwriting.qml116
-rw-r--r--src/virtualkeyboard/content/layouts/ja_JP/main.qml10
-rw-r--r--src/virtualkeyboard/content/styles/default/style.qml2
-rw-r--r--src/virtualkeyboard/content/styles/retro/style.qml2
-rw-r--r--src/virtualkeyboard/inputengine.cpp1
-rw-r--r--src/virtualkeyboard/inputengine.h1
-rw-r--r--src/virtualkeyboard/shifthandler.cpp2
-rw-r--r--src/virtualkeyboard/t9writeinputmethod.cpp42
-rw-r--r--src/virtualkeyboard/virtualkeyboard.pro2
10 files changed, 170 insertions, 9 deletions
diff --git a/src/virtualkeyboard/content/components/InputModeKey.qml b/src/virtualkeyboard/content/components/InputModeKey.qml
index 141413e8..dc4c8266 100644
--- a/src/virtualkeyboard/content/components/InputModeKey.qml
+++ b/src/virtualkeyboard/content/components/InputModeKey.qml
@@ -69,6 +69,7 @@ Key {
"カ", // InputEngine.Katakana
"全角", // InputEngine.FullwidthLatin
"中文", // InputEngine.ChineseHandwriting
+ "日本語", // InputEngine.JapaneseHandwriting
"한국어", // InputEngine.KoreanHandwriting
]
diff --git a/src/virtualkeyboard/content/layouts/ja_JP/handwriting.qml b/src/virtualkeyboard/content/layouts/ja_JP/handwriting.qml
new file mode 100644
index 00000000..0820cbbc
--- /dev/null
+++ b/src/virtualkeyboard/content/layouts/ja_JP/handwriting.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.Layouts 1.0
+import QtQuick.VirtualKeyboard 2.3
+
+KeyboardLayout {
+ function createInputMethod() {
+ return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent)
+ }
+ sharedLayouts: ['symbols']
+ inputMode: preferredInputMode()
+
+ Connections {
+ target: InputContext
+ onInputMethodHintsChanged: {
+ var newInputMode = preferredInputMode()
+ if (InputContext.inputEngine.inputModes.indexOf(newInputMode) !== -1)
+ InputContext.inputEngine.inputMode = newInputMode
+ }
+ }
+
+ function preferredInputMode() {
+ return InputContext.inputMethodHints &
+ (Qt.ImhPreferLatin | Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly |
+ Qt.ImhLatinOnly) ? InputEngine.Latin : InputEngine.JapaneseHandwriting
+ }
+
+ KeyboardRow {
+ Layout.preferredHeight: 3
+ KeyboardColumn {
+ Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width
+ KeyboardRow {
+ TraceInputKey {
+ objectName: "hwrInputArea"
+ patternRecognitionMode: InputEngine.HandwritingRecoginition
+ horizontalRulers:
+ InputContext.inputEngine.inputMode !== InputEngine.JapaneseHandwriting ? [] :
+ [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3]
+
+ }
+ }
+ }
+ KeyboardColumn {
+ Layout.preferredWidth: hideKeyboardKey.width
+ KeyboardRow {
+ BackspaceKey {}
+ }
+ KeyboardRow {
+ EnterKey {}
+ }
+ KeyboardRow {
+ ShiftKey { }
+ }
+ }
+ }
+ KeyboardRow {
+ id: bottomRow
+ Layout.preferredHeight: 1
+ keyWeight: 154
+ InputModeKey {
+ weight: 217
+ }
+ ChangeLanguageKey {
+ weight: 154
+ customLayoutsOnly: true
+ }
+ HandwritingModeKey {
+ weight: 154
+ }
+ SpaceKey {
+ weight: 864
+ }
+ Key {
+ key: Qt.Key_Apostrophe
+ text: "‘"
+ alternativeKeys: "《》〈〉•…々〆‘’“”「」¥"
+ }
+ Key {
+ key: Qt.Key_Period
+ text: "."
+ alternativeKeys: ":;,.、。?!"
+ }
+ HideKeyboardKey {
+ id: hideKeyboardKey
+ weight: 204
+ }
+ }
+}
diff --git a/src/virtualkeyboard/content/layouts/ja_JP/main.qml b/src/virtualkeyboard/content/layouts/ja_JP/main.qml
index 772702af..06d8fd0b 100644
--- a/src/virtualkeyboard/content/layouts/ja_JP/main.qml
+++ b/src/virtualkeyboard/content/layouts/ja_JP/main.qml
@@ -189,10 +189,11 @@ KeyboardLayoutLoader {
KeyboardRow {
keyWeight: 154
SymbolModeKey {
- weight: 217
+ weight: 194
}
ChangeLanguageKey {
- weight: 174
+ }
+ HandwritingModeKey {
}
Key {
key: Qt.Key_Left
@@ -378,10 +379,11 @@ KeyboardLayoutLoader {
KeyboardRow {
keyWeight: 154
SymbolModeKey {
- weight: 217
+ weight: 194
}
ChangeLanguageKey {
- weight: 174
+ }
+ HandwritingModeKey {
}
Key {
key: Qt.Key_Left
diff --git a/src/virtualkeyboard/content/styles/default/style.qml b/src/virtualkeyboard/content/styles/default/style.qml
index e759616e..b4848f68 100644
--- a/src/virtualkeyboard/content/styles/default/style.qml
+++ b/src/virtualkeyboard/content/styles/default/style.qml
@@ -764,6 +764,8 @@ KeyboardStyle {
return "123"
case InputEngine.ChineseHandwriting:
return "中文"
+ case InputEngine.JapaneseHandwriting:
+ return "日本語"
case InputEngine.KoreanHandwriting:
return "한국어"
default:
diff --git a/src/virtualkeyboard/content/styles/retro/style.qml b/src/virtualkeyboard/content/styles/retro/style.qml
index 68905852..26def327 100644
--- a/src/virtualkeyboard/content/styles/retro/style.qml
+++ b/src/virtualkeyboard/content/styles/retro/style.qml
@@ -878,6 +878,8 @@ KeyboardStyle {
return "123"
case InputEngine.ChineseHandwriting:
return "中文"
+ case InputEngine.JapaneseHandwriting:
+ return "日本語"
case InputEngine.KoreanHandwriting:
return "한국어"
default:
diff --git a/src/virtualkeyboard/inputengine.cpp b/src/virtualkeyboard/inputengine.cpp
index 811b04ca..097e99bd 100644
--- a/src/virtualkeyboard/inputengine.cpp
+++ b/src/virtualkeyboard/inputengine.cpp
@@ -765,6 +765,7 @@ void InputEngine::timerEvent(QTimerEvent *timerEvent)
\li \c InputEngine.Katakana Katakana input mode for Japanese.
\li \c InputEngine.FullwidthLatin Fullwidth latin input mode for East Asian languages.
\li \c InputEngine.ChineseHandwriting Chinese handwriting.
+ \li \c InputEngine.JapaneseHandwriting Japanese handwriting.
\li \c InputEngine.KoreanHandwriting Korean handwriting.
\endlist
*/
diff --git a/src/virtualkeyboard/inputengine.h b/src/virtualkeyboard/inputengine.h
index e8622f63..2d7980d1 100644
--- a/src/virtualkeyboard/inputengine.h
+++ b/src/virtualkeyboard/inputengine.h
@@ -75,6 +75,7 @@ public:
Katakana,
FullwidthLatin,
ChineseHandwriting,
+ JapaneseHandwriting,
KoreanHandwriting
};
enum PatternRecognitionMode {
diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp
index 47328d60..62d23775 100644
--- a/src/virtualkeyboard/shifthandler.cpp
+++ b/src/virtualkeyboard/shifthandler.cpp
@@ -51,7 +51,7 @@ public:
resetWhenVisible(false),
manualShiftLanguageFilter(QSet<QLocale::Language>() << QLocale::Arabic << QLocale::Persian << QLocale::Hindi << QLocale::Korean),
manualCapsInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::Cangjie << InputEngine::Zhuyin),
- noAutoUppercaseInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::FullwidthLatin << InputEngine::Pinyin << InputEngine::Cangjie << InputEngine::Zhuyin << InputEngine::ChineseHandwriting << InputEngine::KoreanHandwriting),
+ noAutoUppercaseInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::FullwidthLatin << InputEngine::Pinyin << InputEngine::Cangjie << InputEngine::Zhuyin << InputEngine::ChineseHandwriting << InputEngine::JapaneseHandwriting << InputEngine::KoreanHandwriting),
allCapsInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::Hiragana << InputEngine::Katakana)
{
timer.start();
diff --git a/src/virtualkeyboard/t9writeinputmethod.cpp b/src/virtualkeyboard/t9writeinputmethod.cpp
index c9e5829b..d081fad2 100644
--- a/src/virtualkeyboard/t9writeinputmethod.cpp
+++ b/src/virtualkeyboard/t9writeinputmethod.cpp
@@ -455,6 +455,9 @@ public:
return SimplifiedChinese;
break;
}
+ case QLocale::Japanese:
+ return Japanese;
+ break;
case QLocale::Korean:
return Korean;
default:
@@ -620,6 +623,9 @@ public:
language = DECUMA_LANG_EN;
else if (locale.script() == QLocale::TraditionalChineseScript)
language = (locale.country() == QLocale::HongKong) ? DECUMA_LANG_HK : DECUMA_LANG_TW;
+ } else if (language == DECUMA_LANG_JP) {
+ if (inputMode != InputEngine::JapaneseHandwriting)
+ language = DECUMA_LANG_EN;
} else if (language == DECUMA_LANG_KO) {
if (inputMode != InputEngine::KoreanHandwriting)
language = DECUMA_LANG_EN;
@@ -642,7 +648,9 @@ public:
sessionSettings.recognitionMode = mcrMode;
// Use scrMode with hidden text or with no predictive mode
- if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
+ if (inputMode != InputEngine::ChineseHandwriting &&
+ inputMode != InputEngine::JapaneseHandwriting &&
+ inputMode != InputEngine::KoreanHandwriting) {
const Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints();
if (inputMethodHints.testFlag(Qt::ImhHiddenText) || inputMethodHints.testFlag(Qt::ImhNoPredictiveText))
sessionSettings.recognitionMode = scrMode;
@@ -782,6 +790,18 @@ public:
}
break;
+ case InputEngine::JapaneseHandwriting:
+ symbolCategories.append(DECUMA_CATEGORY_JIS_LEVEL_1);
+ symbolCategories.append(DECUMA_CATEGORY_JIS_LEVEL_2);
+ symbolCategories.append(DECUMA_CATEGORY_HIRAGANA);
+ symbolCategories.append(DECUMA_CATEGORY_KATAKANA);
+ symbolCategories.append(DECUMA_CATEGORY_HIRAGANASMALL);
+ symbolCategories.append(DECUMA_CATEGORY_KATAKANASMALL);
+ symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL);
+ symbolCategories.append(DECUMA_CATEGORY_CJK_GENERAL_PUNCTUATIONS);
+ symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS);
+ break;
+
case InputEngine::KoreanHandwriting:
symbolCategories.append(DECUMA_CATEGORY_HANGUL_1001_A);
symbolCategories.append(DECUMA_CATEGORY_HANGUL_1001_B);
@@ -1263,7 +1283,9 @@ public:
// Delete trace history
const InputEngine::InputMode inputMode = q->inputEngine()->inputMode();
if (sessionSettings.recognitionMode == mcrMode && !symbolStrokes.isEmpty() &&
- inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
+ inputMode != InputEngine::ChineseHandwriting &&
+ inputMode != InputEngine::JapaneseHandwriting &&
+ inputMode != InputEngine::KoreanHandwriting) {
int activeTraces = symbolStrokes.at(symbolStrokes.count() - 1).toInt();
if (symbolStrokes.count() > 1)
activeTraces += symbolStrokes.at(symbolStrokes.count() - 2).toInt();
@@ -1362,7 +1384,9 @@ public:
// Swipe right
const InputEngine::InputMode inputMode = q->inputEngine()->inputMode();
- if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
+ if (inputMode != InputEngine::ChineseHandwriting &&
+ inputMode != InputEngine::JapaneseHandwriting &&
+ inputMode != InputEngine::KoreanHandwriting) {
if (swipeAngle <= SWIPE_ANGLE_THRESHOLD || swipeAngle >= 360 - SWIPE_ANGLE_THRESHOLD) {
if (swipeTouchCount == 1) {
// Single swipe: space
@@ -1518,6 +1542,12 @@ QList<InputEngine::InputMode> T9WriteInputMethod::inputModes(const QString &loca
if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
availableInputModes.append(InputEngine::ChineseHandwriting);
break;
+ case T9WriteInputMethodPrivate::Japanese:
+ if (d->findHwrDb(T9WriteInputMethodPrivate::Japanese, d->defaultHwrDbPath).isEmpty())
+ return availableInputModes;
+ if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
+ availableInputModes.append(InputEngine::JapaneseHandwriting);
+ break;
case T9WriteInputMethodPrivate::Korean:
if (d->findHwrDb(T9WriteInputMethodPrivate::Korean, d->defaultHwrDbPath).isEmpty())
return availableInputModes;
@@ -1728,6 +1758,7 @@ bool T9WriteInputMethod::reselect(int cursorPosition, const InputEngine::Reselec
const InputEngine::InputMode inputMode = inputEngine()->inputMode();
const int maxLength = (inputMode == InputEngine::ChineseHandwriting ||
+ inputMode == InputEngine::JapaneseHandwriting ||
inputMode == InputEngine::KoreanHandwriting) ? 0 : 32;
const QString surroundingText = ic->surroundingText();
int replaceFrom = 0;
@@ -1807,8 +1838,11 @@ void T9WriteInputMethod::timerEvent(QTimerEvent *timerEvent)
d->stopResultTimer();
#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
const InputEngine::InputMode inputMode = inputEngine()->inputMode();
- if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting)
+ if (inputMode != InputEngine::ChineseHandwriting &&
+ inputMode != InputEngine::JapaneseHandwriting &&
+ inputMode != InputEngine::KoreanHandwriting) {
d->clearTraces();
+ }
#endif
} else if (d->sessionSettings.recognitionMode == scrMode) {
d->select();
diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro
index 1399d20e..5af6a00e 100644
--- a/src/virtualkeyboard/virtualkeyboard.pro
+++ b/src/virtualkeyboard/virtualkeyboard.pro
@@ -143,6 +143,8 @@ contains(CONFIG, lang-ja.*) {
LAYOUT_FILES += \
content/layouts/ja_JP/main.qml \
content/layouts/ja_JP/symbols.qml
+t9write-cjk: LAYOUT_FILES += \
+ content/layouts/ja_JP/handwriting.qml
}
contains(CONFIG, lang-ko.*) {
LAYOUT_FILES += \