summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2023-03-17 17:26:39 +0100
committerMichal Klocek <michal.klocek@qt.io>2023-03-31 12:37:43 +0200
commitc87f97e566599563ecaf5cbaf4f75f3fb8f4655d (patch)
treed44f34d1be099486fcfd1c35b54b2a1def648146 /examples
parent9937cbb4a0f43a799400f4057e8c695f88d1aa9f (diff)
downloadqtwebengine-c87f97e566599563ecaf5cbaf4f75f3fb8f4655d.tar.gz
Replace WebEngineAction example with a snippet
Also moves the example to the manual tests directory. Task-number: QTBUG-108751 Change-Id: Ie3fa492cfcaf61ee26ed65fa22954bb6a6532d6e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io> (cherry picked from commit 23d1131577e1780de0552211a84357bcb1f63de5)
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginequick/CMakeLists.txt1
-rw-r--r--examples/webenginequick/webengineaction/CMakeLists.txt49
-rw-r--r--examples/webenginequick/webengineaction/doc/images/webengineaction-example.pngbin100266 -> 0 bytes
-rw-r--r--examples/webenginequick/webengineaction/doc/src/webengineaction.qdoc47
-rw-r--r--examples/webenginequick/webengineaction/main.cpp25
-rw-r--r--examples/webenginequick/webengineaction/main.qml121
-rw-r--r--examples/webenginequick/webengineaction/qml.qrc5
-rw-r--r--examples/webenginequick/webengineaction/utils.h25
-rw-r--r--examples/webenginequick/webengineaction/webengineaction.pro11
-rw-r--r--examples/webenginequick/webenginequick.pro3
10 files changed, 1 insertions, 286 deletions
diff --git a/examples/webenginequick/CMakeLists.txt b/examples/webenginequick/CMakeLists.txt
index ef140ee72..ff291fdcf 100644
--- a/examples/webenginequick/CMakeLists.txt
+++ b/examples/webenginequick/CMakeLists.txt
@@ -3,7 +3,6 @@
qt_internal_add_example(lifecycle)
qt_internal_add_example(quicknanobrowser)
-qt_internal_add_example(webengineaction)
if(TARGET Qt::QuickControls2)
qt_internal_add_example(recipebrowser)
endif()
diff --git a/examples/webenginequick/webengineaction/CMakeLists.txt b/examples/webenginequick/webengineaction/CMakeLists.txt
deleted file mode 100644
index 94f03a143..000000000
--- a/examples/webenginequick/webengineaction/CMakeLists.txt
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(webengineaction LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginequick/webengineaction")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineQuick)
-
-qt_add_executable(webengineaction
- main.cpp
- utils.h
-)
-
-set_target_properties(webengineaction PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(webengineaction PUBLIC
- Qt::Core
- Qt::Gui
- Qt::WebEngineQuick
-)
-
-# Resources:
-set(qml_resource_files
- "main.qml"
-)
-
-qt_add_resources(webengineaction "qml"
- PREFIX
- "/"
- FILES
- ${qml_resource_files}
-)
-
-install(TARGETS webengineaction
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/webenginequick/webengineaction/doc/images/webengineaction-example.png b/examples/webenginequick/webengineaction/doc/images/webengineaction-example.png
deleted file mode 100644
index 2e34bbf63..000000000
--- a/examples/webenginequick/webengineaction/doc/images/webengineaction-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginequick/webengineaction/doc/src/webengineaction.qdoc b/examples/webenginequick/webengineaction/doc/src/webengineaction.qdoc
deleted file mode 100644
index 272853aef..000000000
--- a/examples/webenginequick/webengineaction/doc/src/webengineaction.qdoc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example webenginequick/webengineaction
- \title WebEngine Action Example
- \ingroup webengine-examples
- \brief A simple browser implemented using WebEngineActions.
-
- \image webengineaction-example.png
-
- \e {WebEngine Action Example} demonstrates how to perform actions on a web page
- using the \l{WebEngineAction} type. It shows the minimum amount of code needed
- to bind browser functionalities to input elements and build up a custom context
- menu.
-
- \include examples-run.qdocinc
-
- \section1 Working With Web Engine Actions
-
- An intended use of \l{WebEngineAction} is building a connection between UI
- elements and browser commands. It can be added to menus and toolbars via
- assigning its properties to the corresponding ones of the element.
-
- The \l{ToolButton} relies on the properties provided by a
- \l{WebEngineAction}. Clicking the button triggers backwards navigation on the
- originating \l{WebEngineView} of the action.
-
- \quotefromfile webenginequick/webengineaction/main.qml
- \skipto ToolButton {
- \printuntil }
-
- The simplest way to create custom context menus is enumerating the required
- \l{WebEngineAction} types in a data model and instantiating \l{MenuItem} types
- for them, for example using a \l{Repeater}.
-
- \quotefromfile webenginequick/webengineaction/main.qml
- \skipto property Menu contextMenu: Menu {
- \printuntil /^ {8}\}/
-
- Assigning a \l{WebEngineAction} to multiple UI elements will keep them in sync.
- As it can be seen in the picture above, if the browser engine disables a
- navigation action, both corresponding menu items will be disabled.
-
- \note Note that incomplete URLs in the navigation bar are handled by
- \l {QUrl::} {fromUserInput}.
-*/
diff --git a/examples/webenginequick/webengineaction/main.cpp b/examples/webenginequick/webengineaction/main.cpp
deleted file mode 100644
index a7bfaaf36..000000000
--- a/examples/webenginequick/webengineaction/main.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "utils.h"
-
-#include <QGuiApplication>
-#include <QQmlApplicationEngine>
-#include <QQmlContext>
-#include <QtWebEngineQuick/qtwebenginequickglobal.h>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication::setOrganizationName("QtExamples");
- QtWebEngineQuick::initialize();
-
- QGuiApplication app(argc, argv);
-
- QQmlApplicationEngine engine;
- Utils utils;
-
- engine.rootContext()->setContextProperty("utils", &utils);
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
-
- return app.exec();
-}
diff --git a/examples/webenginequick/webengineaction/main.qml b/examples/webenginequick/webengineaction/main.qml
deleted file mode 100644
index d29181e23..000000000
--- a/examples/webenginequick/webengineaction/main.qml
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Window
-import QtWebEngine
-import QtQuick.Controls
-import QtQuick.Layouts
-
-ApplicationWindow {
- id: window
- visible: true
- width: 800
- height: 600
- title: qsTr("WebEngineAction Example")
-
- header: ToolBar {
- RowLayout {
- anchors.fill: parent
-
- ToolButton {
- property int itemAction: WebEngineView.Back
- text: webEngineView.action(itemAction).text
- enabled: webEngineView.action(itemAction).enabled
- onClicked: webEngineView.action(itemAction).trigger()
- icon.name: webEngineView.action(itemAction).iconName
- display: AbstractButton.TextUnderIcon
- }
-
- ToolButton {
- property int itemAction: WebEngineView.Forward
- text: webEngineView.action(itemAction).text
- enabled: webEngineView.action(itemAction).enabled
- onClicked: webEngineView.action(itemAction).trigger()
- icon.name: webEngineView.action(itemAction).iconName
- display: AbstractButton.TextUnderIcon
- }
-
- ToolButton {
- property int itemAction: webEngineView.loading ? WebEngineView.Stop : WebEngineView.Reload
- text: webEngineView.action(itemAction).text
- enabled: webEngineView.action(itemAction).enabled
- onClicked: webEngineView.action(itemAction).trigger()
- icon.name: webEngineView.action(itemAction).iconName
- display: AbstractButton.TextUnderIcon
- }
-
- TextField {
- Layout.fillWidth: true
-
- text: webEngineView.url
- selectByMouse: true
- onEditingFinished: webEngineView.url = utils.fromUserInput(text)
- }
-
- ToolButton {
- id: settingsButton
- text: "Settings"
- icon.name: "settings-configure"
- display: AbstractButton.TextUnderIcon
- onClicked: settingsMenu.open()
- checked: settingsMenu.visible
-
- Menu {
- id: settingsMenu
- y: settingsButton.height
-
- MenuItem {
- id: customContextMenuOption
- checkable: true
- checked: true
-
- text: "Custom context menu"
- }
- }
- }
- }
- }
-
- WebEngineView {
- id: webEngineView
- url: "https://qt.io"
- anchors.fill: parent
-
- Component.onCompleted: {
- profile.downloadRequested.connect(function(download){
- download.accept();
- })
- }
-
- property Menu contextMenu: Menu {
- Repeater {
- model: [
- WebEngineView.Back,
- WebEngineView.Forward,
- WebEngineView.Reload,
- WebEngineView.SavePage,
- WebEngineView.Copy,
- WebEngineView.Paste,
- WebEngineView.Cut,
- WebEngineView.ChangeTextDirectionLTR,
- WebEngineView.ChangeTextDirectionRTL,
- ]
- MenuItem {
- text: webEngineView.action(modelData).text
- enabled: webEngineView.action(modelData).enabled
- onClicked: webEngineView.action(modelData).trigger()
- icon.name: webEngineView.action(modelData).iconName
- display: MenuItem.TextBesideIcon
- }
- }
- }
-
- onContextMenuRequested: function(request) {
- if (customContextMenuOption.checked) {
- request.accepted = true;
- contextMenu.popup();
- }
- }
- }
-}
diff --git a/examples/webenginequick/webengineaction/qml.qrc b/examples/webenginequick/webengineaction/qml.qrc
deleted file mode 100644
index 5f6483ac3..000000000
--- a/examples/webenginequick/webengineaction/qml.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>main.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/webenginequick/webengineaction/utils.h b/examples/webenginequick/webengineaction/utils.h
deleted file mode 100644
index d9a803907..000000000
--- a/examples/webenginequick/webengineaction/utils.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef UTILS_H
-#define UTILS_H
-
-#include <QtCore/QFileInfo>
-#include <QtCore/QUrl>
-
-class Utils : public QObject
-{
- Q_OBJECT
-public:
- Q_INVOKABLE static QUrl fromUserInput(const QString &userInput);
-};
-
-inline QUrl Utils::fromUserInput(const QString &userInput)
-{
- QFileInfo fileInfo(userInput);
- if (fileInfo.exists())
- return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
- return QUrl::fromUserInput(userInput);
-}
-
-#endif // UTILS_H
diff --git a/examples/webenginequick/webengineaction/webengineaction.pro b/examples/webenginequick/webengineaction/webengineaction.pro
deleted file mode 100644
index 223109eb9..000000000
--- a/examples/webenginequick/webengineaction/webengineaction.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = app
-
-QT += webenginequick
-
-HEADERS += utils.h
-SOURCES += main.cpp
-
-RESOURCES += qml.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginequick/webengineaction
-INSTALLS += target
diff --git a/examples/webenginequick/webenginequick.pro b/examples/webenginequick/webenginequick.pro
index 9711ccb3a..acf6127d6 100644
--- a/examples/webenginequick/webenginequick.pro
+++ b/examples/webenginequick/webenginequick.pro
@@ -1,8 +1,7 @@
TEMPLATE=subdirs
SUBDIRS += \
- quicknanobrowser \
- webengineaction
+ quicknanobrowser
qtHaveModule(quickcontrols2) {
SUBDIRS += \