diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-08-20 21:24:02 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2017-08-21 12:48:05 +0000 |
commit | d80646f8f11283ad4bd9996d5a59a1154e7f651d (patch) | |
tree | 22c2d8c8eeb72d1b186e122a67a1738bb49ed342 | |
parent | 4bd38e1de5a893a1cf6ba04686b2ff73077d61cb (diff) |
Add Farsi handwriting
[ChangeLog] Added Farsi handwriting.
Change-Id: I1bf25cbc7f36cf8ca3f0a44b7e217a55ed3aa13a
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
10 files changed, 743 insertions, 4 deletions
diff --git a/src/virtualkeyboard/content/layouts/fa_FA/handwriting.qml b/src/virtualkeyboard/content/layouts/fa_FA/handwriting.qml new file mode 100644 index 00000000..006df195 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/fa_FA/handwriting.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2016 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: InputEngine.Arabic + readonly property bool alphabeticInputMode: [InputEngine.Latin, InputEngine.Dialable].indexOf(InputContext.inputEngine.inputMode) !== -1 + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + alphabeticInputMode ? [] : + [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 + inputModeNameList: [ + "ABC", // InputEngine.Latin + "\u0660\u0661\u0662", // InputEngine.Numeric + "123", // InputEngine.Dialable + "", // InputEngine.Pinyin + "", // InputEngine.Cangjie + "", // InputEngine.Zhuyin + "", // InputEngine.Hangul + "", // InputEngine.Hiragana + "", // InputEngine.Katakana + "", // InputEngine.FullwidthLatin + "", // InputEngine.Greek + "", // InputEngine.Cyrillic + "\u0627\u200C\u0628\u200C\u067E", // InputEngine.Arabic + ] + } + ChangeLanguageKey { + weight: 154 + customLayoutsOnly: true + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: alphabeticInputMode ? Qt.Key_Apostrophe : 0x060C + text: alphabeticInputMode ? "'" : "\u060C" + alternativeKeys: alphabeticInputMode ? "<>()#%&*/\\\"'=+-_" : "\"\u060C\u066B\u066C\u066D" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: alphabeticInputMode ? ":;,.?!" : ":\u061B.\u061F!" + } + HideKeyboardKey { + id: hideKeyboardKey + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/fa_FA/main.qml b/src/virtualkeyboard/content/layouts/fa_FA/main.qml index 3681dd2b..e73665a8 100644 --- a/src/virtualkeyboard/content/layouts/fa_FA/main.qml +++ b/src/virtualkeyboard/content/layouts/fa_FA/main.qml @@ -28,10 +28,10 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayoutLoader { - inputMode: InputEngine.Latin + inputMode: InputEngine.Arabic sourceComponent: InputContext.shift ? page2 : page1 Component { id: page1 @@ -166,6 +166,9 @@ KeyboardLayoutLoader { ChangeLanguageKey { weight: 154 } + HandwritingModeKey { + weight: 154 + } SpaceKey { weight: 864 } @@ -317,6 +320,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 595c7b79..a30bcb51 100644 --- a/src/virtualkeyboard/content/styles/default/style.qml +++ b/src/virtualkeyboard/content/styles/default/style.qml @@ -770,6 +770,8 @@ KeyboardStyle { case InputEngine.Cyrillic: return "АБВ" case InputEngine.Arabic: + if (InputContext.locale.substring(0, 2) === "fa") + return "\u0627\u200C\u0628\u200C\u067E" return "\u0623\u200C\u0628\u200C\u062C" case InputEngine.ChineseHandwriting: return "中文" diff --git a/src/virtualkeyboard/content/styles/retro/style.qml b/src/virtualkeyboard/content/styles/retro/style.qml index 888f4b50..16dfe7fc 100644 --- a/src/virtualkeyboard/content/styles/retro/style.qml +++ b/src/virtualkeyboard/content/styles/retro/style.qml @@ -884,6 +884,8 @@ KeyboardStyle { case InputEngine.Cyrillic: return "АБВ" case InputEngine.Arabic: + if (InputContext.locale.substring(0, 2) === "fa") + return "\u0627\u200C\u0628\u200C\u067E" return "\u0623\u200C\u0628\u200C\u062C" case InputEngine.ChineseHandwriting: return "中文" diff --git a/src/virtualkeyboard/t9writeinputmethod.cpp b/src/virtualkeyboard/t9writeinputmethod.cpp index 8479ae5a..baecbf47 100644 --- a/src/virtualkeyboard/t9writeinputmethod.cpp +++ b/src/virtualkeyboard/t9writeinputmethod.cpp @@ -639,7 +639,7 @@ public: } else if (language == DECUMA_LANG_SRCY) { if (inputMode != InputEngine::Cyrillic) language = DECUMA_LANG_SRLA; - } else if (language == DECUMA_LANG_AR) { + } else if (language == DECUMA_LANG_AR || language == DECUMA_LANG_FA) { if (inputMode != InputEngine::Arabic && inputMode != InputEngine::Numeric) language = DECUMA_LANG_EN; } @@ -703,7 +703,7 @@ public: break; case InputEngine::Numeric: - if (language == DECUMA_LANG_AR) { + if (language == DECUMA_LANG_AR || language == DECUMA_LANG_FA) { symbolCategories.append(DECUMA_CATEGORY_ARABIC_NUM_MODE); symbolCategories.append(DECUMA_CATEGORY_ARABIC_GESTURES); leftToRightGestures = false; diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro index 83d0b408..deac2944 100644 --- a/src/virtualkeyboard/virtualkeyboard.pro +++ b/src/virtualkeyboard/virtualkeyboard.pro @@ -142,6 +142,8 @@ contains(CONFIG, lang-fa.*) { content/layouts/fa_FA/main.qml \ content/layouts/fa_FA/numbers.qml \ content/layouts/fa_FA/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/fa_FA/handwriting.qml } contains(CONFIG, lang-fi.*) { LAYOUT_FILES += \ diff --git a/tests/auto/inputpanel/data/inputpanel/unipen_data_arabic.js b/tests/auto/inputpanel/data/inputpanel/unipen_data_arabic.js index a25d16c3..da810919 100644 --- a/tests/auto/inputpanel/data/inputpanel/unipen_data_arabic.js +++ b/tests/auto/inputpanel/data/inputpanel/unipen_data_arabic.js @@ -1166,5 +1166,500 @@ var unipenData = { ".X_POINTS_PER_INCH": 94, ".Y_DIM": 263, ".Y_POINTS_PER_INCH": 94 + }, + "0x0686": { + ".COORD": [ + "X", + "Y", + "T" + ], + ".HIERARCHY": "CHARACTER", + ".PEN": [ + [ + [ + 458, + 113, + 0 + ], + [ + 457, + 112, + 48 + ], + [ + 457, + 111, + 49 + ], + [ + 454, + 107, + 103 + ], + [ + 446, + 99, + 104 + ], + [ + 440, + 94, + 165 + ], + [ + 426, + 75, + 166 + ], + [ + 419, + 61, + 227 + ], + [ + 419, + 58, + 228 + ], + [ + 420, + 53, + 230 + ], + [ + 441, + 49, + 288 + ], + [ + 473, + 49, + 289 + ], + [ + 508, + 55, + 349 + ], + [ + 517, + 65, + 350 + ], + [ + 517, + 71, + 409 + ], + [ + 501, + 85, + 411 + ], + [ + 454, + 104, + 471 + ], + [ + 435, + 108, + 472 + ], + [ + 417, + 112, + 475 + ], + [ + 397, + 119, + 536 + ], + [ + 383, + 126, + 537 + ], + [ + 377, + 130, + 539 + ], + [ + 376, + 138, + 594 + ], + [ + 376, + 144, + 595 + ], + [ + 378, + 148, + 596 + ], + [ + 383, + 156, + 654 + ], + [ + 390, + 162, + 655 + ], + [ + 410, + 169, + 716 + ], + [ + 446, + 172, + 717 + ], + [ + 467, + 172, + 749 + ], + [ + 487, + 172, + 777 + ], + [ + 503, + 173, + 778 + ], + [ + 517, + 173, + 779 + ], + [ + 533, + 170, + 838 + ], + [ + 553, + 169, + 838 + ], + [ + 555, + 169, + 868 + ], + [ + 555, + 168, + 899 + ] + ], + [ + [ + 505, + 127, + 1279 + ], + [ + 503, + 127, + 1283 + ], + [ + 491, + 127, + 1351 + ], + [ + 475, + 128, + 1352 + ], + [ + 471, + 131, + 1412 + ], + [ + 475, + 142, + 1413 + ], + [ + 504, + 149, + 1474 + ], + [ + 512, + 145, + 1475 + ], + [ + 512, + 143, + 1539 + ], + [ + 510, + 134, + 1541 + ] + ] + ], + ".POINTS_PER_SECOND": 60, + ".SEGMENT": "CHARACTER", + ".VERSION": "1.0", + ".X_DIM": 1032, + ".X_POINTS_PER_INCH": 94, + ".Y_DIM": 263, + ".Y_POINTS_PER_INCH": 94 + }, + "0x06cc": { + ".COORD": [ + "X", + "Y", + "T" + ], + ".HIERARCHY": "CHARACTER", + ".PEN": [ + [ + [ + 399, + 119, + 0 + ], + [ + 399, + 118, + 49 + ], + [ + 399, + 116, + 50 + ], + [ + 399, + 111, + 110 + ], + [ + 399, + 107, + 110 + ], + [ + 399, + 104, + 141 + ], + [ + 398, + 99, + 171 + ], + [ + 397, + 97, + 172 + ], + [ + 395, + 88, + 173 + ], + [ + 391, + 79, + 234 + ], + [ + 384, + 70, + 236 + ], + [ + 381, + 68, + 298 + ], + [ + 380, + 67, + 298 + ], + [ + 379, + 67, + 300 + ], + [ + 376, + 67, + 353 + ], + [ + 371, + 69, + 353 + ], + [ + 366, + 71, + 356 + ], + [ + 363, + 73, + 414 + ], + [ + 357, + 78, + 415 + ], + [ + 352, + 91, + 476 + ], + [ + 349, + 105, + 477 + ], + [ + 349, + 116, + 536 + ], + [ + 355, + 129, + 537 + ], + [ + 356, + 132, + 539 + ], + [ + 357, + 137, + 596 + ], + [ + 362, + 150, + 597 + ], + [ + 363, + 156, + 661 + ], + [ + 362, + 161, + 662 + ], + [ + 359, + 165, + 717 + ], + [ + 349, + 171, + 718 + ], + [ + 331, + 178, + 777 + ], + [ + 328, + 179, + 778 + ], + [ + 320, + 181, + 780 + ], + [ + 311, + 182, + 840 + ], + [ + 297, + 182, + 841 + ], + [ + 289, + 181, + 900 + ], + [ + 284, + 179, + 901 + ], + [ + 282, + 177, + 961 + ], + [ + 276, + 170, + 962 + ], + [ + 275, + 164, + 1023 + ], + [ + 275, + 160, + 1023 + ], + [ + 275, + 156, + 1083 + ], + [ + 275, + 151, + 1084 + ], + [ + 275, + 147, + 1143 + ] + ] + ], + ".POINTS_PER_SECOND": 60, + ".SEGMENT": "CHARACTER", + ".VERSION": "1.0", + ".X_DIM": 1032, + ".X_POINTS_PER_INCH": 94, + ".Y_DIM": 263, + ".Y_POINTS_PER_INCH": 94 } } diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml index 77a7fb07..08697972 100644 --- a/tests/auto/inputpanel/data/tst_inputpanel.qml +++ b/tests/auto/inputpanel/data/tst_inputpanel.qml @@ -1122,6 +1122,7 @@ Rectangle { { initHwrMode: true, initInputMethodHints: Qt.ImhNone, initLocale: "bg_BG", initInputMode: "Cyrillic", inputSequence: "\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438", outputText: "\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438" }, { initHwrMode: true, initInputMethodHints: Qt.ImhNone, initLocale: "cs_CZ", initInputMode: "Latin", inputSequence: "ahoj", outputText: "Ahoj" }, { initHwrMode: true, initInputMethodHints: Qt.ImhNone, initLocale: "ar_AR", initInputMode: "Arabic", inputSequence: "\u0643\u062A\u0627\u0628", outputText: "\u0643\u062A\u0627\u0628" }, + { initHwrMode: true, initInputMethodHints: Qt.ImhNone, initLocale: "fa_FA", initInputMode: "Arabic", inputSequence: "\u0686\u0627\u06CC", outputText: "\u0686\u0627\u06CC" }, ] } diff --git a/tests/auto/inputpanel/hwr_test_data/arabic/1670_100_0.txt b/tests/auto/inputpanel/hwr_test_data/arabic/1670_100_0.txt new file mode 100644 index 00000000..58580245 --- /dev/null +++ b/tests/auto/inputpanel/hwr_test_data/arabic/1670_100_0.txt @@ -0,0 +1,60 @@ +.VERSION 1.0 +.HIERARCHY CHARACTER +.COORD X Y T +.SEGMENT CHARACTER +.X_DIM 1032 +.Y_DIM 263 +.X_POINTS_PER_INCH 94 +.Y_POINTS_PER_INCH 94 +.POINTS_PER_SECOND 60 +.PEN_DOWN +458 113 0 +457 112 48 +457 111 49 +454 107 103 +446 99 104 +440 94 165 +426 75 166 +419 61 227 +419 58 228 +420 53 230 +441 49 288 +473 49 289 +508 55 349 +517 65 350 +517 71 409 +501 85 411 +454 104 471 +435 108 472 +417 112 475 +397 119 536 +383 126 537 +377 130 539 +376 138 594 +376 144 595 +378 148 596 +383 156 654 +390 162 655 +410 169 716 +446 172 717 +467 172 749 +487 172 777 +503 173 778 +517 173 779 +533 170 838 +553 169 838 +555 169 868 +555 168 899 +.PEN_UP +.PEN_DOWN +505 127 1279 +503 127 1283 +491 127 1351 +475 128 1352 +471 131 1412 +475 142 1413 +504 149 1474 +512 145 1475 +512 143 1539 +510 134 1541 +.PEN_UP diff --git a/tests/auto/inputpanel/hwr_test_data/arabic/1740_100_0.txt b/tests/auto/inputpanel/hwr_test_data/arabic/1740_100_0.txt new file mode 100644 index 00000000..f119560c --- /dev/null +++ b/tests/auto/inputpanel/hwr_test_data/arabic/1740_100_0.txt @@ -0,0 +1,55 @@ +.VERSION 1.0 +.HIERARCHY CHARACTER +.COORD X Y T +.SEGMENT CHARACTER +.X_DIM 1032 +.Y_DIM 263 +.X_POINTS_PER_INCH 94 +.Y_POINTS_PER_INCH 94 +.POINTS_PER_SECOND 60 +.PEN_DOWN +399 119 0 +399 118 49 +399 116 50 +399 111 110 +399 107 110 +399 104 141 +398 99 171 +397 97 172 +395 88 173 +391 79 234 +384 70 236 +381 68 298 +380 67 298 +379 67 300 +376 67 353 +371 69 353 +366 71 356 +363 73 414 +357 78 415 +352 91 476 +349 105 477 +349 116 536 +355 129 537 +356 132 539 +357 137 596 +362 150 597 +363 156 661 +362 161 662 +359 165 717 +349 171 718 +331 178 777 +328 179 778 +320 181 780 +311 182 840 +297 182 841 +289 181 900 +284 179 901 +282 177 961 +276 170 962 +275 164 1023 +275 160 1023 +275 156 1083 +275 151 1084 +275 147 1143 +.PEN_UP |