diff options
author | Michal Klocek <michal.klocek@qt.io> | 2023-03-20 08:46:55 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2023-03-22 08:59:42 +0100 |
commit | 55f9fc348278b2aa8985ec9c1e7e092f88f68f83 (patch) | |
tree | fd12d6347bad7f93f9ba845043fbf86ff6755fa6 | |
parent | 6bf30525ee49d270dae6a6440bc607513f21237c (diff) | |
download | qtwebengine-55f9fc348278b2aa8985ec9c1e7e092f88f68f83.tar.gz |
Move custom touch handles example to manual tests
Move and add missing parts as snippet.
Pick-to: dev 6.5
Task-number: QTBUG-108751
Change-Id: I25849941700337626ca46e399fdb52264bc4659a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Yigit Akcay <yigit.akcay@qt.io>
12 files changed, 58 insertions, 92 deletions
diff --git a/examples/webenginequick/CMakeLists.txt b/examples/webenginequick/CMakeLists.txt index 30ecb9808..ef140ee72 100644 --- a/examples/webenginequick/CMakeLists.txt +++ b/examples/webenginequick/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -qt_internal_add_example(customtouchhandle) qt_internal_add_example(lifecycle) qt_internal_add_example(quicknanobrowser) qt_internal_add_example(webengineaction) diff --git a/examples/webenginequick/customtouchhandle/CMakeLists.txt b/examples/webenginequick/customtouchhandle/CMakeLists.txt deleted file mode 100644 index e84e97524..000000000 --- a/examples/webenginequick/customtouchhandle/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(customtouchhandle LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginequick/customtouchhandle") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineQuick) - -qt_add_executable(customtouchhandle - main.cpp -) - -set_target_properties(customtouchhandle PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(customtouchhandle PUBLIC - Qt::Core - Qt::Gui - Qt::WebEngineQuick -) - -# Resources: -set(qml_resource_files - "main.qml" -) - -qt6_add_resources(customtouchhandle "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) - -install(TARGETS customtouchhandle - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/webenginequick/customtouchhandle/doc/images/customtouchhandle.jpg b/examples/webenginequick/customtouchhandle/doc/images/customtouchhandle.jpg Binary files differdeleted file mode 100644 index bd65c083d..000000000 --- a/examples/webenginequick/customtouchhandle/doc/images/customtouchhandle.jpg +++ /dev/null diff --git a/examples/webenginequick/customtouchhandle/doc/src/customtouchhandle.qdoc b/examples/webenginequick/customtouchhandle/doc/src/customtouchhandle.qdoc deleted file mode 100644 index 742f65b6b..000000000 --- a/examples/webenginequick/customtouchhandle/doc/src/customtouchhandle.qdoc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example webenginequick/customtouchhandle - \title WebEngine Qt Quick Custom Touch Handle Example - \ingroup webengine-examples - \brief Shows custom touch handles upon touch selection events. - - \image customtouchhandle.jpg - - \e {WebEngine Qt Quick Touch Handle Example} demonstrates how to use - custom touch handles when a touch selection event happens. It shows the - minimum amount of code needed to use custom touch handle delegates, and - can be used as a basis for further experimentation. - - \section1 Custom Touch Handle - - In \c main.qml we create the custom touch handle delegate. - - \quotefromfile webenginequick/customtouchhandle/main.qml - \skipto WebEngineView - \printuntil /^\ {4}\}/ - - \section1 QML Code - - In \c main.qml we create the top level window filled by a - \l{WebEngineView} item loading the \l{Qt Homepage}. - To display custom touch handles, a QML item should be delegated to - \l{WebEngineView::touchHandleDelegate}. - - The touch handle's position, opacity, and visibility is automatically updated. - - \note If no delegate is provided, Chromium's default touch handles will appear. - - \section1 Requirements - - The example requires a working internet connection to render the - \l{Qt Homepage} and a touch-enabled input device to trigger touch - events. - An optional system proxy should be picked up automatically. -*/ diff --git a/examples/webenginequick/webenginequick.pro b/examples/webenginequick/webenginequick.pro index 8c7343017..9711ccb3a 100644 --- a/examples/webenginequick/webenginequick.pro +++ b/examples/webenginequick/webenginequick.pro @@ -1,7 +1,6 @@ TEMPLATE=subdirs SUBDIRS += \ - customtouchhandle \ quicknanobrowser \ webengineaction diff --git a/src/webenginequick/doc/src/webengineview_lgpl.qdoc b/src/webenginequick/doc/src/webengineview_lgpl.qdoc index 5413d70fb..6390c0c02 100644 --- a/src/webenginequick/doc/src/webengineview_lgpl.qdoc +++ b/src/webenginequick/doc/src/webengineview_lgpl.qdoc @@ -1501,6 +1501,27 @@ // ... } \endcode + + The touch handles can be also switched dynamically: + + \code + Component { + id: circleTouchHandle + Rectangle { + color: "blue" + radius: 50 + } + } + function showDefaultHandle(isDefault) { + if (isDefault) + webEngineView.touchHandleDelegate = circleTouchHandle + else + webEngineView.touchHandleDelegate = null + } + \endcode + + \note If no delegate is provided, Chromium's default touch handles will appear. + */ \sa {WebEngine Qt Quick Custom Touch Handle Example} diff --git a/tests/manual/examples/quick/CMakeLists.txt b/tests/manual/examples/quick/CMakeLists.txt index 72b86d185..d5f960480 100644 --- a/tests/manual/examples/quick/CMakeLists.txt +++ b/tests/manual/examples/quick/CMakeLists.txt @@ -1,2 +1,3 @@ add_subdirectory(minimal) add_subdirectory(customdialogs) +add_subdirectory(customtouchhandle) diff --git a/tests/manual/examples/quick/customtouchhandle/CMakeLists.txt b/tests/manual/examples/quick/customtouchhandle/CMakeLists.txt new file mode 100644 index 000000000..5d790a9e3 --- /dev/null +++ b/tests/manual/examples/quick/customtouchhandle/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(customtouchhandle LANGUAGES CXX) + find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineQuick) +endif() + +qt_internal_add_manual_test(customtouchhandle + SOURCES main.cpp +) + +set_target_properties(customtouchhandle PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(customtouchhandle PUBLIC + Qt::Core + Qt::Gui + Qt::WebEngineQuick +) + +# Resources: +set(qml_resource_files + "main.qml" +) + +qt6_add_resources(customtouchhandle "qml" + PREFIX + "/" + FILES + ${qml_resource_files} +) + diff --git a/examples/webenginequick/customtouchhandle/customtouchhandle.pro b/tests/manual/examples/quick/customtouchhandle/customtouchhandle.pro index a74ef3146..a74ef3146 100644 --- a/examples/webenginequick/customtouchhandle/customtouchhandle.pro +++ b/tests/manual/examples/quick/customtouchhandle/customtouchhandle.pro diff --git a/examples/webenginequick/customtouchhandle/main.cpp b/tests/manual/examples/quick/customtouchhandle/main.cpp index f1b70b024..f1b70b024 100644 --- a/examples/webenginequick/customtouchhandle/main.cpp +++ b/tests/manual/examples/quick/customtouchhandle/main.cpp diff --git a/examples/webenginequick/customtouchhandle/main.qml b/tests/manual/examples/quick/customtouchhandle/main.qml index c40b4c73b..c40b4c73b 100644 --- a/examples/webenginequick/customtouchhandle/main.qml +++ b/tests/manual/examples/quick/customtouchhandle/main.qml diff --git a/examples/webenginequick/customtouchhandle/qml.qrc b/tests/manual/examples/quick/customtouchhandle/qml.qrc index 5f6483ac3..5f6483ac3 100644 --- a/examples/webenginequick/customtouchhandle/qml.qrc +++ b/tests/manual/examples/quick/customtouchhandle/qml.qrc |