aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-06-04 23:38:09 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-07-08 19:28:39 +0000
commitf989e76c5072f4d5c80ca05e0e52452570368d95 (patch)
treeb6ff8807f30d08ea7b857ba33bf683ec675282c4 /src
parenta82fd907ad378a412efdb39aff39f5b6d41996f4 (diff)
Add support for Korean handwriting (T9 Write CJK)
This change adds handwriting support for Korean. Change-Id: I77eb322020c39259d9609051100c40b271a62c04 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/ko_KR/handwriting.qml118
-rw-r--r--src/virtualkeyboard/content/layouts/ko_KR/main.qml6
-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.h3
-rw-r--r--src/virtualkeyboard/shifthandler.cpp2
-rw-r--r--src/virtualkeyboard/t9writeinputmethod.cpp30
-rw-r--r--src/virtualkeyboard/virtualkeyboard.pro2
10 files changed, 160 insertions, 7 deletions
diff --git a/src/virtualkeyboard/content/components/InputModeKey.qml b/src/virtualkeyboard/content/components/InputModeKey.qml
index d880867f..141413e8 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.KoreanHandwriting
]
function __nextInputMode(inputMode) {
diff --git a/src/virtualkeyboard/content/layouts/ko_KR/handwriting.qml b/src/virtualkeyboard/content/layouts/ko_KR/handwriting.qml
new file mode 100644
index 00000000..58fb566b
--- /dev/null
+++ b/src/virtualkeyboard/content/layouts/ko_KR/handwriting.qml
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** 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.KoreanHandwriting
+ }
+
+ KeyboardRow {
+ Layout.preferredHeight: 3
+ KeyboardColumn {
+ Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width
+ KeyboardRow {
+ TraceInputKey {
+ objectName: "hwrInputArea"
+ patternRecognitionMode: InputEngine.HandwritingRecoginition
+ horizontalRulers:
+ InputContext.inputEngine.inputMode !== InputEngine.KoreanHandwriting ? [] :
+ [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 {
+ enabled: InputContext.inputEngine.inputMode !== InputEngine.KoreanHandwriting
+ }
+ }
+ }
+ }
+ 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/ko_KR/main.qml b/src/virtualkeyboard/content/layouts/ko_KR/main.qml
index 8c9e6fcb..525a0392 100644
--- a/src/virtualkeyboard/content/layouts/ko_KR/main.qml
+++ b/src/virtualkeyboard/content/layouts/ko_KR/main.qml
@@ -152,6 +152,9 @@ KeyboardLayoutLoader {
ChangeLanguageKey {
weight: 154
}
+ HandwritingModeKey {
+ weight: 154
+ }
SpaceKey {
weight: 864
}
@@ -286,6 +289,9 @@ KeyboardLayoutLoader {
ChangeLanguageKey {
weight: 154
}
+ HandwritingModeKey {
+ weight: 154
+ }
SpaceKey {
weight: 864
}
diff --git a/src/virtualkeyboard/content/styles/default/style.qml b/src/virtualkeyboard/content/styles/default/style.qml
index 9d00bb11..e759616e 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.KoreanHandwriting:
+ return "한국어"
default:
return "Abc"
}
diff --git a/src/virtualkeyboard/content/styles/retro/style.qml b/src/virtualkeyboard/content/styles/retro/style.qml
index 3751608b..68905852 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.KoreanHandwriting:
+ return "한국어"
default:
return "Abc"
}
diff --git a/src/virtualkeyboard/inputengine.cpp b/src/virtualkeyboard/inputengine.cpp
index dd04f645..811b04ca 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.KoreanHandwriting Korean handwriting.
\endlist
*/
diff --git a/src/virtualkeyboard/inputengine.h b/src/virtualkeyboard/inputengine.h
index d1b99ae4..e8622f63 100644
--- a/src/virtualkeyboard/inputengine.h
+++ b/src/virtualkeyboard/inputengine.h
@@ -74,7 +74,8 @@ public:
Hiragana,
Katakana,
FullwidthLatin,
- ChineseHandwriting
+ ChineseHandwriting,
+ KoreanHandwriting
};
enum PatternRecognitionMode {
PatternRecognitionDisabled,
diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp
index a5f80d05..47328d60 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),
+ noAutoUppercaseInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::FullwidthLatin << InputEngine::Pinyin << InputEngine::Cangjie << InputEngine::Zhuyin << InputEngine::ChineseHandwriting << 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 ee69d49d..c9e5829b 100644
--- a/src/virtualkeyboard/t9writeinputmethod.cpp
+++ b/src/virtualkeyboard/t9writeinputmethod.cpp
@@ -455,6 +455,8 @@ public:
return SimplifiedChinese;
break;
}
+ case QLocale::Korean:
+ return Korean;
default:
break;
}
@@ -618,6 +620,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_KO) {
+ if (inputMode != InputEngine::KoreanHandwriting)
+ language = DECUMA_LANG_EN;
}
return language;
@@ -637,7 +642,7 @@ public:
sessionSettings.recognitionMode = mcrMode;
// Use scrMode with hidden text or with no predictive mode
- if (inputMode != InputEngine::ChineseHandwriting) {
+ if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
const Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints();
if (inputMethodHints.testFlag(Qt::ImhHiddenText) || inputMethodHints.testFlag(Qt::ImhNoPredictiveText))
sessionSettings.recognitionMode = scrMode;
@@ -777,6 +782,14 @@ public:
}
break;
+ case InputEngine::KoreanHandwriting:
+ symbolCategories.append(DECUMA_CATEGORY_HANGUL_1001_A);
+ symbolCategories.append(DECUMA_CATEGORY_HANGUL_1001_B);
+ symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL);
+ symbolCategories.append(DECUMA_CATEGORY_CJK_GENERAL_PUNCTUATIONS);
+ symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS);
+ break;
+
default:
return false;
}
@@ -1250,7 +1263,7 @@ public:
// Delete trace history
const InputEngine::InputMode inputMode = q->inputEngine()->inputMode();
if (sessionSettings.recognitionMode == mcrMode && !symbolStrokes.isEmpty() &&
- inputMode != InputEngine::ChineseHandwriting) {
+ inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
int activeTraces = symbolStrokes.at(symbolStrokes.count() - 1).toInt();
if (symbolStrokes.count() > 1)
activeTraces += symbolStrokes.at(symbolStrokes.count() - 2).toInt();
@@ -1349,7 +1362,7 @@ public:
// Swipe right
const InputEngine::InputMode inputMode = q->inputEngine()->inputMode();
- if (inputMode != InputEngine::ChineseHandwriting) {
+ if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting) {
if (swipeAngle <= SWIPE_ANGLE_THRESHOLD || swipeAngle >= 360 - SWIPE_ANGLE_THRESHOLD) {
if (swipeTouchCount == 1) {
// Single swipe: space
@@ -1505,6 +1518,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::Korean:
+ if (d->findHwrDb(T9WriteInputMethodPrivate::Korean, d->defaultHwrDbPath).isEmpty())
+ return availableInputModes;
+ if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
+ availableInputModes.append(InputEngine::KoreanHandwriting);
+ break;
#endif
default:
return availableInputModes;
@@ -1708,7 +1727,8 @@ bool T9WriteInputMethod::reselect(int cursorPosition, const InputEngine::Reselec
return false;
const InputEngine::InputMode inputMode = inputEngine()->inputMode();
- const int maxLength = inputMode == InputEngine::ChineseHandwriting ? 0 : 32;
+ const int maxLength = (inputMode == InputEngine::ChineseHandwriting ||
+ inputMode == InputEngine::KoreanHandwriting) ? 0 : 32;
const QString surroundingText = ic->surroundingText();
int replaceFrom = 0;
@@ -1787,7 +1807,7 @@ void T9WriteInputMethod::timerEvent(QTimerEvent *timerEvent)
d->stopResultTimer();
#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
const InputEngine::InputMode inputMode = inputEngine()->inputMode();
- if (inputMode != InputEngine::ChineseHandwriting)
+ if (inputMode != InputEngine::ChineseHandwriting && inputMode != InputEngine::KoreanHandwriting)
d->clearTraces();
#endif
} else if (d->sessionSettings.recognitionMode == scrMode) {
diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro
index cfbd55c7..1399d20e 100644
--- a/src/virtualkeyboard/virtualkeyboard.pro
+++ b/src/virtualkeyboard/virtualkeyboard.pro
@@ -148,6 +148,8 @@ contains(CONFIG, lang-ko.*) {
LAYOUT_FILES += \
content/layouts/ko_KR/main.qml \
content/layouts/ko_KR/symbols.qml
+t9write-cjk: LAYOUT_FILES += \
+ content/layouts/ko_KR/handwriting.qml
}
contains(CONFIG, lang-nb.*) {
LAYOUT_FILES += \