aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/t9write
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/t9write')
-rw-r--r--src/plugins/t9write/3rdparty/t9write/CMakeLists.txt70
-rw-r--r--src/plugins/t9write/3rdparty/t9write/t9write-build.pri83
-rw-r--r--src/plugins/t9write/3rdparty/t9write/t9write.pro27
-rw-r--r--src/plugins/t9write/3rdparty/t9write/unpack.py278
-rw-r--r--src/plugins/t9write/CMakeLists.txt4
-rw-r--r--src/plugins/t9write/plugin/CMakeLists.txt264
-rw-r--r--src/plugins/t9write/plugin/plugin.pro118
-rw-r--r--src/plugins/t9write/plugin/t9write.json6
-rw-r--r--src/plugins/t9write/plugin/t9write_p.h63
-rw-r--r--src/plugins/t9write/plugin/t9writedictionary.cpp121
-rw-r--r--src/plugins/t9write/plugin/t9writedictionary_p.h80
-rw-r--r--src/plugins/t9write/plugin/t9writeinputmethod.cpp2177
-rw-r--r--src/plugins/t9write/plugin/t9writeinputmethod_p.h117
-rw-r--r--src/plugins/t9write/plugin/t9writeplugin.cpp44
-rw-r--r--src/plugins/t9write/plugin/t9writeplugin.h49
-rw-r--r--src/plugins/t9write/plugin/t9writeworker.cpp406
-rw-r--r--src/plugins/t9write/plugin/t9writeworker_p.h221
-rw-r--r--src/plugins/t9write/t9write.pro7
18 files changed, 0 insertions, 4135 deletions
diff --git a/src/plugins/t9write/3rdparty/t9write/CMakeLists.txt b/src/plugins/t9write/3rdparty/t9write/CMakeLists.txt
deleted file mode 100644
index 8f3baf69..00000000
--- a/src/plugins/t9write/3rdparty/t9write/CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-# Generated from t9write.pro.
-
-#####################################################################
-## BundledT9Write_Db Generic Library:
-#####################################################################
-
-qt_add_3rdparty_library(BundledT9Write_Db
- STATIC
- SOURCES
- api/*
- PUBLIC_LIBRARIES
- Qt::Core
-)
-
-file(GLOB resource_glob_0 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/arabic/*.bin")
-foreach(file IN LISTS resource_glob_0)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_1 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/hebrew/*.bin")
-foreach(file IN LISTS resource_glob_1)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_2 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/thai/*.bin")
-foreach(file IN LISTS resource_glob_2)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_3 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/*.bin")
-foreach(file IN LISTS resource_glob_3)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_4 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/*.ldb")
-foreach(file IN LISTS resource_glob_4)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_5 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/*.hdb")
-foreach(file IN LISTS resource_glob_5)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-file(GLOB resource_glob_6 RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "data/*.phd")
-foreach(file IN LISTS resource_glob_6)
- set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${file}" PROPERTIES QT_RESOURCE_ALIAS "${file}")
-endforeach()
-
-# Resources:
-set(qmake_t9write_db_resource_files
- ${resource_glob_0}
- ${resource_glob_1}
- ${resource_glob_2}
- ${resource_glob_3}
- ${resource_glob_4}
- ${resource_glob_5}
- ${resource_glob_6}
-)
-
-qt_add_resource(BundledT9Write_Db "qmake_t9write_db"
- PREFIX
- "/QtQuick/VirtualKeyboard/T9Write"
- FILES
- ${qmake_t9write_db_resource_files}
-)
-
-
-#### Keys ignored in scope 1:.:.:t9write.pro:<TRUE>:
-# QMAKE_RESOURCE_FLAGS = "-no-compress"
diff --git a/src/plugins/t9write/3rdparty/t9write/t9write-build.pri b/src/plugins/t9write/3rdparty/t9write/t9write-build.pri
deleted file mode 100644
index a39291fa..00000000
--- a/src/plugins/t9write/3rdparty/t9write/t9write-build.pri
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# Automatically detects the T9Write build directory and sets the following variables:
-#
-# 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_SHARED_DIR = lib/arm/shared
- T9WRITE_BUILD_STATIC_DIR = lib/arm/static
-} else:linux {
- T9WRITE_BUILD_SHARED_DIR = lib/linux/shared
- T9WRITE_BUILD_STATIC_DIR = lib/linux/static
-} else:win32 {
- T9WRITE_BUILD_SHARED_DIR = lib/win32/shared
- T9WRITE_BUILD_STATIC_DIR = lib/win32/static
-}
-
-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/plugins/t9write/3rdparty/t9write/t9write.pro b/src/plugins/t9write/3rdparty/t9write/t9write.pro
deleted file mode 100644
index c7f0a86b..00000000
--- a/src/plugins/t9write/3rdparty/t9write/t9write.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TARGET = qtt9write_db
-CONFIG += static
-
-HEADERS += $$files(api/*)
-
-T9WRITE_RESOURCE_FILES = \
- $$files(data/arabic/*.bin) \
- $$files(data/hebrew/*.bin) \
- $$files(data/thai/*.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
-
-t9write_db.files = $$T9WRITE_RESOURCE_FILES
-t9write_db.prefix =/QtQuick/VirtualKeyboard/T9Write
-RESOURCES += t9write_db
-
-load(qt_helper_lib)
-
-# Needed for resources
-CONFIG += qt
-QT = core
diff --git a/src/plugins/t9write/3rdparty/t9write/unpack.py b/src/plugins/t9write/3rdparty/t9write/unpack.py
deleted file mode 100644
index 4fc1f4dc..00000000
--- a/src/plugins/t9write/3rdparty/t9write/unpack.py
+++ /dev/null
@@ -1,278 +0,0 @@
-#!/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',
- '*/decumaPlusFunctionalSupport.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/thai': [
- '*/*Thai*/*_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/plugins/t9write/CMakeLists.txt b/src/plugins/t9write/CMakeLists.txt
deleted file mode 100644
index f136b3f3..00000000
--- a/src/plugins/t9write/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from t9write.pro.
-
-add_subdirectory(3rdparty/t9write)
-add_subdirectory(plugin)
diff --git a/src/plugins/t9write/plugin/CMakeLists.txt b/src/plugins/t9write/plugin/CMakeLists.txt
deleted file mode 100644
index 31e806ad..00000000
--- a/src/plugins/t9write/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,264 +0,0 @@
-# Generated from plugin.pro.
-
-#####################################################################
-## QtVirtualKeyboardT9WritePlugin Plugin:
-#####################################################################
-
-qt_internal_add_plugin(QtVirtualKeyboardT9WritePlugin
- OUTPUT_NAME qtvirtualkeyboard_t9write
- TYPE virtualkeyboard
- SOURCES
- t9write_p.h
- t9writedictionary.cpp t9writedictionary_p.h
- t9writeinputmethod.cpp t9writeinputmethod_p.h
- t9writeplugin.cpp t9writeplugin.h
- t9writeworker.cpp t9writeworker_p.h
- DEFINES
- HAVE_T9WRITE
- QT_ASCII_CAST_WARNINGS
- QT_NO_CAST_FROM_ASCII
- QT_NO_CAST_FROM_BYTEARRAY
- QT_NO_CAST_TO_ASCII
- INCLUDE_DIRECTORIES
- api
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::Gui
- Qt::Qml
- Qt::VirtualKeyboardPrivate
- t9write_db
-)
-
-# Resources:
-set(qmake_virtualkeyboard_t9write_layouts_resource_files
- "virtualkeyboard/content/layouts/fallback/handwriting.qml"
-)
-
-qt_add_resource(QtVirtualKeyboardT9WritePlugin "qmake_virtualkeyboard_t9write_layouts"
- PREFIX
- "$$LAYOUTS_PREFIX"
- BASE
- "$$LAYOUTS_BASE"
- FILES
- ${qmake_virtualkeyboard_t9write_layouts_resource_files}
-)
-
-
-#### Keys ignored in scope 1:.:.:plugin.pro:<TRUE>:
-# OTHER_FILES = "t9write.json" "$$LAYOUT_FILES"
-
-## Scopes:
-#####################################################################
-
-qt_extend_target(QtVirtualKeyboardT9WritePlugin CONDITION QT_FEATURE_t9write_alphabetic
- DEFINES
- HAVE_T9WRITE_ALPHABETIC
-)
-
-#### Keys ignored in scope 4:.:.:plugin.pro:QT_FEATURE_vkb_lang_en_GB:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/en_GB/handwriting.fallback"
-
-#### Keys ignored in scope 5:.:.:plugin.pro:QT_FEATURE_vkb_lang_en_US:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/en_US/handwriting.fallback"
-
-#### Keys ignored in scope 6:.:.:plugin.pro:QT_FEATURE_vkb_lang_ar_AR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ar_AR/handwriting.qml"
-
-#### Keys ignored in scope 7:.:.:plugin.pro:QT_FEATURE_vkb_lang_bg_BG:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/bg_BG/handwriting.qml"
-
-#### Keys ignored in scope 8:.:.:plugin.pro:QT_FEATURE_vkb_lang_cs_CZ:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/cs_CZ/handwriting.qml"
-
-#### Keys ignored in scope 9:.:.:plugin.pro:QT_FEATURE_vkb_lang_da_DK:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/da_DK/handwriting.fallback"
-
-#### Keys ignored in scope 10:.:.:plugin.pro:QT_FEATURE_vkb_lang_de_DE:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/de_DE/handwriting.fallback"
-
-#### Keys ignored in scope 11:.:.:plugin.pro:QT_FEATURE_vkb_lang_el_GR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/el_GR/handwriting.qml"
-
-#### Keys ignored in scope 12:.:.:plugin.pro:QT_FEATURE_vkb_lang_es_ES:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/es_ES/handwriting.qml"
-
-#### Keys ignored in scope 13:.:.:plugin.pro:QT_FEATURE_vkb_lang_es_MX:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/es_MX/handwriting.qml"
-
-#### Keys ignored in scope 14:.:.:plugin.pro:QT_FEATURE_vkb_lang_et_EE:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/et_EE/handwriting.fallback"
-
-#### Keys ignored in scope 15:.:.:plugin.pro:QT_FEATURE_vkb_lang_fa_FA:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/fa_FA/handwriting.qml"
-
-#### Keys ignored in scope 16:.:.:plugin.pro:QT_FEATURE_vkb_lang_fi_FI:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/fi_FI/handwriting.fallback"
-
-#### Keys ignored in scope 17:.:.:plugin.pro:QT_FEATURE_vkb_lang_fr_FR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/fr_FR/handwriting.fallback"
-
-#### Keys ignored in scope 18:.:.:plugin.pro:QT_FEATURE_vkb_lang_fr_CA:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/fr_CA/handwriting.fallback"
-
-#### Keys ignored in scope 19:.:.:plugin.pro:QT_FEATURE_vkb_lang_he_IL:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/he_IL/handwriting.qml"
-
-#### Keys ignored in scope 20:.:.:plugin.pro:QT_FEATURE_vkb_lang_hr_HR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/hr_HR/handwriting.qml"
-
-#### Keys ignored in scope 21:.:.:plugin.pro:QT_FEATURE_vkb_lang_hu_HU:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/hu_HU/handwriting.qml"
-
-#### Keys ignored in scope 22:.:.:plugin.pro:QT_FEATURE_vkb_lang_id_ID:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/id_ID/handwriting.fallback"
-
-#### Keys ignored in scope 23:.:.:plugin.pro:QT_FEATURE_vkb_lang_it_IT:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/it_IT/handwriting.fallback"
-
-#### Keys ignored in scope 24:.:.:plugin.pro:QT_FEATURE_vkb_lang_ms_MY:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ms_MY/handwriting.fallback"
-
-#### Keys ignored in scope 25:.:.:plugin.pro:QT_FEATURE_vkb_lang_nb_NO:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/nb_NO/handwriting.fallback"
-
-#### Keys ignored in scope 26:.:.:plugin.pro:QT_FEATURE_vkb_lang_nl_NL:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/nl_NL/handwriting.fallback"
-
-#### Keys ignored in scope 27:.:.:plugin.pro:QT_FEATURE_vkb_lang_pl_PL:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/pl_PL/handwriting.fallback"
-
-#### Keys ignored in scope 28:.:.:plugin.pro:QT_FEATURE_vkb_lang_pt_BR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/pt_BR/handwriting.fallback"
-
-#### Keys ignored in scope 29:.:.:plugin.pro:QT_FEATURE_vkb_lang_pt_PT:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/pt_PT/handwriting.fallback"
-
-#### Keys ignored in scope 30:.:.:plugin.pro:QT_FEATURE_vkb_lang_ro_RO:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ro_RO/handwriting.qml"
-
-#### Keys ignored in scope 31:.:.:plugin.pro:QT_FEATURE_vkb_lang_ru_RU:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ru_RU/handwriting.fallback"
-
-#### Keys ignored in scope 32:.:.:plugin.pro:QT_FEATURE_vkb_lang_sk_SK:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/sk_SK/handwriting.fallback"
-
-#### Keys ignored in scope 33:.:.:plugin.pro:QT_FEATURE_vkb_lang_sl_SI:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/sl_SI/handwriting.fallback"
-
-#### Keys ignored in scope 34:.:.:plugin.pro:QT_FEATURE_vkb_lang_sq_AL:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/sq_AL/handwriting.fallback"
-
-#### Keys ignored in scope 35:.:.:plugin.pro:QT_FEATURE_vkb_lang_sr_SP:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/sr_SP/handwriting.qml"
-
-#### Keys ignored in scope 36:.:.:plugin.pro:QT_FEATURE_vkb_lang_sv_SE:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/sv_SE/handwriting.fallback"
-
-#### Keys ignored in scope 37:.:.:plugin.pro:QT_FEATURE_vkb_lang_th_TH:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/th_TH/handwriting.qml"
-
-#### Keys ignored in scope 38:.:.:plugin.pro:QT_FEATURE_vkb_lang_tr_TR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/tr_TR/handwriting.fallback"
-
-#### Keys ignored in scope 39:.:.:plugin.pro:QT_FEATURE_vkb_lang_uk_UA:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/uk_UA/handwriting.fallback"
-
-#### Keys ignored in scope 40:.:.:plugin.pro:QT_FEATURE_vkb_lang_vi_VN:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/vi_VN/handwriting.fallback"
-
-qt_extend_target(QtVirtualKeyboardT9WritePlugin CONDITION QT_FEATURE_t9write_cjk
- DEFINES
- HAVE_T9WRITE_CJK
-)
-
-#### Keys ignored in scope 42:.:.:plugin.pro:QT_FEATURE_vkb_lang_ja_JP:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ja_JP/handwriting.qml"
-
-#### Keys ignored in scope 43:.:.:plugin.pro:QT_FEATURE_vkb_lang_ko_KR:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/ko_KR/handwriting.qml"
-
-#### Keys ignored in scope 44:.:.:plugin.pro:QT_FEATURE_vkb_lang_zh_CN:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/zh_CN/handwriting.qml"
-
-#### Keys ignored in scope 45:.:.:plugin.pro:QT_FEATURE_vkb_lang_zh_TW:
-# LAYOUT_FILES = "$$LAYOUTS_BASE/content/layouts/zh_TW/handwriting.qml"
-
-#### Keys ignored in scope 47:.:.:plugin.pro:NOT T9WRITE_ALPHABETIC_BINS_ISEMPTY:
-# INSTALLS = "t9write_alphabetic_bins"
-# t9write_alphabetic_bins.files = "$$T9WRITE_ALPHABETIC_BINS"
-# t9write_alphabetic_bins.path = "$$[QT_INSTALL_BINS]"
-
-#### Keys ignored in scope 48:.:.:plugin.pro:NOT prefix_build:
-# COPIES = "t9write_alphabetic_bins"
-
-#### Keys ignored in scope 50:.:.:plugin.pro:NOT T9WRITE_CJK_BINS_ISEMPTY:
-# INSTALLS = "t9write_cjk_bins"
-# t9write_cjk_bins.files = "$$T9WRITE_CJK_BINS"
-# t9write_cjk_bins.path = "$$[QT_INSTALL_BINS]"
-
-#### Keys ignored in scope 51:.:.:plugin.pro:NOT prefix_build:
-# COPIES = "t9write_cjk_bins"
-
-#### Keys ignored in scope 52:.:.:plugin.pro:WIN32:
-# QMAKE_TARGET_DESCRIPTION = "Virtual Keyboard Extension for Qt."
-# QMAKE_TARGET_PRODUCT = "Qt Virtual Keyboard T9 Write (Qt $$QT_VERSION)"
-
-#### Keys ignored in scope 55:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:QT_ARCH___contains___arm:
-# T9WRITE_BUILD_SHARED_DIR = "lib/arm/shared"
-# T9WRITE_BUILD_STATIC_DIR = "lib/arm/static"
-
-#### Keys ignored in scope 57:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:LINUX:
-# T9WRITE_BUILD_SHARED_DIR = "lib/linux/shared"
-# T9WRITE_BUILD_STATIC_DIR = "lib/linux/static"
-
-#### Keys ignored in scope 59:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:WIN32:
-# T9WRITE_BUILD_SHARED_DIR = "lib/win32/shared"
-# T9WRITE_BUILD_STATIC_DIR = "lib/win32/static"
-
-#### Keys ignored in scope 61:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:WIN32:
-# result = "$$1/*.obj"
-
-#### Keys ignored in scope 62:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:result_ISEMPTY:
-# result = "$$1/*.lib"
-
-#### Keys ignored in scope 63:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:else:
-# result = "$$1/*.o"
-
-#### Keys ignored in scope 64:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:result_ISEMPTY:
-# result = "$$1/*.a"
-
-#### Keys ignored in scope 66:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:WIN32:
-# result = "$$1/*.lib"
-
-#### Keys ignored in scope 67:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:else:
-# result = "$$1/*.so"
-
-#### Keys ignored in scope 69:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:WIN32:
-# result = "$$1/*.dll"
-
-#### Keys ignored in scope 70:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:else:
-# result = "$$1/*.so"
-
-#### Keys ignored in scope 72:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:(T9WRITE_ALPHABETIC_FOUND EQUAL 1):
-# T9WRITE_ALPHABETIC_LIBS = "$$findSharedLibrary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/alphabetic)"
-
-#### Keys ignored in scope 73:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:NOT T9WRITE_ALPHABETIC_LIBS_ISEMPTY:
-# T9WRITE_ALPHABETIC_BINS = "$$findSharedBinary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/alphabetic)"
-
-#### Keys ignored in scope 74:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:else:
-# T9WRITE_ALPHABETIC_LIBS = "$$findStaticLibrary($$PWD/$$T9WRITE_BUILD_STATIC_DIR/alphabetic)"
-
-#### Keys ignored in scope 75:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:(T9WRITE_CJK_FOUND EQUAL 1):
-# T9WRITE_CJK_LIBS = "$$findSharedLibrary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/cjk)"
-
-#### Keys ignored in scope 76:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:NOT T9WRITE_CJK_LIBS_ISEMPTY:
-# T9WRITE_CJK_BINS = "$$findSharedBinary($$PWD/$$T9WRITE_BUILD_SHARED_DIR/cjk)"
-
-#### Keys ignored in scope 77:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:else:
-# T9WRITE_CJK_LIBS = "$$findStaticLibrary($$PWD/$$T9WRITE_BUILD_STATIC_DIR/cjk)"
-
-#### Keys ignored in scope 78:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:(T9WRITE_ALPHABETIC_FOUND EQUAL 1) AND NOT T9WRITE_ALPHABETIC_LIBS_ISEMPTY:
-# T9WRITE_FOUND = "1"
-
-#### Keys ignored in scope 79:.:../3rdparty/t9write:../3rdparty/t9write/t9write-build.pri:(T9WRITE_CJK_FOUND EQUAL 1) AND NOT T9WRITE_CJK_LIBS_ISEMPTY:
-# T9WRITE_FOUND = "1"
diff --git a/src/plugins/t9write/plugin/plugin.pro b/src/plugins/t9write/plugin/plugin.pro
deleted file mode 100644
index 98156373..00000000
--- a/src/plugins/t9write/plugin/plugin.pro
+++ /dev/null
@@ -1,118 +0,0 @@
-TARGET = qtvirtualkeyboard_t9write
-QT += qml virtualkeyboard-private
-
-include(../../../shared.pri)
-
-HEADERS += \
- t9write_p.h \
- t9writedictionary_p.h \
- t9writeinputmethod_p.h \
- t9writeplugin.h \
- t9writeworker_p.h
-SOURCES += \
- t9writedictionary.cpp \
- t9writeinputmethod.cpp \
- t9writeplugin.cpp \
- t9writeworker.cpp
-OTHER_FILES += \
- t9write.json
-
-DEFINES += \
- QT_NO_CAST_TO_ASCII \
- QT_ASCII_CAST_WARNINGS \
- QT_NO_CAST_FROM_ASCII \
- QT_NO_CAST_FROM_BYTEARRAY
-
-include(../3rdparty/t9write/t9write-build.pri)
-
-!qtConfig(t9write-cjk): \
- error("T9Write SDK could not be found. For more information, see" \
- "the documentation in Building Qt Virtual Keyboard")
-
-LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/fallback/handwriting.qml
-qtConfig(t9write-alphabetic) {
- qtConfig(vkb-lang-en_GB): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/en_GB/handwriting.fallback
- qtConfig(vkb-lang-en_US): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/en_US/handwriting.fallback
- qtConfig(vkb-lang-ar_AR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ar_AR/handwriting.qml
- qtConfig(vkb-lang-bg_BG): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/bg_BG/handwriting.qml
- qtConfig(vkb-lang-cs_CZ): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/cs_CZ/handwriting.qml
- qtConfig(vkb-lang-da_DK): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/da_DK/handwriting.fallback
- qtConfig(vkb-lang-de_DE): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/de_DE/handwriting.fallback
- qtConfig(vkb-lang-el_GR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/el_GR/handwriting.qml
- qtConfig(vkb-lang-es_ES): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/es_ES/handwriting.qml
- qtConfig(vkb-lang-es_MX): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/es_MX/handwriting.qml
- qtConfig(vkb-lang-et_EE): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/et_EE/handwriting.fallback
- qtConfig(vkb-lang-fa_FA): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/fa_FA/handwriting.qml
- qtConfig(vkb-lang-fi_FI): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/fi_FI/handwriting.fallback
- qtConfig(vkb-lang-fr_FR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/fr_FR/handwriting.fallback
- qtConfig(vkb-lang-fr_CA): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/fr_CA/handwriting.fallback
- qtConfig(vkb-lang-he_IL): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/he_IL/handwriting.qml
- qtConfig(vkb-lang-hr_HR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/hr_HR/handwriting.qml
- qtConfig(vkb-lang-hu_HU): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/hu_HU/handwriting.qml
- qtConfig(vkb-lang-id_ID): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/id_ID/handwriting.fallback
- qtConfig(vkb-lang-it_IT): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/it_IT/handwriting.fallback
- qtConfig(vkb-lang-ms_MY): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ms_MY/handwriting.fallback
- qtConfig(vkb-lang-nb_NO): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/nb_NO/handwriting.fallback
- qtConfig(vkb-lang-nl_NL): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/nl_NL/handwriting.fallback
- qtConfig(vkb-lang-pl_PL): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/pl_PL/handwriting.fallback
- qtConfig(vkb-lang-pt_BR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/pt_BR/handwriting.fallback
- qtConfig(vkb-lang-pt_PT): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/pt_PT/handwriting.fallback
- qtConfig(vkb-lang-ro_RO): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ro_RO/handwriting.qml
- qtConfig(vkb-lang-ru_RU): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ru_RU/handwriting.fallback
- qtConfig(vkb-lang-sk_SK): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/sk_SK/handwriting.fallback
- qtConfig(vkb-lang-sl_SI): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/sl_SI/handwriting.fallback
- qtConfig(vkb-lang-sq_AL): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/sq_AL/handwriting.fallback
- qtConfig(vkb-lang-sr_SP): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/sr_SP/handwriting.qml
- qtConfig(vkb-lang-sv_SE): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/sv_SE/handwriting.fallback
- qtConfig(vkb-lang-th_TH): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/th_TH/handwriting.qml
- qtConfig(vkb-lang-tr_TR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/tr_TR/handwriting.fallback
- qtConfig(vkb-lang-uk_UA): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/uk_UA/handwriting.fallback
- qtConfig(vkb-lang-vi_VN): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/vi_VN/handwriting.fallback
-}
-qtConfig(t9write-cjk) {
- qtConfig(vkb-lang-ja_JP): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ja_JP/handwriting.qml
- qtConfig(vkb-lang-ko_KR): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/ko_KR/handwriting.qml
- qtConfig(vkb-lang-zh_CN): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/zh_CN/handwriting.qml
- qtConfig(vkb-lang-zh_TW): LAYOUT_FILES += $$LAYOUTS_BASE/content/layouts/zh_TW/handwriting.qml
-}
-
-OTHER_FILES += \
- $$LAYOUT_FILES
-
-virtualkeyboard_t9write_layouts.files = $$LAYOUT_FILES
-virtualkeyboard_t9write_layouts.base = $$LAYOUTS_BASE
-virtualkeyboard_t9write_layouts.prefix = $$LAYOUTS_PREFIX
-RESOURCES += virtualkeyboard_t9write_layouts
-
-DEFINES += HAVE_T9WRITE
-QMAKE_USE += t9write_db
-INCLUDEPATH += $$T9WRITE_INCLUDE_DIRS
-qtConfig(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
- }
-}
-qtConfig(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
- }
-}
-
-win32 {
- QMAKE_TARGET_PRODUCT = "Qt Virtual Keyboard T9 Write (Qt $$QT_VERSION)"
- QMAKE_TARGET_DESCRIPTION = "Virtual Keyboard Extension for Qt."
-}
-
-PLUGIN_TYPE = virtualkeyboard
-PLUGIN_CLASS_NAME = QtVirtualKeyboardT9WritePlugin
-load(qt_plugin)
diff --git a/src/plugins/t9write/plugin/t9write.json b/src/plugins/t9write/plugin/t9write.json
deleted file mode 100644
index ac71f7cc..00000000
--- a/src/plugins/t9write/plugin/t9write.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "Name": "handwriting",
- "Provider": "Qt T9 Write Extension",
- "InputMethod": "HandwritingInputMethod",
- "Version": 200
-}
diff --git a/src/plugins/t9write/plugin/t9write_p.h b/src/plugins/t9write/plugin/t9write_p.h
deleted file mode 100644
index 5e85b19c..00000000
--- a/src/plugins/t9write/plugin/t9write_p.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** 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_P_H
-#define T9WRITE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtVirtualKeyboard/private/qvirtualkeyboard_global_p.h>
-
-#include "t9write_api_version.h"
-#if QT_CONFIG(t9write_alphabetic)
-#include "decuma_hwr.h"
-#endif
-#if QT_CONFIG(t9write_cjk)
-#include "decuma_hwr_cjk.h"
-#endif
-#include "decumaFunctionalSupport.h"
-
-#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_P_H
diff --git a/src/plugins/t9write/plugin/t9writedictionary.cpp b/src/plugins/t9write/plugin/t9writedictionary.cpp
deleted file mode 100644
index 5a17ae6d..00000000
--- a/src/plugins/t9write/plugin/t9writedictionary.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** 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_p.h"
-#include <QLoggingCategory>
-
-QT_BEGIN_NAMESPACE
-namespace QtVirtualKeyboard {
-
-Q_DECLARE_LOGGING_CATEGORY(lcT9Write)
-
-T9WriteDictionary::T9WriteDictionary(DECUMA_SESSION *decumaSession,
- const DECUMA_MEM_FUNCTIONS &memFuncs,
- bool cjk) :
- decumaSession(decumaSession),
- memFuncs(memFuncs),
- cjk(cjk),
- sourceData(nullptr),
- sourceSize(0),
- convertedData(nullptr),
- convertedSize(0)
-{
-}
-
-T9WriteDictionary::~T9WriteDictionary()
-{
- if (convertedData) {
- DECUMA_STATUS status = DECUMA_API(DestroyConvertedDictionary)(&convertedData, &memFuncs);
- Q_ASSERT(status == decumaNoError);
- Q_ASSERT(convertedData == nullptr);
- }
-}
-
-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;
- qCWarning(lcT9Write) << "Could not read dictionary file" << fileName;
- }
- file.close();
- } else {
- qCWarning(lcT9Write) << "Could not open dictionary file" << fileName;
- }
-
- return sourceData != nullptr;
-}
-
-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) {
- qCWarning(lcT9Write) << "Could not convert dictionary" << file.fileName();
- file.unmap((uchar *)sourceData);
- sourceSize = 0;
- sourceData = nullptr;
- }
-
- 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 != nullptr;
-}
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
diff --git a/src/plugins/t9write/plugin/t9writedictionary_p.h b/src/plugins/t9write/plugin/t9writedictionary_p.h
deleted file mode 100644
index d728a583..00000000
--- a/src/plugins/t9write/plugin/t9writedictionary_p.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** 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_P_H
-#define T9WRITEDICTIONARY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGlobal>
-#include <QFile>
-#include "t9write_p.h"
-
-QT_BEGIN_NAMESPACE
-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;
-};
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
-
-#endif // T9WRITEDICTIONARY_P_H
diff --git a/src/plugins/t9write/plugin/t9writeinputmethod.cpp b/src/plugins/t9write/plugin/t9writeinputmethod.cpp
deleted file mode 100644
index 007a1989..00000000
--- a/src/plugins/t9write/plugin/t9writeinputmethod.cpp
+++ /dev/null
@@ -1,2177 +0,0 @@
-/****************************************************************************
-**
-** 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 "t9writeinputmethod_p.h"
-#include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h>
-#include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h>
-#include <QtVirtualKeyboard/qvirtualkeyboardtrace.h>
-#include "t9writeworker_p.h"
-#include <QLoggingCategory>
-#include <QDirIterator>
-#include <QCryptographicHash>
-#include <QTime>
-#include <QMetaEnum>
-#include <QtVirtualKeyboard/private/handwritinggesturerecognizer_p.h>
-#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
-#include <QtVirtualKeyboard/private/unipentrace_p.h>
-#include <QStandardPaths>
-#endif
-
-#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
-
-QT_BEGIN_NAMESPACE
-namespace QtVirtualKeyboard {
-
-Q_LOGGING_CATEGORY(lcT9Write, "qt.virtualkeyboard.t9write")
-
-class T9WriteCaseFormatter
-{
-public:
- T9WriteCaseFormatter() :
- preferLowercase(false)
- {
- }
-
- void clear()
- {
- textCaseList.clear();
- }
-
- void ensureLength(int length, QVirtualKeyboardInputEngine::TextCase textCase)
- {
- if (length <= 0) {
- textCaseList.clear();
- return;
- }
- while (length < textCaseList.length())
- textCaseList.removeLast();
- while (length > textCaseList.length())
- textCaseList.append(textCase);
- }
-
- QString formatString(const QString &str) const
- {
- QString result;
- QVirtualKeyboardInputEngine::TextCase textCase = QVirtualKeyboardInputEngine::TextCase::Lower;
- for (int i = 0; i < str.length(); ++i) {
- if (i < textCaseList.length())
- textCase = textCaseList.at(i);
- result.append(textCase == QVirtualKeyboardInputEngine::TextCase::Upper ? str.at(i).toUpper() : (preferLowercase ? str.at(i).toLower() : str.at(i)));
- }
- return result;
- }
-
- bool preferLowercase;
-
-private:
- QList<QVirtualKeyboardInputEngine::TextCase> textCaseList;
-};
-
-class T9WriteInputMethodPrivate
-{
- Q_DECLARE_PUBLIC(T9WriteInputMethod)
-public:
- T9WriteInputMethodPrivate(T9WriteInputMethod *q_ptr) :
- q_ptr(q_ptr),
- cjk(false),
- engineMode(T9WriteInputMethod::EngineMode::Uninitialized),
- defaultHwrDbPath(QLatin1String(":/QtQuick/VirtualKeyboard/T9Write/data/")),
- defaultDictionaryDbPath(defaultHwrDbPath),
- traceListHardLimit(32),
- attachedDictionary(nullptr),
- resultId(0),
- lastResultId(0),
- resultTimer(0),
- decumaSession(nullptr),
- activeWordIndex(-1),
- arcAdditionStarted(false),
- ignoreUpdate(false),
- textCase(QVirtualKeyboardInputEngine::TextCase::Lower)
-#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- , unipenTrace()
-#endif
- {
- }
-
- static void *decumaMalloc(size_t size, void *pPrivate)
- {
- Q_UNUSED(pPrivate);
- return malloc(size);
- }
-
- static void *decumaCalloc(size_t elements, size_t size, void *pPrivate)
- {
- Q_UNUSED(pPrivate);
- return calloc(elements, size);
- }
-
- static void decumaFree(void *ptr, void *pPrivate)
- {
- Q_UNUSED(pPrivate);
- free(ptr);
- }
-
-#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);
- 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
-
- static const char *engineModeToString(T9WriteInputMethod::EngineMode mode)
- {
- return QMetaEnum::fromType<T9WriteInputMethod::EngineMode>().key(static_cast<int>(mode));
- }
-
- bool initEngine(T9WriteInputMethod::EngineMode newEngineMode)
- {
- if (engineMode == newEngineMode)
- return engineMode != T9WriteInputMethod::EngineMode::Uninitialized;
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::initEngine()" << engineModeToString(newEngineMode);
-
- if (decumaSession)
- exitEngine();
-
- if (newEngineMode == T9WriteInputMethod::EngineMode::Uninitialized)
- return false;
-
- switch (newEngineMode) {
- case T9WriteInputMethod::EngineMode::Alphabetic:
- case T9WriteInputMethod::EngineMode::Arabic:
- case T9WriteInputMethod::EngineMode::Hebrew:
- case T9WriteInputMethod::EngineMode::Thai:
- cjk = false;
- break;
- case T9WriteInputMethod::EngineMode::SimplifiedChinese:
- case T9WriteInputMethod::EngineMode::TraditionalChinese:
- case T9WriteInputMethod::EngineMode::HongKongChinese:
- case T9WriteInputMethod::EngineMode::Japanese:
- case T9WriteInputMethod::EngineMode::Korean:
- cjk = true;
- break;
- default:
- Q_ASSERT(0 && "Invalid T9WriteInputMethod::EngineMode!");
- return false;
- }
- engineMode = newEngineMode;
-
- memset(&sessionSettings, 0, sizeof(sessionSettings));
-
- QString hwrDb = findHwrDb(engineMode, defaultHwrDbPath);
- hwrDbFile.setFileName(hwrDb);
- if (!hwrDbFile.open(QIODevice::ReadOnly)) {
- qCCritical(lcT9Write) << "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) {
- qCCritical(lcT9Write) << "Could not read HWR database" << hwrDb;
- exitEngine();
- return false;
- }
-
- symbolCategories.append(DECUMA_CATEGORY_ANSI);
- languageCategories.append(DECUMA_LANG_EN);
-
- sessionSettings.recognitionMode = mcrMode;
- sessionSettings.writingDirection = unknownWriting;
- sessionSettings.charSet.pSymbolCategories = symbolCategories.data();
- sessionSettings.charSet.nSymbolCategories = symbolCategories.size();
- sessionSettings.charSet.pLanguages = languageCategories.data();
- sessionSettings.charSet.nLanguages = languageCategories.size();
-
- session = QByteArray(DECUMA_API(GetSessionSize)(), 0);
- decumaSession = (DECUMA_SESSION *)(!session.isEmpty() ? session.data() : nullptr);
-
- DECUMA_STATUS status = DECUMA_API(BeginSession)(decumaSession, &sessionSettings, &memFuncs);
- Q_ASSERT(status == decumaNoError);
- if (status != decumaNoError) {
- qCCritical(lcT9Write) << "Could not initialize engine" << status;
- exitEngine();
- return false;
- }
-
-#if QT_VIRTUALKEYBOARD_T9WRITE_LOG
- DECUMA_API(StartLogging)(decumaSession, 0, decumaLogString);
-#endif
-
- worker.reset(new T9WriteWorker(decumaSession, cjk));
- worker->start();
-
- Q_Q(T9WriteInputMethod);
- processResultConnection = QObject::connect(q, &T9WriteInputMethod::resultListChanged, q, &T9WriteInputMethod::processResult, Qt::QueuedConnection);
-
- return true;
- }
-
- void exitEngine()
- {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::exitEngine()";
-
- if (processResultConnection)
- QObject::disconnect(processResultConnection);
-
- worker.reset();
-
- if (sessionSettings.pStaticDB) {
- hwrDbFile.unmap((uchar *)sessionSettings.pStaticDB);
- hwrDbFile.close();
- }
-
- if (attachedDictionary) {
- detachDictionary(attachedDictionary);
- attachedDictionary.reset();
- }
- loadedDictionary.reset();
-
- if (decumaSession) {
-#if QT_VIRTUALKEYBOARD_T9WRITE_LOG
- DECUMA_API(StopLogging)(decumaSession);
-#endif
- DECUMA_API(EndSession)(decumaSession);
- decumaSession = nullptr;
- session.clear();
- }
-
- memset(&sessionSettings, 0, sizeof(sessionSettings));
-
- symbolCategories.clear();
- languageCategories.clear();
-
- engineMode = T9WriteInputMethod::EngineMode::Uninitialized;
- cjk = false;
- }
-
- QString findHwrDb(T9WriteInputMethod::EngineMode mode, const QString &dir) const
- {
- QString hwrDbPath(dir);
- switch (mode) {
- case T9WriteInputMethod::EngineMode::Alphabetic:
-#if T9WRITEAPIMAJORVERNUM >= 21
- hwrDbPath.append(QLatin1String("hwrDB_le.bin"));
-#else
- hwrDbPath.append(QLatin1String("_databas_le.bin"));
-#endif
- break;
- case T9WriteInputMethod::EngineMode::Arabic:
-#if T9WRITEAPIMAJORVERNUM >= 21
- hwrDbPath.append(QLatin1String("arabic/hwrDB_le.bin"));
-#else
- hwrDbPath.append(QLatin1String("arabic/_databas_le.bin"));
-#endif
- break;
- case T9WriteInputMethod::EngineMode::Hebrew:
-#if T9WRITEAPIMAJORVERNUM >= 21
- hwrDbPath.append(QLatin1String("hebrew/hwrDB_le.bin"));
-#else
- hwrDbPath.append(QLatin1String("hebrew/_databas_le.bin"));
-#endif
- break;
- case T9WriteInputMethod::EngineMode::Thai:
-#if T9WRITEAPIMAJORVERNUM >= 21
- hwrDbPath.append(QLatin1String("thai/hwrDB_le.bin"));
-#else
- hwrDbPath.append(QLatin1String("thai/_databas_le.bin"));
-#endif
- break;
- case T9WriteInputMethod::EngineMode::SimplifiedChinese:
- hwrDbPath.append(QLatin1String("cjk_S_gb18030_le.hdb"));
- break;
- case T9WriteInputMethod::EngineMode::TraditionalChinese:
- hwrDbPath.append(QLatin1String("cjk_T_std_le.hdb"));
- break;
- case T9WriteInputMethod::EngineMode::HongKongChinese:
- hwrDbPath.append(QLatin1String("cjk_HK_std_le.hdb"));
- break;
- case T9WriteInputMethod::EngineMode::Japanese:
- hwrDbPath.append(QLatin1String("cjk_J_std_le.hdb"));
- break;
- case T9WriteInputMethod::EngineMode::Korean:
- hwrDbPath.append(QLatin1String("cjk_K_mkt_le.hdb"));
- break;
- default:
- return QString();
- }
- if (!QFileInfo::exists(hwrDbPath)) {
- qCCritical(lcT9Write) << "Could not find HWR database for" << engineModeToString(mode);
- return QString();
- }
- return hwrDbPath;
- }
-
- QString findDictionary(const QString &dir, const QLocale &locale, DECUMA_SRC_DICTIONARY_TYPE &srcType)
- {
- srcType = numberOfSrcDictionaryTypes;
-
- QStringList languageCountry = locale.name().split(QLatin1String("_"));
- if (languageCountry.length() != 2)
- return QString();
- const QString language = languageCountry[0].toUpper();
-
- QString dictionary;
- QDirIterator it(dir, QDirIterator::NoIteratorFlags);
- while (it.hasNext()) {
- QString fileEntry = it.next();
- const QFileInfo fileInfo(fileEntry);
-
- if (fileInfo.isDir())
- continue;
-
- const QString fileName(fileInfo.fileName());
- if (!fileName.startsWith(language) &&
- !fileName.startsWith(QLatin1String("zzEval_") + language))
- continue;
-
- if (fileEntry.endsWith(QLatin1String(".ldb"))) {
-#if T9WRITEAPIMAJORVERNUM >= 20
- qCCritical(lcT9Write) << "Incompatible dictionary" << fileEntry;
- continue;
-#else
- srcType = decumaXT9LDB;
-#endif
- } else if (fileEntry.endsWith(QLatin1String(".phd"))) {
-#if T9WRITEAPIMAJORVERNUM >= 20
- srcType = decumaPortableHWRDictionary;
-#else
- qCCritical(lcT9Write) << "Incompatible dictionary" << fileEntry;
- continue;
-#endif
- } else {
- qCCritical(lcT9Write) << "Incompatible dictionary" << fileEntry;
- continue;
- }
-
- dictionary = fileEntry;
- break;
- }
-
- return dictionary;
- }
-
- bool attachDictionary(const QSharedPointer<T9WriteDictionary> &dictionary)
- {
- const std::lock_guard<QRecursiveMutex> dictionaryGuard(dictionaryLock);
- Q_ASSERT(decumaSession != nullptr);
- Q_ASSERT(dictionary != nullptr);
- qCDebug(lcT9Write) << "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(const QSharedPointer<T9WriteDictionary> &dictionary)
- {
- const std::lock_guard<QRecursiveMutex> dictionaryGuard(dictionaryLock);
- if (!dictionary)
- return;
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::detachDictionary():" << dictionary->fileName();
-
- Q_ASSERT(decumaSession != nullptr);
- DECUMA_STATUS status = DECUMA_API(DetachDictionary)(decumaSession, dictionary->data());
- Q_UNUSED(status);
- Q_ASSERT(status == decumaNoError);
- }
-
- bool setInputMode(const QLocale &locale, QVirtualKeyboardInputEngine::InputMode inputMode)
- {
- Q_Q(T9WriteInputMethod);
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::setInputMode():" << locale << inputMode;
-
- finishRecognition();
-
- DECUMA_UINT32 language = mapToDecumaLanguage(locale, inputMode);
- if (language == DECUMA_LANG_GSMDEFAULT) {
- qCCritical(lcT9Write) << "Language is not supported" << locale.name();
- return false;
- }
-
- if (!initEngine(mapLocaleToEngineMode(locale, language)))
- return false;
-
- int isLanguageSupported = 0;
- DECUMA_API(DatabaseIsLanguageSupported)(sessionSettings.pStaticDB, language, &isLanguageSupported);
- if (!isLanguageSupported) {
- qCCritical(lcT9Write) << "Language is not supported" << locale.name();
- return false;
- }
-
- bool languageChanged = languageCategories.isEmpty() || languageCategories.first() != language;
- languageCategories.clear();
- languageCategories.append(language);
-
- // 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);
-
- if (!updateSymbolCategories(language, locale, inputMode))
- return false;
- 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 : leftToRight;
-
- // 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
-
- qCDebug(lcT9Write) << " -> language categories:" << languageCategories;
- qCDebug(lcT9Write) << " -> symbol categories:" << symbolCategories;
- qCDebug(lcT9Write) << " -> 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 = DECUMA_API(ChangeSessionSettings)(decumaSession, &sessionSettings);
- Q_ASSERT(status == decumaNoError);
-
- caseFormatter.preferLowercase = q->inputContext()->inputMethodHints().testFlag(Qt::ImhPreferLowercase);
-
- return status == decumaNoError;
- }
-
- T9WriteInputMethod::EngineMode mapLocaleToEngineMode(const QLocale &locale, DECUMA_UINT32 language = 0)
- {
-#ifdef HAVE_T9WRITE_CJK
- switch (locale.language()) {
- case QLocale::Chinese: {
- if (locale.script() == QLocale::TraditionalChineseScript)
- return locale.country() == QLocale::HongKong ? T9WriteInputMethod::EngineMode::HongKongChinese : T9WriteInputMethod::EngineMode::TraditionalChinese;
- return T9WriteInputMethod::EngineMode::SimplifiedChinese;
- break;
- }
- case QLocale::Japanese:
- return T9WriteInputMethod::EngineMode::Japanese;
- break;
- case QLocale::Korean:
- return T9WriteInputMethod::EngineMode::Korean;
- default:
- break;
- }
-#else
- Q_UNUSED(locale);
- Q_UNUSED(language);
-#endif
-
-#ifdef HAVE_T9WRITE_ALPHABETIC
- switch (locale.script()) {
- case QLocale::ArabicScript:
- return T9WriteInputMethod::EngineMode::Arabic;
- case QLocale::HebrewScript:
- return T9WriteInputMethod::EngineMode::Hebrew;
- case QLocale::ThaiScript:
- return language == DECUMA_LANG_EN ? T9WriteInputMethod::EngineMode::Alphabetic
- : T9WriteInputMethod::EngineMode::Thai;
- default:
- return T9WriteInputMethod::EngineMode::Alphabetic;
- }
-#else
- return T9WriteInputMethod::EngineMode::Uninitialized;
-#endif
- }
-
- DECUMA_UINT32 mapToDecumaLanguage(const QLocale &locale, QVirtualKeyboardInputEngine::InputMode inputMode)
- {
- static const QLocale::Language maxLanguage = QLocale::Vietnamese;
- static const DECUMA_UINT32 languageMap[maxLanguage + 1] = {
- DECUMA_LANG_GSMDEFAULT, // AnyLanguage = 0
- DECUMA_LANG_GSMDEFAULT, // C = 1
- DECUMA_LANG_GSMDEFAULT, // Abkhazian = 2
- DECUMA_LANG_GSMDEFAULT, // Oromo = 3
- DECUMA_LANG_GSMDEFAULT, // Afar = 4
- DECUMA_LANG_AF, // Afrikaans = 5
- DECUMA_LANG_SQ, // Albanian = 6
- DECUMA_LANG_GSMDEFAULT, // Amharic = 7
- DECUMA_LANG_AR, // Arabic = 8
- DECUMA_LANG_GSMDEFAULT, // Armenian = 9
- DECUMA_LANG_GSMDEFAULT, // Assamese = 10
- DECUMA_LANG_GSMDEFAULT, // Aymara = 11
- DECUMA_LANG_AZ, // Azerbaijani = 12
- DECUMA_LANG_GSMDEFAULT, // Bashkir = 13
- DECUMA_LANG_EU, // Basque = 14
- DECUMA_LANG_BN, // Bengali = 15
- DECUMA_LANG_GSMDEFAULT, // Dzongkha = 16
- DECUMA_LANG_GSMDEFAULT, // Bihari = 17
- DECUMA_LANG_GSMDEFAULT, // Bislama = 18
- DECUMA_LANG_GSMDEFAULT, // Breton = 19
- DECUMA_LANG_BG, // Bulgarian = 20
- DECUMA_LANG_GSMDEFAULT, // Burmese = 21
- DECUMA_LANG_BE, // Belarusian = 22
- DECUMA_LANG_KM, // Khmer = 23
- DECUMA_LANG_CA, // Catalan = 24
- DECUMA_LANG_PRC, // Chinese = 25
- DECUMA_LANG_GSMDEFAULT, // Corsican = 26
- DECUMA_LANG_HR, // Croatian = 27
- DECUMA_LANG_CS, // Czech = 28
- DECUMA_LANG_DA, // Danish = 29
- DECUMA_LANG_NL, // Dutch = 30
- DECUMA_LANG_EN, // English = 31
- DECUMA_LANG_GSMDEFAULT, // Esperanto = 32
- DECUMA_LANG_ET, // Estonian = 33
- DECUMA_LANG_GSMDEFAULT, // Faroese = 34
- DECUMA_LANG_GSMDEFAULT, // Fijian = 35
- DECUMA_LANG_FI, // Finnish = 36
- DECUMA_LANG_FR, // French = 37
- DECUMA_LANG_GSMDEFAULT, // WesternFrisian = 38
- DECUMA_LANG_GSMDEFAULT, // Gaelic = 39
- DECUMA_LANG_GL, // Galician = 40
- DECUMA_LANG_GSMDEFAULT, // Georgian = 41
- DECUMA_LANG_DE, // German = 42
- DECUMA_LANG_EL, // Greek = 43
- DECUMA_LANG_GSMDEFAULT, // Greenlandic = 44
- DECUMA_LANG_GSMDEFAULT, // Guarani = 45
- DECUMA_LANG_GU, // Gujarati = 46
- DECUMA_LANG_HA, // Hausa = 47
- DECUMA_LANG_IW, // Hebrew = 48
- DECUMA_LANG_HI, // Hindi = 49
- DECUMA_LANG_HU, // Hungarian = 50
- DECUMA_LANG_IS, // Icelandic = 51
- DECUMA_LANG_IN, // Indonesian = 52
- DECUMA_LANG_GSMDEFAULT, // Interlingua = 53
- DECUMA_LANG_GSMDEFAULT, // Interlingue = 54
- DECUMA_LANG_GSMDEFAULT, // Inuktitut = 55
- DECUMA_LANG_GSMDEFAULT, // Inupiak = 56
- DECUMA_LANG_GSMDEFAULT, // Irish = 57
- DECUMA_LANG_IT, // Italian = 58
- DECUMA_LANG_JP, // Japanese = 59
- DECUMA_LANG_GSMDEFAULT, // Javanese = 60
- DECUMA_LANG_KN, // Kannada = 61
- DECUMA_LANG_GSMDEFAULT, // Kashmiri = 62
- DECUMA_LANG_KK, // Kazakh = 63
- DECUMA_LANG_GSMDEFAULT, // Kinyarwanda = 64
- DECUMA_LANG_KY, // Kirghiz = 65
- DECUMA_LANG_KO, // Korean = 66
- DECUMA_LANG_GSMDEFAULT, // Kurdish = 67
- DECUMA_LANG_GSMDEFAULT, // Rundi = 68
- DECUMA_LANG_GSMDEFAULT, // Lao = 69
- DECUMA_LANG_GSMDEFAULT, // Latin = 70
- DECUMA_LANG_LV, // Latvian = 71
- DECUMA_LANG_GSMDEFAULT, // Lingala = 72
- DECUMA_LANG_LT, // Lithuanian = 73
- DECUMA_LANG_MK, // Macedonian = 74
- DECUMA_LANG_GSMDEFAULT, // Malagasy = 75
- DECUMA_LANG_MS, // Malay = 76
- DECUMA_LANG_ML, // Malayalam = 77
- DECUMA_LANG_GSMDEFAULT, // Maltese = 78
- DECUMA_LANG_GSMDEFAULT, // Maori = 79
- DECUMA_LANG_MR, // Marathi = 80
- DECUMA_LANG_GSMDEFAULT, // Marshallese = 81
- DECUMA_LANG_MN, // Mongolian = 82
- DECUMA_LANG_GSMDEFAULT, // NauruLanguage = 83
- DECUMA_LANG_GSMDEFAULT, // Nepali = 84
- DECUMA_LANG_NO, // NorwegianBokmal = 85
- DECUMA_LANG_GSMDEFAULT, // Occitan = 86
- DECUMA_LANG_GSMDEFAULT, // Oriya = 87
- DECUMA_LANG_GSMDEFAULT, // Pashto = 88
- DECUMA_LANG_FA, // Persian = 89
- DECUMA_LANG_PL, // Polish = 90
- DECUMA_LANG_PT, // Portuguese = 91
- DECUMA_LANG_PA, // Punjabi = 92
- DECUMA_LANG_GSMDEFAULT, // Quechua = 93
- DECUMA_LANG_GSMDEFAULT, // Romansh = 94
- DECUMA_LANG_RO, // Romanian = 95
- DECUMA_LANG_RU, // Russian = 96
- DECUMA_LANG_GSMDEFAULT, // Samoan = 97
- DECUMA_LANG_GSMDEFAULT, // Sango = 98
- DECUMA_LANG_GSMDEFAULT, // Sanskrit = 99
- DECUMA_LANG_SRCY, // Serbian = 100
- DECUMA_LANG_GSMDEFAULT, // Ossetic = 101
- DECUMA_LANG_ST, // SouthernSotho = 102
- DECUMA_LANG_GSMDEFAULT, // Tswana = 103
- DECUMA_LANG_GSMDEFAULT, // Shona = 104
- DECUMA_LANG_GSMDEFAULT, // Sindhi = 105
- DECUMA_LANG_SI, // Sinhala = 106
- DECUMA_LANG_GSMDEFAULT, // Swati = 107
- DECUMA_LANG_SK, // Slovak = 108
- DECUMA_LANG_SL, // Slovenian = 109
- DECUMA_LANG_GSMDEFAULT, // Somali = 110
- DECUMA_LANG_ES, // Spanish = 111
- DECUMA_LANG_GSMDEFAULT, // Sundanese = 112
- DECUMA_LANG_SW, // Swahili = 113
- DECUMA_LANG_SV, // Swedish = 114
- DECUMA_LANG_GSMDEFAULT, // Sardinian = 115
- DECUMA_LANG_TG, // Tajik = 116
- DECUMA_LANG_TA, // Tamil = 117
- DECUMA_LANG_GSMDEFAULT, // Tatar = 118
- DECUMA_LANG_TE, // Telugu = 119
- DECUMA_LANG_TH, // Thai = 120
- DECUMA_LANG_GSMDEFAULT, // Tibetan = 121
- DECUMA_LANG_GSMDEFAULT, // Tigrinya = 122
- DECUMA_LANG_GSMDEFAULT, // Tongan = 123
- DECUMA_LANG_GSMDEFAULT, // Tsonga = 124
- DECUMA_LANG_TR, // Turkish = 125
- DECUMA_LANG_GSMDEFAULT, // Turkmen = 126
- DECUMA_LANG_GSMDEFAULT, // Tahitian = 127
- DECUMA_LANG_GSMDEFAULT, // Uighur = 128
- DECUMA_LANG_UK, // Ukrainian = 129
- DECUMA_LANG_UR, // Urdu = 130
- DECUMA_LANG_UZ, // Uzbek = 131
- DECUMA_LANG_VI // Vietnamese = 132
- };
-
- int localeLanguage = locale.language();
- if (locale.language() > maxLanguage)
- return DECUMA_LANG_GSMDEFAULT;
-
- DECUMA_UINT32 language = languageMap[localeLanguage];
- if (language == DECUMA_LANG_PRC) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::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 != QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting)
- language = DECUMA_LANG_EN;
- } else if (language == DECUMA_LANG_KO) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting)
- language = DECUMA_LANG_EN;
- } else if (language == DECUMA_LANG_SRCY) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::Cyrillic)
- language = DECUMA_LANG_SRLA;
- } else if (language == DECUMA_LANG_AR || language == DECUMA_LANG_FA) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::Arabic && inputMode != QVirtualKeyboardInputEngine::InputMode::Numeric)
- language = DECUMA_LANG_EN;
- } else if (language == DECUMA_LANG_IW) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::Hebrew)
- language = DECUMA_LANG_EN;
- } else if (language == DECUMA_LANG_TH) {
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::Thai)
- language = DECUMA_LANG_EN;
- }
-
- return language;
- }
-
- void updateRecognitionMode(DECUMA_UINT32 language, const QLocale &locale,
- QVirtualKeyboardInputEngine::InputMode inputMode)
- {
- Q_Q(T9WriteInputMethod);
- Q_UNUSED(language);
- Q_UNUSED(locale);
-
- // Select recognition mode
- // Note: MCR mode is preferred, as it does not require recognition
- // timer and provides better user experience.
- sessionSettings.recognitionMode = mcrMode;
-
- // T9 Write Alphabetic v8.0.0 supports UCR mode for specific languages
-#if T9WRITEAPIMAJORVERNUM >= 21
- if (!cjk) {
- switch (inputMode) {
- case QVirtualKeyboardInputEngine::InputMode::Latin:
- switch (language) {
- case DECUMA_LANG_EN:
- case DECUMA_LANG_FR:
- case DECUMA_LANG_IT:
- case DECUMA_LANG_DE:
- case DECUMA_LANG_ES:
- sessionSettings.recognitionMode = ucrMode;
- break;
- default:
- break;
- }
- break;
- case QVirtualKeyboardInputEngine::InputMode::Arabic:
- sessionSettings.recognitionMode = ucrMode;
- break;
- default:
- break;
- }
- }
-#endif
-
- // Use scrMode with hidden text or with no predictive mode
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::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,
- QVirtualKeyboardInputEngine::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 QVirtualKeyboardInputEngine::InputMode::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 ||
- language == DECUMA_LANG_MS || language == DECUMA_LANG_IN)
- 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);
- else if (language == DECUMA_LANG_VI)
- symbolCategories.append(DECUMA_CATEGORY_VIETNAMESE_SUPPLEMENTS);
- }
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::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 QVirtualKeyboardInputEngine::InputMode::Dialable:
- symbolCategories.append(DECUMA_CATEGORY_PHONE_NUMBER);
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::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 QVirtualKeyboardInputEngine::InputMode::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 QVirtualKeyboardInputEngine::InputMode::Arabic:
- symbolCategories.append(DECUMA_CATEGORY_ARABIC_ISOLATED_LETTER_MODE);
- symbolCategories.append(DECUMA_CATEGORY_ARABIC_GESTURES);
- leftToRightGestures = false;
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::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;
-
- case QVirtualKeyboardInputEngine::InputMode::Thai:
- symbolCategories.append(DECUMA_CATEGORY_THAI_BASE);
- symbolCategories.append(DECUMA_CATEGORY_THAI_NON_BASE);
- break;
-
- default:
- qCCritical(lcT9Write) << "Invalid input mode" << inputMode;
- 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,
- QVirtualKeyboardInputEngine::InputMode inputMode)
- {
- Q_ASSERT(cjk);
-
- symbolCategories.clear();
-
- switch (inputMode) {
- case QVirtualKeyboardInputEngine::InputMode::Latin:
- symbolCategories.append(DECUMA_CATEGORY_ANSI);
- symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL);
- symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS);
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::Numeric:
- symbolCategories.append(DECUMA_CATEGORY_DIGIT);
- symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL);
- symbolCategories.append(DECUMA_CATEGORY_PUNCTUATIONS);
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::Dialable:
- symbolCategories.append(DECUMA_CATEGORY_DIGIT);
- symbolCategories.append(DECUMA_CATEGORY_CJK_SYMBOL);
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::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:
- qCCritical(lcT9Write) << "Invalid locale" << locale << "for" << engineModeToString(engineMode);
- return false;
- }
- break;
-
- case QVirtualKeyboardInputEngine::InputMode::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 QVirtualKeyboardInputEngine::InputMode::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.
- */
- const std::lock_guard<QRecursiveMutex> 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) {
- qCDebug(lcT9Write) << " -> 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 != scrMode && !inputMethodHints.testFlag(Qt::ImhNoPredictiveText) &&
- loadedDictionary && !attachedDictionary) {
- if (attachDictionary(loadedDictionary))
- attachedDictionary = loadedDictionary;
- }
- }
-
- QByteArray getContext(QVirtualKeyboardInputEngine::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(QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode,
- const QVariantMap &traceCaptureDeviceInfo,
- const QVariantMap &traceScreenInfo,
- const QByteArray &context)
- {
- Q_UNUSED(patternRecognitionMode);
- if (context == currentContext)
- return;
- currentContext = context;
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::setContext():" << QLatin1String((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(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit q->selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, activeWordIndex);
- }
-
- const int dpi = traceCaptureDeviceInfo.value(QLatin1String("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(QLatin1String("horizontalRulers"), QVariantList()).toList());
- if (horizontalRulers.count() > 2) {
- sessionSettings.baseline = horizontalRulers.last().toInt();
- sessionSettings.helpline = 0;
- sessionSettings.topline = horizontalRulers.first().toInt();
- sessionSettings.supportLineSet = baselineAndTopline;
- sessionSettings.UIInputGuide = supportlines;
- } else if (horizontalRulers.count() == 2) {
- sessionSettings.baseline = horizontalRulers.last().toInt();
- sessionSettings.helpline = horizontalRulers.first().toInt();
- sessionSettings.topline = 0;
- sessionSettings.supportLineSet = baselineAndHelpline;
- sessionSettings.UIInputGuide = supportlines;
- } else {
- sessionSettings.baseline = 0;
- sessionSettings.helpline = 0;
- sessionSettings.topline = 0;
- sessionSettings.supportLineSet = baselineAndHelpline;
- sessionSettings.UIInputGuide = none;
- }
-
- DECUMA_STATUS status = DECUMA_API(ChangeSessionSettings)(decumaSession, &sessionSettings);
- Q_ASSERT(status == decumaNoError);
- }
-
- QVirtualKeyboardTrace *traceBegin(
- int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode,
- const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
- {
- if (!worker)
- return nullptr;
-
- // The result id follows the trace id so that the (previous)
- // results completed during the handwriting can be rejected.
- resultId = traceId;
-
- stopResultTimer();
-
- // Dictionary must be completed before the arc addition can begin
- if (dictionaryTask) {
- dictionaryTask->wait();
- dictionaryTask.reset();
- }
-
- // Cancel the current recognition task
- worker->removeAllTasks<T9WriteRecognitionResultsTask>();
- worker->removeAllTasks<T9WriteRecognitionTask>();
- if (recognitionTask) {
- recognitionTask->cancelRecognition();
- recognitionTask.reset();
- }
-
-#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- if (!unipenTrace)
- unipenTrace.reset(new UnipenTrace(traceCaptureDeviceInfo, traceScreenInfo));
-#endif
-
- QByteArray context = getContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo);
- if (context != currentContext) {
- worker->waitForAllTasks();
- setContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo, context);
- }
-
- DECUMA_STATUS status;
-
- if (!arcAdditionStarted) {
- worker->waitForAllTasks();
- status = DECUMA_API(BeginArcAddition)(decumaSession);
- Q_ASSERT(status == decumaNoError);
- arcAdditionStarted = true;
- }
-
- QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace();
-#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- trace->setChannels(QStringList(QLatin1String("t")));
-#endif
- traceList.append(trace);
-
- return trace;
- }
-
- void traceEnd(QVirtualKeyboardTrace *trace)
- {
- if (trace->isCanceled()) {
- traceList.removeOne(trace);
- delete trace;
- } else {
- if (cjk && countActiveTraces() == 0) {
- // For some reason gestures don't seem to work in CJK mode
- // Using our own gesture recognizer as fallback
- if (handleGesture())
- return;
- }
- worker->addTask(QSharedPointer<T9WriteAddArcTask>(new T9WriteAddArcTask(trace)));
- }
- if (!traceList.isEmpty()) {
- Q_ASSERT(arcAdditionStarted);
- if (countActiveTraces() == 0)
- restartRecognition();
- }
- }
-
- int countActiveTraces() const
- {
- int count = 0;
- for (QVirtualKeyboardTrace *trace : qAsConst(traceList)) {
- if (!trace->isFinal())
- count++;
- }
- return count;
- }
-
- void clearTraces()
- {
- worker->waitForAllTasks();
- qDeleteAll(traceList);
- traceList.clear();
- }
-
- void noteSelected(int index)
- {
- if (wordCandidatesHwrResultIndex.isEmpty())
- return;
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::noteSelected():" << index;
- Q_ASSERT(index >= 0 && index < wordCandidatesHwrResultIndex.length());
- int resultIndex = wordCandidatesHwrResultIndex[index];
- DECUMA_API(NoteSelectedCandidate)(decumaSession, resultIndex);
- }
-
- void restartRecognition()
- {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::restartRecognition()";
-
- Q_Q(T9WriteInputMethod);
-
- worker->removeAllTasks<T9WriteRecognitionResultsTask>();
- if (recognitionTask) {
- recognitionTask->cancelRecognition();
- recognitionTask.reset();
- }
-
- // Boost dictionary words by default
- BOOST_LEVEL boostLevel = attachedDictionary ? boostDictWords : noBoost;
-
- // Disable dictionary boost in UCR mode for URL and E-mail input
- // Otherwise it will completely mess input
- const Qt::InputMethodHints inputMethodHints = q->inputContext()->inputMethodHints();
- if (sessionSettings.recognitionMode == ucrMode && (inputMethodHints & (Qt::ImhUrlCharactersOnly | Qt::ImhEmailCharactersOnly)))
- boostLevel = noBoost;
-
- QSharedPointer<T9WriteRecognitionResult> recognitionResult(new T9WriteRecognitionResult(resultId, 9, 64));
- recognitionTask.reset(new T9WriteRecognitionTask(recognitionResult, instantGestureSettings,
- boostLevel, stringStart));
- worker->addTask(recognitionTask);
-
- QSharedPointer<T9WriteRecognitionResultsTask> resultsTask(new T9WriteRecognitionResultsTask(recognitionResult));
- q->connect(resultsTask.data(), SIGNAL(resultsAvailable(const QVariantList &)), SLOT(resultsAvailable(const QVariantList &)));
- worker->addTask(resultsTask);
-
- resetResultTimer();
- }
-
- void waitForRecognitionResults()
- {
- if (!worker)
- return;
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::waitForRecognitionResults()";
- worker->waitForAllTasks();
- processResult();
- }
-
- bool finishRecognition(bool emitSelectionListChanged = true)
- {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::finishRecognition()";
- if (!worker)
- return false;
-
- bool result = !traceList.isEmpty();
-
- Q_ASSERT(decumaSession != nullptr);
-
- stopResultTimer();
-
- worker->removeAllTasks<T9WriteAddArcTask>();
- worker->removeAllTasks<T9WriteRecognitionResultsTask>();
- if (recognitionTask) {
- recognitionTask->cancelRecognition();
- recognitionTask.reset();
- result = true;
- }
-
- clearTraces();
-
- if (arcAdditionStarted) {
- DECUMA_API(EndArcAddition)(decumaSession);
- arcAdditionStarted = false;
- }
-
- if (!wordCandidates.isEmpty()) {
- wordCandidates.clear();
- wordCandidatesHwrResultIndex.clear();
- activeWordIndex = -1;
- if (emitSelectionListChanged) {
- Q_Q(T9WriteInputMethod);
- emit q->selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit q->selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, activeWordIndex);
- }
- result = true;
- }
-
- stringStart.clear();
- 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 != scrMode && wordCandidates.isEmpty()) {
- finishRecognition();
- return false;
- }
- if (sessionSettings.recognitionMode == scrMode && scrResult.isEmpty()) {
- finishRecognition();
- return false;
- }
-
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::select():" << index;
-
- Q_Q(T9WriteInputMethod);
- if (sessionSettings.recognitionMode != scrMode) {
- 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 == QVirtualKeyboardInputEngine::TextCase::Upper))) {
- QStringList homeLocations = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
- if (!homeLocations.isEmpty()) {
- unipenTrace->setDirectory(QStringLiteral("%1/%2").arg(homeLocations.at(0)).arg(QLatin1String("VIRTUAL_KEYBOARD_TRACES")));
- unipenTrace->record(traceList);
- unipenTrace->save(ch.unicode(), 100);
- }
- }
- }
- }
-#endif
-
- finishRecognition();
- QChar gesture = T9WriteInputMethodPrivate::mapSymbolToGesture(finalWord.right(1).at(0));
- if (!gesture.isNull())
- finalWord.chop(1);
- q->inputContext()->commit(finalWord);
- applyGesture(gesture);
- } else if (sessionSettings.recognitionMode == scrMode) {
- QString finalWord = scrResult;
- finishRecognition();
- q->inputContext()->inputEngine()->virtualKeyClick((Qt::Key)finalWord.at(0).unicode(), finalWord, Qt::NoModifier);
- }
-
- return true;
- }
-
- void resetResultTimer(int interval = 500)
- {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::resetResultTimer():" << interval;
- Q_Q(T9WriteInputMethod);
- stopResultTimer();
- resultTimer = q->startTimer(interval);
- }
-
- void stopResultTimer()
- {
- if (resultTimer) {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::stopResultTimer()";
- Q_Q(T9WriteInputMethod);
- q->killTimer(resultTimer);
- resultTimer = 0;
- }
- }
-
- void processResult()
- {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::processResult()";
- Q_Q(T9WriteInputMethod);
- QVirtualKeyboardInputContext *ic = q->inputContext();
- if (!ic)
- return;
-
- QStringList newWordCandidates;
- QList<int> newWordCandidatesHwrResultIndex;
- QString resultString;
- QString gesture;
- QVariantList symbolStrokes;
- {
- QMutexLocker resultListGuard(&resultListLock);
- if (resultList.isEmpty())
- return;
-
- if (resultList.first().toMap()[QLatin1String("resultId")] != resultId) {
- qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::processResult(): resultId mismatch" << resultList.first().toMap()[QLatin1String("resultId")] << "(" << resultId << ")";
- resultList.clear();
- return;
- }
- lastResultId = resultId;
-
- for (int i = 0; i < resultList.size(); i++) {
- QVariantMap result = resultList.at(i).toMap();
- QString resultChars = result[QLatin1String("chars")].toString();
- if (i == 0) {
- if (ic->isShiftActive()) {
- caseFormatter.ensureLength(1, textCase);
- caseFormatter.ensureLength(resultChars.length(), QVirtualKeyboardInputEngine::TextCase::Lower);
- } else {
- caseFormatter.ensureLength(resultChars.length(), textCase);
- }
- }
- if (!resultChars.isEmpty()) {
- resultChars = caseFormatter.formatString(resultChars);
- if (sessionSettings.recognitionMode != scrMode) {
- newWordCandidates.append(resultChars);
- newWordCandidatesHwrResultIndex.append(i);
- }
- }
- if (i == 0) {
- resultString = resultChars;
- if (result.contains(QLatin1String("gesture")))
- gesture = result[QLatin1String("gesture")].toString();
- if (sessionSettings.recognitionMode != scrMode && result.contains(QLatin1String("symbolStrokes")))
- symbolStrokes = result[QLatin1String("symbolStrokes")].toList();
- if (sessionSettings.recognitionMode == scrMode)
- break;
- } else {
- // Add a gesture symbol to the secondary candidate
- if (sessionSettings.recognitionMode != scrMode && result.contains(QLatin1String("gesture"))) {
- QString gesture2 = result[QLatin1String("gesture")].toString();
- if (gesture2.length() == 1) {
- QChar symbol = T9WriteInputMethodPrivate::mapGestureToSymbol(gesture2.at(0).unicode());
- if (!symbol.isNull()) {
- // Check for duplicates
- bool duplicateFound = false;
- for (const QString &wordCandidate : newWordCandidates) {
- duplicateFound = wordCandidate.size() == 1 && wordCandidate.at(0) == symbol;
- if (duplicateFound)
- break;
- }
- if (!duplicateFound) {
- if (!resultChars.isEmpty()) {
- newWordCandidates.last().append(symbol);
- } else {
- newWordCandidates.append(symbol);
- newWordCandidatesHwrResultIndex.append(i);
- }
- }
- }
- }
- }
- }
- }
-
- resultList.clear();
- }
-
- bool wordCandidatesChanged = wordCandidates != newWordCandidates;
-
-#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- // Delete trace history
- // Note: We have to be sure there are no background tasks
- // running since the QVirtualKeyboardTrace objects consumed there.
- if (worker->numberOfPendingTasks() == 0) {
-
- const QVirtualKeyboardInputEngine::InputMode inputMode = q->inputEngine()->inputMode();
- if (sessionSettings.recognitionMode == mcrMode && !symbolStrokes.isEmpty() &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting) {
- int activeTraces = symbolStrokes.at(symbolStrokes.count() - 1).toInt();
- if (symbolStrokes.count() > 1)
- activeTraces += symbolStrokes.at(symbolStrokes.count() - 2).toInt();
- while (activeTraces < traceList.count())
- delete traceList.takeFirst();
- }
-
- // Enforce hard limit for number of traces
- if (traceList.count() >= traceListHardLimit) {
- qCDebug(lcT9Write) << "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();
- if (!applyGesture(gestureSymbol)) {
- ic->commit(ic->preeditText());
- finishRecognition();
- }
-
- return;
- }
-
- if (sessionSettings.recognitionMode != scrMode) {
- ignoreUpdate = true;
- ic->setPreeditText(resultString);
- ignoreUpdate = false;
- } else {
- scrResult = resultString;
- }
-
- if (wordCandidatesChanged) {
- wordCandidates = newWordCandidates;
- wordCandidatesHwrResultIndex = newWordCandidatesHwrResultIndex;
- activeWordIndex = wordCandidates.isEmpty() ? -1 : 0;
- emit q->selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit q->selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, activeWordIndex);
- }
-
- if (arcAdditionStarted && traceList.isEmpty() && worker->numberOfPendingTasks() == 0) {
- DECUMA_API(EndArcAddition)(decumaSession);
- arcAdditionStarted = false;
- }
- }
-
- static QChar mapGestureToSymbol(const QChar &gesture)
- {
- switch (gesture.unicode()) {
- case '\r':
- return QChar(0x23CE);
- case ' ':
- return QChar(0x2423);
- default:
- return QChar();
- }
- }
-
- static QChar mapSymbolToGesture(const QChar &symbol)
- {
- switch (symbol.unicode()) {
- case 0x23CE:
- return QLatin1Char('\r');
- case 0x2423:
- return QLatin1Char(' ');
- default:
- return QChar();
- }
- }
-
- bool applyGesture(const QChar &gesture)
- {
- Q_Q(T9WriteInputMethod);
- QVirtualKeyboardInputContext *ic = q->inputContext();
- switch (gesture.unicode()) {
- case '\b':
- return ic->inputEngine()->virtualKeyClick(Qt::Key_Backspace, QString(), Qt::NoModifier);
- case '\r':
- return ic->inputEngine()->virtualKeyClick(Qt::Key_Return, QLatin1String("\n"), Qt::NoModifier);
- case ' ':
- return ic->inputEngine()->virtualKeyClick(Qt::Key_Space, QLatin1String(" "), Qt::NoModifier);
- default:
- return false;
- }
- }
-
- bool handleGesture()
- {
- if (countActiveTraces() > 0)
- return false;
-
- QVariantMap gesture(gestureRecognizer.recognize(traceList.mid(traceList.length() - 1, 1)));
- if (gesture.isEmpty())
- return false;
-
- qCDebug(lcT9Write) << "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);
- QVirtualKeyboardInputContext *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 QVirtualKeyboardInputEngine::InputMode inputMode = q->inputEngine()->inputMode();
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting) {
- if (swipeAngle <= SWIPE_ANGLE_THRESHOLD || swipeAngle >= 360 - SWIPE_ANGLE_THRESHOLD) {
- if (swipeTouchCount == 1) {
- // Single swipe: space
- ic->inputEngine()->virtualKeyClick(Qt::Key_Space, QLatin1String(" "), 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(static_cast<const int>(QVirtualKeyboardInputEngine::InputMode::Numeric));
- int indexOfDialableInputMode = inputModes.indexOf(static_cast<const int>(QVirtualKeyboardInputEngine::InputMode::Dialable));
- if (indexOfNumericInputMode != -1 && indexOfDialableInputMode != -1)
- inputModes.removeAt(inputMode != QVirtualKeyboardInputEngine::InputMode::Dialable ?
- indexOfDialableInputMode :
- indexOfNumericInputMode);
- if (inputModes.count() > 1) {
- int inputModeIndex = inputModes.indexOf(static_cast<const int>(inputMode)) + 1;
- if (inputModeIndex >= inputModes.count())
- inputModeIndex = 0;
- ic->inputEngine()->setInputMode(static_cast<QVirtualKeyboardInputEngine::InputMode>(inputModes.at(inputModeIndex)));
- }
- }
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- bool isValidInputChar(const QChar &c) const
- {
- if (c.isLetterOrNumber())
- return true;
- if (isJoiner(c))
- return true;
- return false;
- }
-
- bool isJoiner(const QChar &c) const
- {
- if (c.isPunct() || c.isSymbol()) {
- Q_Q(const T9WriteInputMethod);
- QVirtualKeyboardInputContext *ic = q->inputContext();
- if (ic) {
- Qt::InputMethodHints inputMethodHints = ic->inputMethodHints();
- if (inputMethodHints.testFlag(Qt::ImhUrlCharactersOnly) || inputMethodHints.testFlag(Qt::ImhEmailCharactersOnly))
- return QString(QStringLiteral(":/?#[]@!$&'()*+,;=-_.%")).contains(c);
- }
- ushort unicode = c.unicode();
- if (unicode == Qt::Key_Apostrophe || unicode == Qt::Key_Minus)
- return true;
- }
- return false;
- }
-
- T9WriteInputMethod *q_ptr;
- static const DECUMA_MEM_FUNCTIONS memFuncs;
- bool cjk;
- T9WriteInputMethod::EngineMode engineMode;
- QByteArray currentContext;
- DECUMA_SESSION_SETTINGS sessionSettings;
- DECUMA_INSTANT_GESTURE_SETTINGS instantGestureSettings;
- QString defaultHwrDbPath;
- QString defaultDictionaryDbPath;
- QFile hwrDbFile;
- QList<DECUMA_UINT32> languageCategories;
- QList<DECUMA_UINT32> symbolCategories;
- QScopedPointer<T9WriteWorker> worker;
- QList<QVirtualKeyboardTrace *> traceList;
- int traceListHardLimit;
- QRecursiveMutex dictionaryLock;
- QString dictionaryFileName;
- QSharedPointer<T9WriteDictionary> loadedDictionary;
- QSharedPointer<T9WriteDictionary> attachedDictionary;
- QSharedPointer<T9WriteDictionaryTask> dictionaryTask;
- QSharedPointer<T9WriteRecognitionTask> recognitionTask;
- QMutex resultListLock;
- QVariantList resultList;
- int resultId;
- int lastResultId;
- int resultTimer;
- QMetaObject::Connection processResultConnection;
- QByteArray session;
- DECUMA_SESSION *decumaSession;
- QStringList wordCandidates;
- QList<int> wordCandidatesHwrResultIndex;
- QString stringStart;
- QString scrResult;
- int activeWordIndex;
- bool arcAdditionStarted;
- bool ignoreUpdate;
- QVirtualKeyboardInputEngine::TextCase textCase;
- T9WriteCaseFormatter caseFormatter;
- HandwritingGestureRecognizer gestureRecognizer;
-#ifdef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- QScopedPointer<UnipenTrace> unipenTrace;
-#endif
-};
-
-const DECUMA_MEM_FUNCTIONS T9WriteInputMethodPrivate::memFuncs = {
- T9WriteInputMethodPrivate::decumaMalloc,
- T9WriteInputMethodPrivate::decumaCalloc,
- T9WriteInputMethodPrivate::decumaFree,
- nullptr
-};
-
-/*!
- \class QtVirtualKeyboard::T9WriteInputMethod
- \internal
-*/
-
-T9WriteInputMethod::T9WriteInputMethod(QObject *parent) :
- QVirtualKeyboardAbstractInputMethod(parent),
- d_ptr(new T9WriteInputMethodPrivate(this))
-{
-}
-
-T9WriteInputMethod::~T9WriteInputMethod()
-{
- Q_D(T9WriteInputMethod);
- d->exitEngine();
-}
-
-QList<QVirtualKeyboardInputEngine::InputMode> T9WriteInputMethod::inputModes(const QString &locale)
-{
- Q_D(T9WriteInputMethod);
- QList<QVirtualKeyboardInputEngine::InputMode> availableInputModes;
- const Qt::InputMethodHints inputMethodHints(inputContext()->inputMethodHints());
- const QLocale loc(locale);
- T9WriteInputMethod::EngineMode mode = d->mapLocaleToEngineMode(loc);
-
- // Add primary input mode
- switch (mode) {
-#ifdef HAVE_T9WRITE_ALPHABETIC
- case T9WriteInputMethod::EngineMode::Alphabetic:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Alphabetic, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly))) {
- switch (loc.script()) {
- case QLocale::GreekScript:
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Greek);
- break;
- case QLocale::CyrillicScript:
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Cyrillic);
- break;
- case QLocale::ThaiScript:
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Thai);
- break;
- default:
- break;
- }
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Latin);
- }
- break;
- case T9WriteInputMethod::EngineMode::Arabic:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Arabic, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Arabic);
- break;
- case T9WriteInputMethod::EngineMode::Hebrew:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Hebrew, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Hebrew);
- break;
- case T9WriteInputMethod::EngineMode::Thai:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Thai, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Thai);
- break;
-#endif
-#ifdef HAVE_T9WRITE_CJK
- case T9WriteInputMethod::EngineMode::SimplifiedChinese:
- case T9WriteInputMethod::EngineMode::TraditionalChinese:
- case T9WriteInputMethod::EngineMode::HongKongChinese:
- if (d->findHwrDb(mode, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting);
- break;
- case T9WriteInputMethod::EngineMode::Japanese:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Japanese, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting);
- break;
- case T9WriteInputMethod::EngineMode::Korean:
- if (d->findHwrDb(T9WriteInputMethod::EngineMode::Korean, d->defaultHwrDbPath).isEmpty())
- return availableInputModes;
- if (!(inputMethodHints & (Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly | Qt::ImhDigitsOnly | Qt::ImhLatinOnly)))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting);
- break;
-#endif
- default:
- return availableInputModes;
- }
-
- // Add exclusive input modes
- if (inputMethodHints.testFlag(Qt::ImhDialableCharactersOnly) || inputMethodHints.testFlag(Qt::ImhDigitsOnly)) {
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Dialable);
- } else if (inputMethodHints.testFlag(Qt::ImhFormattedNumbersOnly)) {
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Numeric);
- } else if (inputMethodHints.testFlag(Qt::ImhLatinOnly)) {
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Latin);
- } else {
- // Add other input modes
- Q_ASSERT(!availableInputModes.isEmpty());
- if (!availableInputModes.contains(QVirtualKeyboardInputEngine::InputMode::Latin))
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Latin);
- availableInputModes.append(QVirtualKeyboardInputEngine::InputMode::Numeric);
- }
-
- return availableInputModes;
-}
-
-bool T9WriteInputMethod::setInputMode(const QString &locale, QVirtualKeyboardInputEngine::InputMode inputMode)
-{
- Q_D(T9WriteInputMethod);
- d->select();
- return d->setInputMode(QLocale(locale), inputMode);
-}
-
-bool T9WriteInputMethod::setTextCase(QVirtualKeyboardInputEngine::TextCase textCase)
-{
- Q_D(T9WriteInputMethod);
- d->textCase = textCase;
- return true;
-}
-
-bool T9WriteInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers)
-{
- Q_UNUSED(modifiers);
- Q_D(T9WriteInputMethod);
- switch (key) {
- case Qt::Key_Enter:
- case Qt::Key_Return:
- case Qt::Key_Tab:
- case Qt::Key_Space:
- d->select();
- update();
- break;
-
- case Qt::Key_Backspace:
- {
- QVirtualKeyboardInputContext *ic = inputContext();
- QString preeditText = ic->preeditText();
- 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) {
- d->waitForRecognitionResults();
- ic->commit();
- d->finishRecognition();
- return true;
- }
- d->caseFormatter.ensureLength(preeditText.length(), d->textCase);
- T9WriteCaseFormatter caseFormatter(d->caseFormatter);
- d->finishRecognition(false);
- d->caseFormatter = caseFormatter;
- d->stringStart = preeditText;
- d->wordCandidates.append(preeditText);
- d->activeWordIndex = 0;
- emit selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->activeWordIndex);
- return true;
- } else {
- bool result = !preeditText.isEmpty();
- if (result)
- ic->clear();
- else
- result = !d->scrResult.isEmpty();
- d->finishRecognition();
- return result;
- }
- break;
- }
-
- default:
- if (d->sessionSettings.recognitionMode != scrMode && text.length() > 0) {
- d->waitForRecognitionResults();
- QVirtualKeyboardInputContext *ic = inputContext();
- QString preeditText = ic->preeditText();
- QChar c = text.at(0);
- bool addToWord = d->isValidInputChar(c) && (!preeditText.isEmpty() || !d->isJoiner(c));
- if (addToWord) {
- preeditText.append(text);
- ic->setPreeditText(preeditText);
- d->caseFormatter.ensureLength(preeditText.length(), d->textCase);
- T9WriteCaseFormatter caseFormatter(d->caseFormatter);
- d->finishRecognition(false);
- d->caseFormatter = caseFormatter;
- d->stringStart = preeditText;
- d->wordCandidates.append(preeditText);
- d->activeWordIndex = 0;
- emit selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->activeWordIndex);
- return true;
- } else {
- ic->commit();
- d->finishRecognition();
- }
- break;
- } else if (d->sessionSettings.recognitionMode == scrMode) {
- d->finishRecognition();
- }
- }
- return false;
-}
-
-void T9WriteInputMethod::reset()
-{
- Q_D(T9WriteInputMethod);
- d->finishRecognition();
- d->setInputMode(QLocale(inputContext()->locale()), inputEngine()->inputMode());
-}
-
-void T9WriteInputMethod::update()
-{
- Q_D(T9WriteInputMethod);
- if (d->ignoreUpdate)
- return;
- d->select();
-}
-
-QList<QVirtualKeyboardSelectionListModel::Type> T9WriteInputMethod::selectionLists()
-{
- return QList<QVirtualKeyboardSelectionListModel::Type>() << QVirtualKeyboardSelectionListModel::Type::WordCandidateList;
-}
-
-int T9WriteInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListModel::Type type)
-{
- Q_UNUSED(type);
- Q_D(T9WriteInputMethod);
- return d->wordCandidates.count();
-}
-
-QVariant T9WriteInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role)
-{
- QVariant result;
- Q_D(T9WriteInputMethod);
- switch (role) {
- case QVirtualKeyboardSelectionListModel::Role::Display:
- result = QVariant(d->wordCandidates.at(index));
- break;
- case QVirtualKeyboardSelectionListModel::Role::WordCompletionLength:
- result.setValue(0);
- break;
- default:
- result = QVirtualKeyboardAbstractInputMethod::selectionListData(type, index, role);
- break;
- }
- return result;
-}
-
-void T9WriteInputMethod::selectionListItemSelected(QVirtualKeyboardSelectionListModel::Type type, int index)
-{
- Q_UNUSED(type);
- Q_D(T9WriteInputMethod);
- d->select(index);
-}
-
-QList<QVirtualKeyboardInputEngine::PatternRecognitionMode> T9WriteInputMethod::patternRecognitionModes() const
-{
- return QList<QVirtualKeyboardInputEngine::PatternRecognitionMode>()
- << QVirtualKeyboardInputEngine::PatternRecognitionMode::Handwriting;
-}
-
-QVirtualKeyboardTrace *T9WriteInputMethod::traceBegin(
- int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode,
- const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo)
-{
- Q_D(T9WriteInputMethod);
- return d->traceBegin(traceId, patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo);
-}
-
-bool T9WriteInputMethod::traceEnd(QVirtualKeyboardTrace *trace)
-{
- Q_D(T9WriteInputMethod);
- d->traceEnd(trace);
- return true;
-}
-
-bool T9WriteInputMethod::reselect(int cursorPosition, const QVirtualKeyboardInputEngine::ReselectFlags &reselectFlags)
-{
- Q_D(T9WriteInputMethod);
-
- if (d->sessionSettings.recognitionMode == scrMode)
- return false;
-
- QVirtualKeyboardInputContext *ic = inputContext();
- if (!ic)
- return false;
-
- const QVirtualKeyboardInputEngine::InputMode inputMode = inputEngine()->inputMode();
- const int maxLength = (inputMode == QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting ||
- inputMode == QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting ||
- inputMode == QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting) ? 0 : 32;
- const QString surroundingText = ic->surroundingText();
- int replaceFrom = 0;
-
- if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordBeforeCursor)) {
- for (int i = cursorPosition - 1; i >= 0 && d->stringStart.length() < maxLength; --i) {
- QChar c = surroundingText.at(i);
- if (!d->isValidInputChar(c))
- break;
- d->stringStart.insert(0, c);
- --replaceFrom;
- }
-
- while (replaceFrom < 0 && d->isJoiner(d->stringStart.at(0))) {
- d->stringStart.remove(0, 1);
- ++replaceFrom;
- }
- }
-
- if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == 0) {
- d->stringStart.clear();
- return false;
- }
-
- if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAfterCursor)) {
- for (int i = cursorPosition; i < surroundingText.length() && d->stringStart.length() < maxLength; ++i) {
- QChar c = surroundingText.at(i);
- if (!d->isValidInputChar(c))
- break;
- d->stringStart.append(c);
- }
-
- while (replaceFrom > -d->stringStart.length()) {
- int lastPos = d->stringStart.length() - 1;
- if (!d->isJoiner(d->stringStart.at(lastPos)))
- break;
- d->stringStart.remove(lastPos, 1);
- }
- }
-
- if (d->stringStart.isEmpty())
- return false;
-
- if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == -d->stringStart.length() && d->stringStart.length() < maxLength) {
- d->stringStart.clear();
- return false;
- }
-
- if (d->isJoiner(d->stringStart.at(0))) {
- d->stringStart.clear();
- return false;
- }
-
- if (d->isJoiner(d->stringStart.at(d->stringStart.length() - 1))) {
- d->stringStart.clear();
- return false;
- }
-
- ic->setPreeditText(d->stringStart, QList<QInputMethodEvent::Attribute>(), replaceFrom, d->stringStart.length());
- for (int i = 0; i < d->stringStart.length(); ++i)
- d->caseFormatter.ensureLength(i + 1, d->stringStart.at(i).isUpper() ? QVirtualKeyboardInputEngine::TextCase::Upper : QVirtualKeyboardInputEngine::TextCase::Lower);
- d->wordCandidates.append(d->stringStart);
- d->activeWordIndex = 0;
- emit selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList);
- emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->activeWordIndex);
-
- return true;
-}
-
-void T9WriteInputMethod::timerEvent(QTimerEvent *timerEvent)
-{
- Q_D(T9WriteInputMethod);
- int timerId = timerEvent->timerId();
- qCDebug(lcT9Write) << "T9WriteInputMethod::timerEvent():" << timerId;
- if (timerId == d->resultTimer) {
- d->stopResultTimer();
-
- // Ignore if the result is not yet available
- if (d->resultId != d->lastResultId) {
- qCDebug(lcT9Write) << "T9WriteInputMethod::timerEvent(): Result not yet available";
- return;
- }
-
- if (d->sessionSettings.recognitionMode != scrMode) {
-#ifndef QT_VIRTUALKEYBOARD_RECORD_TRACE_INPUT
- // Don't clear traces in UCR mode if dictionary is loaded.
- // In UCR mode the whole purpose is to write the word with
- // one or few strokes.
- if (d->sessionSettings.recognitionMode == ucrMode) {
- const std::lock_guard<QRecursiveMutex> dictionaryGuard(d->dictionaryLock);
- if (d->attachedDictionary)
- return;
- }
-
- const QVirtualKeyboardInputEngine::InputMode inputMode = inputEngine()->inputMode();
- if (inputMode != QVirtualKeyboardInputEngine::InputMode::ChineseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::JapaneseHandwriting &&
- inputMode != QVirtualKeyboardInputEngine::InputMode::KoreanHandwriting) {
- d->clearTraces();
- }
-#endif
- } else {
- d->select();
- }
- }
-}
-
-void T9WriteInputMethod::dictionaryLoadCompleted(QSharedPointer<T9WriteDictionary> dictionary)
-{
- Q_D(T9WriteInputMethod);
- // Note: This method is called in worker thread context
- const std::lock_guard<QRecursiveMutex> dictionaryGuard(d->dictionaryLock);
-
- if (!dictionary)
- return;
-
- qCDebug(lcT9Write) << "T9WriteInputMethod::dictionaryLoadCompleted():"
- << dictionary->fileName() << dictionary->data() << dictionary->size();
-
- QVirtualKeyboardInputContext *ic = inputContext();
- if (ic && dictionary->fileName() == d->dictionaryFileName) {
- d->loadedDictionary = dictionary;
- if (d->sessionSettings.recognitionMode != scrMode &&
- !ic->inputMethodHints().testFlag(Qt::ImhNoPredictiveText) &&
- !d->attachedDictionary) {
- if (d->attachDictionary(d->loadedDictionary))
- d->attachedDictionary = d->loadedDictionary;
- }
- }
-}
-
-void T9WriteInputMethod::resultsAvailable(const QVariantList &resultList)
-{
-#ifdef SENSITIVE_DEBUG
- if (lcT9Write().isDebugEnabled()) {
- qCDebug(lcT9Write) << "T9WriteInputMethod::resultsAvailable():";
- for (int i = 0; i < resultList.size(); i++) {
- QVariantMap result = resultList.at(i).toMap();
- QString resultPrint = QStringLiteral("%1: ").arg(i + 1);
- QString resultChars = result.value(QLatin1String("chars")).toString();
- if (!resultChars.isEmpty())
- resultPrint.append(resultChars);
- if (result.contains(QLatin1String("gesture"))) {
- if (!resultChars.isEmpty())
- resultPrint.append(QLatin1String(", "));
- QString gesture = result[QLatin1String("gesture")].toString();
- resultPrint.append(QLatin1String("gesture ="));
- for (const QChar &chr : gesture) {
- resultPrint.append(QString::fromLatin1(" 0x%1").arg(chr.unicode(), 0, 16));
- }
- }
- qCDebug(lcT9Write) << resultPrint.toUtf8().constData();
- }
- }
-#endif
- Q_D(T9WriteInputMethod);
- QMutexLocker resultListGuard(&d->resultListLock);
- d->resultList = resultList;
- emit resultListChanged();
-}
-
-void T9WriteInputMethod::processResult()
-{
- Q_D(T9WriteInputMethod);
- bool resultTimerWasRunning = d->resultTimer != 0;
-
- d->processResult();
-
- // Restart the result timer now if it stopped before the results were completed
- if (!resultTimerWasRunning && (!d->scrResult.isEmpty() || !d->wordCandidates.isEmpty()))
- d->resetResultTimer(0);
-
-}
-
-void T9WriteInputMethod::recognitionError(int status)
-{
- qCDebug(lcT9Write) << "T9WriteInputMethod::recognitionError():" << status;
- reset();
-}
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
diff --git a/src/plugins/t9write/plugin/t9writeinputmethod_p.h b/src/plugins/t9write/plugin/t9writeinputmethod_p.h
deleted file mode 100644
index 39a0b2ac..00000000
--- a/src/plugins/t9write/plugin/t9writeinputmethod_p.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#ifndef T9WRITEINPUTMETHOD_P_H
-#define T9WRITEINPUTMETHOD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtVirtualKeyboard/qvirtualkeyboardabstractinputmethod.h>
-#include <QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-namespace QtVirtualKeyboard {
-
-class T9WriteInputMethodPrivate;
-class T9WriteDictionary;
-
-class T9WriteInputMethod : public QVirtualKeyboardAbstractInputMethod
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(T9WriteInputMethod)
-
-public:
- enum class EngineMode {
- Uninitialized,
- Alphabetic,
- Arabic,
- Hebrew,
- Thai,
- SimplifiedChinese,
- TraditionalChinese,
- HongKongChinese,
- Japanese,
- Korean
- };
- Q_ENUM(EngineMode)
-
- explicit T9WriteInputMethod(QObject *parent = nullptr);
- ~T9WriteInputMethod();
-
- QList<QVirtualKeyboardInputEngine::InputMode> inputModes(const QString &locale);
- bool setInputMode(const QString &locale, QVirtualKeyboardInputEngine::InputMode inputMode);
- bool setTextCase(QVirtualKeyboardInputEngine::TextCase textCase);
-
- bool keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers);
-
- void reset();
- void update();
-
- QList<QVirtualKeyboardSelectionListModel::Type> selectionLists();
- int selectionListItemCount(QVirtualKeyboardSelectionListModel::Type type);
- QVariant selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role);
- void selectionListItemSelected(QVirtualKeyboardSelectionListModel::Type type, int index);
-
- QList<QVirtualKeyboardInputEngine::PatternRecognitionMode> patternRecognitionModes() const;
- QVirtualKeyboardTrace *traceBegin(
- int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode,
- const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo);
- bool traceEnd(QVirtualKeyboardTrace *trace);
-
- bool reselect(int cursorPosition, const QVirtualKeyboardInputEngine::ReselectFlags &reselectFlags);
-
-signals:
- void resultListChanged();
-
-protected:
- void timerEvent(QTimerEvent *timerEvent);
-
-protected slots:
- void dictionaryLoadCompleted(QSharedPointer<T9WriteDictionary> dictionary);
- void resultsAvailable(const QVariantList &resultList);
- void processResult();
- void recognitionError(int status);
-
-private:
- QScopedPointer<T9WriteInputMethodPrivate> d_ptr;
-};
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/t9write/plugin/t9writeplugin.cpp b/src/plugins/t9write/plugin/t9writeplugin.cpp
deleted file mode 100644
index 25c1366f..00000000
--- a/src/plugins/t9write/plugin/t9writeplugin.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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 "t9writeplugin.h"
-#include "t9writeinputmethod_p.h"
-#include <QtQml>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QtVirtualKeyboard;
-
-void QtVirtualKeyboardT9WritePlugin::registerTypes(const char *uri) const
-{
- Q_INIT_RESOURCE(qmake_t9write_db);
- qmlRegisterType<T9WriteInputMethod>(uri, 2, 0, "HandwritingInputMethod");
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/t9write/plugin/t9writeplugin.h b/src/plugins/t9write/plugin/t9writeplugin.h
deleted file mode 100644
index 570aea46..00000000
--- a/src/plugins/t9write/plugin/t9writeplugin.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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 T9WRITEPLUGIN_H
-#define T9WRITEPLUGIN_H
-
-#include <QVirtualKeyboardExtensionPlugin>
-
-QT_BEGIN_NAMESPACE
-
-class QtVirtualKeyboardT9WritePlugin : public QVirtualKeyboardExtensionPlugin
-{
- Q_OBJECT
- Q_INTERFACES(QVirtualKeyboardExtensionPlugin)
- Q_PLUGIN_METADATA(IID QVirtualKeyboardExtensionPluginFactoryInterface_iid
- FILE "t9write.json")
-public:
- void registerTypes(const char *uri) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/t9write/plugin/t9writeworker.cpp b/src/plugins/t9write/plugin/t9writeworker.cpp
deleted file mode 100644
index 7ed1a4b7..00000000
--- a/src/plugins/t9write/plugin/t9writeworker.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#include "t9writeworker_p.h"
-#include <QLoggingCategory>
-
-#include <QFile>
-#include <QTime>
-
-QT_BEGIN_NAMESPACE
-namespace QtVirtualKeyboard {
-
-Q_DECLARE_LOGGING_CATEGORY(lcT9Write)
-
-/*!
- \class QtVirtualKeyboard::T9WriteTask
- \internal
-*/
-
-T9WriteTask::T9WriteTask(QObject *parent) :
- QObject(parent),
- decumaSession(nullptr),
- runSema()
-{
-}
-
-void T9WriteTask::wait()
-{
- runSema.acquire();
- runSema.release();
-}
-
-/*!
- \class QtVirtualKeyboard::T9WriteDictionaryTask
- \internal
-*/
-
-T9WriteDictionaryTask::T9WriteDictionaryTask(QSharedPointer<T9WriteDictionary> dictionary,
- const QString &dictionaryFileName,
- bool convertDictionary,
- const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo) :
- dictionary(dictionary),
- dictionaryFileName(dictionaryFileName),
- convertDictionary(convertDictionary),
- dictionaryInfo(dictionaryInfo)
-{
-}
-
-void T9WriteDictionaryTask::run()
-{
- qCDebug(lcT9Write) << "T9WriteDictionaryTask::run()";
-
- QTime perf;
- perf.start();
-
- bool result = false;
- if (dictionary) {
- result = dictionary->load(dictionaryFileName);
- if (result && convertDictionary)
- result = dictionary->convert(dictionaryInfo);
- }
-
- qCDebug(lcT9Write) << "T9WriteDictionaryTask::run(): time:" << perf.elapsed() << "ms";
-
- if (result)
- emit completed(dictionary);
-}
-
-T9WriteAddArcTask::T9WriteAddArcTask(QVirtualKeyboardTrace *trace) :
- trace(trace)
-{
-}
-
-void T9WriteAddArcTask::run()
-{
- QTime perf;
- perf.start();
- DECUMA_UINT32 arcID = (DECUMA_UINT32)trace->traceId();
- DECUMA_STATUS status = DECUMA_API(StartNewArc)(decumaSession, arcID);
- Q_ASSERT(status == decumaNoError);
- if (status != decumaNoError) {
- qCWarning(lcT9Write) << "T9WriteAddArcTask::run(): Failed to start new arc, status:" << status;
- return;
- }
-
- const QVariantList points = trace->points();
- Q_ASSERT(!points.isEmpty());
-
- for (const QVariant &p : points) {
- const QPoint pt(p.toPointF().toPoint());
- status = DECUMA_API(AddPoint)(decumaSession, (DECUMA_COORD)pt.x(),(DECUMA_COORD)pt.y(), arcID);
- if (status != decumaNoError) {
- qCWarning(lcT9Write) << "T9WriteAddArcTask::run(): Failed to add point, status:" << status;
- DECUMA_API(CancelArc)(decumaSession, arcID);
- return;
- }
- }
-
- status = DECUMA_API(CommitArc)(decumaSession, arcID);
- if (status != decumaNoError)
- qCWarning(lcT9Write) << "T9WriteAddArcTask::run(): Failed to commit arc, status:" << status;
- else
- qCDebug(lcT9Write) << "T9WriteAddArcTask::run(): time:" << perf.elapsed() << "ms";
-}
-
-/*!
- \class QtVirtualKeyboard::T9WriteRecognitionResult
- \internal
-*/
-
-T9WriteRecognitionResult::T9WriteRecognitionResult(int id, int maxResults, int maxCharsPerWord) :
- status(decumaNoError),
- numResults(0),
- instantGesture(0),
- id(id),
- maxResults(maxResults),
- maxCharsPerWord(maxCharsPerWord)
-{
- Q_ASSERT(maxResults > 0);
- Q_ASSERT(maxCharsPerWord > 0);
- results.resize(maxResults);
- int bufferLength = (maxCharsPerWord + 1);
- _chars.resize(maxResults * bufferLength);
- _symbolChars.resize(maxResults * bufferLength);
- _symbolStrokes.resize(maxResults * bufferLength);
- for (int i = 0; i < maxResults; i++) {
- DECUMA_HWR_RESULT &hwrResult = results[i];
- hwrResult.pChars = &_chars[i * bufferLength];
- hwrResult.pSymbolChars = &_symbolChars[i * bufferLength];
- hwrResult.pSymbolStrokes = &_symbolStrokes[i * bufferLength];
- }
-}
-
-/*!
- \class QtVirtualKeyboard::T9WriteRecognitionTask
- \internal
-*/
-
-T9WriteRecognitionTask::T9WriteRecognitionTask(QSharedPointer<T9WriteRecognitionResult> result,
- const DECUMA_INSTANT_GESTURE_SETTINGS &instantGestureSettings,
- BOOST_LEVEL boostLevel,
- const QString &stringStart) :
- T9WriteTask(),
- result(result),
- instantGestureSettings(instantGestureSettings),
- boostLevel(boostLevel),
- stringStart(stringStart),
- stateCancelled(false)
-{
-#ifdef SENSITIVE_DEBUG
- qCDebug(lcT9Write) << "T9WriteRecognitionTask():" << "boostLevel:" << boostLevel << "stringStart:" << stringStart;
-#endif
-}
-
-void T9WriteRecognitionTask::run()
-{
- if (!decumaSession)
- return;
-
- {
- QMutexLocker stateGuard(&stateLock);
- Q_UNUSED(stateGuard);
- if (stateCancelled)
- return;
- }
-
- //In a normal text composition case boostDictWords and canBeContinued are the preffered settings
- DECUMA_RECOGNITION_SETTINGS recSettings;
- memset(&recSettings, 0, sizeof(recSettings));
- recSettings.boostLevel = boostLevel;
- recSettings.stringCompleteness = canBeContinued;
- if (!stringStart.isEmpty())
- recSettings.pStringStart = (DECUMA_UNICODE *)stringStart.utf16();
-
- QTime perf;
- perf.start();
-
-#if SUPPORTS_ABORTRECOGNITION
- DECUMA_INTERRUPT_FUNCTIONS interruptFunctions;
- interruptFunctions.pShouldAbortRecognize = shouldAbortRecognize;
- interruptFunctions.pUserData = (void *)this;
- DECUMA_INTERRUPT_FUNCTIONS *pInterruptFunctions = &interruptFunctions;
-#else
- DECUMA_INTERRUPT_FUNCTIONS *pInterruptFunctions = nullptr;
-#endif
- result->status = DECUMA_API(Recognize)(decumaSession, result->results.data(), result->results.size(), &result->numResults, result->maxCharsPerWord, &recSettings, pInterruptFunctions);
- if (result->status != decumaNoError)
- qCWarning(lcT9Write) << "T9WriteRecognitionTask::run(): Recognition failed, status:" << result->status;
-
- int perfElapsed = perf.elapsed();
-
- {
- QMutexLocker stateGuard(&stateLock);
- Q_UNUSED(stateGuard);
- if (stateCancelled)
- result.reset();
- qCDebug(lcT9Write) << "T9WriteRecognitionTask::run(): time:" << perfElapsed << "ms" << (stateCancelled ? "(cancelled)" : "");
- }
-}
-
-int T9WriteRecognitionTask::shouldAbortRecognize(void *pUserData)
-{
- T9WriteRecognitionTask *pThis = (T9WriteRecognitionTask *)pUserData;
- QMutexLocker stateGuard(&pThis->stateLock);
- Q_UNUSED(stateGuard);
- return pThis->stateCancelled;
-}
-
-bool T9WriteRecognitionTask::cancelRecognition()
-{
- QMutexLocker stateGuard(&stateLock);
- Q_UNUSED(stateGuard);
- stateCancelled = true;
- return true;
-}
-
-int T9WriteRecognitionTask::resultId() const
-{
- return result != nullptr ? result->id : -1;
-}
-
-/*!
- \class QtVirtualKeyboard::T9WriteRecognitionResultsTask
- \internal
-*/
-
-T9WriteRecognitionResultsTask::T9WriteRecognitionResultsTask(QSharedPointer<T9WriteRecognitionResult> result) :
- T9WriteTask(),
- result(result)
-{
-}
-
-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++)
- {
- QVariantMap resultMap;
- QString resultString;
- QString gesture;
- const DECUMA_HWR_RESULT &hwrResult = result->results.at(i);
- resultString.reserve(hwrResult.nChars);
- QVariantList symbolStrokes;
- int charPos = 0;
- for (int symbolIndex = 0; symbolIndex < hwrResult.nSymbols; symbolIndex++) {
- int symbolLength = hwrResult.pSymbolChars[symbolIndex];
- QString symbol(QString::fromUtf16(&hwrResult.pChars[charPos], symbolLength));
- // Do not append gesture symbol to result string
- if (hwrResult.bGesture) {
- gesture = symbol.right(1);
- symbol.chop(1);
- }
- resultString.append(symbol);
- charPos += symbolLength;
- if (hwrResult.pSymbolStrokes)
- symbolStrokes.append(QVariant((int)hwrResult.pSymbolStrokes[symbolIndex]));
- }
-
- resultMap[QLatin1String("resultId")] = result->id;
- resultMap[QLatin1String("chars")] = resultString;
- resultMap[QLatin1String("symbolStrokes")] = symbolStrokes;
- if (!gesture.isEmpty())
- resultMap[QLatin1String("gesture")] = gesture;
-
- resultList.append(resultMap);
- }
-
- if (resultList.isEmpty())
- return;
-
- emit resultsAvailable(resultList);
-}
-
-/*!
- \class QtVirtualKeyboard::T9WriteWorker
- \internal
-*/
-
-T9WriteWorker::T9WriteWorker(DECUMA_SESSION *decumaSession, const bool cjk, QObject *parent) :
- QThread(parent),
- taskSema(),
- taskLock(),
- decumaSession(decumaSession),
- cjk(cjk)
-{
- abort = false;
-}
-
-T9WriteWorker::~T9WriteWorker()
-{
- abort = true;
- taskSema.release();
- wait();
-}
-
-void T9WriteWorker::addTask(QSharedPointer<T9WriteTask> task)
-{
- if (task) {
- QMutexLocker guard(&taskLock);
- task->moveToThread(this);
- taskList.append(task);
- taskSema.release();
- }
-}
-
-int T9WriteWorker::removeTask(QSharedPointer<T9WriteTask> task)
-{
- int count = 0;
- if (task) {
- QMutexLocker guard(&taskLock);
- count = taskList.removeAll(task);
- taskSema.acquire(qMin(count, taskSema.available()));
- }
- return count;
-}
-
-int T9WriteWorker::removeAllTasks()
-{
- QMutexLocker guard(&taskLock);
- int count = taskList.count();
- taskList.clear();
- if (taskSema.available())
- taskSema.acquire(taskSema.available());
- return count;
-}
-
-void T9WriteWorker::waitForAllTasks()
-{
- while (isRunning()) {
- idleSema.acquire();
- QMutexLocker guard(&taskLock);
- if (taskList.isEmpty()) {
- idleSema.release();
- break;
- }
- idleSema.release();
- }
-}
-
-int T9WriteWorker::numberOfPendingTasks()
-{
- QMutexLocker guard(&taskLock);
- return taskList.count() + (!idleSema.available() ? 1 : 0);
-}
-
-void T9WriteWorker::run()
-{
- while (!abort) {
- idleSema.release();
- taskSema.acquire();
- if (abort)
- break;
- idleSema.acquire();
- QSharedPointer<T9WriteTask> currentTask;
- {
- QMutexLocker guard(&taskLock);
- if (!taskList.isEmpty()) {
- currentTask = taskList.front();
- taskList.pop_front();
- }
- }
- if (currentTask) {
- currentTask->decumaSession = decumaSession;
- currentTask->cjk = cjk;
- currentTask->run();
- currentTask->runSema.release();
- }
- }
-}
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
diff --git a/src/plugins/t9write/plugin/t9writeworker_p.h b/src/plugins/t9write/plugin/t9writeworker_p.h
deleted file mode 100644
index 0cdb19a4..00000000
--- a/src/plugins/t9write/plugin/t9writeworker_p.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-#ifndef T9WRITEWORKER_H
-#define T9WRITEWORKER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtVirtualKeyboard/qvirtualkeyboardtrace.h>
-
-#include <QThread>
-#include <QSemaphore>
-#include <QMutex>
-#include <QStringList>
-#include <QSharedPointer>
-#include <QPointer>
-#include <QMap>
-#include <QList>
-
-#include "t9write_p.h"
-#include "t9writedictionary_p.h"
-
-QT_BEGIN_NAMESPACE
-namespace QtVirtualKeyboard {
-
-class T9WriteTask : public QObject
-{
- Q_OBJECT
-public:
- explicit T9WriteTask(QObject *parent = nullptr);
-
- virtual void run() = 0;
-
- void wait();
-
- friend class T9WriteWorker;
-
-protected:
- DECUMA_SESSION *decumaSession;
- bool cjk;
-
-private:
- QSemaphore runSema;
-};
-
-class T9WriteDictionaryTask : public T9WriteTask
-{
- Q_OBJECT
-public:
- explicit T9WriteDictionaryTask(QSharedPointer<T9WriteDictionary> dictionary,
- const QString &dictionaryFileName,
- bool convertDictionary,
- const DECUMA_SRC_DICTIONARY_INFO &dictionaryInfo);
-
- void run();
-
- QSharedPointer<T9WriteDictionary> dictionary;
- const QString dictionaryFileName;
- bool convertDictionary;
- const DECUMA_SRC_DICTIONARY_INFO dictionaryInfo;
-
-signals:
- void completed(QSharedPointer<T9WriteDictionary> dictionary);
-};
-
-class T9WriteAddArcTask : public T9WriteTask
-{
- Q_OBJECT
-public:
- explicit T9WriteAddArcTask(QVirtualKeyboardTrace *trace);
-
- void run();
-
-private:
- QVirtualKeyboardTrace *trace;
-};
-
-class T9WriteRecognitionResult
-{
- Q_DISABLE_COPY(T9WriteRecognitionResult)
-
-public:
- explicit T9WriteRecognitionResult(int id, int maxResults, int maxCharsPerWord);
-
- DECUMA_STATUS status;
- QList<DECUMA_HWR_RESULT> results;
- DECUMA_UINT16 numResults;
- int instantGesture;
- const int id;
- const int maxResults;
- const int maxCharsPerWord;
-
-private:
- QList<DECUMA_UNICODE> _chars;
- QList<DECUMA_INT16> _symbolChars;
- QList<DECUMA_INT16> _symbolStrokes;
-};
-
-class T9WriteRecognitionTask : public T9WriteTask
-{
- Q_OBJECT
-public:
- explicit T9WriteRecognitionTask(QSharedPointer<T9WriteRecognitionResult> result,
- const DECUMA_INSTANT_GESTURE_SETTINGS &instantGestureSettings,
- BOOST_LEVEL boostLevel,
- const QString &stringStart);
-
- void run();
- bool cancelRecognition();
- int resultId() const;
-
-private:
- static int shouldAbortRecognize(void *pUserData);
- friend int shouldAbortRecognize(void *pUserData);
-
-private:
- QSharedPointer<T9WriteRecognitionResult> result;
- DECUMA_INSTANT_GESTURE_SETTINGS instantGestureSettings;
- BOOST_LEVEL boostLevel;
- QString stringStart;
- QMutex stateLock;
- bool stateCancelled;
-};
-
-class T9WriteRecognitionResultsTask : public T9WriteTask
-{
- Q_OBJECT
-public:
- explicit T9WriteRecognitionResultsTask(QSharedPointer<T9WriteRecognitionResult> result);
-
- void run();
-
-signals:
- void resultsAvailable(const QVariantList &resultList);
- void recognitionError(int status);
-
-private:
- QSharedPointer<T9WriteRecognitionResult> result;
-};
-
-class T9WriteWorker : public QThread
-{
- Q_OBJECT
-public:
- explicit T9WriteWorker(DECUMA_SESSION *decumaSession, const bool cjk, QObject *parent = nullptr);
- ~T9WriteWorker();
-
- void addTask(QSharedPointer<T9WriteTask> task);
- int removeTask(QSharedPointer<T9WriteTask> task);
- int removeAllTasks();
- void waitForAllTasks();
- int numberOfPendingTasks();
-
- template <class X>
- int removeAllTasks() {
- QMutexLocker guard(&taskLock);
- int count = 0;
- for (int i = 0; i < taskList.size();) {
- QSharedPointer<X> task(taskList[i].objectCast<X>());
- if (task) {
- taskList.removeAt(i);
- ++count;
- } else {
- ++i;
- }
- }
- return count;
- }
-
-protected:
- void run();
-
-private:
- QList<QSharedPointer<T9WriteTask> > taskList;
- QSemaphore idleSema;
- QSemaphore taskSema;
- QMutex taskLock;
- DECUMA_SESSION *decumaSession;
- QBasicAtomicInt abort;
- const bool cjk;
-};
-
-} // namespace QtVirtualKeyboard
-QT_END_NAMESPACE
-
-#endif // T9WRITEWORKER_H
diff --git a/src/plugins/t9write/t9write.pro b/src/plugins/t9write/t9write.pro
deleted file mode 100644
index 5b59353a..00000000
--- a/src/plugins/t9write/t9write.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += \
- 3rdparty/t9write \
- plugin
-
-plugin.depends += 3rdparty/t9write