diff options
Diffstat (limited to 'src')
97 files changed, 10465 insertions, 830 deletions
diff --git a/src/config.pri b/src/config.pri index 11ae1c0b..21ba6842 100644 --- a/src/config.pri +++ b/src/config.pri @@ -4,6 +4,11 @@ handwriting:!lipi-toolkit:!t9write { equals(T9WRITE_FOUND, 1): CONFIG += t9write else: CONFIG += lipi-toolkit } +t9write { + !handwriting: include(virtualkeyboard/3rdparty/t9write/t9write-build.pri) + equals(T9WRITE_CJK_FOUND, 1): CONFIG += t9write-cjk + equals(T9WRITE_ALPHABETIC_FOUND, 1): CONFIG += t9write-alphabetic +} # Disable built-in layouts disable-layouts { @@ -27,22 +32,31 @@ disable-layouts { # Flag for activating all languages lang-all: CONFIG += \ lang-ar_AR \ + lang-bg_BG \ + lang-cs_CZ \ lang-da_DK \ lang-de_DE \ + lang-el_GR \ lang-en_GB \ lang-es_ES \ + lang-et_EE \ lang-fa_FA \ lang-fi_FI \ lang-fr_FR \ + lang-he_IL \ lang-hi_IN \ + lang-hr_HR \ + lang-hu_HU \ lang-it_IT \ lang-ja_JP \ lang-ko_KR \ lang-nb_NO \ + lang-nl_NL \ lang-pl_PL \ lang-pt_PT \ lang-ro_RO \ lang-ru_RU \ + lang-sr_SP \ lang-sv_SE \ lang-zh_CN \ lang-zh_TW diff --git a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/composingtext.cpp b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/composingtext.cpp index e299c6db..82022c8e 100644 --- a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/composingtext.cpp +++ b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/composingtext.cpp @@ -22,7 +22,6 @@ #include "composingtext.h" #include <QtCore/private/qobject_p.h> -#include <QDebug> class ComposingTextPrivate : public QObjectPrivate { @@ -208,14 +207,11 @@ void ComposingText::debugout() const { Q_D(const ComposingText); for (int i = LAYER0; i < MAX_LAYER; i++) { - qDebug() << QString("ComposingText[%1]").arg(i); - qDebug() << " cur =" << d->mCursor[i]; QString tmp; for (QList<StrSegment>::ConstIterator it = d->mStringLayer[i].constBegin(); it != d->mStringLayer[i].constEnd(); it++) { tmp += QString("(%1,%2,%3)").arg(it->string).arg(it->from).arg(it->to); } - qDebug() << " str =" << tmp; } } diff --git a/src/virtualkeyboard/3rdparty/t9write/t9write-build.pri b/src/virtualkeyboard/3rdparty/t9write/t9write-build.pri index ab519b90..f810badf 100644 --- a/src/virtualkeyboard/3rdparty/t9write/t9write-build.pri +++ b/src/virtualkeyboard/3rdparty/t9write/t9write-build.pri @@ -1,25 +1,83 @@ # # Automatically detects the T9Write build directory and sets the following variables: # -# T9WRITE_BUILD_DIR: A base directory for the architecture specific build directory -# T9WRITE_ALPHABETIC_OBJ: Absolute path to the target object file +# T9WRITE_FOUND: 0/1 T9Write SDK found +# T9WRITE_BUILD_STATIC: 0/1 Static libraries found (0 == shared libraries) +# T9WRITE_ALPHABETIC_FOUND: 0/1 T9 Write Alphabetic API header found +# T9WRITE_CJK_FOUND: 0/1 T9 Write CJK API header found +# T9WRITE_INCLUDE_DIRS: T9 Write include directories +# T9WRITE_ALPHABETIC_LIBS: Absolute path to the target library file +# T9WRITE_ALPHABETIC_BINS: Absolute path to the target binary file (shared library) +# T9WRITE_CJK_LIBS: Absolute path to the target library file +# T9WRITE_CJK_BINS: Absolute path to the target binary file (shared library) # +T9WRITE_FOUND = 0 +T9WRITE_ALPHABETIC_FOUND = 0 +T9WRITE_CJK_FOUND = 0 +T9WRITE_INCLUDE_DIRS = $$PWD/api contains(QT_ARCH, arm) { - T9WRITE_BUILD_DIR = $$files(build_Android_ARM*) + T9WRITE_BUILD_SHARED_DIR = lib/arm/shared + T9WRITE_BUILD_STATIC_DIR = lib/arm/static } else:linux { - T9WRITE_BUILD_DIR = $$files(build_Android_x86*) + T9WRITE_BUILD_SHARED_DIR = lib/linux-x86/shared + T9WRITE_BUILD_STATIC_DIR = lib/linux-x86/static } else:win32 { - T9WRITE_BUILD_DIR = $$files(build_VC*) + T9WRITE_BUILD_SHARED_DIR = lib/win32/shared + T9WRITE_BUILD_STATIC_DIR = lib/win32/static } -count(T9WRITE_BUILD_DIR, 1) { - T9WRITE_FOUND = 1 - T9WRITE_INCLUDE_DIRS = \ - $$PWD/$$T9WRITE_BUILD_DIR/api \ - $$PWD/$$T9WRITE_BUILD_DIR/public - T9WRITE_ALPHABETIC_LIBS = \ - $$PWD/$$files($$T9WRITE_BUILD_DIR/objects/t9write_alphabetic*.o*) -} else { - T9WRITE_FOUND = 0 +defineReplace(findStaticLibrary) { + win32 { + result = $$files($$1/*.obj) + isEmpty(result): result = $$files($$1/*.lib) + } else { + result = $$files($$1/*.o) + isEmpty(result): result = $$files($$1/*.a) + } + return($$result) +} + +defineReplace(findSharedLibrary) { + win32 { + result = $$files($$1/*.lib) + } else { + result = $$files($$1/*.so) + } + return($$result) +} + +defineReplace(findSharedBinary) { + win32 { + result = $$files($$1/*.dll) + } else { + result = $$files($$1/*.so) + } + return($$result) +} + +for(include_dir, T9WRITE_INCLUDE_DIRS) { + exists($${include_dir}/decuma_hwr.h): T9WRITE_ALPHABETIC_FOUND = 1 + exists($${include_dir}/decuma_hwr_cjk.h): T9WRITE_CJK_FOUND = 1 +} + +equals(T9WRITE_ALPHABETIC_FOUND, 1)|equals(T9WRITE_CJK_FOUND, 1) { + equals(T9WRITE_ALPHABETIC_FOUND, 1) { + T9WRITE_ALPHABETIC_LIBS = $$findSharedLibrary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/alphabetic) + !isEmpty(T9WRITE_ALPHABETIC_LIBS) { + T9WRITE_ALPHABETIC_BINS = $$findSharedBinary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/alphabetic) + } else { + T9WRITE_ALPHABETIC_LIBS = $$findStaticLibrary($$PWD/$$T9WRITE_BUILD_STATIC_DIR/alphabetic) + } + } + equals(T9WRITE_CJK_FOUND, 1) { + T9WRITE_CJK_LIBS = $$findSharedLibrary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/cjk) + !isEmpty(T9WRITE_CJK_LIBS) { + T9WRITE_CJK_BINS = $$findSharedBinary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/cjk) + } else { + T9WRITE_CJK_LIBS = $$findStaticLibrary($$PWD/$$T9WRITE_BUILD_STATIC_DIR/cjk) + } + } + equals(T9WRITE_ALPHABETIC_FOUND, 1):!isEmpty(T9WRITE_ALPHABETIC_LIBS): T9WRITE_FOUND = 1 + equals(T9WRITE_CJK_FOUND, 1):!isEmpty(T9WRITE_CJK_LIBS): T9WRITE_FOUND = 1 } diff --git a/src/virtualkeyboard/3rdparty/t9write/t9write.pro b/src/virtualkeyboard/3rdparty/t9write/t9write.pro index 05f723a7..d64f831d 100644 --- a/src/virtualkeyboard/3rdparty/t9write/t9write.pro +++ b/src/virtualkeyboard/3rdparty/t9write/t9write.pro @@ -2,18 +2,21 @@ TARGET = qtt9write_db CONFIG += static -T9WRITE_LDBS = $$files(databases/XT9_LDBs/*.ldb) - T9WRITE_RESOURCE_FILES = \ - databases/HWR_LatinCG/_databas_le.bin \ - $$T9WRITE_LDBS + $$files(data/arabic/*.bin) \ + $$files(data/hebrew/*.bin) \ + $$files(data/*.bin) \ + $$files(data/*.ldb) \ + $$files(data/*.hdb) \ + $$files(data/*.phd) # Note: Compression is disabled, because the resource is accessed directly from the memory QMAKE_RESOURCE_FLAGS += -no-compress +CONFIG += resources_big include(../../generateresource.pri) -RESOURCES += $$generate_resource(t9write_db.qrc, $$T9WRITE_RESOURCE_FILES) +RESOURCES += $$generate_resource(t9write_db.qrc, $$T9WRITE_RESOURCE_FILES, /QtQuick/VirtualKeyboard/T9Write) load(qt_helper_lib) diff --git a/src/virtualkeyboard/3rdparty/t9write/unpack.py b/src/virtualkeyboard/3rdparty/t9write/unpack.py new file mode 100644 index 00000000..e6a3e7a1 --- /dev/null +++ b/src/virtualkeyboard/3rdparty/t9write/unpack.py @@ -0,0 +1,274 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################# +## +## 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 os +import sys +import zipfile +import tempfile +import shutil +import fnmatch + +# +# This utility script unpacks the T9 Write SDK to appropriate directory +# structure for Qt Virtual Keyboard. +# +# Usage: unpack.py <filename.zip> <target dir> +# unpack.py <input dir> <target dir> +# +# The script will happily overwrite existing files, so be careful. +# + +# +# Unpack rule list +# +# Each list entry is a dictionary consisting of target directory as +# key and matching pattern as value. The dictionary can be defined in +# the following ways: +# +# Note: The rules within the dictionary are executed in arbitrary order. +# Add a new list entry if the order is significant. +# +# Format: +# 1. { 'target dir 1': [ 'pattern1', 'pattern2', ... ], 'target dir 2': ... } +# - Each pattern is matched against the zip file contents. The file is +# copied to target dir if the pattern matches. Each pattern is handled +# independent of each other. +# +# 2. { 'target dir 1': [ [ 'file group pattern', 'sub pattern1', ... ] ], 'target dir 2': ... } +# - First the file group pattern is matched against the zip file contents. +# Then all the sub patterns are matched in the sub directory specified by +# the first match. If all the sub patterns match, then first match from +# file group pattern and all the matching files from sub pattterns are copied. +# The purpose of this option is to copy coupled files, e.g. DLL and LIB +# files found in the same directory. +# + +UNPACK_RULES = [ +{ # Header files +'api': [ + '*/decuma_hwr.h', + '*/decuma_hwr_cjk.h', + '*/decuma_hwr_types.h', + '*/decuma_point.h', + '*/decumaBasicTypes.h', + '*/decumaBasicTypesMinMax.h', + '*/decumaCharacterSetType.h', + '*/decumaCurve.h', + '*/decumaFunctionalSupport.h', + '*/decumaFunctionalSupportCheck.h', + '*/decumaLanguages.h', + '*/decumaLiteFunctionalSupport.h', + '*/decumaRuntimeMallocData.h', + '*/decumaStatus.h', + '*/decumaStorageSpecifiers.h', + '*/decumaSymbolCategories.h', + '*/decumaUnicodeTypes.h', + '*/t9write_alpha_version.h', + '*/t9write_api_version.h', + '*/t9write_cjk_version.h', + '*/xxt9wApiOem.h', + '*/xxt9wOem.h', +], +}, { # Data: Arabic and Hebrew database must be copied first (the file name collides with Alphabetic database) +'data/arabic': [ + '*/Arabic/*_le.bin', +], +'data/hebrew': [ + '*/Hebrew/*_le.bin', +], +}, { # Data: Alphabetic and CJK databases +'data': [ + '*/*_le.bin', + '*/*.hdb', + '*/*.phd', + '*/*.ldb', +], +}, { # Libraries +'lib/arm/static/alphabetic': [ + '*T9Write_Alpha*/*Android_ARM*/*.a', + '*T9Write_Alpha*/*Android_ARM*/*.o', +], +'lib/arm/shared/alphabetic': [ + '*T9Write_Alpha*/*Android_ARM*/*.so', +], +'lib/arm/static/cjk': [ + '*T9Write_CJK*/*Android_ARM*/*.a', + '*T9Write_CJK*/*Android_ARM*/*.o', +], +'lib/arm/shared/cjk': [ + '*T9Write_CJK*/*Android_ARM*/*.so', +], +'lib/linux/static/alphabetic': [ + '*T9Write_Alpha*/*Android_x86*/*.a', + '*T9Write_Alpha*/*Android_x86*/*.o', +], +'lib/linux/shared/alphabetic': [ + '*T9Write_Alpha*/*Android_x86*/*.so', +], +'lib/linux/static/cjk': [ + '*T9Write_CJK*/*Android_x86*/*.a', + '*T9Write_CJK*/*Android_x86*/*.o', +], +'lib/linux/shared/cjk': [ + '*T9Write_CJK*/*Android_x86*/*.so', +], +'lib/win32/static/alphabetic': [ + '*T9Write_Alpha*/*.obj', +], +'lib/win32/shared/alphabetic': [ + [ '*T9Write_Alpha*/*.dll', '*.lib' ], +], +'lib/win32/static/cjk': [ + '*T9Write_CJK*/*.obj', +], +'lib/win32/shared/cjk': [ + [ '*T9Write_CJK*/*.dll', '*.lib' ], +], +'lib/win32/shared/alphabetic': [ + [ '*T9Write_Alpha*/*.dll', '*.lib' ], +], +} +] + +# +# Blacklist +# +# File matching rules for blacklisted items. Matched before UNPACK_RULES. +# + +BLACKLIST_RULES = [ +'*__MACOSX*', +'*/.DS_Store', +] + +def blacklist(file_list): + result = [] + for file_name in file_list: + match = False + for blacklist_rule in BLACKLIST_RULES: + match = fnmatch.fnmatch(file_name, blacklist_rule) + if match: + break + if not match: + result.append(file_name) + return result + +def unzip(zip_file, target_dir): + zip_list = [] + if os.path.isdir(zip_file): + base_dir, sdk_dir = os.path.split(zip_file.replace('\\', '/').rstrip('/')) + base_dir_length = len(base_dir) + 1 if base_dir else 0 + if not 'T9Write' in sdk_dir: + print("Error: The input directory name '" + sdk_dir + "' does not contain 'T9Write'.") + print("Please unzip the file to a directory named after the zip file and try again.") + return zip_list + for root, dirs, files in os.walk(zip_file): + for file_name in files: + sub_dir = root[base_dir_length:] + dst_dir = os.path.join(target_dir, sub_dir) + if not os.path.exists(dst_dir): + os.makedirs(dst_dir) + shutil.copy2(os.path.join(root, file_name), dst_dir) + os.chmod(os.path.join(dst_dir, file_name), 0o644) + zip_list.append(os.path.join(sub_dir, file_name).replace('\\', '/')) + return zip_list + with zipfile.ZipFile(zip_file, 'r') as z: + zip_list = sorted(blacklist(z.namelist())) + zip_basename = os.path.splitext(os.path.basename(zip_file))[0] + if zip_list and zip_basename in zip_list[0]: + zip_basename = '' + zip_list = [os.path.join(zip_basename, zip_name).replace('\\', '/') for zip_name in zip_list] + z.extractall(os.path.join(target_dir, zip_basename)) + return zip_list + +def match_file_list(file_list, base_dir, fnpattern): + return [file_name for file_name in file_list \ + if fnmatch.fnmatch(file_name, fnpattern) and \ + os.path.isfile(os.path.join(base_dir, file_name))] + +def unpack(zip_list, zip_dir, out_dir): + if not zip_list: + return + + for unpack_rules in UNPACK_RULES: + process_unpack_rules(zip_list, zip_dir, out_dir, unpack_rules) + +def process_unpack_rules(zip_list, zip_dir, out_dir, unpack_rules): + for (target_dir, match_rules) in unpack_rules.items(): + for match_rule in match_rules: + # Match + match_rule_group = match_rule if isinstance(match_rule, list) else [match_rule] + match_group_candidates = [match_file_list(zip_list, zip_dir, match_rule_group[0])] + if len(match_rule_group) > 1: + while len(match_group_candidates[0]) > 0: + match_group0_candidate = match_group_candidates[0][0] + all_sub_groups_match = True + for sub_group_rule in match_rule_group[1:]: + fnpattern = os.path.join(os.path.dirname(match_group0_candidate), sub_group_rule).replace('\\', '/') + sub_group_candidates = match_file_list(zip_list, zip_dir, fnpattern) + if not sub_group_candidates: + all_sub_groups_match = False + break + match_group_candidates.append(sub_group_candidates) + if all_sub_groups_match: + match_group_candidates[0] = [match_group0_candidate] + break + else: + match_group_candidates = [match_group_candidates[0][1:]] + + # Copy + if match_group_candidates: + for match_group_candidate in match_group_candidates: + for zip_name in match_group_candidate: + dst_dir = os.path.join(out_dir, target_dir) + if not os.path.exists(dst_dir): + os.makedirs(dst_dir) + src = os.path.join(zip_dir, zip_name).replace('\\', '/') + dst = os.path.join(dst_dir, os.path.basename(zip_name)).replace('\\', '/') + print(zip_name + ' -> ' + dst) + shutil.copy2(src, dst) + zip_list.remove(zip_name) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print("Usage: %s <filename.zip> <target dir>" % os.path.basename(__file__)) + exit() + + out_dir = sys.argv[2] + zip_dir = tempfile.mkdtemp() + + try: + unpack(unzip(sys.argv[1], zip_dir), zip_dir, out_dir) + except Exception as e: + print(e) + finally: + shutil.rmtree(zip_dir) diff --git a/src/virtualkeyboard/content/components/BaseKey.qml b/src/virtualkeyboard/content/components/BaseKey.qml index 5c686adf..ae3b530f 100644 --- a/src/virtualkeyboard/content/components/BaseKey.qml +++ b/src/virtualkeyboard/content/components/BaseKey.qml @@ -79,7 +79,7 @@ Item { The default value based on the default item in the effective alternative keys. */ - property string smallText: effectiveAlternativeKeysHighlightIndex !== -1 ? effectiveAlternativeKeys[effectiveAlternativeKeysHighlightIndex] : "" + property string smallText: effectiveAlternativeKeys && effectiveAlternativeKeysHighlightIndex !== -1 ? effectiveAlternativeKeys[effectiveAlternativeKeysHighlightIndex] : "" /*! \since QtQuick.VirtualKeyboard 2.0 diff --git a/src/virtualkeyboard/content/components/CharacterPreviewBubble.qml b/src/virtualkeyboard/content/components/CharacterPreviewBubble.qml index 1f9a05a2..ee70e110 100644 --- a/src/virtualkeyboard/content/components/CharacterPreviewBubble.qml +++ b/src/virtualkeyboard/content/components/CharacterPreviewBubble.qml @@ -45,7 +45,7 @@ Item { onActiveKeyChanged: { if (activeKey && characterPreview.item !== null) { - characterPreview.item.text = InputContext.uppercase ? activeKey.text.toUpperCase() : activeKey.text + characterPreview.item.text = InputContext.uppercase ? activeKey.displayText.toUpperCase() : activeKey.displayText width = activeKey.width height = activeKey.height var position = keyboard.mapFromItem(activeKey, 0, 0) diff --git a/src/virtualkeyboard/content/components/HandwritingModeKey.qml b/src/virtualkeyboard/content/components/HandwritingModeKey.qml index b07cdcd6..815d89db 100644 --- a/src/virtualkeyboard/content/components/HandwritingModeKey.qml +++ b/src/virtualkeyboard/content/components/HandwritingModeKey.qml @@ -49,6 +49,6 @@ Key { displayText: "HWR" functionKey: true visible: keyboard.isHandwritingAvailable() - onClicked: keyboard.handwritingMode = !keyboard.handwritingMode + onClicked: keyboard.setHandwritingMode(!keyboard.handwritingMode) keyPanelDelegate: keyboard.style ? keyboard.style.handwritingKeyPanel : undefined } diff --git a/src/virtualkeyboard/content/components/InputModeKey.qml b/src/virtualkeyboard/content/components/InputModeKey.qml new file mode 100644 index 00000000..c4463a8e --- /dev/null +++ b/src/virtualkeyboard/content/components/InputModeKey.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +/*! + \qmltype InputModeKey + \inqmlmodule QtQuick.VirtualKeyboard + \ingroup qtvirtualkeyboard-qml + \inherits Key + \since QtQuick.VirtualKeyboard 2.3 + + \brief Input mode key for keyboard layouts. + + This key toggles between available \l {InputEngine::inputModes} {InputEngine.inputModes}. +*/ + +Key { + key: Qt.Key_Mode_switch + noKeyEvent: true + functionKey: true + text: InputContext.inputEngine.inputMode < inputModeNameList.length ? + inputModeNameList[InputContext.inputEngine.inputMode] : "ABC" + onClicked: InputContext.inputEngine.inputMode = __nextInputMode(InputContext.inputEngine.inputMode) + keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined + enabled: inputModeCount > 1 + + /*! + List of input mode names. + + The default list contains all known input modes for \l {InputEngine::inputMode} {InputEngine.inputMode}. + */ + property var inputModeNameList: [ + "ABC", // InputEngine.Latin + "123", // InputEngine.Numeric + "123", // InputEngine.Dialable + "拼音", // InputEngine.Pinyin + "倉頡", // InputEngine.Cangjie + "注音", // InputEngine.Zhuyin + "한글", // InputEngine.Hangul + "あ", // InputEngine.Hiragana + "カ", // InputEngine.Katakana + "全角", // InputEngine.FullwidthLatin + "ΑΒΓ", // InputEngine.Greek + "АБВ", // InputEngine.Cyrillic + "\u0623\u200C\u0628\u200C\u062C", // InputEngine.Arabic + "\u05D0\u05D1\u05D2", // InputEngine.Hebrew + "中文", // InputEngine.ChineseHandwriting + "日本語", // InputEngine.JapaneseHandwriting + "한국어", // InputEngine.KoreanHandwriting + ] + + /*! + List of input modes to toggle. + + This property allows to define a custom list of input modes to + toggle. + + The default list contains all the available input modes. + */ + property var inputModes: InputContext.inputEngine.inputModes + + /*! + This read-only property reflects the actual number of input modes + the user can cycle through this key. + */ + readonly property int inputModeCount: __inputModes !== undefined ? __inputModes.length : 0 + + property var __inputModes: __filterInputModes([].concat(InputContext.inputEngine.inputModes), inputModes) + + onInputModesChanged: { + // Check that the current input mode is included in our list + if (keyboard.active && InputContext.inputEngine.inputMode !== -1 && + __inputModes !== undefined && __inputModes.length > 0 && + __inputModes.indexOf(InputContext.inputEngine.inputMode) === -1) + InputContext.inputEngine.inputMode = __inputModes[0] + } + + function __nextInputMode(inputMode) { + if (!enabled) + return inputMode + var inputModeIndex = __inputModes.indexOf(inputMode) + 1 + if (inputModeIndex >= __inputModes.length) + inputModeIndex = 0 + return __inputModes[inputModeIndex] + } + + function __filterInputModes(inputModes, filter) { + for (var i = 0; i < inputModes.length; i++) { + if (filter.indexOf(inputModes[i]) === -1) + inputModes.splice(i, 1) + } + return inputModes + } +} diff --git a/src/virtualkeyboard/content/components/Key.qml b/src/virtualkeyboard/content/components/Key.qml index 620a3a7b..5a376310 100644 --- a/src/virtualkeyboard/content/components/Key.qml +++ b/src/virtualkeyboard/content/components/Key.qml @@ -42,6 +42,6 @@ import QtQuick 2.0 BaseKey { id: keyItem - key: !functionKey && text.length > 0 ? text.charCodeAt(0) : Qt.Key_unknown + key: !functionKey && text.length > 0 ? text.toUpperCase().charCodeAt(0) : Qt.Key_unknown keyPanelDelegate: keyboard.style ? keyboard.style.keyPanel : undefined } diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml index 2bd2ff2e..22378b44 100644 --- a/src/virtualkeyboard/content/components/Keyboard.qml +++ b/src/virtualkeyboard/content/components/Keyboard.qml @@ -48,14 +48,17 @@ Item { property string locale: localeIndex >= 0 && localeIndex < layoutsModel.count ? layoutsModel.get(localeIndex, "fileName") : "" property string inputLocale property int defaultLocaleIndex: -1 - property bool latinOnly: InputContext.inputMethodHints & Qt.ImhLatinOnly - property bool preferNumbers: InputContext.inputMethodHints & Qt.ImhPreferNumbers + readonly property bool latinOnly: InputContext.inputMethodHints & (Qt.ImhLatinOnly | Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly) + readonly property bool preferNumbers: InputContext.inputMethodHints & Qt.ImhPreferNumbers + readonly property bool dialableCharactersOnly: InputContext.inputMethodHints & Qt.ImhDialableCharactersOnly + readonly property bool formattedNumbersOnly: InputContext.inputMethodHints & Qt.ImhFormattedNumbersOnly + readonly property bool digitsOnly: InputContext.inputMethodHints & Qt.ImhDigitsOnly property string layout property string layoutType: { if (keyboard.handwritingMode) return "handwriting" - if (InputContext.inputMethodHints & Qt.ImhDialableCharactersOnly) return "dialpad" - if (InputContext.inputMethodHints & Qt.ImhFormattedNumbersOnly) return "numbers" - if (InputContext.inputMethodHints & Qt.ImhDigitsOnly) return "digits" + if (keyboard.dialableCharactersOnly) return "dialpad" + if (keyboard.formattedNumbersOnly) return "numbers" + if (keyboard.digitsOnly) return "digits" if (keyboard.symbolMode) return "symbols" return "main" } @@ -128,17 +131,14 @@ Item { updateAvailableLocaleIndices() updateLayout() } - onLatinOnlyChanged: { - if (!latinOnly) - inputModeNeedsReset = true - updateInputMethod() - } + onLatinOnlyChanged: inputModeNeedsReset = true onPreferNumbersChanged: { keyboard.symbolMode = !keyboard.handwritingMode && preferNumbers - if (!preferNumbers) - inputModeNeedsReset = true - updateInputMethod() + inputModeNeedsReset = true } + onDialableCharactersOnlyChanged: inputModeNeedsReset = true + onFormattedNumbersOnlyChanged: inputModeNeedsReset = true + onDigitsOnlyChanged: inputModeNeedsReset = true onHandwritingModeChanged: if (!keyboard.handwritingMode) keyboard.fullScreenHandwritingMode = false onFullScreenHandwritingModeChanged: if (keyboard.fullScreenHandwritingMode) keyboard.handwritingMode = true onLanguagePopupListActiveChanged: { @@ -751,6 +751,12 @@ Item { when: keyboard.layout.length > 0 } + onItemChanged: { + // Reset input mode if the new layout wants to override it + if (item && item.inputMode !== -1) + inputModeNeedsReset = true + } + MultiPointTouchArea { id: keyboardInputArea objectName: "keyboardInputArea" @@ -1139,29 +1145,30 @@ Item { var inputModes = InputContext.inputEngine.inputModes if (inputModes.length > 0) { // Reset to default input mode if the input locale has changed - if (inputModeNeedsReset) + if (inputModeNeedsReset) { inputMode = inputModes[0] - // Check the current layout for input mode override - if (keyboardLayoutLoader.item.inputMode !== -1) - inputMode = keyboardLayoutLoader.item.inputMode + // Check the current layout for input mode override + if (keyboardLayoutLoader.item.inputMode !== -1) + inputMode = keyboardLayoutLoader.item.inputMode + + // Update input mode automatically in handwriting mode + if (keyboard.handwritingMode) { + if (keyboard.dialableCharactersOnly && inputModes.indexOf(InputEngine.Dialable) !== -1) + inputMode = InputEngine.Dialable + else if ((keyboard.formattedNumbersOnly || keyboard.digitsOnly) && inputModes.indexOf(InputEngine.Numeric) !== -1) + inputMode = InputEngine.Numeric + else if (keyboardLayoutLoader.item.inputMode === -1) + inputMode = inputModes[0] + } - // Update input mode automatically in handwriting mode - if (keyboard.handwritingMode) { - if ((InputContext.inputMethodHints & Qt.ImhDialableCharactersOnly) && inputModes.indexOf(InputEngine.Dialable) !== -1) - inputMode = InputEngine.Dialable - else if ((InputContext.inputMethodHints & (Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) && inputModes.indexOf(InputEngine.Numeric) !== -1) + // Check the input method hints for input mode overrides + if (latinOnly) + inputMode = InputEngine.Latin + if (preferNumbers) inputMode = InputEngine.Numeric - else - inputMode = inputModes[0] } - // Check the input method hints for input mode overrides - if (latinOnly) - inputMode = InputEngine.Latin - if (preferNumbers) - inputMode = InputEngine.Numeric - // Make sure the input mode is supported by the current input method if (inputModes.indexOf(inputMode) === -1) inputMode = inputModes[0] @@ -1172,6 +1179,9 @@ Item { inputModeNeedsReset = false } } + + // Clear the toggle shift timer + InputContext.shiftHandler.clearToggleShiftTimer() } function updateLayout() { @@ -1349,4 +1359,10 @@ Item { function isHandwritingAvailable() { return VirtualKeyboardInputMethods.indexOf("HandwritingInputMethod") !== -1 && layoutExists(locale, "handwriting") } + + function setHandwritingMode(enabled, resetInputMode) { + if (enabled && resetInputMode) + inputModeNeedsReset = true + handwritingMode = enabled + } } diff --git a/src/virtualkeyboard/content/components/SelectionControl.qml b/src/virtualkeyboard/content/components/SelectionControl.qml index 125a8eb7..16961c23 100644 --- a/src/virtualkeyboard/content/components/SelectionControl.qml +++ b/src/virtualkeyboard/content/components/SelectionControl.qml @@ -45,7 +45,7 @@ Item { Behavior on opacity { NumberAnimation { duration: 200 } } - opacity: inputContext.anchorRectIntersectsClipRect ? 1.0 : 0.0 + opacity: inputContext !== null && inputContext.anchorRectIntersectsClipRect ? 1.0 : 0.0 MouseArea { width: parent.width * 2 @@ -77,7 +77,7 @@ Item { Behavior on opacity { NumberAnimation { duration: 200 } } - opacity: inputContext.cursorRectIntersectsClipRect ? 1.0 : 0.0 + opacity: inputContext !== null && inputContext.cursorRectIntersectsClipRect ? 1.0 : 0.0 MouseArea { width: parent.width * 2 diff --git a/src/virtualkeyboard/content/content.qrc b/src/virtualkeyboard/content/content.qrc index 431e4205..d29dbe33 100644 --- a/src/virtualkeyboard/content/content.qrc +++ b/src/virtualkeyboard/content/content.qrc @@ -30,5 +30,6 @@ <file>components/LanguagePopupList.qml</file> <file>components/SelectionControl.qml</file> <file>components/ShadowInputControl.qml</file> + <file>components/InputModeKey.qml</file> </qresource> </RCC> diff --git a/src/virtualkeyboard/content/layouts/ar_AR/handwriting.qml b/src/virtualkeyboard/content/layouts/ar_AR/handwriting.qml new file mode 100644 index 00000000..f84d47dc --- /dev/null +++ b/src/virtualkeyboard/content/layouts/ar_AR/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 + "\u0623\u200C\u0628\u200C\u062C", // 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/ar_AR/main.qml b/src/virtualkeyboard/content/layouts/ar_AR/main.qml index 9e53caca..e79847ec 100644 --- a/src/virtualkeyboard/content/layouts/ar_AR/main.qml +++ b/src/virtualkeyboard/content/layouts/ar_AR/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 @@ -163,13 +163,16 @@ KeyboardLayoutLoader { ChangeLanguageKey { weight: 154 } + HandwritingModeKey { + weight: 154 + } SpaceKey { weight: 864 } Key { key: 0x060C text: "\u060C" - alternativeKeys: ".,\u060C\u061F" + alternativeKeys: "\"\u061F\u060C.!:\u061B\u066B\u066C\u066D" } Key { key: 0xE000 @@ -312,6 +315,9 @@ KeyboardLayoutLoader { ChangeLanguageKey { weight: 154 } + HandwritingModeKey { + weight: 154 + } SpaceKey { weight: 864 } diff --git a/src/virtualkeyboard/content/layouts/bg_BG/handwriting.qml b/src/virtualkeyboard/content/layouts/bg_BG/handwriting.qml new file mode 100644 index 00000000..782f3217 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/bg_BG/handwriting.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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'] + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.Cyrillic ? [] : + [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/bg_BG/main.qml b/src/virtualkeyboard/content/layouts/bg_BG/main.qml new file mode 100644 index 00000000..f9dad187 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/bg_BG/main.qml @@ -0,0 +1,370 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayoutLoader { + sharedLayouts: ['symbols'] + sourceComponent: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? cyrillicLayout : latinLayout + Component { + id: cyrillicLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + text: "я" + } + Key { + text: "в" + } + Key { + text: "е" + } + Key { + text: "р" + } + Key { + text: "т" + } + Key { + text: "ъ" + } + Key { + text: "у" + } + Key { + text: "и" + } + Key { + text: "о" + } + Key { + text: "п" + } + Key { + text: "ч" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + text: "а" + } + Key { + text: "с" + } + Key { + text: "д" + } + Key { + text: "ф" + } + Key { + text: "г" + } + Key { + text: "х" + } + Key { + text: "й" + } + Key { + text: "к" + } + Key { + text: "л" + } + Key { + text: "ш" + } + Key { + text: "щ" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Cyrillic, InputEngine.Latin] + } + Key { + text: "з" + } + Key { + text: "ь" + } + Key { + text: "ц" + } + Key { + text: "ж" + } + Key { + text: "б" + } + Key { + text: "н" + } + Key { + text: "м" + } + Key { + text: "ю" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "!.;?" + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: latinLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "êeëèé" + } + Key { + key: Qt.Key_R + text: "r" + alternativeKeys: "ŕrř" + } + Key { + key: Qt.Key_T + text: "t" + alternativeKeys: "ţtŧť" + } + Key { + key: Qt.Key_Y + text: "y" + alternativeKeys: "ÿyýŷ" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "űūũûüuùú" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "îïīĩiìí" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "œøõôöòóo" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) ? "a@äåãâàá" : "aäåãâàá" + smallTextVisible: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "šsşś" + } + Key { + key: Qt.Key_D + text: "d" + alternativeKeys: "dđď" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + alternativeKeys: "ġgģĝğ" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + alternativeKeys: "ĺŀłļľl" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 + inputModes: [InputEngine.Cyrillic, InputEngine.Latin] + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zžż" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + alternativeKeys: "çcċčć" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + alternativeKeys: "ņńnň" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/bg_BG/symbols.qml b/src/virtualkeyboard/content/layouts/bg_BG/symbols.qml new file mode 100644 index 00000000..a649017b --- /dev/null +++ b/src/virtualkeyboard/content/layouts/bg_BG/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? "АБВ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? "АБВ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/cs_CZ/handwriting.qml b/src/virtualkeyboard/content/layouts/cs_CZ/handwriting.qml new file mode 100644 index 00000000..a8d3b59b --- /dev/null +++ b/src/virtualkeyboard/content/layouts/cs_CZ/handwriting.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: InputEngine.Latin + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + } + } + } + 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_Minus + text: "-" + alternativeKeys: "<>()#%&*/\\\"'=+-_" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ":;,.?!" + } + HideKeyboardKey { + id: hideKeyboardKey + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/cs_CZ/main.qml b/src/virtualkeyboard/content/layouts/cs_CZ/main.qml new file mode 100644 index 00000000..1a4057e8 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/cs_CZ/main.qml @@ -0,0 +1,207 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayout { + inputMode: InputEngine.Latin + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "eéě" + } + Key { + key: Qt.Key_R + text: "r" + alternativeKeys: "rř" + } + Key { + key: Qt.Key_T + text: "t" + alternativeKeys: "tť" + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zž" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "uúů" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "ií" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "oóö" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aåäá" + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "sš" + } + Key { + key: Qt.Key_D + text: "d" + alternativeKeys: "dď" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + ShiftKey {} + Key { + key: Qt.Key_Y + text: "y" + alternativeKeys: "yý" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + alternativeKeys: "cćč" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + alternativeKeys: "nń" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Minus + text: "-" + alternativeKeys: "-\"'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/cs_CZ/symbols.qml b/src/virtualkeyboard/content/layouts/cs_CZ/symbols.qml new file mode 100644 index 00000000..76c06493 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/cs_CZ/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/da_DK/handwriting.qml b/src/virtualkeyboard/content/layouts/da_DK/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/da_DK/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/da_DK/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/de_DE/handwriting.qml b/src/virtualkeyboard/content/layouts/de_DE/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/de_DE/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/de_DE/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/el_GR/handwriting.qml b/src/virtualkeyboard/content/layouts/el_GR/handwriting.qml new file mode 100644 index 00000000..03747a85 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/el_GR/handwriting.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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'] + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.Greek ? [] : + [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/el_GR/main.qml b/src/virtualkeyboard/content/layouts/el_GR/main.qml new file mode 100644 index 00000000..50b5fec1 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/el_GR/main.qml @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayoutLoader { + sharedLayouts: ['symbols'] + sourceComponent: InputContext.inputEngine.inputMode === InputEngine.Greek ? greekLayout : latinLayout + Component { + id: greekLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + text: "ς" + } + Key { + text: "ε" + alternativeKeys: "εέ" + } + Key { + text: "ρ" + } + Key { + text: "τ" + } + Key { + text: "ψ" + } + Key { + text: "υ" + alternativeKeys: "υύϋΰ" + } + Key { + text: "θ" + } + Key { + text: "ι" + alternativeKeys: "ιίϊΐ" + } + Key { + text: "ο" + alternativeKeys: "οό" + } + Key { + text: "π" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + text: "α" + alternativeKeys: "αά" + } + Key { + text: "σ" + } + Key { + text: "δ" + } + Key { + text: "φ" + } + Key { + text: "γ" + } + Key { + text: "η" + alternativeKeys: "ηή" + } + Key { + text: "ξ" + } + Key { + text: "κ" + } + Key { + text: "λ" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Greek, InputEngine.Latin] + } + Key { + text: "ζ" + } + Key { + text: "χ" + } + Key { + text: "ψ" + } + Key { + text: "ω" + alternativeKeys: "ωώ" + } + Key { + text: "β" + } + Key { + text: "ν" + } + Key { + text: "μ" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "!.;?" + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: latinLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "êeëèé" + } + Key { + key: Qt.Key_R + text: "r" + alternativeKeys: "ŕrř" + } + Key { + key: Qt.Key_T + text: "t" + alternativeKeys: "ţtŧť" + } + Key { + key: Qt.Key_Y + text: "y" + alternativeKeys: "ÿyýŷ" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "űūũûüuùú" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "îïīĩiìí" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "œøõôöòóo" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) ? "a@äåãâàá" : "aäåãâàá" + smallTextVisible: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "šsşś" + } + Key { + key: Qt.Key_D + text: "d" + alternativeKeys: "dđď" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + alternativeKeys: "ġgģĝğ" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + alternativeKeys: "ĺŀłļľl" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Greek, InputEngine.Latin] + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zžż" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + alternativeKeys: "çcċčć" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + alternativeKeys: "ņńnň" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/el_GR/symbols.qml b/src/virtualkeyboard/content/layouts/el_GR/symbols.qml new file mode 100644 index 00000000..b5eda063 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/el_GR/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Greek ? "ΑΒΓ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Greek ? "ΑΒΓ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/en_GB/handwriting.qml b/src/virtualkeyboard/content/layouts/en_GB/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/en_GB/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/en_GB/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/es_ES/handwriting.qml b/src/virtualkeyboard/content/layouts/es_ES/handwriting.qml index bbf77c10..0b929162 100644 --- a/src/virtualkeyboard/content/layouts/es_ES/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/es_ES/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/et_EE/handwriting.qml b/src/virtualkeyboard/content/layouts/et_EE/handwriting.qml new file mode 100644 index 00000000..d42de535 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/et_EE/handwriting.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: InputEngine.Latin + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + } + } + } + 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/et_EE/main.qml b/src/virtualkeyboard/content/layouts/et_EE/main.qml new file mode 100644 index 00000000..0deff352 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/et_EE/main.qml @@ -0,0 +1,215 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.1 + +KeyboardLayout { + inputMode: InputEngine.Latin + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + } + Key { + key: Qt.Key_R + text: "r" + } + Key { + key: Qt.Key_T + text: "t" + } + Key { + key: Qt.Key_Y + text: "y" + } + Key { + key: Qt.Key_U + text: "u" + } + Key { + key: Qt.Key_I + text: "i" + } + Key { + key: Qt.Key_O + text: "o" + } + Key { + key: Qt.Key_P + text: "p" + } + Key { + key: Qt.Key_Udiaeresis + text: "ü" + } + Key { + key: Qt.Key_Otilde + text: "õ" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 66 + } + Key { + key: Qt.Key_A + text: "a" + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "sš" + } + Key { + key: Qt.Key_D + text: "d" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + Key { + key: Qt.Key_Odiaeresis + text: "ö" + } + Key { + key: Qt.Key_Adiaeresis + text: "ä" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + ShiftKey { } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zž" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + Key { + key: Qt.Key_Minus + text: "-" + } + ShiftKey { + weight: 264 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/et_EE/symbols.qml b/src/virtualkeyboard/content/layouts/et_EE/symbols.qml new file mode 100644 index 00000000..49f6e709 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/et_EE/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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.1 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} 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/layouts/fi_FI/handwriting.qml b/src/virtualkeyboard/content/layouts/fi_FI/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/fi_FI/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/fi_FI/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/fr_FR/handwriting.qml b/src/virtualkeyboard/content/layouts/fr_FR/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/fr_FR/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/fr_FR/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/he_IL/handwriting.qml b/src/virtualkeyboard/content/layouts/he_IL/handwriting.qml new file mode 100644 index 00000000..321fbd42 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/he_IL/handwriting.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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'] + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.Hebrew ? [] : + [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/he_IL/main.qml b/src/virtualkeyboard/content/layouts/he_IL/main.qml new file mode 100644 index 00000000..fde3cb4b --- /dev/null +++ b/src/virtualkeyboard/content/layouts/he_IL/main.qml @@ -0,0 +1,381 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayoutLoader { + sharedLayouts: ['symbols'] + sourceComponent: InputContext.inputEngine.inputMode === InputEngine.Hebrew ? hebrewLayout : latinLayout + Component { + id: hebrewLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Apostrophe + text: "'" + alternativeKeys: "'\"" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + text: "\u05E7" + alternativeKeys: "\u05B3\u05E7\u05B8\u05BB" + } + Key { + text: "\u05E8" + } + Key { + text: "\u05D0" + } + Key { + text: "\u05D8" + } + Key { + text: "\u05D5" + alternativeKeys: [ "\u05D5", "\u05D5\u05B9", "\u05D5\u05BC" ] + } + Key { + text: "\u05DF" + } + Key { + text: "\u05DD" + } + Key { + text: "\u05E4" + alternativeKeys: "\u05B2\u05B7\u05E4" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + text: "\u05E9" + alternativeKeys: [ "\u05E9", "\u05B0", "\u05E9\u05C2", "\u05E9\u05C1" ] + } + Key { + text: "\u05D3" + alternativeKeys: "\u05D3\u05BC" + } + Key { + text: "\u05D2" + alternativeKeys: [ "\u05D2", "\u05D2\u05F3" ] + } + Key { + text: "\u05DB" + } + Key { + text: "\u05E2" + } + Key { + text: "\u05D9" + alternativeKeys: [ "\u05D9", "\u05F2\u05B7" ] + } + Key { + text: "\u05D7" + alternativeKeys: [ "\u05B9", "\u05D7", "\u05D7\u05F3", "\u05B4" ] + } + Key { + text: "\u05DC" + } + Key { + text: "\u05DA" + } + Key { + text: "\u05E3" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Hebrew, InputEngine.Latin] + } + Key { + text: "\u05D6" + alternativeKeys: [ "\u05D6", "\u05D6\u05F3" ] + } + Key { + text: "\u05E1" + alternativeKeys: "\u05E1\u05B6\u05B1" + } + Key { + text: "\u05D1" + } + Key { + text: "\u05D4" + } + Key { + text: "\u05E0" + } + Key { + text: "\u05DE" + } + Key { + text: "\u05E6" + alternativeKeys: [ "\u05E6", "\u05E6\u05F3", "\u05B5" ] + } + Key { + text: "\u05EA" + alternativeKeys: [ "\u05EA", "\u05EA\u05F3" ] + } + Key { + text: "\u05E5" + alternativeKeys: [ "\u05E5", "\u05E5\u05F3" ] + } + Key { + key: Qt.Key_Comma + text: "," + alternativeKeys: ":,;" + } + ShiftKey { + weight: 204 + enabled: false + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "!.?" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: latinLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "êeëèé" + } + Key { + key: Qt.Key_R + text: "r" + alternativeKeys: "ŕrř" + } + Key { + key: Qt.Key_T + text: "t" + alternativeKeys: "ţtŧť" + } + Key { + key: Qt.Key_Y + text: "y" + alternativeKeys: "ÿyýŷ" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "űūũûüuùú" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "îïīĩiìí" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "œøõôöòóo" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aäåãâàá" + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "šsşś" + } + Key { + key: Qt.Key_D + text: "d" + alternativeKeys: "dđď" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + alternativeKeys: "ġgģĝğ" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + alternativeKeys: "ĺŀłļľl" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Hebrew, InputEngine.Latin] + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zžż" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + alternativeKeys: "çcċčć" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + alternativeKeys: "ņńnň" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + alternativeKeys: ":,;" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "!.?" + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/he_IL/symbols.qml b/src/virtualkeyboard/content/layouts/he_IL/symbols.qml new file mode 100644 index 00000000..866a91a7 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/he_IL/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Hebrew ? "\u05D0\u05D1\u05D2" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + alternativeKeys: "$¢" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + text: "₪" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Hebrew ? "\u05D0\u05D1\u05D2" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hr_HR/handwriting.qml b/src/virtualkeyboard/content/layouts/hr_HR/handwriting.qml new file mode 100644 index 00000000..6f43e6de --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hr_HR/handwriting.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** 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: InputEngine.Latin + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + } + } + } + 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_Minus + text: "-" + alternativeKeys: "<>()#%&*/\\\"'=+-_" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ":;,.?!" + } + Key { + key: 0x102 + text: "ă" + alternativeKeys: "ăîâșț" + } + HideKeyboardKey { + id: hideKeyboardKey + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hr_HR/main.qml b/src/virtualkeyboard/content/layouts/hr_HR/main.qml new file mode 100644 index 00000000..6c4c306c --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hr_HR/main.qml @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayout { + inputMode: InputEngine.Latin + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + } + Key { + key: Qt.Key_R + text: "r" + } + Key { + key: Qt.Key_T + text: "t" + } + Key { + key: Qt.Key_Z + text: "z" + } + Key { + key: Qt.Key_U + text: "u" + } + Key { + key: Qt.Key_I + text: "i" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "oö" + } + Key { + key: Qt.Key_P + text: "p" + } + Key { + key: 0x160 + text: "š" + } + Key { + key: 0x110 + text: "đ" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aåä" + } + Key { + key: Qt.Key_S + text: "s" + } + Key { + key: Qt.Key_D + text: "d" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + Key { + key: 0x10C + text: "č" + } + Key { + key: 0x106 + text: "ć" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + ShiftKey { + weight: 166 + } + Key { + key: Qt.Key_Y + text: "y" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: 0x17D + text: "ž" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 234 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Minus + text: "-" + alternativeKeys: [ "-", "\"", "'" ] + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hr_HR/symbols.qml b/src/virtualkeyboard/content/layouts/hr_HR/symbols.qml new file mode 100644 index 00000000..76c06493 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hr_HR/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hu_HU/handwriting.qml b/src/virtualkeyboard/content/layouts/hu_HU/handwriting.qml new file mode 100644 index 00000000..a8d3b59b --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hu_HU/handwriting.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: InputEngine.Latin + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + } + } + } + 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_Minus + text: "-" + alternativeKeys: "<>()#%&*/\\\"'=+-_" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ":;,.?!" + } + HideKeyboardKey { + id: hideKeyboardKey + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hu_HU/main.qml b/src/virtualkeyboard/content/layouts/hu_HU/main.qml new file mode 100644 index 00000000..21a513a3 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hu_HU/main.qml @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayout { + inputMode: InputEngine.Latin + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "eé" + } + Key { + key: Qt.Key_R + text: "r" + } + Key { + key: Qt.Key_T + text: "t" + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zž" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "úűuü" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "ií" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "óőoö" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aåäá" + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "sš" + } + Key { + key: Qt.Key_D + text: "d" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + ShiftKey {} + Key { + key: Qt.Key_Y + text: "y" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Minus + text: "-" + alternativeKeys: "-\"'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/hu_HU/symbols.qml b/src/virtualkeyboard/content/layouts/hu_HU/symbols.qml new file mode 100644 index 00000000..76c06493 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/hu_HU/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/it_IT/handwriting.qml b/src/virtualkeyboard/content/layouts/it_IT/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/it_IT/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/it_IT/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 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..9fe3b191 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/ja_JP/handwriting.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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'] + 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 84baba97..2d765d36 100644 --- a/src/virtualkeyboard/content/layouts/ja_JP/main.qml +++ b/src/virtualkeyboard/content/layouts/ja_JP/main.qml @@ -28,11 +28,11 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayoutLoader { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; JapaneseInputMethod {}', parent, "japaneseInputMethod") + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; JapaneseInputMethod {}', parent, "japaneseInputMethod") } sharedLayouts: ['symbols'] sourceComponent: InputContext.inputEngine.inputMode === InputEngine.FullwidthLatin ? page2 : page1 @@ -129,38 +129,20 @@ KeyboardLayoutLoader { } KeyboardRow { keyWeight: 156 - Key { - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) - displayText: { - switch (InputContext.inputEngine.inputMode) { - case InputEngine.Latin: - return "\u534A\u89D2" - case InputEngine.Hiragana: - return "\u3042" - case InputEngine.Katakana: - return "\u30AB" - default: - return "" - } - } - onClicked: { - switch (InputContext.inputEngine.inputMode) { - case InputEngine.Latin: - InputContext.inputEngine.inputMode = InputEngine.FullwidthLatin - break - case InputEngine.Hiragana: - InputContext.inputEngine.inputMode = InputEngine.Katakana - break - case InputEngine.Katakana: - InputContext.inputEngine.inputMode = InputEngine.Latin - break - default: - break - } - } + InputModeKey { + enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 + inputModeNameList: [ + "半角", // InputEngine.Latin + "", // InputEngine.Numeric + "", // InputEngine.Dialable + "", // InputEngine.Pinyin + "", // InputEngine.Cangjie + "", // InputEngine.Zhuyin + "", // InputEngine.Hangul + "あ", // InputEngine.Hiragana + "カ", // InputEngine.Katakana + "全角", // InputEngine.FullwidthLatin + ] } Key { key: Qt.Key_Z @@ -207,10 +189,11 @@ KeyboardLayoutLoader { KeyboardRow { keyWeight: 154 SymbolModeKey { - weight: 217 + weight: 194 } ChangeLanguageKey { - weight: 174 + } + HandwritingModeKey { } Key { key: Qt.Key_Left @@ -349,12 +332,7 @@ KeyboardLayoutLoader { } KeyboardRow { keyWeight: 156 - Key { - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - displayText: "\u5168\u89D2" - onClicked: InputContext.inputEngine.inputMode = InputEngine.Hiragana + InputModeKey { } Key { key: Qt.Key_Z @@ -401,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/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/layouts/nb_NO/handwriting.qml b/src/virtualkeyboard/content/layouts/nb_NO/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/nb_NO/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/nb_NO/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/nl_NL/handwriting.qml b/src/virtualkeyboard/content/layouts/nl_NL/handwriting.qml new file mode 100644 index 00000000..d42de535 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/nl_NL/handwriting.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: InputEngine.Latin + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + } + } + } + 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/nl_NL/main.qml b/src/virtualkeyboard/content/layouts/nl_NL/main.qml new file mode 100644 index 00000000..1deb766a --- /dev/null +++ b/src/virtualkeyboard/content/layouts/nl_NL/main.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.1 + +KeyboardLayout { + inputMode: InputEngine.Latin + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + alternativeKeys: "êeëèé" + } + Key { + key: Qt.Key_R + text: "r" + } + Key { + key: Qt.Key_T + text: "t" + } + Key { + key: Qt.Key_Y + text: "y" + alternativeKeys: "yijÿýŷ" + } + Key { + key: Qt.Key_U + text: "u" + alternativeKeys: "űūũûüuùú" + } + Key { + key: Qt.Key_I + text: "i" + alternativeKeys: "îïīĩiìí" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "œøõôöòóo" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aäåãâàá" + } + Key { + key: Qt.Key_S + text: "s" + } + Key { + key: Qt.Key_D + text: "d" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + ShiftKey {} + Key { + key: Qt.Key_Z + text: "z" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/nl_NL/symbols.qml b/src/virtualkeyboard/content/layouts/nl_NL/symbols.qml new file mode 100644 index 00000000..49f6e709 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/nl_NL/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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.1 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/pl_PL/handwriting.qml b/src/virtualkeyboard/content/layouts/pl_PL/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/pl_PL/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/pl_PL/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/pt_PT/handwriting.qml b/src/virtualkeyboard/content/layouts/pt_PT/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/pt_PT/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/pt_PT/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/ro_RO/handwriting.qml b/src/virtualkeyboard/content/layouts/ro_RO/handwriting.qml index ab2600f5..7826b542 100644 --- a/src/virtualkeyboard/content/layouts/ro_RO/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/ro_RO/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/ru_RU/handwriting.qml b/src/virtualkeyboard/content/layouts/ru_RU/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/ru_RU/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/ru_RU/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/sr_SP/handwriting.qml b/src/virtualkeyboard/content/layouts/sr_SP/handwriting.qml new file mode 100644 index 00000000..7781e455 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/sr_SP/handwriting.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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'] + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.Cyrillic ? [] : + [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_Minus + text: "-" + alternativeKeys: "<>()#%&*/\\\"'=+-_" + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ":;,.?!" + } + HideKeyboardKey { + id: hideKeyboardKey + weight: 204 + } + } +} diff --git a/src/virtualkeyboard/content/layouts/sr_SP/main.qml b/src/virtualkeyboard/content/layouts/sr_SP/main.qml new file mode 100644 index 00000000..d739e79c --- /dev/null +++ b/src/virtualkeyboard/content/layouts/sr_SP/main.qml @@ -0,0 +1,363 @@ +/**************************************************************************** +** +** 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.VirtualKeyboard 2.3 + +KeyboardLayoutLoader { + sharedLayouts: ['symbols'] + sourceComponent: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? cyrillicLayout : latinLayout + Component { + id: cyrillicLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + text: "љ" + } + Key { + text: "њ" + } + Key { + text: "е" + } + Key { + text: "р" + } + Key { + text: "т" + } + Key { + text: "з" + } + Key { + text: "у" + } + Key { + text: "и" + } + Key { + text: "о" + } + Key { + text: "п" + } + Key { + text: "ш" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + text: "а" + } + Key { + text: "с" + } + Key { + text: "д" + } + Key { + text: "ф" + } + Key { + text: "г" + } + Key { + text: "х" + } + Key { + text: "ј" + } + Key { + text: "к" + } + Key { + text: "л" + } + Key { + text: "ч" + } + Key { + text: "ћ" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Cyrillic, InputEngine.Latin] + } + Key { + text: "ѕ" + } + Key { + text: "џ" + } + Key { + text: "ц" + } + Key { + text: "в" + } + Key { + text: "б" + } + Key { + text: "н" + } + Key { + text: "м" + } + Key { + text: "ђ" + } + Key { + text: "ж" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "!.;?" + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: latinLayout + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_Q + text: "q" + } + Key { + key: Qt.Key_W + text: "w" + } + Key { + key: Qt.Key_E + text: "e" + } + Key { + key: Qt.Key_R + text: "r" + } + Key { + key: Qt.Key_T + text: "t" + } + Key { + key: Qt.Key_Z + text: "z" + alternativeKeys: "zž" + } + Key { + key: Qt.Key_U + text: "u" + } + Key { + key: Qt.Key_I + text: "i" + } + Key { + key: Qt.Key_O + text: "o" + alternativeKeys: "oö" + } + Key { + key: Qt.Key_P + text: "p" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_A + text: "a" + alternativeKeys: "aåä" + } + Key { + key: Qt.Key_S + text: "s" + alternativeKeys: "sš" + } + Key { + key: Qt.Key_D + text: "d" + alternativeKeys: "dđ" + } + Key { + key: Qt.Key_F + text: "f" + } + Key { + key: Qt.Key_G + text: "g" + } + Key { + key: Qt.Key_H + text: "h" + } + Key { + key: Qt.Key_J + text: "j" + } + Key { + key: Qt.Key_K + text: "k" + } + Key { + key: Qt.Key_L + text: "l" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + InputModeKey { + inputModes: [InputEngine.Cyrillic, InputEngine.Latin] + } + Key { + key: Qt.Key_Y + text: "y" + } + Key { + key: Qt.Key_X + text: "x" + } + Key { + key: Qt.Key_C + text: "c" + alternativeKeys: "ćcč" + } + Key { + key: Qt.Key_V + text: "v" + } + Key { + key: Qt.Key_B + text: "b" + } + Key { + key: Qt.Key_N + text: "n" + } + Key { + key: Qt.Key_M + text: "m" + } + Key { + key: Qt.Key_Comma + text: "," + } + Key { + key: Qt.Key_Period + text: "." + } + ShiftKey { + weight: 204 + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + } + ChangeLanguageKey { + weight: 154 + } + HandwritingModeKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Minus + text: "-" + alternativeKeys: "-\"'" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/sr_SP/symbols.qml b/src/virtualkeyboard/content/layouts/sr_SP/symbols.qml new file mode 100644 index 00000000..42f8f3b6 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/sr_SP/symbols.qml @@ -0,0 +1,376 @@ +/**************************************************************************** +** +** 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 + +KeyboardLayoutLoader { + property bool secondPage + onVisibleChanged: if (!visible) secondPage = false + sourceComponent: secondPage ? page2 : page1 + Component { + id: page1 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_1 + text: "1" + } + Key { + key: Qt.Key_2 + text: "2" + } + Key { + key: Qt.Key_3 + text: "3" + } + Key { + key: Qt.Key_4 + text: "4" + } + Key { + key: Qt.Key_5 + text: "5" + } + Key { + key: Qt.Key_6 + text: "6" + } + Key { + key: Qt.Key_7 + text: "7" + } + Key { + key: Qt.Key_8 + text: "8" + } + Key { + key: Qt.Key_9 + text: "9" + } + Key { + key: Qt.Key_0 + text: "0" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_At + text: "@" + } + Key { + key: Qt.Key_NumberSign + text: "#" + } + Key { + key: Qt.Key_Percent + text: "%" + } + Key { + key: Qt.Key_Ampersand + text: "&" + } + Key { + key: Qt.Key_Asterisk + text: "*" + } + Key { + key: Qt.Key_Minus + text: "-" + } + Key { + key: Qt.Key_Plus + text: "+" + } + Key { + key: Qt.Key_ParenLeft + text: "(" + } + Key { + key: Qt.Key_ParenRight + text: ")" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Exclam + text: "!" + } + Key { + key: Qt.Key_QuoteDbl + text: '"' + } + Key { + key: Qt.Key_Apostrophe + text: "'" + } + Key { + key: Qt.Key_Less + text: "<" + } + Key { + key: Qt.Key_Greater + text: ">" + } + Key { + key: Qt.Key_Colon + text: ":" + } + Key { + key: Qt.Key_Semicolon + text: ";" + } + Key { + key: Qt.Key_Slash + text: "/" + } + Key { + key: Qt.Key_Question + text: "?" + } + Key { + weight: 204 + displayText: "1/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? "АБВ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: ".," + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } + Component { + id: page2 + KeyboardLayout { + keyWeight: 160 + KeyboardRow { + Key { + key: Qt.Key_AsciiTilde + text: "~" + } + Key { + key: Qt.Key_Agrave + text: "`" + } + Key { + key: Qt.Key_Bar + text: "|" + } + Key { + key: 0x7B + text: "·" + } + Key { + key: 0x221A + text: "√" + } + Key { + key: Qt.Key_division + text: "÷" + } + Key { + key: Qt.Key_multiply + text: "×" + } + Key { + key: Qt.Key_onehalf + text: "½" + alternativeKeys: "¼⅓½¾⅞" + } + Key { + key: Qt.Key_BraceLeft + text: "{" + } + Key { + key: Qt.Key_BraceRight + text: "}" + } + BackspaceKey {} + } + KeyboardRow { + FillerKey { + weight: 56 + } + Key { + key: Qt.Key_Dollar + text: "$" + } + Key { + key: 0x20AC + text: "€" + } + Key { + key: 0xC2 + text: "£" + } + Key { + key: 0xA2 + text: "¢" + } + Key { + key: 0xA5 + text: "¥" + } + Key { + key: Qt.Key_Equal + text: "=" + } + Key { + key: Qt.Key_section + text: "§" + } + Key { + key: Qt.Key_BracketLeft + text: "[" + } + Key { + key: Qt.Key_BracketRight + text: "]" + } + EnterKey { + weight: 283 + } + } + KeyboardRow { + keyWeight: 156 + Key { + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + Key { + key: Qt.Key_Underscore + text: "_" + } + Key { + key: 0x2122 + text: '™' + } + Key { + key: 0x00AE + text: '®' + } + Key { + key: Qt.Key_guillemotleft + text: '«' + } + Key { + key: Qt.Key_guillemotright + text: '»' + } + Key { + key: 0x201C + text: '“' + } + Key { + key: 0x201D + text: '”' + } + Key { + key: Qt.Key_Backslash + text: "\\" + } + Key { + key: Qt.Key_AsciiCircum + text: "^" + } + Key { + weight: 204 + displayText: "2/2" + functionKey: true + onClicked: secondPage = !secondPage + } + } + KeyboardRow { + keyWeight: 154 + SymbolModeKey { + weight: 217 + displayText: InputContext.inputEngine.inputMode === InputEngine.Cyrillic ? "АБВ" : "ABC" + } + ChangeLanguageKey { + weight: 154 + } + SpaceKey { + weight: 864 + } + Key { + key: 0x2026 + text: "\u2026" + } + Key { + key: 0xE000 + text: ":-)" + alternativeKeys: [ ";-)", ":-)", ":-D", ":-(", "<3" ] + } + HideKeyboardKey { + weight: 204 + } + } + } + } +} diff --git a/src/virtualkeyboard/content/layouts/sv_SE/handwriting.qml b/src/virtualkeyboard/content/layouts/sv_SE/handwriting.qml index 8f3672c9..d42de535 100644 --- a/src/virtualkeyboard/content/layouts/sv_SE/handwriting.qml +++ b/src/virtualkeyboard/content/layouts/sv_SE/handwriting.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayout { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; HandwritingInputMethod {}', parent) + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] inputMode: InputEngine.Latin @@ -66,15 +66,8 @@ KeyboardLayout { id: bottomRow Layout.preferredHeight: 1 keyWeight: 154 - Key { + InputModeKey { weight: 217 - key: Qt.Key_Mode_switch - noKeyEvent: true - functionKey: true - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "123" : "ABC" - onClicked: InputContext.inputEngine.inputMode = InputContext.inputEngine.inputMode === InputEngine.Latin ? InputEngine.Numeric : InputEngine.Latin - enabled: !(InputContext.inputMethodHints & (Qt.ImhDialableCharactersOnly | Qt.ImhFormattedNumbersOnly | Qt.ImhDigitsOnly)) - keyPanelDelegate: keyboard.style ? keyboard.style.symbolKeyPanel : undefined } ChangeLanguageKey { weight: 154 diff --git a/src/virtualkeyboard/content/layouts/zh_CN/handwriting.qml b/src/virtualkeyboard/content/layouts/zh_CN/handwriting.qml new file mode 100644 index 00000000..598980d1 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/zh_CN/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.ChineseHandwriting + } + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.ChineseHandwriting ? [] : + [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/zh_CN/main.qml b/src/virtualkeyboard/content/layouts/zh_CN/main.qml index c8e21c84..44b0ceb7 100644 --- a/src/virtualkeyboard/content/layouts/zh_CN/main.qml +++ b/src/virtualkeyboard/content/layouts/zh_CN/main.qml @@ -181,6 +181,9 @@ KeyboardLayout { ChangeLanguageKey { weight: 154 } + HandwritingModeKey { + weight: 154 + } SpaceKey { weight: 864 } diff --git a/src/virtualkeyboard/content/layouts/zh_TW/handwriting.qml b/src/virtualkeyboard/content/layouts/zh_TW/handwriting.qml new file mode 100644 index 00000000..598980d1 --- /dev/null +++ b/src/virtualkeyboard/content/layouts/zh_TW/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.ChineseHandwriting + } + + KeyboardRow { + Layout.preferredHeight: 3 + KeyboardColumn { + Layout.preferredWidth: bottomRow.width - hideKeyboardKey.width + KeyboardRow { + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.HandwritingRecoginition + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.ChineseHandwriting ? [] : + [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/zh_TW/main.qml b/src/virtualkeyboard/content/layouts/zh_TW/main.qml index a71a27c5..7c5728c7 100644 --- a/src/virtualkeyboard/content/layouts/zh_TW/main.qml +++ b/src/virtualkeyboard/content/layouts/zh_TW/main.qml @@ -29,11 +29,11 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 -import QtQuick.VirtualKeyboard 2.1 +import QtQuick.VirtualKeyboard 2.3 KeyboardLayoutLoader { function createInputMethod() { - return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.1; TCInputMethod {}', parent, "tcInputMethod") + return Qt.createQmlObject('import QtQuick 2.0; import QtQuick.VirtualKeyboard 2.3; TCInputMethod {}', parent, "tcInputMethod") } sharedLayouts: ['symbols'] sourceComponent: InputContext.inputEngine.inputMode === InputEngine.Cangjie ? pageCangjie : pageZhuyin @@ -197,11 +197,11 @@ KeyboardLayoutLoader { ChangeLanguageKey { weight: 154 } - ModeKey { + HandwritingModeKey { + weight: 154 + } + InputModeKey { visible: InputContext.inputEngine.inputModes.indexOf(InputEngine.Zhuyin) !== -1 - // Cangjie - displayText: "\u5009\u9821" - onClicked: InputContext.inputEngine.inputMode = InputEngine.Zhuyin } SpaceKey { weight: 864 @@ -246,7 +246,8 @@ KeyboardLayoutLoader { } Key { text: "\u02CB" - alternativeKeys: "\u02CB4" + alternativeKeys: "4" + displayText: "`" } Key { text: "\u3113" @@ -254,7 +255,8 @@ KeyboardLayoutLoader { } Key { text: "\u02CA" - alternativeKeys: "\u02CA6" + alternativeKeys: "6" + displayText: "´" } Key { text: "\u02D9" @@ -423,11 +425,11 @@ KeyboardLayoutLoader { ChangeLanguageKey { weight: 154 } - ModeKey { + HandwritingModeKey { + weight: 154 + } + InputModeKey { visible: InputContext.inputEngine.inputModes.indexOf(InputEngine.Cangjie) !== -1 - // Zhuyin - displayText: "\u6CE8\u97F3" - onClicked: InputContext.inputEngine.inputMode = InputEngine.Cangjie } SpaceKey { weight: 864 diff --git a/src/virtualkeyboard/content/styles/default/style.qml b/src/virtualkeyboard/content/styles/default/style.qml index 1440f008..6c49ee67 100644 --- a/src/virtualkeyboard/content/styles/default/style.qml +++ b/src/virtualkeyboard/content/styles/default/style.qml @@ -92,9 +92,9 @@ KeyboardStyle { verticalAlignment: Text.AlignVCenter anchors.fill: parent anchors.leftMargin: keyContentMargin - anchors.topMargin: control.smallTextVisible ? keyContentMargin * 1.2 : keyContentMargin + anchors.topMargin: keyContentMargin anchors.rightMargin: keyContentMargin - anchors.bottomMargin: control.smallTextVisible ? keyContentMargin * 0.8 : keyContentMargin + anchors.bottomMargin: keyContentMargin font { family: fontFamily weight: Font.Normal @@ -757,7 +757,34 @@ KeyboardStyle { Text { id: hwrInputModeIndicator visible: control.patternRecognitionMode === InputEngine.HandwritingRecoginition - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "Abc" : "123" + text: { + switch (InputContext.inputEngine.inputMode) { + case InputEngine.Numeric: + if (["ar", "fa"].indexOf(InputContext.locale.substring(0, 2)) !== -1) + return "\u0660\u0661\u0662" + // Fallthrough + case InputEngine.Dialable: + return "123" + case InputEngine.Greek: + return "ΑΒΓ" + 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.Hebrew: + return "\u05D0\u05D1\u05D2" + case InputEngine.ChineseHandwriting: + return "中文" + case InputEngine.JapaneseHandwriting: + return "日本語" + case InputEngine.KoreanHandwriting: + return "한국어" + default: + return "Abc" + } + } color: "white" anchors.left: parent.left anchors.top: parent.top @@ -786,23 +813,42 @@ KeyboardStyle { ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF) ctx.clearRect(0, 0, width, height) var i + var margin = Math.round(30 * scaleHint) if (control.horizontalRulers) { for (i = 0; i < control.horizontalRulers.length; i++) { ctx.beginPath() - ctx.moveTo(0, control.horizontalRulers[i]) - ctx.lineTo(width, control.horizontalRulers[i]) + var y = Math.round(control.horizontalRulers[i]) + var rightMargin = Math.round(width - margin) + if (i + 1 === control.horizontalRulers.length) { + ctx.moveTo(margin, y) + ctx.lineTo(rightMargin, y) + } else { + var dashLen = Math.round(20 * scaleHint) + for (var dash = margin, dashCount = 0; + dash < rightMargin; dash += dashLen, dashCount++) { + if ((dashCount & 1) === 0) { + ctx.moveTo(dash, y) + ctx.lineTo(Math.min(dash + dashLen, rightMargin), y) + } + } + } ctx.stroke() } } if (control.verticalRulers) { for (i = 0; i < control.verticalRulers.length; i++) { ctx.beginPath() - ctx.moveTo(control.verticalRulers[i], 0) - ctx.lineTo(control.verticalRulers[i], height) + ctx.moveTo(control.verticalRulers[i], margin) + ctx.lineTo(control.verticalRulers[i], Math.round(height - margin)) ctx.stroke() } } } + Connections { + target: control + onHorizontalRulersChanged: traceInputKeyGuideLines.requestPaint() + onVerticalRulersChanged: traceInputKeyGuideLines.requestPaint() + } } } diff --git a/src/virtualkeyboard/content/styles/retro/style.qml b/src/virtualkeyboard/content/styles/retro/style.qml index 0ed184b7..c22338ba 100644 --- a/src/virtualkeyboard/content/styles/retro/style.qml +++ b/src/virtualkeyboard/content/styles/retro/style.qml @@ -871,7 +871,34 @@ KeyboardStyle { Text { id: hwrInputModeIndicator visible: control.patternRecognitionMode === InputEngine.HandwritingRecoginition - text: InputContext.inputEngine.inputMode === InputEngine.Latin ? "Abc" : "123" + text: { + switch (InputContext.inputEngine.inputMode) { + case InputEngine.Numeric: + if (["ar", "fa"].indexOf(InputContext.locale.substring(0, 2)) !== -1) + return "\u0660\u0661\u0662" + // Fallthrough + case InputEngine.Dialable: + return "123" + case InputEngine.Greek: + return "ΑΒΓ" + 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.Hebrew: + return "\u05D0\u05D1\u05D2" + case InputEngine.ChineseHandwriting: + return "中文" + case InputEngine.JapaneseHandwriting: + return "日本語" + case InputEngine.KoreanHandwriting: + return "한국어" + default: + return "Abc" + } + } color: "black" anchors.left: parent.left anchors.top: parent.top @@ -892,18 +919,32 @@ KeyboardStyle { Canvas { id: traceInputKeyGuideLines anchors.fill: traceInputKeyPanelBackground - opacity: 0.1 + opacity: 0.4 onPaint: { var ctx = getContext("2d") ctx.lineWidth = 1 - ctx.strokeStyle = Qt.rgba(0xFF, 0xFF, 0xFF) + ctx.strokeStyle = Qt.rgba(0, 0, 0) ctx.clearRect(0, 0, width, height) var i + var margin = Math.round(30 * scaleHint) if (control.horizontalRulers) { for (i = 0; i < control.horizontalRulers.length; i++) { ctx.beginPath() - ctx.moveTo(0, control.horizontalRulers[i]) - ctx.lineTo(width, control.horizontalRulers[i]) + var y = Math.round(control.horizontalRulers[i]) + var rightMargin = Math.round(width - margin) + if (i + 1 === control.horizontalRulers.length) { + ctx.moveTo(margin, y) + ctx.lineTo(rightMargin, y) + } else { + var dashLen = Math.round(20 * scaleHint) + for (var dash = margin, dashCount = 0; + dash < rightMargin; dash += dashLen, dashCount++) { + if ((dashCount & 1) === 0) { + ctx.moveTo(dash, y) + ctx.lineTo(Math.min(dash + dashLen, rightMargin), y) + } + } + } ctx.stroke() } } @@ -916,6 +957,11 @@ KeyboardStyle { } } } + Connections { + target: control + onHorizontalRulersChanged: traceInputKeyGuideLines.requestPaint() + onVerticalRulersChanged: traceInputKeyGuideLines.requestPaint() + } } } diff --git a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf index 2698378e..fbb0d465 100644 --- a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf +++ b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf @@ -13,6 +13,9 @@ excludedirs += ../content/layouts \ exampledirs += ../../../examples/virtualkeyboard \ snippets examplesinstallpath = virtualkeyboard + +manifestmeta.highlighted.names = "QtVirtualKeyboard/Qt Quick Virtual Keyboard - Basic Example" + imagedirs += images depends += qtdoc qtcore qtgui qtqml qtquick diff --git a/src/virtualkeyboard/doc/src/build.qdoc b/src/virtualkeyboard/doc/src/build.qdoc index 3d9d9eac..a858cdea 100644 --- a/src/virtualkeyboard/doc/src/build.qdoc +++ b/src/virtualkeyboard/doc/src/build.qdoc @@ -281,6 +281,140 @@ Hunspell sources and dictionary files is listed below: (etc.) \endcode +\section2 T9 Write Integration + +T9 Write integration supports the T9 Write Alphabetic and T9 Write CJK engines. Both +engines are integrated via T9WriteInputMethod. The input method can be initialized +with either of the engines at runtime. The engine selection happens automatically +based on input locale and input mode from the keyboard. + +\section3 T9 Write Compatibility + +Qt Virtual Keyboard is compatible with T9 Write v7.5.0 onward. + +The latest tested version is v7.8.1. + +\section3 T9 Write Build Preparations + +The contents of the SDK must be either manually copied to the directory structure +described below, or by using the \e unpack.py script found in the t9write directory. + +To unpack the SDK using the script: + +\badcode +$ cd src/virtualkeyboard/3rdparty/t9write/ +$ python unpack.py T9Write_Alpha_v7-8-0_SDK.zip . +\endcode + +\badcode +3rdparty +└── t9write + ├─── api + │ ├─── decuma*.h + │ ├─── t9write*.h + │ └─── xxt9w*.h + ├─── data + │ ├─── arabic + │ │ └─── *.bin [T9 Write Arabic] + │ ├─── hebrew + │ │ └─── *.bin [T9 Write Hebrew] + │ ├─── *.bin [T9 Write Alphabetic] + │ ├─── *.hdb + │ ├─── *.phd + │ └─── *.ldb [T9 Write v7.5] + └─── lib + ├─── arm + │ ├─── shared + │ │ ├─── alphabetic + │ │ │ └─── *.so + │ │ └─── cjk + │ │ └─── *.so + │ └─── static + │ ├─── alphabetic + │ │ └─── *.a / *.o + │ └─── cjk + │ └─── *.a / *.o + ├─── linux-x86 + │ ├─── shared + │ │ ├─── alphabetic + │ │ │ └─── *.so + │ │ └─── cjk + │ │ └─── *.so + │ └─── static + │ ├─── alphabetic + │ │ └─── *.a / *.o + │ └─── cjk + │ └─── *.a / *.o + └─── win32 + ├─── shared + │ ├─── alphabetic + │ │ ├─── *.dll + │ │ └─── *.lib + │ └─── cjk + │ ├─── *.dll + │ └─── *.lib + └─── static + ├─── alphabetic + │ └─── *.lib / *.obj + └─── cjk + └─── *.lib / *.obj +\endcode + +\note The above files are from the T9 Write demo SDK for Windows; the contents may vary for other + platforms. + +Where the contents of each directory are: + +\table +\header + \li Directory + \li Description + \li Remarks +\row + \li \e api + \li This directory should contain all of the API files + \li The API files usually located in the "api" and "public" directories + of the SDK, but sometimes in the "demo" directory. + + When using both Alphabetic and CJK engines at the same time, any + overlapping files can be copied from either SDK. +\row + \li \e data + \li This directory should contain all HWR databases and optionally + XT9 databases. + \li HWR database for the T9 Write Alphabetic: + \list + \li \e _databas_le.bin + \endlist + + HWR database for the T9 Write CJK: + \list + \li \e cjk_HK_std_le.hdb HongKong Chinese + \li \e cjk_J_std_le.hdb Japanese + \li \e cjk_K_mkt_le.hdb Korean + \li \e cjk_S_gb18030_le.hdb Simplified Chinese + \li \e cjk_T_std_le.hdb Traditional Chinese + \endlist + + Language database: + \list + \li File extension is either \e .ldb or \e .phd + \endlist +\row + \li \e lib/<target>/<linkage>/<engine-variant> + \li Directory structure holding supported target builds. + \li These directories should hold the desired target libraries. + If both shared and static libraries are found, shared libraries + are preferred. + + For example, to enable a static win32 build, copy + \e t9write_alphabetic_rel.obj to \e lib/win32/static/alphabetic + directory. +\endtable + +Finally, the SDK is included in the build by adding CONFIG+=t9write to the +qmake command line. + \section2 Static builds The virtual keyboard can be built and linked statically against the application. diff --git a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc index 61b11d26..ef2bf69f 100644 --- a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc +++ b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc @@ -40,7 +40,44 @@ \ingroup qtvirtualkeyboard-examples \image basic-example.png - The example shows how to build a virtual keyboard UI with support for - multiple keyboard layouts using QML, and a QPlatformInputContext bridge - for communicating between the keyboard and focused text editor in C++. + The example has two implementations: one for the desktop + platforms and another for the embedded platforms. The former version + enables text input into several text fields using the virtual keyboard, + whereas the latter version uses the same UI but with a custom virtual + keyboard InputPanel. The following snippet from + \c basic.pro shows how the qmake project is set up to choose the + appropriate implementation based on the CONFIG options: + + \quotefromfile basic/basic.pro + \skipto android-embedded + \printuntil /^\}$/ + + The example enables the virtual keyboard by setting the \c QT_IM_MODULE + environment variable before loading the \c .qml file: + + \quotefromfile basic/main.cpp + \skipto #include + \printuntil } + + Besides this, it uses custom TextField and TextArea items to configure the + \e[ENTER] key behavior using the EnterKeyAction attached property. + + \quotefromfile basic/Basic.qml + \skipto import + \printuntil Rectangle + \dots + \skipto TextField + \printuntil } + \dots + \skipto TextArea + \printuntil } + \skipto /^\}$/ + \printuntil } + + The TextField and TextArea are inherited from the TextBase custom type, + which has \c enterKeyEnabled, \c enterKeyText, and \c enterKeyAction + properties. The TextField and TextArea instances in the snippet can + set these properties to change the default behavior. + + \include examples-run.qdocinc */ diff --git a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc index 91373b23..21be028c 100644 --- a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc +++ b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc @@ -50,7 +50,7 @@ \li Automatic capitalization and space insertion. \li Scalability to different resolutions. \li Support for different character sets (Latin, Simplified/Traditional Chinese, - Hindi, Japanese, Arabic, Korean, and others). + Hindi, Japanese, Arabic, Hebrew, Korean, and others). \li Support for most common input \l {Supported Languages}{languages}, with possibility to easily extend the language support. \li Left-to-right and right-to-left input. @@ -66,12 +66,20 @@ \list \li Arabic + \li Bulgarian + \li Croatian + \li Czech \li Danish + \li Dutch \li English + \li Estonian \li Finnish \li French \li German + \li Greek + \li Hebrew \li Hindi + \li Hungarian \li Italian \li Japanese \li Korean @@ -81,6 +89,7 @@ \li Portugese \li Romanian \li Russian + \li Serbian \li Simplified Chinese \li Traditional Chinese \li Spanish @@ -124,7 +133,7 @@ */ /*! -\qmlmodule QtQuick.VirtualKeyboard 2.2 +\qmlmodule QtQuick.VirtualKeyboard 2.3 \title Qt Virtual Keyboard QML Types \ingroup qmlmodules \brief Provides QML types for an input framework and a reference keyboard front @@ -134,7 +143,7 @@ end. import statements in your .qml file: \code - import QtQuick.VirtualKeyboard 2.2 + import QtQuick.VirtualKeyboard 2.3 import QtQuick.VirtualKeyboard.Styles 2.2 import QtQuick.VirtualKeyboard.Settings 2.2 \endcode diff --git a/src/virtualkeyboard/gesturerecognizer.cpp b/src/virtualkeyboard/gesturerecognizer.cpp new file mode 100644 index 00000000..09db68a5 --- /dev/null +++ b/src/virtualkeyboard/gesturerecognizer.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "gesturerecognizer.h" + +namespace QtVirtualKeyboard { + +GestureRecognizer::GestureRecognizer(QObject *parent) : + QObject(parent) +{ +} + +} diff --git a/src/virtualkeyboard/gesturerecognizer.h b/src/virtualkeyboard/gesturerecognizer.h new file mode 100644 index 00000000..f1636609 --- /dev/null +++ b/src/virtualkeyboard/gesturerecognizer.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef GESTURERECOGNIZER_H +#define GESTURERECOGNIZER_H + +#include <QObject> +#include <QVariantMap> +#include "trace.h" + +namespace QtVirtualKeyboard { + +class GestureRecognizer : public QObject +{ + Q_OBJECT +public: + explicit GestureRecognizer(QObject *parent = 0); + + virtual QVariantMap recognize(const QList<Trace *> traceList) = 0; +}; + +} // namespace QtVirtualKeyboard + +#endif // GESTURERECOGNIZER_H diff --git a/src/virtualkeyboard/handwritinggesturerecognizer.cpp b/src/virtualkeyboard/handwritinggesturerecognizer.cpp new file mode 100644 index 00000000..23ac63e9 --- /dev/null +++ b/src/virtualkeyboard/handwritinggesturerecognizer.cpp @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "handwritinggesturerecognizer.h" + +#include <QtCore/qmath.h> +#include <QVector2D> + +namespace QtVirtualKeyboard { + +HandwritingGestureRecognizer::HandwritingGestureRecognizer(QObject *parent) : + GestureRecognizer(parent), + m_dpi(96) +{ +} + +void HandwritingGestureRecognizer::setDpi(int value) +{ + m_dpi = value >= 0 ? value : 96; +} + +int HandwritingGestureRecognizer::dpi() const +{ + return m_dpi; +} + +QVariantMap HandwritingGestureRecognizer::recognize(const QList<Trace *> traceList) +{ + if (traceList.count() > 0 && traceList.count() < 3) { + + // Swipe gesture detection + // ======================= + // + // The following algorithm is based on the assumption that a + // vector composed of two arbitrary selected, but consecutive + // measuring points, and a vector composed of the first and last + // of the measuring points, are approximately in the same angle. + // + // If the measuring points are located very close to each other, + // the angle can fluctuate a lot. This has been taken into account + // by setting a minimum Euclidean distance between the measuring + // points. + // + + // Minimum euclidean distance of a segment (in millimeters) + static const int MINIMUM_EUCLIDEAN_DISTANCE = 8; + + // Maximum theta variance (in degrees) + static const qreal THETA_THRESHOLD = 25.0; + + // Maximum width variance in multitouch swipe (+- in percent) + static const int MAXIMUM_WIDTH_VARIANCE = 20; + + const qreal minimumEuclideanDistance = MINIMUM_EUCLIDEAN_DISTANCE / 25.4 * m_dpi; + static const qreal thetaThreshold = qDegreesToRadians(THETA_THRESHOLD); + + QList<QVector2D> swipeVectors; + + int traceIndex; + const int traceCount = traceList.size(); + for (traceIndex = 0; traceIndex < traceCount; ++traceIndex) { + + const Trace *trace = traceList.at(traceIndex); + const QVariantList &points = trace->points(); + QVector2D swipeVector; + const int pointCount = points.count(); + int pointIndex = 0; + if (pointCount >= 2) { + + QPointF startPosition = points.first().toPointF(); + swipeVector = QVector2D(points.last().toPointF() - startPosition); + const qreal swipeLength = swipeVector.length(); + + if (swipeLength >= minimumEuclideanDistance) { + + QPointF previousPosition = startPosition; + qreal euclideanDistance = 0; + for (pointIndex = 1; pointIndex < pointCount; ++pointIndex) { + + QPointF currentPosition(points.at(pointIndex).toPointF()); + + euclideanDistance += QVector2D(currentPosition - previousPosition).length(); + if (euclideanDistance >= minimumEuclideanDistance) { + + // Set the angle (theta) between the sample vector and the swipe vector + const QVector2D sampleVector(currentPosition - startPosition); + const qreal theta = qAcos(QVector2D::dotProduct(swipeVector, sampleVector) / (swipeLength * sampleVector.length())); + + // Rejected when theta above threshold + if (theta >= thetaThreshold) { + swipeVector = QVector2D(); + break; + } + + startPosition = currentPosition; + euclideanDistance = 0; + } + + previousPosition = currentPosition; + } + + if (pointIndex < pointCount) { + swipeVector = QVector2D(); + break; + } + + // Check to see if angle and length matches to existing touch points + if (!swipeVectors.isEmpty()) { + bool matchesToExisting = true; + const qreal minimumSwipeLength = (swipeLength * (100.0 - MAXIMUM_WIDTH_VARIANCE) / 100.0); + const qreal maximumSwipeLength = (swipeLength * (100.0 + MAXIMUM_WIDTH_VARIANCE) / 100.0); + for (const QVector2D &otherSwipeVector : qAsConst(swipeVectors)) { + const qreal otherSwipeLength = otherSwipeVector.length(); + const qreal theta = qAcos(QVector2D::dotProduct(swipeVector, otherSwipeVector) / (swipeLength * otherSwipeLength)); + + if (theta >= thetaThreshold) { + matchesToExisting = false; + break; + } + + if (otherSwipeLength < minimumSwipeLength || otherSwipeLength > maximumSwipeLength) { + matchesToExisting = false; + break; + } + } + + if (!matchesToExisting) { + swipeVector = QVector2D(); + break; + } + } + } else { + swipeVector = QVector2D(); + } + } + + if (swipeVector.isNull()) + break; + + swipeVectors.append(swipeVector); + } + + if (swipeVectors.size() == traceCount) { + + QVariantMap swipeGesture; + + // Get swipe angle from the first vector: + // 0 degrees == right + // 90 degrees == down + // 180 degrees == left + // 270 degrees == up + QList<QVector2D>::ConstIterator swipeVector = swipeVectors.constBegin(); + qreal swipeLength = swipeVector->length(); + qreal swipeAngle = qAcos(swipeVector->x() / swipeLength); + if (swipeVector->y() < 0) + swipeAngle = 2 * M_PI - swipeAngle; + + // Calculate an average length of the vector + ++swipeVector; + for (const auto cend = swipeVectors.cend(); swipeVector != cend; ++swipeVector) + swipeLength += swipeVector->length(); + swipeLength /= traceCount; + + swipeGesture[QLatin1String("type")] = QLatin1String("swipe"); + swipeGesture[QLatin1String("angle")] = swipeAngle; + swipeGesture[QLatin1String("angle_degrees")] = qRadiansToDegrees(swipeAngle); + swipeGesture[QLatin1String("length")] = swipeLength; + swipeGesture[QLatin1String("length_mm")] = swipeLength / m_dpi * 25.4; + swipeGesture[QLatin1String("touch_count")] = traceCount; + + return swipeGesture; + } + } + + return QVariantMap(); +} + +} diff --git a/src/virtualkeyboard/handwritinggesturerecognizer.h b/src/virtualkeyboard/handwritinggesturerecognizer.h new file mode 100644 index 00000000..5ef2ba14 --- /dev/null +++ b/src/virtualkeyboard/handwritinggesturerecognizer.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef HANDWRITINGGESTURERECOGNIZER_H +#define HANDWRITINGGESTURERECOGNIZER_H + +#include "gesturerecognizer.h" + +namespace QtVirtualKeyboard { + +class HandwritingGestureRecognizer : public GestureRecognizer +{ + Q_OBJECT +public: + explicit HandwritingGestureRecognizer(QObject *parent = 0); + + void setDpi(int dpi); + int dpi() const; + + QVariantMap recognize(const QList<Trace *> traceList); + +private: + int m_dpi; +}; + +} // namespace QtVirtualKeyboard + +#endif // HANDWRITINGGESTURERECOGNIZER_H diff --git a/src/virtualkeyboard/hunspellinputmethod.cpp b/src/virtualkeyboard/hunspellinputmethod.cpp index 5cd88c2e..76b5f654 100644 --- a/src/virtualkeyboard/hunspellinputmethod.cpp +++ b/src/virtualkeyboard/hunspellinputmethod.cpp @@ -53,8 +53,26 @@ HunspellInputMethod::~HunspellInputMethod() QList<InputEngine::InputMode> HunspellInputMethod::inputModes(const QString &locale) { - Q_UNUSED(locale) - return QList<InputEngine::InputMode>() << InputEngine::Latin << InputEngine::Numeric; + QList<InputEngine::InputMode> result; + switch (QLocale(locale).script()) { + case QLocale::GreekScript: + result.append(InputEngine::Greek); + break; + case QLocale::CyrillicScript: + result.append(InputEngine::Cyrillic); + break; + case QLocale::ArabicScript: + result.append(InputEngine::Arabic); + break; + case QLocale::HebrewScript: + result.append(InputEngine::Hebrew); + break; + default: + break; + } + result.append(InputEngine::Latin); + result.append(InputEngine::Numeric); + return result; } bool HunspellInputMethod::setInputMode(const QString &locale, InputEngine::InputMode inputMode) @@ -163,7 +181,7 @@ QList<SelectionListModel::Type> HunspellInputMethod::selectionLists() { Q_D(const HunspellInputMethod); Qt::InputMethodHints inputMethodHints = inputContext()->inputMethodHints(); - if (d->dictionaryState != HunspellInputMethodPrivate::DictionaryReady || inputMethodHints.testFlag(Qt::ImhNoPredictiveText) || inputMethodHints.testFlag(Qt::ImhHiddenText)) + if (d->dictionaryState == HunspellInputMethodPrivate::DictionaryNotLoaded || inputMethodHints.testFlag(Qt::ImhNoPredictiveText) || inputMethodHints.testFlag(Qt::ImhHiddenText)) return QList<SelectionListModel::Type>(); return QList<SelectionListModel::Type>() << SelectionListModel::WordCandidateList; } diff --git a/src/virtualkeyboard/hunspellinputmethod_p.cpp b/src/virtualkeyboard/hunspellinputmethod_p.cpp index 2512337d..0f4bc25a 100644 --- a/src/virtualkeyboard/hunspellinputmethod_p.cpp +++ b/src/virtualkeyboard/hunspellinputmethod_p.cpp @@ -94,6 +94,7 @@ bool HunspellInputMethodPrivate::createHunspell(const QString &locale) QSharedPointer<HunspellLoadDictionaryTask> loadDictionaryTask(new HunspellLoadDictionaryTask(locale, searchPaths)); QObject::connect(loadDictionaryTask.data(), &HunspellLoadDictionaryTask::completed, q, &HunspellInputMethod::dictionaryLoadCompleted); dictionaryState = HunspellInputMethodPrivate::DictionaryLoading; + emit q->selectionListsChanged(); hunspellWorker->addTask(loadDictionaryTask); this->locale = locale; } @@ -173,7 +174,7 @@ bool HunspellInputMethodPrivate::isAutoSpaceAllowed() const Q_Q(const HunspellInputMethod); if (!autoSpaceAllowed) return false; - if (q->inputEngine()->inputMode() != InputEngine::Latin) + if (q->inputEngine()->inputMode() == InputEngine::Numeric) return false; InputContext *ic = q->inputContext(); if (!ic) diff --git a/src/virtualkeyboard/hunspellworker.cpp b/src/virtualkeyboard/hunspellworker.cpp index 9517ca4b..f2e502ad 100644 --- a/src/virtualkeyboard/hunspellworker.cpp +++ b/src/virtualkeyboard/hunspellworker.cpp @@ -90,7 +90,6 @@ void HunspellLoadDictionaryTask::run() } if (!affPath.isEmpty() && !dicPath.isEmpty()) { - VIRTUALKEYBOARD_DEBUG() << "Hunspell dictionary is missing for the" << locale << "language. Search paths" << searchPaths; *hunspellPtr = Hunspell_create(affPath.toUtf8().constData(), dicPath.toUtf8().constData()); if (*hunspellPtr) { /* Make sure the encoding used by the dictionary is supported @@ -106,6 +105,8 @@ void HunspellLoadDictionaryTask::run() #ifdef QT_VIRTUALKEYBOARD_DEBUG VIRTUALKEYBOARD_DEBUG() << "HunspellLoadDictionaryTask::run(): time:" << perf.elapsed() << "ms"; #endif + } else { + VIRTUALKEYBOARD_DEBUG() << "Hunspell dictionary is missing for" << locale << ". Search paths" << searchPaths; } emit completed(*hunspellPtr != 0); diff --git a/src/virtualkeyboard/import/import.pro b/src/virtualkeyboard/import/import.pro index 301f4f2b..d76bb91e 100644 --- a/src/virtualkeyboard/import/import.pro +++ b/src/virtualkeyboard/import/import.pro @@ -7,6 +7,6 @@ load(qml_module) !cross_compile:if(build_pass|!debug_and_release) { qtPrepareTool(QMLPLUGINDUMP, qmlplugindump) - qmltypes.commands = QT_IM_MODULE=qtvirtualkeyboard $$QMLPLUGINDUMP -defaultplatform -nonrelocatable QtQuick.VirtualKeyboard 2.1 > $$PWD/plugins.qmltypes + qmltypes.commands = QT_IM_MODULE=qtvirtualkeyboard $$QMLPLUGINDUMP -defaultplatform -nonrelocatable QtQuick.VirtualKeyboard 2.3 > $$PWD/plugins.qmltypes QMAKE_EXTRA_TARGETS += qmltypes } diff --git a/src/virtualkeyboard/inputcontext.cpp b/src/virtualkeyboard/inputcontext.cpp index 6d36ae5e..e23f6e46 100644 --- a/src/virtualkeyboard/inputcontext.cpp +++ b/src/virtualkeyboard/inputcontext.cpp @@ -173,7 +173,6 @@ InputContext::InputContext(PlatformInputContext *parent) : if (d->inputContext) { d->inputContext->setInputContext(this); connect(d->inputContext, SIGNAL(focusObjectChanged()), SLOT(onInputItemChanged())); - connect(d->inputContext, SIGNAL(focusObjectChanged()), SIGNAL(inputItemChanged())); } d->inputEngine = new InputEngine(this); d->shiftHandler = new ShiftHandler(this); @@ -561,7 +560,7 @@ bool InputContext::fileExists(const QUrl &fileUrl) } else { fileName = fileUrl.toLocalFile(); } - return QFile::exists(fileName); + return !fileName.isEmpty() && QFile::exists(fileName); #endif } @@ -650,6 +649,8 @@ void InputContext::onInputItemChanged() d->stateFlags &= ~InputContextPrivate::KeyEventState; } d->stateFlags &= ~InputContextPrivate::InputMethodClickState; + + emit inputItemChanged(); } void InputContext::setFocus(bool enable) diff --git a/src/virtualkeyboard/inputengine.cpp b/src/virtualkeyboard/inputengine.cpp index f15eee26..e825f05b 100644 --- a/src/virtualkeyboard/inputengine.cpp +++ b/src/virtualkeyboard/inputengine.cpp @@ -85,6 +85,7 @@ public: AbstractInputMethod *defaultInputMethod; InputEngine::TextCase textCase; InputEngine::InputMode inputMode; + QList<int> inputModes; QMap<SelectionListModel::Type, SelectionListModel *> selectionListModels; Qt::Key activeKey; QString activeKeyText; @@ -158,6 +159,8 @@ InputEngine::InputEngine(InputContext *parent) : connect(d->inputContext, SIGNAL(shiftChanged()), SLOT(shiftChanged())); connect(d->inputContext, SIGNAL(localeChanged()), SLOT(update())); QObject::connect(d->inputContext, &InputContext::inputMethodHintsChanged, this, &InputEngine::updateSelectionListModels); + QObject::connect(d->inputContext, &InputContext::localeChanged, this, &InputEngine::updateInputModes); + QObject::connect(this, &InputEngine::inputMethodChanged, this, &InputEngine::updateInputModes); } d->defaultInputMethod = new DefaultInputMethod(this); if (d->defaultInputMethod) @@ -378,7 +381,6 @@ void InputEngine::setInputMethod(AbstractInputMethod *inputMethod) } updateSelectionListModels(); emit inputMethodChanged(); - emit inputModesChanged(); emit patternRecognitionModesChanged(); } } @@ -389,18 +391,7 @@ void InputEngine::setInputMethod(AbstractInputMethod *inputMethod) QList<int> InputEngine::inputModes() const { Q_D(const InputEngine); - QList<InputMode> inputModeList; - if (d->inputMethod) { - inputModeList = d->inputMethod->inputModes(d->inputContext->locale()); - } - QList<int> resultList; - if (inputModeList.isEmpty()) { - return resultList; - } - resultList.reserve(inputModeList.size()); - for (const InputMode &inputMode : qAsConst(inputModeList)) - resultList.append(inputMode); - return resultList; + return d->inputModes; } InputEngine::InputMode InputEngine::inputMode() const @@ -414,16 +405,22 @@ void InputEngine::setInputMode(InputEngine::InputMode inputMode) Q_D(InputEngine); VIRTUALKEYBOARD_DEBUG() << "InputEngine::setInputMode():" << inputMode; if (d->inputMethod) { - const QString locale(d->inputContext->locale()); - QList<InputEngine::InputMode> inputModeList(d->inputMethod->inputModes(locale)); - if (inputModeList.contains(inputMode)) { - d->inputMethod->setInputMode(locale, inputMode); +#ifdef QT_DEBUG + // Cached input modes should be in sync with the input method + // If the assert below fails, we have missed an update somewhere + QList<int> cachedInputModes(d->inputModes); + updateInputModes(); + Q_ASSERT(cachedInputModes == d->inputModes); +#endif + if (d->inputModes.contains(inputMode)) { + d->inputMethod->setInputMode(d->inputContext->locale(), inputMode); if (d->inputMode != inputMode) { d->inputMode = inputMode; emit inputModeChanged(); } } else { - qWarning() << "the input mode" << inputMode << "is not valid"; + qWarning() << "Input mode" << inputMode << + "is not in the list of available input modes" << d->inputModes; } } } @@ -580,7 +577,10 @@ void InputEngine::reset() RecursiveMethodGuard guard(d->recursiveMethodLock); if (!guard.locked()) { emit inputMethodReset(); + updateInputModes(); } + } else { + updateInputModes(); } } @@ -654,6 +654,29 @@ void InputEngine::updateSelectionListModels() /*! \internal */ +void InputEngine::updateInputModes() +{ + Q_D(InputEngine); + QList<int> newInputModes; + if (d->inputMethod) { + QList<InputMode> tmpList(d->inputMethod->inputModes(d->inputContext->locale())); + if (!tmpList.isEmpty()) { + std::transform(tmpList.constBegin(), tmpList.constEnd(), + std::back_inserter(newInputModes), + [tmpList] (InputMode inputMode) { + return static_cast<int>(inputMode); + }); + } + } + if (d->inputModes != newInputModes) { + d->inputModes = newInputModes; + emit inputModesChanged(); + } +} + +/*! + \internal +*/ void InputEngine::timerEvent(QTimerEvent *timerEvent) { Q_D(InputEngine); @@ -740,6 +763,13 @@ void InputEngine::timerEvent(QTimerEvent *timerEvent) \li \c InputEngine.Hiragana Hiragana input mode for Japanese. \li \c InputEngine.Katakana Katakana input mode for Japanese. \li \c InputEngine.FullwidthLatin Fullwidth latin input mode for East Asian languages. + \li \c InputEngine.Greek Greek input mode. + \li \c InputEngine.Cyrillic Cyrillic input mode. + \li \c InputEngine.Arabic Arabic input mode. + \li \c InputEngine.Hebrew Hebrew input mode. + \li \c InputEngine.ChineseHandwriting Chinese handwriting. + \li \c InputEngine.JapaneseHandwriting Japanese handwriting. + \li \c InputEngine.KoreanHandwriting Korean handwriting. \endlist */ @@ -807,6 +837,14 @@ void InputEngine::timerEvent(QTimerEvent *timerEvent) Katakana input mode for Japanese. \value FullwidthLatin Fullwidth latin input mode for East Asian languages. + \value Greek + Greek input mode. + \value Cyrillic + Cyrillic input mode. + \value Arabic + Arabic input mode. + \value Hebrew + Hebrew input mode. */ /*! diff --git a/src/virtualkeyboard/inputengine.h b/src/virtualkeyboard/inputengine.h index 784ed91c..66eb2c3d 100644 --- a/src/virtualkeyboard/inputengine.h +++ b/src/virtualkeyboard/inputengine.h @@ -73,7 +73,14 @@ public: Hangul, Hiragana, Katakana, - FullwidthLatin + FullwidthLatin, + Greek, + Cyrillic, + Arabic, + Hebrew, + ChineseHandwriting, + JapaneseHandwriting, + KoreanHandwriting }; enum PatternRecognitionMode { PatternRecognitionDisabled, @@ -138,6 +145,7 @@ private slots: void update(); void shiftChanged(); void updateSelectionListModels(); + void updateInputModes(); protected: void timerEvent(QTimerEvent *timerEvent); diff --git a/src/virtualkeyboard/lipiinputmethod.cpp b/src/virtualkeyboard/lipiinputmethod.cpp index 30ee9ed4..10dcb4ae 100644 --- a/src/virtualkeyboard/lipiinputmethod.cpp +++ b/src/virtualkeyboard/lipiinputmethod.cpp @@ -34,6 +34,7 @@ #include "shifthandler.h" #include "virtualkeyboarddebug.h" #include "trace.h" +#include "handwritinggesturerecognizer.h" #ifdef HAVE_HUNSPELL #include "hunspellinputmethod_p.h" @@ -49,14 +50,11 @@ #include <QCryptographicHash> -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT +#include "unipentrace.h" #include <QStandardPaths> -#include <QFileInfo> -#include <QDir> #endif -#include <QtCore/qmath.h> - #ifdef HAVE_HUNSPELL #define LipiInputMethodPrivateBase HunspellInputMethodPrivate #else @@ -78,6 +76,9 @@ public: q_ptr(q_ptr), recognizeTimer(0), textCase(InputEngine::Lower) +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + , unipenTrace(0) +#endif { } @@ -147,6 +148,8 @@ public: } } + gestureRecognizer.setDpi(deviceInfo->getXDPI()); + currentContext = context; } @@ -165,6 +168,13 @@ public: delayedResult.clear(); } +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + if (!unipenTrace) { + Q_Q(LipiInputMethod); + unipenTrace = new UnipenTrace(traceCaptureDeviceInfo, traceScreenInfo, q); + } +#endif + Trace *trace = new Trace(); trace->setChannels(QStringList("t")); traceList.append(trace); @@ -201,7 +211,7 @@ public: if (countActiveTraces() > 0) return; - QVariantMap gesture = detectGesture(); + QVariantMap gesture = gestureRecognizer.recognize(traceList); if (gesture.isEmpty()) return; @@ -227,7 +237,7 @@ public: if (swipeAngle <= 180 + SWIPE_ANGLE_THRESHOLD && swipeAngle >= 180 - SWIPE_ANGLE_THRESHOLD) { if (swipeTouchCount == 1) { // Single swipe: backspace -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT dumpTraces(); saveTraces(Qt::Key_Backspace, 100); #endif @@ -250,7 +260,7 @@ public: if (swipeAngle <= SWIPE_ANGLE_THRESHOLD || swipeAngle >= 360 - SWIPE_ANGLE_THRESHOLD) { if (swipeTouchCount == 1) { // Single swipe: space -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT dumpTraces(); saveTraces(Qt::Key_Space, 100); #endif @@ -274,7 +284,7 @@ public: if (swipeAngle <= 270 + SWIPE_ANGLE_THRESHOLD && swipeAngle >= 270 - SWIPE_ANGLE_THRESHOLD) { if (swipeTouchCount == 1) { // Single swipe: toggle input mode -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT dumpTraces(); saveTraces(Qt::Key_Mode_switch, 100); #endif @@ -296,157 +306,6 @@ public: } } - QVariantMap detectGesture() - { - if (traceList.count() > 0 && traceList.count() < 3) { - - // Swipe gesture detection - // ======================= - // - // The following algorithm is based on the assumption that a - // vector composed of two arbitrary selected, but consecutive - // measuring points, and a vector composed of the first and last - // of the measuring points, are approximately in the same angle. - // - // If the measuring points are located very close to each other, - // the angle can fluctuate a lot. This has been taken into account - // by setting a minimum Euclidean distance between the measuring - // points. - // - - // Minimum euclidean distance of a segment (in millimeters) - static const int MINIMUM_EUCLIDEAN_DISTANCE = 8; - - // Maximum theta variance (in degrees) - static const qreal THETA_THRESHOLD = 25.0; - - // Maximum width variance in multitouch swipe (+- in percent) - static const int MAXIMUM_WIDTH_VARIANCE = 20; - - const int dpi = deviceInfo->getXDPI() >= 0 ? deviceInfo->getXDPI() : 96; - const qreal minimumEuclideanDistance = MINIMUM_EUCLIDEAN_DISTANCE / 25.4 * dpi; - static const qreal thetaThreshold = qDegreesToRadians(THETA_THRESHOLD); - - QList<QVector2D> swipeVectors; - - int traceIndex; - const int traceCount = traceList.size(); - for (traceIndex = 0; traceIndex < traceCount; ++traceIndex) { - - const Trace *trace = traceList.at(traceIndex); - const QVariantList &points = trace->points(); - QVector2D swipeVector; - const int pointCount = points.count(); - int pointIndex = 0; - if (pointCount >= 2) { - - QPointF startPosition = points.first().toPointF(); - swipeVector = QVector2D(points.last().toPointF() - startPosition); - const qreal swipeLength = swipeVector.length(); - - if (swipeLength >= minimumEuclideanDistance) { - - QPointF previousPosition = startPosition; - qreal euclideanDistance = 0; - for (pointIndex = 1; pointIndex < pointCount; ++pointIndex) { - - QPointF currentPosition(points.at(pointIndex).toPointF()); - - euclideanDistance += QVector2D(currentPosition - previousPosition).length(); - if (euclideanDistance >= minimumEuclideanDistance) { - - // Set the angle (theta) between the sample vector and the swipe vector - const QVector2D sampleVector(currentPosition - startPosition); - const qreal theta = qAcos(QVector2D::dotProduct(swipeVector, sampleVector) / (swipeLength * sampleVector.length())); - - // Rejected when theta above threshold - if (theta >= thetaThreshold) { - swipeVector = QVector2D(); - break; - } - - startPosition = currentPosition; - euclideanDistance = 0; - } - - previousPosition = currentPosition; - } - - if (pointIndex < pointCount) { - swipeVector = QVector2D(); - break; - } - - // Check to see if angle and length matches to existing touch points - if (!swipeVectors.isEmpty()) { - bool matchesToExisting = true; - const qreal minimumSwipeLength = (swipeLength * (100.0 - MAXIMUM_WIDTH_VARIANCE) / 100.0); - const qreal maximumSwipeLength = (swipeLength * (100.0 + MAXIMUM_WIDTH_VARIANCE) / 100.0); - for (const QVector2D &otherSwipeVector : qAsConst(swipeVectors)) { - const qreal otherSwipeLength = otherSwipeVector.length(); - const qreal theta = qAcos(QVector2D::dotProduct(swipeVector, otherSwipeVector) / (swipeLength * otherSwipeLength)); - - if (theta >= thetaThreshold) { - matchesToExisting = false; - break; - } - - if (otherSwipeLength < minimumSwipeLength || otherSwipeLength > maximumSwipeLength) { - matchesToExisting = false; - break; - } - } - - if (!matchesToExisting) { - swipeVector = QVector2D(); - break; - } - } - } else { - swipeVector = QVector2D(); - } - } - - if (swipeVector.isNull()) - break; - - swipeVectors.append(swipeVector); - } - - if (swipeVectors.size() == traceCount) { - - QVariantMap swipeGesture; - - // Get swipe angle from the first vector: - // 0 degrees == right - // 90 degrees == down - // 180 degrees == left - // 270 degrees == up - QList<QVector2D>::ConstIterator swipeVector = swipeVectors.constBegin(); - qreal swipeLength = swipeVector->length(); - qreal swipeAngle = qAcos(swipeVector->x() / swipeLength); - if (swipeVector->y() < 0) - swipeAngle = 2 * M_PI - swipeAngle; - - // Calculate an average length of the vector - for (++swipeVector; swipeVector != swipeVectors.end(); ++swipeVector) - swipeLength += swipeVector->length(); - swipeLength /= traceCount; - - swipeGesture[QLatin1String("type")] = QLatin1String("swipe"); - swipeGesture[QLatin1String("angle")] = swipeAngle; - swipeGesture[QLatin1String("angle_degrees")] = qRadiansToDegrees(swipeAngle); - swipeGesture[QLatin1String("length")] = swipeLength; - swipeGesture[QLatin1String("length_mm")] = swipeLength / dpi * 25.4; - swipeGesture[QLatin1String("touch_count")] = traceCount; - - return swipeGesture; - } - } - - return QVariantMap(); - } - void clearTraces() { qDeleteAll(traceList); @@ -484,7 +343,7 @@ public: void finishRecognition() { -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT dumpTraces(); #endif stopRecognizeTimer(); @@ -553,11 +412,14 @@ public: { const QChar ch = result["unicode"].toChar(); const QChar chUpper = ch.toUpper(); -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT // In recording mode, the text case must match with the current text case - if (ch.isLetter() && (ch.isUpper() != (textCase == InputEngine::Upper))) - return; - saveTraces(ch.unicode(), qRound(result["confidence"].toDouble() * 100)); + if (unipenTrace) { + if (!ch.isLetter() || (ch.isUpper() == (textCase == InputEngine::Upper))) + saveTraces(ch.unicode(), qRound(result["confidence"].toDouble() * 100)); + delete unipenTrace; + unipenTrace = 0; + } #endif Q_Q(LipiInputMethod); q->inputContext()->inputEngine()->virtualKeyClick((Qt::Key)chUpper.unicode(), @@ -565,72 +427,23 @@ public: Qt::NoModifier); } -#ifdef QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT - QStringList recordedData; - +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT void dumpTraces() { - recordedData.clear(); - recordedData.append(QStringLiteral(".VERSION 1.0")); - recordedData.append(QStringLiteral(".HIERARCHY CHARACTER")); - recordedData.append(QStringLiteral(".COORD X Y T")); - recordedData.append(QStringLiteral(".SEGMENT CHARACTER")); - recordedData.append(QStringLiteral(".X_DIM %1").arg(qRound(screenContext->getBboxRight()))); - recordedData.append(QStringLiteral(".Y_DIM %1").arg(qRound(screenContext->getBboxBottom()))); - recordedData.append(QStringLiteral(".X_POINTS_PER_INCH %1").arg(deviceInfo->getXDPI())); - recordedData.append(QStringLiteral(".Y_POINTS_PER_INCH %1").arg(deviceInfo->getYDPI())); - recordedData.append(QStringLiteral(".POINTS_PER_SECOND %1").arg(deviceInfo->getSamplingRate())); - - qlonglong t0 = 0; - for (const Trace *trace : qAsConst(traceList)) { - const QVariantList &points = trace->points(); - const bool hasTime = trace->channels().contains("t"); - const QVariantList timeData = hasTime ? trace->channelData("t") : QVariantList(); - QVariantList::ConstIterator t = timeData.constBegin(); - if (t0 == 0 && hasTime) - t0 = t->toLongLong(); - - recordedData.append(QStringLiteral(".PEN_DOWN")); - - for (const QVariant &point : points) { - const QPointF pt(point.toPointF()); - QString pointStr(QStringLiteral("%1 %2 ").arg(qRound(pt.x())).arg(qRound(pt.y()))); - if (hasTime) { - pointStr.append(QString::number(t->toLongLong() - t0)); - t++; - } else { - pointStr.append(QStringLiteral("0")); - } - recordedData.append(pointStr); - } - - recordedData.append(QStringLiteral(".PEN_UP")); - } + if (unipenTrace) + unipenTrace->record(traceList); } void saveTraces(uint unicode, uint confidence) { - QString fileName; + if (!unipenTrace) + return; + QStringList homeLocations = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); if (!homeLocations.isEmpty()) { QString filePath = QStringLiteral("%1/%2").arg(homeLocations.at(0)).arg("VIRTUAL_KEYBOARD_TRACES"); - QDir fileDir(filePath); - if (!fileDir.exists()) - fileDir.mkpath(filePath); - if (fileDir.exists()) { - int fileIndex = 0; - do { - fileName = fileDir.absoluteFilePath(QStringLiteral("%1_%2_%3.txt").arg(unicode).arg(confidence, 3, 10, QLatin1Char('0')).arg(fileIndex++)); - } while (QFileInfo::exists(fileName)); - } - } - QString dataStr(recordedData.join('\n')); - dataStr.append('\n'); - QFile file(fileName); - if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { - file.write(dataStr.toUtf8().constData()); - } else { - qWarning() << "Cannot open file for writing" << fileName; + unipenTrace->setDirectory(filePath); + unipenTrace->save(unicode, confidence); } } #endif @@ -647,6 +460,10 @@ public: InputEngine::TextCase textCase; vector<int> subsetOfClasses; QVariantMap delayedResult; + HandwritingGestureRecognizer gestureRecognizer; +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + UnipenTrace *unipenTrace; +#endif }; /*! @@ -666,10 +483,19 @@ LipiInputMethod::~LipiInputMethod() QList<InputEngine::InputMode> LipiInputMethod::inputModes(const QString &locale) { Q_UNUSED(locale) - return QList<InputEngine::InputMode>() - << InputEngine::Latin - << InputEngine::Numeric - << InputEngine::Dialable; + QList<InputEngine::InputMode> availableInputModes; + const Qt::InputMethodHints inputMethodHints(inputContext()->inputMethodHints()); + + if (inputMethodHints.testFlag(Qt::ImhDialableCharactersOnly) || inputMethodHints.testFlag(Qt::ImhDigitsOnly)) { + availableInputModes.append(InputEngine::Dialable); + } else if (inputMethodHints.testFlag(Qt::ImhFormattedNumbersOnly)) { + availableInputModes.append(InputEngine::Numeric); + } else { + availableInputModes.append(InputEngine::Latin); + availableInputModes.append(InputEngine::Numeric); + } + + return availableInputModes; } bool LipiInputMethod::setInputMode(const QString &locale, InputEngine::InputMode inputMode) diff --git a/src/virtualkeyboard/plaininputmethod.cpp b/src/virtualkeyboard/plaininputmethod.cpp index 29c560da..2ca10cb4 100644 --- a/src/virtualkeyboard/plaininputmethod.cpp +++ b/src/virtualkeyboard/plaininputmethod.cpp @@ -49,13 +49,26 @@ PlainInputMethod::~PlainInputMethod() QList<InputEngine::InputMode> PlainInputMethod::inputModes(const QString &locale) { - Q_UNUSED(locale) - // Supports all input modes - return QList<InputEngine::InputMode>() - << InputEngine::Latin - << InputEngine::Numeric - << InputEngine::Dialable - << InputEngine::Pinyin; + QList<InputEngine::InputMode> result; + switch (QLocale(locale).script()) { + case QLocale::GreekScript: + result.append(InputEngine::Greek); + break; + case QLocale::CyrillicScript: + result.append(InputEngine::Cyrillic); + break; + case QLocale::ArabicScript: + result.append(InputEngine::Arabic); + break; + case QLocale::HebrewScript: + result.append(InputEngine::Hebrew); + break; + default: + break; + } + result.append(InputEngine::Latin); + result.append(InputEngine::Numeric); + return result; } bool PlainInputMethod::setInputMode(const QString &locale, InputEngine::InputMode inputMode) diff --git a/src/virtualkeyboard/plugin.cpp b/src/virtualkeyboard/plugin.cpp index 73ddeabc..136bba80 100644 --- a/src/virtualkeyboard/plugin.cpp +++ b/src/virtualkeyboard/plugin.cpp @@ -199,6 +199,7 @@ QPlatformInputContext *QVirtualKeyboardPlugin::create(const QString &system, con qmlRegisterType(QUrl(path + QLatin1String("InputPanel.qml")), pluginUri, 2, 0, "InputPanel"); qmlRegisterType(QUrl(path + QLatin1String("InputPanel.qml")), pluginUri, 2, 1, "InputPanel"); qmlRegisterType(QUrl(path + QLatin1String("InputPanel.qml")), pluginUri, 2, 2, "InputPanel"); + qmlRegisterType(QUrl(path + QLatin1String("InputPanel.qml")), pluginUri, 2, 3, "InputPanel"); qmlRegisterType(QUrl(path + QLatin1String("HandwritingInputPanel.qml")), pluginUri, 2, 0, "HandwritingInputPanel"); const QString componentsPath = path + QStringLiteral("components/"); qmlRegisterType(QUrl(componentsPath + QLatin1String("AlternativeKeys.qml")), pluginUri, 1, 0, "AlternativeKeys"); @@ -248,6 +249,7 @@ QPlatformInputContext *QVirtualKeyboardPlugin::create(const QString &system, con qmlRegisterType(QUrl(componentsPath + QLatin1String("WordCandidatePopupList.qml")), pluginUri, 2, 0, "WordCandidatePopupList"); qmlRegisterType(QUrl(componentsPath + QLatin1String("LanguagePopupList.qml")), pluginUri, 2, 1, "LanguagePopupList"); qmlRegisterType(QUrl(componentsPath + QLatin1String("SelectionControl.qml")), pluginUri, 2, 1, "SelectionControl"); + qmlRegisterType(QUrl(componentsPath + QLatin1String("InputModeKey.qml")), pluginUri, 2, 3, "InputModeKey"); if (system.compare(system, QLatin1String(pluginName), Qt::CaseInsensitive) == 0) { platformInputContext = new PlatformInputContext(); diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp index 376410e3..8f42a762 100644 --- a/src/virtualkeyboard/shifthandler.cpp +++ b/src/virtualkeyboard/shifthandler.cpp @@ -50,11 +50,10 @@ public: shiftChanged(false), 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), + manualCapsInputModeFilter(QSet<InputEngine::InputMode>() << InputEngine::Cangjie << InputEngine::Zhuyin << InputEngine::Hebrew), + 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(); } InputContext *inputContext; @@ -185,7 +184,7 @@ void ShiftHandler::toggleShift() QStyleHints *style = QGuiApplication::styleHints(); - if (d->timer.elapsed() > style->mouseDoubleClickInterval()) { + if (d->timer.isNull() || d->timer.elapsed() > style->mouseDoubleClickInterval()) { d->timer.restart(); } else if (d->timer.elapsed() < style->mouseDoubleClickInterval() && !d->inputContext->capsLock()) { d->inputContext->setCapsLock(!d->inputContext->capsLock() && d->inputContext->shift() && !d->shiftChanged); @@ -196,6 +195,15 @@ void ShiftHandler::toggleShift() } } +/*! Clears the toggle shift timer. + +*/ +void ShiftHandler::clearToggleShiftTimer() +{ + Q_D(ShiftHandler); + d->timer = QTime(); +} + void ShiftHandler::reset() { Q_D(ShiftHandler); diff --git a/src/virtualkeyboard/shifthandler.h b/src/virtualkeyboard/shifthandler.h index c28a9581..93ba3e34 100644 --- a/src/virtualkeyboard/shifthandler.h +++ b/src/virtualkeyboard/shifthandler.h @@ -57,6 +57,7 @@ public: bool toggleShiftEnabled() const; Q_INVOKABLE void toggleShift(); + Q_INVOKABLE void clearToggleShiftTimer(); signals: void sentenceEndingCharactersChanged(); diff --git a/src/virtualkeyboard/t9write.h b/src/virtualkeyboard/t9write.h new file mode 100644 index 00000000..621d2312 --- /dev/null +++ b/src/virtualkeyboard/t9write.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef T9WRITE_H +#define T9WRITE_H + +#include "t9write_api_version.h" +#ifdef HAVE_T9WRITE_ALPHABETIC +#include "decuma_hwr.h" +#endif +#ifdef HAVE_T9WRITE_CJK +#include "decuma_hwr_cjk.h" +#endif + +#if defined(HAVE_T9WRITE_CJK) && defined(HAVE_T9WRITE_ALPHABETIC) +#define DECUMA_API(FUNC_NAME) (cjk ? decumaCJK ## FUNC_NAME : decuma ## FUNC_NAME) +#elif defined(HAVE_T9WRITE_CJK) +#define DECUMA_API(FUNC_NAME) (decumaCJK ## FUNC_NAME) +#else // defined(HAVE_T9WRITE_ALPHABETIC) +#define DECUMA_API(FUNC_NAME) (decuma ## FUNC_NAME) +#endif + +#endif // T9WRITE_H diff --git a/src/virtualkeyboard/t9writedictionary.cpp b/src/virtualkeyboard/t9writedictionary.cpp new file mode 100644 index 00000000..d15b16e3 --- /dev/null +++ b/src/virtualkeyboard/t9writedictionary.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "t9writedictionary.h" +#include "virtualkeyboarddebug.h" + +namespace QtVirtualKeyboard { + +T9WriteDictionary::T9WriteDictionary(DECUMA_SESSION *decumaSession, + const DECUMA_MEM_FUNCTIONS &memFuncs, + bool cjk) : + decumaSession(decumaSession), + memFuncs(memFuncs), + cjk(cjk), + sourceData(0), + sourceSize(0), + convertedData(0), + convertedSize(0) +{ +} + +T9WriteDictionary::~T9WriteDictionary() +{ + if (convertedData) { + DECUMA_STATUS status = DECUMA_API(DestroyConvertedDictionary)(&convertedData, &memFuncs); + Q_ASSERT(status == decumaNoError); + Q_ASSERT(convertedData == 0); + } +} + +bool T9WriteDictionary::load(const QString &fileName) +{ + if (sourceData || convertedData) + return false; + + file.setFileName(fileName); + if (file.open(QIODevice::ReadOnly)) { + sourceSize = file.size(); + sourceData = file.map(0, sourceSize, QFile::NoOptions); + if (!sourceData) { + sourceSize = 0; + qWarning() << "Could not read dictionary file" << fileName; + } + file.close(); + } else { + qWarning() << "Could not open dictionary file" << fileName; + } + + return sourceData != 0; +} + +bool T9WriteDictionary::convert(const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo) +{ + if (!sourceData || convertedData) + return false; + + DECUMA_STATUS status; + status = DECUMA_API(ConvertDictionary)(&convertedData, sourceData, (DECUMA_UINT32)sourceSize, + &dictionaryInfo, &convertedSize, &memFuncs); + + if (status != decumaNoError) { + qWarning() << "Could not convert dictionary" << file.fileName(); + file.unmap((uchar *)sourceData); + sourceSize = 0; + sourceData = 0; + } + + return status == decumaNoError; +} + +QString T9WriteDictionary::fileName() const +{ + return file.fileName(); +} + +const void *T9WriteDictionary::data() const +{ + return convertedData ? convertedData : sourceData; +} + +qint64 T9WriteDictionary::size() const +{ + return convertedData ? convertedSize : sourceSize; +} + +bool T9WriteDictionary::isConverted() const +{ + return convertedData != 0; +} + +} // namespace QtVirtualKeyboard diff --git a/src/virtualkeyboard/t9writedictionary.h b/src/virtualkeyboard/t9writedictionary.h new file mode 100644 index 00000000..dc2d9475 --- /dev/null +++ b/src/virtualkeyboard/t9writedictionary.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef T9WRITEDICTIONARY_H +#define T9WRITEDICTIONARY_H + +#include <QtGlobal> +#include <QFile> +#include "t9write.h" + +namespace QtVirtualKeyboard { + +class T9WriteDictionary +{ + Q_DISABLE_COPY(T9WriteDictionary) +public: + explicit T9WriteDictionary(DECUMA_SESSION *decumaSession, const DECUMA_MEM_FUNCTIONS &memFuncs, bool cjk); + ~T9WriteDictionary(); + + bool load(const QString &fileName); + bool convert(const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo); + + QString fileName() const; + const void *data() const; + qint64 size() const; + bool isConverted() const; + +private: + QFile file; + DECUMA_SESSION *decumaSession; + const DECUMA_MEM_FUNCTIONS &memFuncs; + bool cjk; + void *sourceData; + qint64 sourceSize; + void *convertedData; + DECUMA_UINT32 convertedSize; +}; + +} + +#endif // T9WRITEDICTIONARY_H diff --git a/src/virtualkeyboard/t9writeinputmethod.cpp b/src/virtualkeyboard/t9writeinputmethod.cpp index eb4cf9fb..14b6508b 100644 --- a/src/virtualkeyboard/t9writeinputmethod.cpp +++ b/src/virtualkeyboard/t9writeinputmethod.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** 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. @@ -34,16 +34,29 @@ #include "t9writeworker.h" #include "virtualkeyboarddebug.h" #include <QDirIterator> +#include <QCryptographicHash> #ifdef QT_VIRTUALKEYBOARD_DEBUG #include <QTime> #endif +#include "handwritinggesturerecognizer.h" +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT +#include "unipentrace.h" +#include <QStandardPaths> +#endif -#include "decuma_hwr.h" #include "decumaStatus.h" #include "decumaSymbolCategories.h" #include "decumaLanguages.h" #include "xxt9wOem.h" +/* Set to 1 to enable T9 Write log. + + The log is routed to qDebug() and it can be enabled for troubleshooting + and when reporting issues. The log must not to be enabled in production + build. +*/ +#define QT_VIRTUALKEYBOARD_T9WRITE_LOG 0 + namespace QtVirtualKeyboard { class T9WriteCaseFormatter @@ -94,12 +107,28 @@ class T9WriteInputMethodPrivate : public AbstractInputMethodPrivate Q_DECLARE_PUBLIC(T9WriteInputMethod) public: + enum EngineMode { + EngineUninitialized, + Alphabetic, + Arabic, + Hebrew, + SimplifiedChinese, + TraditionalChinese, + HongKongChinese, + Japanese, + Korean + }; + T9WriteInputMethodPrivate(T9WriteInputMethod *q_ptr) : AbstractInputMethodPrivate(), q_ptr(q_ptr), + cjk(false), + engineMode(EngineUninitialized), + defaultHwrDbPath(QLatin1String(":/QtQuick/VirtualKeyboard/T9Write/data/")), + defaultDictionaryDbPath(defaultHwrDbPath), dictionaryLock(QMutex::Recursive), - convertedDictionary(0), attachedDictionary(0), + traceListHardLimit(32), resultId(0), resultTimer(0), decumaSession(0), @@ -107,6 +136,9 @@ public: arcAdditionStarted(false), ignoreUpdate(false), textCase(InputEngine::Lower) +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + , unipenTrace() +#endif { } @@ -128,34 +160,76 @@ public: free(ptr); } - void initEngine() +#if QT_VIRTUALKEYBOARD_T9WRITE_LOG + static void decumaLogString(void *pUserData, const char *pLogString, DECUMA_UINT32 nLogStringLength) + { + static QMutex s_logMutex; + static QByteArray s_logString; + Q_UNUSED(pUserData) + Q_UNUSED(nLogStringLength) + QMutexLocker guard(&s_logMutex); + s_logString.append(pLogString, nLogStringLength); + if (s_logString.endsWith('\n')) { + while (s_logString.endsWith('\n')) + s_logString.chop(1); + qDebug() << (const char *)s_logString.constData(); + s_logString.clear(); + } + } +#endif + + bool initEngine(EngineMode newEngineMode) { - VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::initEngine()"; + if (engineMode == newEngineMode) + return engineMode != EngineUninitialized; + + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::initEngine()" << newEngineMode; if (decumaSession) - return; + exitEngine(); - symbolCategories.clear(); - symbolCategories.append(DECUMA_CATEGORY_ANSI); - languageCategories.clear(); - languageCategories.append(DECUMA_LANG_EN); + if (newEngineMode == EngineUninitialized) + return false; + + switch (newEngineMode) { + case Alphabetic: + case Arabic: + case Hebrew: + cjk = false; + break; + case SimplifiedChinese: + case TraditionalChinese: + case HongKongChinese: + case Japanese: + case Korean: + cjk = true; + break; + default: + Q_ASSERT(0 && "Invalid EngineMode!"); + return false; + } + engineMode = newEngineMode; memset(&sessionSettings, 0, sizeof(sessionSettings)); - QString latinDb = findLatinDb(":/databases/HWR_LatinCG/"); - hwrDbFile.setFileName(latinDb); + QString hwrDb = findHwrDb(engineMode, defaultHwrDbPath); + hwrDbFile.setFileName(hwrDb); if (!hwrDbFile.open(QIODevice::ReadOnly)) { - qWarning() << "Could not open hwr database file" << latinDb; - return; + qCritical() << "Could not open HWR database" << hwrDb; + exitEngine(); + return false; } sessionSettings.pStaticDB = (DECUMA_STATIC_DB_PTR)hwrDbFile.map(0, hwrDbFile.size(), QFile::NoOptions); if (!sessionSettings.pStaticDB) { - hwrDbFile.close(); - qWarning() << "Could not map hwr database" << latinDb; - return; + qCritical() << "Could not read HWR database" << hwrDb; + exitEngine(); + return false; } + symbolCategories.append(DECUMA_CATEGORY_ANSI); + languageCategories.append(DECUMA_LANG_EN); + sessionSettings.recognitionMode = mcrMode; sessionSettings.bMinimizeAddArcPreProcessing = 1; sessionSettings.writingDirection = unknownWriting; @@ -164,17 +238,25 @@ public: sessionSettings.charSet.pLanguages = languageCategories.data(); sessionSettings.charSet.nLanguages = languageCategories.size(); - session = QByteArray(decumaGetSessionSize(), 0); + session = QByteArray(DECUMA_API(GetSessionSize)(), 0); decumaSession = (DECUMA_SESSION *)(!session.isEmpty() ? session.data() : 0); - DECUMA_STATUS status = decumaBeginSession(decumaSession, &sessionSettings, &memFuncs); + DECUMA_STATUS status = DECUMA_API(BeginSession)(decumaSession, &sessionSettings, &memFuncs); Q_ASSERT(status == decumaNoError); if (status != decumaNoError) { - qWarning() << "Could not initialize T9Write engine" << status; + qCritical() << "Could not initialize T9Write engine" << status; + exitEngine(); + return false; } - worker.reset(new T9WriteWorker(decumaSession)); +#if QT_VIRTUALKEYBOARD_T9WRITE_LOG + DECUMA_API(StartLogging)(decumaSession, 0, decumaLogString); +#endif + + worker.reset(new T9WriteWorker(decumaSession, cjk)); worker->start(); + + return true; } void exitEngine() @@ -188,36 +270,80 @@ public: hwrDbFile.close(); } - detachDictionary(&attachedDictionary); - destroyConvertedDictionary(&convertedDictionary); + if (attachedDictionary) { + detachDictionary(attachedDictionary); + attachedDictionary.reset(); + } + loadedDictionary.reset(); if (decumaSession) { - decumaEndSession(decumaSession); +#if QT_VIRTUALKEYBOARD_T9WRITE_LOG + DECUMA_API(StopLogging)(decumaSession); +#endif + DECUMA_API(EndSession)(decumaSession); decumaSession = 0; session.clear(); } memset(&sessionSettings, 0, sizeof(sessionSettings)); - } - QString findLatinDb(const QString &dir) - { - QString latinDb; - QDirIterator it(dir, QDirIterator::NoIteratorFlags); - while (it.hasNext()) { - QString fileEntry = it.next(); + symbolCategories.clear(); + languageCategories.clear(); - if (!fileEntry.endsWith(QLatin1String(".bin"))) - continue; + engineMode = EngineUninitialized; + cjk = false; + } - latinDb = fileEntry; + QString findHwrDb(EngineMode mode, const QString &dir) const + { + QString hwrDbPath(dir); + switch (mode) { + case Alphabetic: +#if T9WRITEAPIMAJORVERNUM >= 21 + hwrDbPath.append(QLatin1String("hwrDB_le.bin")); +#else + hwrDbPath.append(QLatin1String("_databas_le.bin")); +#endif + break; + case Arabic: +#if T9WRITEAPIMAJORVERNUM >= 21 + hwrDbPath.append(QLatin1String("arabic/hwrDB_le.bin")); +#else + hwrDbPath.append(QLatin1String("arabic/_databas_le.bin")); +#endif + break; + case Hebrew: +#if T9WRITEAPIMAJORVERNUM >= 21 + hwrDbPath.append(QLatin1String("hebrew/hwrDB_le.bin")); +#else + hwrDbPath.append(QLatin1String("hebrew/_databas_le.bin")); +#endif break; + case SimplifiedChinese: + hwrDbPath.append(QLatin1String("cjk_S_gb18030_le.hdb")); + break; + case TraditionalChinese: + hwrDbPath.append(QLatin1String("cjk_T_std_le.hdb")); + break; + case HongKongChinese: + hwrDbPath.append(QLatin1String("cjk_HK_std_le.hdb")); + break; + case Japanese: + hwrDbPath.append(QLatin1String("cjk_J_std_le.hdb")); + break; + case Korean: + hwrDbPath.append(QLatin1String("cjk_K_mkt_le.hdb")); + break; + default: + return QString(); } - return latinDb; + return QFileInfo::exists(hwrDbPath) ? hwrDbPath : QString(); } - QString findDictionary(const QString &dir, const QLocale &locale) + QString findDictionary(const QString &dir, const QLocale &locale, DECUMA_SRC_DICTIONARY_TYPE &srcType) { + srcType = numberOfSrcDictionaryTypes; + QStringList languageCountry = locale.name().split("_"); if (languageCountry.length() != 2) return QString(); @@ -227,11 +353,27 @@ public: while (it.hasNext()) { QString fileEntry = it.next(); - if (!fileEntry.endsWith(QLatin1String(".ldb"))) + if (!fileEntry.contains("_" + languageCountry[0].toUpper())) continue; - if (!fileEntry.contains("_" + languageCountry[0].toUpper())) + if (fileEntry.endsWith(QLatin1String(".ldb"))) { +#if T9WRITEAPIMAJORVERNUM >= 20 + qCritical() << "Incompatible T9 Write dictionary" << fileEntry; continue; +#else + srcType = decumaXT9LDB; +#endif + } else if (fileEntry.endsWith(QLatin1String(".phd"))) { +#if T9WRITEAPIMAJORVERNUM >= 20 + srcType = decumaPortableHWRDictionary; +#else + qCritical() << "Incompatible T9 Write dictionary" << fileEntry; + continue; +#endif + } else { + qWarning() << "Incompatible T9 Write dictionary" << fileEntry; + continue; + } dictionary = fileEntry; break; @@ -240,201 +382,136 @@ public: return dictionary; } - bool attachDictionary(void *dictionary) + bool attachDictionary(const QSharedPointer<T9WriteDictionary> &dictionary) { - VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::attachDictionary():" << dictionary; - QMutexLocker dictionaryGuard(&dictionaryLock); Q_ASSERT(decumaSession != 0); Q_ASSERT(dictionary != 0); - - DECUMA_STATUS status = decumaAttachConvertedDictionary(decumaSession, dictionary); - Q_ASSERT(status == decumaNoError); + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::attachDictionary():" << dictionary->fileName(); +#if T9WRITEAPIMAJORVERNUM >= 20 + DECUMA_STATUS status = DECUMA_API(AttachDictionary)(decumaSession, dictionary->data(), dictionary->size()); +#else + DECUMA_STATUS status = DECUMA_API(AttachConvertedDictionary)(decumaSession, dictionary->data()); +#endif return status == decumaNoError; } - void detachDictionary(void **dictionary) + void detachDictionary(const QSharedPointer<T9WriteDictionary> &dictionary) { QMutexLocker dictionaryGuard(&dictionaryLock); - Q_ASSERT(decumaSession != 0); - if (!dictionary || !*dictionary) + if (!dictionary) return; - VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::detachDictionary():" << *dictionary; + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::detachDictionary():" << dictionary->fileName(); - DECUMA_STATUS status = decumaDetachDictionary(decumaSession, *dictionary); - Q_UNUSED(status) - Q_ASSERT(status == decumaNoError); - *dictionary = 0; - } - - void destroyConvertedDictionary(void **dictionary) - { - QMutexLocker dictionaryGuard(&dictionaryLock); Q_ASSERT(decumaSession != 0); - if (!dictionary || !*dictionary) - return; - - VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::destroyConvertedDictionary():" << *dictionary; - - DECUMA_STATUS status = decumaDestroyConvertedDictionary(dictionary, &memFuncs); + DECUMA_STATUS status = DECUMA_API(DetachDictionary)(decumaSession, dictionary->data()); Q_UNUSED(status) Q_ASSERT(status == decumaNoError); - Q_ASSERT(*dictionary == 0); } bool setInputMode(const QLocale &locale, InputEngine::InputMode inputMode) { + Q_Q(T9WriteInputMethod); VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::setInputMode():" << locale << inputMode; - Q_Q(T9WriteInputMethod); - DECUMA_UINT32 language = mapToDecumaLanguage(locale); + finishRecognition(); + + if (!initEngine(mapLocaleToEngineMode(locale))) + return false; + + DECUMA_UINT32 language = mapToDecumaLanguage(locale, inputMode); if (language == DECUMA_LANG_GSMDEFAULT) { - qWarning() << "Handwriting input does not support the language" << locale.name(); + qWarning() << "Handwriting is not supported in" << locale.name(); return false; } int isLanguageSupported = 0; - decumaDatabaseIsLanguageSupported(sessionSettings.pStaticDB, language, &isLanguageSupported); + DECUMA_API(DatabaseIsLanguageSupported)(sessionSettings.pStaticDB, language, &isLanguageSupported); if (!isLanguageSupported) { - qWarning() << "Handwriting input does not support the language" << locale.name(); + qWarning() << "Handwriting is not supported in" << locale.name(); return false; } - finishRecognition(); - - bool languageChanged = languageCategories.isEmpty() || !languageCategories.contains(language); - if (languageChanged) { - languageCategories.clear(); - languageCategories.append(language); - } - - // Choose the symbol categories by input mode, script and input method hints - bool leftToRightGestures = true; - Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints(); - symbolCategories.clear(); - switch (inputMode) { - case InputEngine::Latin: - if (inputMethodHints.testFlag(Qt::ImhEmailCharactersOnly)) { - symbolCategories.append(DECUMA_CATEGORY_EMAIL); - } else if (inputMethodHints.testFlag(Qt::ImhUrlCharactersOnly)) { - symbolCategories.append(DECUMA_CATEGORY_URL); - } else { - bool includeDigits = true; - bool includeBasicPunctuation = true; - switch (locale.script()) { - case QLocale::LatinScript: - if (language == DECUMA_LANG_EN) - symbolCategories.append(DECUMA_CATEGORY_ANSI); - else - symbolCategories.append(DECUMA_CATEGORY_ISO8859_1); - break; - - case QLocale::CyrillicScript: - symbolCategories.append(DECUMA_CATEGORY_CYRILLIC); - break; - - case QLocale::GreekScript: - symbolCategories.append(DECUMA_CATEGORY_GREEK); - break; - - default: - qWarning() << "Handwriting input does not support the language" << locale.name(); - return false; - } - - if (includeDigits) - symbolCategories.append(DECUMA_CATEGORY_DIGIT); - - if (includeBasicPunctuation) { - symbolCategories.append(DECUMA_CATEGORY_BASIC_PUNCTUATIONS); - symbolCategories.append(DECUMA_CATEGORY_CONTRACTION_MARK); - } - - if (language == DECUMA_LANG_ES) - symbolCategories.append(DECUMA_CATEGORY_SPANISH_PUNCTUATIONS); - } - break; - - case InputEngine::Numeric: - symbolCategories.append(DECUMA_CATEGORY_DIGIT); - if (!inputMethodHints.testFlag(Qt::ImhDigitsOnly)) - symbolCategories.append(DECUMA_CATEGORY_NUM_SUP); - break; + bool languageChanged = languageCategories.isEmpty() || languageCategories.first() != language; + languageCategories.clear(); + languageCategories.append(language); - case InputEngine::Dialable: - symbolCategories.append(DECUMA_CATEGORY_PHONE_NUMBER); - break; + // Add English as secondary language for non-latin languages. + // T9 Write requires it for punctuation and latin symbols if + // included in the symbol categories. + if (locale.script() != QLocale::LatinScript) + languageCategories.append(DECUMA_LANG_EN); - default: + if (!updateSymbolCategories(language, locale, inputMode)) return false; - } - - if (leftToRightGestures) { - symbolCategories.append(DECUMA_CATEGORY_BACKSPACE_STROKE); - symbolCategories.append(DECUMA_CATEGORY_RETURN_STROKE); - symbolCategories.append(DECUMA_CATEGORY_WHITESPACE_STROKE); - } - - /* The dictionary is loaded in the background thread. Once the loading is - complete the dictionary will be attached to the current session. The - attachment happens in the worker thread context, thus the direct - connection for the signal handler and the mutex protecting the - converted dictionary for concurrent access. - - The loading operation is blocking for the main thread only if the - user starts handwriting input before the operation is complete. - */ - { - QMutexLocker dictionaryGuard(&dictionaryLock); - - // Select recognition mode - // Note: MCR mode is preferred in all cases, since it eliminates the need - // for recognition timer, thus provides better user experience. - sessionSettings.recognitionMode = inputMethodHints.testFlag(Qt::ImhHiddenText) ? scrMode : mcrMode; - - // Detach previous dictionary if the language is being changed - // or the recognizer mode is single-character mode - if ((languageChanged || inputMethodHints.testFlag(Qt::ImhNoPredictiveText) || sessionSettings.recognitionMode == scrMode) && attachedDictionary) { - detachDictionary(&attachedDictionary); - } - - // Check if a dictionary needs to be loaded - if (languageChanged || !convertedDictionary) { - destroyConvertedDictionary(&convertedDictionary); - dictionaryFileName = findDictionary(":/databases/XT9_LDBs/", locale); - if (!dictionaryFileName.isEmpty()) { - if (dictionaryTask.isNull() || dictionaryTask->fileUri != dictionaryFileName) { - dictionaryTask.reset(new T9WriteDictionaryTask(dictionaryFileName, memFuncs)); - q->connect(dictionaryTask.data(), SIGNAL(completed(QString,void*)), - SLOT(dictionaryLoadCompleted(QString,void*)), Qt::DirectConnection); - worker->addTask(dictionaryTask); - } - } - } + updateRecognitionMode(language, locale, inputMode); + updateDictionary(language, locale, languageChanged); + static const QList<DECUMA_UINT32> rtlLanguages = QList<DECUMA_UINT32>() + << DECUMA_LANG_AR << DECUMA_LANG_IW << DECUMA_LANG_FA << DECUMA_LANG_UR; + sessionSettings.writingDirection = rtlLanguages.contains(language) ? rightToLeft : unknownWriting; + + // Enable multi-threaded recognition if available. +#ifdef DECUMA_USE_MULTI_THREAD + // Note: This feature requires T9 Write v8.0.0 or later, + // and feature enabled in the SDK. + sessionSettings.nMaxThreads = qMax(QThread::idealThreadCount(), 0); +#endif - // Attach existing dictionary, if necessary - if (sessionSettings.recognitionMode == mcrMode && !inputMethodHints.testFlag(Qt::ImhNoPredictiveText) && - convertedDictionary && !attachedDictionary) { - attachDictionary(convertedDictionary); - attachedDictionary = convertedDictionary; - } - } + VIRTUALKEYBOARD_DEBUG() << " -> language categories:" << languageCategories; + VIRTUALKEYBOARD_DEBUG() << " -> symbol categories:" << symbolCategories; + VIRTUALKEYBOARD_DEBUG() << " -> recognition mode:" << sessionSettings.recognitionMode; // Change session settings sessionSettings.charSet.pSymbolCategories = symbolCategories.data(); sessionSettings.charSet.nSymbolCategories = symbolCategories.size(); sessionSettings.charSet.pLanguages = languageCategories.data(); sessionSettings.charSet.nLanguages = languageCategories.size(); - DECUMA_STATUS status = decumaChangeSessionSettings(decumaSession, &sessionSettings); + DECUMA_STATUS status = DECUMA_API(ChangeSessionSettings)(decumaSession, &sessionSettings); Q_ASSERT(status == decumaNoError); - caseFormatter.preferLowercase = inputMethodHints.testFlag(Qt::ImhPreferLowercase); + caseFormatter.preferLowercase = q->inputContext()->inputMethodHints().testFlag(Qt::ImhPreferLowercase); return status == decumaNoError; } - DECUMA_UINT32 mapToDecumaLanguage(const QLocale &locale) + EngineMode mapLocaleToEngineMode(const QLocale &locale) + { +#ifdef HAVE_T9WRITE_CJK + switch (locale.language()) { + case QLocale::Chinese: { + if (locale.script() == QLocale::TraditionalChineseScript) + return locale.country() == QLocale::HongKong ? HongKongChinese : TraditionalChinese; + return SimplifiedChinese; + break; + } + case QLocale::Japanese: + return Japanese; + break; + case QLocale::Korean: + return Korean; + default: + break; + } +#else + Q_UNUSED(locale) +#endif + +#ifdef HAVE_T9WRITE_ALPHABETIC + switch (locale.script()) { + case QLocale::ArabicScript: + return T9WriteInputMethodPrivate::Arabic; + case QLocale::HebrewScript: + return T9WriteInputMethodPrivate::Hebrew; + default: + return T9WriteInputMethodPrivate::Alphabetic; + } +#else + return T9WriteInputMethodPrivate::EngineUninitialized; +#endif + } + + DECUMA_UINT32 mapToDecumaLanguage(const QLocale &locale, InputEngine::InputMode inputMode) { static const QLocale::Language maxLanguage = QLocale::Vietnamese; static const DECUMA_UINT32 languageMap[maxLanguage + 1] = { @@ -538,7 +615,7 @@ public: DECUMA_LANG_GSMDEFAULT, // Samoan = 97 DECUMA_LANG_GSMDEFAULT, // Sango = 98 DECUMA_LANG_GSMDEFAULT, // Sanskrit = 99 - DECUMA_LANG_SR, // Serbian = 100 + DECUMA_LANG_SRCY, // Serbian = 100 DECUMA_LANG_GSMDEFAULT, // Ossetic = 101 DECUMA_LANG_ST, // SouthernSotho = 102 DECUMA_LANG_GSMDEFAULT, // Tswana = 103 @@ -573,22 +650,388 @@ public: DECUMA_LANG_VI // Vietnamese = 132 }; + int localeLanguage = locale.language(); if (locale.language() > maxLanguage) return DECUMA_LANG_GSMDEFAULT; - DECUMA_UINT32 language = languageMap[locale.language()]; + DECUMA_UINT32 language = languageMap[localeLanguage]; + if (language == DECUMA_LANG_PRC) { + if (inputMode != InputEngine::ChineseHandwriting) + 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; + } else if (language == DECUMA_LANG_SRCY) { + if (inputMode != InputEngine::Cyrillic) + language = DECUMA_LANG_SRLA; + } else if (language == DECUMA_LANG_AR || language == DECUMA_LANG_FA) { + if (inputMode != InputEngine::Arabic && inputMode != InputEngine::Numeric) + language = DECUMA_LANG_EN; + } else if (language == DECUMA_LANG_IW) { + if (inputMode != InputEngine::Hebrew) + language = DECUMA_LANG_EN; + } return language; } + void updateRecognitionMode(DECUMA_UINT32 language, const QLocale &locale, + InputEngine::InputMode inputMode) + { + Q_Q(T9WriteInputMethod); + Q_UNUSED(language) + Q_UNUSED(locale) + Q_UNUSED(inputMode) + + // Select recognition mode + // Note: MCR mode is preferred, as it does not require recognition + // timer and provides better user experience. + sessionSettings.recognitionMode = mcrMode; + + // Use scrMode with hidden text or with no predictive mode + 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; + } + } + + bool updateSymbolCategories(DECUMA_UINT32 language, const QLocale &locale, + InputEngine::InputMode inputMode) + { + // Handle CJK in separate method + if (cjk) + return updateSymbolCategoriesCjk(language, locale, inputMode); + + symbolCategories.clear(); + + // Choose the symbol categories by input mode, script and input method hints + bool leftToRightGestures = true; + Q_Q(T9WriteInputMethod); + const Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints(); + switch (inputMode) { + case InputEngine::Latin: + if (inputMethodHints.testFlag(Qt::ImhEmailCharactersOnly)) { + symbolCategories.append(DECUMA_CATEGORY_EMAIL); + } else if (inputMethodHints.testFlag(Qt::ImhUrlCharactersOnly)) { + symbolCategories.append(DECUMA_CATEGORY_URL); + } else { + if (language == DECUMA_LANG_EN || language == DECUMA_LANG_NL) + symbolCategories.append(DECUMA_CATEGORY_ANSI); + else + symbolCategories.append(DECUMA_CATEGORY_ISO8859_1); + symbolCategories.append(DECUMA_CATEGORY_DIGIT); + symbolCategories.append(DECUMA_CATEGORY_BASIC_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_CONTRACTION_MARK); + if (language == DECUMA_LANG_ES) + symbolCategories.append(DECUMA_CATEGORY_SPANISH_PUNCTUATIONS); + } + break; + + case InputEngine::Numeric: + if (language == DECUMA_LANG_AR || language == DECUMA_LANG_FA) { + symbolCategories.append(DECUMA_CATEGORY_ARABIC_NUM_MODE); + symbolCategories.append(DECUMA_CATEGORY_ARABIC_GESTURES); + leftToRightGestures = false; + break; + } + symbolCategories.append(DECUMA_CATEGORY_DIGIT); + if (!inputMethodHints.testFlag(Qt::ImhDigitsOnly)) + symbolCategories.append(DECUMA_CATEGORY_NUM_SUP); + break; + + case InputEngine::Dialable: + symbolCategories.append(DECUMA_CATEGORY_PHONE_NUMBER); + break; + + case InputEngine::Greek: + symbolCategories.append(DECUMA_CATEGORY_GREEK); + symbolCategories.append(DECUMA_CATEGORY_QUEST_EXCL_MARK_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_PERIOD_COMMA_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_COLON_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_CONTRACTION_MARK); + symbolCategories.append(DECUMA_CATEGORY_CONTRACTION_MARK); + break; + + case InputEngine::Cyrillic: + symbolCategories.append(DECUMA_CATEGORY_CYRILLIC); + symbolCategories.append(DECUMA_CATEGORY_QUEST_EXCL_MARK_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_PERIOD_COMMA_PUNCTUATIONS); + // Ukrainian needs contraction mark, but not Russian or Bulgarian + if (language == DECUMA_LANG_UK) + symbolCategories.append(DECUMA_CATEGORY_CONTRACTION_MARK); + break; + + case InputEngine::Arabic: + symbolCategories.append(DECUMA_CATEGORY_ARABIC_ISOLATED_LETTER_MODE); + symbolCategories.append(DECUMA_CATEGORY_ARABIC_GESTURES); + leftToRightGestures = false; + break; + + case InputEngine::Hebrew: + symbolCategories.append(DECUMA_CATEGORY_HEBREW_GL_HEBREW_CURSIVE_MODE); + symbolCategories.append(DECUMA_CATEGORY_HEBREW_GL_HEBREW_LETTERSYMBOLS); + symbolCategories.append(DECUMA_CATEGORY_HEBREW_SHEQEL); + symbolCategories.append(DECUMA_CATEGORY_ARABIC_GESTURES); + leftToRightGestures = false; + break; + + default: + qWarning() << "Handwriting is not supported in" << locale.name(); + return false; + } + + if (leftToRightGestures) { + symbolCategories.append(DECUMA_CATEGORY_BACKSPACE_STROKE); + symbolCategories.append(DECUMA_CATEGORY_RETURN_STROKE); + symbolCategories.append(DECUMA_CATEGORY_WHITESPACE_STROKE); + } + + return true; + } + + bool updateSymbolCategoriesCjk(DECUMA_UINT32 language, const QLocale &locale, + InputEngine::InputMode inputMode) + { + Q_UNUSED(language) + Q_ASSERT(cjk); + + symbolCategories.clear(); + + switch (inputMode) { + case InputEngine::Latin: + symbolCategories.append(DECUMA_CATEGORY_ANSI); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS); + break; + + case InputEngine::Numeric: + symbolCategories.append(DECUMA_CATEGORY_DIGIT); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS); + break; + + case InputEngine::Dialable: + symbolCategories.append(DECUMA_CATEGORY_DIGIT); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + break; + + case InputEngine::ChineseHandwriting: + switch (locale.script()) { + case QLocale::SimplifiedChineseScript: + symbolCategories.append(DECUMA_CATEGORY_GB2312_A); + symbolCategories.append(DECUMA_CATEGORY_GB2312_B_CHARS_ONLY); + symbolCategories.append(DECUMA_CATEGORY_GBK_3); + symbolCategories.append(DECUMA_CATEGORY_GBK_4); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + symbolCategories.append(DECUMA_CATEGORY_CJK_GENERAL_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS); + break; + + case QLocale::TraditionalChineseScript: + symbolCategories.append(DECUMA_CATEGORY_BIGFIVE); + if (language == DECUMA_LANG_HK) + symbolCategories.append(DECUMA_CATEGORY_HKSCS_CHARS_ONLY); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + symbolCategories.append(DECUMA_CATEGORY_CJK_GENERAL_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS); + break; + + default: + qWarning() << "Chinese handwriting is not supported in" << locale.name(); + return false; + } + 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); + symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL); + symbolCategories.append(DECUMA_CATEGORY_CJK_GENERAL_PUNCTUATIONS); + symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS); + break; + + default: + return false; + } + + return true; + } + + void updateDictionary(DECUMA_UINT32 language, const QLocale &locale, bool languageChanged) + { + Q_Q(T9WriteInputMethod); + + /* The dictionary is loaded in the background thread. Once the loading is + complete the dictionary will be attached to the current session. The + attachment happens in the worker thread context, thus the direct + connection for the signal handler and the mutex protecting the + converted dictionary for concurrent access. + The loading operation is blocking for the main thread only if the + user starts handwriting input before the operation is complete. + */ + QMutexLocker dictionaryGuard(&dictionaryLock); + + // Detach previous dictionary if the language is being changed + // or the recognizer mode is single-character mode + const Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints(); + if ((languageChanged || inputMethodHints.testFlag(Qt::ImhNoPredictiveText) || sessionSettings.recognitionMode == scrMode) && attachedDictionary) { + detachDictionary(attachedDictionary); + attachedDictionary.reset(); + } + + // Check if a dictionary needs to be loaded + if (languageChanged || !loadedDictionary) { + loadedDictionary.reset(); + + DECUMA_SRC_DICTIONARY_INFO dictionaryInfo; + memset(&dictionaryInfo, 0, sizeof(dictionaryInfo)); + + QList<QLocale> decumaLocales; + decumaLocales.append(locale); + + // CJK: No dictionary for latin input + if (cjk && language == DECUMA_LANG_EN) + decumaLocales.clear(); + + dictionaryFileName.clear(); + QLocale decumaLocale; + for (QLocale tryLocale : decumaLocales) { + dictionaryFileName = findDictionary(defaultDictionaryDbPath, tryLocale, dictionaryInfo.srcType); + if (!dictionaryFileName.isEmpty()) { + decumaLocale = tryLocale; + break; + } + } + if (!dictionaryFileName.isEmpty()) { + if (dictionaryTask.isNull() || dictionaryTask->dictionaryFileName != dictionaryFileName) { + VIRTUALKEYBOARD_DEBUG() << " -> load dictionary:" << dictionaryFileName; + + bool convertDictionary = true; +#if defined(HAVE_T9WRITE_CJK) && T9WRITEAPIMAJORVERNUM >= 20 + // Chinese dictionary cannot be converted (PHD) + if (dictionaryInfo.srcType == decumaPortableHWRDictionary && decumaLocale.language() == QLocale::Chinese) + convertDictionary = false; +#endif + + QSharedPointer<T9WriteDictionary> newDictionary(new T9WriteDictionary(decumaSession, memFuncs, cjk)); + dictionaryTask.reset(new T9WriteDictionaryTask(newDictionary, dictionaryFileName, convertDictionary, dictionaryInfo)); + + QObject::connect(dictionaryTask.data(), &T9WriteDictionaryTask::completed, + q, &T9WriteInputMethod::dictionaryLoadCompleted, Qt::DirectConnection); + worker->addTask(dictionaryTask); + } + } + } + + // Attach existing dictionary, if available + if (sessionSettings.recognitionMode == mcrMode && !inputMethodHints.testFlag(Qt::ImhNoPredictiveText) && + loadedDictionary && !attachedDictionary) { + if (attachDictionary(loadedDictionary)) + attachedDictionary = loadedDictionary; + } + } + + QByteArray getContext(InputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, + const QVariantMap &traceScreenInfo) const + { + QCryptographicHash hash(QCryptographicHash::Md5); + + hash.addData((const char *)&patternRecognitionMode, sizeof(patternRecognitionMode)); + + QByteArray mapData; + QDataStream ds(&mapData, QIODevice::WriteOnly); + ds << traceCaptureDeviceInfo; + ds << traceScreenInfo; + hash.addData(mapData); + + return hash.result(); + } + + void setContext(InputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, + const QVariantMap &traceScreenInfo) + { + QByteArray context = getContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo); + if (context == currentContext) + return; + currentContext = context; + + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::setContext():" << QString(context.toHex()); + + // Finish recognition, but preserve current input + Q_Q(T9WriteInputMethod); + QString preeditText = q->inputContext()->preeditText(); + // WA: T9Write CJK may crash in some cases with long stringStart. + // Therefore we don't restore the current input in this mode. + bool preserveCurrentInput = !preeditText.isEmpty() && !cjk; + T9WriteCaseFormatter oldCaseFormatter(caseFormatter); + finishRecognition(!preserveCurrentInput); + + if (preserveCurrentInput) { + caseFormatter = oldCaseFormatter; + stringStart = preeditText; + wordCandidates.append(preeditText); + activeWordIndex = 0; + emit q->selectionListChanged(SelectionListModel::WordCandidateList); + emit q->selectionListActiveItemChanged(SelectionListModel::WordCandidateList, activeWordIndex); + } + + const int dpi = traceCaptureDeviceInfo.value("dpi", 96).toInt(); + static const int INSTANT_GESTURE_WIDTH_THRESHOLD_MM = 25; + static const int INSTANT_GESTURE_HEIGHT_THRESHOLD_MM = 25; + instantGestureSettings.widthThreshold = INSTANT_GESTURE_WIDTH_THRESHOLD_MM / 25.4 * dpi; + instantGestureSettings.heightThreshold = INSTANT_GESTURE_HEIGHT_THRESHOLD_MM / 25.4 * dpi; + + gestureRecognizer.setDpi(dpi); + + QVariantList horizontalRulers(traceScreenInfo.value("horizontalRulers", QVariantList()).toList()); + if (horizontalRulers.count() >= 2) { + sessionSettings.baseline = horizontalRulers.last().toInt(); + sessionSettings.helpline = 0; + sessionSettings.topline = horizontalRulers.first().toInt(); + sessionSettings.supportLineSet = baselineAndTopline; + } else { + sessionSettings.baseline = 0; + sessionSettings.helpline = 0; + sessionSettings.topline = 0; + sessionSettings.supportLineSet = baselineAndTopline; + } + + DECUMA_STATUS status = DECUMA_API(ChangeSessionSettings)(decumaSession, &sessionSettings); + Q_ASSERT(status == decumaNoError); + } + Trace *traceBegin(int traceId, InputEngine::PatternRecognitionMode patternRecognitionMode, const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo) { Q_UNUSED(traceId) Q_UNUSED(patternRecognitionMode) - Q_UNUSED(traceCaptureDeviceInfo) Q_UNUSED(traceScreenInfo) + if (!worker) + return 0; + stopResultTimer(); // Dictionary must be completed before the arc addition can begin @@ -606,30 +1049,34 @@ public: recognitionTask.reset(); } - const int dpi = traceCaptureDeviceInfo.value("dpi", 96).toInt(); - static const int INSTANT_GESTURE_WIDTH_THRESHOLD_MM = 25; - static const int INSTANT_GESTURE_HEIGHT_THRESHOLD_MM = 25; - instantGestureSettings.widthThreshold = INSTANT_GESTURE_WIDTH_THRESHOLD_MM / 25.4 * dpi; - instantGestureSettings.heightThreshold = INSTANT_GESTURE_HEIGHT_THRESHOLD_MM / 25.4 * dpi; +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + if (!unipenTrace) + unipenTrace.reset(new UnipenTrace(traceCaptureDeviceInfo, traceScreenInfo)); +#endif + + setContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo); DECUMA_STATUS status; if (!arcAdditionStarted) { - status = decumaBeginArcAddition(decumaSession); + status = DECUMA_API(BeginArcAddition)(decumaSession); Q_ASSERT(status == decumaNoError); arcAdditionStarted = true; } DECUMA_UINT32 arcID = (DECUMA_UINT32)traceId; - status = decumaStartNewArc(decumaSession, arcID); + status = DECUMA_API(StartNewArc)(decumaSession, arcID); Q_ASSERT(status == decumaNoError); if (status != decumaNoError) { - decumaEndArcAddition(decumaSession); + DECUMA_API(EndArcAddition)(decumaSession); arcAdditionStarted = false; return NULL; } Trace *trace = new Trace(); +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + trace->setChannels(QStringList("t")); +#endif traceList.append(trace); return trace; @@ -638,7 +1085,7 @@ public: void traceEnd(Trace *trace) { if (trace->isCanceled()) { - decumaCancelArc(decumaSession, trace->traceId()); + DECUMA_API(CancelArc)(decumaSession, trace->traceId()); traceList.removeOne(trace); delete trace; } else { @@ -646,10 +1093,16 @@ public: } if (!traceList.isEmpty()) { Q_ASSERT(arcAdditionStarted); - if (countActiveTraces() == 0) + if (countActiveTraces() == 0) { restartRecognition(); + if (cjk) { + // For some reason gestures don't seem to work in CJK mode + // Using our own gesture recognizer as fallback + handleGesture(); + } + } } else if (arcAdditionStarted) { - decumaEndArcAddition(decumaSession); + DECUMA_API(EndArcAddition)(decumaSession); arcAdditionStarted = false; } } @@ -675,17 +1128,26 @@ public: Q_ASSERT(decumaSession != 0); const QVariantList points = trace->points(); + Q_ASSERT(!points.isEmpty()); DECUMA_UINT32 arcID = (DECUMA_UINT32)trace->traceId(); DECUMA_STATUS status; for (const QVariant &p : points) { const QPoint pt(p.toPointF().toPoint()); - status = decumaAddPoint(decumaSession, (DECUMA_COORD)pt.x(),(DECUMA_COORD)pt.y(), arcID); - Q_ASSERT(status == decumaNoError); + status = DECUMA_API(AddPoint)(decumaSession, (DECUMA_COORD)pt.x(),(DECUMA_COORD)pt.y(), arcID); + if (status != decumaNoError) { + VIRTUALKEYBOARD_DEBUG() << "decumaAddPoint failed" << status; + finishRecognition(); + return; + } } - status = decumaCommitArc(decumaSession, arcID); - Q_ASSERT(status == decumaNoError); + status = DECUMA_API(CommitArc)(decumaSession, arcID); + if (status != decumaNoError) { + VIRTUALKEYBOARD_DEBUG() << "decumaCommitArc failed" << status; + finishRecognition(); + return; + } } void noteSelected(int index) @@ -696,7 +1158,7 @@ public: VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::noteSelected():" << index; Q_ASSERT(index >= 0 && index < wordCandidatesHwrResultIndex.length()); int resultIndex = wordCandidatesHwrResultIndex[index]; - DECUMA_STATUS status = decumaNoteSelectedCandidate(decumaSession, resultIndex); + DECUMA_STATUS status = DECUMA_API(NoteSelectedCandidate)(decumaSession, resultIndex); Q_UNUSED(status) Q_ASSERT(status == decumaNoError); } @@ -723,6 +1185,8 @@ public: bool finishRecognition(bool emitSelectionListChanged = true) { VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::finishRecognition()"; + if (!worker) + return false; bool result = !traceList.isEmpty(); @@ -742,7 +1206,7 @@ public: } if (arcAdditionStarted) { - decumaEndArcAddition(decumaSession); + DECUMA_API(EndArcAddition)(decumaSession); arcAdditionStarted = false; } @@ -762,11 +1226,18 @@ public: scrResult.clear(); caseFormatter.clear(); +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + unipenTrace.reset(); +#endif + return result; } bool select(int index = -1) { + if (!worker) + return false; + if (sessionSettings.recognitionMode == mcrMode && wordCandidates.isEmpty()) { finishRecognition(); return false; @@ -783,6 +1254,25 @@ public: index = index >= 0 ? index : activeWordIndex; noteSelected(index); QString finalWord = wordCandidates.at(index); + +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + // Record trace + if (unipenTrace) { + if (finalWord.length() == 1) { + // In recording mode, the text case must match with the current text case + QChar ch(finalWord.at(0)); + if (!ch.isLetter() || (ch.isUpper() == (textCase == InputEngine::Upper))) { + QStringList homeLocations = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); + if (!homeLocations.isEmpty()) { + unipenTrace->setDirectory(QStringLiteral("%1/%2").arg(homeLocations.at(0)).arg("VIRTUAL_KEYBOARD_TRACES")); + unipenTrace->record(traceList); + unipenTrace->save(ch.unicode(), 100); + } + } + } + } +#endif + finishRecognition(); q->inputContext()->commit(finalWord); } else if (sessionSettings.recognitionMode == scrMode) { @@ -865,8 +1355,13 @@ public: bool wordCandidatesChanged = wordCandidates != newWordCandidates; +#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT // Delete trace history - if (sessionSettings.recognitionMode == mcrMode && !symbolStrokes.isEmpty()) { + const InputEngine::InputMode inputMode = q->inputEngine()->inputMode(); + if (sessionSettings.recognitionMode == mcrMode && !symbolStrokes.isEmpty() && + 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(); @@ -874,7 +1369,14 @@ public: delete traceList.takeFirst(); } - // Look for a gesture at the end of first result + // Enforce hard limit for number of traces + if (traceList.count() >= traceListHardLimit) { + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::processResult(): Clearing traces (hard limit):" << traceList.count(); + clearTraces(); + } +#endif + + // Find a gesture at the end of the first result if (!gesture.isEmpty()) { DECUMA_UNICODE gestureSymbol = gesture.at(0).unicode(); @@ -892,8 +1394,8 @@ public: break; default: - finishRecognition(); ic->commit(ic->preeditText()); + finishRecognition(); break; } @@ -920,6 +1422,87 @@ public: } } + bool handleGesture() + { + if (countActiveTraces() > 0) + return false; + + QVariantMap gesture(gestureRecognizer.recognize(traceList.mid(traceList.length() - 1, 1))); + if (gesture.isEmpty()) + return false; + + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethodPrivate::handleGesture():" << gesture; + + if (gesture[QLatin1String("type")].toString() == QLatin1String("swipe")) { + + static const int SWIPE_ANGLE_THRESHOLD = 15; // degrees +- + + qreal swipeLength = gesture[QLatin1String("length")].toReal(); + if (swipeLength >= instantGestureSettings.widthThreshold) { + + Q_Q(T9WriteInputMethod); + InputContext *ic = q->inputContext(); + if (!ic) + return false; + + qreal swipeAngle = gesture[QLatin1String("angle_degrees")].toReal(); + int swipeTouchCount = gesture[QLatin1String("touch_count")].toInt(); + + // Swipe left + if (swipeAngle <= 180 + SWIPE_ANGLE_THRESHOLD && swipeAngle >= 180 - SWIPE_ANGLE_THRESHOLD) { + if (swipeTouchCount == 1) { + // Single swipe: backspace + ic->inputEngine()->virtualKeyClick(Qt::Key_Backspace, QString(), Qt::NoModifier); + return true; + } + return false; + } + + // Swipe right + const InputEngine::InputMode inputMode = q->inputEngine()->inputMode(); + 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 + ic->inputEngine()->virtualKeyClick(Qt::Key_Space, QString(" "), Qt::NoModifier); + return true; + } + return false; + } + } + + // Swipe up + if (swipeAngle <= 270 + SWIPE_ANGLE_THRESHOLD && swipeAngle >= 270 - SWIPE_ANGLE_THRESHOLD) { + if (swipeTouchCount == 1) { + // Single swipe: toggle input mode + select(); + if (!(ic->inputMethodHints() & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly))) { + QList<int> inputModes = ic->inputEngine()->inputModes(); + // Filter out duplicate numeric mode (in favor of Numeric) + int indexOfNumericInputMode = inputModes.indexOf(InputEngine::Numeric); + int indexOfDialableInputMode = inputModes.indexOf(InputEngine::Dialable); + if (indexOfNumericInputMode != -1 && indexOfDialableInputMode != -1) + inputModes.removeAt(inputMode != InputEngine::Dialable ? + indexOfDialableInputMode : + indexOfNumericInputMode); + if (inputModes.count() > 1) { + int inputModeIndex = inputModes.indexOf((int)inputMode) + 1; + if (inputModeIndex >= inputModes.count()) + inputModeIndex = 0; + ic->inputEngine()->setInputMode((InputEngine::InputMode)inputModes.at(inputModeIndex)); + } + } + return true; + } + } + } + } + + return false; + } + bool isValidInputChar(const QChar &c) const { if (c.isLetterOrNumber()) @@ -948,17 +1531,23 @@ public: T9WriteInputMethod *q_ptr; static const DECUMA_MEM_FUNCTIONS memFuncs; + bool cjk; + EngineMode engineMode; + QByteArray currentContext; DECUMA_SESSION_SETTINGS sessionSettings; DECUMA_INSTANT_GESTURE_SETTINGS instantGestureSettings; + QString defaultHwrDbPath; + QString defaultDictionaryDbPath; QFile hwrDbFile; QVector<DECUMA_UINT32> languageCategories; QVector<DECUMA_UINT32> symbolCategories; QScopedPointer<T9WriteWorker> worker; QList<Trace *> traceList; + int traceListHardLimit; QMutex dictionaryLock; QString dictionaryFileName; - void *convertedDictionary; - void *attachedDictionary; + QSharedPointer<T9WriteDictionary> loadedDictionary; + QSharedPointer<T9WriteDictionary> attachedDictionary; QSharedPointer<T9WriteDictionaryTask> dictionaryTask; QSharedPointer<T9WriteRecognitionTask> recognitionTask; int resultId; @@ -974,6 +1563,10 @@ public: bool ignoreUpdate; InputEngine::TextCase textCase; T9WriteCaseFormatter caseFormatter; + HandwritingGestureRecognizer gestureRecognizer; +#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + QScopedPointer<UnipenTrace> unipenTrace; +#endif }; const DECUMA_MEM_FUNCTIONS T9WriteInputMethodPrivate::memFuncs = { @@ -991,8 +1584,6 @@ const DECUMA_MEM_FUNCTIONS T9WriteInputMethodPrivate::memFuncs = { T9WriteInputMethod::T9WriteInputMethod(QObject *parent) : AbstractInputMethod(*new T9WriteInputMethodPrivate(this), parent) { - Q_D(T9WriteInputMethod); - d->initEngine(); } T9WriteInputMethod::~T9WriteInputMethod() @@ -1003,18 +1594,94 @@ T9WriteInputMethod::~T9WriteInputMethod() QList<InputEngine::InputMode> T9WriteInputMethod::inputModes(const QString &locale) { - Q_UNUSED(locale) - return QList<InputEngine::InputMode>() - << InputEngine::Latin - << InputEngine::Numeric - << InputEngine::Dialable; + Q_D(T9WriteInputMethod); + QList<InputEngine::InputMode> availableInputModes; + const Qt::InputMethodHints inputMethodHints(inputContext()->inputMethodHints()); + const QLocale loc(locale); + T9WriteInputMethodPrivate::EngineMode mode = d->mapLocaleToEngineMode(loc); + + // Add primary input mode + switch (mode) { +#ifdef HAVE_T9WRITE_ALPHABETIC + case T9WriteInputMethodPrivate::Alphabetic: + if (d->findHwrDb(T9WriteInputMethodPrivate::Alphabetic, d->defaultHwrDbPath).isEmpty()) + return availableInputModes; + if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly))) { + switch (loc.script()) { + case QLocale::GreekScript: + availableInputModes.append(InputEngine::Greek); + break; + case QLocale::CyrillicScript: + availableInputModes.append(InputEngine::Cyrillic); + break; + default: + break; + } + availableInputModes.append(InputEngine::Latin); + } + break; + case T9WriteInputMethodPrivate::Arabic: + if (d->findHwrDb(T9WriteInputMethodPrivate::Arabic, d->defaultHwrDbPath).isEmpty()) + return availableInputModes; + if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly))) + availableInputModes.append(InputEngine::Arabic); + break; + case T9WriteInputMethodPrivate::Hebrew: + if (d->findHwrDb(T9WriteInputMethodPrivate::Hebrew, d->defaultHwrDbPath).isEmpty()) + return availableInputModes; + if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly))) + availableInputModes.append(InputEngine::Hebrew); + break; +#endif +#ifdef HAVE_T9WRITE_CJK + case T9WriteInputMethodPrivate::SimplifiedChinese: + case T9WriteInputMethodPrivate::TraditionalChinese: + case T9WriteInputMethodPrivate::HongKongChinese: + if (d->findHwrDb(mode, d->defaultHwrDbPath).isEmpty()) + return availableInputModes; + 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; + if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly))) + availableInputModes.append(InputEngine::KoreanHandwriting); + break; +#endif + default: + return availableInputModes; + } + + // Add exclusive input modes + if (inputMethodHints.testFlag(Qt::ImhDialableCharactersOnly) || inputMethodHints.testFlag(Qt::ImhDigitsOnly)) { + availableInputModes.append(InputEngine::Dialable); + } else if (inputMethodHints.testFlag(Qt::ImhFormattedNumbersOnly)) { + availableInputModes.append(InputEngine::Numeric); + } else if (inputMethodHints.testFlag(Qt::ImhLatinOnly)) { + availableInputModes.append(InputEngine::Latin); + } else { + // Add other input modes + Q_ASSERT(!availableInputModes.isEmpty()); + if (!availableInputModes.contains(InputEngine::Latin)) + availableInputModes.append(InputEngine::Latin); + availableInputModes.append(InputEngine::Numeric); + } + + return availableInputModes; } bool T9WriteInputMethod::setInputMode(const QString &locale, InputEngine::InputMode inputMode) { Q_D(T9WriteInputMethod); d->select(); - return d->setInputMode(locale, inputMode); + return d->setInputMode(QLocale(locale), inputMode); } bool T9WriteInputMethod::setTextCase(InputEngine::TextCase textCase) @@ -1045,6 +1712,13 @@ bool T9WriteInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboard if (preeditText.length() > 1) { preeditText.chop(1); ic->setPreeditText(preeditText); + // WA: T9Write CJK may crash in some cases with long stringStart. + // Therefore we commit the current input and finish the recognition. + if (d->cjk) { + ic->commit(); + d->finishRecognition(); + return true; + } d->caseFormatter.ensureLength(preeditText.length(), d->textCase); T9WriteCaseFormatter caseFormatter(d->caseFormatter); d->finishRecognition(false); @@ -1182,11 +1856,15 @@ bool T9WriteInputMethod::reselect(int cursorPosition, const InputEngine::Reselec if (!ic) return false; + 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; if (reselectFlags.testFlag(InputEngine::WordBeforeCursor)) { - for (int i = cursorPosition - 1; i >= 0; --i) { + for (int i = cursorPosition - 1; i >= 0 && d->stringStart.length() < maxLength; --i) { QChar c = surroundingText.at(i); if (!d->isValidInputChar(c)) break; @@ -1206,7 +1884,7 @@ bool T9WriteInputMethod::reselect(int cursorPosition, const InputEngine::Reselec } if (reselectFlags.testFlag(InputEngine::WordAfterCursor)) { - for (int i = cursorPosition; i < surroundingText.length(); ++i) { + for (int i = cursorPosition; i < surroundingText.length() && d->stringStart.length() < maxLength; ++i) { QChar c = surroundingText.at(i); if (!d->isValidInputChar(c)) break; @@ -1224,7 +1902,7 @@ bool T9WriteInputMethod::reselect(int cursorPosition, const InputEngine::Reselec if (d->stringStart.isEmpty()) return false; - if (reselectFlags.testFlag(InputEngine::WordAtCursor) && replaceFrom == -d->stringStart.length()) { + if (reselectFlags.testFlag(InputEngine::WordAtCursor) && replaceFrom == -d->stringStart.length() && d->stringStart.length() < maxLength) { d->stringStart.clear(); return false; } @@ -1258,35 +1936,41 @@ void T9WriteInputMethod::timerEvent(QTimerEvent *timerEvent) if (timerId == d->resultTimer) { if (d->sessionSettings.recognitionMode == mcrMode) { d->stopResultTimer(); - d->clearTraces(); +#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT + const InputEngine::InputMode inputMode = inputEngine()->inputMode(); + if (inputMode != InputEngine::ChineseHandwriting && + inputMode != InputEngine::JapaneseHandwriting && + inputMode != InputEngine::KoreanHandwriting) { + d->clearTraces(); + } +#endif } else if (d->sessionSettings.recognitionMode == scrMode) { d->select(); } } } -void T9WriteInputMethod::dictionaryLoadCompleted(const QString &fileUri, void *dictionary) +void T9WriteInputMethod::dictionaryLoadCompleted(QSharedPointer<T9WriteDictionary> dictionary) { Q_D(T9WriteInputMethod); // Note: This method is called in worker thread context QMutexLocker dictionaryGuard(&d->dictionaryLock); - VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethod::dictionaryLoadCompleted():" << fileUri << dictionary; - if (!dictionary) return; + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethod::dictionaryLoadCompleted():" + << dictionary->fileName() << dictionary->data() << dictionary->size(); + InputContext *ic = inputContext(); - if (ic && fileUri == d->dictionaryFileName) { - d->convertedDictionary = dictionary; + if (ic && dictionary->fileName() == d->dictionaryFileName) { + d->loadedDictionary = dictionary; if (d->sessionSettings.recognitionMode == mcrMode && !ic->inputMethodHints().testFlag(Qt::ImhNoPredictiveText) && !d->attachedDictionary) { - d->attachDictionary(d->convertedDictionary); - d->attachedDictionary = d->convertedDictionary; + if (d->attachDictionary(d->loadedDictionary)) + d->attachedDictionary = d->loadedDictionary; } - } else { - d->destroyConvertedDictionary(&dictionary); } } @@ -1315,4 +1999,10 @@ void T9WriteInputMethod::resultsAvailable(const QVariantList &resultList) d->resultsAvailable(resultList); } +void T9WriteInputMethod::recognitionError(int status) +{ + VIRTUALKEYBOARD_DEBUG() << "T9WriteInputMethod::recognitionError():" << status; + reset(); +} + } // namespace QtVirtualKeyboard diff --git a/src/virtualkeyboard/t9writeinputmethod.h b/src/virtualkeyboard/t9writeinputmethod.h index 9b87ebdf..173abd99 100644 --- a/src/virtualkeyboard/t9writeinputmethod.h +++ b/src/virtualkeyboard/t9writeinputmethod.h @@ -31,10 +31,12 @@ #define T9WRITEINPUTMETHOD_H #include "abstractinputmethod.h" +#include <QSharedPointer> namespace QtVirtualKeyboard { class T9WriteInputMethodPrivate; +class T9WriteDictionary; class T9WriteInputMethod : public AbstractInputMethod { @@ -70,8 +72,9 @@ protected: void timerEvent(QTimerEvent *timerEvent); protected slots: - void dictionaryLoadCompleted(const QString &fileUri, void *dictionary); + void dictionaryLoadCompleted(QSharedPointer<T9WriteDictionary> dictionary); void resultsAvailable(const QVariantList &resultList); + void recognitionError(int status); }; } diff --git a/src/virtualkeyboard/t9writeworker.cpp b/src/virtualkeyboard/t9writeworker.cpp index 2de62a0b..adbdcedb 100644 --- a/src/virtualkeyboard/t9writeworker.cpp +++ b/src/virtualkeyboard/t9writeworker.cpp @@ -58,10 +58,14 @@ void T9WriteTask::wait() \internal */ -T9WriteDictionaryTask::T9WriteDictionaryTask(const QString &fileUri, - const DECUMA_MEM_FUNCTIONS &memFuncs) : - fileUri(fileUri), - memFuncs(memFuncs) +T9WriteDictionaryTask::T9WriteDictionaryTask(QSharedPointer<T9WriteDictionary> dictionary, + const QString &dictionaryFileName, + bool convertDictionary, + const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo) : + dictionary(dictionary), + dictionaryFileName(dictionaryFileName), + convertDictionary(convertDictionary), + dictionaryInfo(dictionaryInfo) { } @@ -74,33 +78,19 @@ void T9WriteDictionaryTask::run() perf.start(); #endif - void *dictionary = 0; - - QFile dictionaryFile(fileUri); - if (dictionaryFile.open(QIODevice::ReadOnly)) { - uchar *dictionaryData = dictionaryFile.map(0, dictionaryFile.size(), QFile::NoOptions); - if (dictionaryData) { - - DECUMA_SRC_DICTIONARY_INFO dictionaryInfo; - memset(&dictionaryInfo, 0, sizeof(dictionaryInfo)); - dictionaryInfo.srcType = decumaXT9LDB; - DECUMA_UINT32 dictionarySize = 0; - DECUMA_STATUS status = decumaConvertDictionary(&dictionary, dictionaryData, dictionaryFile.size(), &dictionaryInfo, &dictionarySize, &memFuncs); - Q_UNUSED(status) - Q_ASSERT(status == decumaNoError); - dictionaryFile.unmap(dictionaryData); - } else { - qWarning() << "Could not map dictionary file" << fileUri; - } - } else { - qWarning() << "Could not open dictionary file" << fileUri; + bool result = false; + if (dictionary) { + result = dictionary->load(dictionaryFileName); + if (result && convertDictionary) + result = dictionary->convert(dictionaryInfo); } #ifdef QT_VIRTUALKEYBOARD_DEBUG VIRTUALKEYBOARD_DEBUG() << "T9WriteDictionaryTask::run(): time:" << perf.elapsed() << "ms"; #endif - emit completed(fileUri, dictionary); + if (result) + emit completed(dictionary); } /*! @@ -109,6 +99,7 @@ void T9WriteDictionaryTask::run() */ T9WriteRecognitionResult::T9WriteRecognitionResult(int id, int maxResults, int maxCharsPerWord) : + status(decumaNoError), numResults(0), instantGesture(0), id(id), @@ -176,16 +167,18 @@ void T9WriteRecognitionTask::run() perf.start(); #endif - DECUMA_STATUS status = decumaIndicateInstantGesture(decumaSession, &result->instantGesture, &instantGestureSettings); - Q_ASSERT(status == decumaNoError); + DECUMA_STATUS status; + if (!cjk) { + status = DECUMA_API(IndicateInstantGesture)(decumaSession, &result->instantGesture, &instantGestureSettings); + Q_ASSERT(status == decumaNoError); + } DECUMA_INTERRUPT_FUNCTIONS interruptFunctions; interruptFunctions.pShouldAbortRecognize = shouldAbortRecognize; interruptFunctions.pUserData = (void *)this; - status = decumaRecognize(decumaSession, result->results.data(), result->results.size(), &result->numResults, result->maxCharsPerWord, &recSettings, &interruptFunctions); - if (status == decumaAbortRecognitionUnsupported) - status = decumaRecognize(decumaSession, result->results.data(), result->results.size(), &result->numResults, result->maxCharsPerWord, &recSettings, NULL); - Q_ASSERT(status == decumaNoError); + result->status = DECUMA_API(Recognize)(decumaSession, result->results.data(), result->results.size(), &result->numResults, result->maxCharsPerWord, &recSettings, &interruptFunctions); + if (result->status == decumaAbortRecognitionUnsupported) + result->status = DECUMA_API(Recognize)(decumaSession, result->results.data(), result->results.size(), &result->numResults, result->maxCharsPerWord, &recSettings, NULL); QStringList resultList; QString gesture; @@ -261,6 +254,11 @@ void T9WriteRecognitionResultsTask::run() if (!result) return; + if (result->status != decumaNoError) { + emit recognitionError(result->status); + return; + } + QVariantList resultList; for (int i = 0; i < result->numResults; i++) { @@ -306,11 +304,12 @@ void T9WriteRecognitionResultsTask::run() \internal */ -T9WriteWorker::T9WriteWorker(DECUMA_SESSION *decumaSession, QObject *parent) : +T9WriteWorker::T9WriteWorker(DECUMA_SESSION *decumaSession, const bool cjk, QObject *parent) : QThread(parent), taskSema(), taskLock(), - decumaSession(decumaSession) + decumaSession(decumaSession), + cjk(cjk) { abort = false; } @@ -369,6 +368,7 @@ void T9WriteWorker::run() } if (currentTask) { currentTask->decumaSession = decumaSession; + currentTask->cjk = cjk; currentTask->run(); currentTask->runSema.release(); } diff --git a/src/virtualkeyboard/t9writeworker.h b/src/virtualkeyboard/t9writeworker.h index 0f130acb..437a84f5 100644 --- a/src/virtualkeyboard/t9writeworker.h +++ b/src/virtualkeyboard/t9writeworker.h @@ -41,7 +41,8 @@ #include <QMap> #include <QVector> -#include "decuma_hwr.h" +#include "t9write.h" +#include "t9writedictionary.h" namespace QtVirtualKeyboard { @@ -59,6 +60,7 @@ public: protected: DECUMA_SESSION *decumaSession; + bool cjk; private: QSemaphore runSema; @@ -68,16 +70,20 @@ class T9WriteDictionaryTask : public T9WriteTask { Q_OBJECT public: - explicit T9WriteDictionaryTask(const QString &fileUri, - const DECUMA_MEM_FUNCTIONS &memFuncs); + explicit T9WriteDictionaryTask(QSharedPointer<T9WriteDictionary> dictionary, + const QString &dictionaryFileName, + bool convertDictionary, + const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo); void run(); - const QString fileUri; - const DECUMA_MEM_FUNCTIONS &memFuncs; + QSharedPointer<T9WriteDictionary> dictionary; + const QString dictionaryFileName; + bool convertDictionary; + const DECUMA_SRC_DICTIONARY_INFO dictionaryInfo; signals: - void completed(const QString &fileUri, void *dictionary); + void completed(QSharedPointer<T9WriteDictionary> dictionary); }; class T9WriteRecognitionResult @@ -87,12 +93,14 @@ class T9WriteRecognitionResult public: explicit T9WriteRecognitionResult(int id, int maxResults, int maxCharsPerWord); + DECUMA_STATUS status; QVector<DECUMA_HWR_RESULT> results; DECUMA_UINT16 numResults; int instantGesture; const int id; const int maxResults; const int maxCharsPerWord; + private: QVector<DECUMA_UNICODE> _chars; QVector<DECUMA_INT16> _symbolChars; @@ -135,6 +143,7 @@ public: signals: void resultsAvailable(const QVariantList &resultList); + void recognitionError(int status); private: QSharedPointer<T9WriteRecognitionResult> result; @@ -144,7 +153,7 @@ class T9WriteWorker : public QThread { Q_OBJECT public: - explicit T9WriteWorker(DECUMA_SESSION *decumaSession, QObject *parent = 0); + explicit T9WriteWorker(DECUMA_SESSION *decumaSession, const bool cjk, QObject *parent = 0); ~T9WriteWorker(); void addTask(QSharedPointer<T9WriteTask> task); @@ -176,6 +185,7 @@ private: QMutex taskLock; DECUMA_SESSION *decumaSession; QBasicAtomicInt abort; + const bool cjk; }; } // namespace QtVirtualKeyboard diff --git a/src/virtualkeyboard/unipentrace.cpp b/src/virtualkeyboard/unipentrace.cpp new file mode 100644 index 00000000..74c1b23e --- /dev/null +++ b/src/virtualkeyboard/unipentrace.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "unipentrace.h" +#include <QRectF> +#include <QDir> +#include <QFile> +#include <QDebug> + +namespace QtVirtualKeyboard { + +UnipenTrace::UnipenTrace(const QVariantMap &traceCaptureDeviceInfo, + const QVariantMap &traceScreenInfo, + QObject *parent) : + QObject(parent) +{ + m_lines.append(QLatin1String(".VERSION 1.0")); + m_lines.append(QLatin1String(".HIERARCHY CHARACTER")); + m_lines.append(QLatin1String(".COORD X Y T")); + m_lines.append(QLatin1String(".SEGMENT CHARACTER")); + const QRectF boundingBox = traceScreenInfo["boundingBox"].toRectF(); + if (!boundingBox.isEmpty()) { + m_lines.append(QStringLiteral(".X_DIM %1").arg(qRound(boundingBox.right()))); + m_lines.append(QStringLiteral(".Y_DIM %1").arg(qRound(boundingBox.bottom()))); + } + bool ok = false; + int dpi = traceCaptureDeviceInfo["dpi"].toInt(&ok); + if (ok) { + m_lines.append(QStringLiteral(".X_POINTS_PER_INCH %1").arg(dpi)); + m_lines.append(QStringLiteral(".Y_POINTS_PER_INCH %1").arg(dpi)); + } + ok = false; + int sampleRate = traceCaptureDeviceInfo["sampleRate"].toInt(&ok); + if (ok) + m_lines.append(QStringLiteral(".POINTS_PER_SECOND %1").arg(sampleRate)); +} + +void UnipenTrace::record(const QList<Trace *> &traceList) +{ + qlonglong t0 = 0; + for (const Trace *trace : qAsConst(traceList)) { + const QVariantList &points = trace->points(); + const bool hasTime = trace->channels().contains("t"); + const QVariantList timeData = hasTime ? trace->channelData("t") : QVariantList(); + QVariantList::ConstIterator t = timeData.constBegin(); + if (t0 == 0 && hasTime) + t0 = t->toLongLong(); + + m_lines.append(QLatin1String(".PEN_DOWN")); + + for (const QVariant &point : points) { + const QPointF pt(point.toPointF()); + QString pointStr(QStringLiteral("%1 %2 ").arg(qRound(pt.x())).arg(qRound(pt.y()))); + if (hasTime) { + pointStr.append(QString::number(t->toLongLong() - t0)); + t++; + } else { + pointStr.append(QLatin1String("0")); + } + m_lines.append(pointStr); + } + + m_lines.append(QLatin1String(".PEN_UP")); + } +} + +void UnipenTrace::save(uint unicode, uint confidence) +{ + if (m_directory.isEmpty()) + return; + + QString fileName; + QDir fileDir(m_directory); + if (!fileDir.exists()) + fileDir.mkpath(m_directory); + if (fileDir.exists()) { + int fileIndex = 0; + do { + fileName = fileDir.absoluteFilePath(QStringLiteral("%1_%2_%3.txt").arg(unicode).arg(confidence, 3, 10, QLatin1Char('0')).arg(fileIndex++)); + } while (QFileInfo::exists(fileName)); + } + + QString dataStr(m_lines.join('\n')); + dataStr.append('\n'); + QFile file(fileName); + if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) { + file.write(dataStr.toUtf8().constData()); + } else { + qWarning() << "Cannot open file for writing" << fileName; + } +} + +QString UnipenTrace::directory() const +{ + return m_directory; +} + +void UnipenTrace::setDirectory(const QString &directory) +{ + m_directory = directory; +} + +} diff --git a/src/virtualkeyboard/unipentrace.h b/src/virtualkeyboard/unipentrace.h new file mode 100644 index 00000000..f7e182dd --- /dev/null +++ b/src/virtualkeyboard/unipentrace.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef UNIPENTRACE_H +#define UNIPENTRACE_H + +#include <QObject> +#include "trace.h" + +namespace QtVirtualKeyboard { + +class UnipenTrace : public QObject +{ + Q_OBJECT +public: + explicit UnipenTrace(const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo, QObject *parent = 0); + + void record(const QList<Trace *> &traceList); + void save(uint unicode, uint confidence); + + QString directory() const; + void setDirectory(const QString &directory); + +private: + QStringList m_lines; + QString m_directory; +}; + +} // namespace QtVirtualKeyboard + +#endif // UNIPENTRACE_H diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro index ca84cd27..2b2f2aac 100644 --- a/src/virtualkeyboard/virtualkeyboard.pro +++ b/src/virtualkeyboard/virtualkeyboard.pro @@ -34,7 +34,9 @@ SOURCES += platforminputcontext.cpp \ virtualkeyboardsettings.cpp \ trace.cpp \ desktopinputselectioncontrol.cpp \ - shadowinputcontext.cpp + shadowinputcontext.cpp \ + gesturerecognizer.cpp \ + handwritinggesturerecognizer.cpp HEADERS += platforminputcontext.h \ inputcontext.h \ @@ -55,21 +57,26 @@ HEADERS += platforminputcontext.h \ plugin.h \ trace.h \ desktopinputselectioncontrol.h \ - shadowinputcontext.h + shadowinputcontext.h \ + gesturerecognizer.h \ + handwritinggesturerecognizer.h RESOURCES += \ content/styles/default/default_style.qrc \ content/styles/retro/retro_style.qrc \ content/content.qrc +# Fallback for languages which don't have these special layouts +LAYOUT_FILES += \ + content/layouts/en_GB/dialpad.qml \ + content/layouts/en_GB/digits.qml \ + content/layouts/en_GB/numbers.qml contains(CONFIG, lang-en.*) { LAYOUT_FILES += \ content/layouts/en_GB/main.qml \ - content/layouts/en_GB/dialpad.qml \ - content/layouts/en_GB/digits.qml \ - content/layouts/en_GB/handwriting.qml \ - content/layouts/en_GB/numbers.qml \ content/layouts/en_GB/symbols.qml +t9write-alphabetic|lipi-toolkit: LAYOUT_FILES += \ + content/layouts/en_GB/handwriting.qml } contains(CONFIG, lang-ar.*) { LAYOUT_FILES += \ @@ -77,122 +84,197 @@ contains(CONFIG, lang-ar.*) { content/layouts/ar_AR/main.qml \ content/layouts/ar_AR/numbers.qml \ content/layouts/ar_AR/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/ar_AR/handwriting.qml +} +contains(CONFIG, lang-bg.*) { + LAYOUT_FILES += \ + content/layouts/bg_BG/main.qml \ + content/layouts/bg_BG/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/bg_BG/handwriting.qml +} +contains(CONFIG, lang-cs.*) { + LAYOUT_FILES += \ + content/layouts/cs_CZ/main.qml \ + content/layouts/cs_CZ/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/cs_CZ/handwriting.qml } contains(CONFIG, lang-da.*) { LAYOUT_FILES += \ content/layouts/da_DK/main.qml \ content/layouts/da_DK/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/da_DK/handwriting.qml } contains(CONFIG, lang-de.*) { LAYOUT_FILES += \ content/layouts/de_DE/main.qml \ content/layouts/de_DE/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/de_DE/handwriting.qml } +contains(CONFIG, lang-el.*) { + LAYOUT_FILES += \ + content/layouts/el_GR/main.qml \ + content/layouts/el_GR/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/el_GR/handwriting.qml +} contains(CONFIG, lang-es.*) { LAYOUT_FILES += \ content/layouts/es_ES/main.qml \ content/layouts/es_ES/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/es_ES/handwriting.qml } +contains(CONFIG, lang-et.*) { + LAYOUT_FILES += \ + content/layouts/et_EE/main.qml \ + content/layouts/et_EE/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/et_EE/handwriting.qml +} contains(CONFIG, lang-fa.*) { LAYOUT_FILES += \ content/layouts/fa_FA/digits.qml \ 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 += \ content/layouts/fi_FI/main.qml \ content/layouts/fi_FI/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/fi_FI/handwriting.qml } contains(CONFIG, lang-fr.*) { LAYOUT_FILES += \ content/layouts/fr_FR/main.qml \ content/layouts/fr_FR/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/fr_FR/handwriting.qml } +contains(CONFIG, lang-he.*) { + LAYOUT_FILES += \ + content/layouts/he_IL/main.qml \ + content/layouts/he_IL/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/he_IL/handwriting.qml +} contains(CONFIG, lang-hi.*) { LAYOUT_FILES += \ content/layouts/hi_IN/main.qml \ content/layouts/hi_IN/symbols.qml } +contains(CONFIG, lang-hr.*) { + LAYOUT_FILES += \ + content/layouts/hr_HR/main.qml \ + content/layouts/hr_HR/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/hr_HR/handwriting.qml +} +contains(CONFIG, lang-hu.*) { + LAYOUT_FILES += \ + content/layouts/hu_HU/main.qml \ + content/layouts/hu_HU/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/hu_HU/handwriting.qml +} contains(CONFIG, lang-it.*) { LAYOUT_FILES += \ content/layouts/it_IT/main.qml \ content/layouts/it_IT/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/it_IT/handwriting.qml } 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 += \ 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 += \ content/layouts/nb_NO/main.qml \ content/layouts/nb_NO/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/nb_NO/handwriting.qml } +contains(CONFIG, lang-nl.*) { + LAYOUT_FILES += \ + content/layouts/nl_NL/main.qml \ + content/layouts/nl_NL/symbols.qml +t9write-alphabetic|lipi-toolkit: LAYOUT_FILES += \ + content/layouts/nl_NL/handwriting.qml +} contains(CONFIG, lang-pl.*) { LAYOUT_FILES += \ content/layouts/pl_PL/main.qml \ content/layouts/pl_PL/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/pl_PL/handwriting.qml } contains(CONFIG, lang-pt.*) { LAYOUT_FILES += \ content/layouts/pt_PT/main.qml \ content/layouts/pt_PT/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/pt_PT/handwriting.qml } contains(CONFIG, lang-ro.*) { LAYOUT_FILES += \ content/layouts/ro_RO/main.qml \ content/layouts/ro_RO/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/ro_RO/handwriting.qml } contains(CONFIG, lang-ru.*) { LAYOUT_FILES += \ content/layouts/ru_RU/main.qml \ content/layouts/ru_RU/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/ru_RU/handwriting.qml } +contains(CONFIG, lang-sr.*) { + LAYOUT_FILES += \ + content/layouts/sr_SP/main.qml \ + content/layouts/sr_SP/symbols.qml +t9write-alphabetic: LAYOUT_FILES += \ + content/layouts/sr_SP/handwriting.qml +} contains(CONFIG, lang-sv.*) { LAYOUT_FILES += \ content/layouts/sv_SE/main.qml \ content/layouts/sv_SE/symbols.qml -t9write: LAYOUT_FILES += \ +t9write-alphabetic: LAYOUT_FILES += \ content/layouts/sv_SE/handwriting.qml } contains(CONFIG, lang-zh(_CN)?) { LAYOUT_FILES += \ content/layouts/zh_CN/main.qml \ content/layouts/zh_CN/symbols.qml +t9write-cjk: LAYOUT_FILES += \ + content/layouts/zh_CN/handwriting.qml } contains(CONFIG, lang-zh(_TW)?) { LAYOUT_FILES += \ content/layouts/zh_TW/main.qml \ content/layouts/zh_TW/symbols.qml +t9write-cjk: LAYOUT_FILES += \ + content/layouts/zh_TW/handwriting.qml } retro-style { @@ -325,7 +407,6 @@ lipi-toolkit { -lltkutil$$qtPlatformTargetSuffix() win32: LIBS += Advapi32.lib else: QMAKE_USE += libdl - record-trace-input: DEFINES += QT_VIRTUALKEYBOARD_LIPI_RECORD_TRACE_INPUT ltk_projects.files = $$PWD/3rdparty/lipi-toolkit/projects ltk_projects.path = $$[QT_INSTALL_DATA]/qtvirtualkeyboard/lipi_toolkit INSTALLS += ltk_projects @@ -335,18 +416,47 @@ lipi-toolkit { t9write { include(3rdparty/t9write/t9write-build.pri) equals(T9WRITE_FOUND, 0): \ - error("T9Write SDK could not be found. Please make sure you have extracted" \ - "the contents of the T9Write SDK to $$PWD/3rdparty/t9write") + error("T9Write SDK could not be found. For more information, see" \ + "the documentation in Building Qt Virtual Keyboard") SOURCES += \ t9writeinputmethod.cpp \ - t9writeworker.cpp + t9writeworker.cpp \ + t9writedictionary.cpp HEADERS += \ t9writeinputmethod.h \ - t9writeworker.h + t9writeworker.h \ + t9writedictionary.h \ + t9write.h DEFINES += HAVE_T9WRITE QMAKE_USE += t9write_db INCLUDEPATH += $$T9WRITE_INCLUDE_DIRS - LIBS += $$T9WRITE_ALPHABETIC_LIBS + t9write-alphabetic { + LIBS += $$T9WRITE_ALPHABETIC_LIBS + DEFINES += HAVE_T9WRITE_ALPHABETIC + !isEmpty(T9WRITE_ALPHABETIC_BINS) { + t9write_alphabetic_bins.files = $$T9WRITE_ALPHABETIC_BINS + t9write_alphabetic_bins.path = $$[QT_INSTALL_BINS] + INSTALLS += t9write_alphabetic_bins + !prefix_build: COPIES += t9write_alphabetic_bins + } + } + t9write-cjk { + LIBS += $$T9WRITE_CJK_LIBS + DEFINES += HAVE_T9WRITE_CJK + !isEmpty(T9WRITE_CJK_BINS) { + t9write_cjk_bins.files = $$T9WRITE_CJK_BINS + t9write_cjk_bins.path = $$[QT_INSTALL_BINS] + INSTALLS += t9write_cjk_bins + !prefix_build: COPIES += t9write_cjk_bins + } + } + DEFINES += QT_VIRTUALKEYBOARD_DEBUG +} + +record-trace-input { + SOURCES += unipentrace.cpp + HEADERS += unipentrace.h + DEFINES += QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT } arrow-key-navigation: DEFINES += QT_VIRTUALKEYBOARD_ARROW_KEY_NAVIGATION |