diff options
297 files changed, 4824 insertions, 2764 deletions
diff --git a/.cmake.conf b/.cmake.conf index 02aefcb2..dc1d7a92 100644 --- a/.cmake.conf +++ b/.cmake.conf @@ -1,2 +1,5 @@ -set(QT_REPO_MODULE_VERSION "6.5.0") +set(QT_REPO_MODULE_VERSION "6.8.0") set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1") +set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_AS_CONST=1") +list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_FOREACH=1") +list(APPEND QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_NO_CONTEXTLESS_CONNECT=1") diff --git a/CMakeLists.txt b/CMakeLists.txt index d0a974a0..b52481c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from qtvirtualkeyboard.pro. cmake_minimum_required(VERSION 3.16) @@ -14,7 +17,17 @@ project(QtVirtualKeyboard set(QT_USE_FIXED_QT_ADD_RESOURCE_BASE TRUE) find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) # special case -find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Qml QmlTools Quick Svg QuickTest QuickControls2) # special case +find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG + OPTIONAL_COMPONENTS + Qml + QmlTools + Quick + Svg + QuickTest + QuickControls2 + Multimedia +) +qt_internal_project_setup() if(NOT TARGET Qt::Quick) message(NOTICE "Skipping the build as the condition \"TARGET Qt::Quick\" is not met.") diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt new file mode 100644 index 00000000..b91bbd89 --- /dev/null +++ b/LICENSES/BSD-3-Clause.txt @@ -0,0 +1,9 @@ +Copyright (c) <year> <owner>. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/CerenceCommon.cmake b/cmake/CerenceCommon.cmake index ca9e36a4..875f988f 100644 --- a/cmake/CerenceCommon.cmake +++ b/cmake/CerenceCommon.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + if(NOT CERENCE_SDK_ROOT) if(INPUT_vkb_cerence_sdk) set(CERENCE_SDK_ROOT ${INPUT_vkb_cerence_sdk}) diff --git a/cmake/FindCerenceHwrAlphabetic.cmake b/cmake/FindCerenceHwrAlphabetic.cmake index 26724545..3c5e53a2 100644 --- a/cmake/FindCerenceHwrAlphabetic.cmake +++ b/cmake/FindCerenceHwrAlphabetic.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #[=======================================================================[.rst: FindCerenceHwrAlphabetic ------------------------ diff --git a/cmake/FindCerenceHwrCjk.cmake b/cmake/FindCerenceHwrCjk.cmake index 084cec2d..6b590295 100644 --- a/cmake/FindCerenceHwrCjk.cmake +++ b/cmake/FindCerenceHwrCjk.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #[=======================================================================[.rst: FindCerenceHwrCjk ----------------- diff --git a/cmake/FindCerenceXt9.cmake b/cmake/FindCerenceXt9.cmake index 5210f877..d91932ce 100644 --- a/cmake/FindCerenceXt9.cmake +++ b/cmake/FindCerenceXt9.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #[=======================================================================[.rst: FindCerenceXt9 -------------- diff --git a/cmake/FindHunspell.cmake b/cmake/FindHunspell.cmake index 8b588317..3cf22147 100644 --- a/cmake/FindHunspell.cmake +++ b/cmake/FindHunspell.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # We can't create the same interface imported target multiple times, CMake will complain if we do # that. This can happen if the find_package call is done in multiple different subdirectories. if(TARGET Hunspell::Hunspell) diff --git a/cmake/FindMyScript.cmake b/cmake/FindMyScript.cmake index c2c21e07..81f6d21d 100644 --- a/cmake/FindMyScript.cmake +++ b/cmake/FindMyScript.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #[=======================================================================[.rst: FindMyScript ------------ diff --git a/cmake/QtVirtualKeyboardSetup.cmake b/cmake/QtVirtualKeyboardSetup.cmake index 741897fd..e7aa254b 100644 --- a/cmake/QtVirtualKeyboardSetup.cmake +++ b/cmake/QtVirtualKeyboardSetup.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + get_filename_component(VKB_LAYOUTS_BASE "${CMAKE_CURRENT_LIST_DIR}/../src/layouts" REALPATH CACHE) set(VKB_LAYOUTS_PREFIX "/qt-project.org/imports/QtQuick/VirtualKeyboard/Layouts" CACHE STRING "" FORCE) diff --git a/coin/axivion/ci_config_linux.json b/coin/axivion/ci_config_linux.json new file mode 100644 index 00000000..4249f9b4 --- /dev/null +++ b/coin/axivion/ci_config_linux.json @@ -0,0 +1,46 @@ +{ + "Project": { + "BuildSystemIntegration": { + "child_order": [ + "GCCSetup", + "CMake", + "LinkLibraries" + ] + }, + "CMake": { + "_active": true, + "_copy_from": "CMakeIntegration", + "build_environment": {}, + "build_options": "-j4", + "generate_options": "--fresh", + "generator": "Ninja" + }, + "GCCSetup": { + "_active": true, + "_copy_from": "Command", + "build_command": "gccsetup --cc gcc --cxx g++ --config ../../../axivion/" + }, + "LinkLibraries": { + "_active": true, + "_copy_from": "AxivionLinker", + "input_files": [ + "build/lib/lib*.so*.ir", + "build/qml/*/*/lib*.so*.ir", + "build/qml/*/*/*/lib*.so*.ir", + "build/qml/*/*/*/*/lib*.so*.ir" + ], + "ir": "build/$(env:TESTED_MODULE_COIN).ir", + "plugin_files": [ + "build/plugins/*/lib*.so*.ir" + ] + } + }, + "_Format": "1.0", + "_Version": "7.6.2", + "_VersionNum": [ + 7, + 6, + 2, + 12725 + ] +} diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index df2ec3e4..00000000 --- a/conanfile.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2021 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -from conans import ConanFile -import re -from pathlib import Path - - -def _parse_qt_version_by_key(key: str) -> str: - with open(Path(__file__).parent.resolve() / ".cmake.conf") as f: - m = re.search(fr'{key} .*"(.*)"', f.read()) - return m.group(1) if m else "" - - -def _get_qt_minor_version() -> str: - return ".".join(_parse_qt_version_by_key("QT_REPO_MODULE_VERSION").split(".")[:2]) - - -class QtVirtualKeyboard(ConanFile): - name = "qtvirtualkeyboard" - license = "GPL-3.0+, Commercial Qt License Agreement" - author = "The Qt Company <https://www.qt.io/contact-us>" - url = "https://code.qt.io/cgit/qt/qtvirtualkeyboard.git" - description = ( - "The Qt Virtual Keyboard project provides an input framework and " - "reference keyboard frontend for Qt on Linux Desktop/X11, " - "Windows Desktop, and Boot2Qt targets." - ) - topics = "qt", "qt6", "input", "keyboard" - settings = "os", "compiler", "arch", "build_type" - # for referencing the version number and prerelease tag and dependencies info - exports = ".cmake.conf", "dependencies.yaml" - exports_sources = "*", "!conan*.*" - python_requires = f"qt-conan-common/{_get_qt_minor_version()}@qt/everywhere" - python_requires_extend = "qt-conan-common.QtLeafModule" diff --git a/config.tests/hunspell/CMakeLists.txt b/config.tests/hunspell/CMakeLists.txt index 4bb5b025..4aa35fa7 100644 --- a/config.tests/hunspell/CMakeLists.txt +++ b/config.tests/hunspell/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from hunspell.pro. cmake_minimum_required(VERSION 3.16) diff --git a/config.tests/hunspell/main.cpp b/config.tests/hunspell/main.cpp index 76f2cb3d..81ba797b 100644 --- a/config.tests/hunspell/main.cpp +++ b/config.tests/hunspell/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: BSD-3-Clause #include <hunspell/hunspell.h> diff --git a/configure.cmake b/configure.cmake index 53e3f110..68f54ce7 100644 --- a/configure.cmake +++ b/configure.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #### Inputs diff --git a/dependencies.yaml b/dependencies.yaml index b86eb287..b0ae33b8 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -1,13 +1,13 @@ dependencies: ../qtbase: - ref: d7068eaad7c180c814a766c91cebee25f04513a6 + ref: f1c6c66985d1ceda16b0f74e91f36b0df44daf58 required: true ../qtdeclarative: - ref: bfc9e70632048791f86b44b85df92ee05c937c90 + ref: 6083d39de9c003ffbb4b32fd8d5c9941479f3ad0 required: true ../qtmultimedia: - ref: b2fd76ab1763507f7aafc42fc8372075fb49b473 + ref: f0c05df41bc9624d1cd6159a180f5ddd8a84d9d9 required: false ../qtsvg: - ref: ff259509fa5d1cf6d1f4939e4dc70ce74cb73f19 + ref: cbef67469371d2e3f5e682928d5b61c1aa97c198 required: true diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 53719861..a4dd5c9b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + qt_examples_build_begin(EXTERNAL_BUILD) add_subdirectory(virtualkeyboard) diff --git a/examples/virtualkeyboard/CMakeLists.txt b/examples/virtualkeyboard/CMakeLists.txt index e04da6ad..8e52b3e0 100644 --- a/examples/virtualkeyboard/CMakeLists.txt +++ b/examples/virtualkeyboard/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + if(TARGET Qt::QuickControls2) qt_internal_add_example(basic) endif() diff --git a/examples/virtualkeyboard/basic/Basic.qml b/examples/virtualkeyboard/basic/Basic.qml index 35ac89cf..445b6738 100644 --- a/examples/virtualkeyboard/basic/Basic.qml +++ b/examples/virtualkeyboard/basic/Basic.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls @@ -117,4 +117,9 @@ Rectangle { anchors.fill: parent visible: handwritingInputPanelActive } + + Shortcut { + sequence: "Ctrl+Q" + onActivated: Qt.quit() + } } diff --git a/examples/virtualkeyboard/basic/CMakeLists.txt b/examples/virtualkeyboard/basic/CMakeLists.txt index 8be9b50d..dc52fbd1 100644 --- a/examples/virtualkeyboard/basic/CMakeLists.txt +++ b/examples/virtualkeyboard/basic/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + cmake_minimum_required(VERSION 3.16) project(basic LANGUAGES CXX) @@ -9,7 +12,10 @@ endif() set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/virtualkeyboard/basic") -find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick) +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick OPTIONAL_COMPONENTS Multimedia) +if(QT_FEATURE_static) + find_package(Qt6 REQUIRED COMPONENTS Svg) +endif() qt_add_executable(basic main.cpp @@ -27,6 +33,11 @@ target_link_libraries(basic PUBLIC Qt::Quick ) +if(TARGET Qt::Multimedia) + # See QTBUG-122607 + target_link_libraries(basic PRIVATE Qt::Multimedia) +endif() + # Resources: set(demo_resource_files "Basic.qml" @@ -48,10 +59,18 @@ qt6_add_resources(basic "demo" ) if(QT_FEATURE_static) - find_package(Qt6 REQUIRED COMPONENTS Svg) - target_link_libraries(basic PUBLIC + target_link_libraries(basic PRIVATE Qt::Svg ) + qt_import_plugins(basic + INCLUDE Qt::QVirtualKeyboardPlugin + ) +endif() + +if(ANDROID AND TARGET Qt::Multimedia) + qt_import_plugins(basic + INCLUDE Qt::QAndroidMediaPlugin + ) endif() if(NOT QT_FEATURE_vkb_desktop) diff --git a/examples/virtualkeyboard/basic/basic-b2qt.qml b/examples/virtualkeyboard/basic/basic-b2qt.qml index a2bb79a6..d23c7464 100644 --- a/examples/virtualkeyboard/basic/basic-b2qt.qml +++ b/examples/virtualkeyboard/basic/basic-b2qt.qml @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick // Deliberately imported after QtQuick to avoid missing restoreMode property in Binding. Fix in Qt 6. @@ -15,15 +15,15 @@ Item { Item { id: appContainer - width: Screen.orientation === Qt.LandscapeOrientation ? parent.width : parent.height - height: Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width + width: inLandscapeOrientation ? parent.width : parent.height + height: inLandscapeOrientation ? parent.height : parent.width anchors.centerIn: parent Basic { id: virtualKeyboard anchors.left: parent.left anchors.top: parent.top anchors.right: parent.right - anchors.bottom: parent.bottom + anchors.bottom: inputPanel.top handwritingInputPanelActive: handwritingInputPanel.available && handwritingInputPanel.active } @@ -83,12 +83,10 @@ Item { id: inputPanel z: 89 y: yPositionWhenHidden - x: Screen.orientation === Qt.LandscapeOrientation ? 0 : (parent.width-parent.height) / 2 - width: Screen.orientation === Qt.LandscapeOrientation ? parent.width : parent.height + x: 0 + width: parent.width - keyboard.shadowInputControl.height: (Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width) - keyboard.height - - property real yPositionWhenHidden: Screen.orientation === Qt.LandscapeOrientation ? parent.height : parent.width + (parent.height-parent.width) / 2 + property real yPositionWhenHidden: parent.height states: State { name: "visible" @@ -136,7 +134,8 @@ Item { } - property bool inLandscapeOrientation: Screen.orientation === Qt.LandscapeOrientation + property bool inLandscapeOrientation: Screen.primaryOrientation === Qt.LandscapeOrientation || + Screen.primaryOrientation === Qt.InvertedLandscapeOrientation Binding { target: appContainer.Window.window !== null ? appContainer.Window.window.contentItem : null diff --git a/examples/virtualkeyboard/basic/content/AutoScroller.qml b/examples/virtualkeyboard/basic/content/AutoScroller.qml index 3b2cdb3d..5f21dfd9 100644 --- a/examples/virtualkeyboard/basic/content/AutoScroller.qml +++ b/examples/virtualkeyboard/basic/content/AutoScroller.qml @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.VirtualKeyboard diff --git a/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml b/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml index d04a9ac9..e4878847 100644 --- a/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml +++ b/examples/virtualkeyboard/basic/content/HandwritingModeButton.qml @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick diff --git a/examples/virtualkeyboard/basic/content/TextArea.qml b/examples/virtualkeyboard/basic/content/TextArea.qml index 067bc843..6ff3e1c3 100644 --- a/examples/virtualkeyboard/basic/content/TextArea.qml +++ b/examples/virtualkeyboard/basic/content/TextArea.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls as Controls diff --git a/examples/virtualkeyboard/basic/content/TextField.qml b/examples/virtualkeyboard/basic/content/TextField.qml index 02c57334..7c398a82 100644 --- a/examples/virtualkeyboard/basic/content/TextField.qml +++ b/examples/virtualkeyboard/basic/content/TextField.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.Controls as Controls diff --git a/examples/virtualkeyboard/basic/main.cpp b/examples/virtualkeyboard/basic/main.cpp index 6b3b1565..e3d58bb6 100644 --- a/examples/virtualkeyboard/basic/main.cpp +++ b/examples/virtualkeyboard/basic/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #include <QQuickView> #include <QGuiApplication> diff --git a/licenseRule.json b/licenseRule.json new file mode 100644 index 00000000..623171cd --- /dev/null +++ b/licenseRule.json @@ -0,0 +1,89 @@ +[ + { + "comment" : ["file_pattern_ending: strings matched against the end of a file name.", + "location keys: regular expression matched against the beginning of", + "the file path (relative to the git submodule root).", + "spdx: list of SPDX-License-Expression's allowed in the matching files.", + "-------------------------------------------------------", + "Files with the following endings are Build System licensed,", + "unless they are examples", + "Files with other endings can also be build system files" + ], + "file_pattern_ending" : ["CMakeLists.txt", ".cmake", ".pro", ".pri", ".prf", + "configure", "configure.bat", "cmake.in", "plist.in", "CMakeLists.txt.in"], + "location" : { + "" : { + "comment" : "Default", + "file type" : "build system", + "spdx" : ["BSD-3-Clause"] + }, + "(.*)(examples/|snippets/)" : { + "comment" : "Example takes precedence", + "file type" : "examples and snippets", + "spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"] + } + } + }, + { + "comments" : ["Files with the following endings are Tool licensed,", + "unless they are examples.", + "Files with other endings can also be tool files."], + "file_pattern_ending" : [".sh", ".py", ".pl", ".bat", ".ps1"], + "location" :{ + "" : { + "comment" : "Default", + "file type" : "tools and utils", + "spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"] + }, + "(.*)(examples/|snippets/)" : { + "comment" : "Example takes precedence", + "file type" : "examples and snippets", + "spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"] + } + } + }, + { + "comment" : "Files with the following endings are Documentation licensed.", + "file_pattern_ending" : [".qdoc", ".qdocinc" , ".qdocconf", ".txt", "README", "qt_attribution.json"], + "location" :{ + "" : { + "comment" : "", + "file type" : "documentation", + "spdx" : ["LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only"] + } + } + }, + { + "comment" : ["All other files", + "The licensing is defined only by the file location in the Qt module repository.", + "NO <file_pattern_ending> key for this case!", + "This needs to be the last entry of the file."], + "location" : { + "" : { + "comment" : "Default", + "file type" : "module and plugin", + "spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only"] + }, + "src/" : { + "comment" : "Default", + "file type" : "module and plugin", + "spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only"] + }, + "tests/" : { + "comment" : "Default", + "file type" : "test", + "spdx" : ["LicenseRef-Qt-Commercial OR GPL-3.0-only"] + }, + "(.*)(examples/|snippets/)" : { + "comment" : "Default", + "file type" : "examples and snippets", + "spdx" : ["LicenseRef-Qt-Commercial OR BSD-3-Clause"] + }, + "config\\.tests/" : { + "comment" : "Default", + "file type" : "build system", + "spdx" : ["BSD-3-Clause"] + } + } + } +] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cf6cac3..747defa4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,12 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from src.pro. add_subdirectory(virtualkeyboard) +add_subdirectory(settings) add_subdirectory(components) add_subdirectory(layouts) -add_subdirectory(settings) add_subdirectory(styles) add_subdirectory(plugin) add_subdirectory(plugins) diff --git a/src/components/BackspaceKey.qml b/src/components/BackspaceKey.qml index 3b37a6ae..cb018be0 100644 --- a/src/components/BackspaceKey.qml +++ b/src/components/BackspaceKey.qml @@ -20,7 +20,7 @@ import QtQuick.VirtualKeyboard BaseKey { key: Qt.Key_Backspace - keyType: QtVirtualKeyboard.BackspaceKey + keyType: QtVirtualKeyboard.KeyType.BackspaceKey repeat: true functionKey: true highlighted: true diff --git a/src/components/BaseKey.qml b/src/components/BaseKey.qml index bf31ccbe..1fb2dff4 100644 --- a/src/components/BaseKey.qml +++ b/src/components/BaseKey.qml @@ -28,9 +28,9 @@ Item { \l Key type for the specialized key. Possible values are defined by the {QtVirtualKeyboard::KeyType}{key type enumeration}. - For example, \l SpaceKey sets this value to \e QtVirtualKeyboard.SpaceKey. + For example, \l SpaceKey sets this value to \e QtVirtualKeyboard.KeyType.SpaceKey. */ - property int keyType: QtVirtualKeyboard.BaseKey + property int keyType: QtVirtualKeyboard.KeyType.BaseKey /*! Sets the key weight value which determines the relative size of the key. diff --git a/src/components/CMakeLists.txt b/src/components/CMakeLists.txt index 746dce26..4510bbcd 100644 --- a/src/components/CMakeLists.txt +++ b/src/components/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## VirtualKeyboard.Components Module: ##################################################################### @@ -52,4 +55,7 @@ qt_internal_add_qml_module(qtvkbcomponentsplugin Qt::Gui Qt::Qml Qt::Quick + Qt::VirtualKeyboard + Qt::VirtualKeyboardSettings + NO_GENERATE_CPP_EXPORTS ) diff --git a/src/components/ChangeLanguageKey.qml b/src/components/ChangeLanguageKey.qml index 2f59eb01..ad14bbe4 100644 --- a/src/components/ChangeLanguageKey.qml +++ b/src/components/ChangeLanguageKey.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.VirtualKeyboard +import QtQuick.VirtualKeyboard.Settings /*! \qmltype ChangeLanguageKey @@ -40,12 +41,13 @@ BaseKey { property bool customLayoutsOnly: false id: changeLanguageKey - keyType: QtVirtualKeyboard.ChangeLanguageKey + keyType: QtVirtualKeyboard.KeyType.ChangeLanguageKey objectName: "changeLanguageKey" functionKey: true highlighted: true displayText: keyboard.locale.split("_")[0] keyPanelDelegate: keyboard.style ? keyboard.style.languageKeyPanel : undefined - onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.ChangeLanguage, customLayoutsOnly) - enabled: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.ChangeLanguage, customLayoutsOnly) + onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.ChangeLanguage, customLayoutsOnly) + enabled: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.KeyboardFunction.ChangeLanguage, customLayoutsOnly) + visible: VirtualKeyboardSettings.visibleFunctionKeys & QtVirtualKeyboard.KeyboardFunctionKeys.Language } diff --git a/src/components/CharacterPreviewBubble.qml b/src/components/CharacterPreviewBubble.qml index 4819f371..8f09d465 100644 --- a/src/components/CharacterPreviewBubble.qml +++ b/src/components/CharacterPreviewBubble.qml @@ -27,10 +27,10 @@ Item { characterPreview.item.text = Qt.binding(function() { if (!activeKey) return "" - var displayText = (activeKey.keyType === QtVirtualKeyboard.FlickKey) ? activeKey.text : activeKey.displayText + var displayText = (activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) ? activeKey.text : activeKey.displayText return InputContext.uppercase ? displayText.toUpperCase() : displayText }) - if (activeKey.keyType === QtVirtualKeyboard.FlickKey) { + if (activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) { if (characterPreview.item.hasOwnProperty("flickLeft")) { characterPreview.item.flickLeft = activeKey.flickLeft characterPreview.item.flickRight = activeKey.flickRight diff --git a/src/components/EnterKey.qml b/src/components/EnterKey.qml index 17e2a109..39ef8599 100644 --- a/src/components/EnterKey.qml +++ b/src/components/EnterKey.qml @@ -23,7 +23,7 @@ BaseKey { */ readonly property int actionId: InputContext.priv.hasEnterKeyAction(InputContext.priv.inputItem) ? InputContext.priv.inputItem.EnterKeyAction.actionId : EnterKeyAction.None - keyType: QtVirtualKeyboard.EnterKey + keyType: QtVirtualKeyboard.KeyType.EnterKey text: "\n" displayText: InputContext.priv.hasEnterKeyAction(InputContext.priv.inputItem) ? InputContext.priv.inputItem.EnterKeyAction.label : "" key: Qt.Key_Return diff --git a/src/components/FillerKey.qml b/src/components/FillerKey.qml index 5187c2ef..54c400a5 100644 --- a/src/components/FillerKey.qml +++ b/src/components/FillerKey.qml @@ -18,6 +18,6 @@ import QtQuick.VirtualKeyboard */ BaseKey { - keyType: QtVirtualKeyboard.FillerKey + keyType: QtVirtualKeyboard.KeyType.FillerKey showPreview: false } diff --git a/src/components/FlickKey.qml b/src/components/FlickKey.qml index e6f2a2ae..e9afb492 100644 --- a/src/components/FlickKey.qml +++ b/src/components/FlickKey.qml @@ -39,7 +39,7 @@ Key { property string flickBottom: flickKeys.length > 3 ? flickKeys[3] : (flickKeys.length > 2 ? flickKeys[2] : "") property string flickRight: flickKeys.length > 3 ? flickKeys[2] : (flickKeys.length === 2 ? flickKeys[1] : "") - keyType: QtVirtualKeyboard.FlickKey + keyType: QtVirtualKeyboard.KeyType.FlickKey Component.onCompleted: { __key = key diff --git a/src/components/FunctionPopupList.qml b/src/components/FunctionPopupList.qml index 5f24a539..ed617656 100644 --- a/src/components/FunctionPopupList.qml +++ b/src/components/FunctionPopupList.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.VirtualKeyboard +import QtQuick.VirtualKeyboard.Settings Item { property bool active @@ -59,7 +60,7 @@ Item { target: backgroundLoader.item property: "view" value: listView - when: backgroundLoader.item !== null && backgroundLoader.item.hasOwnProperty("view") + when: backgroundLoader.item && backgroundLoader.item.hasOwnProperty("view") } } @@ -73,21 +74,23 @@ Item { function open(key, originX, originY) { listModel.clear() for (const keyboardFunction of [ - QtVirtualKeyboard.HideInputPanel, - QtVirtualKeyboard.ChangeLanguage, - QtVirtualKeyboard.ToggleHandwritingMode, + QtVirtualKeyboard.KeyboardFunction.HideInputPanel, + QtVirtualKeyboard.KeyboardFunction.ChangeLanguage, + QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode, ]) { - if (keyboard.isKeyboardFunctionAvailable(keyboardFunction)) { + const functionKey = InputContext.priv.keyboardFunctionKey(keyboardFunction) + if (keyboard.isKeyboardFunctionAvailable(keyboardFunction) && + !(VirtualKeyboardSettings.visibleFunctionKeys & functionKey)) { const listElement = { keyboardFunction: keyboardFunction } listModel.append(listElement) } } + listView.currentIndex = (listModel.count > 0) ? 0 : -1 origin = Qt.binding(function() { return Qt.point(Math.min(Math.max(0, originX), width - listView.width), originY) }) - listView.currentIndex = (listModel.count > 0) ? 0 : -1 active = listView.currentIndex !== -1 return active } diff --git a/src/components/HandwritingModeKey.qml b/src/components/HandwritingModeKey.qml index cdbca933..520f431d 100644 --- a/src/components/HandwritingModeKey.qml +++ b/src/components/HandwritingModeKey.qml @@ -22,12 +22,12 @@ import QtQuick.VirtualKeyboard */ Key { - keyType: QtVirtualKeyboard.HandwritingModeKey + keyType: QtVirtualKeyboard.KeyType.HandwritingModeKey key: Qt.Key_Context2 displayText: "HWR" functionKey: true highlighted: true - visible: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.ToggleHandwritingMode) - onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.ToggleHandwritingMode) + visible: keyboard.isKeyboardFunctionAvailable(QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode) + onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode) keyPanelDelegate: keyboard.style ? keyboard.style.handwritingKeyPanel : undefined } diff --git a/src/components/HideKeyboardKey.qml b/src/components/HideKeyboardKey.qml index 9a8a1537..bbf16b95 100644 --- a/src/components/HideKeyboardKey.qml +++ b/src/components/HideKeyboardKey.qml @@ -3,6 +3,7 @@ import QtQuick import QtQuick.VirtualKeyboard +import QtQuick.VirtualKeyboard.Settings /*! \qmltype HideKeyboardKey @@ -18,9 +19,10 @@ import QtQuick.VirtualKeyboard */ BaseKey { - keyType: QtVirtualKeyboard.HideKeyboardKey + keyType: QtVirtualKeyboard.KeyType.HideKeyboardKey functionKey: true highlighted: true - onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.HideInputPanel) + onClicked: keyboard.doKeyboardFunction(QtVirtualKeyboard.KeyboardFunction.HideInputPanel) keyPanelDelegate: keyboard.style ? keyboard.style.hideKeyPanel : undefined + visible: VirtualKeyboardSettings.visibleFunctionKeys & QtVirtualKeyboard.KeyboardFunctionKeys.Hide } diff --git a/src/components/InputModeKey.qml b/src/components/InputModeKey.qml index 7ca32f86..d51c8429 100644 --- a/src/components/InputModeKey.qml +++ b/src/components/InputModeKey.qml @@ -19,7 +19,7 @@ import QtQuick.VirtualKeyboard */ Key { - keyType: QtVirtualKeyboard.InputModeKey + keyType: QtVirtualKeyboard.KeyType.InputModeKey key: Qt.Key_Mode_switch noKeyEvent: true functionKey: true diff --git a/src/components/Key.qml b/src/components/Key.qml index c90fe11f..7005a30e 100644 --- a/src/components/Key.qml +++ b/src/components/Key.qml @@ -19,7 +19,7 @@ import QtQuick.VirtualKeyboard BaseKey { id: keyItem - keyType: QtVirtualKeyboard.Key + keyType: QtVirtualKeyboard.KeyType.Key key: !functionKey && text.length > 0 ? text.toUpperCase().charCodeAt(0) : Qt.Key_unknown keyPanelDelegate: keyboard.style ? keyboard.style.keyPanel : undefined } diff --git a/src/components/Keyboard.qml b/src/components/Keyboard.qml index 636b7535..45ca8dca 100644 --- a/src/components/Keyboard.qml +++ b/src/components/Keyboard.qml @@ -19,6 +19,12 @@ Item { property alias style: styleLoader.item property alias wordCandidateView: wordCandidateView property alias shadowInputControl: shadowInputControl + property alias alternativeKeys: alternativeKeys + property alias characterPreview: characterPreview + property alias wordCandidateContextMenu: wordCandidateContextMenu + property alias fullScreenModeSelectionControl: fullScreenModeSelectionControl + property alias naviationHighlight: naviationHighlight + property alias keyboardInputArea: keyboardInputArea property Item activeKey: null property TouchPoint activeTouchPoint property int localeIndex: -1 @@ -57,6 +63,9 @@ Item { readonly property bool languagePopupListActive: languagePopupList.enabled property alias soundEffect: soundEffect property alias keyboardLayoutLoader: keyboardLayoutLoader + property real screenHeight: parent.parent ? parent.parent.height : Screen.height + property bool noAnimations + property int pressAndHoldDelay: 500 function initDefaultInputMethod() { try { @@ -68,7 +77,7 @@ Item { Component.onCompleted: InputContext.priv.registerInputPanel(parent) width: keyboardBackground.width - height: keyboardBackground.height + (VirtualKeyboardSettings.wordCandidateList.alwaysVisible ? wordCandidateView.height : 0) + height: keyboardBackground.height onActiveChanged: { hideLanguagePopup() if (active && symbolMode && !preferNumbers) @@ -91,10 +100,6 @@ Item { if (!isValidLocale(localeIndex) || VirtualKeyboardSettings.locale) localeIndex = defaultLocaleIndex } - function onFullScreenModeChanged() { - wordCandidateView.disableAnimation = VirtualKeyboardSettings.fullScreenMode - keyboard.fullScreenMode = VirtualKeyboardSettings.fullScreenMode - } function onDefaultInputMethodDisabledChanged() { updateInputMethod() } @@ -206,22 +211,19 @@ Item { } } initialKey = keyboardInputArea.initialKey - if (!keyboardInputArea.navigateToNextKey(-1, 0, false)) { + if (!keyboardInputArea.navigateToNextKey(-1 * direction, 0, false)) { keyboardInputArea.initialKey = initialKey if (!keyboardInputArea.navigateToNextKey(0, -1 * direction, false)) { if (wordCandidateView.count) { - if (wordCandidateView.count) { - wordCandidateView.currentIndex = - wordCandidateView.effectiveLayoutDirection == Qt.LeftToRight ? - (wordCandidateView.count - 1) : 0 - break - } + wordCandidateView.currentIndex = + wordCandidateView.effectiveLayoutDirection == Qt.LeftToRight ? + (wordCandidateView.count - 1) : 0 break } keyboardInputArea.initialKey = initialKey keyboardInputArea.navigateToNextKey(0, -1 * direction, true) } - keyboardInputArea.navigateToNextKey(-1, 0, true) + keyboardInputArea.navigateToNextKey(-1 * direction, 0, true) } break case Qt.Key_Up: @@ -318,7 +320,7 @@ Item { } } initialKey = keyboardInputArea.initialKey - if (!keyboardInputArea.navigateToNextKey(1, 0, false)) { + if (!keyboardInputArea.navigateToNextKey(1 * direction, 0, false)) { keyboardInputArea.initialKey = initialKey if (!keyboardInputArea.navigateToNextKey(0, 1 * direction, false)) { if (wordCandidateView.count) { @@ -330,7 +332,7 @@ Item { keyboardInputArea.initialKey = initialKey keyboardInputArea.navigateToNextKey(0, 1 * direction, true) } - keyboardInputArea.navigateToNextKey(1, 0, true) + keyboardInputArea.navigateToNextKey(1 * direction, 0, true) } break case Qt.Key_Down: @@ -507,7 +509,7 @@ Item { } Timer { id: pressAndHoldTimer - interval: 500 + interval: keyboard.pressAndHoldDelay onTriggered: { if (keyboard.activeKey && keyboard.activeKey === keyboardInputArea.initialKey) { var origin = keyboard.mapFromItem(activeKey, activeKey.width / 2, 0) @@ -619,12 +621,8 @@ Item { } // Note: without "highlightItem.x - highlightItem.x" the binding does not work for alternativeKeys property var highlightItemOffset: highlightItem ? keyboard.mapFromItem(highlightItem, highlightItem.x - highlightItem.x, highlightItem.y - highlightItem.y) : ({x:0, y:0}) - property int moveDuration: 200 - property int resizeDuration: 200 - property alias xAnimation: xAnimation - property alias yAnimation: yAnimation - property alias widthAnimation: widthAnimation - property alias heightAnimation: heightAnimation + property int moveDuration: !keyboard.noAnimations ? 200 : 0 + property int resizeDuration: !keyboard.noAnimations ? 200 : 0 z: 2 x: highlightItemOffset.x y: highlightItemOffset.y @@ -653,8 +651,9 @@ Item { anchors.left: parent.left anchors.right: parent.right anchors.bottom: wordCandidateView.top - height: (keyboard.parent.parent ? keyboard.parent.parent.height : Screen.height) - - keyboard.height - (wordCandidateView.visibleCondition && !VirtualKeyboardSettings.wordCandidateList.alwaysVisible ? wordCandidateView.height : 0) + height: keyboard.screenHeight - + keyboard.height - + wordCandidateView.height visible: fullScreenMode && (shadowInputControlVisibleTimer.running || InputContext.animating) Connections { @@ -681,6 +680,7 @@ Item { } SelectionControl { + id: fullScreenModeSelectionControl objectName: "fullScreenModeSelectionControl" inputContext: InputContext.priv.shadow anchors.top: shadowInputControl.top @@ -693,13 +693,12 @@ Item { objectName: "wordCandidateView" clip: true z: -2 - property bool disableAnimation: VirtualKeyboardSettings.fullScreenMode property bool empty: true - readonly property bool visibleCondition: (((!wordCandidateView.empty || wordCandidateViewAutoHideTimer.running || shadowInputControl.visible) && + readonly property bool visibleCondition: (((!wordCandidateView.empty || wordCandidateViewAutoHideTimer.running) && InputContext.inputEngine.wordCandidateListVisibleHint) || VirtualKeyboardSettings.wordCandidateList.alwaysVisible) && - (keyboard.active || shadowInputControl.visible) - readonly property real visibleYOffset: VirtualKeyboardSettings.wordCandidateList.alwaysVisible ? 0 : -height - readonly property real currentYOffset: visibleCondition || wordCandidateViewTransition.running ? visibleYOffset : 0 + keyboard.active + readonly property real visibleYOffset: -height + readonly property real currentYOffset: visibleCondition ? visibleYOffset : 0 height: style ? style.selectionListHeight : 0 anchors.left: parent.left anchors.right: parent.right @@ -710,8 +709,8 @@ Item { highlight: style.selectionListHighlight ? style.selectionListHighlight : defaultHighlight highlightMoveDuration: 0 highlightResizeDuration: 0 - add: style.selectionListAdd - remove: style.selectionListRemove + add: !keyboard.noAnimations ? style.selectionListAdd : null + remove: !keyboard.noAnimations ? style.selectionListRemove : null keyNavigationWraps: true model: InputContext.inputEngine.wordCandidateListModel onCurrentItemChanged: if (currentItem) soundEffect.register(currentItem.soundEffect) @@ -750,18 +749,29 @@ Item { id: defaultHighlight Item {} } - states: State { - name: "visible" - when: wordCandidateView.visibleCondition - PropertyChanges { - target: wordCandidateView - y: wordCandidateView.visibleYOffset + states: [ + State { + name: "visible" + when: wordCandidateView.visibleCondition + PropertyChanges { + target: wordCandidateView + y: wordCandidateView.visibleYOffset + } + }, + State { + name: "alwaysVisible" + when: keyboard.fullScreenMode || VirtualKeyboardSettings.wordCandidateList.alwaysVisible + PropertyChanges { + target: wordCandidateView + y: wordCandidateView.visibleYOffset + } } - } + ] transitions: Transition { id: wordCandidateViewTransition + from: "" to: "visible" - enabled: !InputContext.animating && !VirtualKeyboardSettings.wordCandidateList.alwaysVisible && !wordCandidateView.disableAnimation + enabled: !InputContext.animating && !keyboard.noAnimations reversible: true ParallelAnimation { NumberAnimation { @@ -870,16 +880,22 @@ Item { target: keyboardLayoutLoader property: "source" value: keyboard.layout - when: keyboard.layout.length > 0 - restoreMode: Binding.RestoreBinding + when: keyboard.width > 0 && keyboard.layout.length > 0 + restoreMode: Binding.RestoreNone } onItemChanged: { + if (!item) + return + // Reset input mode if the new layout wants to override it - if (item && item.inputMode !== -1) + if (item.inputMode !== -1) inputModeNeedsReset = true - if (item) - notifyLayoutChanged() + + if (!InputContext.inputEngine.inputMethod) + updateInputMethod() + + notifyLayoutChanged() } MultiPointTouchArea { @@ -937,7 +953,7 @@ Item { if (keyboard.activeKey === activeKey) return if (keyboard.activeKey) { - if (keyboard.activeKey.keyType === QtVirtualKeyboard.FlickKey) + if (keyboard.activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) keyboard.activeKey.onKeyChanged.disconnect(onFlickKeyKeyChanged) keyboard.activeKey.active = false } @@ -1107,7 +1123,7 @@ Item { if (!initialKey) continue activeTouchPoint = touchPoints[i] - if (initialKey.keyType === QtVirtualKeyboard.FlickKey) { + if (initialKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) { initialKey.press(activeTouchPoint.x, activeTouchPoint.y) initialKey.onKeyChanged.connect(onFlickKeyKeyChanged) } else { @@ -1126,7 +1142,7 @@ Item { alternativeKeys.move(mapToItem(alternativeKeys, activeTouchPoint.x, 0).x) } else if (functionPopupList.active) { functionPopupList.move(mapToItem(functionPopupList, activeTouchPoint.x, activeTouchPoint.y)) - } else if (activeKey && activeKey.keyType === QtVirtualKeyboard.FlickKey) { + } else if (activeKey && activeKey.keyType === QtVirtualKeyboard.KeyType.FlickKey) { activeKey.update(activeTouchPoint.x, activeTouchPoint.y) } else { var key = null @@ -1200,8 +1216,8 @@ Item { model: languageListModel delegate: keyboard.style ? keyboard.style.languageListDelegate : null highlight: keyboard.style ? keyboard.style.languageListHighlight : defaultHighlight - add: keyboard.style ? keyboard.style.languageListAdd : null - remove: keyboard.style ? keyboard.style.languageListRemove : null + add: keyboard.style && !keyboard.noAnimations ? keyboard.style.languageListAdd : null + remove: keyboard.style && !keyboard.noAnimations ? keyboard.style.languageListRemove : null property rect previewRect: Qt.rect(keyboard.x + languagePopupList.x, keyboard.y + languagePopupList.y, languagePopupList.width, @@ -1250,7 +1266,10 @@ Item { } languagePopupList.positionViewAtIndex(languagePopupList.currentIndex, ListView.Center) if (parentItem) { - languagePopupList.anchors.leftMargin = Qt.binding(function() {return Math.round(keyboard.mapFromItem(parentItem, (parentItem.width - languagePopupList.width) / 2, 0).x)}) + languagePopupList.anchors.leftMargin = Qt.binding(function() { + const newLeftMargin = Math.round(keyboard.mapFromItem(parentItem, (parentItem.width - languagePopupList.width) / 2, 0).x) + return Math.min(Math.max(0, newLeftMargin), keyboard.width - languagePopupList.width) + }) languagePopupList.anchors.topMargin = Qt.binding(function() {return Math.round(keyboard.mapFromItem(parentItem, 0, -languagePopupList.height).y)}) } else { languagePopupList.anchors.leftMargin = Qt.binding(function() {return Math.round((keyboard.width - languagePopupList.width) / 2)}) @@ -1294,7 +1313,7 @@ Item { anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom - height: keyboard.parent.parent ? keyboard.parent.parent.height : Screen.height + height: keyboard.screenHeight onPressed: keyboard.hideWordCandidateContextMenu() enabled: wordCandidateContextMenuList.enabled } @@ -1762,10 +1781,10 @@ Item { if (!isKeyboardFunctionAvailable(keyboardFunction)) return switch (keyboardFunction) { - case QtVirtualKeyboard.HideInputPanel: + case QtVirtualKeyboard.KeyboardFunction.HideInputPanel: InputContext.priv.hideInputPanel() break - case QtVirtualKeyboard.ChangeLanguage: + case QtVirtualKeyboard.KeyboardFunction.ChangeLanguage: if (style.languagePopupListEnabled) { if (!languagePopupListActive) { showLanguagePopup(activeKey, false) @@ -1777,7 +1796,7 @@ Item { changeInputLanguage(customLayoutsOnly) } break - case QtVirtualKeyboard.ToggleHandwritingMode: + case QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode: setHandwritingMode(!handwritingMode) break default: @@ -1788,15 +1807,22 @@ Item { function isKeyboardFunctionAvailable(keyboardFunction) { switch (keyboardFunction) { - case QtVirtualKeyboard.HideInputPanel: + case QtVirtualKeyboard.KeyboardFunction.HideInputPanel: return true - case QtVirtualKeyboard.ChangeLanguage: + case QtVirtualKeyboard.KeyboardFunction.ChangeLanguage: const customLayoutsOnly = arguments.length == 2 && arguments[1] return canChangeInputLanguage(customLayoutsOnly) - case QtVirtualKeyboard.ToggleHandwritingMode: + case QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode: return isHandwritingAvailable() default: return false } } + + function isFunctionPopupListAvailable() { + const allFunctionKeys = QtVirtualKeyboard.KeyboardFunctionKeys.Hide | + QtVirtualKeyboard.KeyboardFunctionKeys.Language + return (VirtualKeyboardSettings.visibleFunctionKeys & allFunctionKeys) !== allFunctionKeys || + isHandwritingAvailable() + } } diff --git a/src/components/ModeKey.qml b/src/components/ModeKey.qml index aaec44f5..63134c13 100644 --- a/src/components/ModeKey.qml +++ b/src/components/ModeKey.qml @@ -33,7 +33,7 @@ Key { The default is false. */ property bool mode - keyType: QtVirtualKeyboard.ModeKey + keyType: QtVirtualKeyboard.KeyType.ModeKey noKeyEvent: true functionKey: true highlighted: true diff --git a/src/components/NumberKey.qml b/src/components/NumberKey.qml index 6e3b07db..2a55d824 100644 --- a/src/components/NumberKey.qml +++ b/src/components/NumberKey.qml @@ -21,5 +21,5 @@ import QtQuick.VirtualKeyboard Key { showPreview: false - keyType: QtVirtualKeyboard.NumberKey + keyType: QtVirtualKeyboard.KeyType.NumberKey } diff --git a/src/components/PopupList.qml b/src/components/PopupList.qml index bdf0c70c..56f45187 100644 --- a/src/components/PopupList.qml +++ b/src/components/PopupList.qml @@ -20,8 +20,8 @@ ListView { highlight: keyboard.style.popupListHighlight ? keyboard.style.popupListHighlight : defaultHighlight highlightMoveDuration: 0 highlightResizeDuration: 0 - add: keyboard.style.popupListAdd - remove: keyboard.style.popupListRemove + add: !keyboard.noAnimations ? keyboard.style.popupListAdd : null + remove: !keyboard.noAnimations ? keyboard.style.popupListRemove : null keyNavigationWraps: true onCurrentItemChanged: if (currentItem) keyboard.soundEffect.register(currentItem.soundEffect) diff --git a/src/components/ShadowInputControl.qml b/src/components/ShadowInputControl.qml index aa9b8e31..064a93fa 100644 --- a/src/components/ShadowInputControl.qml +++ b/src/components/ShadowInputControl.qml @@ -9,6 +9,7 @@ import QtQuick.VirtualKeyboard.Settings Item { id: control + property alias textEdit: shadowInput enabled: keyboard.active && VirtualKeyboardSettings.fullScreenMode @@ -68,7 +69,8 @@ Item { onCursorPositionChanged: { cursorSyncTimer.restart() blinkStatus = true - cursorTimer.restart() + if (cursorTimer.running) + cursorTimer.restart() } onSelectionStartChanged: cursorSyncTimer.restart() onSelectionEndChanged: cursorSyncTimer.restart() @@ -97,7 +99,7 @@ Item { id: cursorTimer interval: Qt.styleHints.cursorFlashTime / 2 repeat: true - running: true + running: control.visible onTriggered: shadowInput.blinkStatus = !shadowInput.blinkStatus } } @@ -105,11 +107,23 @@ Item { } } - Binding { + Component.onCompleted: { + if (VirtualKeyboardSettings.fullScreenMode) { + InputContext.priv.shadow.inputItem = shadowInput + } + } + Connections { + target: VirtualKeyboardSettings + function onFullScreenModeChanged() { + InputContext.priv.shadow.inputItem = VirtualKeyboardSettings.fullScreenMode ? shadowInput : null + } + } + Connections { target: InputContext.priv.shadow - property: "inputItem" - value: shadowInput - when: VirtualKeyboardSettings.fullScreenMode - restoreMode: Binding.RestoreBinding + function onInputItemChanged() { + cursorSyncTimer.stop() + if (!InputContext.priv.shadow.inputItem) + shadowInput.clear() + } } } diff --git a/src/components/ShiftKey.qml b/src/components/ShiftKey.qml index 76fdc3fa..a2623395 100644 --- a/src/components/ShiftKey.qml +++ b/src/components/ShiftKey.qml @@ -19,7 +19,7 @@ import QtQuick.VirtualKeyboard BaseKey { id: shiftKey - keyType: QtVirtualKeyboard.ShiftKey + keyType: QtVirtualKeyboard.KeyType.ShiftKey key: Qt.Key_Shift enabled: InputContext.priv.shiftHandler.toggleShiftEnabled highlighted: true diff --git a/src/components/SpaceKey.qml b/src/components/SpaceKey.qml index 73d41c37..d8313a6c 100644 --- a/src/components/SpaceKey.qml +++ b/src/components/SpaceKey.qml @@ -18,7 +18,7 @@ import QtQuick.VirtualKeyboard */ Key { - keyType: QtVirtualKeyboard.SpaceKey + keyType: QtVirtualKeyboard.KeyType.SpaceKey text: " " displayText: "" repeat: true diff --git a/src/components/SymbolModeKey.qml b/src/components/SymbolModeKey.qml index 1aa24c4d..662ce8ac 100644 --- a/src/components/SymbolModeKey.qml +++ b/src/components/SymbolModeKey.qml @@ -18,7 +18,7 @@ import QtQuick.VirtualKeyboard */ Key { - keyType: QtVirtualKeyboard.SymbolModeKey + keyType: QtVirtualKeyboard.KeyType.SymbolModeKey key: Qt.Key_Context1 displayText: "&123" functionKey: true diff --git a/src/layouts/CMakeLists.txt b/src/layouts/CMakeLists.txt index 33d1de9a..0a64ff97 100644 --- a/src/layouts/CMakeLists.txt +++ b/src/layouts/CMakeLists.txt @@ -1,9 +1,13 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_qml_module(qtvkblayoutsplugin URI "QtQuick.VirtualKeyboard.Layouts" VERSION "${PROJECT_VERSION}" PAST_MAJOR_VERSIONS 2 1 PLUGIN_TARGET qtvkblayoutsplugin NO_PLUGIN_OPTIONAL + NO_GENERATE_CPP_EXPORTS ) set(LAYOUT_FILES diff --git a/src/layouts/ar_AR/digits.qml b/src/layouts/ar_AR/digits.qml index 502269cb..3b9788a2 100644 --- a/src/layouts/ar_AR/digits.qml +++ b/src/layouts/ar_AR/digits.qml @@ -75,11 +75,14 @@ KeyboardLayout { text: "\u0663" alternativeKeys: "\u06633" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { customLayoutsOnly: true + visible: true } Key { key: 0x0660 diff --git a/src/layouts/ar_AR/handwriting.qml b/src/layouts/ar_AR/handwriting.qml index abd5524d..e93dfab7 100644 --- a/src/layouts/ar_AR/handwriting.qml +++ b/src/layouts/ar_AR/handwriting.qml @@ -15,61 +15,60 @@ KeyboardLayout { readonly property bool alphabeticInputMode: [InputEngine.InputMode.Latin, InputEngine.InputMode.Dialable].indexOf(InputContext.inputEngine.inputMode) !== -1 KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - alphabeticInputMode ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + inputModeNameList: [ + "ABC", // InputEngine.InputMode.Latin + "\u0660\u0661\u0662", // InputEngine.InputMode.Numeric + "123", // InputEngine.InputMode.Dialable + "", // InputEngine.InputMode.Pinyin + "", // InputEngine.InputMode.Cangjie + "", // InputEngine.InputMode.Zhuyin + "", // InputEngine.InputMode.Hangul + "", // InputEngine.InputMode.Hiragana + "", // InputEngine.InputMode.Katakana + "", // InputEngine.InputMode.FullwidthLatin + "", // InputEngine.InputMode.Greek + "", // InputEngine.InputMode.Cyrillic + "\u0623\u200C\u0628\u200C\u062C", // InputEngine.InputMode.Arabic + ] + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - inputModeNameList: [ - "ABC", // InputEngine.InputMode.Latin - "\u0660\u0661\u0662", // InputEngine.InputMode.Numeric - "123", // InputEngine.InputMode.Dialable - "", // InputEngine.InputMode.Pinyin - "", // InputEngine.InputMode.Cangjie - "", // InputEngine.InputMode.Zhuyin - "", // InputEngine.InputMode.Hangul - "", // InputEngine.InputMode.Hiragana - "", // InputEngine.InputMode.Katakana - "", // InputEngine.InputMode.FullwidthLatin - "", // InputEngine.InputMode.Greek - "", // InputEngine.InputMode.Cyrillic - "\u0623\u200C\u0628\u200C\u062C", // InputEngine.InputMode.Arabic - ] - } - Key { - key: Qt.Key_Comma - text: alphabeticInputMode ? "," : "\u060C" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: alphabeticInputMode ? "#%&*/\\\"'=+-_:;,.?!<>()" : "#%&*/\\\"'=+-_:\u061B.\u061F!<>()" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + alphabeticInputMode ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: alphabeticInputMode ? "#%&*/\\\"'=+-_:;,.?!<>() " : "#%&*/\\\"'=+-_:\u061B\u060C.\u061F!<>() " + smallText: alphabeticInputMode ? "!?" : "\u061F!" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/ar_AR/main.qml b/src/layouts/ar_AR/main.qml index 8eb738f4..d31bd2cc 100644 --- a/src/layouts/ar_AR/main.qml +++ b/src/layouts/ar_AR/main.qml @@ -170,13 +170,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -189,6 +193,10 @@ KeyboardLayout { alternativeKeys: "!,\u060C\u061B.\u061F" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ar_AR/numbers.qml b/src/layouts/ar_AR/numbers.qml index 5477330b..a9dec1f8 100644 --- a/src/layouts/ar_AR/numbers.qml +++ b/src/layouts/ar_AR/numbers.qml @@ -147,11 +147,14 @@ KeyboardLayout { text: "\u0663" alternativeKeys: "\u06633" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { customLayoutsOnly: true + visible: true } Key { key: 0x0660 diff --git a/src/layouts/ar_AR/symbols.qml b/src/layouts/ar_AR/symbols.qml index f7e95ea0..a28a96e8 100644 --- a/src/layouts/ar_AR/symbols.qml +++ b/src/layouts/ar_AR/symbols.qml @@ -162,13 +162,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0623\u200C\u0628\u200C\u062C" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -329,13 +333,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0623\u200C\u0628\u200C\u062C" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { diff --git a/src/layouts/bg_BG/handwriting.qml b/src/layouts/bg_BG/handwriting.qml index 0c4f5847..3a75a2ce 100644 --- a/src/layouts/bg_BG/handwriting.qml +++ b/src/layouts/bg_BG/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/bg_BG/main.qml b/src/layouts/bg_BG/main.qml index dbdd7b31..d2d6ed67 100644 --- a/src/layouts/bg_BG/main.qml +++ b/src/layouts/bg_BG/main.qml @@ -125,13 +125,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -151,6 +155,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -320,13 +328,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -347,6 +359,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/cs_CZ/handwriting.fallback b/src/layouts/cs_CZ/handwriting.fallback new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/layouts/cs_CZ/handwriting.fallback diff --git a/src/layouts/cs_CZ/handwriting.qml b/src/layouts/cs_CZ/handwriting.qml deleted file mode 100644 index f1ca6300..00000000 --- a/src/layouts/cs_CZ/handwriting.qml +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.VirtualKeyboard -import QtQuick.VirtualKeyboard.Components - -KeyboardLayout { - function createInputMethod() { - return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) - } - sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin - - KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 - } - } -} diff --git a/src/layouts/cs_CZ/main.qml b/src/layouts/cs_CZ/main.qml index c31ed7b4..fbc3df33 100644 --- a/src/layouts/cs_CZ/main.qml +++ b/src/layouts/cs_CZ/main.qml @@ -164,13 +164,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -185,6 +189,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/da_DK/main.qml b/src/layouts/da_DK/main.qml index e3b04cf8..4fa091fa 100644 --- a/src/layouts/da_DK/main.qml +++ b/src/layouts/da_DK/main.qml @@ -165,13 +165,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -186,6 +190,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/de_DE/main.qml b/src/layouts/de_DE/main.qml index b14c3eef..729d8111 100644 --- a/src/layouts/de_DE/main.qml +++ b/src/layouts/de_DE/main.qml @@ -160,13 +160,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -181,6 +185,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/el_GR/handwriting.qml b/src/layouts/el_GR/handwriting.qml index 6fb698de..43f10410 100644 --- a/src/layouts/el_GR/handwriting.qml +++ b/src/layouts/el_GR/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Greek ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Greek ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/el_GR/main.qml b/src/layouts/el_GR/main.qml index cc52bed0..fce6d15a 100644 --- a/src/layouts/el_GR/main.qml +++ b/src/layouts/el_GR/main.qml @@ -136,13 +136,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -162,6 +166,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -331,13 +339,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -357,6 +369,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/es_ES/handwriting.qml b/src/layouts/es_ES/handwriting.qml index b2914924..038933b7 100644 --- a/src/layouts/es_ES/handwriting.qml +++ b/src/layouts/es_ES/handwriting.qml @@ -11,46 +11,44 @@ KeyboardLayout { return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.¿?¡!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.¿?¡! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/es_ES/main.qml b/src/layouts/es_ES/main.qml index 959dbb43..8f5b6be0 100644 --- a/src/layouts/es_ES/main.qml +++ b/src/layouts/es_ES/main.qml @@ -149,13 +149,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -170,6 +174,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/es_ES/symbols.qml b/src/layouts/es_ES/symbols.qml index e0504866..3c89d487 100644 --- a/src/layouts/es_ES/symbols.qml +++ b/src/layouts/es_ES/symbols.qml @@ -151,13 +151,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -169,6 +173,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -316,13 +324,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? "АБВ" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -334,6 +346,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/es_MX/handwriting.qml b/src/layouts/es_MX/handwriting.qml index b2914924..038933b7 100644 --- a/src/layouts/es_MX/handwriting.qml +++ b/src/layouts/es_MX/handwriting.qml @@ -11,46 +11,44 @@ KeyboardLayout { return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) } sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.¿?¡!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.¿?¡! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/es_MX/main.qml b/src/layouts/es_MX/main.qml index 959dbb43..8f5b6be0 100644 --- a/src/layouts/es_MX/main.qml +++ b/src/layouts/es_MX/main.qml @@ -149,13 +149,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -170,6 +174,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/es_MX/symbols.qml b/src/layouts/es_MX/symbols.qml index dccb2f43..ee119d83 100644 --- a/src/layouts/es_MX/symbols.qml +++ b/src/layouts/es_MX/symbols.qml @@ -151,13 +151,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -169,6 +173,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -316,13 +324,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? "АБВ" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -334,6 +346,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/et_EE/main.qml b/src/layouts/et_EE/main.qml index 3852506f..bebb17b9 100644 --- a/src/layouts/et_EE/main.qml +++ b/src/layouts/et_EE/main.qml @@ -162,13 +162,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -183,6 +187,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fa_FA/digits.qml b/src/layouts/fa_FA/digits.qml index 3598312c..05046448 100644 --- a/src/layouts/fa_FA/digits.qml +++ b/src/layouts/fa_FA/digits.qml @@ -66,7 +66,9 @@ KeyboardLayout { text: "\u06F3" alternativeKeys: "\u06F33" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { diff --git a/src/layouts/fa_FA/handwriting.qml b/src/layouts/fa_FA/handwriting.qml index 4653f60a..d75a4b03 100644 --- a/src/layouts/fa_FA/handwriting.qml +++ b/src/layouts/fa_FA/handwriting.qml @@ -15,61 +15,60 @@ KeyboardLayout { readonly property bool alphabeticInputMode: [InputEngine.InputMode.Latin, InputEngine.InputMode.Dialable].indexOf(InputContext.inputEngine.inputMode) !== -1 KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - alphabeticInputMode ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + inputModeNameList: [ + "ABC", // InputEngine.InputMode.Latin + "\u0660\u0661\u0662", // InputEngine.InputMode.Numeric + "123", // InputEngine.InputMode.Dialable + "", // InputEngine.InputMode.Pinyin + "", // InputEngine.InputMode.Cangjie + "", // InputEngine.InputMode.Zhuyin + "", // InputEngine.InputMode.Hangul + "", // InputEngine.InputMode.Hiragana + "", // InputEngine.InputMode.Katakana + "", // InputEngine.InputMode.FullwidthLatin + "", // InputEngine.InputMode.Greek + "", // InputEngine.InputMode.Cyrillic + "\u0627\u200C\u0628\u200C\u067E", // InputEngine.InputMode.Arabic + ] + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - inputModeNameList: [ - "ABC", // InputEngine.InputMode.Latin - "\u0660\u0661\u0662", // InputEngine.InputMode.Numeric - "123", // InputEngine.InputMode.Dialable - "", // InputEngine.InputMode.Pinyin - "", // InputEngine.InputMode.Cangjie - "", // InputEngine.InputMode.Zhuyin - "", // InputEngine.InputMode.Hangul - "", // InputEngine.InputMode.Hiragana - "", // InputEngine.InputMode.Katakana - "", // InputEngine.InputMode.FullwidthLatin - "", // InputEngine.InputMode.Greek - "", // InputEngine.InputMode.Cyrillic - "\u0627\u200C\u0628\u200C\u067E", // InputEngine.InputMode.Arabic - ] - } - Key { - key: Qt.Key_Comma - text: alphabeticInputMode ? "," : "\u060C" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: alphabeticInputMode ? "#%&*/\\\"'=+-_:;,.?!<>()" : "#%&*/\\\"'=+-_:\u061B.\u061F!<>()" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + alphabeticInputMode ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: alphabeticInputMode ? "#%&*/\\\"'=+-_:;,.?!<>() " : "#%&*/\\\"'=+-_:\u061B\u060C.\u061F!<>() " + smallText: alphabeticInputMode ? "!?" : "\u061F!" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/fa_FA/main.qml b/src/layouts/fa_FA/main.qml index 54447107..7f865fb9 100644 --- a/src/layouts/fa_FA/main.qml +++ b/src/layouts/fa_FA/main.qml @@ -137,13 +137,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -156,6 +160,10 @@ KeyboardLayout { alternativeKeys: "!,\u060C\u061B.\u061F" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fa_FA/numbers.qml b/src/layouts/fa_FA/numbers.qml index 342996b2..98178d61 100644 --- a/src/layouts/fa_FA/numbers.qml +++ b/src/layouts/fa_FA/numbers.qml @@ -138,11 +138,14 @@ KeyboardLayout { text: "\u06F3" alternativeKeys: "\u06F33" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { customLayoutsOnly: true + visible: true } Key { text: "\u06F0" diff --git a/src/layouts/fa_FA/symbols.qml b/src/layouts/fa_FA/symbols.qml index e134fc9e..407542fe 100644 --- a/src/layouts/fa_FA/symbols.qml +++ b/src/layouts/fa_FA/symbols.qml @@ -152,13 +152,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0627\u200C\u0628\u200C\u067E" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -171,6 +175,10 @@ KeyboardLayoutLoader { alternativeKeys: "!,\u060C." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -319,13 +327,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0627\u200C\u0628\u200C\u067E" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u060C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -337,6 +349,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fallback/dialpad.qml b/src/layouts/fallback/dialpad.qml index 3bcf49d1..4a3db8ee 100644 --- a/src/layouts/fallback/dialpad.qml +++ b/src/layouts/fallback/dialpad.qml @@ -66,7 +66,9 @@ KeyboardLayout { key: Qt.Key_9 text: "9" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { Key { diff --git a/src/layouts/fallback/digits.qml b/src/layouts/fallback/digits.qml index a1d5a803..21afcb42 100644 --- a/src/layouts/fallback/digits.qml +++ b/src/layouts/fallback/digits.qml @@ -66,11 +66,14 @@ KeyboardLayout { key: Qt.Key_3 text: "3" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { customLayoutsOnly: true + visible: true } Key { key: Qt.Key_0 diff --git a/src/layouts/fallback/handwriting.qml b/src/layouts/fallback/handwriting.qml index e6764a08..9f3c9cfb 100644 --- a/src/layouts/fallback/handwriting.qml +++ b/src/layouts/fallback/handwriting.qml @@ -13,43 +13,42 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/fallback/main.qml b/src/layouts/fallback/main.qml index 76aab6e1..bcc6dba8 100644 --- a/src/layouts/fallback/main.qml +++ b/src/layouts/fallback/main.qml @@ -166,13 +166,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -187,6 +191,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fallback/numbers.qml b/src/layouts/fallback/numbers.qml index 5c8699cf..80671df1 100644 --- a/src/layouts/fallback/numbers.qml +++ b/src/layouts/fallback/numbers.qml @@ -138,11 +138,14 @@ KeyboardLayout { key: Qt.Key_3 text: "3" } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } } KeyboardRow { ChangeLanguageKey { customLayoutsOnly: true + visible: true } Key { key: Qt.Key_0 diff --git a/src/layouts/fallback/symbols.qml b/src/layouts/fallback/symbols.qml index c18dffa6..4f0c1233 100644 --- a/src/layouts/fallback/symbols.qml +++ b/src/layouts/fallback/symbols.qml @@ -149,13 +149,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? "АБВ" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -167,6 +171,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -314,13 +322,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? "АБВ" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -332,6 +344,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fi_FI/main.qml b/src/layouts/fi_FI/main.qml index e6b21ab2..61f76491 100644 --- a/src/layouts/fi_FI/main.qml +++ b/src/layouts/fi_FI/main.qml @@ -159,13 +159,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -180,6 +184,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fr_CA/main.qml b/src/layouts/fr_CA/main.qml index e98eef88..fa96b77d 100644 --- a/src/layouts/fr_CA/main.qml +++ b/src/layouts/fr_CA/main.qml @@ -158,13 +158,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -179,6 +183,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/fr_FR/main.qml b/src/layouts/fr_FR/main.qml index 9480bb60..fda6eb57 100644 --- a/src/layouts/fr_FR/main.qml +++ b/src/layouts/fr_FR/main.qml @@ -146,13 +146,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -167,6 +171,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/he_IL/handwriting.qml b/src/layouts/he_IL/handwriting.qml index 08f52a7e..5eb39268 100644 --- a/src/layouts/he_IL/handwriting.qml +++ b/src/layouts/he_IL/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Hebrew ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Hebrew ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/he_IL/main.qml b/src/layouts/he_IL/main.qml index 5abb8aae..f2aa3322 100644 --- a/src/layouts/he_IL/main.qml +++ b/src/layouts/he_IL/main.qml @@ -144,13 +144,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -170,6 +174,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -339,13 +347,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -366,6 +378,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/he_IL/symbols.qml b/src/layouts/he_IL/symbols.qml index c7b002a1..ddeb3573 100644 --- a/src/layouts/he_IL/symbols.qml +++ b/src/layouts/he_IL/symbols.qml @@ -149,13 +149,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Hebrew ? "\u05D0\u05D1\u05D2" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -167,6 +171,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -314,13 +322,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: InputContext.inputEngine.inputMode === InputEngine.InputMode.Hebrew ? "\u05D0\u05D1\u05D2" : "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -332,6 +344,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/hi_IN/handwriting.fallback b/src/layouts/hi_IN/handwriting.fallback new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/layouts/hi_IN/handwriting.fallback diff --git a/src/layouts/hi_IN/handwriting.qml b/src/layouts/hi_IN/handwriting.qml deleted file mode 100644 index e6764a08..00000000 --- a/src/layouts/hi_IN/handwriting.qml +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.VirtualKeyboard -import QtQuick.VirtualKeyboard.Components - -KeyboardLayout { - function createInputMethod() { - return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) - } - sharedLayouts: ['symbols'] - - KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 - } - } -} diff --git a/src/layouts/hi_IN/main.qml b/src/layouts/hi_IN/main.qml index 805e1efc..c9512cc9 100644 --- a/src/layouts/hi_IN/main.qml +++ b/src/layouts/hi_IN/main.qml @@ -156,13 +156,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -175,6 +179,10 @@ KeyboardLayout { alternativeKeys: "!.?" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/hi_IN/symbols.qml b/src/layouts/hi_IN/symbols.qml index 02fb1e49..15e46e8a 100644 --- a/src/layouts/hi_IN/symbols.qml +++ b/src/layouts/hi_IN/symbols.qml @@ -159,13 +159,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0915\u0916\u0917" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -177,6 +181,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -324,13 +332,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\u0915\u0916\u0917" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -342,6 +354,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/hr_HR/handwriting.fallback b/src/layouts/hr_HR/handwriting.fallback new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/layouts/hr_HR/handwriting.fallback diff --git a/src/layouts/hr_HR/handwriting.qml b/src/layouts/hr_HR/handwriting.qml deleted file mode 100644 index eaae7571..00000000 --- a/src/layouts/hr_HR/handwriting.qml +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.VirtualKeyboard -import QtQuick.VirtualKeyboard.Components - -KeyboardLayout { - function createInputMethod() { - return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) - } - sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin - - KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 - } - } -} diff --git a/src/layouts/hr_HR/main.qml b/src/layouts/hr_HR/main.qml index 6d52bf9e..283cc6d7 100644 --- a/src/layouts/hr_HR/main.qml +++ b/src/layouts/hr_HR/main.qml @@ -153,13 +153,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -174,6 +178,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/hu_HU/handwriting.fallback b/src/layouts/hu_HU/handwriting.fallback new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/layouts/hu_HU/handwriting.fallback diff --git a/src/layouts/hu_HU/handwriting.qml b/src/layouts/hu_HU/handwriting.qml deleted file mode 100644 index eaae7571..00000000 --- a/src/layouts/hu_HU/handwriting.qml +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.VirtualKeyboard -import QtQuick.VirtualKeyboard.Components - -KeyboardLayout { - function createInputMethod() { - return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) - } - sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin - - KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 - } - } -} diff --git a/src/layouts/hu_HU/main.qml b/src/layouts/hu_HU/main.qml index 6508dd75..0def7493 100644 --- a/src/layouts/hu_HU/main.qml +++ b/src/layouts/hu_HU/main.qml @@ -158,13 +158,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -179,6 +183,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/it_IT/main.qml b/src/layouts/it_IT/main.qml index f7cee4e9..54cacad7 100644 --- a/src/layouts/it_IT/main.qml +++ b/src/layouts/it_IT/main.qml @@ -156,13 +156,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -177,6 +181,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ja_JP/handwriting.qml b/src/layouts/ja_JP/handwriting.qml index a1eb3b81..c8d5acd3 100644 --- a/src/layouts/ja_JP/handwriting.qml +++ b/src/layouts/ja_JP/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.JapaneseHandwriting ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "、" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "‘’“”~…—《》〈〉「」\",.:;。?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.JapaneseHandwriting ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "。" + alternativeKeys: "‘’“”~…—\",.:;、。?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/ja_JP/main.qml b/src/layouts/ja_JP/main.qml index 711f4f36..18680c99 100644 --- a/src/layouts/ja_JP/main.qml +++ b/src/layouts/ja_JP/main.qml @@ -158,13 +158,17 @@ KeyboardLayoutLoader { Layout.preferredWidth: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma Layout.preferredWidth: normalKeyWidth Layout.fillWidth: false text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -216,6 +220,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { Layout.preferredWidth: functionKeyWidth Layout.fillWidth: false @@ -369,13 +377,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -427,6 +439,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ja_JP/symbols.qml b/src/layouts/ja_JP/symbols.qml index 75e19aad..c84134fb 100644 --- a/src/layouts/ja_JP/symbols.qml +++ b/src/layouts/ja_JP/symbols.qml @@ -161,13 +161,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: inputModeName } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -179,6 +183,10 @@ KeyboardLayoutLoader { text: "—" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -298,13 +306,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: inputModeName } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -316,6 +328,10 @@ KeyboardLayoutLoader { text: "。" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -434,13 +450,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: inputModeName } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -452,6 +472,10 @@ KeyboardLayoutLoader { text: "…" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ko_KR/handwriting.qml b/src/layouts/ko_KR/handwriting.qml index ff51aa00..5502517d 100644 --- a/src/layouts/ko_KR/handwriting.qml +++ b/src/layouts/ko_KR/handwriting.qml @@ -29,46 +29,45 @@ KeyboardLayout { } KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.KoreanHandwriting ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.KoreanHandwriting ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/ko_KR/main.qml b/src/layouts/ko_KR/main.qml index 0877999f..b04c6310 100644 --- a/src/layouts/ko_KR/main.qml +++ b/src/layouts/ko_KR/main.qml @@ -139,13 +139,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -160,6 +164,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -287,13 +295,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -308,6 +320,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ko_KR/symbols.qml b/src/layouts/ko_KR/symbols.qml index 10a67b82..c7e0890c 100644 --- a/src/layouts/ko_KR/symbols.qml +++ b/src/layouts/ko_KR/symbols.qml @@ -153,13 +153,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\uD55C\uAE00" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -171,6 +175,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -318,13 +326,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "\uD55C\uAE00" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -336,6 +348,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/nb_NO/main.qml b/src/layouts/nb_NO/main.qml index de8d83fc..d11349a0 100644 --- a/src/layouts/nb_NO/main.qml +++ b/src/layouts/nb_NO/main.qml @@ -165,13 +165,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -186,6 +190,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/pl_PL/main.qml b/src/layouts/pl_PL/main.qml index 5ae3bb20..933febcb 100644 --- a/src/layouts/pl_PL/main.qml +++ b/src/layouts/pl_PL/main.qml @@ -160,13 +160,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -181,6 +185,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/pt_BR/main.qml b/src/layouts/pt_BR/main.qml index 5e42560b..3864a500 100644 --- a/src/layouts/pt_BR/main.qml +++ b/src/layouts/pt_BR/main.qml @@ -145,13 +145,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -166,6 +170,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/pt_PT/main.qml b/src/layouts/pt_PT/main.qml index 5e42560b..3864a500 100644 --- a/src/layouts/pt_PT/main.qml +++ b/src/layouts/pt_PT/main.qml @@ -145,13 +145,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -166,6 +170,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ro_RO/handwriting.fallback b/src/layouts/ro_RO/handwriting.fallback new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/layouts/ro_RO/handwriting.fallback diff --git a/src/layouts/ro_RO/handwriting.qml b/src/layouts/ro_RO/handwriting.qml deleted file mode 100644 index eaae7571..00000000 --- a/src/layouts/ro_RO/handwriting.qml +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.VirtualKeyboard -import QtQuick.VirtualKeyboard.Components - -KeyboardLayout { - function createInputMethod() { - return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; HandwritingInputMethod {}', parent) - } - sharedLayouts: ['symbols'] - inputMode: InputEngine.InputMode.Latin - - KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 - } - } -} diff --git a/src/layouts/ro_RO/main.qml b/src/layouts/ro_RO/main.qml index b4deac67..68e693bd 100644 --- a/src/layouts/ro_RO/main.qml +++ b/src/layouts/ro_RO/main.qml @@ -155,13 +155,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -176,6 +180,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/ru_RU/handwriting.qml b/src/layouts/ru_RU/handwriting.qml index 0c4f5847..3a75a2ce 100644 --- a/src/layouts/ru_RU/handwriting.qml +++ b/src/layouts/ru_RU/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/ru_RU/main.qml b/src/layouts/ru_RU/main.qml index 91820981..34bd1e15 100644 --- a/src/layouts/ru_RU/main.qml +++ b/src/layouts/ru_RU/main.qml @@ -6,383 +6,185 @@ import QtQuick.VirtualKeyboard import QtQuick.VirtualKeyboard.Components import QtQuick.Layouts -KeyboardLayoutLoader { +KeyboardLayout { sharedLayouts: ['symbols'] - sourceComponent: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? cyrillicLayout : latinLayout - Component { - id: cyrillicLayout - KeyboardLayout { - keyWeight: 160 - readonly property real normalKeyWidth: normalKey.width - readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x - KeyboardRow { - Key { - key: 0x0419 - text: "й" - } - Key { - id: normalKey - key: 0x0426 - text: "ц" - } - Key { - key: 0x0423 - text: "у" - } - Key { - key: 0x041A - text: "к" - } - Key { - key: 0x0415 - text: "е" - alternativeKeys: "её" - } - Key { - key: 0x041D - text: "н" - } - Key { - key: 0x0413 - text: "г" - } - Key { - key: 0x0428 - text: "ш" - } - Key { - key: 0x0429 - text: "щ" - } - Key { - key: 0x0417 - text: "з" - } - Key { - key: 0x0425 - text: "х" - } - } - KeyboardRow { - Key { - key: 0x0424 - text: "ф" - } - Key { - key: 0x042B - text: "ы" - } - Key { - key: 0x0412 - text: "в" - } - Key { - key: 0x0410 - text: "а" - } - Key { - key: 0x041F - text: "п" - } - Key { - key: 0x0420 - text: "р" - } - Key { - key: 0x041E - text: "о" - } - Key { - key: 0x041B - text: "л" - } - Key { - key: 0x0414 - text: "д" - } - Key { - key: 0x0416 - text: "ж" - } - Key { - key: 0x042D - text: "э" - } - } - KeyboardRow { - ShiftKey { - } - Key { - key: 0x042F - text: "я" - } - Key { - key: 0x0427 - text: "ч" - } - Key { - key: 0x0421 - text: "с" - } - Key { - key: 0x041C - text: "м" - } - Key { - key: 0x0418 - text: "и" - } - Key { - key: 0x0422 - text: "т" - } - Key { - key: 0x042C - text: "ь" - alternativeKeys: "ьъ" - } - Key { - key: 0x0411 - text: "б" - } - Key { - key: 0x042E - text: "ю" - } - BackspaceKey { - } - } - KeyboardRow { - SymbolModeKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - InputModeKey { - inputModes: [InputEngine.InputMode.Cyrillic, InputEngine.InputMode.Latin] - weight: normalKeyWidth - Layout.fillWidth: false - } - SpaceKey { - } - Key { - key: Qt.Key_Period - weight: normalKeyWidth - Layout.fillWidth: false - text: "." - alternativeKeys: "!.?" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - EnterKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - } + keyWeight: 160 + readonly property real normalKeyWidth: normalKey.width + readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x + KeyboardRow { + Key { + key: 0x0419 + text: "й" + } + Key { + id: normalKey + key: 0x0426 + text: "ц" + } + Key { + key: 0x0423 + text: "у" + } + Key { + key: 0x041A + text: "к" + } + Key { + key: 0x0415 + text: "е" + alternativeKeys: "её" + } + Key { + key: 0x041D + text: "н" + } + Key { + key: 0x0413 + text: "г" + } + Key { + key: 0x0428 + text: "ш" + } + Key { + key: 0x0429 + text: "щ" + } + Key { + key: 0x0417 + text: "з" + } + Key { + key: 0x0425 + text: "х" + } + } + KeyboardRow { + Key { + key: 0x0424 + text: "ф" + } + Key { + key: 0x042B + text: "ы" + } + Key { + key: 0x0412 + text: "в" + } + Key { + key: 0x0410 + text: "а" + } + Key { + key: 0x041F + text: "п" + } + Key { + key: 0x0420 + text: "р" + } + Key { + key: 0x041E + text: "о" + } + Key { + key: 0x041B + text: "л" + } + Key { + key: 0x0414 + text: "д" + } + Key { + key: 0x0416 + text: "ж" + } + Key { + key: 0x042D + text: "э" + } + } + KeyboardRow { + ShiftKey { + } + Key { + key: 0x042F + text: "я" + } + Key { + key: 0x0427 + text: "ч" + } + Key { + key: 0x0421 + text: "с" + } + Key { + key: 0x041C + text: "м" + } + Key { + key: 0x0418 + text: "и" + } + Key { + key: 0x0422 + text: "т" + } + Key { + key: 0x042C + text: "ь" + alternativeKeys: "ьъ" + } + Key { + key: 0x0411 + text: "б" + } + Key { + key: 0x042E + text: "ю" + } + BackspaceKey { } } - Component { - id: latinLayout - KeyboardLayout { - keyWeight: 160 - readonly property real normalKeyWidth: normalKey.width - readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x - KeyboardRow { - Key { - key: Qt.Key_Q - text: "q" - } - Key { - id: normalKey - key: Qt.Key_W - text: "w" - } - Key { - key: Qt.Key_E - text: "e" - alternativeKeys: "êeëèé" - } - Key { - key: Qt.Key_R - text: "r" - alternativeKeys: "ŕrř" - } - Key { - key: Qt.Key_T - text: "t" - alternativeKeys: "ţtŧť" - } - Key { - key: Qt.Key_Z - text: "z" - alternativeKeys: "zž" - } - Key { - key: Qt.Key_U - text: "u" - alternativeKeys: "űūũûüuùú" - } - Key { - key: Qt.Key_I - text: "i" - alternativeKeys: "îïīĩiìí" - } - Key { - key: Qt.Key_O - text: "o" - alternativeKeys: "œøõôöòóo" - } - Key { - key: Qt.Key_P - text: "p" - } - } - KeyboardRow { - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - FillerKey { - } - Key { - key: Qt.Key_A - text: "a" - alternativeKeys: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) ? "a@äåãâàá" : "aäåãâàá" - smallTextVisible: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) - weight: normalKeyWidth - Layout.fillWidth: false - } - } - Key { - key: Qt.Key_S - text: "s" - alternativeKeys: "šsşś" - } - Key { - key: Qt.Key_D - text: "d" - alternativeKeys: "dđď" - } - Key { - key: Qt.Key_F - text: "f" - } - Key { - key: Qt.Key_G - text: "g" - alternativeKeys: "ġgģĝğ" - } - Key { - key: Qt.Key_H - text: "h" - } - Key { - key: Qt.Key_J - text: "j" - } - Key { - key: Qt.Key_K - text: "k" - } - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - Key { - key: Qt.Key_L - text: "l" - alternativeKeys: "ĺŀłļľl" - weight: normalKeyWidth - Layout.fillWidth: false - } - FillerKey { - } - } - } - KeyboardRow { - ShiftKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Y - text: "y" - } - Key { - key: Qt.Key_X - text: "x" - } - Key { - key: Qt.Key_C - text: "c" - alternativeKeys: "çcċčć" - } - Key { - key: Qt.Key_V - text: "v" - } - Key { - key: Qt.Key_B - text: "b" - } - Key { - key: Qt.Key_N - text: "n" - alternativeKeys: "ņńnň" - } - Key { - key: Qt.Key_M - text: "m" - } - BackspaceKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - } - KeyboardRow { - SymbolModeKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - InputModeKey { - enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 - inputModes: [InputEngine.InputMode.Cyrillic, InputEngine.InputMode.Latin] - weight: normalKeyWidth - Layout.fillWidth: false - } - SpaceKey { - } - Key { - key: Qt.Key_Period - weight: normalKeyWidth - Layout.fillWidth: false - text: "." - alternativeKeys: "!.?" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - EnterKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - } + KeyboardRow { + SymbolModeKey { + weight: functionKeyWidth + Layout.fillWidth: false + } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + weight: normalKeyWidth + Layout.fillWidth: false + text: "," + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } + SpaceKey { + } + Key { + key: Qt.Key_Period + weight: normalKeyWidth + Layout.fillWidth: false + text: "." + alternativeKeys: "!.?" + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + EnterKey { + weight: functionKeyWidth + Layout.fillWidth: false } } } diff --git a/src/layouts/sk_SK/main.qml b/src/layouts/sk_SK/main.qml index 1e54dcab..3b3a85a8 100644 --- a/src/layouts/sk_SK/main.qml +++ b/src/layouts/sk_SK/main.qml @@ -165,13 +165,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -186,6 +190,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/sl_SI/main.qml b/src/layouts/sl_SI/main.qml index be871af0..185fecfb 100644 --- a/src/layouts/sl_SI/main.qml +++ b/src/layouts/sl_SI/main.qml @@ -160,13 +160,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -181,6 +185,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/sq_AL/main.qml b/src/layouts/sq_AL/main.qml index 51b737c3..707a181c 100644 --- a/src/layouts/sq_AL/main.qml +++ b/src/layouts/sq_AL/main.qml @@ -172,13 +172,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -193,6 +197,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/sr_SP/handwriting.qml b/src/layouts/sr_SP/handwriting.qml index 0c4f5847..3a75a2ce 100644 --- a/src/layouts/sr_SP/handwriting.qml +++ b/src/layouts/sr_SP/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/sr_SP/main.qml b/src/layouts/sr_SP/main.qml index 73595911..51ce560f 100644 --- a/src/layouts/sr_SP/main.qml +++ b/src/layouts/sr_SP/main.qml @@ -124,13 +124,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -150,6 +154,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -318,13 +326,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -345,6 +357,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/sv_SE/main.qml b/src/layouts/sv_SE/main.qml index e6b21ab2..61f76491 100644 --- a/src/layouts/sv_SE/main.qml +++ b/src/layouts/sv_SE/main.qml @@ -159,13 +159,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -180,6 +184,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/th_TH/handwriting.qml b/src/layouts/th_TH/handwriting.qml index 55089a4a..f6801c7c 100644 --- a/src/layouts/th_TH/handwriting.qml +++ b/src/layouts/th_TH/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Thai ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Thai ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/th_TH/main.qml b/src/layouts/th_TH/main.qml index 3de1d020..87795bd4 100644 --- a/src/layouts/th_TH/main.qml +++ b/src/layouts/th_TH/main.qml @@ -226,13 +226,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -247,6 +251,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -428,13 +436,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -449,6 +461,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/th_TH/symbols.qml b/src/layouts/th_TH/symbols.qml index 3aadebf4..8d50ee44 100644 --- a/src/layouts/th_TH/symbols.qml +++ b/src/layouts/th_TH/symbols.qml @@ -149,13 +149,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "กขค" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -167,6 +171,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -314,13 +322,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "กขค" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -332,6 +344,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/tr_TR/main.qml b/src/layouts/tr_TR/main.qml index 4fa4afc0..ed9adf4f 100644 --- a/src/layouts/tr_TR/main.qml +++ b/src/layouts/tr_TR/main.qml @@ -177,13 +177,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -198,6 +202,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/uk_UA/handwriting.qml b/src/layouts/uk_UA/handwriting.qml index 0c4f5847..3a75a2ce 100644 --- a/src/layouts/uk_UA/handwriting.qml +++ b/src/layouts/uk_UA/handwriting.qml @@ -13,46 +13,45 @@ KeyboardLayout { sharedLayouts: ['symbols'] KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] - } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "." - alternativeKeys: "<>()/\\\"'=+-_:;.?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { - } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } + } + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.Cyrillic ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } + } + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "." + alternativeKeys: "<>()/\\\"'=+-_:;,.?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/uk_UA/main.qml b/src/layouts/uk_UA/main.qml index c808bbb3..79f8b194 100644 --- a/src/layouts/uk_UA/main.qml +++ b/src/layouts/uk_UA/main.qml @@ -6,376 +6,176 @@ import QtQuick.VirtualKeyboard import QtQuick.VirtualKeyboard.Components import QtQuick.Layouts -KeyboardLayoutLoader { +KeyboardLayout { sharedLayouts: ['symbols'] - sourceComponent: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cyrillic ? cyrillicLayout : latinLayout - Component { - id: cyrillicLayout - KeyboardLayout { - keyWeight: 160 - readonly property real normalKeyWidth: normalKey.width - readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x - KeyboardRow { - Key { - text: "й" - } - Key { - id: normalKey - text: "ц" - } - Key { - text: "у" - } - Key { - text: "к" - } - Key { - text: "е" - } - Key { - text: "н" - } - Key { - text: "г" - } - Key { - text: "ш" - } - Key { - text: "щ" - } - Key { - text: "з" - } - Key { - text: "х" - } - Key { - text: "ї" - } - } - KeyboardRow { - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - FillerKey { - } - Key { - text: "ф" - weight: normalKeyWidth - Layout.fillWidth: false - } - } - Key { - text: "і" - } - Key { - text: "в" - } - Key { - text: "а" - } - Key { - text: "п" - } - Key { - text: "р" - } - Key { - text: "о" - } - Key { - text: "л" - } - Key { - text: "д" - } - Key { - text: "ж" - } - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - Key { - text: "є" - weight: normalKeyWidth - Layout.fillWidth: false - } - FillerKey { - } - } - } - KeyboardRow { - ShiftKey { - } - Key { - text: "ґ" - } - Key { - text: "я" - alternativeKeys: "$¢я₴€¥£" - smallTextVisible: true - } - Key { - text: "ч" - } - Key { - text: "с" - } - Key { - text: "м" - } - Key { - text: "и" - } - Key { - text: "т" - } - Key { - text: "ь" - } - Key { - text: "б" - } - Key { - text: "ю" - } - BackspaceKey { - } - } - KeyboardRow { - SymbolModeKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - InputModeKey { - inputModes: [InputEngine.InputMode.Cyrillic, InputEngine.InputMode.Latin] - weight: normalKeyWidth - Layout.fillWidth: false - } - SpaceKey { - } - Key { - key: Qt.Key_Period - weight: normalKeyWidth - Layout.fillWidth: false - text: "." - alternativeKeys: "!.?" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - EnterKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - } + keyWeight: 160 + readonly property real normalKeyWidth: normalKey.width + readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x + KeyboardRow { + Key { + text: "й" + } + Key { + id: normalKey + text: "ц" + } + Key { + text: "у" + } + Key { + text: "к" + } + Key { + text: "е" + } + Key { + text: "н" + } + Key { + text: "г" + } + Key { + text: "ш" + } + Key { + text: "щ" + } + Key { + text: "з" + } + Key { + text: "х" + } + Key { + text: "ї" } } - Component { - id: latinLayout - KeyboardLayout { - keyWeight: 160 - readonly property real normalKeyWidth: normalKey.width - readonly property real functionKeyWidth: mapFromItem(normalKey, normalKey.width / 2, 0).x - KeyboardRow { - Key { - key: Qt.Key_Q - text: "q" - } - Key { - id: normalKey - key: Qt.Key_W - text: "w" - } - Key { - key: Qt.Key_E - text: "e" - alternativeKeys: "êeëèé" - } - Key { - key: Qt.Key_R - text: "r" - alternativeKeys: "ŕrř" - } - Key { - key: Qt.Key_T - text: "t" - alternativeKeys: "ţtŧť" - } - Key { - key: Qt.Key_Y - text: "y" - } - Key { - key: Qt.Key_U - text: "u" - alternativeKeys: "űūũûüuùú" - } - Key { - key: Qt.Key_I - text: "i" - alternativeKeys: "îïīĩiìí" - } - Key { - key: Qt.Key_O - text: "o" - alternativeKeys: "œøõôöòóo" - } - Key { - key: Qt.Key_P - text: "p" - } + KeyboardRow { + KeyboardRow { + Layout.preferredWidth: functionKeyWidth + Layout.fillWidth: false + FillerKey { } - KeyboardRow { - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - FillerKey { - } - Key { - key: Qt.Key_A - text: "a" - alternativeKeys: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) ? "a@äåãâàá" : "aäåãâàá" - smallTextVisible: (InputContext.inputMethodHints & (Qt.ImhEmailCharactersOnly | Qt.ImhUrlCharactersOnly)) - weight: normalKeyWidth - Layout.fillWidth: false - } - } - Key { - key: Qt.Key_S - text: "s" - alternativeKeys: "šsşś" - } - Key { - key: Qt.Key_D - text: "d" - alternativeKeys: "dđď" - } - Key { - key: Qt.Key_F - text: "f" - } - Key { - key: Qt.Key_G - text: "g" - alternativeKeys: "ġgģĝğ" - } - Key { - key: Qt.Key_H - text: "h" - } - Key { - key: Qt.Key_J - text: "j" - } - Key { - key: Qt.Key_K - text: "k" - } - KeyboardRow { - Layout.preferredWidth: functionKeyWidth - Layout.fillWidth: false - Key { - key: Qt.Key_L - text: "l" - alternativeKeys: "ĺŀłļľl" - weight: normalKeyWidth - Layout.fillWidth: false - } - FillerKey { - } - } + Key { + text: "ф" + weight: normalKeyWidth + Layout.fillWidth: false } - KeyboardRow { - ShiftKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Z - text: "z" - alternativeKeys: "zž" - } - Key { - key: Qt.Key_X - text: "x" - alternativeKeys: "$¢x₴€¥£" - smallTextVisible: true - } - Key { - key: Qt.Key_C - text: "c" - alternativeKeys: "çcċčć" - } - Key { - key: Qt.Key_V - text: "v" - } - Key { - key: Qt.Key_B - text: "b" - } - Key { - key: Qt.Key_N - text: "n" - alternativeKeys: "ņńnň" - } - Key { - key: Qt.Key_M - text: "m" - } - BackspaceKey { - weight: functionKeyWidth - Layout.fillWidth: false - } + } + Key { + text: "і" + } + Key { + text: "в" + } + Key { + text: "а" + } + Key { + text: "п" + } + Key { + text: "р" + } + Key { + text: "о" + } + Key { + text: "л" + } + Key { + text: "д" + } + Key { + text: "ж" + } + KeyboardRow { + Layout.preferredWidth: functionKeyWidth + Layout.fillWidth: false + Key { + text: "є" + weight: normalKeyWidth + Layout.fillWidth: false } - KeyboardRow { - SymbolModeKey { - weight: functionKeyWidth - Layout.fillWidth: false - } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "," - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - InputModeKey { - enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 - inputModes: [InputEngine.InputMode.Cyrillic, InputEngine.InputMode.Latin] - weight: normalKeyWidth - Layout.fillWidth: false - } - SpaceKey { - } - Key { - key: Qt.Key_Period - weight: normalKeyWidth - Layout.fillWidth: false - text: "." - alternativeKeys: "!.?" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - EnterKey { - weight: functionKeyWidth - Layout.fillWidth: false - } + FillerKey { } } } + KeyboardRow { + ShiftKey { + } + Key { + text: "ґ" + } + Key { + text: "я" + alternativeKeys: "$¢я₴€¥£" + smallTextVisible: true + } + Key { + text: "ч" + } + Key { + text: "с" + } + Key { + text: "м" + } + Key { + text: "и" + } + Key { + text: "т" + } + Key { + text: "ь" + } + Key { + text: "б" + } + Key { + text: "ю" + } + BackspaceKey { + } + } + KeyboardRow { + SymbolModeKey { + weight: functionKeyWidth + Layout.fillWidth: false + } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + weight: normalKeyWidth + Layout.fillWidth: false + text: "," + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } + SpaceKey { + } + Key { + key: Qt.Key_Period + weight: normalKeyWidth + Layout.fillWidth: false + text: "." + alternativeKeys: "!.?" + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + EnterKey { + weight: functionKeyWidth + Layout.fillWidth: false + } + } } diff --git a/src/layouts/vi_VN/main.qml b/src/layouts/vi_VN/main.qml index cea1d0ce..6ad84093 100644 --- a/src/layouts/vi_VN/main.qml +++ b/src/layouts/vi_VN/main.qml @@ -162,13 +162,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -183,6 +187,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/vi_VN/symbols.qml b/src/layouts/vi_VN/symbols.qml index 08929ba9..d297d624 100644 --- a/src/layouts/vi_VN/symbols.qml +++ b/src/layouts/vi_VN/symbols.qml @@ -149,13 +149,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -167,6 +171,10 @@ KeyboardLayoutLoader { text: "." highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -314,13 +322,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -332,6 +344,10 @@ KeyboardLayoutLoader { text: "\u2026" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/zh_CN/handwriting.qml b/src/layouts/zh_CN/handwriting.qml index 4dea03c9..a2548b89 100644 --- a/src/layouts/zh_CN/handwriting.qml +++ b/src/layouts/zh_CN/handwriting.qml @@ -29,46 +29,45 @@ KeyboardLayout { } KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "、" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "。" - alternativeKeys: "¥‘’“”~…—《》〈〉「」\",.:;。?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "。" + alternativeKeys: "¥‘’“”~…—\",.:;、。?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/zh_CN/main.qml b/src/layouts/zh_CN/main.qml index 12dc978c..619c8ee3 100644 --- a/src/layouts/zh_CN/main.qml +++ b/src/layouts/zh_CN/main.qml @@ -157,13 +157,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\uFF0C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -178,6 +182,10 @@ KeyboardLayout { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/zh_CN/symbols.qml b/src/layouts/zh_CN/symbols.qml index 638cbfcf..6058b2c1 100644 --- a/src/layouts/zh_CN/symbols.qml +++ b/src/layouts/zh_CN/symbols.qml @@ -151,13 +151,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -169,6 +173,10 @@ KeyboardLayoutLoader { text: "—" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -288,13 +296,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -306,6 +318,10 @@ KeyboardLayoutLoader { text: "。" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -424,13 +440,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -442,6 +462,10 @@ KeyboardLayoutLoader { text: "…" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/zh_TW/handwriting.qml b/src/layouts/zh_TW/handwriting.qml index 4dea03c9..a2548b89 100644 --- a/src/layouts/zh_TW/handwriting.qml +++ b/src/layouts/zh_TW/handwriting.qml @@ -29,46 +29,45 @@ KeyboardLayout { } KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "、" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "。" - alternativeKeys: "¥‘’“”~…—《》〈〉「」\",.:;。?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "。" + alternativeKeys: "¥‘’“”~…—\",.:;、。?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/layouts/zh_TW/main.qml b/src/layouts/zh_TW/main.qml index e0a74b5b..65c481c6 100644 --- a/src/layouts/zh_TW/main.qml +++ b/src/layouts/zh_TW/main.qml @@ -11,7 +11,16 @@ KeyboardLayoutLoader { return Qt.createQmlObject('import QtQuick; import QtQuick.VirtualKeyboard.Plugins; TCInputMethod {}', parent, "main.qml") } sharedLayouts: ['symbols'] - sourceComponent: InputContext.inputEngine.inputMode === InputEngine.InputMode.Cangjie ? pageCangjie : pageZhuyin + sourceComponent: { + switch (InputContext.inputEngine.inputMode) { + case InputEngine.InputMode.Cangjie: + return pageCangjie + case InputEngine.InputMode.Zhuyin: + return pageZhuyin + default: + return null + } + } Component { id: pageCangjie KeyboardLayout { @@ -173,13 +182,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\uFF0C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -199,6 +212,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -383,7 +400,7 @@ KeyboardLayoutLoader { } Key { text: "\u3125" - alternativeKeys: ";\u3125:" + alternativeKeys: ";:\u3125\u3126" } } } @@ -394,13 +411,17 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\uFF0C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -424,6 +445,10 @@ KeyboardLayoutLoader { weight: normalKeyWidth Layout.fillWidth: false } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/layouts/zh_TW/symbols.qml b/src/layouts/zh_TW/symbols.qml index d4b0ce5e..9c8dc995 100644 --- a/src/layouts/zh_TW/symbols.qml +++ b/src/layouts/zh_TW/symbols.qml @@ -151,13 +151,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -169,6 +173,10 @@ KeyboardLayoutLoader { text: "—" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -288,13 +296,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -306,6 +318,10 @@ KeyboardLayoutLoader { text: "。" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -424,13 +440,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -442,6 +462,10 @@ KeyboardLayoutLoader { text: "…" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 6db62240..5d235b9f 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QVirtualKeyboardPlugin Plugin: ##################################################################### @@ -5,7 +8,7 @@ qt_internal_add_plugin(QVirtualKeyboardPlugin OUTPUT_NAME qtvirtualkeyboardplugin PLUGIN_TYPE platforminputcontexts - DEFAULT_IF FALSE + DEFAULT_IF ANDROID SOURCES plugin.cpp plugin.h DEFINES diff --git a/src/plugin/plugin.cpp b/src/plugin/plugin.cpp index 9ecef94f..6ea93d47 100644 --- a/src/plugin/plugin.cpp +++ b/src/plugin/plugin.cpp @@ -7,6 +7,7 @@ #if defined(Q_OS_WIN) #include <qt_windows.h> #endif +#include <qpa/qplatforminputcontextfactory_p.h> QT_BEGIN_NAMESPACE @@ -15,7 +16,6 @@ using namespace QtVirtualKeyboard; Q_LOGGING_CATEGORY(qlcVirtualKeyboard, "qt.virtualkeyboard") static const char pluginName[] = "qtvirtualkeyboard"; -static const char inputMethodEnvVarName[] = "QT_IM_MODULE"; QStringList QVirtualKeyboardPlugin::keys() const { @@ -26,11 +26,11 @@ QPlatformInputContext *QVirtualKeyboardPlugin::create(const QString &system, con { Q_UNUSED(paramList); - if (!qEnvironmentVariableIsSet(inputMethodEnvVarName) || qgetenv(inputMethodEnvVarName) != pluginName) - return Q_NULLPTR; + if (!QPlatformInputContextFactory::requested().contains(QLatin1StringView(pluginName))) + return nullptr; if (system.compare(system, QLatin1String(pluginName), Qt::CaseInsensitive) != 0) - return Q_NULLPTR; + return nullptr; #if defined(Q_OS_WIN) // QTBUG-93042 diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 9174648b..686a6808 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,8 +1,15 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + set(plugins_imports) if(QT_FEATURE_cerence_sdk) add_subdirectory(cerence) list(APPEND plugins_imports QtQuick.VirtualKeyboard.Plugins.Cerence/auto) endif() +if(QT_FEATURE_example_hwr) + add_subdirectory(example) + list(APPEND plugins_imports QtQuick.VirtualKeyboard.Plugins.Example/auto) +endif() if(QT_FEATURE_hangul) add_subdirectory(hangul) list(APPEND plugins_imports QtQuick.VirtualKeyboard.Plugins.Hangul/auto) @@ -35,7 +42,9 @@ endif() qt_internal_add_qml_module(qtvkbpluginsplugin URI "QtQuick.VirtualKeyboard.Plugins" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbpluginsplugin IMPORTS ${plugins_imports} + NO_GENERATE_CPP_EXPORTS ) diff --git a/src/plugins/cerence/CMakeLists.txt b/src/plugins/cerence/CMakeLists.txt index 2d9f9cbb..ba38d2cb 100644 --- a/src/plugins/cerence/CMakeLists.txt +++ b/src/plugins/cerence/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + set(cerence_imports) add_subdirectory(cerencecommon) @@ -13,7 +16,9 @@ endif() qt_internal_add_qml_module(qtvkbcerenceplugin URI "QtQuick.VirtualKeyboard.Plugins.Cerence" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbcerenceplugin IMPORTS ${cerence_imports} + NO_GENERATE_CPP_EXPORTS ) diff --git a/src/plugins/cerence/cerencecommon/CMakeLists.txt b/src/plugins/cerence/cerencecommon/CMakeLists.txt index b5ee6d05..4ebbf4fb 100644 --- a/src/plugins/cerence/cerencecommon/CMakeLists.txt +++ b/src/plugins/cerence/cerencecommon/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## BundledCerencecommon Generic Library: ##################################################################### diff --git a/src/plugins/cerence/cerencecommon/xt9ldbmanager.cpp b/src/plugins/cerence/cerencecommon/xt9ldbmanager.cpp index 0d207c3c..6aa7e29a 100644 --- a/src/plugins/cerence/cerencecommon/xt9ldbmanager.cpp +++ b/src/plugins/cerence/cerencecommon/xt9ldbmanager.cpp @@ -87,7 +87,7 @@ void Xt9LdbManager::closeAll() QString Xt9LdbManager::findDictionary(const QLocale &locale) const { QStringList languageCountry = locale.name().split(QLatin1String("_")); - if (languageCountry.length() != 2) + if (languageCountry.size() != 2) return QString(); const QString language_ISO_639_1 = languageCountry[0].toUpper(); const QString country = languageCountry[1].toUpper(); @@ -139,9 +139,9 @@ QString Xt9LdbManager::findDictionary(const QLocale &locale) const (script == QLocale::TraditionalHanScript && charsetClassifier == QLatin1String("tb")))) ++score; - if (locale.country() == QLocale::Taiwan && xt9CountryOrDetail == QLatin1String("ps_Big5_bpmf_pinyin_CJ")) + if (locale.territory() == QLocale::Taiwan && xt9CountryOrDetail == QLatin1String("ps_Big5_bpmf_pinyin_CJ")) ++score; - else if (locale.country() == QLocale::HongKong && xt9CountryOrDetail == QLatin1String("ps_Big5HKSCS_bpmf_pinyin_CJ")) + else if (locale.territory() == QLocale::HongKong && xt9CountryOrDetail == QLatin1String("ps_Big5HKSCS_bpmf_pinyin_CJ")) ++score; if (!almClassifier.isEmpty()) diff --git a/src/plugins/cerence/hwr/CMakeLists.txt b/src/plugins/cerence/hwr/CMakeLists.txt index 472a3475..641a943f 100644 --- a/src/plugins/cerence/hwr/CMakeLists.txt +++ b/src/plugins/cerence/hwr/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from cerence-hwr.pro. add_subdirectory(plugin) diff --git a/src/plugins/cerence/hwr/plugin/CMakeLists.txt b/src/plugins/cerence/hwr/plugin/CMakeLists.txt index f1342077..d566c1eb 100644 --- a/src/plugins/cerence/hwr/plugin/CMakeLists.txt +++ b/src/plugins/cerence/hwr/plugin/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtVirtualKeyboardCerenceHwrPlugin Plugin: ##################################################################### @@ -5,6 +8,7 @@ qt_internal_add_qml_module(qtvkbcerencehwrplugin URI "QtQuick.VirtualKeyboard.Plugins.Cerence.HWR" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbcerencehwrplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -28,6 +32,7 @@ qt_internal_add_qml_module(qtvkbcerencehwrplugin Qt::Gui Qt::Qml Qt::VirtualKeyboardPrivate + NO_GENERATE_CPP_EXPORTS ) # Resources: @@ -61,7 +66,7 @@ endif() if (QT_FEATURE_vkb_lang_cs_CZ) list(APPEND qmake_virtualkeyboard_cerence_hwr_layouts_resource_files - "${VKB_LAYOUTS_BASE}/cs_CZ/handwriting.qml" + "${VKB_LAYOUTS_BASE}/cs_CZ/handwriting.fallback" ) endif() @@ -133,13 +138,13 @@ endif() if (QT_FEATURE_vkb_lang_hr_HR) list(APPEND qmake_virtualkeyboard_cerence_hwr_layouts_resource_files - "${VKB_LAYOUTS_BASE}/hr_HR/handwriting.qml" + "${VKB_LAYOUTS_BASE}/hr_HR/handwriting.fallback" ) endif() if (QT_FEATURE_vkb_lang_hu_HU) list(APPEND qmake_virtualkeyboard_cerence_hwr_layouts_resource_files - "${VKB_LAYOUTS_BASE}/hu_HU/handwriting.qml" + "${VKB_LAYOUTS_BASE}/hu_HU/handwriting.fallback" ) endif() @@ -193,7 +198,7 @@ endif() if (QT_FEATURE_vkb_lang_ro_RO) list(APPEND qmake_virtualkeyboard_cerence_hwr_layouts_resource_files - "${VKB_LAYOUTS_BASE}/ro_RO/handwriting.qml" + "${VKB_LAYOUTS_BASE}/ro_RO/handwriting.fallback" ) endif() diff --git a/src/plugins/cerence/hwr/plugin/content/layouts/zh_HK/handwriting.qml b/src/plugins/cerence/hwr/plugin/content/layouts/zh_HK/handwriting.qml index d43f060f..a2548b89 100644 --- a/src/plugins/cerence/hwr/plugin/content/layouts/zh_HK/handwriting.qml +++ b/src/plugins/cerence/hwr/plugin/content/layouts/zh_HK/handwriting.qml @@ -29,46 +29,45 @@ KeyboardLayout { } KeyboardRow { - Layout.preferredHeight: 3 - TraceInputKey { - objectName: "hwrInputArea" - patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting - horizontalRulers: - InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : - [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + KeyboardColumn { + Layout.preferredWidth: 1 + InputModeKey { + } + ChangeLanguageKey { + visible: true + } + ShiftKey { + } + HandwritingModeKey { + } } - } - KeyboardRow { - id: bottomRow - Layout.preferredHeight: 1 - keyWeight: 160 - ShiftKey { - weight: 240 - } - InputModeKey { - } - Key { - key: Qt.Key_Comma - text: "、" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } - SpaceKey { - weight: 10 * 160 - 4 * 160 - 2 * 240 - } - Key { - key: Qt.Key_Period - text: "。" - alternativeKeys: "¥‘’“”~…—《》〈〉「」\",.:;。?!" - smallText: "!?" - smallTextVisible: true - highlighted: true - } - BackspaceKey { + KeyboardColumn { + Layout.preferredWidth: 8 + TraceInputKey { + objectName: "hwrInputArea" + patternRecognitionMode: InputEngine.PatternRecognitionMode.Handwriting + horizontalRulers: + InputContext.inputEngine.inputMode !== InputEngine.InputMode.ChineseHandwriting ? [] : + [Math.round(boundingBox.height / 4), Math.round(boundingBox.height / 4) * 2, Math.round(boundingBox.height / 4) * 3] + } } - EnterKey { - weight: 240 + KeyboardColumn { + Layout.preferredWidth: 1 + Key { + key: Qt.Key_Period + text: "。" + alternativeKeys: "¥‘’“”~…—\",.:;、。?! " + smallText: "!?" + smallTextVisible: true + highlighted: true + } + HideKeyboardKey { + visible: true + } + BackspaceKey { + } + EnterKey { + } } } } diff --git a/src/plugins/cerence/hwr/plugin/t9writeinputmethod.cpp b/src/plugins/cerence/hwr/plugin/t9writeinputmethod.cpp index f6addb5e..bf0a0807 100644 --- a/src/plugins/cerence/hwr/plugin/t9writeinputmethod.cpp +++ b/src/plugins/cerence/hwr/plugin/t9writeinputmethod.cpp @@ -71,9 +71,9 @@ public: textCaseList.clear(); return; } - while (length < textCaseList.length()) + while (length < textCaseList.size()) textCaseList.removeLast(); - while (length > textCaseList.length()) + while (length > textCaseList.size()) textCaseList.append(textCase); } @@ -82,7 +82,7 @@ public: QString result; QVirtualKeyboardInputEngine::TextCase textCase = QVirtualKeyboardInputEngine::TextCase::Lower; for (int i = 0; i < str.length(); ++i) { - if (i < textCaseList.length()) + if (i < textCaseList.size()) textCase = textCaseList.at(i); result.append(textCase == QVirtualKeyboardInputEngine::TextCase::Upper ? str.at(i).toUpper() : (preferLowercase ? str.at(i).toLower() : str.at(i))); } @@ -818,7 +818,7 @@ public: switch (locale.language()) { case QLocale::Chinese: { if (locale.script() == QLocale::TraditionalChineseScript) - return locale.country() == QLocale::HongKong ? T9WriteInputMethod::EngineMode::HongKongChinese : T9WriteInputMethod::EngineMode::TraditionalChinese; + return locale.territory() == QLocale::HongKong ? T9WriteInputMethod::EngineMode::HongKongChinese : T9WriteInputMethod::EngineMode::TraditionalChinese; return T9WriteInputMethod::EngineMode::SimplifiedChinese; } case QLocale::Japanese: @@ -1277,7 +1277,7 @@ public: { QCryptographicHash hash(QCryptographicHash::Md5); - hash.addData(reinterpret_cast<const char *>(&patternRecognitionMode), sizeof(patternRecognitionMode)); + hash.addData(QByteArrayView(reinterpret_cast<const char *>(&patternRecognitionMode), sizeof(patternRecognitionMode))); QByteArray mapData; QDataStream ds(&mapData, QIODevice::WriteOnly); @@ -1359,9 +1359,9 @@ public: } // Check for hard limit on the size the trace list - if (traceList.count() >= traceListHardLimit) { + if (traceList.size() >= traceListHardLimit) { worker->waitForAllTasksOfType<T9WriteAddArcTask>(); - while (traceListHardLimit < traceList.count()) + while (traceListHardLimit < traceList.size()) delete traceList.takeFirst(); } @@ -1437,7 +1437,7 @@ public: int countActiveTraces() const { int count = 0; - for (QVirtualKeyboardTrace *trace : qAsConst(traceList)) { + for (QVirtualKeyboardTrace *trace : std::as_const(traceList)) { if (!trace->isFinal()) count++; } @@ -1839,8 +1839,8 @@ public: } // Enforce hard limit for number of traces - if (traceList.count() >= traceListHardLimit) { - qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::processResult(): Clearing traces (hard limit):" << traceList.count(); + if (traceList.size() >= traceListHardLimit) { + qCDebug(lcT9Write) << "T9WriteInputMethodPrivate::processResult(): Clearing traces (hard limit):" << traceList.size(); clearTraces(); } } @@ -1924,7 +1924,7 @@ public: if (countActiveTraces() > 0) return false; - QVariantMap gesture(gestureRecognizer.recognize(traceList.mid(traceList.length() - 1, 1))); + QVariantMap gesture(gestureRecognizer.recognize(traceList.mid(traceList.size() - 1, 1))); if (gesture.isEmpty()) return false; @@ -1984,9 +1984,9 @@ public: inputModes.removeAt(inputMode != QVirtualKeyboardInputEngine::InputMode::Dialable ? indexOfDialableInputMode : indexOfNumericInputMode); - if (inputModes.count() > 1) { + if (inputModes.size() > 1) { int inputModeIndex = inputModes.indexOf(static_cast<const int>(inputMode)) + 1; - if (inputModeIndex >= inputModes.count()) + if (inputModeIndex >= inputModes.size()) inputModeIndex = 0; ic->inputEngine()->setInputMode(static_cast<QVirtualKeyboardInputEngine::InputMode>(inputModes.at(inputModeIndex))); } @@ -2580,7 +2580,7 @@ int T9WriteInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListMode { Q_UNUSED(type); Q_D(T9WriteInputMethod); - return d->wordCandidates.count(); + return d->wordCandidates.size(); } QVariant T9WriteInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) diff --git a/src/plugins/cerence/hwr/plugin/t9writeinputmethod_p.h b/src/plugins/cerence/hwr/plugin/t9writeinputmethod_p.h index fa103313..b8abb8d1 100644 --- a/src/plugins/cerence/hwr/plugin/t9writeinputmethod_p.h +++ b/src/plugins/cerence/hwr/plugin/t9writeinputmethod_p.h @@ -28,6 +28,7 @@ class T9WriteInputMethod : public QVirtualKeyboardAbstractInputMethod Q_OBJECT Q_DECLARE_PRIVATE(T9WriteInputMethod) QML_NAMED_ELEMENT(HandwritingInputMethod) + QML_ADDED_IN_VERSION(2, 0) public: enum class EngineMode { diff --git a/src/plugins/cerence/hwr/plugin/t9writeworker.cpp b/src/plugins/cerence/hwr/plugin/t9writeworker.cpp index 9286b187..1a127c71 100644 --- a/src/plugins/cerence/hwr/plugin/t9writeworker.cpp +++ b/src/plugins/cerence/hwr/plugin/t9writeworker.cpp @@ -305,7 +305,7 @@ void T9WriteDlmWordTask::run() static_cast<DECUMA_UINT16>(word.length()), &recSettings, matchResults.data()); if (!status) { - for (const auto &matchResult : qAsConst(matchResults)) { + for (const auto &matchResult : std::as_const(matchResults)) { qCDebug(lcT9Write) << "T9WriteDlmWordTask::run(): MatchWord string type" << matchResult.stringType; if (matchResult.stringType != notFromDictionary) { wordFound = true; @@ -414,7 +414,7 @@ int T9WriteWorker::removeAllTasks() { idleSema.acquire(); QMutexLocker guard(&taskLock); - int count = taskList.count(); + int count = taskList.size(); for (QSharedPointer<T9WriteTask> task : taskList) { task->runSema.release(); } @@ -439,7 +439,7 @@ void T9WriteWorker::waitForAllTasks() int T9WriteWorker::numberOfPendingTasks() { QMutexLocker guard(&taskLock); - return taskList.count(); + return taskList.size(); } void T9WriteWorker::run() diff --git a/src/plugins/cerence/unpack.py b/src/plugins/cerence/unpack.py index 507aa550..825d333e 100644 --- a/src/plugins/cerence/unpack.py +++ b/src/plugins/cerence/unpack.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # Copyright (C) 2021 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys diff --git a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/ja_JP/main.qml b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/ja_JP/main.qml index c39c326f..155d801e 100644 --- a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/ja_JP/main.qml +++ b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/ja_JP/main.qml @@ -114,7 +114,7 @@ KeyboardLayoutLoader { key: Qt.Key_Comma text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() } FlickKey { text: "わ" @@ -147,7 +147,9 @@ KeyboardLayoutLoader { key: Qt.Key_Space highlighted: true } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } EnterKey {} } } @@ -245,7 +247,7 @@ KeyboardLayoutLoader { key: Qt.Key_Comma text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() } FlickKey { text: "ワ" @@ -278,7 +280,9 @@ KeyboardLayoutLoader { key: Qt.Key_Space highlighted: true } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } EnterKey {} } } @@ -436,7 +440,7 @@ KeyboardLayoutLoader { Layout.fillWidth: false text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { @@ -627,7 +631,7 @@ KeyboardLayoutLoader { Layout.fillWidth: false text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { diff --git a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_CN/main.qml b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_CN/main.qml index 11a92ea1..be10d434 100644 --- a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_CN/main.qml +++ b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_CN/main.qml @@ -121,7 +121,7 @@ KeyboardLayout { key: Qt.Key_Comma text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() } Key { key: Qt.Key_0 @@ -156,7 +156,9 @@ KeyboardLayout { key: Qt.Key_Space highlighted: true } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } EnterKey {} } } diff --git a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_TW/main.qml b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_TW/main.qml index 0d0f7322..9754bdb5 100644 --- a/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_TW/main.qml +++ b/src/plugins/cerence/xt9/plugin/9key_layouts/content/layouts/zh_TW/main.qml @@ -117,7 +117,7 @@ KeyboardLayout { key: Qt.Key_Comma text: "\u3001" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() } Key { key: Qt.Key_0 @@ -152,7 +152,9 @@ KeyboardLayout { key: Qt.Key_Space highlighted: true } - HideKeyboardKey {} + HideKeyboardKey { + visible: true + } EnterKey {} } } diff --git a/src/plugins/cerence/xt9/plugin/CMakeLists.txt b/src/plugins/cerence/xt9/plugin/CMakeLists.txt index a1a08742..4494c68e 100644 --- a/src/plugins/cerence/xt9/plugin/CMakeLists.txt +++ b/src/plugins/cerence/xt9/plugin/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtVirtualKeyboardXt9Plugin Plugin: ##################################################################### @@ -5,6 +8,7 @@ qt_internal_add_qml_module(qtvkbcerencext9plugin URI "QtQuick.VirtualKeyboard.Plugins.Cerence.XT9" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbcerencext9plugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -34,6 +38,7 @@ qt_internal_add_qml_module(qtvkbcerencext9plugin Qt::Gui Qt::Qml Qt::VirtualKeyboardPrivate + NO_GENERATE_CPP_EXPORTS ) set(qmake_virtualkeyboard_xt9_layouts_resource_files) diff --git a/src/plugins/cerence/xt9/plugin/content/layouts/ja_JP/main.qml b/src/plugins/cerence/xt9/plugin/content/layouts/ja_JP/main.qml index f49e7a3a..b837d257 100644 --- a/src/plugins/cerence/xt9/plugin/content/layouts/ja_JP/main.qml +++ b/src/plugins/cerence/xt9/plugin/content/layouts/ja_JP/main.qml @@ -217,15 +217,6 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "\u3001" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } InputModeKey { weight: normalKeyWidth Layout.fillWidth: false @@ -243,6 +234,19 @@ KeyboardLayoutLoader { "全角", // InputEngine.InputMode.FullwidthLatin ] } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + weight: normalKeyWidth + Layout.fillWidth: false + text: "\u3001" + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } SpaceKey { } Key { @@ -255,6 +259,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } BackspaceKey { weight: normalKeyWidth Layout.fillWidth: false @@ -461,15 +469,6 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "\u3001" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } InputModeKey { weight: normalKeyWidth Layout.fillWidth: false @@ -487,6 +486,19 @@ KeyboardLayoutLoader { "全角", // InputEngine.InputMode.FullwidthLatin ] } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + weight: normalKeyWidth + Layout.fillWidth: false + text: "\u3001" + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } SpaceKey { } Key { @@ -499,6 +511,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } BackspaceKey { weight: normalKeyWidth Layout.fillWidth: false @@ -656,15 +672,6 @@ KeyboardLayoutLoader { Layout.preferredWidth: functionKeyWidth Layout.fillWidth: false } - Key { - key: Qt.Key_Comma - Layout.preferredWidth: normalKeyWidth - Layout.fillWidth: false - text: "\u3001" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } InputModeKey { enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 Layout.preferredWidth: normalKeyWidth @@ -682,6 +689,19 @@ KeyboardLayoutLoader { "全角", // InputEngine.InputMode.FullwidthLatin ] } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + Layout.preferredWidth: normalKeyWidth + Layout.fillWidth: false + text: "\u3001" + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } SpaceKey { } Key { @@ -694,6 +714,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { Layout.preferredWidth: functionKeyWidth Layout.fillWidth: false @@ -847,15 +871,6 @@ KeyboardLayoutLoader { weight: functionKeyWidth Layout.fillWidth: false } - Key { - key: Qt.Key_Comma - weight: normalKeyWidth - Layout.fillWidth: false - text: "\u3001" - smallText: "\u2699" - smallTextVisible: true - highlighted: true - } InputModeKey { enabled: !(InputContext.inputMethodHints & Qt.ImhLatinOnly) && inputModeCount > 1 weight: normalKeyWidth @@ -873,6 +888,19 @@ KeyboardLayoutLoader { "全角", // InputEngine.InputMode.FullwidthLatin ] } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } + Key { + key: Qt.Key_Comma + weight: normalKeyWidth + Layout.fillWidth: false + text: "\u3001" + smallText: "\u2699" + smallTextVisible: keyboard.isFunctionPopupListAvailable() + highlighted: true + } SpaceKey { } Key { @@ -885,6 +913,10 @@ KeyboardLayoutLoader { smallTextVisible: true highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/main.qml b/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/main.qml index 97249653..e54efca9 100644 --- a/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/main.qml +++ b/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/main.qml @@ -130,13 +130,17 @@ KeyboardLayout { weight: functionKeyWidth Layout.fillWidth: false } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "\uFF0C" smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } InputModeKey { diff --git a/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/symbols.qml b/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/symbols.qml index 6d140828..3205ae53 100644 --- a/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/symbols.qml +++ b/src/plugins/cerence/xt9/plugin/content/layouts/zh_HK/symbols.qml @@ -151,13 +151,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -169,6 +173,10 @@ KeyboardLayoutLoader { text: "—" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -288,13 +296,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -306,6 +318,10 @@ KeyboardLayoutLoader { text: "。" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false @@ -424,13 +440,17 @@ KeyboardLayoutLoader { Layout.fillWidth: false displayText: "ABC" } + ChangeLanguageKey { + weight: normalKeyWidth + Layout.fillWidth: false + } Key { key: Qt.Key_Comma weight: normalKeyWidth Layout.fillWidth: false text: "," smallText: "\u2699" - smallTextVisible: true + smallTextVisible: keyboard.isFunctionPopupListAvailable() highlighted: true } SpaceKey { @@ -442,6 +462,10 @@ KeyboardLayoutLoader { text: "…" highlighted: true } + HideKeyboardKey { + weight: normalKeyWidth + Layout.fillWidth: false + } EnterKey { weight: functionKeyWidth Layout.fillWidth: false diff --git a/src/plugins/cerence/xt9/plugin/xt9awinputmethod.cpp b/src/plugins/cerence/xt9/plugin/xt9awinputmethod.cpp index 69db29c6..f0794be2 100644 --- a/src/plugins/cerence/xt9/plugin/xt9awinputmethod.cpp +++ b/src/plugins/cerence/xt9/plugin/xt9awinputmethod.cpp @@ -152,7 +152,7 @@ int Xt9AwInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListModel: { Q_UNUSED(type) Q_D(Xt9AwInputMethod); - return d->selectionList.count(); + return d->selectionList.size(); } QVariant Xt9AwInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) diff --git a/src/plugins/cerence/xt9/plugin/xt9awinputmethod_p.h b/src/plugins/cerence/xt9/plugin/xt9awinputmethod_p.h index b1eaee3b..a2eb521b 100644 --- a/src/plugins/cerence/xt9/plugin/xt9awinputmethod_p.h +++ b/src/plugins/cerence/xt9/plugin/xt9awinputmethod_p.h @@ -16,6 +16,8 @@ class Xt9AwInputMethod : public Xt9InputMethod Q_OBJECT Q_DECLARE_PRIVATE(Xt9AwInputMethod) QML_NAMED_ELEMENT(DefaultInputMethod) + QML_ADDED_IN_VERSION(2, 0) + protected: Xt9AwInputMethod(Xt9AwInputMethodPrivate &dd, QObject *parent = nullptr); diff --git a/src/plugins/cerence/xt9/plugin/xt9awinputmethodprivate.cpp b/src/plugins/cerence/xt9/plugin/xt9awinputmethodprivate.cpp index b1689795..4bb3c691 100644 --- a/src/plugins/cerence/xt9/plugin/xt9awinputmethodprivate.cpp +++ b/src/plugins/cerence/xt9/plugin/xt9awinputmethodprivate.cpp @@ -53,7 +53,7 @@ void Xt9AwInputMethodPrivate::selectionListSelectItem(int index) Q_Q(Xt9AwInputMethod); Xt9DeferredSelectionListUpdate deferredSelectionListUpdate(this); - if (index >= 0 && index < selectionList.count()) { + if (index >= 0 && index < selectionList.size()) { QVirtualKeyboardInputContext *ic = q->inputContext(); const QString &selectedWord = selectionList.at(index); diff --git a/src/plugins/cerence/xt9/plugin/xt9cpinputmethod.cpp b/src/plugins/cerence/xt9/plugin/xt9cpinputmethod.cpp index fc906fc9..f8a59334 100644 --- a/src/plugins/cerence/xt9/plugin/xt9cpinputmethod.cpp +++ b/src/plugins/cerence/xt9/plugin/xt9cpinputmethod.cpp @@ -100,7 +100,7 @@ int Xt9CpInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListModel: { Q_UNUSED(type) Q_D(Xt9CpInputMethod); - return d->selectionList.count(); + return d->selectionList.size(); } QVariant Xt9CpInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) diff --git a/src/plugins/cerence/xt9/plugin/xt9cpinputmethod_p.h b/src/plugins/cerence/xt9/plugin/xt9cpinputmethod_p.h index 12df80a1..6486c662 100644 --- a/src/plugins/cerence/xt9/plugin/xt9cpinputmethod_p.h +++ b/src/plugins/cerence/xt9/plugin/xt9cpinputmethod_p.h @@ -16,6 +16,8 @@ class Xt9CpInputMethod : public Xt9InputMethod Q_OBJECT Q_DECLARE_PRIVATE(Xt9CpInputMethod) QML_NAMED_ELEMENT(PinyinInputMethod) + QML_ADDED_IN_VERSION(2, 0) + public: explicit Xt9CpInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/cerence/xt9/plugin/xt9jinputmethod_p.h b/src/plugins/cerence/xt9/plugin/xt9jinputmethod_p.h index e3db27fc..0c4e37c1 100644 --- a/src/plugins/cerence/xt9/plugin/xt9jinputmethod_p.h +++ b/src/plugins/cerence/xt9/plugin/xt9jinputmethod_p.h @@ -17,6 +17,8 @@ class Xt9JInputMethod : public Xt9AwInputMethod Q_DECLARE_PRIVATE(Xt9JInputMethod) Q_PROPERTY(bool modifyKeyEnabled READ isModifyKeyEnabled NOTIFY modifyKeyEnabledChanged) QML_NAMED_ELEMENT(JapaneseInputMethod) + QML_ADDED_IN_VERSION(2, 0) + public: explicit Xt9JInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/cerence/xt9/plugin/xt9kinputmethod.cpp b/src/plugins/cerence/xt9/plugin/xt9kinputmethod.cpp index 7f725b09..956df3cf 100644 --- a/src/plugins/cerence/xt9/plugin/xt9kinputmethod.cpp +++ b/src/plugins/cerence/xt9/plugin/xt9kinputmethod.cpp @@ -29,7 +29,7 @@ void Xt9KInputMethod::update() Q_D(Xt9KInputMethod); if (d->xt9Ime()->hasActiveInput()) { - if (d->selectionList.length() > 0) { + if (d->selectionList.size() > 0) { d->learnWord(d->selectionList.at(0)); d->setAutoSpaceAllowed(false); d->selectionListSelectItem(0); diff --git a/src/plugins/cerence/xt9/plugin/xt9kinputmethod_p.h b/src/plugins/cerence/xt9/plugin/xt9kinputmethod_p.h index 73761a25..e952163d 100644 --- a/src/plugins/cerence/xt9/plugin/xt9kinputmethod_p.h +++ b/src/plugins/cerence/xt9/plugin/xt9kinputmethod_p.h @@ -16,6 +16,8 @@ class Xt9KInputMethod : public Xt9AwInputMethod Q_OBJECT Q_DECLARE_PRIVATE(Xt9KInputMethod) QML_NAMED_ELEMENT(HangulInputMethod) + QML_ADDED_IN_VERSION(2, 0) + public: explicit Xt9KInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/cerence/xt9/plugin/xt9thaiinputmethod_p.h b/src/plugins/cerence/xt9/plugin/xt9thaiinputmethod_p.h index 5ba7b882..b7665cb1 100644 --- a/src/plugins/cerence/xt9/plugin/xt9thaiinputmethod_p.h +++ b/src/plugins/cerence/xt9/plugin/xt9thaiinputmethod_p.h @@ -16,6 +16,8 @@ class Xt9ThaiInputMethod : public Xt9AwInputMethod Q_OBJECT Q_DECLARE_PRIVATE(Xt9ThaiInputMethod) QML_NAMED_ELEMENT(ThaiInputMethod) + QML_ADDED_IN_VERSION(2, 0) + public: explicit Xt9ThaiInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/cerence/xt9/xt9common/CMakeLists.txt b/src/plugins/cerence/xt9/xt9common/CMakeLists.txt index 0e670ed0..08a6b1d6 100644 --- a/src/plugins/cerence/xt9/xt9common/CMakeLists.txt +++ b/src/plugins/cerence/xt9/xt9common/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from xt9common.pro. ##################################################################### diff --git a/src/plugins/cerence/xt9/xt9common/xt9cpime.cpp b/src/plugins/cerence/xt9/xt9common/xt9cpime.cpp index 216c68c1..5dff7495 100644 --- a/src/plugins/cerence/xt9/xt9common/xt9cpime.cpp +++ b/src/plugins/cerence/xt9/xt9common/xt9cpime.cpp @@ -53,7 +53,7 @@ public: for (int i = 0; i < codes.size(); ++i) { cangjieBuf[i] = GetCangjieSymb(codes.at(i).unicode()); } - return QString::fromUtf16(reinterpret_cast<const char16_t *>(cangjieBuf.constData()), cangjieBuf.length()); + return QString::fromUtf16(reinterpret_cast<const char16_t *>(cangjieBuf.constData()), cangjieBuf.size()); } QString convertFrom(const QString &codes) const override @@ -62,7 +62,7 @@ public: for (int i = 0; i < codes.size(); ++i) { cangjieBuf[i] = GetCangjieMappingSymb(codes.at(i).unicode()); } - return QString::fromUtf16(reinterpret_cast<const char16_t *>(cangjieBuf.constData()), cangjieBuf.length()); + return QString::fromUtf16(reinterpret_cast<const char16_t *>(cangjieBuf.constData()), cangjieBuf.size()); } }; diff --git a/src/plugins/cerence/xt9/xt9common/xt9kime.cpp b/src/plugins/cerence/xt9/xt9common/xt9kime.cpp index 9a2205d2..76173728 100644 --- a/src/plugins/cerence/xt9/xt9common/xt9kime.cpp +++ b/src/plugins/cerence/xt9/xt9common/xt9kime.cpp @@ -12,16 +12,16 @@ public: { QVector<ushort> jamoBuf(codes.size()); memcpy(jamoBuf.data(), codes.utf16(), static_cast<size_t>(jamoBuf.size()) * sizeof(ushort)); - XT9_VAPI(ET9KCompatibilityJamoToJamo, jamoBuf.data(), static_cast<ET9U32>(jamoBuf.length())); - return QString::fromUtf16(reinterpret_cast<const char16_t *>(jamoBuf.constData()), jamoBuf.length()); + XT9_VAPI(ET9KCompatibilityJamoToJamo, jamoBuf.data(), static_cast<ET9U32>(jamoBuf.size())); + return QString::fromUtf16(reinterpret_cast<const char16_t *>(jamoBuf.constData()), jamoBuf.size()); } QString convertFrom(const QString &codes) const override { QVector<ushort> jamoBuf(codes.size()); memcpy(jamoBuf.data(), codes.utf16(), static_cast<size_t>(jamoBuf.size()) * sizeof(ushort)); - XT9_VAPI(ET9KJamoToCompatibilityJamo, jamoBuf.data(), static_cast<ET9U32>(jamoBuf.length())); - return QString::fromUtf16(reinterpret_cast<const char16_t *>(jamoBuf.constData()), jamoBuf.length()); + XT9_VAPI(ET9KJamoToCompatibilityJamo, jamoBuf.data(), static_cast<ET9U32>(jamoBuf.size())); + return QString::fromUtf16(reinterpret_cast<const char16_t *>(jamoBuf.constData()), jamoBuf.size()); } }; diff --git a/src/plugins/cerence/xt9/xt9common/xt9languagemap.cpp b/src/plugins/cerence/xt9/xt9common/xt9languagemap.cpp index 89ffd616..e53b562d 100644 --- a/src/plugins/cerence/xt9/xt9common/xt9languagemap.cpp +++ b/src/plugins/cerence/xt9/xt9common/xt9languagemap.cpp @@ -173,11 +173,11 @@ const struct Xt9LanguageMap::LanguageMapEntry Xt9LanguageMap::LANGUAGE_MAP[] = { ET9U32 Xt9LanguageMap::languageId(const QLocale &locale) { const QLocale::Language localeLanguage = locale.language(); - const QLocale::Country localeCountry = locale.country(); + const QLocale::Territory localeTerritory = locale.territory(); for (int i = 0; LANGUAGE_MAP[i].languageId != 0; ++i) { const QLocale &item = LANGUAGE_MAP[i].locale; - if (item.language() == localeLanguage && item.country() == localeCountry) + if (item.language() == localeLanguage && item.territory() == localeTerritory) return LANGUAGE_MAP[i].languageId; } diff --git a/src/plugins/example/CMakeLists.txt b/src/plugins/example/CMakeLists.txt new file mode 100644 index 00000000..a8976f9b --- /dev/null +++ b/src/plugins/example/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(hwr) +list(APPEND example_imports QtQuick.VirtualKeyboard.Plugins.Example.HWR/auto) + +qt_internal_add_qml_module(qtvkbexampleplugin + URI "QtQuick.VirtualKeyboard.Plugins.Example" + VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 + PLUGIN_TARGET qtvkbexampleplugin + IMPORTS + ${example_imports} + NO_GENERATE_CPP_EXPORTS +) diff --git a/src/plugins/example/hwr/CMakeLists.txt b/src/plugins/example/hwr/CMakeLists.txt new file mode 100644 index 00000000..61f64101 --- /dev/null +++ b/src/plugins/example/hwr/CMakeLists.txt @@ -0,0 +1,284 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_qml_module(qtvkbexamplehwrplugin + URI "QtQuick.VirtualKeyboard.Plugins.Example.HWR" + VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 + PLUGIN_TARGET qtvkbexamplehwrplugin + NO_PLUGIN_OPTIONAL + DEPENDENCIES + QtQuick.VirtualKeyboard/auto + SOURCES + examplehwrinputmethod.cpp examplehwrinputmethod_p.h + DEFINES + QT_ASCII_CAST_WARNINGS + QT_NO_CAST_FROM_ASCII + QT_NO_CAST_FROM_BYTEARRAY + QT_NO_CAST_TO_ASCII + LIBRARIES + Qt::Core + Qt::Gui + Qt::Qml + Qt::VirtualKeyboardPrivate + NO_GENERATE_CPP_EXPORTS +) + +set(qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/fallback/handwriting.qml" +) + +if (QT_FEATURE_vkb_lang_en_GB) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/en_GB/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_en_US) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/en_US/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_ar_AR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ar_AR/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_bg_BG) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/bg_BG/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_cs_CZ) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/cs_CZ/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_da_DK) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/da_DK/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_de_DE) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/de_DE/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_el_GR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/el_GR/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_es_ES) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/es_ES/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_es_MX) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/es_MX/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_et_EE) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/et_EE/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_fa_FA) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/fa_FA/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_fi_FI) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/fi_FI/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_fr_FR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/fr_FR/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_fr_CA) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/fr_CA/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_he_IL) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/he_IL/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_hr_HR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/hr_HR/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_hu_HU) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/hu_HU/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_id_ID) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/id_ID/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_it_IT) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/it_IT/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_ms_MY) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ms_MY/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_nb_NO) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/nb_NO/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_nl_NL) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/nl_NL/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_pl_PL) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/pl_PL/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_pt_BR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/pt_BR/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_pt_PT) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/pt_PT/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_ro_RO) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ro_RO/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_ru_RU) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ru_RU/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_sk_SK) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/sk_SK/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_sl_SI) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/sl_SI/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_sq_AL) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/sq_AL/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_sr_SP) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/sr_SP/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_sv_SE) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/sv_SE/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_th_TH) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/th_TH/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_tr_TR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/tr_TR/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_uk_UA) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/uk_UA/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_vi_VN) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/vi_VN/handwriting.fallback" + ) +endif() + +if (QT_FEATURE_vkb_lang_ja_JP) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ja_JP/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_ko_KR) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/ko_KR/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_zh_CN) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/zh_CN/handwriting.qml" + ) +endif() + +if (QT_FEATURE_vkb_lang_zh_TW) + list(APPEND qt_virtualkeyboard_example_hwr_layouts_resource_files + "${VKB_LAYOUTS_BASE}/zh_TW/handwriting.qml" + ) +endif() + +qt_internal_add_resource(qtvkbexamplehwrplugin "qt_virtualkeyboard_example_hwr_layouts" + PREFIX + "${VKB_LAYOUTS_PREFIX}" + BASE + "${VKB_LAYOUTS_BASE}" + FILES + ${qt_virtualkeyboard_example_hwr_layouts_resource_files} +) diff --git a/src/plugins/example/hwr/examplehwrinputmethod.cpp b/src/plugins/example/hwr/examplehwrinputmethod.cpp new file mode 100644 index 00000000..58d1d2c8 --- /dev/null +++ b/src/plugins/example/hwr/examplehwrinputmethod.cpp @@ -0,0 +1,632 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "examplehwrinputmethod_p.h" +#include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h> +#include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h> +#include <QtVirtualKeyboard/qvirtualkeyboardtrace.h> +#include <QtVirtualKeyboard/private/handwritinggesturerecognizer_p.h> +#include <QtVirtualKeyboard/private/settings_p.h> +#include <QtVirtualKeyboard/private/qvirtualkeyboardabstractinputmethod_p.h> +#include <QCryptographicHash> +#include <QRandomGenerator> +#include <QLoggingCategory> +#include <QLocale> + +QT_BEGIN_NAMESPACE +namespace QtVirtualKeyboard { + +Q_LOGGING_CATEGORY(lcExampleHwr, "qt.virtualkeyboard.example.hwr") + +class ExampleHwrInputMethodPrivate : public QVirtualKeyboardAbstractInputMethodPrivate +{ +public: + Q_DECLARE_PUBLIC(ExampleHwrInputMethod) + + ExampleHwrInputMethodPrivate(ExampleHwrInputMethod *q_ptr) : + QVirtualKeyboardAbstractInputMethodPrivate(), + q_ptr(q_ptr) + { + } + + bool setInputMode(const QLocale &locale, QVirtualKeyboardInputEngine::InputMode inputMode) + { + Q_UNUSED(locale); + finishRecognition(); + this->inputMode = inputMode; + return true; + } + + QByteArray getContext(QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, + const QVariantMap &traceScreenInfo) const + { + QCryptographicHash hash(QCryptographicHash::Md5); + + hash.addData(QByteArrayView(reinterpret_cast<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); + Q_UNUSED(traceScreenInfo); + if (context == currentContext) + return; + currentContext = context; + + qCDebug(lcExampleHwr) << "setContext:" << QLatin1String((context.toHex())); + + // Finish recognition, but preserve current input + const int dpi = traceCaptureDeviceInfo.value(QLatin1String("dpi"), 96).toInt(); + static const int INSTANT_GESTURE_WIDTH_THRESHOLD_MM = 25; + gestureWidthThreshold = qRound(INSTANT_GESTURE_WIDTH_THRESHOLD_MM / 25.4 * dpi); + + gestureRecognizer.setDpi(dpi); + } + + QVirtualKeyboardTrace *traceBegin( + int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo) + { + // The result id follows the trace id so that the (previous) + // results completed during the handwriting can be rejected. + resultId = traceId; + + QByteArray context = getContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo); + if (context != currentContext) { + setContext(patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo, context); + } + + Q_Q(ExampleHwrInputMethod); + QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace(q); + traceList.append(trace); + + return trace; + } + + void traceEnd(QVirtualKeyboardTrace *trace) + { + if (trace->isCanceled()) { + traceList.removeOne(trace); + delete trace; + } else if (handleGesture()) { + finishRecognition(); + return; + } + if (!traceList.isEmpty()) { + if (countActiveTraces() == 0) + restartRecognition(); + } + } + + int countActiveTraces() const + { + int count = 0; + for (QVirtualKeyboardTrace *trace : std::as_const(traceList)) { + if (!trace->isFinal()) + count++; + } + return count; + } + + void clearTraces() + { + qDeleteAll(traceList); + traceList.clear(); + } + + bool applyGesture(const QChar &gesture) + { + Q_Q(ExampleHwrInputMethod); + 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.size() - 1, 1))); + if (gesture.isEmpty()) + return false; + + qCDebug(lcExampleHwr) << "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 >= gestureWidthThreshold) { + + Q_Q(ExampleHwrInputMethod); + 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 + 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<int>(QVirtualKeyboardInputEngine::InputMode::Numeric)); + int indexOfDialableInputMode = inputModes.indexOf(static_cast<int>(QVirtualKeyboardInputEngine::InputMode::Dialable)); + if (indexOfNumericInputMode != -1 && indexOfDialableInputMode != -1) + inputModes.removeAt(inputMode != QVirtualKeyboardInputEngine::InputMode::Dialable ? + indexOfDialableInputMode : + indexOfNumericInputMode); + if (inputModes.size() > 1) { + int inputModeIndex = inputModes.indexOf(static_cast<int>(inputMode)) + 1; + if (inputModeIndex >= inputModes.size()) + 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 ExampleHwrInputMethod); + 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; + } + + void restartRecognition() + { + qCDebug(lcExampleHwr) << "restartRecognition"; + + resetResultTimer(Settings::instance()->hwrTimeoutForAlphabetic()); + } + + bool finishRecognition(bool emitSelectionListChanged = true) + { + qCDebug(lcExampleHwr) << "finishRecognition"; + bool result = !traceList.isEmpty(); + + stopResultTimer(); + clearTraces(); + + if (!wordCandidates.isEmpty()) { + wordCandidates.clear(); + activeWordIndex = -1; + if (emitSelectionListChanged) { + Q_Q(ExampleHwrInputMethod); + emit q->selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList); + emit q->selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, activeWordIndex); + } + result = true; + } + + return result; + } + + void select(int index = -1) + { + Q_Q(ExampleHwrInputMethod); + QVirtualKeyboardInputContext *ic = q->inputContext(); + if (!ic) + return; + + if (!wordCandidates.isEmpty()) + ic->commit(wordCandidates.at(index != -1 ? index : 0)); + + finishRecognition(); + } + + void processResult() + { + qCDebug(lcExampleHwr) << "processResult"; + + Q_Q(ExampleHwrInputMethod); + QVirtualKeyboardInputContext *ic = q->inputContext(); + if (!ic) + return; + + QStringList newWordCandidates; + QString word = !wordCandidates.isEmpty() ? wordCandidates.at(0) : QString(); + switch (inputMode) { + case QVirtualKeyboardInputEngine::InputMode::Latin: + appendRandomChar(word); + break; + case QVirtualKeyboardInputEngine::InputMode::Numeric: + case QVirtualKeyboardInputEngine::InputMode::Dialable: + appendRandomDigit(word); + break; + default: + break; + } + newWordCandidates.append(word); + activeWordIndex = 0; + wordCandidates = newWordCandidates; + qCDebug(lcExampleHwr) << "wordCandidates" << wordCandidates; + ic->setPreeditText(word); + + emit q->selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList); + emit q->selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, activeWordIndex); + } + + static void appendRandomChar(QString& word) + { + word.append(QChar('a' + QRandomGenerator::global()->bounded(26))); + } + + static void appendRandomDigit(QString& word) + { + word.append(QChar('0' + QRandomGenerator::global()->bounded(10))); + } + + void resetResultTimer(int interval = 500) + { + qCDebug(lcExampleHwr) << "resetResultTimer:" << interval; + Q_Q(ExampleHwrInputMethod); + stopResultTimer(); + resultTimer = q->startTimer(interval); + } + + void stopResultTimer() + { + if (resultTimer) { + qCDebug(lcExampleHwr) << "stopResultTimer"; + Q_Q(ExampleHwrInputMethod); + q->killTimer(resultTimer); + resultTimer = 0; + } + } + + ExampleHwrInputMethod *q_ptr = nullptr; + QVirtualKeyboardInputEngine::InputMode inputMode = QVirtualKeyboardInputEngine::InputMode::Latin; + QByteArray currentContext; + int gestureWidthThreshold = 0; + int resultId = 0; + int lastResultId = 0; + int resultTimer = 0; + QList<QVirtualKeyboardTrace *> traceList; + HandwritingGestureRecognizer gestureRecognizer; + QStringList wordCandidates; + int activeWordIndex = -1; +}; + +/*! + \class QtVirtualKeyboard::ExampleHwrInputMethod + \internal +*/ + +ExampleHwrInputMethod::ExampleHwrInputMethod(QObject *parent) : + QVirtualKeyboardAbstractInputMethod(*new ExampleHwrInputMethodPrivate(this), parent) +{ +} + +ExampleHwrInputMethod::~ExampleHwrInputMethod() +{ +} + +QList<QVirtualKeyboardInputEngine::InputMode> ExampleHwrInputMethod::inputModes(const QString &locale) +{ + Q_UNUSED(locale); + QList<QVirtualKeyboardInputEngine::InputMode> availableInputModes = { + QVirtualKeyboardInputEngine::InputMode::Latin, + QVirtualKeyboardInputEngine::InputMode::Numeric, + }; + return availableInputModes; +} + +bool ExampleHwrInputMethod::setInputMode(const QString &locale, QVirtualKeyboardInputEngine::InputMode inputMode) +{ + Q_D(ExampleHwrInputMethod); + d->select(); + return d->setInputMode(QLocale(locale), inputMode); +} + +bool ExampleHwrInputMethod::setTextCase(QVirtualKeyboardInputEngine::TextCase textCase) +{ + Q_UNUSED(textCase); + return true; +} + +bool ExampleHwrInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers) +{ + Q_UNUSED(modifiers); + Q_D(ExampleHwrInputMethod); + 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); + emit selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList); + emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->activeWordIndex); + return true; + } else { + bool result = !preeditText.isEmpty(); + if (result) + ic->clear(); + d->finishRecognition(); + return result; + } + } + + default: + if (text.length() > 0) { + 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->finishRecognition(false); + 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; + } + } + return false; +} + +void ExampleHwrInputMethod::reset() +{ + Q_D(ExampleHwrInputMethod); + qCDebug(lcExampleHwr) << "reset"; + d->finishRecognition(); +} + +void ExampleHwrInputMethod::update() +{ + Q_D(ExampleHwrInputMethod); + qCDebug(lcExampleHwr) << "update"; + d->select(); +} + +QList<QVirtualKeyboardSelectionListModel::Type> ExampleHwrInputMethod::selectionLists() +{ + return QList<QVirtualKeyboardSelectionListModel::Type>() << QVirtualKeyboardSelectionListModel::Type::WordCandidateList; +} + +int ExampleHwrInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListModel::Type type) +{ + Q_UNUSED(type); + Q_D(ExampleHwrInputMethod); + return d->wordCandidates.size(); +} + +QVariant ExampleHwrInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) +{ + QVariant result; + Q_D(ExampleHwrInputMethod); + switch (role) { + case QVirtualKeyboardSelectionListModel::Role::Display: + result = QVariant(d->wordCandidates.at(index)); + break; + case QVirtualKeyboardSelectionListModel::Role::WordCompletionLength: + result.setValue(0); + break; + case QVirtualKeyboardSelectionListModel::Role::Dictionary: + { + QVirtualKeyboardSelectionListModel::DictionaryType dictionaryType = + QVirtualKeyboardSelectionListModel::DictionaryType::Default; + result = QVariant(static_cast<int>(dictionaryType)); + break; + } + case QVirtualKeyboardSelectionListModel::Role::CanRemoveSuggestion: + result = QVariant(false); + break; + default: + result = QVirtualKeyboardAbstractInputMethod::selectionListData(type, index, role); + break; + } + return result; +} + +void ExampleHwrInputMethod::selectionListItemSelected(QVirtualKeyboardSelectionListModel::Type type, int index) +{ + Q_UNUSED(type); + Q_D(ExampleHwrInputMethod); + d->select(index); +} + +QList<QVirtualKeyboardInputEngine::PatternRecognitionMode> ExampleHwrInputMethod::patternRecognitionModes() const +{ + return QList<QVirtualKeyboardInputEngine::PatternRecognitionMode>() + << QVirtualKeyboardInputEngine::PatternRecognitionMode::Handwriting; +} + +QVirtualKeyboardTrace *ExampleHwrInputMethod::traceBegin( + int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo) +{ + Q_D(ExampleHwrInputMethod); + return d->traceBegin(traceId, patternRecognitionMode, traceCaptureDeviceInfo, traceScreenInfo); +} + +bool ExampleHwrInputMethod::traceEnd(QVirtualKeyboardTrace *trace) +{ + Q_D(ExampleHwrInputMethod); + d->traceEnd(trace); + return true; +} + +bool ExampleHwrInputMethod::reselect(int cursorPosition, const QVirtualKeyboardInputEngine::ReselectFlags &reselectFlags) +{ + Q_D(ExampleHwrInputMethod); + + QVirtualKeyboardInputContext *ic = inputContext(); + if (!ic) + return false; + + const int maxLength = 32; + const QString surroundingText = ic->surroundingText(); + int replaceFrom = 0; + QString stringStart; + + if (cursorPosition > surroundingText.length()) + return false; + + if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordBeforeCursor)) { + for (int i = cursorPosition - 1; i >= 0 && stringStart.length() < maxLength; --i) { + QChar c = surroundingText.at(i); + if (!d->isValidInputChar(c)) + break; + stringStart.insert(0, c); + --replaceFrom; + } + + while (replaceFrom < 0 && d->isJoiner(stringStart.at(0))) { + stringStart.remove(0, 1); + ++replaceFrom; + } + } + + if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == 0) { + stringStart.clear(); + return false; + } + + if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAfterCursor)) { + for (int i = cursorPosition; i < surroundingText.length() && stringStart.length() < maxLength; ++i) { + QChar c = surroundingText.at(i); + if (!d->isValidInputChar(c)) + break; + stringStart.append(c); + } + + while (replaceFrom > -stringStart.length()) { + int lastPos = stringStart.length() - 1; + if (!d->isJoiner(stringStart.at(lastPos))) + break; + stringStart.remove(lastPos, 1); + } + } + + if (stringStart.isEmpty()) + return false; + + if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == -stringStart.length() && stringStart.length() < maxLength) { + stringStart.clear(); + return false; + } + + if (d->isJoiner(stringStart.at(0))) { + stringStart.clear(); + return false; + } + + if (d->isJoiner(stringStart.at(stringStart.length() - 1))) { + stringStart.clear(); + return false; + } + + ic->setPreeditText(stringStart, QList<QInputMethodEvent::Attribute>(), replaceFrom, stringStart.length()); + d->activeWordIndex = 0; + d->wordCandidates = {stringStart}; + emit selectionListChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList); + emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->activeWordIndex); + + return true; +} + +void ExampleHwrInputMethod::timerEvent(QTimerEvent *timerEvent) +{ + Q_D(ExampleHwrInputMethod); + int timerId = timerEvent->timerId(); + qCDebug(lcExampleHwr) << "timerEvent():" << timerId; + if (timerId == d->resultTimer) { + if (!d->countActiveTraces()) { + d->stopResultTimer(); + d->processResult(); + d->clearTraces(); + } + } +} + +} // namespace QtVirtualKeyboard +QT_END_NAMESPACE diff --git a/src/plugins/example/hwr/examplehwrinputmethod_p.h b/src/plugins/example/hwr/examplehwrinputmethod_p.h new file mode 100644 index 00000000..3bb47c3f --- /dev/null +++ b/src/plugins/example/hwr/examplehwrinputmethod_p.h @@ -0,0 +1,65 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef EXAMPLEHWRINPUTMETHOD_P_H +#define EXAMPLEHWRINPUTMETHOD_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> + +QT_BEGIN_NAMESPACE +namespace QtVirtualKeyboard { + +class ExampleHwrInputMethodPrivate; + +class ExampleHwrInputMethod : public QVirtualKeyboardAbstractInputMethod +{ + Q_OBJECT + Q_DECLARE_PRIVATE(ExampleHwrInputMethod) + QML_NAMED_ELEMENT(HandwritingInputMethod) + QML_ADDED_IN_VERSION(2, 0) + +public: + explicit ExampleHwrInputMethod(QObject *parent = nullptr); + ~ExampleHwrInputMethod(); + + QList<QVirtualKeyboardInputEngine::InputMode> inputModes(const QString &locale) override; + bool setInputMode(const QString &locale, QVirtualKeyboardInputEngine::InputMode inputMode) override; + bool setTextCase(QVirtualKeyboardInputEngine::TextCase textCase) override; + + bool keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers) override; + + void reset() override; + void update() override; + + QList<QVirtualKeyboardSelectionListModel::Type> selectionLists() override; + int selectionListItemCount(QVirtualKeyboardSelectionListModel::Type type) override; + QVariant selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) override; + void selectionListItemSelected(QVirtualKeyboardSelectionListModel::Type type, int index) override; + + QList<QVirtualKeyboardInputEngine::PatternRecognitionMode> patternRecognitionModes() const override; + QVirtualKeyboardTrace *traceBegin( + int traceId, QVirtualKeyboardInputEngine::PatternRecognitionMode patternRecognitionMode, + const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo) override; + bool traceEnd(QVirtualKeyboardTrace *trace) override; + + bool reselect(int cursorPosition, const QVirtualKeyboardInputEngine::ReselectFlags &reselectFlags) override; + +protected: + void timerEvent(QTimerEvent *timerEvent) override; +}; + +} // namespace QtVirtualKeyboard +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/hangul/CMakeLists.txt b/src/plugins/hangul/CMakeLists.txt index 34931c1e..41e4ee47 100644 --- a/src/plugins/hangul/CMakeLists.txt +++ b/src/plugins/hangul/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtVirtualKeyboardHangulPlugin Plugin: ##################################################################### @@ -5,6 +8,7 @@ qt_internal_add_qml_module(qtvkbhangulplugin URI "QtQuick.VirtualKeyboard.Plugins.Hangul" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbhangulplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -22,6 +26,7 @@ qt_internal_add_qml_module(qtvkbhangulplugin Qt::Gui Qt::Qml Qt::VirtualKeyboard + NO_GENERATE_CPP_EXPORTS ) # Resources: diff --git a/src/plugins/hangul/hangul.cpp b/src/plugins/hangul/hangul.cpp index d6e3f384..60f352ec 100644 --- a/src/plugins/hangul/hangul.cpp +++ b/src/plugins/hangul/hangul.cpp @@ -37,7 +37,7 @@ const int Hangul::SCount = Hangul::LCount * Hangul::NCount; // 11172 QString Hangul::decompose(const QString &source) { QString result; - const int len = source.length(); + const int len = source.size(); for (int i = 0; i < len; i++) { QChar ch = source.at(i); int SIndex = (int)ch.unicode() - SBase; @@ -80,7 +80,7 @@ QString Hangul::decompose(const QString &source) QString Hangul::compose(const QString &source) { - const int len = source.length(); + const int len = source.size(); if (len == 0) return QString(); @@ -112,7 +112,7 @@ QString Hangul::compose(const QString &source) TIndex = finals.indexOf(unicode); if (TIndex != -1) { last = QChar((int)lastUnicode + TIndex); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); continue; } @@ -137,7 +137,7 @@ QString Hangul::compose(const QString &source) HangulMedialIndex VIndexD = it.value(); int VDiff = (int)VIndexD - (int)VIndexA; last = QChar((int)lastUnicode + VDiff * TCount); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); continue; } } @@ -162,7 +162,7 @@ QString Hangul::compose(const QString &source) // Remove the previous final jamo from the syllable, // making the current syllable of form LV last = QChar((int)lastUnicode - TIndex); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); // Make new syllable of form LV last = QChar(SBase + (LIndex * VCount + VIndex) * TCount); @@ -183,7 +183,7 @@ QString Hangul::compose(const QString &source) HangulFinalIndex TIndexA, TIndexB; unpackDoubleFinal(key, TIndexA, TIndexB); last = QChar((int)lastUnicode - TIndex + (int)TIndexA); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); // Add new syllable by combining the initial jamo // and the current vowel @@ -212,7 +212,7 @@ QString Hangul::compose(const QString &source) HangulFinalIndex TIndexD = it.value(); int TDiff = (int)TIndexD - (int)TIndexA; last = QChar((int)lastUnicode + TDiff); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); continue; } } @@ -231,7 +231,7 @@ QString Hangul::compose(const QString &source) int VIndex = (int)unicode - VBase; if (VIndex >= 0 && VIndex < VCount) { last = QChar(SBase + (LIndex * VCount + VIndex) * TCount); - result.replace(result.length() - 1, 1, last); + result.replace(result.size() - 1, 1, last); continue; } } diff --git a/src/plugins/hangul/hangulinputmethod.cpp b/src/plugins/hangul/hangulinputmethod.cpp index 8023ac36..eaadbcfa 100644 --- a/src/plugins/hangul/hangulinputmethod.cpp +++ b/src/plugins/hangul/hangulinputmethod.cpp @@ -51,8 +51,8 @@ bool HangulInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardM if (key == Qt::Key_Backspace) { int contextLength = cursorPosition > 1 ? 2 : 1; QString hangul = Hangul::decompose(ic->surroundingText().mid(cursorPosition - contextLength, contextLength)); - int length = hangul.length(); - if (hangul.length() > 1) { + int length = hangul.size(); + if (hangul.size() > 1) { ic->commit(Hangul::compose(hangul.left(length - 1)), -contextLength, contextLength); accept = true; } diff --git a/src/plugins/hangul/hangulinputmethod_p.h b/src/plugins/hangul/hangulinputmethod_p.h index 55e0dfdd..7421232c 100644 --- a/src/plugins/hangul/hangulinputmethod_p.h +++ b/src/plugins/hangul/hangulinputmethod_p.h @@ -27,6 +27,8 @@ class HangulInputMethod : public QVirtualKeyboardAbstractInputMethod Q_OBJECT Q_DECLARE_PRIVATE(HangulInputMethod) QML_ELEMENT + QML_ADDED_IN_VERSION(2, 0) + public: explicit HangulInputMethod(QObject *parent = nullptr); ~HangulInputMethod(); diff --git a/src/plugins/hunspell/3rdparty/hunspell/CMakeLists.txt b/src/plugins/hunspell/3rdparty/hunspell/CMakeLists.txt index aa97f346..73eb12ee 100644 --- a/src/plugins/hunspell/3rdparty/hunspell/CMakeLists.txt +++ b/src/plugins/hunspell/3rdparty/hunspell/CMakeLists.txt @@ -6,7 +6,7 @@ qt_internal_add_3rdparty_library(BundledHunspell QMAKE_LIB_NAME hunspell STATIC SOURCES - hunspell/config.h + ${CMAKE_CURRENT_BINARY_DIR}/hunspell/config.h hunspell/src/hunspell/affentry.cxx hunspell/src/hunspell/affentry.hxx hunspell/src/hunspell/affixmgr.cxx hunspell/src/hunspell/affixmgr.hxx hunspell/src/hunspell/atypes.hxx diff --git a/src/plugins/hunspell/CMakeLists.txt b/src/plugins/hunspell/CMakeLists.txt index e9a1be72..5f4d9015 100644 --- a/src/plugins/hunspell/CMakeLists.txt +++ b/src/plugins/hunspell/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + if(QT_FEATURE_3rdparty_hunspell) add_subdirectory(3rdparty/hunspell) endif() diff --git a/src/plugins/hunspell/module/CMakeLists.txt b/src/plugins/hunspell/module/CMakeLists.txt index 5fc2c8f4..b17ab545 100644 --- a/src/plugins/hunspell/module/CMakeLists.txt +++ b/src/plugins/hunspell/module/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtQuickVirtualKeyboardHunspellPlugin Plugin: ##################################################################### @@ -5,6 +8,7 @@ qt_internal_add_qml_module(HunspellInputMethod URI "QtQuick.VirtualKeyboard.Plugins.Hunspell" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbhunspellplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -26,8 +30,6 @@ qt_internal_add_qml_module(HunspellInputMethod Qt::Gui PUBLIC_LIBRARIES Qt::VirtualKeyboardPrivate - GENERATE_CPP_EXPORTS - GENERATE_PRIVATE_CPP_EXPORTS ) qt_internal_extend_target(HunspellInputMethod CONDITION QT_FEATURE_system_hunspell diff --git a/src/plugins/hunspell/module/hunspellinputmethod.cpp b/src/plugins/hunspell/module/hunspellinputmethod.cpp index e82cab2a..a066c927 100644 --- a/src/plugins/hunspell/module/hunspellinputmethod.cpp +++ b/src/plugins/hunspell/module/hunspellinputmethod.cpp @@ -83,7 +83,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar { QString word = d->wordCandidates.wordAt(0); if (!word.isEmpty()) { - word.remove(word.length() - 1, 1); + word.remove(word.size() - 1, 1); ic->setPreeditText(word); if (!word.isEmpty()) { d->wordCandidates.updateWord(0, word); @@ -105,7 +105,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar update(); break; } - if (text.length() > 0) { + if (text.size() > 0) { QChar c = text.at(0); QString word = d->wordCandidates.wordAt(0); bool addToWord = d->isValidInputChar(c) && (!word.isEmpty() || !d->isJoiner(c)); @@ -121,7 +121,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar - No space before the cursor - No spefic characters before the cursor; minus and apostrophe */ - if (!surroundingText.isEmpty() && cursorPosition == surroundingText.length()) { + if (!surroundingText.isEmpty() && cursorPosition == surroundingText.size()) { QChar lastChar = surroundingText.at(cursorPosition - 1); if (!lastChar.isSpace() && lastChar != QLatin1Char(Qt::Key_Minus) && @@ -148,7 +148,7 @@ bool HunspellInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboar emit selectionListActiveItemChanged(QVirtualKeyboardSelectionListModel::Type::WordCandidateList, d->wordCandidates.index()); } accept = true; - } else if (text.length() > 1) { + } else if (text.size() > 1) { bool addSpace = !word.isEmpty() || d->autoSpaceAllowed; update(); d->autoSpaceAllowed = true; @@ -200,7 +200,7 @@ QVariant HunspellInputMethod::selectionListData(QVirtualKeyboardSelectionListMod { const QString wordCandidate(d->wordCandidates.wordAt(index)); const QString word(d->wordCandidates.wordAt(0)); - int wordCompletionLength = wordCandidate.length() - word.length(); + int wordCompletionLength = wordCandidate.size() - word.size(); result.setValue((wordCompletionLength > 0 && wordCandidate.startsWith(word)) ? wordCompletionLength : 0); break; } @@ -284,15 +284,15 @@ bool HunspellInputMethod::reselect(int cursorPosition, const QVirtualKeyboardInp return false; if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAfterCursor)) { - for (int i = cursorPosition; i < surroundingText.length(); ++i) { + for (int i = cursorPosition; i < surroundingText.size(); ++i) { QChar c = surroundingText.at(i); if (!d->isValidInputChar(c)) break; word.append(c); } - while (replaceFrom > -word.length()) { - int lastPos = word.length() - 1; + while (replaceFrom > -word.size()) { + int lastPos = word.size() - 1; if (!d->isJoiner(word.at(lastPos))) break; word.remove(lastPos, 1); @@ -302,17 +302,17 @@ bool HunspellInputMethod::reselect(int cursorPosition, const QVirtualKeyboardInp if (word.isEmpty()) return false; - if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == -word.length()) + if (reselectFlags.testFlag(QVirtualKeyboardInputEngine::ReselectFlag::WordAtCursor) && replaceFrom == -word.size()) return false; if (d->isJoiner(word.at(0))) return false; - if (d->isJoiner(word.at(word.length() - 1))) + if (d->isJoiner(word.at(word.size() - 1))) return false; d->wordCandidates.updateWord(0, word); - ic->setPreeditText(word, QList<QInputMethodEvent::Attribute>(), replaceFrom, word.length()); + ic->setPreeditText(word, QList<QInputMethodEvent::Attribute>(), replaceFrom, word.size()); d->autoSpaceAllowed = false; if (d->updateSuggestions()) { diff --git a/src/plugins/hunspell/module/hunspellinputmethod_p.cpp b/src/plugins/hunspell/module/hunspellinputmethod_p.cpp index a25a789d..393bbf88 100644 --- a/src/plugins/hunspell/module/hunspellinputmethod_p.cpp +++ b/src/plugins/hunspell/module/hunspellinputmethod_p.cpp @@ -99,7 +99,7 @@ bool HunspellInputMethodPrivate::updateSuggestions() QString word = wordCandidates.wordAt(0); if (!word.isEmpty() && dictionaryState != HunspellInputMethodPrivate::DictionaryNotLoaded) { wordCandidateListChanged = true; - if (word.length() >= wordCompletionPoint) { + if (word.size() >= wordCompletionPoint) { if (hunspellWorker) { QSharedPointer<HunspellWordList> wordList(new HunspellWordList(wordCandidates)); @@ -282,7 +282,7 @@ void HunspellInputMethodPrivate::addToDictionary() if (activeWordIndex == 0) { if (blacklistedWords->removeWord(word) > 0) { saveCustomDictionary(blacklistedWords, QLatin1String("blacklist")); - } else if (word.length() > 1 && !wordFlags.testFlag(HunspellWordList::SpellCheckOk) && !userDictionaryWords->contains(word)) { + } else if (word.size() > 1 && !wordFlags.testFlag(HunspellWordList::SpellCheckOk) && !userDictionaryWords->contains(word)) { userDictionaryWords->appendWord(word); saveCustomDictionary(userDictionaryWords, QLatin1String("userdictionary")); } else { diff --git a/src/plugins/hunspell/module/hunspellinputmethod_p.h b/src/plugins/hunspell/module/hunspellinputmethod_p.h index b898dc2c..fb90812a 100644 --- a/src/plugins/hunspell/module/hunspellinputmethod_p.h +++ b/src/plugins/hunspell/module/hunspellinputmethod_p.h @@ -29,6 +29,8 @@ class Q_HUNSPELLINPUTMETHOD_EXPORT HunspellInputMethod : public QVirtualKeyboard Q_OBJECT Q_DECLARE_PRIVATE(HunspellInputMethod) QML_NAMED_ELEMENT(DefaultInputMethod) + QML_ADDED_IN_VERSION(2, 0) + protected: HunspellInputMethod(HunspellInputMethodPrivate &dd, QObject *parent); public: diff --git a/src/plugins/hunspell/module/hunspellwordlist.cpp b/src/plugins/hunspell/module/hunspellwordlist.cpp index ec55d4d3..6c4a8df0 100644 --- a/src/plugins/hunspell/module/hunspellwordlist.cpp +++ b/src/plugins/hunspell/module/hunspellwordlist.cpp @@ -154,8 +154,8 @@ QString HunspellWordList::findWordCompletion(const QString &word) QString bestMatch; for (int i = 0, count = _list.size(); i < count; ++i) { const QString &wordB(_list[i]); - if (wordB.length() > bestMatch.length() && - word.length() < wordB.length() && + if (wordB.size() > bestMatch.size() && + word.size() < wordB.size() && wordB.startsWith(word, Qt::CaseInsensitive)) bestMatch = wordB; } diff --git a/src/plugins/hunspell/module/hunspellworker.cpp b/src/plugins/hunspell/module/hunspellworker.cpp index 584a2572..85a94888 100644 --- a/src/plugins/hunspell/module/hunspellworker.cpp +++ b/src/plugins/hunspell/module/hunspellworker.cpp @@ -125,7 +125,7 @@ void HunspellBuildSuggestionsTask::run() suggestCapitalization = true; } /* Prioritize word completions, missing punctuation or missing accents */ - } else if ((normalizedWordCandidate.length() > word.length() && + } else if ((normalizedWordCandidate.size() > word.size() && normalizedWordCandidate.startsWith(word)) || wordCandidate.contains(QLatin1Char('\''))) { wordList->insertWord(lastWordCompletionIndex++, wordCandidate); @@ -184,30 +184,30 @@ int HunspellBuildSuggestionsTask::levenshteinDistance(const QString &s, const QS { if (s == t) return 0; - if (s.length() == 0) - return t.length(); - if (t.length() == 0) - return s.length(); - QList<int> v0(t.length() + 1); - QList<int> v1(t.length() + 1); + if (s.size() == 0) + return t.size(); + if (t.size() == 0) + return s.size(); + QList<int> v0(t.size() + 1); + QList<int> v1(t.size() + 1); for (int i = 0; i < v0.size(); i++) v0[i] = i; for (int i = 0; i < s.size(); i++) { v1[0] = i + 1; - for (int j = 0; j < t.length(); j++) { + for (int j = 0; j < t.size(); j++) { int cost = (s[i].toLower() == t[j].toLower()) ? 0 : 1; v1[j + 1] = qMin(qMin(v1[j] + 1, v0[j + 1] + 1), v0[j] + cost); } for (int j = 0; j < v0.size(); j++) v0[j] = v1[j]; } - return v1[t.length()]; + return v1[t.size()]; } QString HunspellBuildSuggestionsTask::removeAccentsAndDiacritics(const QString& s) { QString normalized = s.normalized(QString::NormalizationForm_D); - for (int i = 0; i < normalized.length();) { + for (int i = 0; i < normalized.size();) { QChar::Category category = normalized[i].category(); if (category <= QChar::Mark_Enclosing) { normalized.remove(i, 1); @@ -238,7 +238,7 @@ void HunspellAddWordTask::run() tmpWord.reserve(64); for (int i = 0, count = wordList->size(); i < count; ++i) { const QString word(wordList->wordAt(i)); - if (word.length() < 2) + if (word.size() < 2) continue; Hunspell_add(hunspell, QByteArray { fromUtf16(word) }.constData()); if (HunspellAddWordTask::alternativeForm(word, tmpWord)) @@ -248,7 +248,7 @@ void HunspellAddWordTask::run() bool HunspellAddWordTask::alternativeForm(const QString &word, QString &alternativeForm) { - if (word.length() < 2) + if (word.size() < 2) return false; if (!word.mid(1).isLower()) return false; diff --git a/src/plugins/myscript/plugin/CMakeLists.txt b/src/plugins/myscript/plugin/CMakeLists.txt index f0cca44d..226005ac 100644 --- a/src/plugins/myscript/plugin/CMakeLists.txt +++ b/src/plugins/myscript/plugin/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtVirtualKeyboardMyScriptPlugin Plugin: ##################################################################### @@ -20,6 +23,7 @@ set(MYSCRIPT_LANGUAGE_RESOURCES_NAME "resources") qt_internal_add_qml_module(qtvkbmyscriptplugin URI "QtQuick.VirtualKeyboard.Plugins.MyScript" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbmyscriptplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -28,13 +32,12 @@ qt_internal_add_qml_module(qtvkbmyscriptplugin ${MyScript_ROOT_DIR}/voim/api/c/examples/common/Properties.c myscriptinputmethod.cpp myscriptinputmethod_p.h myscriptinputmethod_p_p.h - myscriptplugin.cpp myscriptplugin.h DEFINES - MYSCRIPT_CERTIFICATE=\\\"${MyScript_ROOT_DIR}/edk/c/examples/certificates/MyCertificate.c\\\" - MYSCRIPT_VOIM_PROPERTY_PATH=\\\"${MYSCRIPT_INSTALL_DATA}/${MYSCRIPT_VOIM_PROPERTY_NAME}\\\" - MYSCRIPT_LANGUAGE_CONF_PATH=\\\"${MYSCRIPT_INSTALL_DATA}/${MYSCRIPT_LANGUAGE_CONF_NAME}\\\" - MYSCRIPT_VOIM_NAME=\\\"${MYSCRIPT_VOIM_NAME}\\\" - MYSCRIPT_ENGINE_NAME=\\\"${MYSCRIPT_ENGINE_NAME}\\\" + MYSCRIPT_CERTIFICATE="${MyScript_ROOT_DIR}/edk/c/examples/certificates/MyCertificate.c" + MYSCRIPT_VOIM_PROPERTY_PATH="${MYSCRIPT_INSTALL_DATA}/${MYSCRIPT_VOIM_PROPERTY_NAME}" + MYSCRIPT_LANGUAGE_CONF_PATH="${MYSCRIPT_INSTALL_DATA}/${MYSCRIPT_LANGUAGE_CONF_NAME}" + MYSCRIPT_VOIM_NAME="${MYSCRIPT_VOIM_NAME}" + MYSCRIPT_ENGINE_NAME="${MYSCRIPT_ENGINE_NAME}" # POSIX source must be required to use "strdup" for "Properties.c" _POSIX_C_SOURCE=200809L INCLUDE_DIRECTORIES @@ -45,6 +48,7 @@ qt_internal_add_qml_module(qtvkbmyscriptplugin Qt::Qml Qt::VirtualKeyboard MyScript::VOIM + NO_GENERATE_CPP_EXPORTS ) # MyScript Engine Binaries @@ -103,7 +107,7 @@ endif() if (QT_FEATURE_vkb_lang_cs_CZ) list(APPEND qmake_virtualkeyboard_myscript_layouts_resource_files - "${VKB_LAYOUTS_BASE}/cs_CZ/handwriting.qml" + "${VKB_LAYOUTS_BASE}/cs_CZ/handwriting.fallback" ) endif() @@ -175,19 +179,19 @@ endif() if (QT_FEATURE_vkb_lang_hi_IN) list(APPEND qmake_virtualkeyboard_myscript_layouts_resource_files - "${VKB_LAYOUTS_BASE}/hi_IN/handwriting.qml" + "${VKB_LAYOUTS_BASE}/hi_IN/handwriting.fallback" ) endif() if (QT_FEATURE_vkb_lang_hr_HR) list(APPEND qmake_virtualkeyboard_myscript_layouts_resource_files - "${VKB_LAYOUTS_BASE}/hr_HR/handwriting.qml" + "${VKB_LAYOUTS_BASE}/hr_HR/handwriting.fallback" ) endif() if (QT_FEATURE_vkb_lang_hu_HU) list(APPEND qmake_virtualkeyboard_myscript_layouts_resource_files - "${VKB_LAYOUTS_BASE}/hu_HU/handwriting.qml" + "${VKB_LAYOUTS_BASE}/hu_HU/handwriting.fallback" ) endif() @@ -253,7 +257,7 @@ endif() if (QT_FEATURE_vkb_lang_ro_RO) list(APPEND qmake_virtualkeyboard_myscript_layouts_resource_files - "${VKB_LAYOUTS_BASE}/ro_RO/handwriting.qml" + "${VKB_LAYOUTS_BASE}/ro_RO/handwriting.fallback" ) endif() diff --git a/src/plugins/myscript/plugin/myscriptinputmethod.cpp b/src/plugins/myscript/plugin/myscriptinputmethod.cpp index 90b84ddf..e1cf48f2 100644 --- a/src/plugins/myscript/plugin/myscriptinputmethod.cpp +++ b/src/plugins/myscript/plugin/myscriptinputmethod.cpp @@ -179,7 +179,7 @@ public: int countActiveTraces() const { int count = 0; - for (QVirtualKeyboardTrace *trace : qAsConst(traceList)) { + for (QVirtualKeyboardTrace *trace : std::as_const(traceList)) { if (!trace->isFinal()) count++; } @@ -243,7 +243,7 @@ public: m_itemIndex = -1; - for (int i = 0; i < m_items.count(); i++) { + for (int i = 0; i < m_items.size(); i++) { CandidateItem *candidateItem = m_items.at(i).second; delete candidateItem; } @@ -1035,7 +1035,7 @@ int MyScriptInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListMod if (type != QVirtualKeyboardSelectionListModel::Type::WordCandidateList) return 0; - return d->wordCandidates.count(); + return d->wordCandidates.size(); } QVariant MyScriptInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) diff --git a/src/plugins/myscript/plugin/myscriptinputmethod_p.h b/src/plugins/myscript/plugin/myscriptinputmethod_p.h index bc0faec8..83b66565 100644 --- a/src/plugins/myscript/plugin/myscriptinputmethod_p.h +++ b/src/plugins/myscript/plugin/myscriptinputmethod_p.h @@ -30,6 +30,8 @@ class MyScriptInputMethod : public QVirtualKeyboardAbstractInputMethod Q_DECLARE_PRIVATE(MyScriptInputMethod) Q_PROPERTY(bool superimposed READ superimposed CONSTANT) QML_NAMED_ELEMENT(HandwritingInputMethod) + QML_ADDED_IN_VERSION(2, 0) + public: explicit MyScriptInputMethod(QObject *parent = nullptr); ~MyScriptInputMethod(); diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/kanaconverter.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/kanaconverter.cpp index 2b200b9e..f29efe94 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/kanaconverter.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/kanaconverter.cpp @@ -50,7 +50,7 @@ public: static bool createCandidateString(const QString &input, const WnnLookupTable &map, QString &outBuf) { outBuf.clear(); - for (int index = 0, length = input.length(); index < length; index++) { + for (int index = 0, length = input.size(); index < length; index++) { QString out = map.value(input.mid(index, 1)); if (out.isEmpty()) return false; @@ -167,7 +167,7 @@ QList<WnnWord> KanaConverter::createPseudoCandidateList(const QString &inputHira Q_D(KanaConverter); QList<WnnWord> list; - if (inputHiragana.length() == 0) { + if (inputHiragana.size() == 0) { return list; } diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp index e948456f..21db663a 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnclauseconverterjajp.cpp @@ -22,7 +22,9 @@ #include "openwnnclauseconverterjajp.h" #include "openwnndictionary.h" #include "wnnword.h" + #include <QtCore/private/qobject_p.h> +#include <QtCore/qpointer.h> class OpenWnnClauseConverterJAJPPrivate : public QObjectPrivate { @@ -49,7 +51,7 @@ public: /* get clauses with ancillary word */ int max = CLAUSE_COST * 2; - for (int split = 1; split < input.length(); split++) { + for (int split = 1; split < input.size(); split++) { /* get ancillary patterns */ QString str = input.mid(split); QList<WnnWord> fzks = getAncillaryPattern(str); @@ -147,7 +149,7 @@ public: QList<WnnWord> getAncillaryPattern(const QString &input) { - if (input.length() == 0) { + if (input.size() == 0) { return QList<WnnWord>(); } @@ -161,7 +163,7 @@ public: dict->clearApproxPattern(); dict->setDictionary(6, 400, 500); - for (int start = input.length() - 1; start >= 0; start--) { + for (int start = input.size() - 1; start >= 0; start--) { QString key = input.mid(start); if (mFzkPatterns.contains(key)) { @@ -178,7 +180,7 @@ public: } /* concatenate sequence of ancillary words */ - for (int end = input.length() - 1; end > start; end--) { + for (int end = input.size() - 1; end > start; end--) { QString followKey = input.mid(end); if (!mFzkPatterns.contains(followKey)) continue; @@ -204,7 +206,7 @@ public: QList<WnnWord> getIndependentWords(const QString &input, bool all) { - if (input.length() == 0) + if (input.size() == 0) return QList<WnnWord>(); QMap<QString, QList<WnnWord> > &wordBag = all ? mAllIndepWordBag : mIndepWordBag; @@ -261,12 +263,12 @@ public: void addAutoGeneratedCandidates(const QString &input, QList<WnnWord> &wordList, bool all) { Q_UNUSED(all); - wordList.append(WnnWord(input, input, mPosDefault, (CLAUSE_COST - 1) * input.length())); + wordList.append(WnnWord(input, input, mPosDefault, (CLAUSE_COST - 1) * input.size())); } WnnClause defaultClause(const QString &input) { - return WnnClause(input, input, mPosDefault, (CLAUSE_COST - 1) * input.length()); + return WnnClause(input, input, mPosDefault, (CLAUSE_COST - 1) * input.size()); } /** Score(frequency value) of word in the learning dictionary */ @@ -351,7 +353,7 @@ QList<WnnClause> OpenWnnClauseConverterJAJP::convert(const QString &input) return convertResult; /* do nothing if the length of input exceeds the limit */ - if (input.length() > OpenWnnClauseConverterJAJPPrivate::MAX_INPUT_LENGTH) + if (input.size() > OpenWnnClauseConverterJAJPPrivate::MAX_INPUT_LENGTH) return convertResult; /* try single clause conversion */ @@ -367,18 +369,18 @@ QSharedPointer<WnnSentence> OpenWnnClauseConverterJAJP::consecutiveClauseConvert /* clear the cache which is not matched */ QList<QSharedPointer<WnnSentence> > sentence; - for (int i = 0; i < input.length(); i++) { + for (int i = 0; i < input.size(); i++) { sentence.append(QSharedPointer<WnnSentence>()); } /* consecutive clause conversion */ - for (int start = 0; start < input.length(); start++) { + for (int start = 0; start < input.size(); start++) { if (start != 0 && sentence[start - 1] == NULL) { continue; } /* limit the length of a clause */ - int end = input.length(); + int end = input.size(); if (end > start + 20) { end = start + 20; } @@ -403,7 +405,7 @@ QSharedPointer<WnnSentence> OpenWnnClauseConverterJAJP::consecutiveClauseConvert QString key = input.mid(start, end - start); clauses.clear(); - if (end == input.length()) { + if (end == input.size()) { /* get the clause which can be the end of the sentence */ d->singleClauseConvert(clauses, key, d->mPosEndOfClause1, false); } else { @@ -424,8 +426,8 @@ QSharedPointer<WnnSentence> OpenWnnClauseConverterJAJP::consecutiveClauseConvert } /* return the result of the consecutive clause conversion */ - if (sentence[input.length() - 1] != NULL) { - return sentence[input.length() - 1]; + if (sentence[input.size() - 1] != NULL) { + return sentence[input.size() - 1]; } return QSharedPointer<WnnSentence>(); } diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp index abcf060c..871a58f4 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnndictionary.cpp @@ -340,7 +340,7 @@ public: return NJ_SET_ERR_VAL(NJ_FUNC_SEARCH_WORD, NJ_ERR_INVALID_PARAM); } - if (keyString.length() > NJ_MAX_LEN) { + if (keyString.size() > NJ_MAX_LEN) { /* If too long key string was specified, return "No result is found" */ work.flag &= ~NJ_JNI_FLAG_ENABLE_CURSOR; work.flag &= ~NJ_JNI_FLAG_ENABLE_RESULT; @@ -468,8 +468,8 @@ public: int setApproxPattern(const QString &src, const QString &dst) { - if (src.isEmpty() || src.length() > 1 || - dst.isEmpty() || dst.length() > 3) { + if (src.isEmpty() || src.size() > 1 || + dst.isEmpty() || dst.size() > 3) { /* If a invalid parameter was specified, return an error code */ return NJ_SET_ERR_VAL(NJ_FUNC_SET_APPROX_PATTERN, NJ_ERR_INVALID_PARAM); } @@ -543,7 +543,7 @@ public: QStringList getApproxPattern(const QString &src) { - if (src.isEmpty() || src.length() > 1) + if (src.isEmpty() || src.size() > 1) return QStringList(); NJ_CHAR from[NJ_MAX_CHARSET_FROM_LEN + NJ_TERM_LEN]; @@ -614,7 +614,7 @@ public: return NJ_SET_ERR_VAL(NJ_FUNC_SET_STROKE, NJ_ERR_INVALID_PARAM); } - if (stroke.length() > NJ_MAX_LEN) { + if (stroke.size() > NJ_MAX_LEN) { /* If a invalid parameter was specified, return an error code */ return NJ_SET_ERR_VAL(NJ_FUNC_SET_STROKE, NJ_ERR_YOMI_TOO_LONG); } @@ -632,7 +632,7 @@ public: return NJ_SET_ERR_VAL(NJ_FUNC_SET_CANDIDATE, NJ_ERR_INVALID_PARAM); } - if (candidate.length() > NJ_MAX_RESULT_LEN) { + if (candidate.size() > NJ_MAX_RESULT_LEN) { /* If a invalid parameter was specified, return an error code */ return NJ_SET_ERR_VAL(NJ_FUNC_SET_CANDIDATE, NJ_ERR_CANDIDATE_TOO_LONG); } diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp index f66d4942..1a13f72d 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/openwnnenginejajp.cpp @@ -143,7 +143,7 @@ public: bool addCandidate(QSharedPointer<WnnWord> word) { if (word.isNull() || word->candidate.isEmpty() || mCandTable.contains(word->candidate) - || word->candidate.length() > OpenWnnEngineJAJP::MAX_OUTPUT_LENGTH) { + || word->candidate.size() > OpenWnnEngineJAJP::MAX_OUTPUT_LENGTH) { return false; } /* @@ -170,14 +170,14 @@ public: int setSearchKey(const ComposingText &text, int maxLen) { QString input = text.toString(ComposingText::LAYER1); - if (0 <= maxLen && maxLen <= input.length()) { + if (0 <= maxLen && maxLen <= input.size()) { input = input.mid(0, maxLen); mExactMatchMode = true; } else { mExactMatchMode = false; } - if (input.length() == 0) { + if (input.size() == 0) { mInputHiragana.clear(); mInputRomaji.clear(); return 0; @@ -186,7 +186,7 @@ public: mInputHiragana = input; mInputRomaji = text.toString(ComposingText::LAYER0); - return input.length(); + return input.size(); } void clearPreviousWord() @@ -292,7 +292,7 @@ int OpenWnnEngineJAJP::convert(ComposingText &text) } QSharedPointer<WnnSentence> sentence; - if (input.length() != 0) { + if (input.size() != 0) { sentence = d->mClauseConverter.consecutiveClauseConvert(input); } if (!head.isNull()) { @@ -307,7 +307,7 @@ int OpenWnnEngineJAJP::convert(ComposingText &text) for (QList<WnnClause>::ConstIterator it = sentence->elements.constBegin(); it != sentence->elements.constEnd(); it++) { const WnnClause &clause = *it; - int len = clause.stroke.length(); + int len = clause.stroke.size(); ss.append(StrSegment(clause, pos, pos + len - 1)); pos += len; } diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/romkan.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/romkan.cpp index 3a555e2b..f3be31d6 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/romkan.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/romkan.cpp @@ -126,20 +126,20 @@ bool Romkan::convertImpl(ComposingText &text, const WnnLookupTable &table) const for (int i = start; i < RomkanPrivate::MAX_LENGTH; i++) { key.append(str[i].string); } - bool upper = key.at(key.length() - 1).isUpper(); + bool upper = key.at(key.size() - 1).isUpper(); QString match = table[key.toLower()]; if (!match.isEmpty()) { if (upper) { match = match.toUpper(); } QList<StrSegment> out; - if (match.length() == 1) { + if (match.size() == 1) { out.append(StrSegment(match, str[start].from, str[RomkanPrivate::MAX_LENGTH - 1].to)); text.replaceStrSegment(ComposingText::LAYER1, out, RomkanPrivate::MAX_LENGTH - start); } else { - out.append(StrSegment(match.left(match.length() - 1), + out.append(StrSegment(match.left(match.size() - 1), str[start].from, str[RomkanPrivate::MAX_LENGTH - 1].to - 1)); - out.append(StrSegment(match.mid(match.length() - 1), + out.append(StrSegment(match.mid(match.size() - 1), str[RomkanPrivate::MAX_LENGTH - 1].to, str[RomkanPrivate::MAX_LENGTH - 1].to)); text.replaceStrSegment(ComposingText::LAYER1, out, RomkanPrivate::MAX_LENGTH - start); } diff --git a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/wnnlookuptable.cpp b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/wnnlookuptable.cpp index a9dc5dda..cd094295 100644 --- a/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/wnnlookuptable.cpp +++ b/src/plugins/openwnn/3rdparty/openwnn/wnnEngine/wnnlookuptable.cpp @@ -54,7 +54,7 @@ void WnnLookupTable::create(const QMap<QString, QString> &map, const QString &ta std::sort(keys.begin(), keys.end(), [] (const QString &lhs, const QString &rhs) { return strcmp(lhs.toUtf8().constData(), rhs.toUtf8().constData()) < 0; }); - file.write(QString("static const int %1Length = %2;\n").arg(tablePrefix).arg(keys.count()).toUtf8().constData()); + file.write(QString("static const int %1Length = %2;\n").arg(tablePrefix).arg(keys.size()).toUtf8().constData()); file.write(QString("static const char *%1Key[%1Length];\n").arg(tablePrefix).toUtf8().constData()); file.write(QString("static const char *%1Value[%1Length];\n").arg(tablePrefix).toUtf8().constData()); file.write(QString("const char *%1Key[] = {\n").arg(tablePrefix).toUtf8().constData()); diff --git a/src/plugins/openwnn/CMakeLists.txt b/src/plugins/openwnn/CMakeLists.txt index 26c2c6a1..eb65f4fb 100644 --- a/src/plugins/openwnn/CMakeLists.txt +++ b/src/plugins/openwnn/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + add_subdirectory(3rdparty/openwnn) ##################################################################### @@ -7,6 +10,7 @@ add_subdirectory(3rdparty/openwnn) qt_internal_add_qml_module(qtvkbopenwnnplugin URI "QtQuick.VirtualKeyboard.Plugins.OpenWNN" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbopenwnnplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -24,6 +28,7 @@ qt_internal_add_qml_module(qtvkbopenwnnplugin Qt::Qml Qt::VirtualKeyboard Qt::BundledOpenwnn + NO_GENERATE_CPP_EXPORTS ) # Resources: diff --git a/src/plugins/openwnn/openwnninputmethod.cpp b/src/plugins/openwnn/openwnninputmethod.cpp index d07b8e3f..745edd14 100644 --- a/src/plugins/openwnn/openwnninputmethod.cpp +++ b/src/plugins/openwnn/openwnninputmethod.cpp @@ -203,7 +203,7 @@ public: } else if (layer == ComposingText::LAYER2) { - highlightEnd = composingText.toString(layer, 0, 0).length(); + highlightEnd = composingText.toString(layer, 0, 0).size(); /* highlights the first segment */ QTextCharFormat textFormat; @@ -212,20 +212,20 @@ public: attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, highlightEnd, textFormat)); } - if (highlightEnd != 0 && highlightEnd < displayText.length()) { + if (highlightEnd != 0 && highlightEnd < displayText.size()) { /* highlights remaining text */ QTextCharFormat textFormat; textFormat.setBackground(QBrush(QColor(0xF0, 0xFF, 0xFF))); textFormat.setForeground(QBrush(Qt::black)); - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, highlightEnd, displayText.length() - highlightEnd, textFormat)); + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, highlightEnd, displayText.size() - highlightEnd, textFormat)); } } QTextCharFormat textFormat; textFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, displayText.length(), textFormat)); + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, displayText.size(), textFormat)); - int displayCursor = composingText.toString(layer, 0, cursor - 1).length(); + int displayCursor = composingText.toString(layer, 0, cursor - 1).size(); attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, displayCursor, 1, QVariant())); Q_Q(OpenWnnInputMethod); @@ -251,7 +251,7 @@ public: displayCandidates(); } else { composingText.setCursor(ComposingText::LAYER1, - composingText.toString(ComposingText::LAYER1).length()); + composingText.toString(ComposingText::LAYER1).size()); clearCandidates(); } break; @@ -479,7 +479,7 @@ public: { if (str.isEmpty()) return false; - ushort ch = str.at(str.length() - 1).unicode(); + ushort ch = str.at(str.size() - 1).unicode(); return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); } @@ -661,7 +661,7 @@ bool OpenWnnInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboard if (d->composingText.size(ComposingText::LAYER1) > 0) { if (d->activeConvertType == OpenWnnInputMethodPrivate::CONVERT_TYPE_RENBUN) { d->composingText.setCursor(ComposingText::LAYER1, - d->composingText.toString(ComposingText::LAYER1).length()); + d->composingText.toString(ComposingText::LAYER1).size()); d->exactMatchMode = false; d->clearFocusCandidate(); } else { diff --git a/src/plugins/openwnn/openwnninputmethod_p.h b/src/plugins/openwnn/openwnninputmethod_p.h index 20ffa2c1..439cd0d3 100644 --- a/src/plugins/openwnn/openwnninputmethod_p.h +++ b/src/plugins/openwnn/openwnninputmethod_p.h @@ -27,6 +27,7 @@ class OpenWnnInputMethod : public QVirtualKeyboardAbstractInputMethod Q_OBJECT Q_DECLARE_PRIVATE(OpenWnnInputMethod) QML_NAMED_ELEMENT(JapaneseInputMethod) + QML_ADDED_IN_VERSION(2, 0) public: explicit OpenWnnInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/pinyin/3rdparty/pinyin/share/userdict.cpp b/src/plugins/pinyin/3rdparty/pinyin/share/userdict.cpp index 4687da2d..5090ad07 100644 --- a/src/plugins/pinyin/3rdparty/pinyin/share/userdict.cpp +++ b/src/plugins/pinyin/3rdparty/pinyin/share/userdict.cpp @@ -336,6 +336,9 @@ bool UserDict::close_dict() { free(offsets_by_id_); free(scores_); free(ids_); +#ifdef ___SYNC_ENABLED___ + free(syncs_); +#endif #ifdef ___PREDICT_ENABLED___ free(predicts_); #endif diff --git a/src/plugins/pinyin/3rdparty/pinyin/update-patches.sh b/src/plugins/pinyin/3rdparty/pinyin/update-patches.sh index ed67686a..100bb754 100644 --- a/src/plugins/pinyin/3rdparty/pinyin/update-patches.sh +++ b/src/plugins/pinyin/3rdparty/pinyin/update-patches.sh @@ -1,32 +1,6 @@ #!/bin/sh -############################################################################# -## -## 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$ -## -############################################################################# +# Copyright (C) 2018 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only REV_FILTER=". :!./patches :!./update-patches.sh :!./pinyin.pro :!./qt_attribution.json" REV_LIST=$(git rev-list --reverse 59208edaaf40be982904a6c8cad4eab2d14f938e..HEAD -- $REV_FILTER) diff --git a/src/plugins/pinyin/CMakeLists.txt b/src/plugins/pinyin/CMakeLists.txt index ebeb04f4..87c1f86e 100644 --- a/src/plugins/pinyin/CMakeLists.txt +++ b/src/plugins/pinyin/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + add_subdirectory(3rdparty/pinyin) ##################################################################### @@ -7,6 +10,7 @@ add_subdirectory(3rdparty/pinyin) qt_internal_add_qml_module(qtvkbpinyinplugin URI "QtQuick.VirtualKeyboard.Plugins.Pinyin" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbpinyinplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -25,6 +29,7 @@ qt_internal_add_qml_module(qtvkbpinyinplugin Qt::Qml Qt::VirtualKeyboard Qt::BundledPinyin + NO_GENERATE_CPP_EXPORTS ) # Resources: diff --git a/src/plugins/pinyin/pinyindecoderservice.cpp b/src/plugins/pinyin/pinyindecoderservice.cpp index 8e809ff6..9613dd9e 100644 --- a/src/plugins/pinyin/pinyindecoderservice.cpp +++ b/src/plugins/pinyin/pinyindecoderservice.cpp @@ -103,7 +103,7 @@ void PinyinDecoderService::setLimits(int maxSpsLen, int maxHzsLen) int PinyinDecoderService::search(const QString &spelling) { QByteArray spellingBuf = spelling.toLatin1(); - return int(im_search(spellingBuf.constData(), spellingBuf.length())); + return int(im_search(spellingBuf.constData(), spellingBuf.size())); } int PinyinDecoderService::deleteSearch(int pos, bool isPosInSpellingId, bool clearFixedInThisStep) @@ -157,7 +157,7 @@ QString PinyinDecoderService::candidateAt(int index) Q_ASSERT(index >= 0); QList<QChar> candidateBuf; candidateBuf.resize(kMaxSearchSteps + 1); - if (!im_get_candidate(size_t(index), (char16 *)candidateBuf.data(), candidateBuf.length() - 1)) + if (!im_get_candidate(size_t(index), (char16 *)candidateBuf.data(), candidateBuf.size() - 1)) return QString(); candidateBuf.last() = u'\0'; return QString(candidateBuf.data()); diff --git a/src/plugins/pinyin/pinyininputmethod.cpp b/src/plugins/pinyin/pinyininputmethod.cpp index 297da328..04753dd7 100644 --- a/src/plugins/pinyin/pinyininputmethod.cpp +++ b/src/plugins/pinyin/pinyininputmethod.cpp @@ -4,7 +4,9 @@ #include "pinyininputmethod_p.h" #include "pinyindecoderservice_p.h" #include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h> + #include <QLoggingCategory> +#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE namespace QtVirtualKeyboard { @@ -91,8 +93,8 @@ public: if (surface.isEmpty()) return false; QList<int> splStart = pinyinDecoderService->spellingStartPositions(); - isPosInSpl = (surface.length() <= splStart[fixedLen + 1]); - posDelSpl = isPosInSpl ? fixedLen - 1 : surface.length() - 1; + isPosInSpl = (surface.size() <= splStart[fixedLen + 1]); + posDelSpl = isPosInSpl ? fixedLen - 1 : surface.size() - 1; return true; } @@ -105,8 +107,8 @@ public: else chooseDecodingCandidate(candId); - if (composingStr.length() > 0) { - if ((candId >= 0 || finishSelection) && composingStr.length() == fixedLen) { + if (composingStr.size() > 0) { + if ((candId >= 0 || finishSelection) && composingStr.size() == fixedLen) { QString resultStr = getComposingStrActivePart(); q->inputContext()->commit(resultStr); tryPredict(); @@ -144,7 +146,7 @@ public: candidatesList.append(pinyinDecoderService->fetchCandidates(candidatesList.size(), fetchMore, fixedLen)); if (index == 0 && totalChoicesNum == 1) { int surfaceDecodedLen = pinyinDecoderService->pinyinStringLength(true); - if (surfaceDecodedLen < surface.length()) + if (surfaceDecodedLen < surface.size()) candidatesList[0] = candidatesList[0] + surface.mid(surfaceDecodedLen).toLower(); } } @@ -158,7 +160,7 @@ public: int result = 0; if (candId < 0) { - if (surface.length() > 0) { + if (surface.size() > 0) { if (posDelSpl < 0) { result = pinyinDecoderService->search(surface); } else { @@ -172,7 +174,7 @@ public: } else { QString resultStr; if (totalChoicesNum == 1) { - QString undecodedStr = candId < candidatesList.length() ? candidatesList.at(candId) : QString(); + QString undecodedStr = candId < candidatesList.size() ? candidatesList.at(candId) : QString(); resultStr = pinyinDecoderService->candidateAt(0).mid(0, fixedLen) + undecodedStr; } resetToIdleState(); @@ -190,7 +192,7 @@ public: QString fullSent = pinyinDecoderService->candidateAt(0); fixedLen = pinyinDecoderService->fixedLength(); composingStr = fullSent.mid(0, fixedLen) + surface.mid(splStart[fixedLen + 1]); - activeCmpsLen = composingStr.length(); + activeCmpsLen = composingStr.size(); // Prepare the display string. QString composingStrDisplay; @@ -200,14 +202,14 @@ public: if (!totalChoicesNum) totalChoicesNum = 1; } else { - activeCmpsLen = activeCmpsLen - (surface.length() - surfaceDecodedLen); + activeCmpsLen = activeCmpsLen - (surface.size() - surfaceDecodedLen); composingStrDisplay = fullSent.mid(0, fixedLen); for (int pos = fixedLen + 1; pos < splStart.size() - 1; pos++) { composingStrDisplay += surface.mid(splStart[pos], splStart[pos + 1] - splStart[pos]); if (splStart[pos + 1] < surfaceDecodedLen) composingStrDisplay += QLatin1String(" "); } - if (surfaceDecodedLen < surface.length()) + if (surfaceDecodedLen < surface.size()) composingStrDisplay += surface.mid(surfaceDecodedLen); } q->inputContext()->setPreeditText(composingStrDisplay); @@ -232,7 +234,7 @@ public: totalChoicesNum = 1; surface.clear(); - fixedLen = tmp.length(); + fixedLen = tmp.size(); composingStr = tmp; activeCmpsLen = fixedLen; @@ -265,7 +267,7 @@ public: Q_Q(PinyinInputMethod); QVirtualKeyboardInputContext *inputContext = q->inputContext(); return inputMode == QVirtualKeyboardInputEngine::InputMode::Pinyin && - composingStr.length() == fixedLen && + composingStr.size() == fixedLen && inputContext && !inputContext->inputMethodHints().testFlag(Qt::ImhNoPredictiveText); } diff --git a/src/plugins/pinyin/pinyininputmethod_p.h b/src/plugins/pinyin/pinyininputmethod_p.h index eaac2f5c..d246d75a 100644 --- a/src/plugins/pinyin/pinyininputmethod_p.h +++ b/src/plugins/pinyin/pinyininputmethod_p.h @@ -27,6 +27,7 @@ class PinyinInputMethod : public QVirtualKeyboardAbstractInputMethod Q_OBJECT Q_DECLARE_PRIVATE(PinyinInputMethod) QML_ELEMENT + QML_ADDED_IN_VERSION(2, 0) public: explicit PinyinInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/tcime/3rdparty/tcime/phrasedictionary.cpp b/src/plugins/tcime/3rdparty/tcime/phrasedictionary.cpp index 6bc62d84..3c6f6de1 100644 --- a/src/plugins/tcime/3rdparty/tcime/phrasedictionary.cpp +++ b/src/plugins/tcime/3rdparty/tcime/phrasedictionary.cpp @@ -30,7 +30,7 @@ PhraseDictionary::PhraseDictionary() : QStringList PhraseDictionary::getWords(const QString &input) const { - if (input.length() != 1) + if (input.size() != 1) return QStringList(); // Phrases are stored in an array consisting of three character arrays. @@ -42,7 +42,7 @@ QStringList PhraseDictionary::getWords(const QString &input) const // char[1][] { 0, 2, 4 } // char[2][] { a, a', b, b', c} const Dictionary &dict = dictionary(); - if (dict.length() != 3) + if (dict.size() != 3) return QStringList(); const DictionaryEntry &words = dict[0]; @@ -55,8 +55,8 @@ QStringList PhraseDictionary::getWords(const QString &input) const const DictionaryEntry &offsets = dict[1]; const DictionaryEntry &phrases = dict[2]; int offset = (int)offsets[index].unicode(); - int count = (index < offsets.length() - 1) ? - ((int)offsets[index + 1].unicode() - offset) : (phrases.length() - offset); + int count = (index < offsets.size() - 1) ? + ((int)offsets[index + 1].unicode() - offset) : (phrases.size() - offset); QStringList result; for (int i = 0; i < count; ++i) diff --git a/src/plugins/tcime/3rdparty/tcime/qt_attribution.json b/src/plugins/tcime/3rdparty/tcime/qt_attribution.json index 717f87ac..71b16654 100644 --- a/src/plugins/tcime/3rdparty/tcime/qt_attribution.json +++ b/src/plugins/tcime/3rdparty/tcime/qt_attribution.json @@ -8,9 +8,9 @@ "License": "Apache License 2.0 and BSD 3-clause \"New\" or \"Revised\" License", "LicenseId": "Apache-2.0 AND BSD-3-Clause", "LicenseFile": "COPYING", - "Copyright": "Copyright 2010 Google Inc. -Copyrighy (c) 1999 TaBE Project. -Copyright (c) 1999 Pai-Hsiang Hsiao. -Copyright (c) 1999 Computer Systems and Communication Lab, Institute of Information Science, Academia Sinica. -Copyright 1996 Chih-Hao Tsai @ Beckman Institute, University of Illinois" + "Copyright": ["Copyright 2010 Google Inc.", + "Copyrighy (c) 1999 TaBE Project.", + "Copyright (c) 1999 Pai-Hsiang Hsiao.", + "Copyright (c) 1999 Computer Systems and Communication Lab, Institute of Information Science, Academia Sinica.", + "Copyright 1996 Chih-Hao Tsai @ Beckman Institute, University of Illinois"] } diff --git a/src/plugins/tcime/3rdparty/tcime/zhuyintable.cpp b/src/plugins/tcime/3rdparty/tcime/zhuyintable.cpp index ce68618b..b7baef78 100644 --- a/src/plugins/tcime/3rdparty/tcime/zhuyintable.cpp +++ b/src/plugins/tcime/3rdparty/tcime/zhuyintable.cpp @@ -66,11 +66,11 @@ int ZhuyinTable::getInitials(QChar initials) noexcept int ZhuyinTable::getFinals(QStringView finals) noexcept { - if (finals.length() == 0) + if (finals.size() == 0) // Syllables ending with no finals can still be valid. return 0; - if (finals.length() > 2) + if (finals.size() > 2) return -1; // Compute the index instead of direct lookup the whole array to save @@ -96,7 +96,7 @@ int ZhuyinTable::getFinals(QStringView finals) noexcept return -1; } - if (finals.length() == 1) + if (finals.size() == 1) return index; for (int i = 0; i < endingFinals.size(); ++i) { diff --git a/src/plugins/tcime/CMakeLists.txt b/src/plugins/tcime/CMakeLists.txt index e6d076fe..0883ca1a 100644 --- a/src/plugins/tcime/CMakeLists.txt +++ b/src/plugins/tcime/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + add_subdirectory(3rdparty/tcime) ##################################################################### @@ -7,6 +10,7 @@ add_subdirectory(3rdparty/tcime) qt_internal_add_qml_module(qtvkbtcimeplugin URI "QtQuick.VirtualKeyboard.Plugins.TCIme" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbtcimeplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -24,6 +28,7 @@ qt_internal_add_qml_module(qtvkbtcimeplugin Qt::Qml Qt::VirtualKeyboardPrivate Qt::BundledTcime + NO_GENERATE_CPP_EXPORTS ) set(qmake_virtualkeyboard_tcime_layouts_resource_files diff --git a/src/plugins/tcime/tcinputmethod.cpp b/src/plugins/tcime/tcinputmethod.cpp index ebb3b18c..c887062a 100644 --- a/src/plugins/tcime/tcinputmethod.cpp +++ b/src/plugins/tcime/tcinputmethod.cpp @@ -59,7 +59,7 @@ public: QString pickHighlighted() const { - return (highlightIndex >= 0 && highlightIndex < candidates.count()) ? candidates[highlightIndex] : QString(); + return (highlightIndex >= 0 && highlightIndex < candidates.size()) ? candidates[highlightIndex] : QString(); } void reset() @@ -101,7 +101,7 @@ public: { bool accept = false; if (!input.contains(QChar(0x91CD)) && CangjieTable::isLetter(c)) { - if (input.length() < (cangjieDictionary.simplified() ? CangjieTable::MAX_SIMPLIFIED_CODE_LENGTH : CangjieTable::MAX_CODE_LENGTH)) { + if (input.size() < (cangjieDictionary.simplified() ? CangjieTable::MAX_SIMPLIFIED_CODE_LENGTH : CangjieTable::MAX_CODE_LENGTH)) { input.append(c); ic->setPreeditText(input); if (setCandidates(wordDictionary->getWords(input), true)) { @@ -119,7 +119,7 @@ public: } accept = true; } else if (c.unicode() == 0x96E3) { - if (input.length() == 1) { + if (input.size() == 1) { Q_ASSERT(input.at(0).unicode() == 0x91CD); input.append(c); ic->setPreeditText(input); @@ -132,7 +132,7 @@ public: bool checkSpecialCharInput() { - if (input.length() == 1 && input.at(0).unicode() == 0x91CD) { + if (input.size() == 1 && input.at(0).unicode() == 0x91CD) { static const QStringList specialChars1 = QStringList() << QChar(0xFF01) << QChar(0x2018) << QChar(0x3000) << QChar(0xFF0C) << QChar(0x3001) << QChar(0x3002) << QChar(0xFF0E) << QChar(0xFF1B) @@ -151,7 +151,7 @@ public: } q->inputContext()->setPreeditText(candidates[highlightIndex]); return true; - } else if (input.length() == 2 && input.at(0).unicode() == 0x91CD && input.at(1).unicode() == 0x96E3) { + } else if (input.size() == 2 && input.at(0).unicode() == 0x91CD && input.at(1).unicode() == 0x96E3) { static const QStringList specialChars2 = QStringList() << QChar(0x3008) << QChar(0x3009) << QChar(0xFE31) << QChar(0x2013) << QChar(0xFF5C) << QChar(0x300C) << QChar(0x300D) << QChar(0xFE40) @@ -192,12 +192,12 @@ public: QChar tone = strippedTones.pair[1].at(0); if (c == ZhuyinTable::DEFAULT_TONE) { if (tone != ZhuyinTable::DEFAULT_TONE) - input.remove(input.length() - 1, 1); + input.remove(input.size() - 1, 1); } else { if (tone == ZhuyinTable::DEFAULT_TONE) input.append(c); else - input.replace(input.length() - 1, 1, c); + input.replace(input.size() - 1, 1, c); } } else if (ZhuyinTable::getInitials(c) > 0) { // Insert the initial or replace the original initial. @@ -255,7 +255,7 @@ public: if (!syllables.isEmpty()) { if (ZhuyinTable::isYiWuYuFinals(syllables.at(0))) { results[1] = syllables.at(0); - if (syllables.length() > 1) + if (syllables.size() > 1) results[2] = syllables.at(1); } else { results[2] = syllables.at(0); @@ -435,7 +435,7 @@ bool TCInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModif case Qt::Key_Backspace: if (!d->input.isEmpty()) { - d->input.remove(d->input.length() - 1, 1); + d->input.remove(d->input.size() - 1, 1); ic->setPreeditText(d->input); #if QT_CONFIG(cangjie) if (!d->checkSpecialCharInput()) { @@ -455,7 +455,7 @@ bool TCInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModif break; default: - if (text.length() == 1) + if (text.size() == 1) accept = d->compose(text.at(0)); if (!accept) update(); @@ -473,7 +473,7 @@ int TCInputMethod::selectionListItemCount(QVirtualKeyboardSelectionListModel::Ty { Q_UNUSED(type); Q_D(TCInputMethod); - return d->candidates.count(); + return d->candidates.size(); } QVariant TCInputMethod::selectionListData(QVirtualKeyboardSelectionListModel::Type type, int index, QVirtualKeyboardSelectionListModel::Role role) diff --git a/src/plugins/tcime/tcinputmethod_p.h b/src/plugins/tcime/tcinputmethod_p.h index 0dcb63df..eee0278e 100644 --- a/src/plugins/tcime/tcinputmethod_p.h +++ b/src/plugins/tcime/tcinputmethod_p.h @@ -29,6 +29,7 @@ class TCInputMethod : public QVirtualKeyboardAbstractInputMethod Q_DECLARE_PRIVATE(TCInputMethod) Q_PROPERTY(bool simplified READ simplified WRITE setSimplified NOTIFY simplifiedChanged) QML_ELEMENT + QML_ADDED_IN_VERSION(2, 0) public: explicit TCInputMethod(QObject *parent = nullptr); diff --git a/src/plugins/thai/CMakeLists.txt b/src/plugins/thai/CMakeLists.txt index bed9f935..64b7b440 100644 --- a/src/plugins/thai/CMakeLists.txt +++ b/src/plugins/thai/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtVirtualKeyboardThaiPlugin Plugin: ##################################################################### @@ -5,6 +8,7 @@ qt_internal_add_qml_module(qtvkbthaiplugin URI "QtQuick.VirtualKeyboard.Plugins.Thai" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 PLUGIN_TARGET qtvkbthaiplugin NO_PLUGIN_OPTIONAL DEPENDENCIES @@ -21,6 +25,7 @@ qt_internal_add_qml_module(qtvkbthaiplugin Qt::Gui Qt::Qml Qt::VirtualKeyboard + NO_GENERATE_CPP_EXPORTS ) # Resources: diff --git a/src/plugins/thai/thaiinputmethod.cpp b/src/plugins/thai/thaiinputmethod.cpp index af7fc44f..670b7958 100644 --- a/src/plugins/thai/thaiinputmethod.cpp +++ b/src/plugins/thai/thaiinputmethod.cpp @@ -45,7 +45,7 @@ bool ThaiInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers) { - const bool isMark = text.length() == 2 && text.at(0) == QLatin1Char(' '); + const bool isMark = text.size() == 2 && text.at(0) == QLatin1Char(' '); #ifdef QT_HUNSPELLINPUTMETHOD_LIB if (isMark) { const QString mark(text.right(1)); diff --git a/src/plugins/thai/thaiinputmethod_p.h b/src/plugins/thai/thaiinputmethod_p.h index d6f2f528..af1f4217 100644 --- a/src/plugins/thai/thaiinputmethod_p.h +++ b/src/plugins/thai/thaiinputmethod_p.h @@ -22,6 +22,8 @@ class ThaiInputMethod : public ThaiInputMethodBase Q_OBJECT Q_DECLARE_PRIVATE(ThaiInputMethod) QML_ELEMENT + QML_ADDED_IN_VERSION(2, 0) + public: explicit ThaiInputMethod(QObject *parent = nullptr); diff --git a/src/settings/CMakeLists.txt b/src/settings/CMakeLists.txt index 125e7bc4..7ac69291 100644 --- a/src/settings/CMakeLists.txt +++ b/src/settings/CMakeLists.txt @@ -1,8 +1,11 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## qtvkbsettingsplugin Plugin: ##################################################################### -qt_internal_add_qml_module(qtvkbsettingsplugin +qt_internal_add_qml_module(VirtualKeyboardSettings URI "QtQuick.VirtualKeyboard.Settings" VERSION "${PROJECT_VERSION}" PAST_MAJOR_VERSIONS 2 1 @@ -16,27 +19,28 @@ qt_internal_add_qml_module(qtvkbsettingsplugin QT_NO_CAST_FROM_ASCII QT_NO_CAST_FROM_BYTEARRAY QT_NO_CAST_TO_ASCII - QT_VIRTUALKEYBOARD_DEFAULT_LAYOUTS_DIR=\\\"qrc:${VKB_LAYOUTS_PREFIX}\\\" + QT_VIRTUALKEYBOARD_DEFAULT_LAYOUTS_DIR="qrc:${VKB_LAYOUTS_PREFIX}" LIBRARIES Qt::Core Qt::Gui Qt::Qml Qt::Quick Qt::VirtualKeyboardPrivate + NO_GENERATE_CPP_EXPORTS ) -qt_internal_extend_target(qtvkbsettingsplugin CONDITION QT_FEATURE_vkb_no_builtin_style +qt_internal_extend_target(VirtualKeyboardSettings CONDITION QT_FEATURE_vkb_no_builtin_style DEFINES - QT_VIRTUALKEYBOARD_DEFAULT_STYLE=\\\"\\\" + QT_VIRTUALKEYBOARD_DEFAULT_STYLE="" ) -qt_internal_extend_target(qtvkbsettingsplugin CONDITION QT_FEATURE_vkb_retro_style AND NOT QT_FEATURE_vkb_no_builtin_style +qt_internal_extend_target(VirtualKeyboardSettings CONDITION QT_FEATURE_vkb_retro_style AND NOT QT_FEATURE_vkb_no_builtin_style DEFINES - QT_VIRTUALKEYBOARD_DEFAULT_STYLE=\\\"retro\\\" + QT_VIRTUALKEYBOARD_DEFAULT_STYLE="retro" ) -qt_internal_extend_target(qtvkbsettingsplugin CONDITION NOT QT_FEATURE_vkb_no_builtin_style AND NOT QT_FEATURE_vkb_retro_style +qt_internal_extend_target(VirtualKeyboardSettings CONDITION NOT QT_FEATURE_vkb_no_builtin_style AND NOT QT_FEATURE_vkb_retro_style DEFINES - QT_VIRTUALKEYBOARD_DEFAULT_STYLE=\\\"default\\\" + QT_VIRTUALKEYBOARD_DEFAULT_STYLE="default" ) diff --git a/src/settings/qquickvirtualkeyboardsettings.cpp b/src/settings/qquickvirtualkeyboardsettings.cpp index d44e36ee..8a0d529b 100644 --- a/src/settings/qquickvirtualkeyboardsettings.cpp +++ b/src/settings/qquickvirtualkeyboardsettings.cpp @@ -10,6 +10,7 @@ #include <QDir> #include <QRegularExpression> #include <QtCore/private/qobject_p.h> +#include <QtCore/qmutex.h> QT_BEGIN_NAMESPACE namespace QtVirtualKeyboard { @@ -18,9 +19,10 @@ class QQuickVirtualKeyboardSettingsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QQuickVirtualKeyboardSettings) public: - QQuickVirtualKeyboardSettingsPrivate(QQuickVirtualKeyboardSettings *q_ptr) : + QQuickVirtualKeyboardSettingsPrivate(QQuickVirtualKeyboardSettings *q_ptr, QQmlEngine *engine) : QObjectPrivate(), - q_ptr(q_ptr) + q_ptr(q_ptr), + engine(engine) {} QString buildStylePath(const QString &path, const QString &name) const @@ -43,13 +45,7 @@ public: QStringList qmlImportPathList() const { - Q_Q(const QQuickVirtualKeyboardSettings); - if (QQmlContext *context = QQmlEngine::contextForObject(q)) { - if (QQmlEngine *engine = context->engine()) { - return engine->importPathList(); - } - } - return QStringList(); + return engine ? engine->importPathList() : QStringList(); } QString stylePath(const QString &name) const @@ -67,7 +63,10 @@ public: stylePathList += stylesPath; } - for (const QString &stylePath : qAsConst(stylePathList)) { + // Path for backwards compatibility + stylePathList << QLatin1String("qrc:/QtQuick/VirtualKeyboard/content/styles/"); + + for (const QString &stylePath : std::as_const(stylePathList)) { QString filePath = buildStyleFilePath(stylePath, name); bool pathExist = false; pathExist = QFileInfo::exists(filePath); @@ -78,6 +77,7 @@ public: } QQuickVirtualKeyboardSettings *q_ptr; + QQmlEngine *engine; QQuickWordCandidateListSettings wordCandidateListSettings; }; @@ -125,8 +125,8 @@ public: /*! \internal */ -QQuickVirtualKeyboardSettings::QQuickVirtualKeyboardSettings(QObject *parent) : - QObject(*new QQuickVirtualKeyboardSettingsPrivate(this), parent) +QQuickVirtualKeyboardSettings::QQuickVirtualKeyboardSettings(QQmlEngine *engine, QObject *parent) : + QObject(*new QQuickVirtualKeyboardSettingsPrivate(this, engine), parent) { Q_D(QQuickVirtualKeyboardSettings); Settings *settings = Settings::instance(); @@ -152,6 +152,23 @@ QQuickVirtualKeyboardSettings::QQuickVirtualKeyboardSettings(QObject *parent) : connect(settings, SIGNAL(handwritingModeDisabledChanged()), SIGNAL(handwritingModeDisabledChanged())); connect(settings, SIGNAL(defaultInputMethodDisabledChanged()), SIGNAL(defaultInputMethodDisabledChanged())); connect(settings, SIGNAL(defaultDictionaryDisabledChanged()), SIGNAL(defaultDictionaryDisabledChanged())); + connect(settings, SIGNAL(visibleFunctionKeysChanged()), SIGNAL(visibleFunctionKeysChanged())); +} + +/*! + \internal + TODO: Remove this method when QML stops creating separate singleton instances for each version. + */ +QQuickVirtualKeyboardSettings *QQuickVirtualKeyboardSettings::create( + QQmlEngine *qmlEngine, QJSEngine *) +{ + static QMutex mutex; + static QHash<QQmlEngine *, QQuickVirtualKeyboardSettings *> instances; + QMutexLocker locker(&mutex); + QQuickVirtualKeyboardSettings *&instance = instances[qmlEngine]; + if (instance == nullptr) + instance = new QQuickVirtualKeyboardSettings(qmlEngine); + return instance; } /*! @@ -344,6 +361,26 @@ void QQuickVirtualKeyboardSettings::setDefaultDictionaryDisabled(bool defaultDic return Settings::instance()->setDefaultDictionaryDisabled(defaultDictionaryDisabled); } +QtVirtualKeyboard::KeyboardFunctionKeys QQuickVirtualKeyboardSettings::visibleFunctionKeys() const +{ + return Settings::instance()->visibleFunctionKeys(); +} + +void QQuickVirtualKeyboardSettings::setVisibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKeys newVisibleFunctionKeys) +{ + Settings::instance()->setVisibleFunctionKeys(newVisibleFunctionKeys); +} + +bool QQuickVirtualKeyboardSettings::closeOnReturn() const +{ + return Settings::instance()->closeOnReturn(); +} + +void QQuickVirtualKeyboardSettings::setCloseOnReturn(bool closeOnReturn) +{ + Settings::instance()->setCloseOnReturn(closeOnReturn); +} + void QQuickVirtualKeyboardSettings::resetStyle() { Q_D(QQuickVirtualKeyboardSettings); @@ -524,10 +561,39 @@ void QQuickVirtualKeyboardSettings::resetStyle() */ /*! + \qmlproperty enumeration VirtualKeyboardSettings::visibleFunctionKeys + \since QtQuick.VirtualKeyboard.Settings 6.6 + + This setting adjusts the visibility of specific function keys in the keyboard layout, allowing + them to be either displayed or hidden. When a function key is not visible, its functionality + remains accessible through the gear menu. + + The value can be combination of the following flags: + + \list + \li \c QtVirtualKeyboard.KeyboardFunctionKeys.None All function keys are hidden + \li \c QtVirtualKeyboard.KeyboardFunctionKeys.Hide Hide function key is visible + \li \c QtVirtualKeyboard.KeyboardFunctionKeys.Language Language function key is visible + \li \c QtVirtualKeyboard.KeyboardFunctionKeys.All All function keys are visible + \endlist + + The default is \c QtVirtualKeyboard.KeyboardFunctionKeys.All. +*/ + +/*! + \qmlproperty bool VirtualKeyboardSettings::closeOnReturn + \since QtQuick.VirtualKeyboard.Settings 6.8 + + This property enables hiding of virtual keyboard. + + When this property is set to \c true, the virtual keyboard is hidden when \l Qt::Key_Enter + or \l Qt::Key_Return key released. The default is \c false. +*/ + +/*! \since QtQuick.VirtualKeyboard.Settings 2.2 - \qmlpropertygroup QtQuick.VirtualKeyboard::VirtualKeyboardSettings::wordCandidateList - \qmlproperty int QtQuick.VirtualKeyboard::VirtualKeyboardSettings::wordCandidateList.autoHideDelay - \qmlproperty bool QtQuick.VirtualKeyboard::VirtualKeyboardSettings::wordCandidateList.alwaysVisible + \qmlproperty int VirtualKeyboardSettings::wordCandidateList.autoHideDelay + \qmlproperty bool VirtualKeyboardSettings::wordCandidateList.alwaysVisible \table \header diff --git a/src/settings/qquickvirtualkeyboardsettings_p.h b/src/settings/qquickvirtualkeyboardsettings_p.h index f345e1dc..3f03ff80 100644 --- a/src/settings/qquickvirtualkeyboardsettings_p.h +++ b/src/settings/qquickvirtualkeyboardsettings_p.h @@ -15,6 +15,7 @@ // We mean it. // +#include <QtVirtualKeyboard/private/qvirtualkeyboardnamespace_p.h> #include <QtQml/qqml.h> #include <QtCore/private/qglobal_p.h> @@ -43,14 +44,17 @@ class QQuickVirtualKeyboardSettings : public QObject Q_PROPERTY(bool handwritingModeDisabled READ isHandwritingModeDisabled WRITE setHandwritingModeDisabled NOTIFY handwritingModeDisabledChanged REVISION(6, 1)) Q_PROPERTY(bool defaultInputMethodDisabled READ isDefaultInputMethodDisabled WRITE setDefaultInputMethodDisabled NOTIFY defaultInputMethodDisabledChanged REVISION(6, 1)) Q_PROPERTY(bool defaultDictionaryDisabled READ isDefaultDictionaryDisabled WRITE setDefaultDictionaryDisabled NOTIFY defaultDictionaryDisabledChanged REVISION(6, 1)) + Q_PROPERTY(QtVirtualKeyboard::KeyboardFunctionKeys visibleFunctionKeys READ visibleFunctionKeys WRITE setVisibleFunctionKeys NOTIFY visibleFunctionKeysChanged REVISION(6, 6)) + Q_PROPERTY(bool closeOnReturn READ closeOnReturn WRITE setCloseOnReturn NOTIFY closeOnReturnChanged REVISION(6, 8)) QML_NAMED_ELEMENT(VirtualKeyboardSettings) QML_SINGLETON QML_ADDED_IN_VERSION(1, 0) QML_EXTRA_VERSION(2, 0) -public: - explicit QQuickVirtualKeyboardSettings(QObject *parent = nullptr); + explicit QQuickVirtualKeyboardSettings(QQmlEngine *engine, QObject *parent = nullptr); +public: + static QQuickVirtualKeyboardSettings *create(QQmlEngine *qmlEngine, QJSEngine *jsEngine); QString style() const; QUrl layoutPath() const; @@ -93,6 +97,12 @@ public: bool isDefaultDictionaryDisabled() const; void setDefaultDictionaryDisabled(bool defaultDictionaryDisabled); + QtVirtualKeyboard::KeyboardFunctionKeys visibleFunctionKeys() const; + void setVisibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKeys newVisibleFunctionKeys); + + bool closeOnReturn() const; + void setCloseOnReturn(bool enable); + signals: void styleChanged(); void styleNameChanged(); @@ -109,6 +119,8 @@ signals: Q_REVISION(6, 1) void handwritingModeDisabledChanged(); Q_REVISION(6, 1) void defaultInputMethodDisabledChanged(); Q_REVISION(6, 1) void defaultDictionaryDisabledChanged(); + Q_REVISION(6, 6) void visibleFunctionKeysChanged(); + Q_REVISION(6, 8) void closeOnReturnChanged(); private: void resetStyle(); diff --git a/src/styles/CMakeLists.txt b/src/styles/CMakeLists.txt index 6e14f976..48c39017 100644 --- a/src/styles/CMakeLists.txt +++ b/src/styles/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + set(styles_imports) if(NOT QT_FEATURE_vkb_no_builtin_style) add_subdirectory(builtin) @@ -13,6 +16,7 @@ qt_internal_add_qml_module(qtvkbstylesplugin VERSION "${PROJECT_VERSION}" PAST_MAJOR_VERSIONS 2 1 PLUGIN_TARGET qtvkbstylesplugin + CLASS_NAME "QtQuickVirtualKeyboardStylesPlugin" # Note: The plugin source is defined manually because it uses an # image provider. Once the image provider doesn't need an # engine anymore, we can auto-generate the plugin. @@ -44,4 +48,6 @@ qt_internal_add_qml_module(qtvkbstylesplugin Qt::Qml Qt::Quick Qt::Svg + Qt::VirtualKeyboard + NO_GENERATE_CPP_EXPORTS ) diff --git a/src/styles/builtin/CMakeLists.txt b/src/styles/builtin/CMakeLists.txt index 1ef540e6..ac3a2491 100644 --- a/src/styles/builtin/CMakeLists.txt +++ b/src/styles/builtin/CMakeLists.txt @@ -1,11 +1,17 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_qml_module(qtvkbbuiltinstylesplugin URI "QtQuick.VirtualKeyboard.Styles.Builtin" VERSION "${PROJECT_VERSION}" + PAST_MAJOR_VERSIONS 2 1 PLUGIN_TARGET qtvkbbuiltinstylesplugin + CLASS_NAME "QtQuickVirtualKeyboardStylesBuiltinPlugin" NO_PLUGIN_OPTIONAL NO_GENERATE_PLUGIN_SOURCE SOURCES qtquickvirtualkeyboardbstylesbuiltinplugin.cpp qtquickvirtualkeyboardbstylesbuiltinplugin.h + NO_GENERATE_CPP_EXPORTS ) # Resources: diff --git a/src/styles/builtin/default/style.qml b/src/styles/builtin/default/style.qml index 41261fd0..0681ef43 100644 --- a/src/styles/builtin/default/style.qml +++ b/src/styles/builtin/default/style.qml @@ -120,7 +120,7 @@ KeyboardStyle { } states: [ State { - when: control.smallText === "\u2699" + when: control.smallText === "\u2699" && control.smallTextVisible PropertyChanges { target: keySmallText visible: false @@ -1181,11 +1181,11 @@ KeyboardStyle { smooth: false source: { switch (keyboardFunction) { - case QtVirtualKeyboard.HideInputPanel: + case QtVirtualKeyboard.KeyboardFunction.HideInputPanel: return resourcePrefix + "images/hidekeyboard-fff.svg" - case QtVirtualKeyboard.ChangeLanguage: + case QtVirtualKeyboard.KeyboardFunction.ChangeLanguage: return resourcePrefix + "images/globe-fff.svg" - case QtVirtualKeyboard.ToggleHandwritingMode: + case QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode: return resourcePrefix + (keyboard.handwritingMode ? "images/textmode-fff.svg" : "images/handwriting-fff.svg") } } diff --git a/src/styles/builtin/retro/style.qml b/src/styles/builtin/retro/style.qml index 2f9c62b5..dd295446 100644 --- a/src/styles/builtin/retro/style.qml +++ b/src/styles/builtin/retro/style.qml @@ -1168,11 +1168,11 @@ KeyboardStyle { smooth: false source: { switch (keyboardFunction) { - case QtVirtualKeyboard.HideInputPanel: + case QtVirtualKeyboard.KeyboardFunction.HideInputPanel: return resourcePrefix + "images/hidekeyboard-c5a96f.svg" - case QtVirtualKeyboard.ChangeLanguage: + case QtVirtualKeyboard.KeyboardFunction.ChangeLanguage: return resourcePrefix + "images/globe-c5a96f.svg" - case QtVirtualKeyboard.ToggleHandwritingMode: + case QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode: return resourcePrefix + (keyboard.handwritingMode ? "images/textmode-c5a96f.svg" : "images/handwriting-c5a96f.svg") } } @@ -1182,11 +1182,11 @@ KeyboardStyle { target: functionIcon source: { switch (keyboardFunction) { - case QtVirtualKeyboard.HideInputPanel: + case QtVirtualKeyboard.KeyboardFunction.HideInputPanel: return resourcePrefix + "images/hidekeyboard-fff.svg" - case QtVirtualKeyboard.ChangeLanguage: + case QtVirtualKeyboard.KeyboardFunction.ChangeLanguage: return resourcePrefix + "images/globe-fff.svg" - case QtVirtualKeyboard.ToggleHandwritingMode: + case QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode: return resourcePrefix + (keyboard.handwritingMode ? "images/textmode-fff.svg" : "images/handwriting-fff.svg") } } diff --git a/src/styles/svgimageprovider.cpp b/src/styles/svgimageprovider.cpp index ab34dc4e..fa8345ba 100644 --- a/src/styles/svgimageprovider.cpp +++ b/src/styles/svgimageprovider.cpp @@ -27,7 +27,7 @@ QPixmap SvgImageProvider::requestPixmap(const QString &id, QSize *size, const QS QVariantMap params; for (const QString ¶m : paramList) { QStringList keyValue = param.split(QLatin1Char('='), Qt::SkipEmptyParts); - if (keyValue.length() == 2) + if (keyValue.size() == 2) params[keyValue[0]] = keyValue[1]; } const auto widthIt = params.constFind(QLatin1String("width")); diff --git a/src/virtualkeyboard/CMakeLists.txt b/src/virtualkeyboard/CMakeLists.txt index 20571ce1..a7ad047a 100644 --- a/src/virtualkeyboard/CMakeLists.txt +++ b/src/virtualkeyboard/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + ##################################################################### ## QtQuick.VirtualKeyboard ##################################################################### @@ -51,6 +54,7 @@ qt_internal_add_qml_module(VirtualKeyboard qvirtualkeyboardfeatures_namespace_p.h qvirtualkeyboardinputcontext.cpp qvirtualkeyboardinputcontext.h qvirtualkeyboardinputcontext_p.cpp qvirtualkeyboardinputcontext_p.h qvirtualkeyboardinputengine.cpp qvirtualkeyboardinputengine.h + qvirtualkeyboardnamespace_p.h qvirtualkeyboardobserver.cpp qvirtualkeyboardobserver.h qvirtualkeyboardselectionlistmodel.cpp qvirtualkeyboardselectionlistmodel.h qvirtualkeyboardtrace.cpp qvirtualkeyboardtrace.h @@ -77,8 +81,6 @@ qt_internal_add_qml_module(VirtualKeyboard PRIVATE_MODULE_INTERFACE Qt::CorePrivate Qt::GuiPrivate - GENERATE_CPP_EXPORTS - GENERATE_PRIVATE_CPP_EXPORTS ) qt_internal_extend_target(VirtualKeyboard CONDITION QT_FEATURE_vkb_desktop diff --git a/src/virtualkeyboard/InputPanel.qml b/src/virtualkeyboard/InputPanel.qml index 63f2bc5b..676cee67 100644 --- a/src/virtualkeyboard/InputPanel.qml +++ b/src/virtualkeyboard/InputPanel.qml @@ -96,6 +96,9 @@ Item { /*! \internal */ property bool desktopPanel: false + /*! \internal */ + property point screenPos: desktopPanel ? Qt.point(keyboard.x, keyboard.y) : Qt.point(x, y) + SelectionControl { objectName: "selectionControl" x: -parent.x @@ -103,10 +106,9 @@ Item { enabled: active && !keyboard.fullScreenMode && !desktopPanel } - implicitHeight: keyboard.height + implicitHeight: keyboard.height - keyboard.wordCandidateView.currentYOffset Keyboard { id: keyboard - readonly property real yOffset: keyboard.wordCandidateView.currentYOffset - (keyboard.shadowInputControl.visible ? keyboard.shadowInputControl.height : 0) anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom @@ -127,15 +129,13 @@ Item { /*! \internal */ function keyboardRectangle() { - var rect = Qt.rect(0, keyboard.yOffset, keyboard.width, keyboard.height - keyboard.yOffset) + var rect = Qt.rect(0, 0, keyboard.width, keyboard.height) + const screenPosX = screenPos.x + const screenPosY = screenPos.y if (desktopPanel) { - rect.x += keyboard.x - rect.y += keyboard.y + rect.x += screenPosX + rect.y += screenPosY } - // Read the inputPanel position. - // This ensures that the Binding works. - var unusedX = inputPanel.x - var unusedY = inputPanel.y return mapToItem(null, rect) } } diff --git a/src/virtualkeyboard/configure.cmake b/src/virtualkeyboard/configure.cmake index 61890362..35ee23de 100644 --- a/src/virtualkeyboard/configure.cmake +++ b/src/virtualkeyboard/configure.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + #### Inputs @@ -33,7 +36,7 @@ qt_feature("vkb-arrow-keynavigation" PUBLIC ) qt_feature("vkb-desktop" PUBLIC LABEL "Desktop integration" - CONDITION NOT cross_compile + CONDITION NOT ANDROID ) qt_feature("vkb-layouts" PUBLIC LABEL "Built-in layouts" @@ -177,6 +180,13 @@ qt_feature("thai" PRIVATE AUTODETECT ( NOT INPUT_lang_th_TH STREQUAL 'no' ) DISABLE QT_FEATURE_cerence_xt9 ) +qt_feature("example-hwr" PRIVATE + LABEL "Example HWR" + ENABLE INPUT_vkb_handwriting STREQUAL 'example-hwr' + AUTODETECT ( FALSE ) + DISABLE NOT INPUT_vkb_handwriting STREQUAL '' AND NOT INPUT_vkb_handwriting STREQUAL 'example-hwr' + PURPOSE "Generates random characters in response to handwriting input. For development and demonstration purposes only." +) qt_feature("vkb-lang-ar_AR" PRIVATE LABEL "Arabic" AUTODETECT ( NOT INPUT_lang_ar_AR STREQUAL 'no' ) @@ -373,6 +383,7 @@ qt_configure_add_summary_entry(ARGS "hunspell") qt_configure_add_summary_entry(ARGS "3rdparty-hunspell") qt_configure_add_summary_entry(ARGS "openwnn") qt_configure_add_summary_entry(ARGS "myscript") +qt_configure_add_summary_entry(ARGS "example-hwr") qt_configure_add_summary_section(NAME "Language support enabled for") qt_configure_add_summary_entry(ARGS "vkb-lang-ar_AR") qt_configure_add_summary_entry(ARGS "vkb-lang-bg_BG") diff --git a/src/virtualkeyboard/desktopinputselectioncontrol.cpp b/src/virtualkeyboard/desktopinputselectioncontrol.cpp index 1c99b583..0fc5d646 100644 --- a/src/virtualkeyboard/desktopinputselectioncontrol.cpp +++ b/src/virtualkeyboard/desktopinputselectioncontrol.cpp @@ -180,6 +180,8 @@ void DesktopInputSelectionControl::setEnabled(bool enable) connect(m_inputContext, &QVirtualKeyboardInputContext::cursorRectangleChanged, this, &DesktopInputSelectionControl::updateCursorHandlePosition); connect(m_inputContext, &QVirtualKeyboardInputContext::anchorRectIntersectsClipRectChanged, this, &DesktopInputSelectionControl::updateVisibility); connect(m_inputContext, &QVirtualKeyboardInputContext::cursorRectIntersectsClipRectChanged, this, &DesktopInputSelectionControl::updateVisibility); + updateAnchorHandlePosition(); + updateCursorHandlePosition(); if (focusWindow) focusWindow->installEventFilter(this); } else { @@ -230,8 +232,8 @@ bool DesktopInputSelectionControl::eventFilter(QObject *object, QEvent *event) for (int i = 0; i <= CursorHandle; ++i) { SelectionHandleInfo &h = handles[i]; - QPoint curHandleCenter = focusWindow->mapToGlobal(h.rect.center()); // ### map to desktoppanel - const QPoint delta = mousePos - curHandleCenter; + QPoint curHandleTopCenter = focusWindow->mapToGlobal(QPoint(h.rect.x() + qRound((qreal)h.rect.width() / 2), h.rect.top())); // ### map to desktoppanel + const QPoint delta = mousePos - curHandleTopCenter; h.delta = delta; h.squaredDistance = QPoint::dotProduct(delta, delta); } @@ -243,7 +245,7 @@ bool DesktopInputSelectionControl::eventFilter(QObject *object, QEvent *event) const QPoint windowPos = focusWindow->mapFromGlobal(mousePos); if (m_anchorHandleVisible && handles[closestHandle].rect.contains(windowPos)) { m_currentDragHandle = closestHandle; - m_distanceBetweenMouseAndCursor = handles[closestHandle].delta - QPoint(0, m_handleWindowSize.height()/2 + 4); + m_distanceBetweenMouseAndCursor = handles[closestHandle].delta; m_handleState = HandleIsHeld; m_handleDragStartedPosition = mousePos; const QRect otherRect = handles[1 - closestHandle].rect; diff --git a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf index 2da552ea..0a87b21f 100644 --- a/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf +++ b/src/virtualkeyboard/doc/qtvirtualkeyboard.qdocconf @@ -1,7 +1,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) include($QT_INSTALL_DOCS/config/exampleurl-qtvirtualkeyboard.qdocconf) -project = QtVirtualKeyboardDoc +project = QtVirtualKeyboard description = Qt Virtual Keyboard version = $QT_VERSION buildversion = Qt Virtual Keyboard | Commercial or GPLv3 @@ -14,46 +14,40 @@ exampledirs += ../../../examples/virtualkeyboard \ snippets examplesinstallpath = virtualkeyboard -Cpp.ignoretokens += \ - Q_VIRTUALKEYBOARD_EXPORT -Cpp.ignoredirectives += \ - Q_DECLARE_LOGGING_CATEGORY \ - VIRTUALKEYBOARD_DEBUG - -manifestmeta.highlighted.names = "QtVirtualKeyboard/Qt Quick Virtual Keyboard - Basic Example" +manifestmeta.highlighted.names = "QtVirtualKeyboard/Virtual Keyboard in Qt Quick" imagedirs += images depends += qtdoc qtcore qtgui qtwidgets qtwaylandcompositor qtqml qtquick qtquickcontrols qtcmake qmake -qhp.projects = QtVirtualKeyboardDoc +qhp.projects = QtVirtualKeyboard -qhp.QtVirtualKeyboardDoc.file = qtvirtualkeyboard.qhp -qhp.QtVirtualKeyboardDoc.namespace = org.qt-project.qtvirtualkeyboard.$QT_VERSION_TAG -qhp.QtVirtualKeyboardDoc.virtualFolder = qtvirtualkeyboard -qhp.QtVirtualKeyboardDoc.indexTitle = Qt Virtual Keyboard -qhp.QtVirtualKeyboardDoc.indexRoot = +qhp.QtVirtualKeyboard.file = qtvirtualkeyboard.qhp +qhp.QtVirtualKeyboard.namespace = org.qt-project.qtvirtualkeyboard.$QT_VERSION_TAG +qhp.QtVirtualKeyboard.virtualFolder = qtvirtualkeyboard +qhp.QtVirtualKeyboard.indexTitle = Qt Virtual Keyboard +qhp.QtVirtualKeyboard.indexRoot = -qhp.QtVirtualKeyboardDoc.subprojects = classes qmltypes examples +qhp.QtVirtualKeyboard.subprojects = classes qmltypes examples -qhp.QtVirtualKeyboardDoc.subprojects.classes.title = C++ Classes -qhp.QtVirtualKeyboardDoc.subprojects.classes.indexTitle = Qt Virtual Keyboard C++ Classes -qhp.QtVirtualKeyboardDoc.subprojects.classes.selectors = class doc:headerfile -qhp.QtVirtualKeyboardDoc.subprojects.classes.sortPages = true +qhp.QtVirtualKeyboard.subprojects.classes.title = C++ Classes +qhp.QtVirtualKeyboard.subprojects.classes.indexTitle = Qt Virtual Keyboard C++ Classes +qhp.QtVirtualKeyboard.subprojects.classes.selectors = class doc:headerfile +qhp.QtVirtualKeyboard.subprojects.classes.sortPages = true -qhp.QtVirtualKeyboardDoc.subprojects.qmltypes.title = QML Types -qhp.QtVirtualKeyboardDoc.subprojects.qmltypes.indexTitle = Qt Virtual Keyboard QML Types -qhp.QtVirtualKeyboardDoc.subprojects.qmltypes.selectors = qmlclass -qhp.QtVirtualKeyboardDoc.subprojects.qmltypes.sortPages = true +qhp.QtVirtualKeyboard.subprojects.qmltypes.title = QML Types +qhp.QtVirtualKeyboard.subprojects.qmltypes.indexTitle = Qt Virtual Keyboard QML Types +qhp.QtVirtualKeyboard.subprojects.qmltypes.selectors = qmlclass +qhp.QtVirtualKeyboard.subprojects.qmltypes.sortPages = true -qhp.QtVirtualKeyboardDoc.subprojects.examples.title = Examples -qhp.QtVirtualKeyboardDoc.subprojects.examples.indexTitle = Qt Virtual Keyboard Examples -qhp.QtVirtualKeyboardDoc.subprojects.examples.selectors = doc:example -qhp.QtVirtualKeyboardDoc.subprojects.examples.sortPages = true +qhp.QtVirtualKeyboard.subprojects.examples.title = Examples +qhp.QtVirtualKeyboard.subprojects.examples.indexTitle = Qt Virtual Keyboard Examples +qhp.QtVirtualKeyboard.subprojects.examples.selectors = doc:example +qhp.QtVirtualKeyboard.subprojects.examples.sortPages = true navigation.landingpage = "Qt Virtual Keyboard" navigation.qmltypespage = "Qt Virtual Keyboard QML Types" navigation.cppclassespage = "Qt Virtual Keyboard C++ Classes" -# Fail the documentation build if there are more warnings than the limit +# Enforce zero documentation warnings warninglimit = 0 diff --git a/src/virtualkeyboard/doc/snippets/CustomInputMethod.qml b/src/virtualkeyboard/doc/snippets/CustomInputMethod.qml index b4b54aa7..7b3b837d 100644 --- a/src/virtualkeyboard/doc/snippets/CustomInputMethod.qml +++ b/src/virtualkeyboard/doc/snippets/CustomInputMethod.qml @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause import QtQuick import QtQuick.VirtualKeyboard @@ -8,7 +8,7 @@ import QtQuick.VirtualKeyboard InputMethod { function inputModes(locale) { - return [InputEngine.Latin]; + return [InputEngine.InputMode.Latin]; } function setInputMode(locale, inputMode) { diff --git a/src/virtualkeyboard/doc/snippets/qtvirtualkeyboard-custom-language-popup.qml b/src/virtualkeyboard/doc/snippets/qtvirtualkeyboard-custom-language-popup.qml index c07f7a69..9272d29f 100644 --- a/src/virtualkeyboard/doc/snippets/qtvirtualkeyboard-custom-language-popup.qml +++ b/src/virtualkeyboard/doc/snippets/qtvirtualkeyboard-custom-language-popup.qml @@ -1,5 +1,5 @@ // Copyright (C) 2018 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause // ![popup] Dialog { diff --git a/src/virtualkeyboard/doc/src/build.qdoc b/src/virtualkeyboard/doc/src/build.qdoc index 51957cfd..54a77719 100644 --- a/src/virtualkeyboard/doc/src/build.qdoc +++ b/src/virtualkeyboard/doc/src/build.qdoc @@ -73,12 +73,14 @@ keyboard features. These options are passed to the \e configure tool. if no other languages are specified. \row \li \e -vkb-handwriting - \li \e [no|myscript-hwr|cerence-hwr] + \li \e [no|example-hwr|myscript-hwr|cerence-hwr] \li Enables or disabled handwriting input \li This flag enables handwriting input. By default, the engine is automatically activated if it is located in the proper plugins folder even without using of this option. But, in case MyScript and Cerence SDK - co-exist, one of [no|myscript-hwr|cerence-hwr] must be configured. + co-exist, one of [no|myscript-hwr|cerence-hwr] must be configured. The + \l {Example Handwriting}{example-hwr} option needs to be explicitly + activated. This can be done for development and testing purposes. \row \li \e [-no]-vkb-arrow-keynavigation \li @@ -392,6 +394,27 @@ is no need for an explicit gesture. <div align="center"><figure><svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg2" viewbox="0 0 156.63411 96.840738" height="27.330608mm" width="44.205627mm"> <defs id="defs4"></defs> <metadata id="metadata7"> </metadata> <g transform="translate(-19.991064,-156.76845)" id="layer1"> <path id="path3338" stroke-dasharray="700" stroke-dashoffset="700" d="m 20.203051,228.07773 c 7.019038,3.28583 18.296996,2.19868 25.253814,2.0203 27.834023,-0.71369 42.825541,-21.91043 41.416254,-47.98224 -0.323001,-5.97553 -7.191269,-26.45641 -10.606602,-24.74874 -10.259596,5.1298 -9.124503,41.18434 -7.576144,52.02286 1.430314,10.01219 2.165272,8.95563 3.030458,20.20305 0.514408,6.68731 0.563751,12.53255 1.515229,19.19289 0.191958,1.34371 0.355181,2.69156 0.505076,4.04061 0.01859,0.16733 0,0.67344 0,0.50508 0,-2.49868 0.106479,0.64925 -1.010153,-4.04061 -1.138171,-4.78032 -2.879899,-14.31543 -2.525381,-18.68782 0.215131,-2.65328 1.334905,-5.19519 2.525381,-7.57615 1.190476,-2.38095 2.750791,-4.60015 4.545687,-6.56599 2.880061,-3.15435 5.631315,-6.15186 10.101525,-5.55584 7.218425,0.96246 9.158962,18.77507 9.596449,24.24367 0.312712,3.90889 -0.730173,4.84918 1.010153,8.08122 2.037193,3.78335 3.387013,4.88523 8.081223,5.55583 5.47716,0.78246 9.60547,-2.86344 13.63706,-6.06091 2.23856,-1.77541 4.56788,-3.62491 6.06091,-6.06092 4.94323,-8.06526 6.7262,-26.15308 -6.06091,-28.28427 -20.629129,-3.43819 -15.11782,36.04559 11.11167,35.35534 3.30658,-0.087 6.53787,-1.26596 9.59645,-2.52538 25.47885,-10.49129 20.89279,-45.3686 11.61676,-65.65992 -1.54311,-3.37554 -5.32932,-11.06285 -9.09137,-13.13198 -1.47519,-0.81135 -3.36718,0 -5.05077,0 -1.01015,0 -2.08112,-0.34521 -3.03046,0 -9.66282,3.51375 -12.01346,27.64821 -11.11167,36.36549 0.68611,6.63247 4.06851,21.716 8.08122,26.76905 8.89766,11.20446 20.90822,13.3675 34.34518,14.64721 4.58435,0.4366 7.15182,0.9294 10.10153,-2.02031" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;"> <animate begin="0s;helOpacityFinal.end" attributename="stroke-dashoffset" from="700px" to="0px" dur="2s" fill="freeze" id="hel"></animate> <animate begin="hel.end" attributename="opacity" from="1" to="0.2" dur="3s" fill="freeze" id="helOpacity"></animate> <animate begin="loOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="helOpacityFinal"></animate> <set begin="helOpacityFinal.end" attributename="opacity" to="1"></set> </path> <path id="path3344" stroke-dasharray="500" stroke-dashoffset="500" d="m 41.416254,231.61326 c 3.094802,7.92585 11.797035,7.22396 19.192898,7.57614 31.260076,1.48858 50.776938,-24.97346 43.436558,-55.55839 -2.10376,-8.76565 -7.342388,-19.06976 -17.172591,-20.70812 -0.664273,-0.11071 -1.494441,-0.42069 -2.020305,0 -0.542049,0.43364 -0.354492,1.34267 -0.505077,2.0203 -0.522917,2.35313 -1.164511,4.68619 -1.515229,7.07107 -2.708747,18.41948 0.296465,32.36077 6.565992,49.49747 2.682486,7.33213 5.639357,17.22468 15.15229,17.67767 13.38648,0.63746 15.45757,-25.2821 7.07106,-32.82995 -1.55953,-1.40358 -5.88665,6.03367 -4.54568,15.15228 1.46349,9.95173 11.80613,17.40505 21.71828,15.15229 4.41964,-1.00446 11.43406,-9.0399 12.6269,-11.11167 7.10359,-12.33781 -9.7499,-22.51604 -18.18274,-26.26397 -11.05732,-4.91436 -18.5283,7.61904 -12.62691,11.61675 9.07281,6.1461 23.89173,1.97435 32.32488,-1.51523 4.27171,-1.7676 7.7445,-5.05076 11.61676,-7.57614" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4"> <animate begin="hel.end" attributename="stroke-dashoffset" from="500px" to="0px" dur="3s" fill="freeze" id="lo"></animate> <animate begin="lo.end" attributename="opacity" from="1" to="0" dur="2s" fill="freeze" id="loOpacity"></animate> <set begin="hel.end" attributename="opacity" to="1"></set> </path> </g></svg><figcaption>Writing fragments of word over the others</figcaption></figure></div> \endraw +\raw DocBook +<db:figure> +<db:title>Writing one character over the other</db:title> +<db:mediaobject> +<db:imageobject> +<db:imagedata> +<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="21.057215mm" height="23.094498mm" viewbox="0 0 74.612178 81.830896" id="svg4891" version="1.1"> <defs id="defs4893"></defs> <metadata id="metadata4896"> </metadata> <g id="layer1" transform="translate(523.68284,-132.09962)"> <filter id="dropshadow" height="130%"> <fegaussianblur in="SourceAlpha" stddeviation="3"></fegaussianblur> <feoffset dx="2" dy="2" result="offsetblur"></feoffset> <fecomponenttransfer xmlns="http://www.w3.org/2000/svg"> <fefunca type="linear" slope="0.5"></fefunca> </fecomponenttransfer> <femerge> <femergenode></femergenode> <femergenode in="SourceGraphic"></femergenode> </femerge></filter> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" stroke-dasharray="300" stroke-dashoffset="300" d="m -523.25902,200.29853 c 6.95139,11.10595 25.78874,3.22177 32.32488,-4.04061 11.79865,-13.1096 17.63403,-31.02787 14.14214,-48.48732 -0.50587,-2.52933 -5.5167,-18.22189 -9.09137,-14.64721 -5.55428,5.55427 -5.5673,24.06358 -6.06092,30.80965 -0.76585,10.46668 -2.8203,20.43699 -4.04061,30.80965 -0.6416,5.45361 -0.50508,9.28437 -0.50508,14.64722 0,1.34687 1.34687,4.04061 0,4.04061 -0.61968,0 0.23734,-4.20009 2.52539,-10.60661 3.69589,-10.34851 8.06488,-17.115 18.68782,-21.71828 2.1627,-0.93717 6.32571,-2.23606 7.07106,0 1.75433,5.26298 -3.71882,27.10875 8.08123,24.74874 1.4766,-0.29532 3.0107,-0.92173 4.04061,-2.0203 1.59968,-1.70633 2.42154,-4.00433 3.53553,-6.06092 1.07581,-1.98612 2.0203,-4.04061 3.03046,-6.06091" id="path4899"> <animate begin="0s;hOpacityFinal.end" attributename="stroke-dashoffset" from="300px" to="0px" dur="2s" fill="freeze" id="h"></animate> <animate begin="h.end" attributename="opacity" from="1" to="0.2" dur="2s" fill="freeze" id="hOpacity"></animate> <animate begin="oOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="hOpacityFinal"></animate> <set begin="hOpacityFinal.end" attributename="opacity" to="1"></set> </path> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" stroke-dasharray="150" stroke-dashoffset="150" d="m -503.05597,187.16655 c 6.30156,1.57539 7.48006,2.26745 14.64721,2.0203 4.68337,-0.16149 7.79914,-1.02611 11.11168,-4.54568 10.51043,-11.16733 -11.38898,-18.31643 -18.18274,-3.03046 -0.77578,1.7455 -0.56279,12.84339 0,14.14214 6.50612,15.01414 20.7593,7.81972 27.77919,-2.52539 1.4399,-2.12194 2.02031,-4.71404 3.03046,-7.07106" id="path4901"> <animate begin="h.end+0.01s" attributename="stroke-dashoffset" from="150px" to="0px" dur="2s" fill="freeze" id="e"></animate> <animate begin="e.end" attributename="opacity" from="1" to="0.2" dur="2s" fill="freeze" id="eOpacity"></animate> <animate begin="oOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="eOpacityFinal"></animate> <set begin="h.end" attributename="opacity" to="1"></set> </path> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" stroke-dasharray="200" stroke-dashoffset="200" d="m -501.03566,200.80361 c 11.64322,7.6781 20.14867,-6.67932 24.24366,-16.16244 1.65295,-3.82789 5.7942,-16.09995 4.54568,-21.71828 -0.76783,-3.45526 -2.7246,-6.56132 -4.54568,-9.59645 -10.0858,-16.80967 -16.78281,-1.60069 -18.68782,10.10152 -1.35371,8.31563 -3.14678,22.86131 -0.50508,31.31473 4.4811,14.33953 15.24399,22.1694 26.76904,8.5863 3.22845,-3.80496 5.30918,-10.30708 7.07107,-15.15229" id="path4903"> <animate begin="e.end+0.01s" attributename="stroke-dashoffset" from="200px" to="0px" dur="2s" fill="freeze" id="l"></animate> <animate begin="l.end" attributename="opacity" from="1" to="0.2" dur="2s" fill="freeze" id="lOpacity"></animate> <animate begin="oOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="lOpacityFinal"></animate> <set begin="e.end" attributename="opacity" to="1"></set> </path> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" stroke-dasharray="220" stroke-dashoffset="220" d="m -507.60165,205.3493 c 1.53719,3.07439 0.25722,2.0203 4.54568,2.0203 11.013,0 16.92189,-7.83289 21.21321,-17.67767 1.48054,-3.39653 3.24098,-15.42468 3.03045,-18.68782 -0.31004,-4.80567 -4.96262,-9.4326 -7.57614,-12.62691 -5.01521,-6.1297 -7.93642,-7.18375 -11.61676,1.51523 -3.61721,8.54979 -5.0193,26.86342 -2.0203,35.86042 3.71905,11.15714 12.82566,21.08507 24.74874,11.61675 3.11162,-2.47099 4.71404,-6.39763 7.07106,-9.59645" id="path4905"> <animate begin="l.end+0.01s" attributename="stroke-dashoffset" from="220px" to="0px" dur="2s" fill="freeze" id="l2"></animate> <animate begin="l2.end" attributename="opacity" from="1" to="0.2" dur="2s" fill="freeze" id="l2Opacity"></animate> <animate begin="oOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="l2OpacityFinal"></animate> <set begin="l.end" attributename="opacity" to="1"></set> </path> <path style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" stroke-dasharray="120" stroke-dashoffset="120" d="m -483.86307,185.14624 c -4.91638,-10.38229 -25.09874,-2.01585 -21.71828,9.09138 4.18358,13.74606 25.60472,15.81949 31.31473,2.0203 8.05585,-19.4683 -24.24366,-20.3309 -24.24366,-12.12183" id="path4907"> <animate begin="l2.end+0.01s" attributename="stroke-dashoffset" from="100px" to="0px" dur="2s" fill="freeze" id="o"></animate> <animate begin="o.end" attributename="opacity" from="1" to="0" dur="2s" fill="freeze" id="oOpacity"></animate> <set begin="l2.end" attributename="opacity" to="1"></set> </path> </g></svg></db:imagedata> +</db:imageobject> +</db:mediaobject> +</db:figure> +<db:figure> +<db:title>Writing fragments of word over the others</db:title> +<db:mediaobject> +<db:imageobject> +<db:imagedata> +<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg2" viewbox="0 0 156.63411 96.840738" height="27.330608mm" width="44.205627mm"> <defs id="defs4"></defs> <metadata id="metadata7"> </metadata> <g transform="translate(-19.991064,-156.76845)" id="layer1"> <path id="path3338" stroke-dasharray="700" stroke-dashoffset="700" d="m 20.203051,228.07773 c 7.019038,3.28583 18.296996,2.19868 25.253814,2.0203 27.834023,-0.71369 42.825541,-21.91043 41.416254,-47.98224 -0.323001,-5.97553 -7.191269,-26.45641 -10.606602,-24.74874 -10.259596,5.1298 -9.124503,41.18434 -7.576144,52.02286 1.430314,10.01219 2.165272,8.95563 3.030458,20.20305 0.514408,6.68731 0.563751,12.53255 1.515229,19.19289 0.191958,1.34371 0.355181,2.69156 0.505076,4.04061 0.01859,0.16733 0,0.67344 0,0.50508 0,-2.49868 0.106479,0.64925 -1.010153,-4.04061 -1.138171,-4.78032 -2.879899,-14.31543 -2.525381,-18.68782 0.215131,-2.65328 1.334905,-5.19519 2.525381,-7.57615 1.190476,-2.38095 2.750791,-4.60015 4.545687,-6.56599 2.880061,-3.15435 5.631315,-6.15186 10.101525,-5.55584 7.218425,0.96246 9.158962,18.77507 9.596449,24.24367 0.312712,3.90889 -0.730173,4.84918 1.010153,8.08122 2.037193,3.78335 3.387013,4.88523 8.081223,5.55583 5.47716,0.78246 9.60547,-2.86344 13.63706,-6.06091 2.23856,-1.77541 4.56788,-3.62491 6.06091,-6.06092 4.94323,-8.06526 6.7262,-26.15308 -6.06091,-28.28427 -20.629129,-3.43819 -15.11782,36.04559 11.11167,35.35534 3.30658,-0.087 6.53787,-1.26596 9.59645,-2.52538 25.47885,-10.49129 20.89279,-45.3686 11.61676,-65.65992 -1.54311,-3.37554 -5.32932,-11.06285 -9.09137,-13.13198 -1.47519,-0.81135 -3.36718,0 -5.05077,0 -1.01015,0 -2.08112,-0.34521 -3.03046,0 -9.66282,3.51375 -12.01346,27.64821 -11.11167,36.36549 0.68611,6.63247 4.06851,21.716 8.08122,26.76905 8.89766,11.20446 20.90822,13.3675 34.34518,14.64721 4.58435,0.4366 7.15182,0.9294 10.10153,-2.02031" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;"> <animate begin="0s;helOpacityFinal.end" attributename="stroke-dashoffset" from="700px" to="0px" dur="2s" fill="freeze" id="hel"></animate> <animate begin="hel.end" attributename="opacity" from="1" to="0.2" dur="3s" fill="freeze" id="helOpacity"></animate> <animate begin="loOpacity.end" attributename="opacity" from="0.2" to="0" dur="0.1s" fill="remove" id="helOpacityFinal"></animate> <set begin="helOpacityFinal.end" attributename="opacity" to="1"></set> </path> <path id="path3344" stroke-dasharray="500" stroke-dashoffset="500" d="m 41.416254,231.61326 c 3.094802,7.92585 11.797035,7.22396 19.192898,7.57614 31.260076,1.48858 50.776938,-24.97346 43.436558,-55.55839 -2.10376,-8.76565 -7.342388,-19.06976 -17.172591,-20.70812 -0.664273,-0.11071 -1.494441,-0.42069 -2.020305,0 -0.542049,0.43364 -0.354492,1.34267 -0.505077,2.0203 -0.522917,2.35313 -1.164511,4.68619 -1.515229,7.07107 -2.708747,18.41948 0.296465,32.36077 6.565992,49.49747 2.682486,7.33213 5.639357,17.22468 15.15229,17.67767 13.38648,0.63746 15.45757,-25.2821 7.07106,-32.82995 -1.55953,-1.40358 -5.88665,6.03367 -4.54568,15.15228 1.46349,9.95173 11.80613,17.40505 21.71828,15.15229 4.41964,-1.00446 11.43406,-9.0399 12.6269,-11.11167 7.10359,-12.33781 -9.7499,-22.51604 -18.18274,-26.26397 -11.05732,-4.91436 -18.5283,7.61904 -12.62691,11.61675 9.07281,6.1461 23.89173,1.97435 32.32488,-1.51523 4.27171,-1.7676 7.7445,-5.05076 11.61676,-7.57614" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4"> <animate begin="hel.end" attributename="stroke-dashoffset" from="500px" to="0px" dur="3s" fill="freeze" id="lo"></animate> <animate begin="lo.end" attributename="opacity" from="1" to="0" dur="2s" fill="freeze" id="loOpacity"></animate> <set begin="hel.end" attributename="opacity" to="1"></set> </path> </g></svg></db:imagedata> +</db:imageobject> +</db:mediaobject> +</db:figure> +\endraw + \section3 Language coverage of MyScript Text SDK MyScript Superimposed supports 72 languages. diff --git a/src/virtualkeyboard/doc/src/deployment-guide.qdoc b/src/virtualkeyboard/doc/src/deployment-guide.qdoc index e9f15c5f..04abd288 100644 --- a/src/virtualkeyboard/doc/src/deployment-guide.qdoc +++ b/src/virtualkeyboard/doc/src/deployment-guide.qdoc @@ -96,17 +96,17 @@ or by adding \c -no-vkb-desktop to the \c configure command line. This section explains how to use Qt Virtual Keyboard to interact with the \l {Line Edits Example}{Qt Widgets Line Edits example} using the -\l {Qt Wayland Compositor Examples - Pure QML}{Pure QML example} -as a compositor. +\l {Fancy Compositor}{Fancy Compositor example} as a compositor. We will be using Ubuntu 18.04 to run the example, using the X11 as the -windowing system. The example compositor (\c pure-qml) will open +windowing system. The example compositor (\c fancy-compositor) will open as a window within an X11 session. \list 1 \li Start the compositor: \badcode -QT_XCB_GL_INTEGRATION=xcb_egl QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=xcomposite-egl QT_IM_MODULE=qtvirtualkeyboard ./pure-qml -platform xcb +QT_XCB_GL_INTEGRATION=xcb_egl QT_WAYLAND_CLIENT_BUFFER_INTEGRATION=xcomposite-egl \ +QT_IM_MODULE=qtvirtualkeyboard ./fancy-compositor -platform xcb \endcode \li Before running the client application, ensure that QT_IM_MODULE is unset: \badcode @@ -277,7 +277,8 @@ There are several environment variables defined by the module that are listed be \li Specifies the location of the style to use with the virtual keyboard. This can also be specified in QML by setting \l {VirtualKeyboardSettings::styleName}, - or at build time by using the \l {Advanced Usage}{Configuration Options}. + or at build time by using the + \l [DOC] {Advanced Usage} {Configuration Options}. \row \li QT_VIRTUALKEYBOARD_LAYOUT_PATH \li Specifies the location of the layouts to be used with the virtual keyboard. diff --git a/src/virtualkeyboard/doc/src/handwriting.qdoc b/src/virtualkeyboard/doc/src/handwriting.qdoc index 0f6192c9..204b4269 100644 --- a/src/virtualkeyboard/doc/src/handwriting.qdoc +++ b/src/virtualkeyboard/doc/src/handwriting.qdoc @@ -21,6 +21,12 @@ For instructions on how to activate and use the handwriting input mode, see the For information about building Qt Virtual Keyboard with a particular handwriting engine, see \l {Configuration Options}. +\section1 Example Handwriting + +The Example Handwriting Plugin offers a simulated handwriting recognition experience +producing random characters regardless of what is written. It serves as a tool for +examining handwriting layouts and as a foundation for developing new plugins. + \section1 Cerence Handwriting \l {https://cerence.com}{Cerence Handwriting} @@ -29,7 +35,7 @@ is a commercial handwriting recognition engine. Cerence Handwriting works with all languages supported by the virtual keyboard. \list - \li \l {Qt Virtual Keyboard#Supported Languages}{Supported Languages} + \li \l {Qt Virtual Keyboard Overview#Supported Languages}{Supported Languages} \endlist \b {See also}: \l {Cerence Handwriting Integration} @@ -130,7 +136,7 @@ MyScript SDK supports 72 handwriting recognition languages: MyScript is integrated into Qt Virtual Keyboard with identical coverage of supported languages. \list - \li \l {Qt Virtual Keyboard#Supported Languages}{Supported Languages} + \li \l {Qt Virtual Keyboard Overview#Supported Languages}{Supported Languages} \endlist However, with minor modifications to the Qt Virtual Keyboard source code, it is easy to add handwriting panels for other languages supported by \MyScript. diff --git a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc index 58b1078d..f0edd5ab 100644 --- a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc +++ b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-examples.qdoc @@ -8,11 +8,13 @@ */ /*! - \title Qt Quick Virtual Keyboard - Basic Example + \title Virtual Keyboard in Qt Quick \example basic - \brief This is a basic QML example that uses the virtual keyboard. + \examplecategory {Embedded} + \brief This example shows how to use the virtual keyboard in a Qt Quick application. \ingroup qtvirtualkeyboard-examples \image basic-example.png + \meta tags {quick} The example has two implementations: one for desktop platforms and another for embedded platforms. The former version diff --git a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc index 6ae1d75c..037acf44 100644 --- a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc +++ b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-index.qdoc @@ -13,54 +13,34 @@ integrate 3rd party input engines. The input methods can be implemented in C++ or QML. - \section1 Features + \section1 Using the Module - Key features of the Qt Virtual Keyboard include: + \include {module-use.qdocinc} {using the c++ api} - \list - \li Customizable keyboard layouts and styles with dynamic switching. - \li Predictive text input with word selection. - \li Character preview and alternative character view. - \li Automatic capitalization and space insertion. - \li Scalability to different resolutions. - \li Support for different character sets (Latin, Simplified/Traditional Chinese, - Hindi, Japanese, Arabic, Hebrew, Korean, and others). - \li Support for most common input \l {Supported Languages}{languages}, - with possibility to easily extend the language support. - \li Left-to-right and right-to-left input. - \li Hardware key support for 2-way and 5-way navigation. - \li \l {Handwriting Recognition}{Handwriting support}, with gestures for fullscreen input. - \li Audio feedback. - \li Cross-platform functionality. - \li Supports both \l {Integration Method}{Qt Quick and Qt Widgets applications}. - \endlist - - \section1 Supported Languages - - \include layouts.qdocinc layout-list + \section2 Building with CMake - \section1 Third-party Plugins + \include {module-use.qdocinc} {building with cmake} {VirtualKeyboard} - The Qt Virtual Keyboard supports third-party plugins from the following vendors: - \list - \li \l {Cerence XT9 Advanced Input}{Cerence XT9} advanced input. - \li \l {Handwriting Recognition#Cerence Handwriting}{Cerence Handwriting} text input. - \li \l {Handwriting Recognition#MyScript}{MyScript} Text handwriting recognition - \endlist + \section2 Building with qmake - \l {Building Qt Virtual Keyboard} describes how to integrate these plugins - into the Qt Virtual Keyboard. + \include {module-use.qdocinc} {building_with_qmake} {virtualkeyboard} - \section1 Guides + \section1 Articles and Guides \list \li \l {Building Qt Virtual Keyboard} \li \l {Deployment Guide} - \li \l {Technical Guide} + \li \l {Qt Virtual Keyboard Overview} \li \l {User Guide} \endlist - \section1 API Reference + \section1 Examples + + \list + \li \l{Qt Virtual Keyboard Examples} + \endlist + + \section1 Reference \list \li \l{Qt Virtual Keyboard API for Applications} @@ -69,20 +49,16 @@ \li \l{Qt Virtual Keyboard C++ Classes} \endlist - \section1 Examples - - \list - \li \l{Qt Virtual Keyboard Examples} - \endlist \section1 Licenses and Attributions - Qt Virtual Keyboard is available under commercial licenses from \l{The Qt Company}. - In addition, it is available under the \l{GNU General Public License, version 3}. + Qt Virtual Keyboard is available under commercial licenses from + \l{The Qt Company}. In addition, it is available under the + \l{GNU General Public License, version 3}. See \l{Qt Licensing} for further details. - Furthermore Qt Virtual Keyboard potentially contains third party - modules under following permissive licenses: + Furthermore, Qt Virtual Keyboard potentially contains third party + modules under the following permissive licenses: \generatelist{groupsbymodule attributions-qtvirtualkeyboard} */ diff --git a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-namespace.qdoc b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-namespace.qdoc index c5b0cb19..6c2635e5 100644 --- a/src/virtualkeyboard/doc/src/qtvirtualkeyboard-namespace.qdoc +++ b/src/virtualkeyboard/doc/src/qtvirtualkeyboard-namespace.qdoc @@ -6,6 +6,7 @@ \inmodule QtVirtualKeyboard \ingroup qtvirtualkeyboard-cpp-for-devs \keyword Qt Virtual Keyboard Namespace + \brief Contains enums used by the virtual keyboard classes. */ /*! diff --git a/src/virtualkeyboard/doc/src/technical-guide.qdoc b/src/virtualkeyboard/doc/src/technical-guide.qdoc index 4488c444..eb424765 100644 --- a/src/virtualkeyboard/doc/src/technical-guide.qdoc +++ b/src/virtualkeyboard/doc/src/technical-guide.qdoc @@ -3,17 +3,53 @@ /*! -\page technical-guide.html +\page qtvirtualkeyboard-overview.html +\title Qt Virtual Keyboard Overview +\brief Describes the technical details of the Qt Virtual Keyboard module. +\ingroup explanantion +This document provides a technical overview of the Qt Virtual Keyboard plugin. -\title Technical Guide +\section1 Features -\section1 Overview +Key features of the Qt Virtual Keyboard include: -This document provides a technical overview of the Qt Virtual Keyboard plugin. +\list + \li Customizable keyboard layouts and styles with dynamic switching. + \li Predictive text input with word selection. + \li Character preview and alternative character view. + \li Automatic capitalization and space insertion. + \li Scalability to different resolutions. + \li Support for different character sets (Latin, Simplified/Traditional Chinese, + Hindi, Japanese, Arabic, Hebrew, Korean, and others). + \li Support for most common input \l {Supported Languages}{languages}, + with possibility to easily extend the language support. + \li Left-to-right and right-to-left input. + \li Hardware key support for 2-way and 5-way navigation. + \li \l {Handwriting Recognition}{Handwriting support}, with gestures for fullscreen input. + \li Audio feedback. + \li Cross-platform functionality. + \li Supports both \l {Integration Method}{Qt Quick and Qt Widgets applications}. +\endlist + +\section1 Supported Languages + +\include layouts.qdocinc layout-list + +\section1 Third-party Plugins + +The Qt Virtual Keyboard supports third-party plugins from the following vendors: +\list + \li \l {Cerence XT9 Advanced Input}{Cerence XT9} advanced input. + \li \l {Handwriting Recognition#Cerence Handwriting}{Cerence Handwriting} text input. + \li \l {Handwriting Recognition#MyScript}{MyScript} Text handwriting recognition +\endlist + +\l {Building Qt Virtual Keyboard} describes how to integrate these plugins +into the Qt Virtual Keyboard. \section1 Basic Concepts -The Qt Virtual Keyboard project is a Qt input context plugin which implements +The Qt Virtual Keyboard project is a Qt input context plugin that implements QPlatformInputContextPlugin and QPlatformInputContext interfaces. These interfaces allow the plugin to be used as a platform input context plugin in Qt applications. @@ -61,46 +97,68 @@ from the application. This information includes, but is not limited to: \section2 Locale -The list of supported locales is specified by the existence of a locale specific -layout directory in "layouts/*". Each layout directory may contain one -or more layouts, for example fi_FI/main.qml or symbols.qml. If the locale specific -layout is not different from the fallback locale, then a place holder file \c -<layout type>.fallback can be added for the layout. This will specify the virtual -keyboard that a fallback layout can be used instead. - -At minimum the layout directory must contain the files: +The Virtual Keyboard Engine generates the list of supported locales from +locale-specific layout directories in \c {layouts/}. Each layout directory +must contain a definition or fallback for the following layout types: +\e dialpad, \e digits, \e handwriting, \e main, \e numbers, and \e symbols. +Definitions are implemented in \c {.qml}-files, fallbacks are defined by a +placeholder file with the \c {.fallback} file extension. The \c {layouts/} +directory must contain a \c {fallback/} sub-directory that contains definitions +for each layout type. + +Each layout directory may contain the definition of one or more layout types. +If the locale-specific layout is the same as that of the fallback locale, you +can add a placeholder file for the layout called \c {<layout type>.fallback}. +This instructs the virtual keyboard to use the fallback layout instead. + +For example: you may add a locale-specific layout for Finnish, that defines the +main layout type in \c {main.qml}. For the other layout types, you opt for the +fallback mechanism. Your \c {layouts/} tree will look like this: + +\badcode +. +├── fallback +│ ├── dialpad.qml +│ ├── digits.qml +│ ├── handwriting.qml +│ ├── main.qml +│ ├── numbers.qml +│ └── symbols.qml +└── fi_FI + ├── dialpad.fallback + ├── digits.fallback + ├── handwriting.fallback + ├── main.qml + ├── numbers.fallback + └── symbols.fallback +\endcode -\list - \li \c dialpad.fallback - \li \c digits.fallback - \li \c main.fallback - \li \c numbers.fallback - \li \c symbols.fallback -\endlist +It's imperative that the \c {layouts/fallback} directory always contain a set +of full implementation files. The application can specify the initial layout by changing the default locale. -However, this needs to be done before the application is initialized and the -input method plugin is loaded. If no changes are made to the default locale, the -current system locale is used. +However, this must be done before the application initializes and loads the +input method plugin. If there are no changes to the default locale, the current +system locale is used. -The keyboard locale matching is performed in the following sequence: +Matching the keyboard locale follows this sequence: \list - \li layouts/<language>_<country> - \li layouts/<language>_* - \li layouts/en_GB + \li \c {layouts/<language>_<country>} + \li \c {layouts/<language>_*} + \li \c {layouts/fallback} -- the default layout here is \e en_GB. \endlist -The locale is first matched against the full locale name. If a full match is -not found, then only the locale language is matched. If a partial match is -not found, then the "en_GB" locale is used as a fallback. +First, the locale is matched against the full locale name. If a there isn't a +full match, then only the locale language is matched. Finally, the contents of +\c {layouts/fallback} is used as a fallback when there's also no partial match. After the locale selection is done, the keyboard updates the input locale and input direction to match the current layout. The application can receive this information through the QInputMethod interface. -Internally, the current input locale is also updated to the QVirtualKeyboardInputEngine -and the current input method instances. +Internally, the current input locale is also updated to +QVirtualKeyboardInputEngine and the current input method instances. \section1 Input Engine @@ -595,7 +653,7 @@ directory, the virtual keyboard falls back to the default built-in layouts. To prevent the built-in layouts from being built into the virtual keyboard plugin when using custom layouts, add \c -no-vkb-layouts option to the \c configure script. -For more information, see \l {Advanced Usage}{Configuration Options}. +For more information, see \l [DOC] {Advanced Usage} {Configuration Options}. \section1 Keyboard Styles diff --git a/src/virtualkeyboard/doc/src/user-guide.qdoc b/src/virtualkeyboard/doc/src/user-guide.qdoc index 3e7c93f9..e1352d14 100644 --- a/src/virtualkeyboard/doc/src/user-guide.qdoc +++ b/src/virtualkeyboard/doc/src/user-guide.qdoc @@ -7,8 +7,6 @@ \title User Guide -\section1 Overview - This document explains how to interact with the virtual keyboard. \section1 Opening the Keyboard diff --git a/src/virtualkeyboard/handwritinggesturerecognizer.cpp b/src/virtualkeyboard/handwritinggesturerecognizer.cpp index 2d64c3f7..72337132 100644 --- a/src/virtualkeyboard/handwritinggesturerecognizer.cpp +++ b/src/virtualkeyboard/handwritinggesturerecognizer.cpp @@ -27,7 +27,7 @@ int HandwritingGestureRecognizer::dpi() const QVariantMap HandwritingGestureRecognizer::recognize(const QList<QVirtualKeyboardTrace *> traceList) { - if (traceList.count() > 0 && traceList.count() < 3) { + if (traceList.size() > 0 && traceList.size() < 3) { // Swipe gesture detection // ======================= @@ -64,7 +64,7 @@ QVariantMap HandwritingGestureRecognizer::recognize(const QList<QVirtualKeyboard const QVirtualKeyboardTrace *trace = traceList.at(traceIndex); const QVariantList &points = trace->points(); QVector2D swipeVector; - const int pointCount = points.count(); + const int pointCount = points.size(); int pointIndex = 0; if (pointCount >= 2) { @@ -110,7 +110,7 @@ QVariantMap HandwritingGestureRecognizer::recognize(const QList<QVirtualKeyboard bool matchesToExisting = true; const qreal minimumSwipeLength = (swipeLength * (100.0 - MAXIMUM_WIDTH_VARIANCE) / 100.0); const qreal maximumSwipeLength = (swipeLength * (100.0 + MAXIMUM_WIDTH_VARIANCE) / 100.0); - for (const QVector2D &otherSwipeVector : qAsConst(swipeVectors)) { + for (const QVector2D &otherSwipeVector : std::as_const(swipeVectors)) { const qreal otherSwipeLength = otherSwipeVector.length(); const qreal theta = qAcos(QVector2D::dotProduct(swipeVector, otherSwipeVector) / (swipeLength * otherSwipeLength)); diff --git a/src/virtualkeyboard/plaininputmethod_p.h b/src/virtualkeyboard/plaininputmethod_p.h index d3e94cb8..4e8c2217 100644 --- a/src/virtualkeyboard/plaininputmethod_p.h +++ b/src/virtualkeyboard/plaininputmethod_p.h @@ -25,6 +25,7 @@ class Q_VIRTUALKEYBOARD_EXPORT PlainInputMethod : public QVirtualKeyboardAbstrac { Q_OBJECT QML_NAMED_ELEMENT(PlainInputMethod) + QML_ADDED_IN_VERSION(2, 0) public: explicit PlainInputMethod(QObject *parent = nullptr); diff --git a/src/virtualkeyboard/platforminputcontext.cpp b/src/virtualkeyboard/platforminputcontext.cpp index 85f4f212..ab3f3887 100644 --- a/src/virtualkeyboard/platforminputcontext.cpp +++ b/src/virtualkeyboard/platforminputcontext.cpp @@ -274,8 +274,10 @@ void PlatformInputContext::updateInputPanelVisible() m_inputPanel->show(); else m_inputPanel->hide(); - if (m_selectionControl) + if (m_selectionControl) { m_selectionControl->setEnabled(visible); + m_inputContext->priv()->updateSelectionControlVisible(visible); + } emitInputPanelVisibleChanged(); } } diff --git a/src/virtualkeyboard/qt_cmdline.cmake b/src/virtualkeyboard/qt_cmdline.cmake index 8ee9f0ee..e66b46c8 100644 --- a/src/virtualkeyboard/qt_cmdline.cmake +++ b/src/virtualkeyboard/qt_cmdline.cmake @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_commandline_option(vkb-sensitive-debug TYPE boolean) qt_commandline_option(vkb-arrow-keynavigation TYPE boolean) qt_commandline_option(vkb-enable TYPE enableLang) @@ -5,7 +8,7 @@ qt_commandline_option(vkb-disable TYPE disableLang) qt_commandline_option(vkb-layouts TYPE boolean) qt_commandline_option(vkb-desktop TYPE boolean) qt_commandline_option(vkb-hunspell TYPE enum VALUES no 3rdparty system) -qt_commandline_option(vkb-handwriting TYPE optionalString VALUES no myscript-hwr cerence-hwr) +qt_commandline_option(vkb-handwriting TYPE optionalString VALUES no myscript-hwr cerence-hwr example-hwr) qt_commandline_option(vkb-cerence-sdk TYPE string) qt_commandline_option(vkb-style TYPE string VALUES standard retro none) qt_commandline_option(vkb-no-bundle-pinyin TYPE boolean) diff --git a/src/virtualkeyboard/qvirtualkeyboard_namespace.h b/src/virtualkeyboard/qvirtualkeyboard_namespace.h index 1c0f6024..84871c1a 100644 --- a/src/virtualkeyboard/qvirtualkeyboard_namespace.h +++ b/src/virtualkeyboard/qvirtualkeyboard_namespace.h @@ -1,48 +1,13 @@ -// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2022 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QVIRTUALKEYBOARD_NAMESPACE_H #define QVIRTUALKEYBOARD_NAMESPACE_H -#include <QMetaEnum> -#include <QtQml/qqml.h> -#include <QtVirtualKeyboard/qvirtualkeyboard_global.h> - -QT_BEGIN_NAMESPACE - -namespace QtVirtualKeyboard { - -Q_VIRTUALKEYBOARD_EXPORT Q_NAMESPACE -QML_NAMED_ELEMENT(QtVirtualKeyboard) - -enum class KeyType { - BaseKey, - BackspaceKey, - ChangeLanguageKey, - EnterKey, - FillerKey, - HandwritingModeKey, - HideKeyboardKey, - InputModeKey, - Key, - ModeKey, - NumberKey, - ShiftKey, - SpaceKey, - SymbolModeKey, - FlickKey, -}; -Q_ENUM_NS(KeyType) - -enum class KeyboardFunction { - HideInputPanel, - ChangeLanguage, - ToggleHandwritingMode, -}; -Q_ENUM_NS(KeyboardFunction) - -} // namespace QtVirtualKeyboard - -QT_END_NAMESPACE +#if 0 +# pragma qt_sync_skip_header_check +#endif +// TODO: Remove in Qt 7 +#include <QtVirtualKeyboard/private/qvirtualkeyboardnamespace_p.h> #endif // QVIRTUALKEYBOARD_NAMESPACE_H diff --git a/src/virtualkeyboard/qvirtualkeyboarddictionary.h b/src/virtualkeyboard/qvirtualkeyboarddictionary.h index 30eb7ef2..a85cc636 100644 --- a/src/virtualkeyboard/qvirtualkeyboarddictionary.h +++ b/src/virtualkeyboard/qvirtualkeyboarddictionary.h @@ -5,8 +5,8 @@ #define QVIRTUALKEYBOARDDICTIONARY_H #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> -#include <QStringList> -#include <QObject> +#include <QtCore/QStringList> +#include <QtCore/QObject> QT_BEGIN_NAMESPACE diff --git a/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.cpp b/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.cpp index 033207c9..14b2bb10 100644 --- a/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.cpp +++ b/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.cpp @@ -75,10 +75,10 @@ QVirtualKeyboardDictionaryManager::QVirtualKeyboardDictionaryManager(QObject *pa QObject(*new QVirtualKeyboardDictionaryManagerPrivate(this), parent) { Q_D(QVirtualKeyboardDictionaryManager); - connect(this, &QVirtualKeyboardDictionaryManager::baseDictionariesChanged, - [=](){ d->updateActiveDictionaries(); }); - connect(this, &QVirtualKeyboardDictionaryManager::extraDictionariesChanged, - [=](){ d->updateActiveDictionaries(); }); + connect(this, &QVirtualKeyboardDictionaryManager::baseDictionariesChanged, this, + [d]() { d->updateActiveDictionaries(); }); + connect(this, &QVirtualKeyboardDictionaryManager::extraDictionariesChanged, this, + [d]() { d->updateActiveDictionaries(); }); } /*! diff --git a/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.h b/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.h index 24ccffa0..fe549fc0 100644 --- a/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.h +++ b/src/virtualkeyboard/qvirtualkeyboarddictionarymanager.h @@ -5,8 +5,8 @@ #define QVIRTUALKEYBOARDDICTIONARYMANAGER_H #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> -#include <QStringList> -#include <QObject> +#include <QtCore/QStringList> +#include <QtCore/QObject> QT_BEGIN_NAMESPACE diff --git a/src/virtualkeyboard/qvirtualkeyboardfeatures_namespace_p.h b/src/virtualkeyboard/qvirtualkeyboardfeatures_namespace_p.h index 14f37e1f..19791285 100644 --- a/src/virtualkeyboard/qvirtualkeyboardfeatures_namespace_p.h +++ b/src/virtualkeyboard/qvirtualkeyboardfeatures_namespace_p.h @@ -17,19 +17,20 @@ #include <QMetaEnum> #include <QtQml/qqml.h> -#include <QtVirtualKeyboard/private/qtvirtualkeyboardexports_p.h> +#include <QtVirtualKeyboard/qtvirtualkeyboardexports.h> #include <QtVirtualKeyboard/private/qtvirtualkeyboard-config_p.h> QT_BEGIN_NAMESPACE namespace QVirtualKeyboardFeatures { -Q_VIRTUALKEYBOARD_PRIVATE_EXPORT Q_NAMESPACE +Q_VIRTUALKEYBOARD_EXPORT Q_NAMESPACE QML_NAMED_ELEMENT(VirtualKeyboardFeatures) +QML_ADDED_IN_VERSION(6, 4) enum Feature { Handwriting = -#if QT_CONFIG(cerence_hwr) || QT_CONFIG(myscript) +#if QT_CONFIG(cerence_hwr) || QT_CONFIG(myscript) || QT_CONFIG(example_hwr) 1 #else 0 diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext.cpp b/src/virtualkeyboard/qvirtualkeyboardinputcontext.cpp index 8c1ec631..1da578d3 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext.cpp +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext.cpp @@ -10,6 +10,7 @@ #include <QTextFormat> #include <QGuiApplication> +#include <QtGui/private/qhighdpiscaling_p.h> QT_BEGIN_NAMESPACE using namespace QtVirtualKeyboard; @@ -107,7 +108,7 @@ void QVirtualKeyboardInputContext::setPreeditText(const QString &text, QList<QIn if (!d->testAttribute(attributes, QInputMethodEvent::TextFormat)) { QTextCharFormat textFormat; textFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline); - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, text.length(), textFormat)); + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, text.size(), textFormat)); } } else if (d->_forceCursorPosition != -1) { d->addSelectionAttribute(attributes); @@ -207,6 +208,10 @@ void QVirtualKeyboardInputContext::sendKeyClick(int key, const QString &text, in d->setState(QVirtualKeyboardInputContextPrivate::State::KeyEvent); d->platformInputContext->sendKeyEvent(&pressEvent); d->platformInputContext->sendKeyEvent(&releaseEvent); + + if (key == Qt::Key_Return || key == Qt::Key_Enter) + d->maybeCloseOnReturn(); + if (d->activeKeys.isEmpty()) d->clearState(QVirtualKeyboardInputContextPrivate::State::KeyEvent); } else { @@ -312,7 +317,11 @@ void QVirtualKeyboardInputContext::clear() */ void QVirtualKeyboardInputContext::setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos) { - QPlatformInputContext::setSelectionOnFocusObject(anchorPos, cursorPos); + QWindow *window = qApp->focusWindow(); + const QPointF &nativeAnchorPos = QHighDpi::toNativePixels(anchorPos, window); + const QPointF &nativeCursorPos = QHighDpi::toNativePixels(cursorPos, window); + + QPlatformInputContext::setSelectionOnFocusObject(nativeAnchorPos, nativeCursorPos); } /*! diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext.h b/src/virtualkeyboard/qvirtualkeyboardinputcontext.h index 6db573f7..1bd81d58 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext.h +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext.h @@ -4,11 +4,11 @@ #ifndef QVIRTUALKEYBOARDINPUTCONTEXT_H #define QVIRTUALKEYBOARDINPUTCONTEXT_H -#include <QObject> -#include <QRectF> -#include <QLocale> -#include <QInputMethodEvent> -#include <QInputMethod> +#include <QtCore/QObject> +#include <QtCore/QRectF> +#include <QtCore/QLocale> +#include <QtGui/QInputMethodEvent> +#include <QtGui/QInputMethod> #include <QtQml/qqml.h> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> @@ -27,9 +27,9 @@ class Q_VIRTUALKEYBOARD_EXPORT QVirtualKeyboardInputContext : public QObject Q_DISABLE_COPY(QVirtualKeyboardInputContext) Q_DECLARE_PRIVATE(QVirtualKeyboardInputContext) Q_PROPERTY(bool shift READ isShiftActive NOTIFY shiftActiveChanged) - Q_PROPERTY(bool shiftActive READ isShiftActive NOTIFY shiftActiveChanged REVISION 4) + Q_PROPERTY(bool shiftActive READ isShiftActive NOTIFY shiftActiveChanged REVISION(2, 4)) Q_PROPERTY(bool capsLock READ isCapsLockActive NOTIFY capsLockActiveChanged) - Q_PROPERTY(bool capsLockActive READ isCapsLockActive NOTIFY capsLockActiveChanged REVISION 4) + Q_PROPERTY(bool capsLockActive READ isCapsLockActive NOTIFY capsLockActiveChanged REVISION(2, 4)) Q_PROPERTY(bool uppercase READ isUppercase NOTIFY uppercaseChanged) Q_PROPERTY(int anchorPosition READ anchorPosition NOTIFY anchorPositionChanged) Q_PROPERTY(int cursorPosition READ cursorPosition NOTIFY cursorPositionChanged) @@ -46,11 +46,13 @@ class Q_VIRTUALKEYBOARD_EXPORT QVirtualKeyboardInputContext : public QObject Q_PROPERTY(bool selectionControlVisible READ isSelectionControlVisible NOTIFY selectionControlVisibleChanged) Q_PROPERTY(bool anchorRectIntersectsClipRect READ anchorRectIntersectsClipRect NOTIFY anchorRectIntersectsClipRectChanged) Q_PROPERTY(bool cursorRectIntersectsClipRect READ cursorRectIntersectsClipRect NOTIFY cursorRectIntersectsClipRectChanged) - Q_PROPERTY(QVirtualKeyboardInputContextPrivate *priv READ priv CONSTANT) + Q_PROPERTY(QVirtualKeyboardInputContextPrivate *priv READ priv CONSTANT REVISION(2, 0)) Q_PROPERTY(QVirtualKeyboardObserver *keyboardObserver READ keyboardObserver CONSTANT REVISION(6, 1)) Q_MOC_INCLUDE("qvirtualkeyboardinputengine.h") Q_MOC_INCLUDE("qvirtualkeyboardinputcontext_p.h") - QML_NAMED_ELEMENT(InputContext) + + // The QML macros are unused for now, until we can move the QML_NAMED_ELEMENT back here. + // QML_SINGLETON generates some code that might or might not emit symbols on some platforms. QML_SINGLETON QML_ADDED_IN_VERSION(1, 0) QML_EXTRA_VERSION(2, 0) diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp index 831d823f..3483a6cc 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.cpp @@ -9,6 +9,7 @@ #include <QtVirtualKeyboard/private/enterkeyaction_p.h> #include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h> #include <QtVirtualKeyboard/qvirtualkeyboardobserver.h> +#include <QtVirtualKeyboard/private/enterkeyactionattachedtype_p.h> #include <QtVirtualKeyboard/private/virtualkeyboardattachedtype_p.h> #include <QtVirtualKeyboard/qvirtualkeyboarddictionarymanager.h> @@ -18,6 +19,7 @@ #include <QtQuick/qquickwindow.h> #include <QtGui/qpa/qplatformintegration.h> #include <QtGui/private/qguiapplication_p.h> +#include <QQmlEngine> QT_BEGIN_NAMESPACE @@ -225,7 +227,7 @@ void QVirtualKeyboardInputContextPrivate::forceCursorPosition(int anchorPosition forceAnchorPosition = -1; _forceCursorPosition = cursorPosition; if (cursorPosition > this->cursorPosition) - _forceCursorPosition += preeditText.length(); + _forceCursorPosition += preeditText.size(); commit(); } else { forceAnchorPosition = anchorPosition; @@ -264,6 +266,19 @@ bool QVirtualKeyboardInputContextPrivate::contains(const QPointF &point) const return !hit; } +KeyboardFunctionKey QVirtualKeyboardInputContextPrivate::keyboardFunctionKey(QtVirtualKeyboard::KeyboardFunction keyboardFunction) const +{ + switch (keyboardFunction) { + case KeyboardFunction::HideInputPanel: + return KeyboardFunctionKey::Hide; + case KeyboardFunction::ChangeLanguage: + return KeyboardFunctionKey::Language; + case KeyboardFunction::ToggleHandwritingMode: + return KeyboardFunctionKey::None; + } + return KeyboardFunctionKey::None; +} + void QVirtualKeyboardInputContextPrivate::onInputItemChanged() { QObject *item = inputItem(); @@ -502,13 +517,13 @@ void QVirtualKeyboardInputContextPrivate::invokeAction(QInputMethod::Action acti if (inputEngine->clickPreeditText(cursorPosition)) break; - bool reselect = !inputMethodHints.testFlag(Qt::ImhNoPredictiveText) && selectedText.isEmpty() && cursorPosition < preeditText.length(); + bool reselect = !inputMethodHints.testFlag(Qt::ImhNoPredictiveText) && selectedText.isEmpty() && cursorPosition < preeditText.size(); if (reselect) { QVirtualKeyboardScopedState reselectState(this, State::Reselect); _forceCursorPosition = this->cursorPosition + cursorPosition; commit(); inputEngine->reselect(this->cursorPosition, QVirtualKeyboardInputEngine::ReselectFlag::WordBeforeCursor); - } else if (!preeditText.isEmpty() && cursorPosition == preeditText.length()) { + } else if (!preeditText.isEmpty() && cursorPosition == preeditText.size()) { commit(); } } @@ -520,6 +535,46 @@ void QVirtualKeyboardInputContextPrivate::invokeAction(QInputMethod::Action acti } } +void QVirtualKeyboardInputContextPrivate::maybeCloseOnReturn() +{ + if (!Settings::instance()->closeOnReturn()) + return; + + const int imHints = QInputMethod::queryFocusObject(Qt::ImHints, QVariant()).toInt(); + if (imHints & Qt::ImhMultiLine) + return; + + const Qt::EnterKeyType keyType = static_cast<Qt::EnterKeyType>(QInputMethod::queryFocusObject(Qt::ImEnterKeyType, QVariant()).toInt()); + switch (keyType) { + case Qt::EnterKeyDefault: + case Qt::EnterKeyDone: + case Qt::EnterKeyGo: + case Qt::EnterKeySend: + case Qt::EnterKeySearch: + break; + case Qt::EnterKeyReturn: + case Qt::EnterKeyNext: + case Qt::EnterKeyPrevious: + return; + } + + if (EnterKeyActionAttachedType *enterKeyActionAttachedType = static_cast<EnterKeyActionAttachedType *>(qmlAttachedPropertiesObject<EnterKeyAction>(inputItem(), false))) { + const EnterKeyAction::Id enterKeyActionId = static_cast<EnterKeyAction::Id>(enterKeyActionAttachedType->actionId()); + switch (enterKeyActionId) { + case EnterKeyAction::None: + case EnterKeyAction::Done: + case EnterKeyAction::Go: + case EnterKeyAction::Search: + case EnterKeyAction::Send: + break; + case EnterKeyAction::Next: + return; + } + } + + hideInputPanel(); +} + bool QVirtualKeyboardInputContextPrivate::filterEvent(const QEvent *event) { QEvent::Type type = event->type(); @@ -552,6 +607,10 @@ bool QVirtualKeyboardInputContextPrivate::filterEvent(const QEvent *event) } #endif + if (type == QEvent::KeyRelease && (key == Qt::Key_Return || key == Qt::Key_Enter)) { + maybeCloseOnReturn(); + } + // Break composing text since the virtual keyboard does not support hard keyboard events if (!preeditText.isEmpty()) { if (type == QEvent::KeyPress && (key == Qt::Key_Delete || key == Qt::Key_Backspace)) { @@ -602,7 +661,7 @@ void QVirtualKeyboardInputContextPrivate::addSelectionAttribute(QList<QInputMeth bool QVirtualKeyboardInputContextPrivate::testAttribute(const QList<QInputMethodEvent::Attribute> &attributes, QInputMethodEvent::AttributeType attributeType) const { - for (const QInputMethodEvent::Attribute &attribute : qAsConst(attributes)) { + for (const QInputMethodEvent::Attribute &attribute : std::as_const(attributes)) { if (attribute.type == attributeType) return true; } @@ -611,7 +670,7 @@ bool QVirtualKeyboardInputContextPrivate::testAttribute(const QList<QInputMethod int QVirtualKeyboardInputContextPrivate::findAttribute(const QList<QInputMethodEvent::Attribute> &attributes, QInputMethodEvent::AttributeType attributeType) const { - const int count = attributes.count(); + const int count = attributes.size(); for (int i = 0; i < count; ++i) { if (attributes.at(i).type == attributeType) return i; @@ -619,4 +678,26 @@ int QVirtualKeyboardInputContextPrivate::findAttribute(const QList<QInputMethodE return -1; } +void QVirtualKeyboardInputContextPrivate::updateSelectionControlVisible(bool inputPanelVisible) +{ + Q_Q(QVirtualKeyboardInputContext); + bool newSelectionControlVisible = inputPanelVisible && (cursorPosition != anchorPosition) && !inputMethodHints.testFlag(Qt::ImhNoTextHandles); + if (selectionControlVisible != newSelectionControlVisible) { + selectionControlVisible = newSelectionControlVisible; + emit q->selectionControlVisibleChanged(); + } +} + +QVirtualKeyboardInputContext *QVirtualKeyboardInputContextForeign::create( + QQmlEngine *qmlEngine, QJSEngine *) +{ + static QMutex mutex; + static QHash<QQmlEngine *, QVirtualKeyboardInputContext *> instances; + QMutexLocker locker(&mutex); + QVirtualKeyboardInputContext *&instance = instances[qmlEngine]; + if (instance == nullptr) + instance = new QVirtualKeyboardInputContext(qmlEngine); + return instance; +} + QT_END_NAMESPACE diff --git a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h index fd945a4f..f81c57b1 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h +++ b/src/virtualkeyboard/qvirtualkeyboardinputcontext_p.h @@ -23,6 +23,9 @@ #include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h> #include <QtVirtualKeyboard/private/shadowinputcontext_p.h> #include <QtVirtualKeyboard/qvirtualkeyboardobserver.h> +#include <QtVirtualKeyboard/private/qvirtualkeyboardnamespace_p.h> + +#include <QtCore/qpointer.h> QT_BEGIN_NAMESPACE @@ -94,6 +97,7 @@ public: Q_INVOKABLE bool hasEnterKeyAction(QObject *item) const; Q_INVOKABLE void registerInputPanel(QObject *inputPanel); Q_INVOKABLE bool contains(const QPointF &point) const; + Q_INVOKABLE QtVirtualKeyboard::KeyboardFunctionKey keyboardFunctionKey(QtVirtualKeyboard::KeyboardFunction keyboardFunction) const; Q_SIGNALS: void focusChanged(); @@ -120,6 +124,7 @@ private: void commit(); void update(Qt::InputMethodQueries queries); void invokeAction(QInputMethod::Action action, int cursorPosition); + void maybeCloseOnReturn(); bool filterEvent(const QEvent *event); void addSelectionAttribute(QList<QInputMethodEvent::Attribute> &attributes); bool testAttribute(const QList<QInputMethodEvent::Attribute> &attributes, QInputMethodEvent::AttributeType attributeType) const; @@ -128,6 +133,7 @@ private: inline void clearState(const State &state) { stateFlags &= ~StateFlags(state); } inline bool testState(const State &state) const { return stateFlags.testFlag(state); } inline bool isEmptyState() const { return !stateFlags; } + void updateSelectionControlVisible(bool inputPanelVisible); private: QVirtualKeyboardInputContext *q_ptr; @@ -190,6 +196,23 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QVirtualKeyboardInputContextPrivate::StateFlags) +/*! + TODO: Remove this type and move the registration back into QVirtualKeyboardInputContext when + QML stops creating separate singleton instances for each version. + */ +struct QVirtualKeyboardInputContextForeign +{ + Q_GADGET + QML_FOREIGN(QVirtualKeyboardInputContext) + QML_NAMED_ELEMENT(InputContext) + QML_SINGLETON + QML_ADDED_IN_VERSION(1, 0) + QML_EXTRA_VERSION(2, 0) + +public: + static QVirtualKeyboardInputContext *create(QQmlEngine *qmlEngine, QJSEngine *); +}; + QT_END_NAMESPACE Q_DECLARE_METATYPE(QVirtualKeyboardInputContextPrivate::State) diff --git a/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp b/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp index 4d449328..59ddb6b1 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp +++ b/src/virtualkeyboard/qvirtualkeyboardinputengine.cpp @@ -453,7 +453,7 @@ QList<int> QVirtualKeyboardInputEngine::patternRecognitionModes() const if (patterRecognitionModeList.isEmpty()) return resultList; resultList.reserve(patterRecognitionModeList.size()); - for (const PatternRecognitionMode &patternRecognitionMode : qAsConst(patterRecognitionModeList)) + for (const PatternRecognitionMode &patternRecognitionMode : std::as_const(patterRecognitionModeList)) resultList.append(static_cast<int>(patternRecognitionMode)); return resultList; } @@ -660,7 +660,7 @@ void QVirtualKeyboardInputEngine::updateSelectionListModels() } // Deallocate inactive selection lists - for (const QVirtualKeyboardSelectionListModel::Type &selectionListType : qAsConst(inactiveSelectionLists)) { + for (const QVirtualKeyboardSelectionListModel::Type &selectionListType : std::as_const(inactiveSelectionLists)) { const auto it = d->selectionListModels.constFind(selectionListType); if (it != d->selectionListModels.cend()) { it.value()->setDataSource(nullptr, selectionListType); diff --git a/src/virtualkeyboard/qvirtualkeyboardinputengine.h b/src/virtualkeyboard/qvirtualkeyboardinputengine.h index 34d84ac7..4e1f9481 100644 --- a/src/virtualkeyboard/qvirtualkeyboardinputengine.h +++ b/src/virtualkeyboard/qvirtualkeyboardinputengine.h @@ -4,8 +4,8 @@ #ifndef QVIRTUALKEYBOARDINPUTENGINE_H #define QVIRTUALKEYBOARDINPUTENGINE_H -#include <QObject> -#include <QPointer> +#include <QtCore/QObject> +#include <QtCore/QPointer> #include <QtQml/qqml.h> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> diff --git a/src/virtualkeyboard/qvirtualkeyboardnamespace_p.h b/src/virtualkeyboard/qvirtualkeyboardnamespace_p.h new file mode 100644 index 00000000..60587a50 --- /dev/null +++ b/src/virtualkeyboard/qvirtualkeyboardnamespace_p.h @@ -0,0 +1,70 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef QVIRTUALKEYBOARDNAMESPACE_P_H +#define QVIRTUALKEYBOARDNAMESPACE_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 <QtCore/qmetaobject.h> +#include <QtQml/qqml.h> +#include <QtVirtualKeyboard/qvirtualkeyboard_global.h> + +QT_BEGIN_NAMESPACE + +namespace QtVirtualKeyboard { + +Q_VIRTUALKEYBOARD_EXPORT Q_NAMESPACE +QML_NAMED_ELEMENT(QtVirtualKeyboard) +QML_ADDED_IN_VERSION(6, 4) + +enum class KeyType { + BaseKey, + BackspaceKey, + ChangeLanguageKey, + EnterKey, + FillerKey, + HandwritingModeKey, + HideKeyboardKey, + InputModeKey, + Key, + ModeKey, + NumberKey, + ShiftKey, + SpaceKey, + SymbolModeKey, + FlickKey, +}; +Q_ENUM_NS(KeyType) + +enum class KeyboardFunction { + HideInputPanel, + ChangeLanguage, + ToggleHandwritingMode, +}; +Q_ENUM_NS(KeyboardFunction) + +enum class KeyboardFunctionKey : quint32 { + None = 0, + Hide = 0x1, + Language = 0x2, + All = 0xffffffff, +}; +Q_DECLARE_FLAGS(KeyboardFunctionKeys, KeyboardFunctionKey) +Q_DECLARE_OPERATORS_FOR_FLAGS(KeyboardFunctionKeys) +Q_FLAG_NS(KeyboardFunctionKeys) + +} // namespace QtVirtualKeyboard + +QT_END_NAMESPACE + +#endif // QVIRTUALKEYBOARDNAMESPACE_P_H diff --git a/src/virtualkeyboard/qvirtualkeyboardobserver.h b/src/virtualkeyboard/qvirtualkeyboardobserver.h index 3ab0012d..7609a521 100644 --- a/src/virtualkeyboard/qvirtualkeyboardobserver.h +++ b/src/virtualkeyboard/qvirtualkeyboardobserver.h @@ -4,8 +4,8 @@ #ifndef QVIRTUALKEYBOARDOBSERVER_H #define QVIRTUALKEYBOARDOBSERVER_H -#include <QObject> -#include <QVariant> +#include <QtCore/QObject> +#include <QtCore/QVariant> #include <QtQml/qqml.h> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> diff --git a/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.cpp b/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.cpp index 0ccffe34..9cece734 100644 --- a/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.cpp +++ b/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.cpp @@ -296,7 +296,7 @@ void QVirtualKeyboardSelectionListModel::selectionListChanged(QVirtualKeyboardSe if (static_cast<QVirtualKeyboardSelectionListModel::Type>(type) == QVirtualKeyboardSelectionListModel::Type::WordCandidateList) d->wclAutoCommitWord = ((oldCount > 1 || (oldCount == 1 && d->wclAutoCommitWord)) && newCount == 1 && Settings::instance()->wclAutoCommitWord() && - dataAt(0).toString().length() > 1); + dataAt(0).toString().size() > 1); if (d->rowCount != oldCount) emit countChanged(); } diff --git a/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.h b/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.h index e613637f..06fab1f6 100644 --- a/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.h +++ b/src/virtualkeyboard/qvirtualkeyboardselectionlistmodel.h @@ -4,7 +4,7 @@ #ifndef QVIRTUALKEYBOARDSELECTIONLISTMODEL_H #define QVIRTUALKEYBOARDSELECTIONLISTMODEL_H -#include <QAbstractListModel> +#include <QtCore/QAbstractListModel> #include <QtQml/qqml.h> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> diff --git a/src/virtualkeyboard/qvirtualkeyboardtrace.h b/src/virtualkeyboard/qvirtualkeyboardtrace.h index 3108c55b..84161f4d 100644 --- a/src/virtualkeyboard/qvirtualkeyboardtrace.h +++ b/src/virtualkeyboard/qvirtualkeyboardtrace.h @@ -4,9 +4,9 @@ #ifndef QVIRTUALKEYBOARDTRACE_H #define QVIRTUALKEYBOARDTRACE_H -#include <QObject> -#include <QVariant> -#include <QPointF> +#include <QtCore/QObject> +#include <QtCore/QVariant> +#include <QtCore/QPointF> #include <QtQml/qqml.h> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> diff --git a/src/virtualkeyboard/settings.cpp b/src/virtualkeyboard/settings.cpp index 2d7015c0..15d66bbc 100644 --- a/src/virtualkeyboard/settings.cpp +++ b/src/virtualkeyboard/settings.cpp @@ -33,7 +33,9 @@ public: hwrTimeoutForCjk(500), handwritingModeDisabled(false), defaultInputMethodDisabled(false), - defaultDictionaryDisabled(false) + defaultDictionaryDisabled(false), + visibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKey::All), + closeOnReturn(false) { ensureUserDataPathExists(); } @@ -64,6 +66,8 @@ public: bool handwritingModeDisabled; bool defaultInputMethodDisabled; bool defaultDictionaryDisabled; + QtVirtualKeyboard::KeyboardFunctionKeys visibleFunctionKeys; + bool closeOnReturn; }; static QScopedPointer<Settings> s_settingsInstance; @@ -341,5 +345,35 @@ void QtVirtualKeyboard::Settings::setDefaultDictionaryDisabled(bool defaultDicti } } +QtVirtualKeyboard::KeyboardFunctionKeys Settings::visibleFunctionKeys() const +{ + Q_D(const Settings); + return d->visibleFunctionKeys; +} + +void Settings::setVisibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKeys newVisibleFunctionKeys) +{ + Q_D(Settings); + if (d->visibleFunctionKeys != newVisibleFunctionKeys) { + d->visibleFunctionKeys = newVisibleFunctionKeys; + emit visibleFunctionKeysChanged(); + } +} + +bool Settings::closeOnReturn() const +{ + Q_D(const Settings); + return d->closeOnReturn; +} + +void Settings::setCloseOnReturn(bool enabled) +{ + Q_D(Settings); + if (d->closeOnReturn != enabled) { + d->closeOnReturn = enabled; + emit closeOnReturnChanged(); + } +} + } // namespace QtVirtualKeyboard QT_END_NAMESPACE diff --git a/src/virtualkeyboard/settings_p.h b/src/virtualkeyboard/settings_p.h index 0fb12014..4efd757f 100644 --- a/src/virtualkeyboard/settings_p.h +++ b/src/virtualkeyboard/settings_p.h @@ -15,6 +15,7 @@ // We mean it. // +#include "qvirtualkeyboardnamespace_p.h" #include <QObject> #include <QUrl> #include <QtVirtualKeyboard/qvirtualkeyboard_global.h> @@ -87,6 +88,12 @@ public: bool isDefaultDictionaryDisabled() const; void setDefaultDictionaryDisabled(bool defaultDictionaryDisabled); + QtVirtualKeyboard::KeyboardFunctionKeys visibleFunctionKeys() const; + void setVisibleFunctionKeys(QtVirtualKeyboard::KeyboardFunctionKeys newVisibleFunctionKeys); + + bool closeOnReturn() const; + void setCloseOnReturn(bool enable); + signals: void styleChanged(); void styleNameChanged(); @@ -106,6 +113,8 @@ signals: void handwritingModeDisabledChanged(); void defaultInputMethodDisabledChanged(); void defaultDictionaryDisabledChanged(); + void visibleFunctionKeysChanged(); + void closeOnReturnChanged(); }; } // namespace QtVirtualKeyboard diff --git a/src/virtualkeyboard/shadowinputcontext.cpp b/src/virtualkeyboard/shadowinputcontext.cpp index 78138eab..c7a5387c 100644 --- a/src/virtualkeyboard/shadowinputcontext.cpp +++ b/src/virtualkeyboard/shadowinputcontext.cpp @@ -106,6 +106,8 @@ void ShadowInputContext::setSelectionOnFocusObject(const QPointF &anchorPos, con if (success) { int cursor = queryFocusObject(Qt::ImCursorPosition, quickItem ? quickItem->mapFromScene(cursorPos) : cursorPos).toInt(&success); if (success) { + if (anchor == cursor && anchorPos != cursorPos) + return; QList<QInputMethodEvent::Attribute> imAttributes; imAttributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, anchor, cursor - anchor, QVariant())); QInputMethodEvent event(QString(), imAttributes); @@ -176,22 +178,28 @@ void ShadowInputContext::update(Qt::InputMethodQueries queries) const int newCursorPosition = d->inputContext->cursorPosition(); const int newAnchorPosition = d->inputContext->anchorPosition(); + const QString newPreeditText = d->inputContext->preeditText(); + const QList<QInputMethodEvent::Attribute> newPreeditAttributes = d->inputContext->preeditTextAttributes(); + bool updateSurroundingText = newSurroundingText != surroundingText; bool updateSelection = newCursorPosition != cursorPosition || newAnchorPosition != anchorPosition; + if (updateSurroundingText) { + QInputMethodEvent inputEvent; + inputEvent.setCommitString(newSurroundingText, -cursorPosition, surroundingText.size()); + QGuiApplication::sendEvent(d->inputItem, &inputEvent); + } + if (updateSurroundingText || updateSelection) { QList<QInputMethodEvent::Attribute> attributes; attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, newAnchorPosition, newCursorPosition - newAnchorPosition, QVariant())); QInputMethodEvent inputEvent(QString(), attributes); - if (updateSurroundingText) - inputEvent.setCommitString(newSurroundingText, -cursorPosition, surroundingText.length()); QGuiApplication::sendEvent(d->inputItem, &inputEvent); } - const QString newPreeditText = d->inputContext->preeditText(); - const QList<QInputMethodEvent::Attribute> newPreeditAttributes = d->inputContext->preeditTextAttributes(); - if (d->preeditText != newPreeditText || d->preeditTextAttributes != newPreeditAttributes) { + const bool forcePreeditText = !newPreeditText.isEmpty() && (updateSurroundingText || updateSelection); + if (forcePreeditText || d->preeditText != newPreeditText || d->preeditTextAttributes != newPreeditAttributes) { d->preeditText = newPreeditText; d->preeditTextAttributes = newPreeditAttributes; QInputMethodEvent inputEvent(d->preeditText, d->preeditTextAttributes); diff --git a/src/virtualkeyboard/shadowinputcontext_p.h b/src/virtualkeyboard/shadowinputcontext_p.h index 6b014c64..aa07ddb6 100644 --- a/src/virtualkeyboard/shadowinputcontext_p.h +++ b/src/virtualkeyboard/shadowinputcontext_p.h @@ -45,6 +45,7 @@ class Q_VIRTUALKEYBOARD_EXPORT ShadowInputContext : public QObject Q_PROPERTY(bool selectionControlVisible READ selectionControlVisible NOTIFY selectionControlVisibleChanged) QML_NAMED_ELEMENT(ShadowInputContext) QML_UNCREATABLE("ShadowInputContext is only available via InputContext.priv.shadow") + QML_ADDED_IN_VERSION(2, 0) explicit ShadowInputContext(QObject *parent = nullptr); diff --git a/src/virtualkeyboard/shifthandler.cpp b/src/virtualkeyboard/shifthandler.cpp index 13e44c31..559f9752 100644 --- a/src/virtualkeyboard/shifthandler.cpp +++ b/src/virtualkeyboard/shifthandler.cpp @@ -281,7 +281,7 @@ void ShiftHandler::autoCapitalize() } else { // space after sentence-ending character triggers auto-capitalization QString text = d->inputContext->surroundingText(); text.truncate(cursorPosition); - if (text.trimmed().length() == 0) + if (text.trimmed().size() == 0) setShiftActive(!preferLowerCase); else if (text.endsWith(QLatin1Char(' '))) setShiftActive(d->sentenceEndingCharacters.contains(QStringView{text}.right(2)[0]) diff --git a/src/virtualkeyboard/unipentrace.cpp b/src/virtualkeyboard/unipentrace.cpp index 7b88e5b7..123ffcbd 100644 --- a/src/virtualkeyboard/unipentrace.cpp +++ b/src/virtualkeyboard/unipentrace.cpp @@ -39,7 +39,7 @@ UnipenTrace::UnipenTrace(const QVariantMap &traceCaptureDeviceInfo, void UnipenTrace::record(const QList<QVirtualKeyboardTrace *> &traceList) { qlonglong t0 = 0; - for (const QVirtualKeyboardTrace *trace : qAsConst(traceList)) { + for (const QVirtualKeyboardTrace *trace : std::as_const(traceList)) { const QVariantList &points = trace->points(); const bool hasTime = trace->channels().contains(QLatin1String("t")); const QVariantList timeData = hasTime ? trace->channelData(QLatin1String("t")) : QVariantList(); diff --git a/src/virtualkeyboard/virtualkeyboard.cpp b/src/virtualkeyboard/virtualkeyboard.cpp index 8d46ef88..6b2fa50d 100644 --- a/src/virtualkeyboard/virtualkeyboard.cpp +++ b/src/virtualkeyboard/virtualkeyboard.cpp @@ -24,7 +24,7 @@ namespace QtVirtualKeyboard { For example: \code TextInput { - VirtualKeyboard.dictionaries: ["myDictionary"] + VirtualKeyboard.extraDictionaries: ["myDictionary"] } \endcode */ @@ -43,7 +43,7 @@ VirtualKeyboardAttachedType *VirtualKeyboard::qmlAttachedProperties(QObject *obj } /*! - \qmlattachedproperty list VirtualKeyboard::dictionaries + \qmlattachedproperty list VirtualKeyboard::extraDictionaries Sets active user dictionaries in this context. */ diff --git a/src/virtualkeyboard/virtualkeyboard_p.h b/src/virtualkeyboard/virtualkeyboard_p.h index ca1f197b..f00cbfdc 100644 --- a/src/virtualkeyboard/virtualkeyboard_p.h +++ b/src/virtualkeyboard/virtualkeyboard_p.h @@ -27,6 +27,8 @@ class VirtualKeyboardAttachedType; class Q_VIRTUALKEYBOARD_EXPORT VirtualKeyboard : public QObject { Q_OBJECT + QML_NAMED_ELEMENT(VirtualKeyboard) + QML_UNCREATABLE("VirtualKeyboard is an abstract type that is only available as an attached property.") QML_ATTACHED(VirtualKeyboardAttachedType) QML_ADDED_IN_VERSION(6, 1) diff --git a/sync.profile b/sync.profile deleted file mode 100644 index 7dd2647c..00000000 --- a/sync.profile +++ /dev/null @@ -1,6 +0,0 @@ -%modules = ( # path to module name map - "QtVirtualKeyboard" => "$basedir/src/virtualkeyboard", - "QtHunspellInputMethod" => "$basedir/src/plugins/hunspell/module", -); -%moduleheaders = ( # restrict the module headers to those found in relative path -); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 22141371..800bc265 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from tests.pro. if(QT_BUILD_STANDALONE_TESTS) diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 72db30d9..1c0b3c51 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from auto.pro. if(NOT ANDROID) # QTBUG-102756 @@ -7,5 +10,6 @@ add_subdirectory(inputpanelcontrols) add_subdirectory(styles) add_subdirectory(layoutfilesystem) add_subdirectory(layoutresources) -# add_subdirectory(cmake) # special case add_subdirectory(dictionarymanager) +add_subdirectory(shadowinput) +add_subdirectory(virtualkeyboardattached) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt deleted file mode 100644 index 16812e61..00000000 --- a/tests/auto/cmake/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(qmake_cmake_files) - -enable_testing() - -find_package(Qt5Core REQUIRED) - -include("${_Qt5CTestMacros}") - -test_module_includes( -) diff --git a/tests/auto/dictionarymanager/CMakeLists.txt b/tests/auto/dictionarymanager/CMakeLists.txt index 9b97f861..f0e7857e 100644 --- a/tests/auto/dictionarymanager/CMakeLists.txt +++ b/tests/auto/dictionarymanager/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from dictionarymanager.pro. ##################################################################### @@ -7,7 +10,7 @@ qt_internal_add_test(tst_dictionarymanager SOURCES tst_dictionarymanager.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Qml Qt::Quick @@ -18,7 +21,7 @@ qt_internal_add_test(tst_dictionarymanager ##################################################################### qt_internal_extend_target(tst_dictionarymanager CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/auto/dictionarymanager/tst_dictionarymanager.cpp b/tests/auto/dictionarymanager/tst_dictionarymanager.cpp index 538b2bfb..8c7c4c06 100644 --- a/tests/auto/dictionarymanager/tst_dictionarymanager.cpp +++ b/tests/auto/dictionarymanager/tst_dictionarymanager.cpp @@ -29,7 +29,7 @@ void tst_dictionarymanager::testCreateDictionary() QVERIFY(dictionarySpy.isValid()); QStringList wordList = QStringList() << "myword"; dictionary->setContents(wordList); - QCOMPARE(dictionarySpy.count(), 1); + QCOMPARE(dictionarySpy.size(), 1); QVERIFY(dictionaryManager->availableDictionaries().contains("custom")); } diff --git a/tests/auto/inputpanel/BLACKLIST b/tests/auto/inputpanel/BLACKLIST index f4e054c5..ac88f44e 100644 --- a/tests/auto/inputpanel/BLACKLIST +++ b/tests/auto/inputpanel/BLACKLIST @@ -1,17 +1 @@ # See qtbase/src/testlib/qtestblacklist.cpp for format - -# QTBUG-97830 -[tst_plugin::test_fullScreenModeSelectionHandles:row 0] -* -[tst_plugin::test_fullScreenModeSelectionHandles:row 2] -* -[tst_plugin::test_fullScreenModeSelectionHandles:row 3] -* - -# QTBUG-97830 -[tst_plugin::test_selection:row 0] -* - -# QTBUG-97901 -[tst_plugin::test_hangulInputMethod:row 24] -* diff --git a/tests/auto/inputpanel/CMakeLists.txt b/tests/auto/inputpanel/CMakeLists.txt index 086ee5bd..2dd636ed 100644 --- a/tests/auto/inputpanel/CMakeLists.txt +++ b/tests/auto/inputpanel/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from inputpanel.pro. ##################################################################### @@ -14,7 +17,7 @@ qt_internal_add_test(tst_inputpanel QMLTEST SOURCES tst_inputpanel.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui TESTDATA ${test_data} ) @@ -27,7 +30,7 @@ qt_internal_add_test(tst_inputpanel ##################################################################### qt_internal_extend_target(tst_inputpanel CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml index f5230ea6..5204c5b7 100644 --- a/tests/auto/inputpanel/data/inputpanel/inputpanel.qml +++ b/tests/auto/inputpanel/data/inputpanel/inputpanel.qml @@ -29,25 +29,20 @@ InputPanel { readonly property var activeLocales: VirtualKeyboardSettings.activeLocales readonly property int inputMode: InputContext.inputEngine.inputMode readonly property var inputMethod: InputContext.inputEngine.inputMethod - readonly property var keyboard: Utils.findChildByProperty(inputPanel, "objectName", "keyboard", null) readonly property bool handwritingMode: keyboard.handwritingMode - readonly property var keyboardLayoutLoader: Utils.findChildByProperty(keyboard, "objectName", "keyboardLayoutLoader", null) - readonly property var keyboardInputArea: Utils.findChildByProperty(keyboard, "objectName", "keyboardInputArea", null) - readonly property var characterPreviewBubble: Utils.findChildByProperty(keyboard, "objectName", "characterPreviewBubble", null) - readonly property var alternativeKeys: Utils.findChildByProperty(keyboard, "objectName", "alternativeKeys", null) - readonly property var naviationHighlight: Utils.findChildByProperty(keyboard, "objectName", "naviationHighlight", null) - readonly property bool naviationHighlightAnimating: naviationHighlight.xAnimation.running || - naviationHighlight.yAnimation.running || - naviationHighlight.widthAnimation.running || - naviationHighlight.heightAnimation.running - readonly property var wordCandidateView: Utils.findChildByProperty(keyboard, "objectName", "wordCandidateView", null) - readonly property var wordCandidateContextMenu: Utils.findChildByProperty(keyboard, "objectName", "wordCandidateContextMenu", null) - readonly property var shadowInputControl: Utils.findChildByProperty(keyboard, "objectName", "shadowInputControl", null) - readonly property var shadowInput: Utils.findChildByProperty(keyboard, "objectName", "shadowInput", null) - readonly property var selectionControl: Utils.findChildByProperty(inputPanel, "objectName", "selectionControl", null) + readonly property Loader keyboardLayoutLoader: keyboard.keyboardLayoutLoader + readonly property MultiPointTouchArea keyboardInputArea: keyboard.keyboardInputArea + readonly property CharacterPreviewBubble characterPreviewBubble: keyboard.characterPreview + readonly property AlternativeKeys alternativeKeys: keyboard.alternativeKeys + readonly property Loader naviationHighlight: keyboard.naviationHighlight + readonly property ListView wordCandidateView: keyboard.wordCandidateView + readonly property Item wordCandidateContextMenu: keyboard.wordCandidateContextMenu + readonly property ShadowInputControl shadowInputControl: keyboard.shadowInputControl + readonly property TextInput shadowInput: keyboard.shadowInputControl.textEdit + readonly property SelectionControl selectionControl: Utils.findChildByProperty(inputPanel, "objectName", "selectionControl", null) readonly property var anchorHandle: selectionControl.children[0] readonly property var cursorHandle: selectionControl.children[1] - readonly property var fullScreenModeSelectionControl: Utils.findChildByProperty(inputPanel, "objectName", "fullScreenModeSelectionControl", null) + readonly property SelectionControl fullScreenModeSelectionControl: keyboard.fullScreenModeSelectionControl readonly property var fullScreenModeAnchorHandle: fullScreenModeSelectionControl.children[0] readonly property var fullScreenModeCursorHandle: fullScreenModeSelectionControl.children[1] readonly property bool wordCandidateListVisibleHint: InputContext.inputEngine.wordCandidateListVisibleHint @@ -66,6 +61,7 @@ InputPanel { property alias wordCandidateListItemSelectedSpy: wordCandidateListItemSelectedSpy property alias inputMethodSelectionListChangedSpy: inputMethodSelectionListChangedSpy property alias wordCandidateListVisibleSpy: wordCandidateListVisibleSpy + property alias wordCandidateListCurrentIndexSpy: wordCandidateListCurrentIndexSpy property alias shiftStateSpy: shiftStateSpy property alias shadowInputControlVisibleSpy: shadowInputControlVisibleSpy property alias externalLanguageSwitchSpy: externalLanguageSwitchSpy @@ -172,6 +168,12 @@ InputPanel { } SignalSpy { + id: wordCandidateListCurrentIndexSpy + target: wordCandidateView + signalName: "onCurrentIndexChanged" + } + + SignalSpy { id: wordCandidateContextMenuActiveSpy target: wordCandidateContextMenu signalName: "onActiveChanged" @@ -195,26 +197,18 @@ InputPanel { signalName: "onExternalLanguageSwitch" } - function findChildByProperty(parent, propertyName, propertyValue, compareCb) { - var obj = null - if (parent === null) - return null - var children = parent.children - for (var i = 0; i < children.length; i++) { - obj = children[i] - if (obj.hasOwnProperty(propertyName)) { - if (compareCb !== null) { - if (compareCb(obj[propertyName], propertyValue)) - break - } else if (obj[propertyName] === propertyValue) { - break - } - } - obj = findChildByProperty(obj, propertyName, propertyValue, compareCb) - if (obj) - break - } - return obj + // Disable all animations during tests + Binding { + target: keyboard + property: "noAnimations" + value: true + } + + // Reduce press and hold delay to avoid unnecessary wait during tests + Binding { + target: keyboard + property: "pressAndHoldDelay" + value: 50 } function isLocaleSupported(inputLocale) { @@ -235,11 +229,11 @@ InputPanel { function mapKeyboardFunction(keyboardFunctionName) { if (keyboardFunctionName === "HideInputPanel") - return QtVirtualKeyboard.HideInputPanel + return QtVirtualKeyboard.KeyboardFunction.HideInputPanel if (keyboardFunctionName === "ChangeLanguage") - return QtVirtualKeyboard.ChangeLanguage + return QtVirtualKeyboard.KeyboardFunction.ChangeLanguage if (keyboardFunctionName === "ToggleHandwritingMode") - return QtVirtualKeyboard.ToggleHandwritingMode + return QtVirtualKeyboard.KeyboardFunction.ToggleHandwritingMode return -1 } @@ -249,6 +243,26 @@ InputPanel { keyboard.doKeyboardFunction(keyboardFunction) } + function mapKeyboardFunctionKey(functionKeyName) { + if (functionKeyName === "None") + return QtVirtualKeyboard.KeyboardFunctionKeys.None + if (functionKeyName === "Hide") + return QtVirtualKeyboard.KeyboardFunctionKeys.Hide + if (functionKeyName === "Language") + return QtVirtualKeyboard.KeyboardFunctionKeys.Language + if (functionKeyName === "All") + return QtVirtualKeyboard.KeyboardFunctionKeys.All + testcase.fail("Invalid function key '%1'".arg(functionKeyName)) + } + + function setVisibleFunctionKeys(functionKeyNames) { + let functionKeys = QtVirtualKeyboard.KeyboardFunctionKeys.None + for (const functionKeyName of functionKeyNames) { + functionKeys |= mapKeyboardFunctionKey(functionKeyName) + } + VirtualKeyboardSettings.visibleFunctionKeys = functionKeys + } + function setWclAutoHideDelay(wclAutoHideDelay) { VirtualKeyboardSettings.wordCandidateList.autoHideDelay = wclAutoHideDelay } @@ -359,42 +373,6 @@ InputPanel { testcase.verify(SelectionListModel.Role.Dictionary !== undefined) testcase.verify(SelectionListModel.DictionaryType.Default !== undefined) testcase.verify(SelectionListModel.DictionaryType.User !== undefined) - // Unscoped - testcase.verify(InputEngine.Lower !== undefined) - testcase.verify(InputEngine.Upper !== undefined) - testcase.verify(InputEngine.Latin !== undefined) - testcase.verify(InputEngine.Numeric !== undefined) - testcase.verify(InputEngine.Dialable !== undefined) - testcase.verify(InputEngine.Pinyin !== undefined) - testcase.verify(InputEngine.Cangjie !== undefined) - testcase.verify(InputEngine.Zhuyin !== undefined) - testcase.verify(InputEngine.Hangul !== undefined) - testcase.verify(InputEngine.Hiragana !== undefined) - testcase.verify(InputEngine.Katakana !== undefined) - testcase.verify(InputEngine.FullwidthLatin !== undefined) - testcase.verify(InputEngine.Greek !== undefined) - testcase.verify(InputEngine.Cyrillic !== undefined) - testcase.verify(InputEngine.Arabic !== undefined) - testcase.verify(InputEngine.Hebrew !== undefined) - testcase.verify(InputEngine.ChineseHandwriting !== undefined) - testcase.verify(InputEngine.JapaneseHandwriting !== undefined) - testcase.verify(InputEngine.KoreanHandwriting !== undefined) - testcase.verify(InputEngine.Thai !== undefined) - testcase.verify(InputEngine.Stroke !== undefined) - testcase.verify(InputEngine.Romaji !== undefined) - testcase.verify(InputEngine.None !== undefined) - testcase.verify(InputEngine.PatternRecognitionDisabled !== undefined) - testcase.verify(InputEngine.Handwriting !== undefined) - testcase.verify(InputEngine.HandwritingRecoginition !== undefined) - testcase.verify(InputEngine.WordBeforeCursor !== undefined) - testcase.verify(InputEngine.WordAfterCursor !== undefined) - testcase.verify(InputEngine.WordAtCursor !== undefined) - testcase.verify(SelectionListModel.WordCandidateList !== undefined) - testcase.verify(SelectionListModel.DisplayRole !== undefined) - testcase.verify(SelectionListModel.WordCompletionLengthRole !== undefined) - testcase.verify(SelectionListModel.DictionaryType !== undefined) - testcase.verify(SelectionListModel.Default !== undefined) - testcase.verify(SelectionListModel.User !== undefined) } function setExternalLanguageSwitchEnabled(enabled) { @@ -430,6 +408,19 @@ InputPanel { return Utils.findChildByProperty(keyboard, "objectName", objectName, null) } + function mapKeyboardKeyType(keyTypeName) { + if (keyTypeName === "ChangeLanguageKey") + return QtVirtualKeyboard.KeyType.ChangeLanguageKey + if (keyTypeName === "HideKeyboardKey") + return QtVirtualKeyboard.KeyType.HideKeyboardKey + testcase.fail("Invalid key type '%1'".arg(keyTypeName)) + } + + function findKeyByKeyType(keyTypeName) { + const keyType = mapKeyboardKeyType(keyTypeName) + return Utils.findChildByProperty(keyboard, "keyType", keyType, null) + } + function virtualKeyPressOnCurrentLayout(key) { var keyObj = typeof key == "object" && key.hasOwnProperty("key") ? key : findVirtualKey(key) var alternativeKey = false @@ -442,14 +433,14 @@ InputPanel { if (keyObj) { virtualKeyPressPoint = inputPanel.mapFromItem(keyObj, keyObj.width / 2, keyObj.height / 2) testcase.mousePress(inputPanel, virtualKeyPressPoint.x, virtualKeyPressPoint.y) - testcase.wait(20) + testcase.wait(1) if (alternativeKey) { alternativeKeysSpy.wait() var keyIndex = keyObj.effectiveAlternativeKeys.indexOf(key.toLowerCase()) var itemX = keyIndex * keyboard.style.alternateKeysListItemWidth + keyboard.style.alternateKeysListItemWidth / 2 virtualKeyPressPoint.x = inputPanel.mapFromItem(alternativeKeys.listView, itemX, 0).x testcase.mouseMove(inputPanel, virtualKeyPressPoint.x, virtualKeyPressPoint.y) - testcase.waitForRendering(inputPanel) + testcase.wait(1) } return true } @@ -536,7 +527,6 @@ InputPanel { function virtualKeyClick(key) { if (virtualKeyPress(key)) { virtualKeyRelease() - testcase.waitForRendering(inputPanel) return true } return false @@ -544,13 +534,7 @@ InputPanel { function emulateNavigationKeyClick(navigationKey) { testcase.keyClick(navigationKey) - while (inputPanel.naviationHighlightAnimating) - testcase.wait(inputPanel.naviationHighlight.moveDuration / 2) - } - - function navigationHighlightContains(point) { - var navigationPoint = inputPanel.mapToItem(inputPanel.naviationHighlight, point.x, point.y) - return inputPanel.naviationHighlight.contains(Qt.point(navigationPoint.x, navigationPoint.y)) + testcase.wait(50) } function navigateToKeyOnPoint(point) { @@ -558,7 +542,7 @@ InputPanel { if (inputPanel.naviationHighlight.visible) { while (true) { var navigationPoint = inputPanel.mapToItem(inputPanel.naviationHighlight, point.x, point.y) - if (navigationHighlightContains(point)) + if (inputPanel.naviationHighlight.contains(Qt.point(navigationPoint.x, navigationPoint.y))) return true if (inputPanel.naviationHighlight.y > point.y) emulateNavigationKeyClick(Qt.Key_Up) @@ -618,12 +602,9 @@ InputPanel { function activateNavigationKeyMode() { if (!inputPanel.naviationHighlight.visible) { - inputPanel.naviationHighlight.moveDuration = 0 - inputPanel.naviationHighlight.resizeDuration = 0 emulateNavigationKeyClick(Qt.Key_Right) if (inputPanel.naviationHighlight.visible) { - while (inputPanel.naviationHighlightAnimating) - testcase.wait(inputPanel.naviationHighlight.moveDuration / 2) + testcase.wait(1) } } return inputPanel.naviationHighlight.visible @@ -680,7 +661,6 @@ InputPanel { inputPanel.wordCandidateView.decrementCurrentIndex() } } - testcase.waitForRendering(inputPanel) } return suggestionFound } @@ -688,7 +668,6 @@ InputPanel { function selectionListSelectCurrentItem() { if (!inputPanel.wordCandidateView.currentItem) return false - testcase.wait(200) testcase.verify(inputPanel.wordCandidateView.currentItem, "Expected wordCandidateView to have a currentItem, but it's null." + " Its property values at the time of failure are:" @@ -704,7 +683,6 @@ InputPanel { inputPanel.wordCandidateView.currentItem.width / 2, inputPanel.wordCandidateView.currentItem.height / 2) testcase.mouseClick(inputPanel, itemPos.x, itemPos.y, Qt.LeftButton, 0, 20) - testcase.waitForRendering(inputPanel) return true } @@ -738,7 +716,6 @@ InputPanel { var wordCandidateContextMenuList = Utils.findChildByProperty(keyboard, "objectName", "wordCandidateContextMenuList", null) if (wordCandidateContextMenuList.currentIndex !== index) { wordCandidateContextMenuList.currentIndex = index - testcase.waitForRendering(inputPanel) } if (!wordCandidateContextMenuList.currentItem) return false @@ -746,10 +723,13 @@ InputPanel { wordCandidateContextMenuList.currentItem.width / 2, wordCandidateContextMenuList.currentItem.height / 2) testcase.mouseClick(inputPanel, itemPos.x, itemPos.y, Qt.LeftButton, 0, 20) - testcase.waitForRendering(inputPanel) return true } + function isHandwritingFeatureAvailable() { + return VirtualKeyboardFeatures.Handwriting + } + function setHandwritingMode(enabled) { if (inputPanel.keyboard.handwritingMode !== enabled) { if (!enabled || inputPanel.keyboard.isHandwritingAvailable()) @@ -781,4 +761,12 @@ InputPanel { return false return inputMethod != null && inputMethod.hasOwnProperty("superimposed") && inputMethod.superimposed } + + function closeOnReturn() { + return VirtualKeyboardSettings.closeOnReturn + } + + function setCloseOnReturn(enabled) { + VirtualKeyboardSettings.closeOnReturn = enabled + } } diff --git a/tests/auto/inputpanel/data/inputpanel/utils.js b/tests/auto/inputpanel/data/inputpanel/utils.js index 4167bb2d..1f1a6299 100644 --- a/tests/auto/inputpanel/data/inputpanel/utils.js +++ b/tests/auto/inputpanel/data/inputpanel/utils.js @@ -8,8 +8,7 @@ function findChildByProperty(parent, propertyName, propertyValue, compareCb) { if (parent === null) return null var children = parent.children - for (var i = 0; i < children.length; i++) { - obj = children[i] + for (obj of children) { if (obj.hasOwnProperty(propertyName)) { if (compareCb !== null) { if (compareCb(obj[propertyName], propertyValue)) @@ -30,8 +29,7 @@ function findChild(parent, param, matchCb) { if (parent === null) return null var children = parent.children - for (var i = 0; i < children.length; i++) { - obj = children[i] + for (obj of children) { if (matchCb(obj, param)) break obj = findChild(obj, param, matchCb) diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml index 0c4e4695..026ed751 100644 --- a/tests/auto/inputpanel/data/tst_inputpanel.qml +++ b/tests/auto/inputpanel/data/tst_inputpanel.qml @@ -4,6 +4,7 @@ import QtTest import QtQuick import QtQuick.Window +import QtQuick.Controls import "inputpanel/utils.js" as Utils Rectangle { @@ -22,6 +23,14 @@ Rectangle { } } + Component { + id: textFieldComp + TextField { + property int enterKeyType: Qt.EnterKeyDefault + EnterKey.type: enterKeyType + } + } + TestCase { id: testcase name: "tst_plugin" @@ -54,12 +63,21 @@ Rectangle { } function prepareTest(data, skipIfFail) { + // Skip hwr tests early if handwriting feature is not available + if (data !== undefined && data.hasOwnProperty("initHwrMode") && data.initHwrMode) { + if (!inputPanel.isHandwritingFeatureAvailable()) + skip("Handwriting feature not available") + } + inputPanel.setWclAutoHideDelay(data !== undefined && data.hasOwnProperty("wclAutoHideDelay") ? data.wclAutoHideDelay : 5000) inputPanel.setWclAlwaysVisible(data !== undefined && data.hasOwnProperty("wclAlwaysVisible") && data.wclAlwaysVisible) inputPanel.setWclAutoCommitWord(data !== undefined && data.hasOwnProperty("wclAutoCommitWord") && data.wclAutoCommitWord) inputPanel.setFullScreenMode(data !== undefined && data.hasOwnProperty("fullScreenMode") && data.fullScreenMode) inputPanel.setExternalLanguageSwitchEnabled(data !== undefined && data.hasOwnProperty("externalLanguageSwitchEnabled") && data.externalLanguageSwitchEnabled) inputPanel.setLayoutMirroring(data !== undefined && data.hasOwnProperty("layoutMirroring") && data.layoutMirroring) + inputPanel.setVisibleFunctionKeys(data !== undefined && data.hasOwnProperty("visibleFunctionKeys") ? data.visibleFunctionKeys : ["All"]) + inputPanel.setCloseOnReturn(data !== undefined && data.hasOwnProperty("closeOnReturn") && data.closeOnReturn) + var window = container.Window.window verify(window) @@ -68,7 +86,6 @@ Rectangle { tryCompare(window, "active", true) container.forceActiveFocus() - waitForRendering(container) if (data !== undefined && data.hasOwnProperty("initText")) { textInput.text = data.initText textInput.cursorPosition = data.hasOwnProperty("initCursorPosition") ? data.initCursorPosition : textInput.text.length @@ -83,7 +100,6 @@ Rectangle { handwritingInputPanel.available = false inputPanel.setHandwritingMode(false) textInput.forceActiveFocus() - waitForRendering(inputPanel) var activeLocales = data !== undefined && data.hasOwnProperty("activeLocales") ? data.activeLocales : [] inputPanel.setActiveLocales(activeLocales) var locale = data !== undefined && data.hasOwnProperty("initLocale") ? data.initLocale : "en_GB" @@ -121,65 +137,65 @@ Rectangle { function test_versionCheck_data() { return [ // Note: Add new import versions here - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 1.0; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 1.1; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 1.2; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 1.3; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 2.0; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard 2.1; \ Item {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 1.0; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 1.1; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 1.2; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 1.3; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 2.0; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Styles; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Styles 2.1; \ KeyboardStyle {}" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Settings 1.0; \ Item { property var styleName: VirtualKeyboardSettings.styleName }" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Settings 1.1; \ Item { property var styleName: VirtualKeyboardSettings.styleName }" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Settings 1.2; \ Item { property var styleName: VirtualKeyboardSettings.styleName }" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Settings 2.0; \ Item { property var styleName: VirtualKeyboardSettings.styleName; \ property var locale: VirtualKeyboardSettings.locale; \ property var availableLocales: VirtualKeyboardSettings.availableLocales; \ property var activeLocales: VirtualKeyboardSettings.activeLocales }" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.0; \ + import QtQuick.VirtualKeyboard.Settings 2.1; \ Item { property var styleName: VirtualKeyboardSettings.styleName; \ property var locale: VirtualKeyboardSettings.locale; \ property var availableLocales: VirtualKeyboardSettings.availableLocales; \ property var activeLocales: VirtualKeyboardSettings.activeLocales }" }, - { qml: "import QtQuick; \ - import QtQuick.VirtualKeyboard.Settings; \ + { qml: "import QtQuick 2.7; \ + import QtQuick.VirtualKeyboard.Settings 2.2; \ Item { property var styleName: VirtualKeyboardSettings.styleName; \ property var locale: VirtualKeyboardSettings.locale; \ property var availableLocales: VirtualKeyboardSettings.availableLocales; \ @@ -188,6 +204,20 @@ Rectangle { property var wclAlwaysVisible: VirtualKeyboardSettings.wordCandidateList.alwaysVisible; \ property var wclAutoCommitWord: VirtualKeyboardSettings.wordCandidateList.autoCommitWord; \ property var fullScreenMode: VirtualKeyboardSettings.fullScreenMode; }" }, + // without versions + { qml: "import QtQuick; \ + import QtQuick.VirtualKeyboard; \ + import QtQuick.VirtualKeyboard.Styles; \ + import QtQuick.VirtualKeyboard.Settings; \ + import QtQuick.VirtualKeyboard.Plugins; \ + Item {}" }, + // virtual keyboard 5.15 + { qml: "import QtQuick 2.7; \ + import QtQuick.VirtualKeyboard 2.3; \ + import QtQuick.VirtualKeyboard.Styles 2.1; \ + import QtQuick.VirtualKeyboard.Settings 2.2; \ + import QtQuick.VirtualKeyboard.Plugins 2.3; \ + Item {}" }, ] } @@ -373,7 +403,6 @@ Rectangle { { initLocale: "pt_BR", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "ol\u00E1", outputText: "Ol\u00E1" }, { initLocale: "pt_PT", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "ol\u00E1", outputText: "Ol\u00E1" }, { initLocale: "ru_RU", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "\u043F\u0440\u0438\u0432\u0435\u0442", outputText: "\u041F\u0440\u0438\u0432\u0435\u0442" }, - { initLocale: "ru_RU", initInputMethodHints: Qt.ImhNoPredictiveText, initInputMode: "Latin", inputSequence: "hello", outputText: "Hello" }, { initLocale: "sr_SP", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "\u0437\u0434\u0440\u0430\u0432\u043E", outputText: "\u0417\u0434\u0440\u0430\u0432\u043E" }, { initLocale: "sv_SE", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "hall\u00E5", outputText: "Hall\u00E5" }, { initLocale: "sq_AL", initInputMethodHints: Qt.ImhNoPredictiveText, inputSequence: "përshëndetje", outputText: "Përshëndetje" }, @@ -394,7 +423,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -423,7 +451,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -455,7 +482,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -501,7 +527,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -606,16 +631,13 @@ Rectangle { inputPanel.setStyle("retro") inputPanel.styleSpy.wait() - waitForRendering(inputPanel) inputPanel.setStyle("default") inputPanel.styleSpy.wait() - waitForRendering(inputPanel) compare(inputPanel.styleSpy.count, 2) inputPanel.setStyle(origStyle) - waitForRendering(inputPanel) } function test_soundEffects() { @@ -635,9 +657,9 @@ Rectangle { function test_navigationKeyInputSequence_data() { return [ - { initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: "\u00E1\u017C", outputText: "\u00E1\u017C" }, - { initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: "~123qwe", outputText: "~123qwe" }, - { initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: [ Qt.Key_Shift, Qt.Key_V, Qt.Key_K, Qt.Key_B, Qt.Key_Return ], outputText: "VKB\n" }, + { initialKey: Qt.Key_Space, initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: "\u00E1\u017C", outputText: "\u00E1\u017C" }, + { initialKey: Qt.Key_Space, initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: "~123qwe", outputText: "~123qwe" }, + { initialKey: Qt.Key_Space, initInputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase, inputSequence: [ Qt.Key_Shift, Qt.Key_Shift, Qt.Key_V, Qt.Key_K, Qt.Key_B, Qt.Key_Return ], outputText: "VKB\n" }, ] } @@ -648,20 +670,20 @@ Rectangle { skip("Arrow key navigation not enabled") verify(inputPanel.naviationHighlight.visible) + verify(inputPanel.navigateToKey(data.initialKey)) for (var inputIndex in data.inputSequence) { verify(inputPanel.navigationKeyClick(data.inputSequence[inputIndex])) } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } function test_navigationCursorWrap_data() { return [ - { initialKey: Qt.Key_Q, navigationKey: Qt.Key_Up, navigationKeyRepeat: 4 }, - { initialKey: Qt.Key_Q, navigationKey: Qt.Key_Down, navigationKeyRepeat: 4 }, + { initialKey: Qt.Key_W, navigationKey: Qt.Key_Up, navigationKeyRepeat: 4 }, + { initialKey: Qt.Key_W, navigationKey: Qt.Key_Down, navigationKeyRepeat: 4 }, { initialKey: Qt.Key_T, navigationKey: Qt.Key_Up, navigationKeyRepeat: 4 }, { initialKey: Qt.Key_T, navigationKey: Qt.Key_Down, navigationKeyRepeat: 4 }, { initialKey: Qt.Key_Backspace, navigationKey: Qt.Key_Up, navigationKeyRepeat: 4 }, @@ -694,7 +716,7 @@ Rectangle { } } - verify(inputPanel.keyboardInputArea.initialKey === initialKeyObj) + compare(inputPanel.keyboardInputArea.initialKey, initialKeyObj) } function test_navigationCursorAndWordCandidateView() { @@ -734,7 +756,10 @@ Rectangle { // Move focus to the next item in the list var previousHighlightIndex = inputPanel.wordCandidateView.currentIndex + inputPanel.wordCandidateListCurrentIndexSpy.clear() inputPanel.emulateNavigationKeyClick(Qt.Key_Right) + inputPanel.wordCandidateListCurrentIndexSpy.wait() + compare(inputPanel.wordCandidateListCurrentIndexSpy.count, 1) compare(inputPanel.wordCandidateView.currentIndex, previousHighlightIndex + 1) // Move focus to previously focused key on keyboard and back @@ -750,7 +775,10 @@ Rectangle { for (previousHighlightIndex = inputPanel.wordCandidateView.currentIndex; previousHighlightIndex < inputPanel.wordCandidateView.count - 1; previousHighlightIndex++) { + inputPanel.wordCandidateListCurrentIndexSpy.clear() inputPanel.emulateNavigationKeyClick(Qt.Key_Right) + inputPanel.wordCandidateListCurrentIndexSpy.wait() + compare(inputPanel.wordCandidateListCurrentIndexSpy.count, 1) compare(inputPanel.wordCandidateView.currentIndex, previousHighlightIndex + 1) } @@ -810,7 +838,7 @@ Rectangle { var keysTraversed = [] do { - verify(keysTraversed.indexOf(inputPanel.keyboardInputArea.initialKey) === -1) + compare(keysTraversed.indexOf(inputPanel.keyboardInputArea.initialKey), -1) var currentKey = inputPanel.keyboardInputArea.initialKey keysTraversed.push(currentKey) inputPanel.emulateNavigationKeyClick(Qt.Key_Right) @@ -845,7 +873,6 @@ Rectangle { for (var inputIndex in data.inputSequence) { verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex])) } - waitForRendering(inputPanel) if (inputPanel.wordCandidateListVisibleHint) { if (data.hasOwnProperty("expectedSuggestion")) { @@ -891,7 +918,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) if (!inputPanel.wordCandidateListVisibleHint && textInput.text !== data.outputText) expectFail("", "Prediction/spell correction not enabled") compare(textInput.text, data.outputText) @@ -935,7 +961,6 @@ Rectangle { for (var inputIndex in data.inputSequence) { verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex])) } - waitForRendering(inputPanel) for (var candidateIndex in data.expectedCandidates) { verify(inputPanel.selectionListSearchSuggestion(data.expectedCandidates[candidateIndex])) @@ -997,7 +1022,6 @@ Rectangle { else verify(inputPanel.virtualKeyClick(key)) } - waitForRendering(inputPanel) if (data.expectedCandidates) { for (var candidateIndex in data.expectedCandidates) { @@ -1066,8 +1090,6 @@ Rectangle { } function test_zhuyinInputMethod(data) { - skip("The test is broken, see QTBUG-80663. Skipping rather than blacklisting to avoid crashes.") - prepareTest(data, true) for (var inputIndex in data.inputSequence) { @@ -1077,8 +1099,6 @@ Rectangle { verify(inputPanel.virtualKeyClick(inputSequence[charIndex])) } - waitForRendering(inputPanel) - if (data.expectedCandidates && inputIndex < data.expectedCandidates.length && data.expectedCandidates[inputIndex].length > 0) { verify(inputPanel.selectionListSearchSuggestion(data.expectedCandidates[inputIndex])) verify(inputPanel.selectionListSelectCurrentItem()) @@ -1087,7 +1107,6 @@ Rectangle { verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex])) } } - waitForRendering(inputPanel) if (!Array.isArray(data.inputSequence) && data.expectedCandidates) { verify(inputPanel.selectionListSearchSuggestion(data.expectedCandidates)) @@ -1160,12 +1179,10 @@ Rectangle { // Remove Jamos one by one. // The number of removed characters must match to the number of Jamos entered. for (inputIndex = data.inputSequence.length - 1; inputIndex >= 0; inputIndex--) { - waitForRendering(inputPanel) compare(Utils.toUnicodeHex(textInputContents()), Utils.toUnicodeHex(intermediateResult.pop())) inputPanel.virtualKeyClick(Qt.Key_Backspace) } - waitForRendering(inputPanel) compare(Utils.toUnicodeHex(textInputContents()), Utils.toUnicodeHex(data.initText !== undefined ? data.initText : "")) } @@ -1210,7 +1227,6 @@ Rectangle { verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex])) } - waitForRendering(inputPanel) compare(textInput.text, data.outputText) if (data.hasOwnProperty("expectedCursorPosition")) @@ -1240,7 +1256,6 @@ Rectangle { for (var inputIndex in data.inputSequence) { verify(inputPanel.virtualKeyClick(data.inputSequence[inputIndex])) } - waitForRendering(inputPanel) for (var candidateIndex in data.expectedCandidates) { verify(inputPanel.selectionListSearchSuggestion(data.expectedCandidates[candidateIndex])) @@ -1295,7 +1310,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -1339,7 +1353,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -1385,7 +1398,6 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) } @@ -1419,12 +1431,10 @@ Rectangle { } Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) var inputMode = inputPanel.inputMode verify(inputPanel.virtualKeyClick(Qt.Key_Mode_switch)) - waitForRendering(inputPanel) compare(inputPanel.inputMode !== inputMode, data.modeSwitchAllowed) } @@ -1448,7 +1458,6 @@ Rectangle { for (var inputIndex in data.inputSequence) { verify(inputPanel.emulateHandwriting(data.inputSequence.charAt(inputIndex), true)) } - waitForRendering(inputPanel) if (inputPanel.wordCandidateListVisibleHint) { if (data.hasOwnProperty("expectedSuggestion")) { @@ -1627,7 +1636,6 @@ Rectangle { for (var inputIndex in data.inputSequence) { verify(handwritingInputPanel.emulateHandwriting(data.inputSequence.charAt(inputIndex), true)) } - waitForRendering(handwritingInputPanel) if (data.popupFlipped) { verify(handwritingInputPanel.wordCandidatePopupList.y + handwritingInputPanel.wordCandidatePopupList.height <= Qt.inputMethod.cursorRectangle.y) @@ -1660,7 +1668,6 @@ Rectangle { else expectedResult = (inputPanel.activeLocales.length === 0 || inputPanel.activeLocales.indexOf(locale) !== -1) && inputPanel.availableLocales.indexOf(locale) !== -1 inputPanel.setLocale(locale) - waitForRendering(inputPanel) compare(inputPanel.locale === locale, expectedResult, "Test locale %1".arg(locale)) } } @@ -1711,7 +1718,6 @@ Rectangle { var cursorRect = cursorRects[i] mousePress(textInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) mouseRelease(textInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) - waitForRendering(textInput) } if (!inputPanel.wordCandidateListVisibleHint && inputPanel.preeditText !== data.expectedPreeditText) @@ -1773,7 +1779,6 @@ Rectangle { var cursorRect = cursorRects[i] mousePress(textInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) mouseRelease(textInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) - waitForRendering(textInput) } if (!inputPanel.wordCandidateListVisibleHint && inputPanel.preeditText !== data.expectedPreeditText) @@ -1799,7 +1804,6 @@ Rectangle { } function test_selection(data) { - waitForRendering(textInput) prepareTest(data) compare(inputPanel.cursorHandle.visible, data.expectHandlesToBeVisible) compare(inputPanel.anchorHandle.visible, data.expectHandlesToBeVisible) @@ -1942,13 +1946,11 @@ Rectangle { prepareTest(data) inputPanel.wordCandidateListChangedSpy.clear() Qt.inputMethod.show() - waitForRendering(inputPanel) compare(inputPanel.wordCandidateView.visibleCondition, data.wclAlwaysVisible) inputPanel.virtualKeyClick("a") inputPanel.virtualKeyClick("u") inputPanel.virtualKeyClick("t") inputPanel.virtualKeyClick("o") - waitForRendering(inputPanel) if (!inputPanel.wordCandidateListVisibleHint) skip("Prediction/spell correction not enabled") inputPanel.wordCandidateListChangedSpy.wait(1000) @@ -1959,7 +1961,6 @@ Rectangle { wait(data.wclAutoHideDelay + 250) else inputPanel.wordCandidateListVisibleSpy.wait(data.wclAutoHideDelay + 500) - waitForRendering(inputPanel) compare(inputPanel.wordCandidateView.visibleCondition, data.wclAlwaysVisible) } @@ -1998,14 +1999,12 @@ Rectangle { inputPanel.shadowInputControlVisibleSpy.clear() inputPanel.setFullScreenMode(true) - waitForRendering(inputPanel) inputPanel.shadowInputControlVisibleSpy.wait() compare(inputPanel.shadowInput.text, textInput.text) inputPanel.shadowInputControlVisibleSpy.clear() inputPanel.setFullScreenMode(false) - waitForRendering(inputPanel) inputPanel.shadowInputControlVisibleSpy.wait() } @@ -2027,7 +2026,6 @@ Rectangle { compare(inputPanel.shadowInput.preeditText, textInput.preeditText) Qt.inputMethod.commit() - waitForRendering(inputPanel) compare(textInput.text, data.outputText) compare(inputPanel.shadowInput.text, textInput.text) compare(inputPanel.shadowInput.cursorPosition, textInput.cursorPosition) @@ -2046,7 +2044,6 @@ Rectangle { prepareTest(data) data.select() - waitForRendering(textInput) compare(inputPanel.shadowInput.text, textInput.text) compare(inputPanel.shadowInput.cursorPosition, textInput.cursorPosition) compare(inputPanel.shadowInput.selectedText, textInput.selectedText) @@ -2083,6 +2080,7 @@ Rectangle { { initText: "aa http://www.example.com bb", initInputMethodHints: Qt.ImhUrlCharactersOnly, clickPositions: [4], expectedPreeditText: "http://www.example.com", expectedCursorPosition: 3, expectedText: "aa bb" }, { initText: "aa username@example.com bb", clickPositions: [4], expectedPreeditText: "username", expectedCursorPosition: 3, expectedText: "aa @example.com bb" }, { initText: "aa username@example.com bb", initInputMethodHints: Qt.ImhEmailCharactersOnly, clickPositions: [4], expectedPreeditText: "username@example.com", expectedCursorPosition: 3, expectedText: "aa bb" }, + { initText: "hello world", clickPositions: [1], expectedPreeditText: "hello", expectedCursorPosition: 0, expectedText: " world" }, ] } @@ -2102,7 +2100,6 @@ Rectangle { var cursorRect = cursorRects[i] mousePress(inputPanel.shadowInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) mouseRelease(inputPanel.shadowInput, cursorRect.x, cursorRect.y + cursorRect.height / 2, Qt.LeftButton, Qt.NoModifier, 20) - waitForRendering(inputPanel.shadowInput) } if (!inputPanel.wordCandidateListVisibleHint && inputPanel.preeditText !== data.expectedPreeditText) @@ -2247,5 +2244,99 @@ Rectangle { Qt.inputMethod.reset() } + + function test_visibleFunctionKey_data() { + return [ + { initLocale: "en_GB", functionKeysAlwaysVisible: false }, + // Number and digits layouts must always have the function keys, because otherwise the layout design looks bad + { initLocale: "en_GB", functionKeysAlwaysVisible: true, initInputMethodHints: Qt.ImhFormattedNumbersOnly }, + { initLocale: "en_GB", functionKeysAlwaysVisible: true, initInputMethodHints: Qt.ImhDigitsOnly }, + // Symbol layout follow the main layout + { initLocale: "en_GB", functionKeysAlwaysVisible: false, initInputMethodHints: Qt.ImhPreferNumbers }, + ] + } + + function test_visibleFunctionKey(data) { + prepareTest(data, true) + + const changeLanguageKey = inputPanel.findKeyByKeyType("ChangeLanguageKey") + verify(!!changeLanguageKey) + const hideKeyboardKey = inputPanel.findKeyByKeyType("HideKeyboardKey") + verify(!!hideKeyboardKey) + + for (const functionKeyName of [ + "None", + "Hide", + "Language", + "All" + ]) { + inputPanel.setVisibleFunctionKeys([functionKeyName]) + if (data.functionKeysAlwaysVisible) { + compare(changeLanguageKey.visible, true) + compare(hideKeyboardKey.visible, true) + } else if (functionKeyName === "None") { + compare(changeLanguageKey.visible, false) + compare(hideKeyboardKey.visible, false) + } else if (functionKeyName === "Hide") { + compare(changeLanguageKey.visible, false) + compare(hideKeyboardKey.visible, true) + } else if (functionKeyName === "Language") { + compare(changeLanguageKey.visible, true) + compare(hideKeyboardKey.visible, false) + } else if (functionKeyName === "All") { + compare(changeLanguageKey.visible, true) + compare(hideKeyboardKey.visible, true) + } + } + } + + function test_closeOnReturnSingleLine_data() { + return [ + { closeOnReturn: true, enterKeyType: Qt.EnterKeyDefault, expectedVisibleAfterReturn: false }, + { closeOnReturn: false, enterKeyType: Qt.EnterKeyDefault, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyReturn, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyDone, expectedVisibleAfterReturn: false }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyGo, expectedVisibleAfterReturn: false }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeySend, expectedVisibleAfterReturn: false }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeySearch, expectedVisibleAfterReturn: false }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyNext, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyPrevious, expectedVisibleAfterReturn: true }, + ] + } + + function test_closeOnReturnSingleLine(data) { + prepareTest(data) + let testObj = textFieldComp.createObject(container, {enterKeyType: data.enterKeyType}) + testObj.forceActiveFocus() + compare(inputPanel.closeOnReturn(), data.closeOnReturn) + verify(inputPanel.visible === true) + keyClick(Qt.Key_Return) + waitForRendering(inputPanel) + verify(inputPanel.visible === data.expectedVisibleAfterReturn) + testObj.destroy() + } + + function test_closeOnReturnMultiline_data() { + return [ + { closeOnReturn: true, enterKeyType: Qt.EnterKeyDefault, expectedVisibleAfterReturn: true }, + { closeOnReturn: false, enterKeyType: Qt.EnterKeyDefault, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyReturn, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyDone, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyGo, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeySend, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeySearch, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyNext, expectedVisibleAfterReturn: true }, + { closeOnReturn: true, enterKeyType: Qt.EnterKeyPrevious, expectedVisibleAfterReturn: true }, + ] + } + + function test_closeOnReturnMultiline(data) { + prepareTest(data) + compare(inputPanel.closeOnReturn(), data.closeOnReturn) + verify(inputPanel.visible === true) + keyClick(Qt.Key_Return) + waitForRendering(inputPanel) + verify(inputPanel.visible === data.expectedVisibleAfterReturn) + } } } diff --git a/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py b/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py index 75a88313..a7758eb8 100755 --- a/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py +++ b/tests/auto/inputpanel/hwr_test_data/build_unipen_data.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (C) 2017 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 import os import sys @@ -15,7 +15,7 @@ unipen_file_pattern = re.compile(r'(^[0-9]{2,9}).*\.txt') def print_header(): print """ // Copyright (C) %s The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 """ % datetime.datetime.now().year def scan_unipen_files(path): diff --git a/tests/auto/inputpanel/tst_inputpanel.cpp b/tests/auto/inputpanel/tst_inputpanel.cpp index 5030d405..41a3f967 100644 --- a/tests/auto/inputpanel/tst_inputpanel.cpp +++ b/tests/auto/inputpanel/tst_inputpanel.cpp @@ -7,18 +7,25 @@ #include <QFileInfo> #include <QDir> -static bool s_configEnv = qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); -static bool initStandardPaths() { - QStandardPaths::setTestModeEnabled(true); - auto configLocations = QStringList() - << QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/qtvirtualkeyboard" - << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/qtvirtualkeyboard"; - for (const QString &configLocation : configLocations) { - if (configLocation != "/qtvirtualkeyboard") - QDir(configLocation).removeRecursively(); +namespace +{ + +struct VirtualKeyboardSetup : QObject +{ + VirtualKeyboardSetup() + { + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + QStandardPaths::setTestModeEnabled(true); + auto configLocations = QStringList() + << QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/qtvirtualkeyboard" + << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/qtvirtualkeyboard"; + for (const QString &configLocation : configLocations) { + if (configLocation != "/qtvirtualkeyboard") + QDir(configLocation).removeRecursively(); + } } - return true; +}; + } -static bool s_initStandardPaths = initStandardPaths(); -QUICK_TEST_MAIN(inputpanel) +QUICK_TEST_MAIN_WITH_SETUP(inputpanel, VirtualKeyboardSetup) diff --git a/tests/auto/inputpanelcontrols/CMakeLists.txt b/tests/auto/inputpanelcontrols/CMakeLists.txt index 29fc0515..665f97d9 100644 --- a/tests/auto/inputpanelcontrols/CMakeLists.txt +++ b/tests/auto/inputpanelcontrols/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Collect test data file(GLOB_RECURSE test_data_glob RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} @@ -8,7 +11,7 @@ qt_internal_add_test(tst_inputpanelcontrols QMLTEST SOURCES tst_inputpanelcontrols.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui TESTDATA ${test_data} ) diff --git a/tests/auto/inputpanelcontrols/tst_inputpanelcontrols.cpp b/tests/auto/inputpanelcontrols/tst_inputpanelcontrols.cpp index 9211b1f2..d06b2410 100644 --- a/tests/auto/inputpanelcontrols/tst_inputpanelcontrols.cpp +++ b/tests/auto/inputpanelcontrols/tst_inputpanelcontrols.cpp @@ -7,18 +7,25 @@ #include <QFileInfo> #include <QDir> -static bool s_configEnv = qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); -static bool initStandardPaths() { - QStandardPaths::setTestModeEnabled(true); - auto configLocations = QStringList() - << QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/qtvirtualkeyboard" - << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/qtvirtualkeyboard"; - for (const QString &configLocation : configLocations) { - if (configLocation != "/qtvirtualkeyboard") - QDir(configLocation).removeRecursively(); +namespace +{ + +struct VirtualKeyboardSetup : QObject +{ + VirtualKeyboardSetup() + { + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + QStandardPaths::setTestModeEnabled(true); + auto configLocations = QStringList() + << QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/qtvirtualkeyboard" + << QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/qtvirtualkeyboard"; + for (const QString &configLocation : configLocations) { + if (configLocation != "/qtvirtualkeyboard") + QDir(configLocation).removeRecursively(); + } } - return true; +}; + } -static bool s_initStandardPaths = initStandardPaths(); -QUICK_TEST_MAIN(inputpanelcontrols) +QUICK_TEST_MAIN_WITH_SETUP(inputpanelcontrols, VirtualKeyboardSetup) diff --git a/tests/auto/layoutfilesystem/CMakeLists.txt b/tests/auto/layoutfilesystem/CMakeLists.txt index cea29b33..0232b449 100644 --- a/tests/auto/layoutfilesystem/CMakeLists.txt +++ b/tests/auto/layoutfilesystem/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from layoutfilesystem.pro. ##################################################################### @@ -9,10 +12,10 @@ qt_internal_add_test(tst_layoutfilesystem ../shared/layouttesthelper.cpp ../shared/layouttesthelper.h tst_layoutfilesystem.cpp DEFINES - SRC_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\" + SRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES ../shared - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Qml Qt::Quick @@ -25,7 +28,7 @@ qt_internal_add_test(tst_layoutfilesystem ##################################################################### qt_internal_extend_target(tst_layoutfilesystem CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/auto/layoutresources/CMakeLists.txt b/tests/auto/layoutresources/CMakeLists.txt index f772e4ea..42c26bf5 100644 --- a/tests/auto/layoutresources/CMakeLists.txt +++ b/tests/auto/layoutresources/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from layoutresources.pro. ##################################################################### @@ -9,10 +12,10 @@ qt_internal_add_test(tst_layoutresources ../shared/layouttesthelper.cpp ../shared/layouttesthelper.h tst_layoutresources.cpp DEFINES - SRC_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}\\\" + SRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES ../shared - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Qml Qt::Quick @@ -37,7 +40,7 @@ qt_internal_add_resource(tst_layoutresources "resourceslayout" ##################################################################### qt_internal_extend_target(tst_layoutresources CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/auto/shadowinput/CMakeLists.txt b/tests/auto/shadowinput/CMakeLists.txt new file mode 100644 index 00000000..e7668ba8 --- /dev/null +++ b/tests/auto/shadowinput/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/data/*) +list(APPEND test_data ${test_data_glob}) + +qt_internal_add_test(tst_shadowinput + QMLTEST + SOURCES + tst_shadowinput.cpp + LIBRARIES + Qt::Gui + TESTDATA ${test_data} +) diff --git a/tests/auto/shadowinput/data/inputpanel/inputpanel.qml b/tests/auto/shadowinput/data/inputpanel/inputpanel.qml new file mode 100644 index 00000000..9879c40f --- /dev/null +++ b/tests/auto/shadowinput/data/inputpanel/inputpanel.qml @@ -0,0 +1,24 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtTest +import QtQuick +import QtQuick.VirtualKeyboard +import QtQuick.VirtualKeyboard.Settings + +InputPanel { + id: inputPanel + z: 99 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + visible: active + property bool fullScreenMode: true + property bool shadowInputVisible: keyboard.shadowInputControl.visible + property string shadowInputText: keyboard.shadowInputControl.textEdit.text + Binding { + target: VirtualKeyboardSettings + property: "fullScreenMode" + value: inputPanel.fullScreenMode + } +} diff --git a/tests/auto/shadowinput/data/tst_shadowinput.qml b/tests/auto/shadowinput/data/tst_shadowinput.qml new file mode 100644 index 00000000..fbe79c82 --- /dev/null +++ b/tests/auto/shadowinput/data/tst_shadowinput.qml @@ -0,0 +1,92 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtTest +import QtQuick +import QtQuick.Window + +Rectangle { + id: container + width: 800 + height: 640 + color: "blue" + + Component { + id: textInputComp + TextEdit { + anchors.fill: parent + visible: true + focus: true + color: "white" + } + } + + TestCase { + id: testcase + name: "tst_inputpanelcontrols" + when: windowShown + + property var inputPanel: null + property var textInput: null + + function initTestCase() { + var inputPanelComp = Qt.createComponent("inputpanel/inputpanel.qml") + compare(inputPanelComp.status, Component.Ready, "Failed to create component: "+inputPanelComp.errorString()) + inputPanel = inputPanelComp.createObject(container) + + textInput = textEditComp.createObject(container) + } + + function cleanupTestCase() { + if (inputPanel) + inputPanel.destroy() + } + + function prepareTest() { + var window = container.Window.window + verify(window) + window.raise() + window.requestActivate() + tryCompare(window, "active", true) + + container.forceActiveFocus() + waitForRendering(container) + textInput.forceActiveFocus() + waitForRendering(inputPanel) + + textInput.text = "" + verify(inputPanel.visible === true) + verify(textInput.activeFocus === true) + } + + Component { + id: textEditComp + TextEdit { + id: textEdit + visible: true + focus: true + color: "white" + } + } + + function test_fullScreenModeBindingWorks() { + prepareTest() + + verify(inputPanel.visible === true) + waitForRendering(inputPanel) + + // VirtualKeyboardSettings.fullScreeenMode is initially true + // Verity that shadow input is visible and the content match with the edit field + verify(inputPanel.shadowInputVisible) + textInput.text = "hello" + compare(inputPanel.shadowInputText, textInput.text) + + // Disable fullScreenMode and verify + inputPanel.fullScreenMode = false + waitForRendering(inputPanel) + verify(!inputPanel.shadowInputVisible) + textInput.text = "world" + compare(inputPanel.shadowInputText, "") + } + } +} diff --git a/tests/auto/shadowinput/tst_shadowinput.cpp b/tests/auto/shadowinput/tst_shadowinput.cpp new file mode 100644 index 00000000..afa0bb28 --- /dev/null +++ b/tests/auto/shadowinput/tst_shadowinput.cpp @@ -0,0 +1,23 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtQuickTest/quicktest.h> +#include <QByteArray> +#include <QStandardPaths> +#include <QFileInfo> +#include <QDir> + +namespace +{ + +struct VirtualKeyboardSetup : QObject +{ + VirtualKeyboardSetup() + { + qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + } +}; + +} + +QUICK_TEST_MAIN_WITH_SETUP(shadowinput, VirtualKeyboardSetup) diff --git a/tests/auto/shared/layouttesthelper.cpp b/tests/auto/shared/layouttesthelper.cpp index 76c54144..266906fe 100644 --- a/tests/auto/shared/layouttesthelper.cpp +++ b/tests/auto/shared/layouttesthelper.cpp @@ -16,7 +16,8 @@ LayoutTestHelper::LayoutTestHelper() Window { \ property var settings: VirtualKeyboardSettings; \ InputPanel { \ - id: inputPanel \ + id: inputPanel; \ + width: parent.width; \ } \ }", QUrl()); window.reset(qobject_cast<QQuickWindow*>(component->create())); diff --git a/tests/auto/styles/CMakeLists.txt b/tests/auto/styles/CMakeLists.txt index 54dd086b..92f77c18 100644 --- a/tests/auto/styles/CMakeLists.txt +++ b/tests/auto/styles/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from styles.pro. ##################################################################### @@ -15,12 +18,30 @@ qt_internal_add_test(tst_styles SOURCES tst_styles.cpp DEFINES - TESTDATA_DIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\" - PUBLIC_LIBRARIES + TESTDATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" + LIBRARIES Qt::Gui TESTDATA ${test_data} ) +qt_internal_add_resource(tst_styles "test_res" + PREFIX + "/qt/qml/QtQuick/VirtualKeyboard/Styles/test_res" + BASE + "data/QtQuick/VirtualKeyboard/Styles/test" + FILES + "data/QtQuick/VirtualKeyboard/Styles/test/style.qml" +) + +qt_internal_add_resource(tst_styles "test_res_compat" + PREFIX + "/QtQuick/VirtualKeyboard/content/styles/test_res_compat" + BASE + "data/QtQuick/VirtualKeyboard/Styles/test" + FILES + "data/QtQuick/VirtualKeyboard/Styles/test/style.qml" +) + #### Keys ignored in scope 1:.:.:styles.pro:<TRUE>: # DISTFILES = "data/tst_styles.qml" "data/QtQuick/VirtualKeyboard/Styles/test/style.qml" # OTHER_FILES = "$$PWD/data/tst_styles.qml" @@ -30,7 +51,7 @@ qt_internal_add_test(tst_styles ##################################################################### qt_internal_extend_target(tst_styles CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/auto/styles/data/tst_styles.qml b/tests/auto/styles/data/tst_styles.qml index 85c55ed3..f5661b07 100644 --- a/tests/auto/styles/data/tst_styles.qml +++ b/tests/auto/styles/data/tst_styles.qml @@ -16,7 +16,9 @@ Item { return [ { tag: "default", result: "default"}, { tag: "retro", result: "retro"}, // in-source alternate style - { tag: "test", result: "test"} // out-of-source alternate style + { tag: "test", result: "test"}, // out-of-source alternate style + { tag: "test_res", result: "test_res"}, // default resource path + { tag: "test_res_compat", result: "test_res_compat"}, // compatibility resource path ]; } diff --git a/tests/auto/virtualkeyboardattached/CMakeLists.txt b/tests/auto/virtualkeyboardattached/CMakeLists.txt new file mode 100644 index 00000000..b3221bd2 --- /dev/null +++ b/tests/auto/virtualkeyboardattached/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/data/*) +list(APPEND test_data ${test_data_glob}) + +qt_internal_add_test(tst_virtualkeyboardattached + QMLTEST + SOURCES + tst_virtualkeyboardattached.cpp + LIBRARIES + Qt::Gui + TESTDATA ${test_data} +) diff --git a/tests/auto/virtualkeyboardattached/data/inputpanel/inputpanel.qml b/tests/auto/virtualkeyboardattached/data/inputpanel/inputpanel.qml new file mode 100644 index 00000000..80fe6265 --- /dev/null +++ b/tests/auto/virtualkeyboardattached/data/inputpanel/inputpanel.qml @@ -0,0 +1,16 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtTest +import QtQuick +import QtQuick.VirtualKeyboard +import QtQuick.VirtualKeyboard.Settings + +InputPanel { + id: inputPanel + z: 99 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + visible: active +} diff --git a/tests/auto/virtualkeyboardattached/data/tst_virtualkeyboardattached.qml b/tests/auto/virtualkeyboardattached/data/tst_virtualkeyboardattached.qml new file mode 100644 index 00000000..b158f603 --- /dev/null +++ b/tests/auto/virtualkeyboardattached/data/tst_virtualkeyboardattached.qml @@ -0,0 +1,99 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +import QtTest +import QtQuick +import QtQuick.Window +import QtQuick.VirtualKeyboard + +Rectangle { + id: container + width: 800 + height: 640 + color: "blue" + + TestCase { + id: testcase + name: "tst_virtualkeyboardattached" + when: windowShown + + property var inputPanel: null + + function initTestCase() { + var inputPanelComp = Qt.createComponent("inputpanel/inputpanel.qml") + compare(inputPanelComp.status, Component.Ready, "Failed to create component: "+inputPanelComp.errorString()) + inputPanel = inputPanelComp.createObject(container) + } + + function cleanupTestCase() { + if (inputPanel) + inputPanel.destroy() + } + + function prepareTest() { + var window = container.Window.window + verify(window) + window.raise() + window.requestActivate() + tryCompare(window, "active", true) + } + + Component { + id: textInputWithVirtualKeyboardAttachedComp + TextEdit { + anchors.fill: parent + visible: true + focus: true + color: "white" + VirtualKeyboard.extraDictionaries: ["example"] + } + } + + function test_virtualKeyboardAttached() { + prepareTest() + + container.forceActiveFocus() + waitForRendering(container) + + let textInput = textInputWithVirtualKeyboardAttachedComp.createObject(container) + + verify(textInput !== null) + + textInput.forceActiveFocus() + waitForRendering(inputPanel) + + verify(inputPanel.visible === true) + verify(textInput.activeFocus === true) + } + + Component { + id: textInputWithEnterKeyActionAttachedComp + TextEdit { + anchors.fill: parent + visible: true + focus: true + color: "white" + EnterKeyAction.actionId: EnterKeyAction.Done + EnterKeyAction.label: "hello" + EnterKeyAction.enabled: true + } + } + + function test_enterKeyActionAttached() { + prepareTest() + + container.forceActiveFocus() + waitForRendering(container) + + let textInput = textInputWithEnterKeyActionAttachedComp.createObject(container) + + verify(textInput !== null) + + textInput.forceActiveFocus() + waitForRendering(inputPanel) + + verify(inputPanel.visible === true) + verify(textInput.activeFocus === true) + } + } +} diff --git a/tests/auto/virtualkeyboardattached/tst_virtualkeyboardattached.cpp b/tests/auto/virtualkeyboardattached/tst_virtualkeyboardattached.cpp new file mode 100644 index 00000000..5bf71dfb --- /dev/null +++ b/tests/auto/virtualkeyboardattached/tst_virtualkeyboardattached.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtQuickTest/quicktest.h> +#include <QByteArray> +#include <QStandardPaths> +#include <QFileInfo> +#include <QDir> + +static bool s_configEnv = qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); + +QUICK_TEST_MAIN(virtualkeyboardattached) diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index 3f048017..861cd2ec 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -1,6 +1,9 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from manual.pro. -find_package(X11 REQUIRED) +find_package(X11) if(X11_FOUND) add_subdirectory(x11vkbwrapper) add_subdirectory(x11vkbtest) diff --git a/tests/manual/quickcontrols2/CMakeLists.txt b/tests/manual/quickcontrols2/CMakeLists.txt index 372cc9bf..04204c69 100644 --- a/tests/manual/quickcontrols2/CMakeLists.txt +++ b/tests/manual/quickcontrols2/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from quickcontrols2.pro. ##################################################################### @@ -8,7 +11,7 @@ qt_internal_add_manual_test(quickcontrols2 GUI SOURCES main.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Qml Qt::Quick diff --git a/tests/manual/startupperformance/CMakeLists.txt b/tests/manual/startupperformance/CMakeLists.txt index 7ae59751..d1132cf1 100644 --- a/tests/manual/startupperformance/CMakeLists.txt +++ b/tests/manual/startupperformance/CMakeLists.txt @@ -1,8 +1,11 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_manual_test(startupperformance GUI SOURCES main.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::Qml Qt::Quick diff --git a/tests/manual/x11vkbtest/CMakeLists.txt b/tests/manual/x11vkbtest/CMakeLists.txt index c30a9770..b23be5a0 100644 --- a/tests/manual/x11vkbtest/CMakeLists.txt +++ b/tests/manual/x11vkbtest/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from x11vkbtest.pro. ##################################################################### @@ -28,7 +31,7 @@ qt_internal_add_manual_test(x11vkbtest windowhelper.cpp windowhelper.h DEFINES QT_DEPRECATED_WARNINGS - PUBLIC_LIBRARIES + LIBRARIES Qt::Charts Qt::Gui X11::X11 diff --git a/tests/manual/x11vkbwrapper/CMakeLists.txt b/tests/manual/x11vkbwrapper/CMakeLists.txt index 93ba582f..94a0bcf1 100644 --- a/tests/manual/x11vkbwrapper/CMakeLists.txt +++ b/tests/manual/x11vkbwrapper/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from x11vkbwrapper.pro. ##################################################################### @@ -30,7 +33,7 @@ qt_internal_add_manual_test(x11vkbwrapper xcbkeyboard.h DEFINES QT_DEPRECATED_WARNINGS - PUBLIC_LIBRARIES + LIBRARIES PkgConfig::ATSPI2 Qt::DBus Qt::Gui @@ -66,7 +69,7 @@ qt_internal_add_resource(x11vkbwrapper "qml" ##################################################################### qt_internal_extend_target(x11vkbwrapper CONDITION NOT QT_BUILD_SHARED_LIBS - PUBLIC_LIBRARIES + LIBRARIES Qt::Svg ) diff --git a/tests/manual/x11vkbwrapper/handleatspievents.cpp b/tests/manual/x11vkbwrapper/handleatspievents.cpp index b71ab88a..7b2c0743 100644 --- a/tests/manual/x11vkbwrapper/handleatspievents.cpp +++ b/tests/manual/x11vkbwrapper/handleatspievents.cpp @@ -113,7 +113,7 @@ void HandleATSPIEvents::setKeyboardVisible(const bool visible) void HandleATSPIEvents::storeFocusElement(const qint8 role) { m_focuses.append(role); - qCDebug(lcHandleAtspiEvents) << "*****INSERTED FOCUS ELEMENT*****" << role << "TOTAL:" << m_focuses.length(); + qCDebug(lcHandleAtspiEvents) << "*****INSERTED FOCUS ELEMENT*****" << role << "TOTAL:" << m_focuses.size(); } /** diff --git a/tests/manual/x11vkbwrapper/vkbnativehost/CMakeLists.txt b/tests/manual/x11vkbwrapper/vkbnativehost/CMakeLists.txt index 4e9c5cfd..6874df79 100644 --- a/tests/manual/x11vkbwrapper/vkbnativehost/CMakeLists.txt +++ b/tests/manual/x11vkbwrapper/vkbnativehost/CMakeLists.txt @@ -1,3 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + # Generated from vkbnativehost.pro. ##################################################################### @@ -11,7 +14,7 @@ qt_internal_add_manual_test(x11vkbnativehost sendertodbus.cpp sendertodbus.h DEFINES QT_DEPRECATED_WARNINGS - PUBLIC_LIBRARIES + LIBRARIES Qt::DBus ) diff --git a/tests/manual/x11vkbwrapper/vkbnativehost/install_host.sh b/tests/manual/x11vkbwrapper/vkbnativehost/install_host.sh index 8eae33d1..a2d45fd2 100755 --- a/tests/manual/x11vkbwrapper/vkbnativehost/install_host.sh +++ b/tests/manual/x11vkbwrapper/vkbnativehost/install_host.sh @@ -1,32 +1,6 @@ #!/bin/bash -#****************************************************************************** -#** -#** Copyright (C) 2019 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$ -#** -#****************************************************************************/ +# Copyright (C) 2019 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 set -e BROWSER=$1 |