summaryrefslogtreecommitdiffstats
path: root/examples/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webenginewidgets')
-rw-r--r--examples/webenginewidgets/CMakeLists.txt33
-rw-r--r--examples/webenginewidgets/clientcertificate/CMakeLists.txt60
-rw-r--r--examples/webenginewidgets/clientcertificate/client.cpp67
-rw-r--r--examples/webenginewidgets/clientcertificate/client.pro10
-rw-r--r--examples/webenginewidgets/clientcertificate/clientcertificate.pro7
-rw-r--r--examples/webenginewidgets/clientcertificate/doc/images/granted.pngbin0 -> 5031 bytes
-rw-r--r--examples/webenginewidgets/clientcertificate/doc/images/selection.pngbin0 -> 6300 bytes
-rw-r--r--examples/webenginewidgets/clientcertificate/doc/src/clientcertificate.qdoc160
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/ca.pem24
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/client.key27
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/client.pem22
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/client.qrc6
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/server.key27
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/server.pem22
-rw-r--r--examples/webenginewidgets/clientcertificate/resources/server.qrc7
-rw-r--r--examples/webenginewidgets/clientcertificate/server.cpp99
-rw-r--r--examples/webenginewidgets/clientcertificate/server.pro11
-rw-r--r--examples/webenginewidgets/contentmanipulation/CMakeLists.txt18
-rw-r--r--examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc29
-rw-r--r--examples/webenginewidgets/contentmanipulation/main.cpp51
-rw-r--r--examples/webenginewidgets/contentmanipulation/mainwindow.cpp51
-rw-r--r--examples/webenginewidgets/contentmanipulation/mainwindow.h51
-rw-r--r--examples/webenginewidgets/cookiebrowser/3rdparty/qt_attribution.json20
-rw-r--r--examples/webenginewidgets/cookiebrowser/CMakeLists.txt17
-rw-r--r--examples/webenginewidgets/cookiebrowser/doc/src/cookiebrowser.qdoc29
-rw-r--r--examples/webenginewidgets/cookiebrowser/main.cpp51
-rw-r--r--examples/webenginewidgets/cookiebrowser/mainwindow.cpp67
-rw-r--r--examples/webenginewidgets/cookiebrowser/mainwindow.h55
-rw-r--r--examples/webenginewidgets/html2pdf/CMakeLists.txt15
-rw-r--r--examples/webenginewidgets/html2pdf/doc/src/html2pdf.qdoc29
-rw-r--r--examples/webenginewidgets/html2pdf/html2pdf.cpp59
-rw-r--r--examples/webenginewidgets/maps/CMakeLists.txt34
-rw-r--r--examples/webenginewidgets/maps/Info.cmake.macos.plist33
-rw-r--r--examples/webenginewidgets/maps/doc/src/maps.qdoc43
-rw-r--r--examples/webenginewidgets/maps/main.cpp51
-rw-r--r--examples/webenginewidgets/maps/mainwindow.cpp51
-rw-r--r--examples/webenginewidgets/maps/mainwindow.h51
-rw-r--r--examples/webenginewidgets/markdowneditor/CMakeLists.txt60
-rw-r--r--examples/webenginewidgets/markdowneditor/doc/images/markdowneditor-example.pngbin41883 -> 0 bytes
-rw-r--r--examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc183
-rw-r--r--examples/webenginewidgets/markdowneditor/document.cpp59
-rw-r--r--examples/webenginewidgets/markdowneditor/document.h73
-rw-r--r--examples/webenginewidgets/markdowneditor/main.cpp66
-rw-r--r--examples/webenginewidgets/markdowneditor/mainwindow.cpp189
-rw-r--r--examples/webenginewidgets/markdowneditor/mainwindow.h90
-rw-r--r--examples/webenginewidgets/markdowneditor/mainwindow.ui115
-rw-r--r--examples/webenginewidgets/markdowneditor/markdowneditor.pro32
-rw-r--r--examples/webenginewidgets/markdowneditor/previewpage.cpp64
-rw-r--r--examples/webenginewidgets/markdowneditor/previewpage.h66
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json35
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/default.md12
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/index.html32
-rw-r--r--examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc8
-rw-r--r--examples/webenginewidgets/minimal/CMakeLists.txt37
-rw-r--r--examples/webenginewidgets/minimal/doc/images/minimal-example.pngbin89294 -> 0 bytes
-rw-r--r--examples/webenginewidgets/minimal/doc/src/minimal.qdoc79
-rw-r--r--examples/webenginewidgets/minimal/main.cpp75
-rw-r--r--examples/webenginewidgets/minimal/minimal.pro8
-rw-r--r--examples/webenginewidgets/notifications/CMakeLists.txt18
-rw-r--r--examples/webenginewidgets/notifications/doc/src/notifications.qdoc29
-rw-r--r--examples/webenginewidgets/notifications/main.cpp51
-rw-r--r--examples/webenginewidgets/notifications/notificationpopup.h51
-rw-r--r--examples/webenginewidgets/printme/CMakeLists.txt20
-rw-r--r--examples/webenginewidgets/printme/data/data.qrc1
-rw-r--r--examples/webenginewidgets/printme/data/icon.svg24
-rw-r--r--examples/webenginewidgets/printme/data/index.html2
-rw-r--r--examples/webenginewidgets/printme/data/style.css104
-rw-r--r--examples/webenginewidgets/printme/doc/images/printme-example.pngbin42074 -> 29055 bytes
-rw-r--r--examples/webenginewidgets/printme/doc/src/printme.qdoc55
-rw-r--r--examples/webenginewidgets/printme/main.cpp51
-rw-r--r--examples/webenginewidgets/printme/printhandler.cpp82
-rw-r--r--examples/webenginewidgets/printme/printhandler.h56
-rw-r--r--examples/webenginewidgets/push-notifications/CMakeLists.txt46
-rw-r--r--examples/webenginewidgets/push-notifications/content/index.html26
-rw-r--r--examples/webenginewidgets/push-notifications/content/ping.js84
-rw-r--r--examples/webenginewidgets/push-notifications/content/style.css29
-rw-r--r--examples/webenginewidgets/push-notifications/content/worker.js7
-rw-r--r--examples/webenginewidgets/push-notifications/data/data.qrc (renamed from examples/webenginewidgets/webui/webui.qrc)2
-rw-r--r--examples/webenginewidgets/push-notifications/data/icon.pngbin0 -> 2252 bytes
-rw-r--r--examples/webenginewidgets/push-notifications/doc/images/notification.pngbin0 -> 1279 bytes
-rw-r--r--examples/webenginewidgets/push-notifications/doc/images/permissions.pngbin0 -> 4749 bytes
-rw-r--r--examples/webenginewidgets/push-notifications/doc/images/push-notifications.pngbin0 -> 10573 bytes
-rw-r--r--examples/webenginewidgets/push-notifications/doc/images/website.pngbin0 -> 7539 bytes
-rw-r--r--examples/webenginewidgets/push-notifications/doc/src/push-notifications.qdoc203
-rw-r--r--examples/webenginewidgets/push-notifications/doc/src/push-notifications.qmodel837
-rw-r--r--examples/webenginewidgets/push-notifications/main.cpp41
-rw-r--r--examples/webenginewidgets/push-notifications/notificationpopup.h91
-rw-r--r--examples/webenginewidgets/push-notifications/push-notifications.pro10
-rw-r--r--examples/webenginewidgets/push-notifications/server.js65
-rw-r--r--examples/webenginewidgets/recipebrowser/CMakeLists.txt76
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKDOWN-LICENSE.txt (renamed from examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKDOWN-LICENSE.txt)0
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKED-LICENSE.txt (renamed from examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt)0
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/3rdparty/markdown.css (renamed from examples/webenginewidgets/markdowneditor/resources/3rdparty/markdown.css)0
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/3rdparty/marked.js (renamed from examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js)0
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/3rdparty/qt_attribution.json34
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/custom.css28
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/custom.js13
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/icons/add.svg4
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/icons/edit.svg4
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/icons/remove.svg4
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/icons/stylesheets.svg4
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/icons/view.svg4
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/burger.html96
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/cupcakes.html75
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/burger.jpgbin0 -> 48882 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/cupcakes.jpgbin0 -> 38653 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/pasta.jpgbin0 -> 42411 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/pizza.jpgbin0 -> 49068 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/skewers.jpgbin0 -> 49246 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/soup.jpgbin0 -> 49028 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/images/steak.jpgbin0 -> 49202 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/pasta.html78
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/pizza.html69
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/skewers.html74
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/soup.html63
-rw-r--r--examples/webenginewidgets/recipebrowser/assets/pages/steak.html88
-rw-r--r--examples/webenginewidgets/recipebrowser/doc/images/recipebrowser.webpbin0 -> 31140 bytes
-rw-r--r--examples/webenginewidgets/recipebrowser/doc/src/recipebrowser.qdoc197
-rw-r--r--examples/webenginewidgets/recipebrowser/document.cpp48
-rw-r--r--examples/webenginewidgets/recipebrowser/document.h36
-rw-r--r--examples/webenginewidgets/recipebrowser/main.cpp18
-rw-r--r--examples/webenginewidgets/recipebrowser/mainwindow.cpp154
-rw-r--r--examples/webenginewidgets/recipebrowser/mainwindow.h44
-rw-r--r--examples/webenginewidgets/recipebrowser/mainwindow.ui116
-rw-r--r--examples/webenginewidgets/recipebrowser/recipebrowser.pro (renamed from examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro)12
-rw-r--r--examples/webenginewidgets/recipebrowser/recipebrowser.qrc27
-rw-r--r--examples/webenginewidgets/recipebrowser/stylesheetdialog.cpp (renamed from examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp)72
-rw-r--r--examples/webenginewidgets/recipebrowser/stylesheetdialog.h39
-rw-r--r--examples/webenginewidgets/recipebrowser/stylesheetdialog.ui (renamed from examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui)12
-rw-r--r--examples/webenginewidgets/simplebrowser/CMakeLists.txt47
-rw-r--r--examples/webenginewidgets/simplebrowser/Info.cmake.macos.plist36
-rw-r--r--examples/webenginewidgets/simplebrowser/browser.cpp68
-rw-r--r--examples/webenginewidgets/simplebrowser/browser.h52
-rw-r--r--examples/webenginewidgets/simplebrowser/browserwindow.cpp131
-rw-r--r--examples/webenginewidgets/simplebrowser/browserwindow.h70
-rw-r--r--examples/webenginewidgets/simplebrowser/data/3rdparty/qt_attribution.json20
-rw-r--r--examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc67
-rw-r--r--examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp52
-rw-r--r--examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h53
-rw-r--r--examples/webenginewidgets/simplebrowser/downloadwidget.cpp80
-rw-r--r--examples/webenginewidgets/simplebrowser/downloadwidget.h51
-rw-r--r--examples/webenginewidgets/simplebrowser/main.cpp67
-rw-r--r--examples/webenginewidgets/simplebrowser/simplebrowser.exe.manifest17
-rw-r--r--examples/webenginewidgets/simplebrowser/simplebrowser.pro14
-rw-r--r--examples/webenginewidgets/simplebrowser/tabwidget.cpp61
-rw-r--r--examples/webenginewidgets/simplebrowser/tabwidget.h53
-rw-r--r--examples/webenginewidgets/simplebrowser/webauthdialog.cpp294
-rw-r--r--examples/webenginewidgets/simplebrowser/webauthdialog.h41
-rw-r--r--examples/webenginewidgets/simplebrowser/webauthdialog.ui151
-rw-r--r--examples/webenginewidgets/simplebrowser/webpage.cpp82
-rw-r--r--examples/webenginewidgets/simplebrowser/webpage.h55
-rw-r--r--examples/webenginewidgets/simplebrowser/webpopupwindow.cpp51
-rw-r--r--examples/webenginewidgets/simplebrowser/webpopupwindow.h53
-rw-r--r--examples/webenginewidgets/simplebrowser/webview.cpp232
-rw-r--r--examples/webenginewidgets/simplebrowser/webview.h71
-rw-r--r--examples/webenginewidgets/spellchecker/CMakeLists.txt50
-rw-r--r--examples/webenginewidgets/spellchecker/data/icon.svg24
-rw-r--r--examples/webenginewidgets/spellchecker/data/index.html47
-rw-r--r--examples/webenginewidgets/spellchecker/data/spellchecker.qrc1
-rw-r--r--examples/webenginewidgets/spellchecker/data/style.css145
-rw-r--r--examples/webenginewidgets/spellchecker/doc/images/spellchecker-example.pngbin15978 -> 28507 bytes
-rw-r--r--examples/webenginewidgets/spellchecker/doc/src/spellchecker.qdoc29
-rw-r--r--examples/webenginewidgets/spellchecker/main.cpp53
-rw-r--r--examples/webenginewidgets/spellchecker/spellchecker.pro5
-rw-r--r--examples/webenginewidgets/spellchecker/webview.cpp51
-rw-r--r--examples/webenginewidgets/spellchecker/webview.h51
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/3rdparty/COPYING1
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/3rdparty/qt_attribution.json24
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/3rdparty/view-refresh.pngbin1364 -> 0 bytes
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/CMakeLists.txt54
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.pngbin45161 -> 0 bytes
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc68
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/main.cpp65
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp169
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/mainwindow.h87
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/mainwindow.ui133
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc5
-rw-r--r--examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h86
-rw-r--r--examples/webenginewidgets/videoplayer/CMakeLists.txt18
-rw-r--r--examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc29
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreennotification.cpp51
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreennotification.h51
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreenwindow.cpp51
-rw-r--r--examples/webenginewidgets/videoplayer/fullscreenwindow.h51
-rw-r--r--examples/webenginewidgets/videoplayer/main.cpp51
-rw-r--r--examples/webenginewidgets/videoplayer/mainwindow.cpp51
-rw-r--r--examples/webenginewidgets/videoplayer/mainwindow.h51
-rw-r--r--examples/webenginewidgets/webenginewidgets.pro21
-rw-r--r--examples/webenginewidgets/webui/CMakeLists.txt51
-rw-r--r--examples/webenginewidgets/webui/about.html129
-rw-r--r--examples/webenginewidgets/webui/doc/images/webui-example.pngbin28862 -> 0 bytes
-rw-r--r--examples/webenginewidgets/webui/doc/src/webui.qdoc165
-rw-r--r--examples/webenginewidgets/webui/main.cpp81
-rw-r--r--examples/webenginewidgets/webui/webui.pro16
-rw-r--r--examples/webenginewidgets/webui/webuihandler.cpp98
-rw-r--r--examples/webenginewidgets/webui/webuihandler.h70
196 files changed, 4843 insertions, 5453 deletions
diff --git a/examples/webenginewidgets/CMakeLists.txt b/examples/webenginewidgets/CMakeLists.txt
index 651a01344..3ce666d72 100644
--- a/examples/webenginewidgets/CMakeLists.txt
+++ b/examples/webenginewidgets/CMakeLists.txt
@@ -1,21 +1,26 @@
-add_subdirectory(minimal)
-add_subdirectory(contentmanipulation)
-add_subdirectory(cookiebrowser)
-add_subdirectory(notifications)
-add_subdirectory(simplebrowser)
-add_subdirectory(stylesheetbrowser)
-add_subdirectory(videoplayer)
-add_subdirectory(webui)
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+qt_internal_add_example(contentmanipulation)
+qt_internal_add_example(cookiebrowser)
+qt_internal_add_example(notifications)
+qt_internal_add_example(simplebrowser)
+qt_internal_add_example(push-notifications)
+qt_internal_add_example(videoplayer)
if(QT_FEATURE_webengine_geolocation)
- add_subdirectory(maps)
+ qt_internal_add_example(maps)
endif()
if(QT_FEATURE_webengine_webchannel)
- add_subdirectory(markdowneditor)
+ qt_internal_add_example(recipebrowser)
endif()
if(QT_FEATURE_webengine_printing_and_pdf)
- add_subdirectory(printme)
- add_subdirectory(html2pdf)
+ qt_internal_add_example(printme)
+ qt_internal_add_example(html2pdf)
endif()
-if(QT_FEATURE_webengine_spellchecker AND NOT CMAKE_CROSSCOMPILING AND NOT QT_FEATURE_webengine_native_spellchecker)
- add_subdirectory(spellchecker)
+if(QT_FEATURE_webengine_spellchecker AND NOT CMAKE_CROSSCOMPILING
+ AND NOT QT_FEATURE_webengine_native_spellchecker AND NOT WIN32)
+ qt_internal_add_example(spellchecker)
+endif()
+if(QT_FEATURE_ssl)
+ qt_internal_add_example(clientcertificate)
endif()
diff --git a/examples/webenginewidgets/clientcertificate/CMakeLists.txt b/examples/webenginewidgets/clientcertificate/CMakeLists.txt
new file mode 100644
index 000000000..97c9393ff
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/CMakeLists.txt
@@ -0,0 +1,60 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(clientcertificate LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/clientcertificate")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
+
+qt_add_executable(server
+ server.cpp
+)
+
+qt_add_executable(client
+ client.cpp
+)
+
+set_target_properties(client PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+qt_add_resources(client "client"
+ PREFIX
+ "/"
+ FILES
+ "resources/client.pem"
+ "resources/client.key"
+)
+
+qt_add_resources(server "server"
+ PREFIX
+ "/"
+ FILES
+ "resources/server.pem"
+ "resources/server.key"
+ "resources/ca.pem"
+)
+
+target_link_libraries(client PUBLIC
+ Qt::WebEngineWidgets
+)
+
+target_link_libraries(server PUBLIC
+ Qt::Core
+ Qt::Network
+)
+
+install(TARGETS server client
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/webenginewidgets/clientcertificate/client.cpp b/examples/webenginewidgets/clientcertificate/client.cpp
new file mode 100644
index 000000000..1227fa28e
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/client.cpp
@@ -0,0 +1,67 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/qfile.h>
+#include <QtNetwork/qsslkey.h>
+#include <QtWebEngineCore/qwebenginecertificateerror.h>
+#include <QtWebEngineCore/qwebengineclientcertificatestore.h>
+#include <QtWebEngineCore/qwebengineprofile.h>
+#include <QtWebEngineCore/qwebenginepage.h>
+#include <QtWebEngineWidgets/qwebengineview.h>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qdialog.h>
+#include <QtWidgets/qlabel.h>
+#include <QtWidgets/qlistwidget.h>
+#include <QtWidgets/qpushbutton.h>
+#include <QtWidgets/qboxlayout.h>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setOrganizationName("QtExamples");
+ QApplication app(argc, argv);
+
+ QFile certFile(":/resources/client.pem");
+ certFile.open(QIODevice::ReadOnly);
+ const QSslCertificate cert(certFile.readAll(), QSsl::Pem);
+
+ QFile keyFile(":/resources/client.key");
+ keyFile.open(QIODevice::ReadOnly);
+ const QSslKey sslKey(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "");
+
+ QWebEngineProfile::defaultProfile()->clientCertificateStore()->add(cert, sslKey);
+
+ QWebEnginePage page;
+ QObject::connect(&page, &QWebEnginePage::certificateError,
+ [](QWebEngineCertificateError e) { e.acceptCertificate(); });
+
+ QObject::connect(
+ &page, &QWebEnginePage::selectClientCertificate, &page,
+ [&cert](QWebEngineClientCertificateSelection selection) {
+ QDialog dialog;
+ QVBoxLayout *layout = new QVBoxLayout;
+ QLabel *label = new QLabel(QLatin1String("Select certificate"));
+ QListWidget *listWidget = new QListWidget;
+ listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+ QPushButton *button = new QPushButton(QLatin1String("Select"));
+ layout->addWidget(label);
+ layout->addWidget(listWidget);
+ layout->addWidget(button);
+ QObject::connect(button, &QPushButton::clicked, [&dialog]() { dialog.accept(); });
+ const QList<QSslCertificate> &list = selection.certificates();
+ for (const QSslCertificate &cert : list) {
+ listWidget->addItem(cert.subjectDisplayName() + " : " + cert.serialNumber());
+ }
+ dialog.setLayout(layout);
+ if (dialog.exec() == QDialog::Accepted)
+ selection.select(list[listWidget->currentRow()]);
+ else
+ selection.selectNone();
+ });
+
+ QWebEngineView view(&page);
+ view.setUrl(QUrl("https://localhost:5555"));
+ view.resize(800, 600);
+ view.show();
+
+ return app.exec();
+}
diff --git a/examples/webenginewidgets/clientcertificate/client.pro b/examples/webenginewidgets/clientcertificate/client.pro
new file mode 100644
index 000000000..e397d5efa
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/client.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += webenginewidgets
+
+SOURCES += client.cpp
+
+RESOURCES += resources/client.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/clientcertificate/client
+INSTALLS += target
diff --git a/examples/webenginewidgets/clientcertificate/clientcertificate.pro b/examples/webenginewidgets/clientcertificate/clientcertificate.pro
new file mode 100644
index 000000000..66039d05c
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/clientcertificate.pro
@@ -0,0 +1,7 @@
+QT_FOR_CONFIG += network-private
+TEMPLATE = subdirs
+
+client.file = client.pro
+server.file = server.pro
+
+qtConfig(ssl): SUBDIRS += client server
diff --git a/examples/webenginewidgets/clientcertificate/doc/images/granted.png b/examples/webenginewidgets/clientcertificate/doc/images/granted.png
new file mode 100644
index 000000000..b2def9b5e
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/doc/images/granted.png
Binary files differ
diff --git a/examples/webenginewidgets/clientcertificate/doc/images/selection.png b/examples/webenginewidgets/clientcertificate/doc/images/selection.png
new file mode 100644
index 000000000..2756ac7be
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/doc/images/selection.png
Binary files differ
diff --git a/examples/webenginewidgets/clientcertificate/doc/src/clientcertificate.qdoc b/examples/webenginewidgets/clientcertificate/doc/src/clientcertificate.qdoc
new file mode 100644
index 000000000..c5440f08f
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/doc/src/clientcertificate.qdoc
@@ -0,0 +1,160 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example webenginewidgets/clientcertificate
+ \examplecategory {Web Technologies}
+ \title WebEngine Widgets Client Certificate Example
+ \ingroup webengine-widgetexamples
+ \brief A simple client certificate authentication scenario using \QWE and \l QSslServer.
+
+ \image selection.png
+
+ In this example we are going to show a client certificate authentication workflow.
+ The presented authentication scenario can be for example implemented
+ for an embedded device, which provides a web interface to handle its functionality.
+ The administrator uses the \QWE powered client to maintain the embedded device
+ and has a custom SSL certificate to authenticate.
+ The connection is encrypted with SSL sockets. The embedded device uses
+ a \c QSslSocket to handle the authentication and the encryption. This way the
+ administrator does not have to enter any credentials and just needs to select
+ a proper certificate that is recognized by the device.
+
+ In the example we focus on a very simple and minimalistic approach to demonstrate
+ the workflow. Note that QSslSocket is a low level solution as we do not have to
+ run a full-blown HTTPS server on the resource limited embedded device.
+
+ \section1 Creating Certificates
+
+ The example comes with certificates already generated, but let's see how to generate
+ new ones. We create certificates for the server and the client using
+ \l{https://www.openssl.org}{OpenSSL tooling}.
+
+ First, we create the certificate signing request \c CSR and sign it. We will use
+ a CA private key to sign and issue both local certificates for the client and the server.
+
+ \badcode
+ openssl req -out ca.pem -new -x509 -nodes -keyout ca.key
+ \endcode
+
+ \note Specify the \c {-days} option to override the default certificate validity of 30 days.
+
+ Now, let's create two private keys for our client and a server:
+
+ \badcode
+ openssl genrsa -out client.key 2048
+ \endcode
+ \badcode
+ openssl genrsa -out server.key 2048
+ \endcode
+
+ Next we need two certificate signing requests:
+
+ \badcode
+ openssl req -key client.key -new -out client.req
+ \endcode
+ \badcode
+ openssl req -key server.key -new -out server.req
+ \endcode
+
+ Let's issue now both certificates from CSRs:
+
+ \badcode
+ openssl x509 -req -in client.req -out client.pem -CA ca.pem -CAkey ca.key
+ \endcode
+ \badcode
+ openssl x509 -req -in server.req -out server.pem -CA ca.pem -CAkey ca.key
+ \endcode
+
+ The client certificate subject and the serial number will be displayed for
+ selection during authentication. The serial number can be printed with:
+
+ \badcode
+ openssl x509 -serial -noout -in client.pem
+ \endcode
+
+ \section1 Implementing the Client
+
+ Now we can implement our web browser client.
+
+ We start by loading our certificate and its private key and creating \l QSslCertificate
+ and \l QSslKey instances.
+
+
+ \quotefromfile webenginewidgets/clientcertificate/client.cpp
+ \skipto QFile
+ \printuntil QSslKey
+
+ Now we add the certificate and its private key to \l {QWebEngineClientCertificateStore}.
+
+ \printuntil clientCertificateStore
+
+ To handle certificates we need to create an instance of \l QWebEnginePage and connect to two
+ singals \l QWebEnginePage::certificateError and \l QWebEnginePage::selectClientCertificate.
+ The first one is only needed as our self-signed server certificate will trigger a certificate
+ error, which has to be accepted to proceed with the authentication. In production
+ environments self-signed certificates are not used, therefore in this example we handle
+ \l QWebEngineCertificateError just to avoid providing proper certificates.
+ Note the private key is a secret and should never be published.
+
+ \printuntil acceptCertificate
+
+ The handling for \l QWebEnginePage::selectClientCertificate simply displays \l QDialog
+ with \l QListWidget showing a list of client certificates to choose from.
+ The user selected certificate is then passed to the
+ \l QWebEngineClientCertificateSelection::select call.
+
+ \printto QWebEngineView
+
+ Finally, we create a \l QWebEngineView for our \l QWebEnginePage, load the server
+ URL, and show the page.
+
+ \printuntil show
+
+ \section1 Implementing the Server
+
+ For our embedded device we will develop a minimalistic HTTPS server. We can use \l QSslServer
+ to handle incoming connections and to provide an \l QSslSocket instance. To do that,
+ we create an instance of a \l QSslServer and, similarly to our client setup, we load a server
+ certificate and its private key. Next, we create \l QSslCertificate and \l QSslKey objects
+ accordingly. Additionally, we need a CA certificate so the server can validate the certificate
+ presented by the client. The CA and local certificate are set to \l QSslConfiguration and
+ used later by the server.
+
+ \quotefromfile webenginewidgets/clientcertificate/server.cpp
+ \skipto QSslServer
+ \printuntil setSslConfiguration
+
+ Next, we set the server to listen for incoming connections on port \c 5555
+
+ \printuntil qInfo
+
+ We provide a lambda function for the \l QTcpServer::pendingConnectionAvailable signal,
+ where we implement handling for incoming connections. This signal is triggered
+ after authentication has succeeded and \c socket TLS encryption has started.
+
+ \printto readyRead
+
+ The \c Request object used above is a simple wrapper around \l QByteArray as we use
+ \l QPointer to help with memory management. This object gathers incoming HTTP data.
+ It is deleted when the request has completed or a socket has been terminated.
+
+ \quotefromfile webenginewidgets/clientcertificate/server.cpp
+ \skipto struct
+ \printuntil };
+
+ The reply for the request depends on the requested URL, and it is sent back through
+ the socket in form of a HTML page. For the \c GET root request the administrator sees
+ the \c {Access Granted} message and an \c {Exit} HTML button. If the administrator clicks it,
+ the client sends another request. This time with the \c{/exit} relative URL,
+ which it turn triggers the server termination.
+
+ \quotefromfile webenginewidgets/clientcertificate/server.cpp
+ \skipto readyRead
+ \printuntil });
+
+ To run the example, start the \c server and then the \c client. After you select
+ the certificate, the \c {Access Granted} page is displayed.
+
+ \image granted.png
+*/
diff --git a/examples/webenginewidgets/clientcertificate/resources/ca.pem b/examples/webenginewidgets/clientcertificate/resources/ca.pem
new file mode 100644
index 000000000..cb62ad62c
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/ca.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIECzCCAvOgAwIBAgIUdhDW1WgGxF313LYA0JjEQpKbanQwDQYJKoZIhvcNAQEL
+BQAwgZQxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJl
+cmxpbjEXMBUGA1UECgwOVGhlIFF0IENvbXBhbnkxFDASBgNVBAsMC1F0V2ViRW5n
+aW5lMRIwEAYDVQQDDAl3d3cucXQuaW8xIDAeBgkqhkiG9w0BCQEWEXF0d2ViZW5n
+aW5lQHF0LmlvMB4XDTIyMTExNjExMDQxNFoXDTMyMTExMzExMDQxNFowgZQxCzAJ
+BgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xDzANBgNVBAcMBkJlcmxpbjEXMBUG
+A1UECgwOVGhlIFF0IENvbXBhbnkxFDASBgNVBAsMC1F0V2ViRW5naW5lMRIwEAYD
+VQQDDAl3d3cucXQuaW8xIDAeBgkqhkiG9w0BCQEWEXF0d2ViZW5naW5lQHF0Lmlv
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxyNLLwAA+FgNQavVJ19n
+gdoy+NKLHQyhzcRFykKSp9aAbpAR6e4ukxwG7mWNBcuR7zv1Zw/JqLFE0gmVztVw
+FeQWdw1cvTN/OlVEuM+0ShTDHHsCqRpx7/XJT6ytMKVU8jdZN4Vl1m7MubWv4aPy
+0WYYd3zIAicciYgy/RHaRhPTKpPzWIPYhmHsM5w2cebL8I0aZXUkC0OeklJArnp9
+007Fr6SXXK0xQ3RO20n7X193gCfd5U70lug0ks/ZZqxtzPHmzIO1WGAOBura50HR
+hxUKAu7qQHzBiW5Qwdn0af4FPLJR/SX8ADKTLCSWlMOo1FLYO5w6D8hB4K6/b9VQ
+RwIDAQABo1MwUTAdBgNVHQ4EFgQUXuTuB85/iBgwJpLdOc+8TB0KESIwHwYDVR0j
+BBgwFoAUXuTuB85/iBgwJpLdOc+8TB0KESIwDwYDVR0TAQH/BAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAvtucUJa0IECltWv8U6R+LQuZ1Q+ubbmstojO/h8tg6Wf
+v6FZ5bH3oboSyGEcytRr6INf4G6znUNAypbodehAEW6/PETdzGM9CJyv2JPJAWzV
+rxb1H5VTyiEs8924QOqcNATD+oe7G0vwnDkvprcqaWBA6yvQkWpCXoqMc+F95KnY
+8VFt2VQw17l4L4nhaX3Us6hJLMiKV+dLeF0pN+pkCPRP9G5WKgW3mT2U6Gig+rLz
+6L7rBbb5KWAttdAbuHCrMa65PgXoVD1P/GteFxUnghDd0PWgUaign8c/DyHGsrbA
+uvJqSym0kmQQXptryRaKFsGcCrizdbE6FfrH2iE7vQ==
+-----END CERTIFICATE-----
diff --git a/examples/webenginewidgets/clientcertificate/resources/client.key b/examples/webenginewidgets/clientcertificate/resources/client.key
new file mode 100644
index 000000000..21c8e3183
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/client.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEAqnHbq38y1VprEaV2xXzv2nAPyjqCuIfuick8qETkzEsNWPQi
+dsBlLfcyf+15wEMhpRIwILXCrUM7Sb7WCGtg1XC00JZvCh2xPBMSD2fiQyHn4men
+Fwh9vVbTf1v7w21ZT/pXQrwlgLgNWYZHE3JrcEAwlThQRIdQfzSE6/QeHfYZoGB9
+WfvbREsOWiUlZze/yrblS9vnAVhYwVurelc7lXyHA0dHmkcZ0HwMxVJZ/vLuCyIw
+lNGT/ytnA9p1l8uFkAgTcbWZKoyJAsAZG9faZp46hk8+e3KAyKQ78aoUSbjAqnNQ
+tBM3bnHeHanf3ddCxyej+k9PfSIY27a9FZxHpQIDAQABAoIBAFsomA8p8ZsQR9Fh
+SJupDXMrmhZTotRkxxxkR4/LgP8OaO4ZbFFM5xBldFndPc+pV9Y8WwczjxIxsgTo
+Dvrjyx98rwgcXPjxFniFzpP0wJudB7McMs5r2SwpwuYL4SQNWMYgowjrLbehOGqY
+GW16NaIMgq9cNfng0RmnkivMHUtyE5GGdK+C6cyK+fIE+cNtQtHPRKfEnwbE9VHz
+3EY/nCXGZvMFyj5uHaU4EeZFCzo19TUqhh8H7b0EA44pBtb5U/CxsH4xphZ7rpjt
+iVjMfRSMR4qalQNIs6ZEj57We+M/zca/Qq1yhjW+0NYbZifcYo1Oj6e4lC9YlIgn
+kGkcuUECgYEA1j0iVFjgBXS8pJP3jBgmbrbBBTNEUv27yjnJCAQx5TbplJkvBM4/
+qzum1uH2o6uRrFtrYJFiAhDHARtg+70rMeYqZp8WFvzJT5c5s+FOmGQPfFjgrD6e
+wfnCwFzS7nohJ8TM2mPGJ88pBv0eBYW6D0f7fvcJmEk8hnGktdLRCrECgYEAy6tU
+YFZDzGhbgrG2wWzBvAKVngUNhrYZHMiF1WVN8zZdCm7Z8b1S/NMe0rPA5orhAkSX
+8fxlDfKOm+U2fKp43aiN0NDiP0TlGRbypAXe7FSnvDxNHbV+Ie0UbwuiJ4s3vJuc
+6cdzgKqAs5/rjPXPdUpM8C7344HV7azgSzHIYTUCgYAtVmCmcuxtmye0uG+BoTa4
+5UnxvMivu2x7PkFRxfl9JWLHBKfTn4YPyZ7kCIu2VT+NtwcBN6MDBuPmUxHyFDVI
+6Ql+EBqPoM1FX55hd8O3Mi2oxfI94T6dlCpnpP0qZIQRs28apFSx5gArr3Mj/gnC
+5BvP4Z2RMaZyWShfJg8A8QKBgQClZEhswyDjiYtmorJqeMsKxn6BiFDnqFDUUvJ7
+zHx0mR0NL9/Es54Eud059ccccIMwuEs7s17M6MBuUMDik/z647nmbPqNroDs0vnP
+wQS6njRoY/+rtIrtOf1x/9x6iE+G1keigNmHDu7c72z1V1hVQzUfhsS+99yl2dF6
+vr6eUQKBgF/OHW1bE3FruZ+53Arcb94N/IKnpH9VWoB3elIzr0w6pLtL4HHhmQ58
+TayEpq6YguUAjTvCBbaHuYuKPHiXCAy5DhtrXvP4YdMNH9X1nHc7jVEbGltVbnQU
+bG/p5YfZSrDmsjf8w0z7feFOcovC6vF1YCXc8OHK/LQ6JFJ/gtO1
+-----END RSA PRIVATE KEY-----
diff --git a/examples/webenginewidgets/clientcertificate/resources/client.pem b/examples/webenginewidgets/clientcertificate/resources/client.pem
new file mode 100644
index 000000000..dd1f898f7
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/client.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDrzCCApcCFFNQAgGBu5nr81tUMdXXLGkm8Li+MA0GCSqGSIb3DQEBCwUAMIGU
+MQswCQYDVQQGEwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4x
+FzAVBgNVBAoMDlRoZSBRdCBDb21wYW55MRQwEgYDVQQLDAtRdFdlYkVuZ2luZTES
+MBAGA1UEAwwJd3d3LnF0LmlvMSAwHgYJKoZIhvcNAQkBFhFxdHdlYmVuZ2luZUBx
+dC5pbzAeFw0yMjExMTYxMjExMDFaFw0zMjExMTMxMjExMDFaMIGSMQswCQYDVQQG
+EwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xFzAVBgNVBAoM
+DlRoZSBRdCBDb21wYW55MRQwEgYDVQQLDAtRdFdlYkVuZ2luZTEVMBMGA1UEAwwM
+Y2xpZW50LnF0LmlvMRswGQYJKoZIhvcNAQkBFgxjbGllbnRAcXQuaW8wggEiMA0G
+CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqcdurfzLVWmsRpXbFfO/acA/KOoK4
+h+6JyTyoROTMSw1Y9CJ2wGUt9zJ/7XnAQyGlEjAgtcKtQztJvtYIa2DVcLTQlm8K
+HbE8ExIPZ+JDIefiZ6cXCH29VtN/W/vDbVlP+ldCvCWAuA1ZhkcTcmtwQDCVOFBE
+h1B/NITr9B4d9hmgYH1Z+9tESw5aJSVnN7/KtuVL2+cBWFjBW6t6VzuVfIcDR0ea
+RxnQfAzFUln+8u4LIjCU0ZP/K2cD2nWXy4WQCBNxtZkqjIkCwBkb19pmnjqGTz57
+coDIpDvxqhRJuMCqc1C0Ezducd4dqd/d10LHJ6P6T099Ihjbtr0VnEelAgMBAAEw
+DQYJKoZIhvcNAQELBQADggEBALE75ZQxmEXJA16cNAxxmxCKHkaqAE6Ulim1vXNH
+jCFfNCDGYn/R28F3BVtMe+bIMoomaTh3h5eOd/9uc2nm8IiT5FUz9epJWPeRG/cl
+I+hQ3fvaE7oJ3m3EwfGq1mdqUf1zi+DFjtkimNbn9ZRDocZfpO5VN0u23ptEuk0P
+5cH4+Dst0giRMv5W0kXG6QD13H/eVH3jDZCtZa/8T4oxGGskHEa4yDr8s976lVOV
+XLI1r7oN4a/KXKow8WN3oHFeKn4QJx86z1uecuZLtT8xjABKSWpZqgsIlmGTGE1a
+9W06C+uPVamwn5ND3gnf93YQqn6PwrjlHdrQOTG/vngJLPw=
+-----END CERTIFICATE-----
diff --git a/examples/webenginewidgets/clientcertificate/resources/client.qrc b/examples/webenginewidgets/clientcertificate/resources/client.qrc
new file mode 100644
index 000000000..cc3492e80
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/client.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/resources">
+ <file>client.key</file>
+ <file>client.pem</file>
+ </qresource>
+</RCC>
diff --git a/examples/webenginewidgets/clientcertificate/resources/server.key b/examples/webenginewidgets/clientcertificate/resources/server.key
new file mode 100644
index 000000000..632cc4d2e
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/server.key
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEowIBAAKCAQEA5gQoJryenjmvzy4RbqHdNXHK8Gk/8Lto1SwT8+Wbh5EyYRTt
+hFdioT1JYcIe3XMwOmx3TjADY1jAXAPfeRcjTkMcnZwF76AXUK2XqBANhaG1wjsi
+b7ISGU/U5/Jarm2iwQJ5zjKsNm8pZYqpmKsYAVFMErtfcpdLdSp6BG54SrbItcXh
+WHfsUs5cuVEi9nCeugLkDzoPLlj/TeouKWOdzhyvLXkPvPmD4/hD0dULTXpCDZhf
+73AuQBWTGsWeUnJQiQhDRwuXWhGRX8qFJQ4rzY8rIbaKhge+BQ6BL+pij2uzHKNQ
+j12ZLFZgLihLDJogGp08y9Ud6Ru/3WGoFkY38wIDAQABAoIBABM/TczQA8XhteB0
+Tmkfik8qknzDkeInDIKqCZFjKTyS3dBZ2/YzCcHMSxOvFr4ZIXQCF4mnYuExUAdj
+G5QaZ43o98AIikae8tSBcitSDI+eFIOIRz1pfTI5B+vQz93AttnHx0GF4/s6GhCx
+JbfsuTmDAAahPz9rgZjwUP2F8PLvaAZqJrXBPY+QLWz0SN2zh6vWAHPbJA0sO/4E
+oWUhRPXJDf33YCFxnwtbUBie5313suAfNspODcyH+AxBH2FFh63pe0ZGOhX7XFMJ
+yxJqujeZrQdfwFZNPXAPVLJGbd7AIOrVE+O8/bYUB/uuj6pPJBqr+Ob/JhY48pRb
+VG2qL4ECgYEA9n3PuL13F9XFcLeergGH7fUcSQeD1T6Z1qaI2Wth0Umfmer/fFZh
+IKSCSwEGMTLsalFdlTj8jsSAasjuSorQTeSgHjzvzik1Ll2P6syputjsD1RX/nkl
+8L50Pwdeey57Y9dgow7Cw/heGYs6dkXLe9H6qM7eoB8Vrk7/TAFuqNECgYEA7uOl
+oKyOxeLn005cenc5enY2IxDhXTaAjTGHE64C0lmicD2OZB7/b+ZIb8M5R7GnCNox
+4TxLSRhZYOMO/QcTrnSND5PXbX/HLd3nyQRIN1XtBbg7pJooxP/MQ/Ne5XTTMjCg
+qPudkOe0ZgUHEcuH8m/YAFY3DDJC50uiXqYtxYMCgYBHfL+ExbZHfGExyp9Duf/x
+PHhCmeJbMzessEnaPLF24FJgcm48YlTzAaMkG5zvIeS9BPIOOCPPSCAyWCn8BnxZ
+SuhBPM0TzpG067+0ijzjiswTuhN3Iy2kv6e5K+rz8MwqbamCQOKtsVehMub2rFFS
+jNiUosKgT8Oa9SBHq9arMQKBgQCE3EVEnFP3iOAILH/QeLiV/GLVk9DTR7mtTUtj
+zZayKLnoFMQ5uOe182x8BCa6UfqlOL0fGKqCZ7Fl6kJuxV3T2+yMKlxZAQTk5JLB
+wMjtRbPCR5mcTUS5c87GR/eSRCwlsNfZw775VXSGfOtWoUzlsACBB3IsLVP6UZ1n
+aKLyQwKBgC61BvKiyGBEYIchqMI4dSF+zCJbSjNUtjwVobcgC6yERZtX2OeLFCoh
+NEf9CcL2Eqb+RzwAD3OV65AiZcrThQNXZ8poBxvwWK8I6E6zB+LX7POAvNu/AV/5
+ANnxwHGGLqi+wTcdMZal2iXkdsrno1Ek/nGMCdA7IVs7l5k7fEpG
+-----END RSA PRIVATE KEY-----
diff --git a/examples/webenginewidgets/clientcertificate/resources/server.pem b/examples/webenginewidgets/clientcertificate/resources/server.pem
new file mode 100644
index 000000000..4706fa73e
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/server.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDrzCCApcCFFNQAgGBu5nr81tUMdXXLGkm8Li/MA0GCSqGSIb3DQEBCwUAMIGU
+MQswCQYDVQQGEwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4x
+FzAVBgNVBAoMDlRoZSBRdCBDb21wYW55MRQwEgYDVQQLDAtRdFdlYkVuZ2luZTES
+MBAGA1UEAwwJd3d3LnF0LmlvMSAwHgYJKoZIhvcNAQkBFhFxdHdlYmVuZ2luZUBx
+dC5pbzAeFw0yMjExMTYxMjExMTRaFw0zMjExMTMxMjExMTRaMIGSMQswCQYDVQQG
+EwJERTEPMA0GA1UECAwGQmVybGluMQ8wDQYDVQQHDAZCZXJsaW4xFzAVBgNVBAoM
+DlRoZSBRdCBDb21wYW55MRQwEgYDVQQLDAtRdFdlYkVuZ2luZTEVMBMGA1UEAwwM
+c2VydmVyLnF0LmlvMRswGQYJKoZIhvcNAQkBFgxzZXJ2ZXJAcXQuaW8wggEiMA0G
+CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDmBCgmvJ6eOa/PLhFuod01ccrwaT/w
+u2jVLBPz5ZuHkTJhFO2EV2KhPUlhwh7dczA6bHdOMANjWMBcA995FyNOQxydnAXv
+oBdQrZeoEA2FobXCOyJvshIZT9Tn8lqubaLBAnnOMqw2bylliqmYqxgBUUwSu19y
+l0t1KnoEbnhKtsi1xeFYd+xSzly5USL2cJ66AuQPOg8uWP9N6i4pY53OHK8teQ+8
++YPj+EPR1QtNekINmF/vcC5AFZMaxZ5SclCJCENHC5daEZFfyoUlDivNjyshtoqG
+B74FDoEv6mKPa7Mco1CPXZksVmAuKEsMmiAanTzL1R3pG7/dYagWRjfzAgMBAAEw
+DQYJKoZIhvcNAQELBQADggEBAHotgaBbqIlG4EqjzSpX8kQnZnGJUsA51dbY3K5C
+4tNCd+JquQfPmCIKDHkRsmmEU6pcU+LT8m+toJ8Gx0XG4nrdUIDt0Nlf/QrykbPj
+hN8z+aSfP9J5tg4NsT7qMWmqUHOa3BcsgWcC4IwWVkbOMz/XbczEQqdBJMbE0+PC
+32ihTKPZBPC2QlIvXyuwupvQtcXgEjw1r2FQeYcmItk3CKbJPE/Rk4/aXSCo4b0F
+iXPphh8BJPZVvQ2cLpPaGvcse5qjIhF9ODb2HEK3myMwuJVi7teURy8mPlS23Li/
+8gRCNu/stjMlkic7d3dqV0LwaG8+Df1W2wzxsT7IkxN/Z+o=
+-----END CERTIFICATE-----
diff --git a/examples/webenginewidgets/clientcertificate/resources/server.qrc b/examples/webenginewidgets/clientcertificate/resources/server.qrc
new file mode 100644
index 000000000..502afa9cc
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/resources/server.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/resources">
+ <file>server.key</file>
+ <file>server.pem</file>
+ <file>ca.pem</file>
+ </qresource>
+</RCC>
diff --git a/examples/webenginewidgets/clientcertificate/server.cpp b/examples/webenginewidgets/clientcertificate/server.cpp
new file mode 100644
index 000000000..ee83dab8a
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/server.cpp
@@ -0,0 +1,99 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qpointer.h>
+#include <QtCore/qtimer.h>
+#include <QtNetwork/qsslconfiguration.h>
+#include <QtNetwork/qsslkey.h>
+#include <QtNetwork/qsslserver.h>
+
+struct Request : public QObject
+{
+ QByteArray m_data;
+};
+
+static const QByteArray http_ok(QByteArrayLiteral(
+ "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nConnection: close\r\n\r\n"));
+static const QByteArray html_start(QByteArrayLiteral("<html><style>"
+ "div {"
+ "height: 400px;"
+ "width: 200px;"
+ "position: fixed;"
+ "top: 50%;"
+ "left: 50%;"
+ "margin-top: -100px;"
+ "margin-left: -200px;"
+ "}</style><body><div>"));
+static const QByteArray html_end(QByteArrayLiteral("</div></body></html>"));
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setOrganizationName("QtExamples");
+ QCoreApplication app(argc, argv);
+
+ QSslServer server;
+ QSslConfiguration configuration(QSslConfiguration::defaultConfiguration());
+ configuration.setPeerVerifyMode(QSslSocket::VerifyPeer);
+
+ QFile keyFile(":/resources/server.key");
+ keyFile.open(QIODevice::ReadOnly);
+
+ QSslKey key(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
+ configuration.setPrivateKey(key);
+
+ QList<QSslCertificate> localCerts = QSslCertificate::fromPath(":/resources/server.pem");
+ configuration.setLocalCertificateChain(localCerts);
+
+ QList<QSslCertificate> caCerts = QSslCertificate::fromPath(":resources/ca.pem");
+ configuration.addCaCertificates(caCerts);
+
+ server.setSslConfiguration(configuration);
+
+ if (!server.listen(QHostAddress::LocalHost, 5555))
+ qFatal("Could not start server on localhost:5555");
+ else
+ qInfo("Server started on localhost:5555");
+
+ QObject::connect(&server, &QTcpServer::pendingConnectionAvailable, [&server]() {
+ QTcpSocket *socket = server.nextPendingConnection();
+ Q_ASSERT(socket);
+
+ QPointer<Request> request(new Request);
+
+ QObject::connect(socket, &QAbstractSocket::disconnected, socket,
+ [socket, request]() mutable {
+ delete request;
+ socket->deleteLater();
+ });
+
+ QObject::connect(socket, &QTcpSocket::readyRead, socket, [socket, request]() mutable {
+ request->m_data.append(socket->readAll());
+
+ if (!request->m_data.endsWith("\r\n\r\n"))
+ return;
+
+ socket->write(http_ok);
+ socket->write(html_start);
+
+ if (request->m_data.startsWith("GET / ")) {
+ socket->write("<p>ACCESS GRANTED !</p>");
+ socket->write("<p>You reached the place, where no one has gone before.</p>");
+ socket->write("<button onclick=\"window.location.href='/exit'\">Exit</button>");
+ } else if (request->m_data.startsWith("GET /exit ")) {
+ socket->write("<p>BYE !</p>");
+ socket->write("<p>Have good day ...</p>");
+ QTimer::singleShot(0, &QCoreApplication::quit);
+ } else {
+ socket->write("<p>There is nothing to see here.</p>");
+ }
+
+ socket->write(html_end);
+ delete request;
+ socket->disconnectFromHost();
+ });
+ });
+
+ return app.exec();
+}
diff --git a/examples/webenginewidgets/clientcertificate/server.pro b/examples/webenginewidgets/clientcertificate/server.pro
new file mode 100644
index 000000000..b8fda1717
--- /dev/null
+++ b/examples/webenginewidgets/clientcertificate/server.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+
+QT += core network
+CONFIG += console
+
+SOURCES += server.cpp
+
+RESOURCES += resources/server.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/clientcertificate/server
+INSTALLS += target
diff --git a/examples/webenginewidgets/contentmanipulation/CMakeLists.txt b/examples/webenginewidgets/contentmanipulation/CMakeLists.txt
index 9ff58587d..f0b9e9638 100644
--- a/examples/webenginewidgets/contentmanipulation/CMakeLists.txt
+++ b/examples/webenginewidgets/contentmanipulation/CMakeLists.txt
@@ -1,43 +1,41 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(contentmanipulation LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/contentmanipulation")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(contentmanipulation
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(contentmanipulation PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(contentmanipulation PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(jquery_resource_files
"jquery.min.js"
)
-qt6_add_resources(contentmanipulation "jquery"
+qt_add_resources(contentmanipulation "jquery"
PREFIX
"/"
FILES
diff --git a/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc b/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc
index 66a1252dc..ae91affe5 100644
--- a/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc
+++ b/examples/webenginewidgets/contentmanipulation/doc/src/contentmanipulation.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/contentmanipulation
+ \examplecategory {Web Technologies}
\title WebEngine Content Manipulation Example
\ingroup webengine-widgetexamples
\brief Demonstrates how to load and manipulate web content.
diff --git a/examples/webenginewidgets/contentmanipulation/main.cpp b/examples/webenginewidgets/contentmanipulation/main.cpp
index b53fdef47..d096a71b2 100644
--- a/examples/webenginewidgets/contentmanipulation/main.cpp
+++ b/examples/webenginewidgets/contentmanipulation/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp
index 154a37747..3990be2b8 100644
--- a/examples/webenginewidgets/contentmanipulation/mainwindow.cpp
+++ b/examples/webenginewidgets/contentmanipulation/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
#include <QtWebEngineWidgets>
diff --git a/examples/webenginewidgets/contentmanipulation/mainwindow.h b/examples/webenginewidgets/contentmanipulation/mainwindow.h
index 66512f969..c50fccacb 100644
--- a/examples/webenginewidgets/contentmanipulation/mainwindow.h
+++ b/examples/webenginewidgets/contentmanipulation/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtWidgets>
diff --git a/examples/webenginewidgets/cookiebrowser/3rdparty/qt_attribution.json b/examples/webenginewidgets/cookiebrowser/3rdparty/qt_attribution.json
index 91a0899c6..35d9cf0d7 100644
--- a/examples/webenginewidgets/cookiebrowser/3rdparty/qt_attribution.json
+++ b/examples/webenginewidgets/cookiebrowser/3rdparty/qt_attribution.json
@@ -9,16 +9,16 @@
"Homepage": "http://tango.freedesktop.org/Tango_Icon_Library",
"Version": "0.8.90",
"DownloadLocation": "http://tango.freedesktop.org/releases/tango-icon-theme-0.8.90.tar.gz",
- "LicenseId": "DocumentRef-PublicDomain",
+ "LicenseId": "urn:dje:license:public-domain",
"License": "Public Domain",
"LicenseFile": "COPYING",
- "Copyright": "Ulisse Perusin <uli.peru@gmail.com>
-Steven Garrity <sgarrity@silverorange.com>
-Lapo Calamandrei <calamandrei@gmail.com>
-Ryan Collier <rcollier@novell.com>
-Rodney Dawes <dobey@novell.com>
-Andreas Nilsson <nisses.mail@home.se>
-Tuomas Kuosmanen <tigert@tigert.com>
-Garrett LeSage <garrett@novell.com>
-Jakub Steiner <jimmac@novell.com>"
+ "Copyright": ["Ulisse Perusin <uli.peru@gmail.com>",
+ "Steven Garrity <sgarrity@silverorange.com>",
+ "Lapo Calamandrei <calamandrei@gmail.com>",
+ "Ryan Collier <rcollier@novell.com>",
+ "Rodney Dawes <dobey@novell.com>",
+ "Andreas Nilsson <nisses.mail@home.se>",
+ "Tuomas Kuosmanen <tigert@tigert.com>",
+ "Garrett LeSage <garrett@novell.com>",
+ "Jakub Steiner <jimmac@novell.com>"]
}
diff --git a/examples/webenginewidgets/cookiebrowser/CMakeLists.txt b/examples/webenginewidgets/cookiebrowser/CMakeLists.txt
index 16d2bfab6..828fb95e8 100644
--- a/examples/webenginewidgets/cookiebrowser/CMakeLists.txt
+++ b/examples/webenginewidgets/cookiebrowser/CMakeLists.txt
@@ -1,21 +1,19 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(cookiebrowser LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/cookiebrowser")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(cookiebrowser
cookiedialog.ui
@@ -23,23 +21,24 @@ qt_add_executable(cookiebrowser
main.cpp
mainwindow.cpp mainwindow.h mainwindow.ui
)
+
set_target_properties(cookiebrowser PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(cookiebrowser PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(cookiebrowser_resource_files
"3rdparty/view-refresh.png"
)
-qt6_add_resources(cookiebrowser "cookiebrowser"
+qt_add_resources(cookiebrowser "cookiebrowser"
PREFIX
"/"
BASE
diff --git a/examples/webenginewidgets/cookiebrowser/doc/src/cookiebrowser.qdoc b/examples/webenginewidgets/cookiebrowser/doc/src/cookiebrowser.qdoc
index 316e11a9b..adc302779 100644
--- a/examples/webenginewidgets/cookiebrowser/doc/src/cookiebrowser.qdoc
+++ b/examples/webenginewidgets/cookiebrowser/doc/src/cookiebrowser.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2015 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/cookiebrowser
+ \examplecategory {Web Technologies}
\title WebEngine Cookie Browser Example
\ingroup webengine-widgetexamples
\brief A cookie browser based on \QWE Widgets.
diff --git a/examples/webenginewidgets/cookiebrowser/main.cpp b/examples/webenginewidgets/cookiebrowser/main.cpp
index b3fe71840..5722b69a4 100644
--- a/examples/webenginewidgets/cookiebrowser/main.cpp
+++ b/examples/webenginewidgets/cookiebrowser/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include <QApplication>
diff --git a/examples/webenginewidgets/cookiebrowser/mainwindow.cpp b/examples/webenginewidgets/cookiebrowser/mainwindow.cpp
index 66e6988d8..67454a9f1 100644
--- a/examples/webenginewidgets/cookiebrowser/mainwindow.cpp
+++ b/examples/webenginewidgets/cookiebrowser/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include <QWebEngineCookieStore>
@@ -106,8 +59,9 @@ CookieWidget::CookieWidget(const QNetworkCookie &cookie, QWidget *parent): QWidg
void CookieWidget::setHighlighted(bool enabled)
{
+ m_isHighlighted = enabled;
QPalette p = palette();
- p.setColor(backgroundRole(), enabled ? QColor(0xF0, 0xF8, 0xFF) : Qt::white);
+ p.setColor(backgroundRole(), enabled ? p.alternateBase().color() : p.base().color());
setPalette(p);
}
@@ -159,9 +113,18 @@ void MainWindow::handleCookieAdded(const QNetworkCookie &cookie)
return;
CookieWidget *widget = new CookieWidget(cookie);
- widget->setHighlighted(m_cookies.count() % 2);
m_cookies.append(cookie);
- m_layout->insertWidget(0,widget);
+ // Check whether the first widget in the layout is highlighted.
+ // if it is highlighted, then do not highlight the new item.
+ CookieWidget *firstWidget = m_layout->count()
+ ? qobject_cast<CookieWidget *>(m_layout->itemAt(0)->widget())
+ : nullptr;
+ if (firstWidget) {
+ widget->setHighlighted(!firstWidget->isHighlighted());
+ } else {
+ widget->setHighlighted(false);
+ }
+ m_layout->insertWidget(0, widget);
connect(widget, &CookieWidget::deleteClicked, [this, cookie, widget]() {
m_store->deleteCookie(cookie);
diff --git a/examples/webenginewidgets/cookiebrowser/mainwindow.h b/examples/webenginewidgets/cookiebrowser/mainwindow.h
index b6aee1c24..da0d438ca 100644
--- a/examples/webenginewidgets/cookiebrowser/mainwindow.h
+++ b/examples/webenginewidgets/cookiebrowser/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -76,9 +29,13 @@ class CookieWidget : public QWidget, public Ui_CookieWidget
public:
CookieWidget(const QNetworkCookie &cookie, QWidget *parent = nullptr);
void setHighlighted(bool enabled);
+ bool isHighlighted() { return m_isHighlighted; }
signals:
void deleteClicked();
void viewClicked();
+
+private:
+ bool m_isHighlighted = false;
};
class MainWindow : public QMainWindow, public Ui_MainWindow
diff --git a/examples/webenginewidgets/html2pdf/CMakeLists.txt b/examples/webenginewidgets/html2pdf/CMakeLists.txt
index 80567e88f..0386d3d83 100644
--- a/examples/webenginewidgets/html2pdf/CMakeLists.txt
+++ b/examples/webenginewidgets/html2pdf/CMakeLists.txt
@@ -1,29 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(html2pdf LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/html2pdf")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(html2pdf
html2pdf.cpp
)
+
set_target_properties(html2pdf PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(html2pdf PUBLIC
Qt::Core
Qt::Gui
diff --git a/examples/webenginewidgets/html2pdf/doc/src/html2pdf.qdoc b/examples/webenginewidgets/html2pdf/doc/src/html2pdf.qdoc
index c60bc6d0b..7199a812c 100644
--- a/examples/webenginewidgets/html2pdf/doc/src/html2pdf.qdoc
+++ b/examples/webenginewidgets/html2pdf/doc/src/html2pdf.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/html2pdf
+ \examplecategory {Web Technologies}
\title WebEngine Widgets Html2Pdf Example
\ingroup webengine-widgetexamples
\brief Converts web pages to PDF documents using \QWE.
diff --git a/examples/webenginewidgets/html2pdf/html2pdf.cpp b/examples/webenginewidgets/html2pdf/html2pdf.cpp
index 1b52d69b1..1c9e5f607 100644
--- a/examples/webenginewidgets/html2pdf/html2pdf.cpp
+++ b/examples/webenginewidgets/html2pdf/html2pdf.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QApplication>
#include <QCommandLineParser>
@@ -55,9 +8,7 @@
#include <QWebEngineView>
#include <functional>
-
-using namespace std;
-using namespace std::placeholders;
+#include <utility>
class Html2PdfConverter : public QObject
{
@@ -77,8 +28,8 @@ private:
};
Html2PdfConverter::Html2PdfConverter(QString inputPath, QString outputPath)
- : m_inputPath(move(inputPath))
- , m_outputPath(move(outputPath))
+ : m_inputPath(std::move(inputPath))
+ , m_outputPath(std::move(outputPath))
, m_view(new QWebEngineView)
{
connect(m_view.data(), &QWebEngineView::loadFinished,
diff --git a/examples/webenginewidgets/maps/CMakeLists.txt b/examples/webenginewidgets/maps/CMakeLists.txt
index 01eb96e70..93d9634f8 100644
--- a/examples/webenginewidgets/maps/CMakeLists.txt
+++ b/examples/webenginewidgets/maps/CMakeLists.txt
@@ -1,36 +1,54 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(maps LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/maps")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(maps
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(maps PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.webenginewidgets.maps"
)
+
target_link_libraries(maps PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
+if (APPLE)
+ set_target_properties(maps PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.cmake.macos.plist"
+ )
+
+ if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
+ # Need to sign application for location permissions to work
+ if(QT_FEATURE_debug_and_release)
+ set(exe_path "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/")
+ else()
+ unset(exe_path)
+ endif()
+ add_custom_command(TARGET maps
+ POST_BUILD COMMAND codesign --force -s - ${exe_path}maps.app
+ )
+ endif()
+endif()
+
install(TARGETS maps
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/webenginewidgets/maps/Info.cmake.macos.plist b/examples/webenginewidgets/maps/Info.cmake.macos.plist
new file mode 100644
index 000000000..82336b25a
--- /dev/null
+++ b/examples/webenginewidgets/maps/Info.cmake.macos.plist
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+ <key>NSLocationUsageDescription</key>
+ <string>The maps demo would like to access your location for demo purposes.</string>
+
+</dict>
+</plist>
diff --git a/examples/webenginewidgets/maps/doc/src/maps.qdoc b/examples/webenginewidgets/maps/doc/src/maps.qdoc
index 489a5a780..0175f8b65 100644
--- a/examples/webenginewidgets/maps/doc/src/maps.qdoc
+++ b/examples/webenginewidgets/maps/doc/src/maps.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/maps
+ \examplecategory {Web Technologies}
\title WebEngine Widgets Maps Example
\ingroup webengine-widgetexamples
\brief Demonstrates how to handle geolocation requests.
@@ -38,14 +15,20 @@
The \l {https://www.w3.org/TR/geolocation-API/}{Geolocation API} is a
JavaScript API that web applications can use to determine the user's
- physical location to show on a map, for example. As \QWE relies on
- \l {Qt Location} to power this API a viable location backend is needed for
- the target platform.
+ physical location to show on a map, for example. As \QWE relies on the
+ \e {Qt Positioning} module to power this API, a viable location backend is
+ needed for the target platform.
To avoid accidentally sending location information to third parties
geolocation requests are denied by default. This example demonstrates the
steps an application must take in order to start accepting these requests.
+ \note On Windows 11, enable settings to grant the application access to
+ Windows location services. In the Settings App under
+ \uicontrol {Privacy & Security} > \uicontrol {Location}, enable \uicontrol
+ {Location services}, \uicontrol {Let apps access your location} and \uicontrol
+ {Let desktop apps access your location}.
+
\include examples-run.qdocinc
\section1 The Code
@@ -94,5 +77,5 @@
\printuntil /^\}/
- \sa {html5-geolocation}{Qt WebEngine HTML5 Geolocation}, {Qt Location}
+ \sa {html5-geolocation}{Qt WebEngine HTML5 Geolocation}
*/
diff --git a/examples/webenginewidgets/maps/main.cpp b/examples/webenginewidgets/maps/main.cpp
index 4a0fedb7b..550546130 100644
--- a/examples/webenginewidgets/maps/main.cpp
+++ b/examples/webenginewidgets/maps/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include <QApplication>
diff --git a/examples/webenginewidgets/maps/mainwindow.cpp b/examples/webenginewidgets/maps/mainwindow.cpp
index 3098bd72e..0d2b49911 100644
--- a/examples/webenginewidgets/maps/mainwindow.cpp
+++ b/examples/webenginewidgets/maps/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
diff --git a/examples/webenginewidgets/maps/mainwindow.h b/examples/webenginewidgets/maps/mainwindow.h
index 6401c2087..3c8450296 100644
--- a/examples/webenginewidgets/maps/mainwindow.h
+++ b/examples/webenginewidgets/maps/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/webenginewidgets/markdowneditor/CMakeLists.txt b/examples/webenginewidgets/markdowneditor/CMakeLists.txt
deleted file mode 100644
index 29bcc2d70..000000000
--- a/examples/webenginewidgets/markdowneditor/CMakeLists.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(markdowneditor LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/markdowneditor")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
-find_package(Qt6 COMPONENTS WebChannel)
-
-qt_add_executable(markdowneditor
- document.cpp document.h
- main.cpp
- mainwindow.cpp mainwindow.h mainwindow.ui
- previewpage.cpp previewpage.h
-)
-set_target_properties(markdowneditor PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(markdowneditor PUBLIC
- Qt::Core
- Qt::Gui
- Qt::WebChannel
- Qt::WebEngineWidgets
-)
-
-
-# Resources:
-set(markdowneditor_resource_files
- "resources/3rdparty/markdown.css"
- "resources/3rdparty/marked.js"
- "resources/default.md"
- "resources/index.html"
-)
-
-qt6_add_resources(markdowneditor "markdowneditor"
- PREFIX
- "/"
- BASE
- "resources"
- FILES
- ${markdowneditor_resource_files}
-)
-
-install(TARGETS markdowneditor
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/webenginewidgets/markdowneditor/doc/images/markdowneditor-example.png b/examples/webenginewidgets/markdowneditor/doc/images/markdowneditor-example.png
deleted file mode 100644
index 9f456c4db..000000000
--- a/examples/webenginewidgets/markdowneditor/doc/images/markdowneditor-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc b/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc
deleted file mode 100644
index 9ff8f0615..000000000
--- a/examples/webenginewidgets/markdowneditor/doc/src/markdowneditor.qdoc
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example webenginewidgets/markdowneditor
- \title WebEngine Markdown Editor Example
- \ingroup webengine-widgetexamples
- \brief Demonstrates how to integrate a web engine in a hybrid desktop
- application.
-
- \image markdowneditor-example.png
-
- \e {Markdown Editor} demonstrates how to use QWebChannel and JavaScript
- libraries to provide a rich text preview tool for a custom markup language.
-
- \l{http://daringfireball.net/projects/markdown/}{Markdown} is a lightweight
- markup language with a plain text formatting syntax.
- Some services, such as \l{http://github.com}{github}, acknowledge the
- format, and render the content as rich text when viewed in a browser.
-
- The Markdown Editor main window is split into an editor and a preview area.
- The editor supports the Markdown syntax and is implemented by using
- QPlainTextEdit. The document is rendered as rich text in the preview area,
- which is implemented by using QWebEngineView. To render the text, the
- Markdown text is converted to HTML format with the help of a JavaScript
- library inside the web engine. The preview is updated from the editor
- through QWebChannel.
-
- \include examples-run.qdocinc
-
- \section1 Exposing Document Text
-
- Because we expose the current Markdown text to be rendered to the web engine
- through QWebChannel, we need to somehow make the current text available
- through the Qt metatype system. This is done by using a dedicated
- \c Document class that exposes the document text as a \c{Q_PROPERTY}:
-
- \quotefromfile webenginewidgets/markdowneditor/document.h
- \skipto class Document
- \printto #endif
-
- The \c Document class wraps a QString to be set on the C++ side with
- the \c setText() method and exposes it at runtime as a \c text property
- with a \c textChanged signal.
-
- We define the \c setText method as follows:
-
- \quotefromfile webenginewidgets/markdowneditor/document.cpp
- \skipto Document::setText
- \printuntil
-
- \section1 Previewing Text
-
- We implement our own \c PreviewPage class that publicly inherits from
- \c QWebEnginePage:
-
- \quotefromfile webenginewidgets/markdowneditor/previewpage.h
- \skipto class PreviewPage
- \printto #endif
-
- We reimplement the virtual \c acceptNavigationRequest method to
- stop the page from navigating away from the current document. Instead,
- we redirect external links to the system browser:
-
- \quotefromfile webenginewidgets/markdowneditor/previewpage.cpp
- \skipto acceptNavigationRequest
- \printuntil
-
- \section1 Creating the Main Window
-
- The \c MainWindow class inherits the QMainWindow class:
-
- \quotefromfile webenginewidgets/markdowneditor/mainwindow.h
- \skipto class MainWindow :
- \printto endif
-
- The class declares private slots that match the actions in the menu,
- as well as the \c isModified() helper method.
-
- The actual layout of the main window is specified in a \c .ui file.
- The widgets and actions are available at runtime in the \c ui member
- variable.
-
- \c m_filePath holds the file path to the currently loaded document.
- \c m_content is an instance of the \c Document class.
-
- The actual setup of the different objects is done in the \c MainWindow
- constructor:
-
- \quotefromfile webenginewidgets/markdowneditor/mainwindow.cpp
- \skipto MainWindow::MainWindow
- \printto PreviewPage
-
- The constructor first calls \c setupUi to construct the widgets and menu
- actions according to the UI file. The text editor font is set to one
- with a fixed character width, and the QWebEngineView widget is told not
- to show a context menu.
-
- \printto connect
-
- Here the constructor makes sure our custom
- \c PreviewPage is used by the QWebEngineView instance in \c{ui->preview}.
-
- \printto ui->preview
-
- Here the \c textChanged signal of the editor is connected to a lambda that
- updates the text in \c m_content. This object is then exposed to the JS side
- by \c QWebChannel under the name \c{content}.
-
- \printto connect
-
- Now we can actually load the \e index.html file from the
- resources. For more information about the file, see
- \l{Creating an Index File}.
-
- \printto defaultTextFile
-
- The menu items are connected to the corresponding member slots. The
- \uicontrol Save item is activated or deactivated depending on whether
- the user has edited the content.
-
- \printuntil }
-
- Finally, we load a default document \e default.md from the resources.
-
- \section1 Creating an Index File
-
- \quotefile webenginewidgets/markdowneditor/resources/index.html
-
- In the \e index.html, we load a custom stylesheet and two JavaScript
- libraries. \l{http://kevinburke.bitbucket.org/markdowncss/}{markdown.css} is
- a markdown-friendly stylesheet created by Kevin Burke.
- \l{https://github.com/chjj/marked}{marked.js} is a markdown parser and
- compiler designed for speed written by Christopher Jeffrey and
- \e qwebchannel.js is part of the \l{QWebChannel} module.
-
- In the \c <body> element we first define a \c placeholder element, and
- make it available as a JavaScript variable. We then define the \c updateText
- helper method that updates the content of \c placeholder with the HTML
- that the JavaScript method \c marked() returns.
-
- Finally, we set up the web channel to access the \c content proxy object
- and make sure that \c updateText() is called whenever \c content.text
- changes.
-
- \section1 Files and Attributions
-
- The example bundles the following code with third-party licenses:
-
- \table
- \row
- \li \l{markdowneditor-marked}{Marked}
- \li MIT License
- \row
- \li \l{markdowneditor-markdowncss}{Markdown.css}
- \li Apache License 2.0
- \endtable
-*/
-
diff --git a/examples/webenginewidgets/markdowneditor/document.cpp b/examples/webenginewidgets/markdowneditor/document.cpp
deleted file mode 100644
index 20e6b6be9..000000000
--- a/examples/webenginewidgets/markdowneditor/document.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "document.h"
-
-void Document::setText(const QString &text)
-{
- if (text == m_text)
- return;
- m_text = text;
- emit textChanged(m_text);
-}
diff --git a/examples/webenginewidgets/markdowneditor/document.h b/examples/webenginewidgets/markdowneditor/document.h
deleted file mode 100644
index 785ce228f..000000000
--- a/examples/webenginewidgets/markdowneditor/document.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DOCUMENT_H
-#define DOCUMENT_H
-
-#include <QObject>
-#include <QString>
-
-class Document : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged FINAL)
-public:
- explicit Document(QObject *parent = nullptr) : QObject(parent) {}
-
- void setText(const QString &text);
-
-signals:
- void textChanged(const QString &text);
-
-private:
- QString m_text;
-};
-
-#endif // DOCUMENT_H
diff --git a/examples/webenginewidgets/markdowneditor/main.cpp b/examples/webenginewidgets/markdowneditor/main.cpp
deleted file mode 100644
index 059e9e64c..000000000
--- a/examples/webenginewidgets/markdowneditor/main.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "document.h"
-#include "mainwindow.h"
-
-#include <QApplication>
-#include <QFile>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication::setOrganizationName("QtExamples");
- QApplication a(argc, argv);
-
- MainWindow window;
- window.show();
-
- return a.exec();
-}
diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.cpp b/examples/webenginewidgets/markdowneditor/mainwindow.cpp
deleted file mode 100644
index 28d6f5641..000000000
--- a/examples/webenginewidgets/markdowneditor/mainwindow.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "previewpage.h"
-#include "ui_mainwindow.h"
-
-#include <QFile>
-#include <QFileDialog>
-#include <QFontDatabase>
-#include <QMessageBox>
-#include <QTextStream>
-#include <QWebChannel>
-
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
-{
- ui->setupUi(this);
- ui->editor->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
- ui->preview->setContextMenuPolicy(Qt::NoContextMenu);
-
- PreviewPage *page = new PreviewPage(this);
- ui->preview->setPage(page);
-
- connect(ui->editor, &QPlainTextEdit::textChanged,
- [this]() { m_content.setText(ui->editor->toPlainText()); });
-
- QWebChannel *channel = new QWebChannel(this);
- channel->registerObject(QStringLiteral("content"), &m_content);
- page->setWebChannel(channel);
-
- ui->preview->setUrl(QUrl("qrc:/index.html"));
-
- connect(ui->actionNew, &QAction::triggered, this, &MainWindow::onFileNew);
- connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::onFileOpen);
- connect(ui->actionSave, &QAction::triggered, this, &MainWindow::onFileSave);
- connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::onFileSaveAs);
- connect(ui->actionExit, &QAction::triggered, this, &MainWindow::onExit);
-
- connect(ui->editor->document(), &QTextDocument::modificationChanged,
- ui->actionSave, &QAction::setEnabled);
-
- QFile defaultTextFile(":/default.md");
- defaultTextFile.open(QIODevice::ReadOnly);
- ui->editor->setPlainText(defaultTextFile.readAll());
-}
-
-MainWindow::~MainWindow()
-{
- delete ui;
-}
-
-void MainWindow::openFile(const QString &path)
-{
- QFile f(path);
- if (!f.open(QIODevice::ReadOnly)) {
- QMessageBox::warning(this, windowTitle(),
- tr("Could not open file %1: %2").arg(
- QDir::toNativeSeparators(path), f.errorString()));
- return;
- }
- m_filePath = path;
- ui->editor->setPlainText(f.readAll());
-}
-
-bool MainWindow::isModified() const
-{
- return ui->editor->document()->isModified();
-}
-
-void MainWindow::onFileNew()
-{
- if (isModified()) {
- QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(),
- tr("You have unsaved changes. Do you want to create a new document anyway?"));
- if (button != QMessageBox::Yes)
- return;
- }
-
- m_filePath.clear();
- ui->editor->setPlainText(tr("## New document"));
- ui->editor->document()->setModified(false);
-}
-
-void MainWindow::onFileOpen()
-{
- if (isModified()) {
- QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(),
- tr("You have unsaved changes. Do you want to open a new document anyway?"));
- if (button != QMessageBox::Yes)
- return;
- }
-
- QString path = QFileDialog::getOpenFileName(this,
- tr("Open MarkDown File"), "", tr("MarkDown File (*.md)"));
- if (path.isEmpty())
- return;
-
- openFile(path);
-}
-
-void MainWindow::onFileSave()
-{
- if (m_filePath.isEmpty()) {
- onFileSaveAs();
- return;
- }
-
- QFile f(m_filePath);
- if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
- QMessageBox::warning(this, windowTitle(),
- tr("Could not write to file %1: %2").arg(
- QDir::toNativeSeparators(m_filePath), f.errorString()));
- return;
- }
- QTextStream str(&f);
- str << ui->editor->toPlainText();
-
- ui->editor->document()->setModified(false);
-}
-
-void MainWindow::onFileSaveAs()
-{
- QString path = QFileDialog::getSaveFileName(this,
- tr("Save MarkDown File"), "", tr("MarkDown File (*.md, *.markdown)"));
- if (path.isEmpty())
- return;
- m_filePath = path;
- onFileSave();
-}
-
-void MainWindow::onExit()
-{
- if (isModified()) {
- QMessageBox::StandardButton button = QMessageBox::question(this, windowTitle(),
- tr("You have unsaved changes. Do you want to exit anyway?"));
- if (button != QMessageBox::Yes)
- return;
- }
- close();
-}
diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.h b/examples/webenginewidgets/markdowneditor/mainwindow.h
deleted file mode 100644
index bb7a7ab01..000000000
--- a/examples/webenginewidgets/markdowneditor/mainwindow.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include "document.h"
-
-#include <QMainWindow>
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class MainWindow;
-}
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(QWidget *parent = nullptr);
- ~MainWindow();
-
- void openFile(const QString &path);
-
-private slots:
- void onFileNew();
- void onFileOpen();
- void onFileSave();
- void onFileSaveAs();
- void onExit();
-
-private:
- bool isModified() const;
-
- Ui::MainWindow *ui;
- QString m_filePath;
- Document m_content;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/webenginewidgets/markdowneditor/mainwindow.ui b/examples/webenginewidgets/markdowneditor/mainwindow.ui
deleted file mode 100644
index 36ab352b7..000000000
--- a/examples/webenginewidgets/markdowneditor/mainwindow.ui
+++ /dev/null
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>600</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>MarkDown Editor</string>
- </property>
- <widget class="QWidget" name="centralwidget">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QSplitter" name="splitter">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <widget class="QPlainTextEdit" name="editor"/>
- <widget class="QWebEngineView" name="preview" native="true"/>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menubar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>26</height>
- </rect>
- </property>
- <widget class="QMenu" name="menu_File">
- <property name="title">
- <string>&amp;File</string>
- </property>
- <addaction name="actionNew"/>
- <addaction name="actionOpen"/>
- <addaction name="actionSave"/>
- <addaction name="actionSaveAs"/>
- <addaction name="separator"/>
- <addaction name="actionExit"/>
- </widget>
- <addaction name="menu_File"/>
- </widget>
- <widget class="QStatusBar" name="statusbar"/>
- <action name="actionOpen">
- <property name="text">
- <string>&amp;Open...</string>
- </property>
- <property name="toolTip">
- <string>Open document</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+O</string>
- </property>
- </action>
- <action name="actionSave">
- <property name="text">
- <string>&amp;Save</string>
- </property>
- <property name="toolTip">
- <string>Save current document</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+S</string>
- </property>
- </action>
- <action name="actionExit">
- <property name="text">
- <string>E&amp;xit</string>
- </property>
- <property name="toolTip">
- <string>Exit editor</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+Q</string>
- </property>
- </action>
- <action name="actionSaveAs">
- <property name="text">
- <string>Save &amp;As...</string>
- </property>
- <property name="toolTip">
- <string>Save document under different name</string>
- </property>
- </action>
- <action name="actionNew">
- <property name="text">
- <string>&amp;New</string>
- </property>
- <property name="toolTip">
- <string>Create new document</string>
- </property>
- <property name="shortcut">
- <string>Ctrl+N</string>
- </property>
- </action>
- </widget>
- <customwidgets>
- <customwidget>
- <class>QWebEngineView</class>
- <extends>QWidget</extends>
- <header>qwebengineview.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <resources/>
- <connections/>
-</ui>
diff --git a/examples/webenginewidgets/markdowneditor/markdowneditor.pro b/examples/webenginewidgets/markdowneditor/markdowneditor.pro
deleted file mode 100644
index 099edf4b5..000000000
--- a/examples/webenginewidgets/markdowneditor/markdowneditor.pro
+++ /dev/null
@@ -1,32 +0,0 @@
-TEMPLATE = app
-
-QT += webenginewidgets webchannel
-
-HEADERS += \
- mainwindow.h \
- previewpage.h \
- document.h
-
-SOURCES = \
- main.cpp \
- mainwindow.cpp \
- previewpage.cpp \
- document.cpp
-
-RESOURCES = \
- resources/markdowneditor.qrc
-
-# Disable Qt Quick compiler because the example doesn't use QML, but more importantly so that
-# the source code of the .js files is not removed from the embedded qrc file.
-CONFIG -= qtquickcompiler
-
-FORMS += \
- mainwindow.ui
-
-DISTFILES += \
- resources/3rdparty/MARKDOWN-LICENSE.txt \
- resources/3rdparty/MARKED-LICENSE.txt
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/markdowneditor
-INSTALLS += target
diff --git a/examples/webenginewidgets/markdowneditor/previewpage.cpp b/examples/webenginewidgets/markdowneditor/previewpage.cpp
deleted file mode 100644
index 1d81d700c..000000000
--- a/examples/webenginewidgets/markdowneditor/previewpage.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "previewpage.h"
-
-#include <QDesktopServices>
-
-bool PreviewPage::acceptNavigationRequest(const QUrl &url,
- QWebEnginePage::NavigationType /*type*/,
- bool /*isMainFrame*/)
-{
- // Only allow qrc:/index.html.
- if (url.scheme() == QString("qrc"))
- return true;
- QDesktopServices::openUrl(url);
- return false;
-}
diff --git a/examples/webenginewidgets/markdowneditor/previewpage.h b/examples/webenginewidgets/markdowneditor/previewpage.h
deleted file mode 100644
index eb7d7ab00..000000000
--- a/examples/webenginewidgets/markdowneditor/previewpage.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PREVIEWPAGE_H
-#define PREVIEWPAGE_H
-
-#include <QWebEnginePage>
-
-class PreviewPage : public QWebEnginePage
-{
- Q_OBJECT
-public:
- explicit PreviewPage(QObject *parent = nullptr) : QWebEnginePage(parent) {}
-
-protected:
- bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
-};
-
-#endif // PREVIEWPAGE_H
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json b/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json
deleted file mode 100644
index de5458eff..000000000
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json
+++ /dev/null
@@ -1,35 +0,0 @@
-[
- {
- "Id": "markdowneditor-marked",
- "Name": "Marked (WebEngine Markdown Editor example)",
- "QDocModule": "qtwebengine",
- "QtUsage": "Marked is used in the WebEngine MarkDown Editor example",
- "QtParts": [ "examples" ],
- "Files": "marked.js",
- "Description": "A full-featured markdown parser and compiler, written in JavaScript. Built for speed.",
- "Homepage": "https://github.com/chjj/marked",
- "Version": "0.4.0",
- "DownloadLocation": "https://github.com/markedjs/marked/blob/0.4.0/lib/marked.js",
- "Copyright": "Copyright (c) 2011-2018, Christopher Jeffrey",
- "License": "MIT License",
- "LicenseId": "MIT",
- "LicenseFile": "MARKED-LICENSE.txt"
- },
- {
- "Id": "markdowneditor-markdowncss",
- "Name": "Markdown.css (WebEngine Markdown Editor example)",
- "QDocModule": "qtwebengine",
- "QtUsage": "markdown.css is used in the WebEngine MarkDown Editor example",
- "QtParts": [ "examples" ],
- "Files": "markdown.css",
- "Description": "Markdown.css is better default styling for your Markdown files.",
- "Homepage": "https://kevinburke.bitbucket.io/markdowncss/",
- "Version": "188530e4b5d020d7e237fc6b26be13ebf4a8def3",
- "DownloadLocation": "https://bitbucket.org/kevinburke/markdowncss/src/188530e4b5d020d7e237fc6b26be13ebf4a8def3/markdown.css",
- "Copyright": "Copyright 2011 Kevin Burke
- Copyright Twitter Inc.",
- "License": "Apache License 2.0",
- "LicenseId": "Apache-2.0",
- "LicenseFile": "MARKDOWN-LICENSE.txt"
- }
-]
diff --git a/examples/webenginewidgets/markdowneditor/resources/default.md b/examples/webenginewidgets/markdowneditor/resources/default.md
deleted file mode 100644
index af835fa4d..000000000
--- a/examples/webenginewidgets/markdowneditor/resources/default.md
+++ /dev/null
@@ -1,12 +0,0 @@
-## WebEngine Markdown Editor Example
-
-This example uses [QWebEngineView](http://doc.qt.io/qt-5/qwebengineview.html)
-to preview text written using the [Markdown](https://en.wikipedia.org/wiki/Markdown)
-syntax.
-
-### Acknowledgments
-
-The conversion from Markdown to HTML is done with the help of the
-[marked JavaScript library](https://github.com/chjj/marked) by _Christopher Jeffrey_.
-The [style sheet](https://kevinburke.bitbucket.io/markdowncss/)
-was created by _Kevin Burke_.
diff --git a/examples/webenginewidgets/markdowneditor/resources/index.html b/examples/webenginewidgets/markdowneditor/resources/index.html
deleted file mode 100644
index 289a2110b..000000000
--- a/examples/webenginewidgets/markdowneditor/resources/index.html
+++ /dev/null
@@ -1,32 +0,0 @@
-<!doctype html>
-<html lang="en">
-<meta charset="utf-8">
-<head>
- <link rel="stylesheet" type="text/css" href="3rdparty/markdown.css">
- <script src="3rdparty/marked.js"></script>
- <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
-</head>
-<body>
- <div id="placeholder"></div>
- <script>
- 'use strict';
-
- var placeholder = document.getElementById('placeholder');
-
- var updateText = function(text) {
- placeholder.innerHTML = marked(text);
- }
-
- new QWebChannel(qt.webChannelTransport,
- function(channel) {
- var content = channel.objects.content;
- updateText(content.text);
- content.textChanged.connect(updateText);
- }
- );
- </script>
-</body>
-</html>
-
-
-
diff --git a/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc b/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc
deleted file mode 100644
index bc738f1cf..000000000
--- a/examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>default.md</file>
- <file>index.html</file>
- <file>3rdparty/markdown.css</file>
- <file>3rdparty/marked.js</file>
- </qresource>
-</RCC>
diff --git a/examples/webenginewidgets/minimal/CMakeLists.txt b/examples/webenginewidgets/minimal/CMakeLists.txt
deleted file mode 100644
index 6c8c44e98..000000000
--- a/examples/webenginewidgets/minimal/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(minimal LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/minimal-widgets")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
-
-qt_add_executable(minimal-widgets
- main.cpp
-)
-set_target_properties(minimal-widgets PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(minimal-widgets PUBLIC
- Qt::Core
- Qt::Gui
- Qt::WebEngineWidgets
-)
-
-install(TARGETS minimal-widgets
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/webenginewidgets/minimal/doc/images/minimal-example.png b/examples/webenginewidgets/minimal/doc/images/minimal-example.png
deleted file mode 100644
index 18ac9b177..000000000
--- a/examples/webenginewidgets/minimal/doc/images/minimal-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginewidgets/minimal/doc/src/minimal.qdoc b/examples/webenginewidgets/minimal/doc/src/minimal.qdoc
deleted file mode 100644
index 9a0ee4593..000000000
--- a/examples/webenginewidgets/minimal/doc/src/minimal.qdoc
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example webenginewidgets/minimal
- \title WebEngine Widgets Minimal Example
- \ingroup webengine-widgetexamples
- \brief Displays a web page using \QWE Widgets.
-
- \image minimal-example.png
-
- \e {WebEngine Widgets Minimal Example} demonstrates how to use
- \l{QWebEngineView} to render a web page. It shows the minimum amount of code
- needed to load and display an HTML page, and can be used as a basis for
- further experimentation.
-
- \include examples-run.qdocinc
-
- \section1 The Code
-
- We first define a \c commandLineUrlArgument function that returns the URL to open.
- This is either the first positional argument given on the command line, or
- \c https://www.qt.io as a fallback.
-
- \quotefromfile webenginewidgets/minimal/main.cpp
- \skipto #include
-
- \printto int main
-
- In the \c main function we first set the
- \l{QCoreApplication::organizationName} property. This affects the locations
- where \QWE stores persistent and cached data (see also
- \l{QWebEngineProfile::cachePath} and
- \l{QWebEngineProfile::persistentStoragePath}).
-
- Next, we instantiate a QApplication and a QWebEngineView. The URL
- to load is taken from \c commandLineUrlArgument and
- loaded by calling \l QWebEngineView::setUrl. The view widget is
- given a reasonable default size, and shown.
- Finally, QApplication::exec() launches the main event loop.
-
- \printuntil }
-
- \section1 Requirements
-
- The example requires a working internet connection to render
- the \l{Qt Homepage}.
- An optional system proxy should be picked up automatically.
- However, for proxies that require a username or password,
- you need to connect to
- QWebEnginePage::proxyAuthenticationRequired.
-
- \l{Qt WebEngine Widgets} uses the \l{Qt Quick Scene Graph} to compose the
- page. Therefore, OpenGL support is required.
-*/
diff --git a/examples/webenginewidgets/minimal/main.cpp b/examples/webenginewidgets/minimal/main.cpp
deleted file mode 100644
index a2c5e4873..000000000
--- a/examples/webenginewidgets/minimal/main.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QWebEngineView>
-
-QUrl commandLineUrlArgument()
-{
- const QStringList args = QCoreApplication::arguments();
- for (const QString &arg : args.mid(1)) {
- if (!arg.startsWith(QLatin1Char('-')))
- return QUrl::fromUserInput(arg);
- }
- return QUrl(QStringLiteral("https://www.qt.io"));
-}
-
-int main(int argc, char *argv[])
-{
- QCoreApplication::setOrganizationName("QtExamples");
- QApplication app(argc, argv);
-
- QWebEngineView view;
- view.setUrl(commandLineUrlArgument());
- view.resize(1024, 750);
- view.show();
-
- return app.exec();
-}
diff --git a/examples/webenginewidgets/minimal/minimal.pro b/examples/webenginewidgets/minimal/minimal.pro
deleted file mode 100644
index 849f4b9b6..000000000
--- a/examples/webenginewidgets/minimal/minimal.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = app
-
-QT += webenginewidgets
-
-SOURCES += main.cpp
-
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/minimal
-INSTALLS += target
diff --git a/examples/webenginewidgets/notifications/CMakeLists.txt b/examples/webenginewidgets/notifications/CMakeLists.txt
index 0f6e504d9..8cca0ab31 100644
--- a/examples/webenginewidgets/notifications/CMakeLists.txt
+++ b/examples/webenginewidgets/notifications/CMakeLists.txt
@@ -1,44 +1,42 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(notifications LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/notifications")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(notifications
main.cpp
notificationpopup.h
)
+
set_target_properties(notifications PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(notifications PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(data_resource_files
"data/icon.png"
"data/index.html"
)
-qt6_add_resources(notifications "data"
+qt_add_resources(notifications "data"
PREFIX
"/"
BASE
diff --git a/examples/webenginewidgets/notifications/doc/src/notifications.qdoc b/examples/webenginewidgets/notifications/doc/src/notifications.qdoc
index ec932f90c..f4fe1818f 100644
--- a/examples/webenginewidgets/notifications/doc/src/notifications.qdoc
+++ b/examples/webenginewidgets/notifications/doc/src/notifications.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/notifications
+ \examplecategory {Web Technologies}
\title WebEngine Notifications Example
\ingroup webengine-widgetexamples
\brief Demonstrates how to pass HTML5 web notifications to users.
diff --git a/examples/webenginewidgets/notifications/main.cpp b/examples/webenginewidgets/notifications/main.cpp
index 9a797376c..c754aff3f 100644
--- a/examples/webenginewidgets/notifications/main.cpp
+++ b/examples/webenginewidgets/notifications/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "notificationpopup.h"
diff --git a/examples/webenginewidgets/notifications/notificationpopup.h b/examples/webenginewidgets/notifications/notificationpopup.h
index d211c7996..57912f204 100644
--- a/examples/webenginewidgets/notifications/notificationpopup.h
+++ b/examples/webenginewidgets/notifications/notificationpopup.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#pragma once
diff --git a/examples/webenginewidgets/printme/CMakeLists.txt b/examples/webenginewidgets/printme/CMakeLists.txt
index 6b21de270..2d071903c 100644
--- a/examples/webenginewidgets/printme/CMakeLists.txt
+++ b/examples/webenginewidgets/printme/CMakeLists.txt
@@ -1,31 +1,29 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(printme LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/printme")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
-find_package(Qt6 COMPONENTS PrintSupport)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui PrintSupport WebEngineWidgets)
qt_add_executable(printme
main.cpp
printhandler.cpp printhandler.h
)
+
set_target_properties(printme PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(printme PUBLIC
Qt::Core
Qt::Gui
@@ -33,15 +31,13 @@ target_link_libraries(printme PUBLIC
Qt::WebEngineWidgets
)
-
# Resources:
set(data_resource_files
- "data/icon.svg"
"data/index.html"
"data/style.css"
)
-qt6_add_resources(printme "data"
+qt_add_resources(printme "data"
PREFIX
"/"
BASE
diff --git a/examples/webenginewidgets/printme/data/data.qrc b/examples/webenginewidgets/printme/data/data.qrc
index a9c76cc7e..b5e0b1fe0 100644
--- a/examples/webenginewidgets/printme/data/data.qrc
+++ b/examples/webenginewidgets/printme/data/data.qrc
@@ -2,6 +2,5 @@
<qresource prefix="/">
<file>index.html</file>
<file>style.css</file>
- <file>icon.svg</file>
</qresource>
</RCC>
diff --git a/examples/webenginewidgets/printme/data/icon.svg b/examples/webenginewidgets/printme/data/icon.svg
deleted file mode 100644
index b90ff26dd..000000000
--- a/examples/webenginewidgets/printme/data/icon.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
- width="94px" height="94px" viewBox="0 0 94 94" enable-background="new 0 0 94 94" xml:space="preserve">
-<g>
- <circle fill="none" cx="47" cy="47" r="47"/>
- <g>
- <path fill="#46A2DA" d="M47,92.979c-11.779,0-23.559-4.484-32.526-13.451C-3.461,61.591-3.461,32.409,14.472,14.474
- C32.41-3.463,61.592-3.461,79.526,14.473c17.935,17.936,17.935,47.119,0.002,65.054l-0.002,0.001
- C70.559,88.495,58.779,92.979,47,92.979z"/>
- </g>
- <path fill="#80C342" d="M93,47C93,21.595,72.405,1,47,1C34.297,1,22.797,6.149,14.473,14.473l65.054,65.054
- C87.851,71.203,93,59.703,93,47z"/>
- <g>
- <path fill="#46A2DA" d="M47,65c-4.808,0-9.328-1.873-12.728-5.272c-7.018-7.019-7.018-18.438,0-25.456
- C37.672,30.873,42.192,29,47,29s9.328,1.873,12.728,5.272c7.018,7.019,7.018,18.438,0,25.456C56.328,63.127,51.808,65,47,65z"/>
- <path fill="#FFFFFF" d="M62.248,59.919c6.671-7.858,6.312-19.644-1.105-27.061C57.237,28.953,52.118,27,47,27
- c-5.118,0-10.237,1.953-14.142,5.858c-7.81,7.81-7.81,20.474,0,28.284C36.763,65.047,41.882,67,47,67
- c4.379,0,8.752-1.441,12.372-4.3L77.88,81.209c0.989-0.895,1.935-1.837,2.843-2.814L62.248,59.919z M35.686,58.314
- c-6.238-6.238-6.238-16.389,0-22.627C38.708,32.664,42.726,31,47,31c4.274,0,8.292,1.664,11.314,4.686
- c6.238,6.238,6.238,16.389,0,22.627C55.292,61.336,51.274,63,47,63C42.726,63,38.708,61.336,35.686,58.314z"/>
- </g>
-</g>
-</svg>
diff --git a/examples/webenginewidgets/printme/data/index.html b/examples/webenginewidgets/printme/data/index.html
index cf286e85a..865152c1d 100644
--- a/examples/webenginewidgets/printme/data/index.html
+++ b/examples/webenginewidgets/printme/data/index.html
@@ -12,13 +12,13 @@
</head>
<body>
<form class="form">
- <img class="logo" src="icon.svg" alt="qtwebengine">
<div class="header">
<h1>Hello Paper World!</h1>
<h2>Press Ctrl+p to print with print preview</h2>
<h2>Press Ctrl+Shift+p to print without print preview</h2>
<h2>Click the button to print using JavaScript</h2>
<p class="button" onclick="printNow()">Print Now</p>
+ </div>
</form>
</body>
</html>
diff --git a/examples/webenginewidgets/printme/data/style.css b/examples/webenginewidgets/printme/data/style.css
index cf6a2b7bf..af8b70fda 100644
--- a/examples/webenginewidgets/printme/data/style.css
+++ b/examples/webenginewidgets/printme/data/style.css
@@ -1,72 +1,74 @@
+@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap');
+* {
+ padding: 0;
+ margin: 0;
+ box-sizing: border-box;
+}
+
html,body {
- height:100%;
- width:100%;
- margin:0;
+ height: 100%;
+ width: 100%;
}
+
body {
- display:flex;
-}
- .logo {
- width: 75px;
- height: 75px;
- float: left;
- margin: 20px 20px 0px 20px;
- -webkit-animation:spin 8s linear infinite;
-}
- @-webkit-keyframes spin {
- 100% {
- -webkit-transform: rotate(360deg);
- }
+ display: flex;
}
+
.header {
display: inline
}
+
.form {
- width: 480px;
- height: 170px;
- background: -webkit-linear-gradient(bottom, #ddd, #fff);
- border: 1px solid #999;
- border-radius: 12px;
+ width: 50%;
+ background: #fff;
+ border: 0.5px solid #999;
+ border-radius: 8px;
color: #46a;
- font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
- font-size: 14px;
- font-style: italic;
- font-weight: bold;
+ font-family: 'Titillium Web', sans-serif;
+ font-size: 1rem;
margin: auto;
- padding: 10px;
+ padding: 1.5rem;
position: relative;
- line-height: 26px;
text-decoration: none;
- -webkit-box-shadow: 0px 0px 5px #444;
}
- h1 {
- padding-left:40px;
- color: #46a2da;
+
+h1 {
+ color: #00414A;
+ font-size: 2.5rem;
+ font-weight: 700;
+ margin-top: -0.85rem;
+ margin-bottom: 2rem;
}
- h2 {
- color: #80c342;
- font-size: 13px;
- margin-top: -20px;
-}
- span {
- margin-left: 20px;
+
+h2 {
+ color: #00414A;
+ font-size: 1.125rem;
+ font-weight: 400;
+ font-style: italic;
+ margin-bottom: 1rem;
}
+
.button{
- display: inline-block;
- background: #46a2da;
- width: 100px;
- height: 30px;
- padding: 0px;
- text-align: center;
- font-weight: bold;
- color: #ffffff;
- text-decoration: none;
- border: 1px solid #999;
- margin-left: 190px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 0.4444em 0.8889em;
+ height: 2.4em;
+ cursor: pointer;
+ background: #00414A;
+ color: #fff;
+ border-radius: 4px;
+ margin-top: 2rem;
+ font-family: 'Titillium Web', sans-serif;
+ font-size: 1.125rem;
+ font-weight: 400;
+ transition: color 300ms ease-out, border 300ms ease-out;
}
+
.button:hover {
- background-color: #46a200
+ background: #19545C;
}
+
.button:active {
- background-color: #3e8e41;
+ background-color: #19545C;
}
diff --git a/examples/webenginewidgets/printme/doc/images/printme-example.png b/examples/webenginewidgets/printme/doc/images/printme-example.png
index a636972fd..dac4e61e6 100644
--- a/examples/webenginewidgets/printme/doc/images/printme-example.png
+++ b/examples/webenginewidgets/printme/doc/images/printme-example.png
Binary files differ
diff --git a/examples/webenginewidgets/printme/doc/src/printme.qdoc b/examples/webenginewidgets/printme/doc/src/printme.qdoc
index 1ba37d0c3..91aecf6de 100644
--- a/examples/webenginewidgets/printme/doc/src/printme.qdoc
+++ b/examples/webenginewidgets/printme/doc/src/printme.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
- \example webenginewidgets/printme
+ \example webenginewidgets/printme
+ \examplecategory {Web Technologies}
\title WebEngine Widgets PrintMe Example
\ingroup webengine-widgetexamples
\brief Demonstrates how to print web pages using Qt WebEngine Widgets.
@@ -66,8 +43,8 @@
\section1 Print Handler
- In the \c{PrintHandler} function, we first implement \c{printPreview()},
- where we instantiate \l{QPrinter} together with \l{QPrintPreviewDialog}.
+ In the \c{PrintHandler} class, we first implement \c{printPreview()},
+ where we instantiate \l{QPrintPreviewDialog}.
We need the \l{QPrintPreviewDialog::paintRequested} handle to generate a
set of preview pages.
@@ -77,16 +54,26 @@
Now we can implement the \c{PrintHandler::printDocument()} slot, which is
called in response to the \l{QPrintPreviewDialog::paintRequested} signal.
+ To do actual painting on a printer, we call the \l QWebEngineView::print()
+ function. Printing is an async operation in Chromium, but not in Qt, so we
+ run a local event loop using \l{QEventLoop::exec()} to make sure printing
+ is done before returning. User input is blocked, since clicking on a button
+ while we're waiting for the print to finish can mess up the internal state
+ and cause a crash.
\quotefromfile webenginewidgets/printme/printhandler.cpp
\skipto PrintHandler::printDocument(
\printuntil /^\}/
- To do actual painting on a printer, we call the \l QWebEngineView::print()
- function. Because this call blocks the main event loop, we need to create
- a local one. We begin the local event loop by calling
- \l{QEventLoop::exec()}. When the local event loop terminates,
- we check for \c{result} and report any errors that occurred.
+ To get notified about the result of printing job, we implement
+ \c{PrintHandler::printFinished()} slot as handler of
+ \l QWebEngineView::printFinished() signal. We check for \c{success} and
+ report any errors that occurred. Finally, we call \l{QEventLoop::quit()}
+ to exit out of the local event loop.
+
+ \quotefromfile webenginewidgets/printme/printhandler.cpp
+ \skipto PrintHandler::printFinished(
+ \printuntil /^\}/
The last function we implement, \c{PrintHandler::print()}, is trivial,
because it simply opens \l{QPrintDialog} and calls the previously
diff --git a/examples/webenginewidgets/printme/main.cpp b/examples/webenginewidgets/printme/main.cpp
index 588026eb2..46f44ccb6 100644
--- a/examples/webenginewidgets/printme/main.cpp
+++ b/examples/webenginewidgets/printme/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "printhandler.h"
#include <QApplication>
diff --git a/examples/webenginewidgets/printme/printhandler.cpp b/examples/webenginewidgets/printme/printhandler.cpp
index 200f2f302..9f8f6ee0b 100644
--- a/examples/webenginewidgets/printme/printhandler.cpp
+++ b/examples/webenginewidgets/printme/printhandler.cpp
@@ -1,57 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "printhandler.h"
-#include <QEventLoop>
#include <QPrintDialog>
-#include <QPrinter>
#include <QPainter>
#include <QPrintPreviewDialog>
#include <QWebEngineView>
@@ -59,7 +10,7 @@
PrintHandler::PrintHandler(QObject *parent)
: QObject(parent)
{
-
+ m_printer.setResolution(300);
}
void PrintHandler::setView(QWebEngineView *view)
@@ -67,36 +18,39 @@ void PrintHandler::setView(QWebEngineView *view)
Q_ASSERT(!m_view);
m_view = view;
connect(view, &QWebEngineView::printRequested, this, &PrintHandler::printPreview);
+ connect(view, &QWebEngineView::printFinished, this, &PrintHandler::printFinished);
}
void PrintHandler::print()
{
- QPrinter printer(QPrinter::HighResolution);
- QPrintDialog dialog(&printer, m_view);
+ QPrintDialog dialog(&m_printer, m_view);
if (dialog.exec() != QDialog::Accepted)
return;
- printDocument(&printer);
+ printDocument(&m_printer);
}
void PrintHandler::printDocument(QPrinter *printer)
{
- QEventLoop loop;
- bool result;
- connect(m_view, &QWebEngineView::printFinished, [&](bool success) { result = success; loop.quit(); });
m_view->print(printer);
- loop.exec();
- if (!result) {
+ // User input in the print preview dialog while we're waiting on a print task
+ // can mess up the internal state and cause a crash.
+ m_waitForResult.exec(QEventLoop::ExcludeUserInputEvents);
+}
+
+void PrintHandler::printFinished(bool success)
+{
+ if (!success) {
QPainter painter;
- if (painter.begin(printer)) {
+ if (painter.begin(&m_printer)) {
QFont font = painter.font();
font.setPixelSize(20);
painter.setFont(font);
painter.drawText(QPointF(10,25),
QStringLiteral("Could not generate print preview."));
-
painter.end();
}
}
+ m_waitForResult.quit();
}
void PrintHandler::printPreview()
@@ -106,9 +60,7 @@ void PrintHandler::printPreview()
if (m_inPrintPreview)
return;
m_inPrintPreview = true;
- QPrinter printer;
- printer.setResolution(300);
- QPrintPreviewDialog preview(&printer, m_view);
+ QPrintPreviewDialog preview(&m_printer, m_view);
connect(&preview, &QPrintPreviewDialog::paintRequested,
this, &PrintHandler::printDocument);
preview.exec();
diff --git a/examples/webenginewidgets/printme/printhandler.h b/examples/webenginewidgets/printme/printhandler.h
index 663fd73d6..ab9a8c3a4 100644
--- a/examples/webenginewidgets/printme/printhandler.h
+++ b/examples/webenginewidgets/printme/printhandler.h
@@ -1,57 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PRINTHANDLER_H
#define PRINTHANDLER_H
+#include <QEventLoop>
#include <QObject>
+#include <QPrinter>
QT_BEGIN_NAMESPACE
class QPainter;
@@ -70,9 +25,12 @@ public slots:
void print();
void printPreview();
void printDocument(QPrinter *printer);
+ void printFinished(bool success);
private:
QWebEngineView *m_view = nullptr;
+ QPrinter m_printer;
+ QEventLoop m_waitForResult;
bool m_inPrintPreview = false;
};
diff --git a/examples/webenginewidgets/push-notifications/CMakeLists.txt b/examples/webenginewidgets/push-notifications/CMakeLists.txt
new file mode 100644
index 000000000..3328c2ce9
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/CMakeLists.txt
@@ -0,0 +1,46 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(notifications LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/push-notifications")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
+
+qt_add_executable(push-notifications
+ main.cpp
+ notificationpopup.h
+)
+
+set_target_properties(push-notifications PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(push-notifications PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::WebEngineWidgets
+)
+
+qt_add_resources(push-notifications "data"
+ PREFIX
+ "/"
+ BASE
+ "data"
+ FILES
+ "data/icon.png"
+)
+
+install(TARGETS push-notifications
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/webenginewidgets/push-notifications/content/index.html b/examples/webenginewidgets/push-notifications/content/index.html
new file mode 100644
index 000000000..cce3055cd
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/content/index.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Push Notification Using Node and FCM</title>
+ <link rel="stylesheet" href="style.css">
+</head>
+<body>
+ <h1>Push Notification Using NodeJS and QtWebEngine</h1>
+ <div id="app">
+ <div id="ping-setup">
+ <form>
+ <div>
+ Ping Me Every [sec]:
+ </div>
+ <div class="ping-input">
+ <input type="number" name="seconds" min="0" max="3600" required="">
+ </div><button>Ping Me</button>
+ </form>
+ </div>
+ <div id="ping-clear">
+ <div id="ping-text"></div><button id="ping-clear-button">Clear</button>
+ </div>
+ </div>
+ <script src="ping.js"></script>
+</body>
+</html>
diff --git a/examples/webenginewidgets/push-notifications/content/ping.js b/examples/webenginewidgets/push-notifications/content/ping.js
new file mode 100644
index 000000000..285a57019
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/content/ping.js
@@ -0,0 +1,84 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+const publicVapidKey =
+ "BNO4fIv439RpvbReeABNlDNiiBD2Maykn7EVnwsPseH7-P5hjnzZLEfnejXVP7Zt6MFoKqKeHm4nV9BHvbgoRPg";
+
+async function setup(delay)
+{
+ console.log('>> register service worker...');
+ const register = await navigator.serviceWorker.register('/worker.js', { scope : '/' });
+ console.log('>> service worker registered...');
+
+ console.log('>> subscribe push subscription to FCM');
+ var subscription = await register.pushManager.subscribe(
+ { userVisibleOnly : true, applicationServerKey : publicVapidKey });
+ console.log('>> subscription created...');
+
+ console.log('>> subscribe to push service...');
+ await fetch('/subscribe', {
+ method : 'POST',
+ body : JSON.stringify(subscription),
+ headers : { 'content-type' : 'application/json', 'ping-time' : delay }
+ });
+ console.log('>> push subscription created...')
+}
+
+async function clear()
+{
+ const register = await navigator.serviceWorker.getRegistration();
+ var subscription = await register.pushManager.getSubscription();
+ console.log('>> unsubscribe to push service...');
+ await fetch('/unsubscribe', {
+ method : 'POST',
+ body : JSON.stringify(subscription),
+ headers : { 'content-type' : 'application/json' }
+ });
+ console.log('>> push unsubscription removed...')
+
+ console.log('>> unsubscribe push subscription to FCM');
+ await subscription.unsubscribe();
+ console.log('>> subscription removed...');
+}
+
+function displaySetup(delay = null)
+{
+ const pingSetup = document.getElementById('ping-setup');
+ const pingClear = document.getElementById('ping-clear');
+ const pingText = document.getElementById('ping-text');
+ if (delay) {
+ pingClear.style.display = 'block';
+ pingSetup.style.display = 'none';
+ pingText.innerHTML = 'Ping Me Every ' + delay + ' seconds';
+ } else {
+ pingClear.style.display = 'none';
+ pingSetup.style.display = 'block';
+ pingText.innerHTML = "";
+ }
+}
+
+function handleSetupPing(event)
+{
+ event.preventDefault();
+
+ const seconds = document.forms[0].seconds.value;
+ document.forms[0].reset();
+
+ // check for service worker support
+ if ('serviceWorker' in navigator) {
+ setup(seconds).catch(err => console.error(err));
+ }
+
+ displaySetup(seconds);
+};
+
+function handleClearPing(event)
+{
+ event.preventDefault();
+ clear();
+ displaySetup();
+};
+
+document.forms[0].addEventListener('submit', handleSetupPing);
+const clearButton = document.getElementById('ping-clear-button');
+clearButton.addEventListener('click', handleClearPing);
diff --git a/examples/webenginewidgets/push-notifications/content/style.css b/examples/webenginewidgets/push-notifications/content/style.css
new file mode 100644
index 000000000..8176462a2
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/content/style.css
@@ -0,0 +1,29 @@
+body {
+ font-family: monaco;
+ height: 100vh;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ display: flex;
+}
+#ping-clear,
+#ping-setup {
+ font-size: 32px;
+ text-align: center;
+}
+.form-inputs{
+ margin-top: 20px;
+}
+input {
+ width: 100px;
+ height: 30px;
+}
+button {
+ font-size: 16px;
+}
+#ping-text {
+ margin-bottom: 30px;
+}
+#ping-clear {
+ display: none;
+}
diff --git a/examples/webenginewidgets/push-notifications/content/worker.js b/examples/webenginewidgets/push-notifications/content/worker.js
new file mode 100644
index 000000000..ed660a6e9
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/content/worker.js
@@ -0,0 +1,7 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+self.addEventListener('push', event => {
+ const data = event.data.json();
+ self.registration.showNotification(data.title, { body : data.text });
+});
diff --git a/examples/webenginewidgets/webui/webui.qrc b/examples/webenginewidgets/push-notifications/data/data.qrc
index 6ddf01fa2..619648d1b 100644
--- a/examples/webenginewidgets/webui/webui.qrc
+++ b/examples/webenginewidgets/push-notifications/data/data.qrc
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>about.html</file>
+ <file>icon.png</file>
</qresource>
</RCC>
diff --git a/examples/webenginewidgets/push-notifications/data/icon.png b/examples/webenginewidgets/push-notifications/data/icon.png
new file mode 100644
index 000000000..4c3870c06
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/data/icon.png
Binary files differ
diff --git a/examples/webenginewidgets/push-notifications/doc/images/notification.png b/examples/webenginewidgets/push-notifications/doc/images/notification.png
new file mode 100644
index 000000000..ec5c67457
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/images/notification.png
Binary files differ
diff --git a/examples/webenginewidgets/push-notifications/doc/images/permissions.png b/examples/webenginewidgets/push-notifications/doc/images/permissions.png
new file mode 100644
index 000000000..dedb6e472
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/images/permissions.png
Binary files differ
diff --git a/examples/webenginewidgets/push-notifications/doc/images/push-notifications.png b/examples/webenginewidgets/push-notifications/doc/images/push-notifications.png
new file mode 100644
index 000000000..c5ba5f589
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/images/push-notifications.png
Binary files differ
diff --git a/examples/webenginewidgets/push-notifications/doc/images/website.png b/examples/webenginewidgets/push-notifications/doc/images/website.png
new file mode 100644
index 000000000..10a4a6150
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/images/website.png
Binary files differ
diff --git a/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qdoc b/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qdoc
new file mode 100644
index 000000000..05ccf3e8b
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qdoc
@@ -0,0 +1,203 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+
+\example webenginewidgets/push-notifications
+\examplecategory {Web Technologies}
+\title WebEngine Push Notifications Example
+\ingroup webengine-widgetexamples
+\brief Demonstrates how to subscribe to and unsubscribe from push notifications.
+
+In this example we are going to send push notifications from a web push service to the user.
+This is the typical scenario where messages are sent from the application server i.e. website
+back-end through a 3rd-party push service, to finally arrive at the user's browser in form of
+notifications. To demonstrate this flow, we will implement a simple push service server
+application, to which the user can subscribe to receive \e ping messages.
+
+As already mentioned, in such a workflow there are three different parties involved:
+
+\list
+ \li the user's web browser where they receive push notifications
+ \li 3rd-party push service, which is defined by a subscription endpoint and is a part
+ of a browser's push service implementation
+ \li application server, which will store user's subscriptions and initiate push messages
+ using a subscription endpoint
+\endlist
+
+The user visits a website, where a JavaScript web application uses the JavaScript Push API
+to create a push notification subscription. The user is then asked to grant a permission
+to receive and display push notifications. Once accepted, the Push API establishes a push channel
+with a 3rd-party push service, which in case of QtWebEngine is \l {https://firebase.google.com}
+{Firebase Cloud Messaging (FCM)}. The unique push subscription is created that
+includes the subscription endpoint URL. The browser then sends a subscription message
+to the application server forwarding the endpoint setup. The application server can now
+use the subscription endpoint to send notifications to the browser. The browser push service
+implementation will deliver a push message. However, to show it, a service worker must
+be registered. As the service worker runs in the background, it allows displaying notifications
+even if a website, which has installed it, is no longer opened.
+
+\image push-notifications.png
+
+Let's go more into implementation details. We start with implementing our custom
+push service using NodeJS with two modules:
+
+\list
+ \li \l {https://github.com/web-push-libs/web-push} {web-push} - provides the web-push protocol
+ implementation
+ \li \l {https://github.com/expressjs/express} {express} - provides the web application framework
+\endlist
+
+Let's initialize a new project and install the required modules in the root directory of this
+example:
+
+\snippet /push-notifications/commands 0
+
+These commands should create package.js, which defines the start command:
+
+\snippet /push-notifications/commands 1
+
+Now let's move on to the push service back-end implementation in server.js.
+
+We start by including the required modules and doing basic \e express framework setup, which
+we use to create our custom push server. For simplicity we are going to handle only one
+subscription at a time. To do that we need to create \e VAPID keys which we are going to
+generate with \e web-push libs. The public key is going to be used by the front-end and authenticate
+to the service.
+
+\quotefromfile webenginewidgets/push-notifications/server.js
+\skipto const express
+\printto add subscribe route
+
+\note We are not going to cover the encryption of messages in this example.
+
+To generate keys, we can use the tool shipped with \e web-push lib, that is installed by
+\c npm in our example's root directory.
+
+\snippet /push-notifications/commands 2
+
+Now we add two \c routes to the push server. One to \c subscribe and one to \c unsubscribe,
+so that our front-end can send an HTTP POST request to handle the push subscription.
+In the subscribe request we will get \c subscription in the request body and we also retrieve
+the custom header \c ping-time that defines how often the ping messages should be pushed to
+the user. We keep around the \c subscription to be able to send push notifications later.
+As a confirmation, we send the 201 status code and schedule the first push notification based on
+the \c ping-time value. The \c unsubscribe request simply removes a subscription.
+
+\quotefromfile webenginewidgets/push-notifications/server.js
+\skipto add subscribe route
+\printto function sendNotification
+
+The \c sendNotication() function sends push messages using the web-push lib. We create the payload
+with the message we want to present to a user and schedule the next push message.
+
+\quotefromfile webenginewidgets/push-notifications/server.js
+\skipto function sendNotification
+\printto server.listen
+
+In the end we start the server to listen on the given port.
+
+\quotefromfile webenginewidgets/push-notifications/server.js
+\skipto server.listen
+\printline started
+
+Let's move now to our front-end. We create a simple page index.html, where the user can enter how
+often they want to receive ping notification messages. We will have two buttons:
+\e {Ping Me} to subscribe for push notifications and \e Clear to unsubscribe.
+In the end we load ping.js, which we cover next.
+
+\quotefromfile webenginewidgets/push-notifications/content/index.html
+\skipto <body>
+\printuntil </body>
+
+The last piece is creating the logic for the push subscription within the front-end. Here we have two
+functions, \c setup and \c clear, to handle subscriptions. When the user clicks on the \e {Ping Me}
+button, \c setup is called. To be able to receive notifications, the service worker is needed.
+This way the user can leave the website and still get notified as the service worker works
+in the background and handles incoming messages. To achieve that, we have to first register
+one with:
+
+\quotefromfile webenginewidgets/push-notifications/content/ping.js
+\skipto const register
+\printline worker.js
+
+The call to \c cpushManager.subscribe() will trigger a permission prompt, which is displayed to the
+user. If the permission is granted, the push subscription is returned. It includes a URL endpoint
+that allows sending notifications to the browser, where the registered service worker waits for
+push messages.
+
+\quotefromfile webenginewidgets/push-notifications/content/ping.js
+\skipto var subscription
+\printto console.log
+
+As mentioned the subscription is created for FCM and should be now sent to our custom server
+with an HTTP POST request. In addition, we add to the post request the HTTP header with the
+\c ping-time the user entered on our website.
+
+\quotefromfile webenginewidgets/push-notifications/content/ping.js
+\skipto await fetch
+\printto console.log
+
+The function \c clear call unsubscribes first from our push server by sending an HTTP POST request
+and later from the 3rd-party push service (FCM).
+
+\quotefromfile webenginewidgets/push-notifications/content/ping.js
+\skipuntil async function clear()
+\skipuntil {
+\printto console.log
+\dots
+\skipto await fetch
+\printto console.log
+\dots
+\skipto await subscription
+\printto console.log
+
+The rest of code in ping.js is just boilerplate code to read a user provided value
+and call \c setup() or \c clear().
+
+As the last part of the front-end let's look inside a service worker script, where we simply
+register an event listener for \e push events.
+
+\quotefromfile webenginewidgets/push-notifications/content/worker.js
+\skipto self
+\printuntil });
+\printuntil });
+
+When a push event comes we simply use the Notification JavaScript API to display a notification.
+
+\note QtWebEngine Notification Example shows how to provide your own handler and customize
+the look and feel of a notification message.
+
+Having the implementation in place, we can start the server on localhost at the port 5000.
+To do that, we can simply enter in the console in the project's root directory:
+
+\snippet /push-notifications/commands 3
+
+Now we can look into the \e push-notification browser application, which is based on
+\l {WebEngine Notifications Example}:
+
+\quotefromfile webenginewidgets/push-notifications/main.cpp
+\skipto main
+\printuntil app.exec
+\printuntil }
+
+This application simply opens the page at \c http:\\localhost:5000. We are not going into detail
+about how to open a notification as it is documented \l {WebEngine Notifications Example}{here}.
+However, you need to modify the application in two ways. First, \c QWebEngineProfile cannot be
+set to \e off-the-record because push messaging would be disabled. Therefore, as you can see
+above, \c QWebEngineProfile is initialized with the name. Second, you need to enable push
+messaging with the call QWebEngineProfile::setPushServiceEnabled for the created \c profile.
+
+When the application runs it displays:
+
+\image website.png
+
+After granting the permission we can send our ping request:
+
+\image permissions.png
+
+We should see the coming push notification:
+
+\image notification.png
+
+*/
diff --git a/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qmodel b/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qmodel
new file mode 100644
index 000000000..048a55911
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/doc/src/push-notifications.qmodel
@@ -0,0 +1,837 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<qmt>
+ <project>
+ <uid>{9fd14f7e-7b67-4e13-9980-ef8fbe24b780}</uid>
+ <root-package>
+ <instance>
+ <MPackage>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{a26e0efd-1b21-4fba-96ce-a607bbcdb4f7}</uid>
+ </MElement>
+ </base-MElement>
+ <name>push_notifications</name>
+ <children>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{6b1a06e9-960b-4a10-872e-5504d8c0b127}</uid>
+ <target>
+ <instance type="MCanvasDiagram">
+ <MCanvasDiagram>
+ <base-MDiagram>
+ <MDiagram>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{6b1a06e9-960b-4a10-872e-5504d8c0b127}</uid>
+ </MElement>
+ </base-MElement>
+ <name>push_notifications</name>
+ </MObject>
+ </base-MObject>
+ <elements>
+ <qlist>
+ <item>
+ <instance type="DBoundary">
+ <DBoundary>
+ <base-DElement>
+ <DElement>
+ <uid>{d50762f2-c7f4-4d52-9592-8bcc07274ba1}</uid>
+ </DElement>
+ </base-DElement>
+ <text>Browser / User Agent</text>
+ <pos>x:415;y:390</pos>
+ <rect>x:-105;y:-125;w:210;h:250</rect>
+ </DBoundary>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{cc80cad6-2e47-4913-aeb1-0c6f41de44bb}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{121189af-36df-4efa-b451-3f1f85ef339f}</object>
+ <name>JavaScript Web Application</name>
+ <pos>x:410;y:395</pos>
+ <rect>x:-75;y:-15;w:150;h:30</rect>
+ <visual-role>0</visual-role>
+ </DObject>
+ </base-DObject>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{8bde1815-304a-41f6-8528-c754dc3d1eda}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{13c69399-5587-4169-a012-8d86216139fd}</object>
+ <name>Push Manager API</name>
+ <pos>x:410;y:320</pos>
+ <rect>x:-75;y:-15;w:150;h:30</rect>
+ <auto-sized>false</auto-sized>
+ <visual-role>0</visual-role>
+ </DObject>
+ </base-DObject>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{75431119-9e8e-4e3e-a539-9d7bad6dbf81}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</object>
+ <name>Service Worker</name>
+ <pos>x:410;y:470</pos>
+ <rect>x:-75;y:-15;w:150;h:30</rect>
+ <auto-sized>false</auto-sized>
+ <visual-role>0</visual-role>
+ </DObject>
+ </base-DObject>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{0a7b0146-d34b-4c39-a1af-df15a1b4108d}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{648fd8d0-6f61-4cc9-b5ce-6c5b9057fe5d}</object>
+ <a>{cc80cad6-2e47-4913-aeb1-0c6f41de44bb}</a>
+ <b>{8bde1815-304a-41f6-8528-c754dc3d1eda}</b>
+ <name>subscribe</name>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{e7d4a675-ddbd-41aa-a802-32221a56dae2}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{afae2401-ea81-4514-aa80-da53d61a8516}</object>
+ <a>{cc80cad6-2e47-4913-aeb1-0c6f41de44bb}</a>
+ <b>{75431119-9e8e-4e3e-a539-9d7bad6dbf81}</b>
+ <name>register</name>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{998e7d36-3416-4b2f-843a-a437449f09f1}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</object>
+ <name>Firebase Cloud Messaging </name>
+ <pos>x:770;y:320</pos>
+ <rect>x:-75;y:-15;w:150;h:30</rect>
+ <visual-role>6</visual-role>
+ </DObject>
+ </base-DObject>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{28c1fccd-c50e-458c-865d-4ba41d55690b}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{d9959769-74a4-40ad-bf00-904c12a67309}</object>
+ <a>{8bde1815-304a-41f6-8528-c754dc3d1eda}</a>
+ <b>{998e7d36-3416-4b2f-843a-a437449f09f1}</b>
+ <name>create subscription</name>
+ </DRelation>
+ </base-DRelation>
+ <direction>2</direction>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{ba581e41-cc00-4129-adae-0a1208bb3222}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{13d79379-1727-46a3-947c-e3f2f6eb3a87}</object>
+ <name>Push Application Server</name>
+ <pos>x:770;y:390</pos>
+ <rect>x:-75;y:-15;w:150;h:30</rect>
+ <auto-sized>false</auto-sized>
+ <visual-role>6</visual-role>
+ </DObject>
+ </base-DObject>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{e796d1cc-f574-45db-a440-7e47d7560d71}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{373c492c-0b9a-4032-9ff4-b3a7cc442883}</object>
+ <a>{cc80cad6-2e47-4913-aeb1-0c6f41de44bb}</a>
+ <b>{ba581e41-cc00-4129-adae-0a1208bb3222}</b>
+ <name>subscribe with endpoint</name>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{6332f8ae-ef9d-4c15-9fbf-d6ee06ba3f84}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{94241d64-4e88-4855-8e78-365be237108b}</object>
+ <a>{ba581e41-cc00-4129-adae-0a1208bb3222}</a>
+ <b>{998e7d36-3416-4b2f-843a-a437449f09f1}</b>
+ <name>push notification</name>
+ <points>
+ <qlist>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:770;y:335</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ </qlist>
+ </points>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DItem">
+ <DItem>
+ <base-DObject>
+ <DObject>
+ <base-DElement>
+ <DElement>
+ <uid>{582af542-5f2d-4660-a6d0-a3bd983d9682}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{00b8f12d-e08b-426a-83b8-83fea8907fab}</object>
+ <name>User</name>
+ <pos>x:185;y:395</pos>
+ <rect>x:-10;y:-20;w:20;h:40</rect>
+ <visual-role>0</visual-role>
+ </DObject>
+ </base-DObject>
+ <variety>actor</variety>
+ <shape-editable>false</shape-editable>
+ </DItem>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{66ca12e1-84a1-4247-82e5-ae6891f3f376}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{6d0ce78f-28e1-4a82-a443-59f4efcb8e66}</object>
+ <a>{582af542-5f2d-4660-a6d0-a3bd983d9682}</a>
+ <b>{cc80cad6-2e47-4913-aeb1-0c6f41de44bb}</b>
+ <name>subscribe</name>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{7657479a-a855-4d97-8c61-098690da9023}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{eef542f5-e2cf-40a8-92c9-9892f3d06e1f}</object>
+ <a>{75431119-9e8e-4e3e-a539-9d7bad6dbf81}</a>
+ <b>{582af542-5f2d-4660-a6d0-a3bd983d9682}</b>
+ <name>notify</name>
+ <points>
+ <qlist>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:340;y:430</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ </qlist>
+ </points>
+ </DRelation>
+ </base-DRelation>
+ </DDependency>
+ </instance>
+ </item>
+ <item>
+ <instance type="DDependency">
+ <DDependency>
+ <base-DRelation>
+ <DRelation>
+ <base-DElement>
+ <DElement>
+ <uid>{97f3e5b0-93ca-4351-98d6-ad88567979f7}</uid>
+ </DElement>
+ </base-DElement>
+ <object>{963ad9f9-ecad-430f-8233-b7897fa630bd}</object>
+ <a>{75431119-9e8e-4e3e-a539-9d7bad6dbf81}</a>
+ <b>{998e7d36-3416-4b2f-843a-a437449f09f1}</b>
+ <name>push notification</name>
+ <points>
+ <qlist>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:535;y:470</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:590;y:470</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:615;y:470</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:670;y:470</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ <item>
+ <DRelation--IntermediatePoint>
+ <pos>x:670;y:365</pos>
+ </DRelation--IntermediatePoint>
+ </item>
+ </qlist>
+ </points>
+ </DRelation>
+ </base-DRelation>
+ <direction>1</direction>
+ </DDependency>
+ </instance>
+ </item>
+ </qlist>
+ </elements>
+ <last-modified>1665083804306</last-modified>
+ <toolbarid>UseCases</toolbarid>
+ </MDiagram>
+ </base-MDiagram>
+ </MCanvasDiagram>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{121189af-36df-4efa-b451-3f1f85ef339f}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{121189af-36df-4efa-b451-3f1f85ef339f}</uid>
+ </MElement>
+ </base-MElement>
+ <name>JavaScript Web Application</name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{648fd8d0-6f61-4cc9-b5ce-6c5b9057fe5d}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{648fd8d0-6f61-4cc9-b5ce-6c5b9057fe5d}</uid>
+ </MElement>
+ </base-MElement>
+ <name>subscribe</name>
+ <a>{121189af-36df-4efa-b451-3f1f85ef339f}</a>
+ <b>{13c69399-5587-4169-a012-8d86216139fd}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{afae2401-ea81-4514-aa80-da53d61a8516}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{afae2401-ea81-4514-aa80-da53d61a8516}</uid>
+ </MElement>
+ </base-MElement>
+ <name>register</name>
+ <a>{121189af-36df-4efa-b451-3f1f85ef339f}</a>
+ <b>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{373c492c-0b9a-4032-9ff4-b3a7cc442883}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{373c492c-0b9a-4032-9ff4-b3a7cc442883}</uid>
+ </MElement>
+ </base-MElement>
+ <name>subscribe with endpoint</name>
+ <a>{121189af-36df-4efa-b451-3f1f85ef339f}</a>
+ <b>{13d79379-1727-46a3-947c-e3f2f6eb3a87}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{13c69399-5587-4169-a012-8d86216139fd}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{13c69399-5587-4169-a012-8d86216139fd}</uid>
+ </MElement>
+ </base-MElement>
+ <name>Push Manager API</name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{d9959769-74a4-40ad-bf00-904c12a67309}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{d9959769-74a4-40ad-bf00-904c12a67309}</uid>
+ </MElement>
+ </base-MElement>
+ <name>create subscription</name>
+ <a>{13c69399-5587-4169-a012-8d86216139fd}</a>
+ <b>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</b>
+ </MRelation>
+ </base-MRelation>
+ <direction>2</direction>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</uid>
+ </MElement>
+ </base-MElement>
+ <name>Service Worker</name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{bfebbc32-3541-4c1a-b3c6-a3652f700767}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{bfebbc32-3541-4c1a-b3c6-a3652f700767}</uid>
+ </MElement>
+ </base-MElement>
+ <name>push notification</name>
+ <a>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</a>
+ <b>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</b>
+ </MRelation>
+ </base-MRelation>
+ <direction>1</direction>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{89d5f886-1913-4bb7-be32-cdd5cb61eebc}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{89d5f886-1913-4bb7-be32-cdd5cb61eebc}</uid>
+ </MElement>
+ </base-MElement>
+ <name>notify</name>
+ <a>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</a>
+ <b>{00b8f12d-e08b-426a-83b8-83fea8907fab}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{eef542f5-e2cf-40a8-92c9-9892f3d06e1f}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{eef542f5-e2cf-40a8-92c9-9892f3d06e1f}</uid>
+ </MElement>
+ </base-MElement>
+ <name>notify</name>
+ <a>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</a>
+ <b>{00b8f12d-e08b-426a-83b8-83fea8907fab}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{963ad9f9-ecad-430f-8233-b7897fa630bd}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{963ad9f9-ecad-430f-8233-b7897fa630bd}</uid>
+ </MElement>
+ </base-MElement>
+ <name>push notification</name>
+ <a>{3f1676be-d3a4-4751-8bcb-400b11c88ada}</a>
+ <b>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</b>
+ </MRelation>
+ </base-MRelation>
+ <direction>1</direction>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</uid>
+ </MElement>
+ </base-MElement>
+ <name>Firebase Cloud Messaging </name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{560fb941-261e-4f45-8909-2106283fdb3e}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{560fb941-261e-4f45-8909-2106283fdb3e}</uid>
+ </MElement>
+ </base-MElement>
+ <a>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</a>
+ <b>{13c69399-5587-4169-a012-8d86216139fd}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{13d79379-1727-46a3-947c-e3f2f6eb3a87}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{13d79379-1727-46a3-947c-e3f2f6eb3a87}</uid>
+ </MElement>
+ </base-MElement>
+ <name>Push Application Server</name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{94241d64-4e88-4855-8e78-365be237108b}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{94241d64-4e88-4855-8e78-365be237108b}</uid>
+ </MElement>
+ </base-MElement>
+ <name>push notification</name>
+ <a>{13d79379-1727-46a3-947c-e3f2f6eb3a87}</a>
+ <b>{5a7b90ea-801e-43ea-a0b5-edaa59761b5b}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ <item>
+ <handle>
+ <uid>{00b8f12d-e08b-426a-83b8-83fea8907fab}</uid>
+ <target>
+ <instance type="MItem">
+ <MItem>
+ <base-MObject>
+ <MObject>
+ <base-MElement>
+ <MElement>
+ <uid>{00b8f12d-e08b-426a-83b8-83fea8907fab}</uid>
+ </MElement>
+ </base-MElement>
+ <name>User</name>
+ <relations>
+ <handles>
+ <handles>
+ <qlist>
+ <item>
+ <handle>
+ <uid>{6d0ce78f-28e1-4a82-a443-59f4efcb8e66}</uid>
+ <target>
+ <instance type="MDependency">
+ <MDependency>
+ <base-MRelation>
+ <MRelation>
+ <base-MElement>
+ <MElement>
+ <uid>{6d0ce78f-28e1-4a82-a443-59f4efcb8e66}</uid>
+ </MElement>
+ </base-MElement>
+ <name>subscribe</name>
+ <a>{00b8f12d-e08b-426a-83b8-83fea8907fab}</a>
+ <b>{121189af-36df-4efa-b451-3f1f85ef339f}</b>
+ </MRelation>
+ </base-MRelation>
+ </MDependency>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </relations>
+ </MObject>
+ </base-MObject>
+ <variety-editable>false</variety-editable>
+ <variety>actor</variety>
+ </MItem>
+ </instance>
+ </target>
+ </handle>
+ </item>
+ </qlist>
+ </handles>
+ </handles>
+ </children>
+ </MObject>
+ </base-MObject>
+ </MPackage>
+ </instance>
+ </root-package>
+ </project>
+</qmt>
diff --git a/examples/webenginewidgets/push-notifications/main.cpp b/examples/webenginewidgets/push-notifications/main.cpp
new file mode 100644
index 000000000..18a862182
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/main.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "notificationpopup.h"
+
+#include <QApplication>
+#include <QWebEngineProfile>
+#include <QWebEnginePage>
+#include <QWebEngineView>
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setOrganizationName("QtExamples");
+ QApplication app(argc, argv);
+
+ const QString name =
+ QString::fromLatin1("push-notifications.%1").arg(qWebEngineChromiumVersion());
+
+ QScopedPointer<QWebEngineProfile> profile(new QWebEngineProfile(name));
+ QWebEngineView view(profile.data());
+ auto popup = new NotificationPopup(&view);
+
+ QObject::connect(view.page(), &QWebEnginePage::featurePermissionRequested,
+ [&](const QUrl &origin, QWebEnginePage::Feature feature) {
+ if (feature != QWebEnginePage::Notifications)
+ return;
+
+ view.page()->setFeaturePermission(origin, feature,
+ QWebEnginePage::PermissionGrantedByUser);
+ });
+
+ profile->setPushServiceEnabled(true);
+ profile->setNotificationPresenter([&](std::unique_ptr<QWebEngineNotification> notification) {
+ popup->present(notification);
+ });
+
+ view.resize(640, 480);
+ view.setUrl(QUrl("http://localhost:5000"));
+ view.show();
+ return app.exec();
+}
diff --git a/examples/webenginewidgets/push-notifications/notificationpopup.h b/examples/webenginewidgets/push-notifications/notificationpopup.h
new file mode 100644
index 000000000..cf53ded45
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/notificationpopup.h
@@ -0,0 +1,91 @@
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#pragma once
+
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QPushButton>
+#include <QSpacerItem>
+#include <QTimer>
+#include <QVBoxLayout>
+#include <QWebEngineNotification>
+
+#include <memory>
+
+class NotificationPopup : public QWidget
+{
+ Q_OBJECT
+
+ QLabel m_icon, m_title, m_message;
+ std::unique_ptr<QWebEngineNotification> notification;
+
+public:
+ NotificationPopup(QWidget *parent) : QWidget(parent)
+ {
+ setWindowFlags(Qt::ToolTip);
+ auto rootLayout = new QHBoxLayout(this);
+
+ rootLayout->addWidget(&m_icon);
+
+ auto bodyLayout = new QVBoxLayout;
+ rootLayout->addLayout(bodyLayout);
+
+ auto titleLayout = new QHBoxLayout;
+ bodyLayout->addLayout(titleLayout);
+
+ titleLayout->addWidget(&m_title);
+ titleLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
+
+ auto close = new QPushButton(tr("Close"));
+ titleLayout->addWidget(close);
+ connect(close, &QPushButton::clicked, this, &NotificationPopup::onClosed);
+
+ bodyLayout->addWidget(&m_message);
+ adjustSize();
+ }
+
+ void present(std::unique_ptr<QWebEngineNotification> &newNotification)
+ {
+ if (notification) {
+ notification->close();
+ notification.reset();
+ }
+
+ notification.swap(newNotification);
+
+ m_title.setText("<b>" + notification->title() + "</b>");
+ m_message.setText(notification->message());
+ m_icon.setPixmap(QPixmap(":/icon.png").scaledToHeight(m_icon.height()));
+
+ show();
+ notification->show();
+
+ connect(notification.get(), &QWebEngineNotification::closed, this,
+ &NotificationPopup::onClosed);
+ QTimer::singleShot(10000, notification.get(), [&]() { onClosed(); });
+
+ // position our popup in the right corner of its parent widget
+ move(parentWidget()->mapToGlobal(parentWidget()->rect().bottomRight()
+ - QPoint(width() + 10, height() + 10)));
+ }
+
+protected slots:
+ void onClosed()
+ {
+ hide();
+ notification->close();
+ notification.reset();
+ }
+
+protected:
+ void mouseReleaseEvent(QMouseEvent *event) override
+ {
+ QWidget::mouseReleaseEvent(event);
+ if (notification && event->button() == Qt::LeftButton) {
+ notification->click();
+ onClosed();
+ }
+ }
+};
diff --git a/examples/webenginewidgets/push-notifications/push-notifications.pro b/examples/webenginewidgets/push-notifications/push-notifications.pro
new file mode 100644
index 000000000..5ffb85fd7
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/push-notifications.pro
@@ -0,0 +1,10 @@
+QT += webenginewidgets
+
+HEADERS = notificationpopup.h
+
+SOURCES = main.cpp
+
+RESOURCES = data/data.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/push-notifications
+INSTALLS += target
diff --git a/examples/webenginewidgets/push-notifications/server.js b/examples/webenginewidgets/push-notifications/server.js
new file mode 100644
index 000000000..fc7deb08a
--- /dev/null
+++ b/examples/webenginewidgets/push-notifications/server.js
@@ -0,0 +1,65 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+const express = require('express');
+const webpush = require('web-push');
+
+// setup server
+const port = 5000;
+const server = express();
+server.use(express.json());
+server.use(express.static('content'));
+
+// we support only one subscription at the time
+var subscription = null;
+
+// setup vapid keys
+const vapidKeys = {
+ publicKey :
+ "BNO4fIv439RpvbReeABNlDNiiBD2Maykn7EVnwsPseH7-P5hjnzZLEfnejXVP7Zt6MFoKqKeHm4nV9BHvbgoRPg",
+ privateKey : "HqhrzsRfG5-SB3j45lyUmV7cYZuy-71r2Bb0tgaOefk"
+};
+
+// set vapid keys for webpush libs
+webpush.setVapidDetails('mailto:push@qt.io', vapidKeys.publicKey, vapidKeys.privateKey);
+
+// add subscribe route
+server.post('/subscribe', (req, res) => {
+
+ // subscription request
+ subscription = req.body;
+ const delay = req.headers['ping-time'];
+ console.log('Got subscription with endpoint: ' + subscription.endpoint);
+ console.log('Ping delay is at: ' + delay);
+
+ // confirm resource created
+ res.status(201).json({});
+
+ // schedule notification
+ setTimeout(() => { sendNotification(delay) }, delay * 1000);
+});
+
+// add unsubscribe route
+server.post('/unsubscribe', (req, res) => {
+ console.log('Got unsubscribe with endpoint: ' + req.body.endpoint);
+ subscription = null;
+ res.status(201).json({});
+});
+
+function sendNotification(delay)
+{
+ if (!subscription)
+ return;
+
+ // create payload text
+ const payload = JSON.stringify({ title : 'Ping !', text : 'Visit qt.io', url : 'www.qt.io' });
+
+ // send notification
+ console.log('Sending notification !');
+ webpush.sendNotification(subscription, payload).catch(err => console.error(err));
+
+ // schedule next notification
+ setTimeout(() => { sendNotification(delay) }, delay * 1000);
+}
+
+server.listen(port, () => console.log(`Push server started at port ${port}`));
diff --git a/examples/webenginewidgets/recipebrowser/CMakeLists.txt b/examples/webenginewidgets/recipebrowser/CMakeLists.txt
new file mode 100644
index 000000000..ef858616e
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/CMakeLists.txt
@@ -0,0 +1,76 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(recipebrowser LANGUAGES CXX)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(NOT DEFINED INSTALL_EXAMPLESDIR)
+ set(INSTALL_EXAMPLESDIR "examples")
+endif()
+
+set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/recipebrowser")
+
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
+
+qt_add_executable(recipebrowser
+ main.cpp
+ mainwindow.cpp mainwindow.h mainwindow.ui
+ stylesheetdialog.cpp stylesheetdialog.h stylesheetdialog.ui
+ document.cpp document.h
+)
+
+set_target_properties(recipebrowser PROPERTIES
+ WIN32_EXECUTABLE TRUE
+ MACOSX_BUNDLE TRUE
+)
+
+target_link_libraries(recipebrowser PUBLIC
+ Qt::Core
+ Qt::Gui
+ Qt::WebEngineWidgets
+)
+
+# Resources:
+set(recipebrowser_resource_files
+ "assets/3rdparty/markdown.css"
+ "assets/3rdparty/marked.js"
+ "assets/custom.css"
+ "assets/custom.js"
+ "assets/pages/burger.html"
+ "assets/pages/cupcakes.html"
+ "assets/pages/images/burger.jpg"
+ "assets/pages/images/cupcakes.jpg"
+ "assets/pages/images/pasta.jpg"
+ "assets/pages/images/pizza.jpg"
+ "assets/pages/images/skewers.jpg"
+ "assets/pages/images/soup.jpg"
+ "assets/pages/images/steak.jpg"
+ "assets/pages/pasta.html"
+ "assets/pages/pizza.html"
+ "assets/pages/skewers.html"
+ "assets/pages/soup.html"
+ "assets/pages/steak.html"
+ "assets/icons/edit.svg"
+ "assets/icons/stylesheets.svg"
+ "assets/icons/add.svg"
+ "assets/icons/remove.svg"
+ "assets/icons/view.svg"
+)
+
+qt_add_resources(recipebrowser "recipebrowser"
+ PREFIX
+ "/"
+ BASE
+ "assets"
+ FILES
+ ${recipebrowser_resource_files}
+)
+
+install(TARGETS recipebrowser
+ RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
+ BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
+ LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
+)
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKDOWN-LICENSE.txt b/examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKDOWN-LICENSE.txt
index 23c52cc43..23c52cc43 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKDOWN-LICENSE.txt
+++ b/examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKDOWN-LICENSE.txt
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt b/examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKED-LICENSE.txt
index 8e3ba0e0a..8e3ba0e0a 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/MARKED-LICENSE.txt
+++ b/examples/webenginewidgets/recipebrowser/assets/3rdparty/MARKED-LICENSE.txt
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/markdown.css b/examples/webenginewidgets/recipebrowser/assets/3rdparty/markdown.css
index 24fc2ffe2..24fc2ffe2 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/markdown.css
+++ b/examples/webenginewidgets/recipebrowser/assets/3rdparty/markdown.css
diff --git a/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js b/examples/webenginewidgets/recipebrowser/assets/3rdparty/marked.js
index 33c02d9cf..33c02d9cf 100644
--- a/examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js
+++ b/examples/webenginewidgets/recipebrowser/assets/3rdparty/marked.js
diff --git a/examples/webenginewidgets/recipebrowser/assets/3rdparty/qt_attribution.json b/examples/webenginewidgets/recipebrowser/assets/3rdparty/qt_attribution.json
new file mode 100644
index 000000000..f8b0fd023
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/3rdparty/qt_attribution.json
@@ -0,0 +1,34 @@
+[
+ {
+ "Id" : "recipebrowser-marked",
+ "Name" : "Marked (WebEngine Recipe Browser example)",
+ "QDocModule" : "qtwebengine",
+ "QtUsage" : "Marked is used in the WebEngine Recipe Browser example",
+ "QtParts" : ["examples"],
+ "Files" : "marked.js",
+ "Description" :
+ "A full-featured markdown parser and compiler, written in JavaScript. Built for speed.",
+ "Homepage" : "https://github.com/chjj/marked",
+ "Version" : "0.4.0",
+ "DownloadLocation" : "https://github.com/markedjs/marked/blob/0.4.0/lib/marked.js",
+ "Copyright" : "Copyright (c) 2011-2018, Christopher Jeffrey",
+ "License" : "MIT License",
+ "LicenseId" : "MIT",
+ "LicenseFile" : "MARKED-LICENSE.txt"
+ },
+ {
+ "Id" : "recipebrowser-markdowncss",
+ "Name" : "Markdown.css (WebEngine Recipe Browser example)",
+ "QDocModule" : "qtwebengine",
+ "QtUsage" : "markdown.css is used in the WebEngine Recipe Browser example",
+ "QtParts" : ["examples"],
+ "Files" : "markdown.css",
+ "Description" : "Markdown.css is better default styling for your Markdown files.",
+ "Version" : "188530e4b5d020d7e237fc6b26be13ebf4a8def3",
+ "DownloadLocation" : "https://bitbucket.org/kevinburke/markdowncss/src/188530e4b5d020d7e237fc6b26be13ebf4a8def3/markdown.css",
+ "Copyright" : "Copyright 2011 Kevin Burke Copyright Twitter Inc.",
+ "License" : "Apache License 2.0",
+ "LicenseId" : "Apache-2.0",
+ "LicenseFile" : "MARKDOWN-LICENSE.txt"
+ }
+ ]
diff --git a/examples/webenginewidgets/recipebrowser/assets/custom.css b/examples/webenginewidgets/recipebrowser/assets/custom.css
new file mode 100644
index 000000000..cc1106af3
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/custom.css
@@ -0,0 +1,28 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+body {
+ padding-top: 0;
+ margin-top: 0;
+}
+
+#content {
+ display: none;
+}
+
+img {
+ width: 100%;
+ height: 100%;
+}
+
+li {
+ margin-left: 25px;
+}
+
+ol li {
+ margin-bottom: 10px;
+}
+
+* {
+ max-width: 960px !important;
+}
diff --git a/examples/webenginewidgets/recipebrowser/assets/custom.js b/examples/webenginewidgets/recipebrowser/assets/custom.js
new file mode 100644
index 000000000..34470164e
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/custom.js
@@ -0,0 +1,13 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+marked.setOptions({
+ renderer : new marked.Renderer(),
+ gfm : true,
+ tables : true,
+ breaks : false,
+ pedantic : false,
+ sanitize : false,
+ smartLists : true,
+ smartypants : false
+});
diff --git a/examples/webenginewidgets/recipebrowser/assets/icons/add.svg b/examples/webenginewidgets/recipebrowser/assets/icons/add.svg
new file mode 100644
index 000000000..b5ecf9ae2
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/icons/add.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M11 15C11 15.5523 11.4477 16 12 16C12.5523 16 13 15.5523 13 15V13H15C15.5523 13 16 12.5523 16 12C16 11.4477 15.5523 11 15 11H13V9C13 8.44772 12.5523 8 12 8C11.4477 8 11 8.44772 11 9V11H9C8.44772 11 8 11.4477 8 12C8 12.5523 8.44772 13 9 13H11V15Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/webenginewidgets/recipebrowser/assets/icons/edit.svg b/examples/webenginewidgets/recipebrowser/assets/icons/edit.svg
new file mode 100644
index 000000000..fe61445dc
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/icons/edit.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M2 5C2 3.34315 3.34315 2 5 2H11C11.5523 2 12 2.44772 12 3C12 3.55228 11.5523 4 11 4H5C4.44772 4 4 4.44772 4 5V19C4 19.5523 4.44772 20 5 20H19C19.5523 20 20 19.5523 20 19V13.125C20 12.5727 20.4477 12.125 21 12.125C21.5523 12.125 22 12.5727 22 13.125V19C22 20.6569 20.6569 22 19 22H5C3.34315 22 2 20.6569 2 19V5Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M19.1974 4C18.9845 4 18.7803 4.08457 18.6298 4.23509L18.1941 4.6708L19.3116 5.82359L19.7649 5.37021C19.9155 5.21969 20 5.01553 20 4.80265C20 4.58978 19.9155 4.38562 19.7649 4.23509C19.6144 4.08457 19.4102 4 19.1974 4ZM17.8972 7.23797L16.7797 6.08518L10.7528 12.1121L10.3744 13.6256L11.8879 13.2473L17.8972 7.23797ZM17.2156 2.82088C17.7412 2.29528 18.4541 2 19.1974 2C19.9407 2 20.6535 2.29528 21.1791 2.82088C21.7047 3.34648 22 4.05934 22 4.80265C22 5.54596 21.7047 6.25883 21.1791 6.78443L13.1062 14.8573C12.9781 14.9855 12.8175 15.0764 12.6417 15.1204L9.24256 15.9701C8.90178 16.0553 8.54129 15.9555 8.29291 15.7071C8.04453 15.4587 7.94468 15.0982 8.02988 14.7575L8.87966 11.3583C8.92362 11.1825 9.01453 11.0219 9.14269 10.8938L17.2156 2.82088Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/webenginewidgets/recipebrowser/assets/icons/remove.svg b/examples/webenginewidgets/recipebrowser/assets/icons/remove.svg
new file mode 100644
index 000000000..3a5a420ac
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/icons/remove.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M8 12C8 11.4477 8.44772 11 9 11H15C15.5523 11 16 11.4477 16 12C16 12.5523 15.5523 13 15 13H9C8.44772 13 8 12.5523 8 12Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/webenginewidgets/recipebrowser/assets/icons/stylesheets.svg b/examples/webenginewidgets/recipebrowser/assets/icons/stylesheets.svg
new file mode 100644
index 000000000..e108265b7
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/icons/stylesheets.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z" fill="#0D0D0D"/>
+<path d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22V2Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/webenginewidgets/recipebrowser/assets/icons/view.svg b/examples/webenginewidgets/recipebrowser/assets/icons/view.svg
new file mode 100644
index 000000000..d2c0c474d
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/icons/view.svg
@@ -0,0 +1,4 @@
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M2.08086 11.6061C2.99143 9.48143 5.39011 4 12 4C15.2544 4 17.4247 5.25776 18.9399 6.87988C20.1459 8.17094 20.9403 9.71187 21.5334 10.8623C21.657 11.102 21.7719 11.3248 21.8799 11.5249L22.1676 12.0576L21.8289 12.5595C21.6963 12.7559 21.5424 13 21.3672 13.2781C20.7396 14.2738 19.8378 15.7048 18.6548 16.9413C17.1043 18.5619 14.9479 20 12 20C9.06156 20 6.9144 18.6096 5.36163 17.0026C4.11775 15.7152 3.19708 14.2194 2.55058 13.1691C2.40657 12.9351 2.27617 12.7233 2.15883 12.5408L1.8717 12.0941L2.08086 11.6061ZM4.12801 11.9149C4.18383 12.0048 4.24056 12.0967 4.29832 12.1903C4.94628 13.2397 5.72401 14.4993 6.79992 15.6128C8.10869 16.9673 9.76922 18 12 18C14.2213 18 15.8899 16.9381 17.2097 15.5587C18.2362 14.4858 18.9795 13.3089 19.6021 12.323C19.6836 12.194 19.7631 12.0682 19.8408 11.9464C19.7982 11.8645 19.7554 11.782 19.7124 11.6989C19.1185 10.5529 18.4761 9.31319 17.4784 8.24512C16.308 6.99224 14.6533 6 12 6C7.15387 6 5.13812 9.64957 4.12801 11.9149Z" fill="#0D0D0D"/>
+<path fill-rule="evenodd" clip-rule="evenodd" d="M12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10ZM8 12C8 9.79086 9.79086 8 12 8C14.2091 8 16 9.79086 16 12C16 14.2091 14.2091 16 12 16C9.79086 16 8 14.2091 8 12Z" fill="#0D0D0D"/>
+</svg>
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/burger.html b/examples/webenginewidgets/recipebrowser/assets/pages/burger.html
new file mode 100644
index 000000000..99497959f
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/burger.html
@@ -0,0 +1,96 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Insanity Burger</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/burger.jpg" alt="Insanity Burger" title="Insanity Burger" />
+
+Insanity burger
+===============
+
+### Ingredients
+
+* 800 g minced chuck steak
+* olive oil
+* 1 large red onion
+* 1 splash of white wine vinegar
+* 2 large gherkins
+* 4 sesame-topped brioche burger buns
+* 4-8 rashers of smoked streaky bacon
+* 4 teaspoons American mustard
+* Tabasco Chipotle sauce
+* 4 thin slices of Red Leicester cheese
+* 4 teaspoons tomato ketchup
+
+#### For the burger sauce
+* ¼ of an iceberg lettuce
+* 2 heaped tablespoons mayonnaise
+* 1 heaped tablespoon tomato ketchup
+* 1 teaspoon Tabasco Chipotle sauce
+* 1 teaspoon Worcestershire sauce
+* 1 teaspoon brandy, or bourbon (optional)
+
+### Instructions
+For the best burger, go to your butcher’s and ask them to mince 800g of chuck steak for you.
+This cut has a really good balance of fat and flavoursome meat. Divide it into 4 and, with wet
+hands, roll each piece into a ball, then press into flat patties roughly 12cm wide and about 2cm
+wider than your buns. Place on an oiled plate and chill in the fridge. Next, finely slice the red
+onion, then dress in a bowl with the vinegar and a pinch of sea salt. Slice the gherkins and halve
+the buns. Finely chop the lettuce and mix with the rest of the burger sauce ingredients in a bowl,
+then season to taste.
+
+I like to only cook 2 burgers at a time to achieve perfection, so get two pans on the go – a large
+non-stick pan on a high heat for your burgers and another on a medium heat for the bacon. Pat your
+burgers with oil and season them with salt and pepper. Put 2 burgers into the first pan, pressing
+down on them with a fish slice, then put half the bacon into the other pan. After 1 minute, flip
+the burgers and brush each cooked side with ½ a teaspoon of mustard and a dash of Tabasco. After
+another minute, flip onto the mustard side and brush again with another ½ teaspoon of mustard and
+a second dash of Tabasco on the other side. Cook for one more minute, by which point you can place
+some crispy bacon on top of each burger with a slice of cheese. Add a tiny splash of water to the
+pan and place a heatproof bowl over the burgers to melt the cheese – 30 seconds should do it. At the
+same time, toast 2 split buns in the bacon fat in the other pan until lightly golden. Repeat with
+the remaining two burgers.
+
+To build each burger, add a quarter of the burger sauce to the bun base, then top with a cheesy
+bacon burger, a quarter of the onions and gherkins. Rub the bun top with a teaspoon of ketchup,
+then gently press together. As the burger rests, juices will soak into the bun, so serve right
+away, which is great, or for an extra filthy experience, wrap each one in greaseproof paper, then
+give it a minute to go gorgeous and sloppy.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/cupcakes.html b/examples/webenginewidgets/recipebrowser/assets/pages/cupcakes.html
new file mode 100644
index 000000000..e8e14a9b6
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/cupcakes.html
@@ -0,0 +1,75 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Cupcakes</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/cupcakes.jpg" alt="Cupcakes" title="Cupcakes" />
+
+Cupcakes
+=============
+
+### Ingredients
+
+* 300 g caster sugar
+* 150 ml sunflower oil
+* 1 teaspoon vanilla extract
+* 500 g dairy-free soya yoghurt
+* 2 teaspoons cider vinegar
+* 350 g plain flour
+* 1 teaspoon bicarbonate of soda
+* 1½ teaspoons baking powder
+
+#### For the vegan vanilla icing
+* 200 g dairy-free soya spread , chilled
+* 660 g icing sugar
+* ½ teaspoon vanilla extract
+
+### Instructions
+1. Preheat the oven to 170°C fan/375°F/gas 5.
+2. Place the sugar, oil and vanilla extract in a large bowl, then beat with an electric mixer for 1 to 2 minutes, until well combined.
+3. Mix the yoghurt and vinegar together in a bowl, then add to the mixture and beat for 1 to 2 minutes.
+4. Add the remaining cupcake ingredients and 1 teaspoon of fine sea salt, then whisk until smooth and just combined.
+5. Fill the paper cases two-thirds full with mixture, but don’t bother to smooth it out.
+6. Bake for 20 minutes, or until they spring back when touched. Leave to cool, transferring to a wire cooling rack after 5 minutes.
+7. Meanwhile, make the icing. Beat the soya spread with an electric mixer for 1 to 2 minutes, or until smooth.
+8. Sift the icing sugar into a large bowl, then add to the soya spread in two stages, beating well between each.
+9. Add the vanilla extract and a small splash of water, then whisk for a further few minutes, or until silky smooth – if it’s too stiff, add a splash more water to loosen.
+10. Once the cupcakes are cool, decorate them with the icing and add a few sprinkles too if you like – whatever takes your fancy – then enjoy.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/burger.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/burger.jpg
new file mode 100644
index 000000000..edc0c65de
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/burger.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/cupcakes.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/cupcakes.jpg
new file mode 100644
index 000000000..cce52ba23
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/cupcakes.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/pasta.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/pasta.jpg
new file mode 100644
index 000000000..7ac924b79
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/pasta.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/pizza.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/pizza.jpg
new file mode 100644
index 000000000..8d8f756af
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/pizza.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/skewers.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/skewers.jpg
new file mode 100644
index 000000000..6bb2f1172
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/skewers.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/soup.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/soup.jpg
new file mode 100644
index 000000000..fc9dff906
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/soup.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/images/steak.jpg b/examples/webenginewidgets/recipebrowser/assets/pages/images/steak.jpg
new file mode 100644
index 000000000..240b72eb4
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/images/steak.jpg
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/pasta.html b/examples/webenginewidgets/recipebrowser/assets/pages/pasta.html
new file mode 100644
index 000000000..c2b3d840a
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/pasta.html
@@ -0,0 +1,78 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Pasta</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/pasta.jpg" alt="Pasta" title="Pasta" />
+
+Pasta
+=============
+
+### Ingredients
+
+* 2 red peppers , deseeded and sliced
+* 2 yellow peppers , deseeded and sliced
+* extra virgin olive oil
+* sea salt
+* freshly ground black pepper
+* 2 red onions , peeled and finely sliced
+* 2 cloves garlic , peeled and grated
+* 2 handfuls fresh flat-leaf parsley , leaves finely chopped, stalks reserved
+* 2 tablespoons red wine vinegar or balsamic vinegar
+* 2 handfuls Parmesan cheese , grated
+* 2 heaped tablespoons mascarpone cheese or crème fraîche , optional
+* 455 g rigatoni, penne or spaghetti
+
+
+### Instructions
+1. Put all the peppers in a large frying pan over a medium heat with a little olive oil and a pinch of salt and pepper.
+2. Place a lid on, and cook slowly for 15 minutes until softened. Don't rush this too much, as cooking the peppers slowly like this really helps to bring out the flavour.
+3. Add the onion and cook for a further 20 minutes.
+4. Then add the garlic and parsley stalks and toss around, keeping everything moving in the pan.
+5. Cook for about 3 minutes most. Have a little taste, and season with a bit more salt and pepper.
+5. Add the vinegar - it will sizzle away, so give everything a good toss.
+6. Then add one handful of the grated Parmesan and the mascarpone or crème fraîche if you are using it and turn the heat down to minimum while you cook the pasta.
+7. Meanwhile put a large pot of salted water on to boil.
+8. Add the pasta to the boiling water and cook according to the packet instructions.
+9. When cooked, drain in a colander, reserving some of the cooking water.
+10. Put the peppers, pasta and parsley leaves into a large warmed bowl.
+11. Give them a good toss together, then add a little of the pasta cooking water and a few good lugs of extra virgin olive oil to coat the pasta nicely.
+12. Serve straight away sprinkled with the rest of the Parmesan.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/pizza.html b/examples/webenginewidgets/recipebrowser/assets/pages/pizza.html
new file mode 100644
index 000000000..7e390a373
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/pizza.html
@@ -0,0 +1,69 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Pizza Diavola</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/pizza.jpg" alt="Pizza Diavola" title="Pizza Diavola" />
+
+Pizza Diavola
+=============
+
+### Ingredients
+
+* 2 pizza dough balls
+* 100g Mozzarella
+* 400g Passata
+* 200 g Spicy Salami
+* 2 fresh chillies
+* Extra virgin olive oil
+* Salt
+
+### Instructions
+1. Preheat oven to 210 oc.
+2. Get your pizza dough balls ( depending on how many you are making) and roll them out to about 12 inches diameter using your hands in a circular stretching technique or using a rolling pin.
+3. With the dough prepared now get our sauce ready by mixing the passata with three tbsp of the olive oil and a good pinch of salt.
+4. Now slice up your salami into thin-ish slices and also finely chop the fresh chillies.
+5. Next, slice or dice your mozzarella and we are ready to dress the pizza.
+6. Add half the tomato sauce to each base and spread evenly leaving a half inch perimeter.
+7. Add the mozzarella, salami and finish with the chillies.
+8. Finally drizzle with some more olive oil and your are ready to cook your pizza diavola.
+9. Place in the oven for ten minutes or until golden.
+10. Remove from the oven, slice, and enjoy your pizza diavola.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/skewers.html b/examples/webenginewidgets/recipebrowser/assets/pages/skewers.html
new file mode 100644
index 000000000..db2df5472
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/skewers.html
@@ -0,0 +1,74 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Grilled skewers</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/skewers.jpg" alt="Grilled skewers" title="Grilled skewers" />
+
+Grilled skewers
+======================
+
+### Ingredients
+
+* 3 cloves of garlic
+* 200g kefalotyri cheese
+* 2 medium aubergine
+* 1 iceberg lettuce
+* 1 tablespoon coriander seeds
+* 2 teaspoons dried oregano
+* 2 lemons
+* 4 tablespoons olive oil
+* 600g lamb neck fillet , in 2cm chunks
+* 12 fresh bay leaves
+
+### Instructions
+1. Peel and crush the garlic.
+2. Chop the cheese into bite-sized pieces, trim and chop the aubergines into 2cm chunks, and trim and finely slice the lettuce.
+3. Finely crush the coriander seeds in a pestle and mortar and add to a large bowl with the oregano and garlic. Finely grate in the lemon zest (reserve the zested lemons) and stir in the oil.
+4. Season, then add the cheese, lamb, aubergines and bay leaves. Leave to marinate for at least an hour, or overnight if you can.
+5. Meanwhile, pickle your cabbage. Trim, core and finely slice the cabbage, then place in a colander in the sink or over a bowl and toss with 2 teaspoons of sea salt. Cover and set aside for at least 2 hours, then rinse.
+6. Peel and finely slice the onions, then transfer to a bowl along with the cabbage.
+7. Put the remaining ingredients in a pan and bring to a boil. Simmer for 10 minutes, then pour over the cabbage and onions. Transfer to sterilised jars – this will keep for up to 1 month.
+8. For the flatbreads, put the flour, baking powder, buttermilk and half of the sesame seeds in a bowl and mix until everything is combined.
+9. Tip onto a lightly floured surface and knead briefly. Divide into six, using a rolling pin to roll them into 1 to 2mm rounds.
+10. Scatter with the remaining sesame seeds and run the rolling pin over them. Pop the flatbreads onto the hot barbecue for 1 to 2 minutes on each side.
+11. Load 12 skewers with the cheese, lamb, aubergines and bay leaves, then place on the barbecue (not directly over the coals) for 20 to 25 minutes, turning often, until the lamb is medium-rare and the aubergines are cooked.
+12. Serve the lamb with the flatbreads, cabbage, lettuce and lemon wedges.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/soup.html b/examples/webenginewidgets/recipebrowser/assets/pages/soup.html
new file mode 100644
index 000000000..ea51fc8a5
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/soup.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Soup</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/soup.jpg" alt="Soup" title="Soup" />
+
+Soup
+=============
+
+### Ingredients
+
+* 2 potatoes
+* 2 onions
+* 2 cloves of garlic
+* olive oil
+* 400 ml organic stock
+* 3 bunches of watercress
+
+### Instructions
+* Peel and roughly chop the potatoes, onions and garlic.
+* In a large saucepan, heat a little olive oil, then sauté the potato, onion and garlic until the onions are translucent.
+* Add the stock and simmer until the potato is soft. Chop and add the watercress and simmer for a further 3 to 4 minutes.
+* Using a hand blender, liquidise the soup until smooth.
+* Serve with a swirl of crème fraîche and some Fortt’s Bath Oliver biscuits, if you like.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/assets/pages/steak.html b/examples/webenginewidgets/recipebrowser/assets/pages/steak.html
new file mode 100644
index 000000000..26391b409
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/assets/pages/steak.html
@@ -0,0 +1,88 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>Grilled steak and rice</title>
+ <link rel="stylesheet" type="text/css" href="../3rdparty/markdown.css">
+ <link rel="stylesheet" type="text/css" href="../custom.css">
+ <script src="../3rdparty/marked.js"></script>
+ <script src="../custom.js"></script>
+ <script src="qrc:/qtwebchannel/qwebchannel.js"></script>
+</head>
+<body>
+ <div id="placeholder"></div>
+ <div id="content">
+
+<img src="images/steak.jpg" alt="Grilled steak and rice" title="Grilled steak and rice" />
+
+Grilled steak and rice
+======================
+
+### Ingredients
+
+#### For the ratatouille
+* courgette
+* 1 small aubergine
+* 2 mixed-color peppers
+* 1 red onion
+* 1 heaped teaspoon harissa
+* 2 anchovy fillets
+* 2-4 cloves of garlic
+* 700 g passata
+* 1 tablespoon balsamic vinegar
+* ½ bunch fresh basil
+* 2 tablespoons fat-free natural yoghurt
+
+#### For the rice
+* 1 mug (300g) 10-minute wholegrain or basmati rice
+* 1 good pinch saffron
+* ½ lemon
+
+#### For the steak
+* 2 x 250 g quality sirloin steaks, fat removed
+* 1 teaspoon sweet paprika olive oil
+* ½ bunch fresh flat-leaf parsley
+* 1 heaped teaspoon Dijon mustard
+* 1 tablespoon extra virgin olive oil
+* ½ lemon
+
+### Instructions
+1. Halve the courgette lengthways, slice the aubergine 1cm thick and place both on the griddle pan, turning when charred.
+2. Put 1 mug of rice, 2 mugs of boiling water, the saffron, lemon half and a pinch of salt into the small pan, cover and cook until fluffy, stirring occasionally.
+3. Tear the seeds and stalks out of the peppers, then roughly chop with the peeled red onion and put into the casserole pan with the harissa, anchovies and 1 teaspoon of their oil.
+4. Squash in the unpeeled garlic through a garlic crusher and stir regularly.
+5. Remove the charred courgette and aubergine from the griddle pan, leaving it on the heat, and roughly chop them on a board.
+6. Add them to the casserole pan along with the passata and vinegar, and boil with the lid on.
+7. Rub the steaks with salt, the paprika and 1 teaspoon of olive oil and place on the hot griddle pan, turning every minute until cooked to your liking.
+8. On a board, finely slice the parsley stalks and roughly chop the leaves.
+9. Add the mustard and extra virgin olive oil, season with salt and pepper and squeeze over the lemon juice, then mix together and spread over the board.
+10. When the steaks are done, transfer them to the board, turn in the dressing, then slice.
+11. Tear the top leafy half of the basil into the ratatouille, season to taste, and serve with yoghurt and saffron rice.
+
+**Enjoy!**
+
+ </div><!--End of content-->
+
+ <script>
+ 'use strict';
+
+ var jsContent = document.getElementById('content');
+ var placeholder = document.getElementById('placeholder');
+
+ var updateText = function(text) {
+ placeholder.innerHTML = marked.parse(text);
+ }
+
+ new QWebChannel(qt.webChannelTransport,
+ function(channel) {
+ var content = channel.objects.content;
+ content.setInitialText(jsContent.innerHTML);
+ content.textChanged.connect(updateText);
+ }
+ );
+ </script>
+</body>
+</html>
+
+
+
diff --git a/examples/webenginewidgets/recipebrowser/doc/images/recipebrowser.webp b/examples/webenginewidgets/recipebrowser/doc/images/recipebrowser.webp
new file mode 100644
index 000000000..7e711c661
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/doc/images/recipebrowser.webp
Binary files differ
diff --git a/examples/webenginewidgets/recipebrowser/doc/src/recipebrowser.qdoc b/examples/webenginewidgets/recipebrowser/doc/src/recipebrowser.qdoc
new file mode 100644
index 000000000..0400fcecc
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/doc/src/recipebrowser.qdoc
@@ -0,0 +1,197 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+ \example webenginewidgets/recipebrowser
+ \title Recipe Browser
+ \meta tag {widgets, webengine, webchannel, webenginescript}
+ \ingroup webengine-widgetexamples
+ \brief Injecting custom stylsheets into web pages and providing a rich text preview
+ tool for a custom markup language.
+ \examplecategory {Web Technologies}
+
+ \image recipebrowser.webp
+
+ \e {Recipe Browser} is a small hybrid web browser application. It demonstrates how to
+ use the \l{Qt WebEngine Widgets C++ Classes} {Qt WebEngine C++ classes} to combine
+ C++ and JavaScript logic in the following ways.
+
+ \list
+ \li Running arbitrary JavaScript code via \c QWebEnginePage::runJavaScript() to
+ inject custom CSS stylesheets
+ \li Using QWebEngineScript and QWebEngineScriptCollection to persist the JavaScript
+ code and inject it to every page
+ \li Using QWebChannel to interact with and provide a rich text preview for a custom
+ markup language
+ \endlist
+
+ \l{http://daringfireball.net/projects/markdown/}{Markdown} is a lightweight
+ markup language with a plain text formatting syntax.
+ Some services, such as \l{http://github.com}{github}, acknowledge the
+ format, and render the content as rich text when viewed in a browser.
+
+ The Recipe Browser main window is split into a navigation on the left and
+ a preview area on the right. The preview area on the right switches to an
+ editor when the user clicks the Edit button on the top left of the main window.
+ The editor supports the Markdown syntax and is implemented by using
+ QPlainTextEdit. The document is rendered as rich text in the preview area,
+ once the user clicks the View button,to which the Edit button transforms to.
+ This rendering is implemented by using QWebEngineView. To render the text,
+ a JavaScript library inside the web engine converts the Markdown text to HTML.
+ The preview is updated from the editor through QWebChannel.
+
+ \include examples-run.qdocinc
+
+ \section1 Exposing Document Text
+
+ To render the current Markdown text it needs to be exposed to the web engine through
+ QWebChannel. To achieve this it has to be part of Qt metatype system. This is done
+ by using a dedicated \c Document class that exposes the document text as a
+ \c {Q_PROPERTY}:
+
+ \quotefromfile webenginewidgets/recipebrowser/document.h
+ \skipto class Document
+ \printto #endif
+
+ The \c Document class wraps a QString \c m_currentText to be set on the C++
+ side with the \c setText() method and exposes it at runtime as a \c text
+ property with a \c textChanged signal. We define the \c setText method as
+ follows:
+
+ \quotefromfile webenginewidgets/recipebrowser/document.cpp
+ \skipto Document::setText(const QString &text)
+ \printuntil /^\}/
+
+ Additionally, the \c Document class keeps track of the current recipe via
+ \c m_currentPage. We call the recipes pages here, because each recipe has
+ its distinct HTML document that contains the initial text content.
+ Furthermore, \c m_textCollection is a QMap<QString, QString> that contains
+ the key/value pairs \{page, text\}, so that changes made to the text content
+ of a page is persisted between navigation. Nevertheless, we do not write the
+ modified text contents to the drive, but instead we persist them between
+ application start and shutdown via QSettings.
+
+ \section1 Creating the Main Window
+
+ The \c MainWindow class inherits the QMainWindow class:
+
+ \quotefromfile webenginewidgets/recipebrowser/mainwindow.h
+ \skipto class MainWindow :
+ \printto endif
+
+ The class declares private slots that match the two buttons on the
+ top left, over the navigation list view. Additionally, helper
+ methods for custom CSS stylesheets are declared.
+
+ The actual layout of the main window is specified in a \c .ui file.
+ The widgets and actions are available at runtime in the \c ui member
+ variable.
+
+ \c m_isEditMode is a boolean that toggles between the editor and the
+ preview area.
+ \c m_content is an instance of the \c Document class.
+
+ The actual setup of the different objects is done in the \c MainWindow
+ constructor:
+
+ \quotefromfile webenginewidgets/recipebrowser/mainwindow.cpp
+ \skipto MainWindow::MainWindow
+ \printto connect
+
+ The constructor first calls \c setupUi to construct the widgets and menu
+ actions according to the UI file. The text editor font is set to one
+ with a fixed character width, and the QWebEngineView widget is told not
+ to show a context menu. Furthermore, the editor is hidden away.
+
+ \printto ui->recipes
+
+ Here the \c clicked signals of QPushButton are connected to respective functions
+ that show the stylesheets dialog or toggle between edit and view mode, that is,
+ hide and show the editor and preview area respectively.
+
+ \printto m_content.setTextEdit
+
+ Here the navigation QListWidget on the left is setup with the 7 recipes.
+ Also, the currentItemChanged signal of QListWidget is connected to a lambda
+ that loads the new, current recipe page and updates the page in \c m_content.
+
+ \printto connect
+
+ Next, the pointer to the ui editor, a QPlainTextEdit, is passed to \c m_content to ensure that
+ calls to \c Document::setInitialText() work properly.
+
+ \printto QSettings
+
+ Here the \c textChanged signal of the editor is connected to a lambda that
+ updates the text in \c m_content. This object is then exposed to the JS side
+ by \c QWebChannel under the name \c{content}.
+
+ \printto ui->recipes
+
+ By using QSettings we persist stylesheets between application runs. If there
+ should be no stylesheets configured, for example, because the user deleted all of them
+ in a previous run, we load default ones.
+
+ \printto }
+
+ Finally, we set the currently selected list item to the first contained in the
+ navigation list widget. This triggers the previously mentioned
+ QListWidget::currentItemChanged signal and navigates to the page of the list item.
+
+ \section1 Working With Stylesheets
+
+ We use JavaScript to create and append CSS elements to the documents.
+ After declaring the script source, QWebEnginePage::runJavaScript() can run it
+ immediately and apply newly created styles on the current content of the web view.
+ Encapsulating the script into a QWebEngineScript and adding it to the script collection
+ of QWebEnginePage makes its effect permanent.
+
+ \quotefromfile webenginewidgets/recipebrowser/mainwindow.cpp
+ \skipto MainWindow::insertStyleSheet
+ \printuntil /^\}/
+
+ Removing stylesheets can be done similarly:
+
+ \quotefromfile webenginewidgets/recipebrowser/mainwindow.cpp
+ \skipto MainWindow::removeStyleSheet
+ \printuntil /^\}/
+
+ \section1 Creating a recipe file
+
+ \quotefile webenginewidgets/recipebrowser/assets/pages/burger.html
+
+ All the different recipe pages are set up the same way.
+
+ In the \c <head> part they
+ include two CSS files: \c markdown.css, that styles the markdown, and
+ custom.css, that does some further styling but most importantly hides the
+ \c <div> with id \e content, as this \c <div> only contains the unmodified,
+ initial content text. Also, three JS scripts are included. \c marked.js
+ is responsible for parsing the markdown and transforming it into HTML.
+ \c custom.js does some configuration of \c marked.js, and \c qwebchannel.js
+ exposes the QWebChannel JavaScript API.
+
+ In the body there are two \c <div> elements. The \c <div> with id \e placeholder
+ gets the markdown text injected that is rendered and visible. The \c <div> with id
+ \e content is hidden by \c custom.css and only contains the original, unmodified
+ text content of the recipe.
+
+ Finally, on the bottom of each recipe HTML file is a script that is responsible for
+ the communication between the C++ and JavaScript side via QWebChannel. The original,
+ unmodified text content inside the \c <div> with id \e content is passed to the C++
+ side and a callback is setup that is invoked when the \c textChanged signal of
+ \c m_content is emitted. The callback then updates the contents of the \c <div>
+ \e placeholder with the parsed markdown.
+
+ \section1 Files and Attributions
+
+ The example bundles the following code with third-party licenses:
+ \table
+ \row
+ \li \l{recipebrowser-marked}{Marked}
+ \li MIT License
+ \row
+ \li \l{recipebrowser-markdowncss}{Markdown.css}
+ \li Apache License 2.0
+ \endtable
+*/
diff --git a/examples/webenginewidgets/recipebrowser/document.cpp b/examples/webenginewidgets/recipebrowser/document.cpp
new file mode 100644
index 000000000..c991e14f8
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/document.cpp
@@ -0,0 +1,48 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "document.h"
+
+#include <QSettings>
+
+Document::Document(QObject *parent) : QObject(parent)
+{
+ QSettings settings;
+ settings.beginGroup("textCollection");
+ QStringList pageTexts = settings.allKeys();
+ for (const QString &name : std::as_const(pageTexts)) {
+ QString pageText = settings.value(name).value<QString>();
+ if (!pageText.isEmpty())
+ m_textCollection.insert(name, pageText);
+ }
+ settings.endGroup();
+}
+
+void Document::setTextEdit(QPlainTextEdit *textEdit)
+{
+ m_textEdit = textEdit;
+}
+
+void Document::setCurrentPage(const QString &page)
+{
+ m_currentPage = page;
+}
+
+void Document::setInitialText(const QString &text)
+{
+ m_textEdit->setPlainText(m_textCollection.value(m_currentPage, text));
+}
+
+void Document::setText(const QString &text)
+{
+ if (text == m_currentText)
+ return;
+ m_currentText = text;
+ emit textChanged(m_currentText);
+
+ QSettings settings;
+ settings.beginGroup("textCollection");
+ settings.setValue(m_currentPage, text);
+ m_textCollection.insert(m_currentPage, text);
+ settings.endGroup();
+}
diff --git a/examples/webenginewidgets/recipebrowser/document.h b/examples/webenginewidgets/recipebrowser/document.h
new file mode 100644
index 000000000..f6b537eb8
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/document.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef DOCUMENT_H
+#define DOCUMENT_H
+
+#include <QObject>
+#include <QString>
+#include <QPlainTextEdit>
+
+class Document : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text MEMBER m_currentText NOTIFY textChanged FINAL)
+public:
+ explicit Document(QObject *parent = nullptr);
+
+ void setTextEdit(QPlainTextEdit *textEdit);
+ void setCurrentPage(const QString &page);
+
+public slots:
+ void setInitialText(const QString &text);
+ void setText(const QString &text);
+
+signals:
+ void textChanged(const QString &text);
+
+private:
+ QPlainTextEdit *m_textEdit;
+
+ QString m_currentText;
+ QString m_currentPage;
+ QMap<QString, QString> m_textCollection;
+};
+
+#endif // DOCUMENT_H
diff --git a/examples/webenginewidgets/recipebrowser/main.cpp b/examples/webenginewidgets/recipebrowser/main.cpp
new file mode 100644
index 000000000..b0b42d16b
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/main.cpp
@@ -0,0 +1,18 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+#include "stylesheetdialog.h"
+#include <QApplication>
+#include <QUrl>
+
+int main(int argc, char *argv[])
+{
+ qRegisterMetaType<StyleSheet>("StyleSheet");
+
+ QCoreApplication::setOrganizationName("QtExamples");
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/examples/webenginewidgets/recipebrowser/mainwindow.cpp b/examples/webenginewidgets/recipebrowser/mainwindow.cpp
new file mode 100644
index 000000000..7eedab480
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/mainwindow.cpp
@@ -0,0 +1,154 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "mainwindow.h"
+#include "stylesheetdialog.h"
+#include "ui_mainwindow.h"
+
+#include <QWebChannel>
+
+static QMap<QString, QString> defaultStyleSheets = {
+ { "Upside down", "body { -webkit-transform: rotate(180deg); }" },
+ { "Darkmode",
+ "body { color: #FFF; background-color: #000 }"
+ "h1, h2, h3, h4, h5 { color: #FFF }" }
+};
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent), ui(new Ui::MainWindow), m_isEditMode(false)
+{
+ ui->setupUi(this);
+ ui->textEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
+ ui->textEdit->hide();
+ ui->webEngineView->setContextMenuPolicy(Qt::NoContextMenu);
+
+ connect(ui->stylesheetsButton, &QPushButton::clicked, this, &MainWindow::showStyleSheetsDialog);
+ connect(ui->editViewButton, &QPushButton::clicked, this, &MainWindow::toggleEditView);
+
+ ui->recipes->insertItem(0, "Burger");
+ ui->recipes->insertItem(1, "Cupcakes");
+ ui->recipes->insertItem(2, "Pasta");
+ ui->recipes->insertItem(3, "Pizza");
+ ui->recipes->insertItem(4, "Skewers");
+ ui->recipes->insertItem(5, "Soup");
+ ui->recipes->insertItem(6, "Steak");
+ connect(ui->recipes, &QListWidget::currentItemChanged, this,
+ [this](QListWidgetItem *current, QListWidgetItem * /* previous */) {
+ const QString page = current->text().toLower();
+ const QString url = QStringLiteral("qrc:/pages/") + page + QStringLiteral(".html");
+ ui->webEngineView->setUrl(QUrl(url));
+ m_content.setCurrentPage(page);
+ });
+
+ m_content.setTextEdit(ui->textEdit);
+
+ connect(ui->textEdit, &QPlainTextEdit::textChanged, this,
+ [this]() { m_content.setText(ui->textEdit->toPlainText()); });
+
+ QWebChannel *channel = new QWebChannel(this);
+ channel->registerObject(QStringLiteral("content"), &m_content);
+ ui->webEngineView->page()->setWebChannel(channel);
+
+ QSettings settings;
+ settings.beginGroup("styleSheets");
+ QStringList styleSheets = settings.allKeys();
+ if (styleSheets.empty()) {
+ // Add back default style sheets if the user cleared them out
+ loadDefaultStyleSheets();
+ } else {
+ for (const auto &name : std::as_const(styleSheets)) {
+ StyleSheet styleSheet = settings.value(name).value<StyleSheet>();
+ if (styleSheet.second)
+ insertStyleSheet(name, styleSheet.first, false);
+ }
+ }
+ settings.endGroup();
+
+ ui->recipes->setCurrentItem(ui->recipes->item(0));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::insertStyleSheet(const QString &name, const QString &source, bool immediately)
+{
+ QWebEngineScript script;
+ QString s = QString::fromLatin1("(function() {"
+ " css = document.createElement('style');"
+ " css.type = 'text/css';"
+ " css.id = '%1';"
+ " document.head.appendChild(css);"
+ " css.innerText = '%2';"
+ "})()")
+ .arg(name, source.simplified());
+ if (immediately)
+ ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld);
+
+ script.setName(name);
+ script.setSourceCode(s);
+ script.setInjectionPoint(QWebEngineScript::DocumentReady);
+ script.setRunsOnSubFrames(true);
+ script.setWorldId(QWebEngineScript::ApplicationWorld);
+ ui->webEngineView->page()->scripts().insert(script);
+}
+
+void MainWindow::removeStyleSheet(const QString &name, bool immediately)
+{
+ QString s = QString::fromLatin1("(function() {"
+ " var element = document.getElementById('%1');"
+ " element.outerHTML = '';"
+ " delete element;"
+ "})()")
+ .arg(name);
+ if (immediately)
+ ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld);
+
+ const QList<QWebEngineScript> scripts = ui->webEngineView->page()->scripts().find(name);
+ if (!scripts.isEmpty())
+ ui->webEngineView->page()->scripts().remove(scripts.first());
+}
+
+bool MainWindow::hasStyleSheet(const QString &name)
+{
+ const QList<QWebEngineScript> scripts = ui->webEngineView->page()->scripts().find(name);
+ return !scripts.isEmpty();
+}
+
+void MainWindow::loadDefaultStyleSheets()
+{
+ QSettings settings;
+ settings.beginGroup("styleSheets");
+
+ for (auto it = defaultStyleSheets.constBegin(); it != defaultStyleSheets.constEnd(); ++it) {
+ settings.setValue(it.key(), QVariant::fromValue(qMakePair(it.value(), false)));
+ }
+
+ settings.endGroup();
+}
+
+void MainWindow::showStyleSheetsDialog()
+{
+ StylesheetDialog *dialog = new StylesheetDialog(this);
+ dialog->show();
+}
+
+void MainWindow::toggleEditView()
+{
+ m_isEditMode = !m_isEditMode;
+
+ if (m_isEditMode) {
+ ui->webEngineView->hide();
+ ui->textEdit->show();
+
+ ui->editViewButton->setText(QStringLiteral("View"));
+ ui->editViewButton->setIcon(QIcon(":/icons/view.svg"));
+ } else {
+ ui->textEdit->hide();
+ ui->webEngineView->show();
+
+ ui->editViewButton->setText(QStringLiteral("Edit"));
+ ui->editViewButton->setIcon(QIcon(":/icons/edit.svg"));
+ }
+}
diff --git a/examples/webenginewidgets/recipebrowser/mainwindow.h b/examples/webenginewidgets/recipebrowser/mainwindow.h
new file mode 100644
index 000000000..959c82af8
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/mainwindow.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include "document.h"
+#include <QMainWindow>
+#include <QSettings>
+#include <QWebEngineScriptCollection>
+#include <QWebEngineView>
+#include <QPlainTextEdit>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = nullptr);
+ ~MainWindow();
+
+ void insertStyleSheet(const QString &name, const QString &source, bool immediately);
+ void removeStyleSheet(const QString &name, bool immediately);
+ bool hasStyleSheet(const QString &name);
+ void loadDefaultStyleSheets();
+
+private slots:
+ void showStyleSheetsDialog();
+ void toggleEditView();
+
+private:
+ Ui::MainWindow *ui;
+
+ bool m_isEditMode;
+ Document m_content;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/webenginewidgets/recipebrowser/mainwindow.ui b/examples/webenginewidgets/recipebrowser/mainwindow.ui
new file mode 100644
index 000000000..9c2539fd5
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/mainwindow.ui
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>713</width>
+ <height>455</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Recipe Browser</string>
+ </property>
+ <property name="unifiedTitleAndToolBarOnMac">
+ <bool>false</bool>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <layout class="QVBoxLayout" name="navigation">
+ <item>
+ <layout class="QHBoxLayout" name="navigationBar">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Recipes</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="editViewButton">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ <property name="icon">
+ <iconset resource="recipebrowser.qrc">
+ <normaloff>:/icons/edit.svg</normaloff>:/icons/edit.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="stylesheetsButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Stylesheets</string>
+ </property>
+ <property name="icon">
+ <iconset resource="recipebrowser.qrc">
+ <normaloff>:/icons/stylesheets.svg</normaloff>:/icons/stylesheets.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QListWidget" name="recipes">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QWebEngineView" name="webEngineView" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="textEdit"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>QWebEngineView</class>
+ <extends>QWidget</extends>
+ <header>qwebengineview.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources>
+ <include location="recipebrowser.qrc"/>
+ </resources>
+ <connections/>
+</ui>
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro b/examples/webenginewidgets/recipebrowser/recipebrowser.pro
index a9ff54400..8f8895b52 100644
--- a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.pro
+++ b/examples/webenginewidgets/recipebrowser/recipebrowser.pro
@@ -1,22 +1,24 @@
TEMPLATE = app
-TARGET = stylesheetbrowser
+TARGET = recipebrowser
QT += webenginewidgets
HEADERS += \
mainwindow.h \
- stylesheetdialog.h
+ stylesheetdialog.h \
+ document.h
SOURCES += \
main.cpp \
mainwindow.cpp \
- stylesheetdialog.cpp
+ stylesheetdialog.cpp \
+ document.cpp
FORMS += \
mainwindow.ui \
stylesheetdialog.ui
-RESOURCES += stylesheetbrowser.qrc
+RESOURCES += recipebrowser.qrc
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/stylesheetbrowser
+target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/recipebrowser
INSTALLS += target
diff --git a/examples/webenginewidgets/recipebrowser/recipebrowser.qrc b/examples/webenginewidgets/recipebrowser/recipebrowser.qrc
new file mode 100644
index 000000000..c1eb909a7
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/recipebrowser.qrc
@@ -0,0 +1,27 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="3rdparty/markdown.css">assets/3rdparty/markdown.css</file>
+ <file alias="3rdparty/marked.js">assets/3rdparty/marked.js</file>
+ <file alias="custom.js">assets/custom.js</file>
+ <file alias="custom.css">assets/custom.css</file>
+ <file alias="pages/images/burger.jpg">assets/pages/images/burger.jpg</file>
+ <file alias="pages/images/cupcakes.jpg">assets/pages/images/cupcakes.jpg</file>
+ <file alias="pages/images/pasta.jpg">assets/pages/images/pasta.jpg</file>
+ <file alias="pages/images/pizza.jpg">assets/pages/images/pizza.jpg</file>
+ <file alias="pages/images/skewers.jpg">assets/pages/images/skewers.jpg</file>
+ <file alias="pages/images/soup.jpg">assets/pages/images/soup.jpg</file>
+ <file alias="pages/images/steak.jpg">assets/pages/images/steak.jpg</file>
+ <file alias="pages/burger.html">assets/pages/burger.html</file>
+ <file alias="pages/cupcakes.html">assets/pages/cupcakes.html</file>
+ <file alias="pages/pasta.html">assets/pages/pasta.html</file>
+ <file alias="pages/pizza.html">assets/pages/pizza.html</file>
+ <file alias="pages/skewers.html">assets/pages/skewers.html</file>
+ <file alias="pages/soup.html">assets/pages/soup.html</file>
+ <file alias="pages/steak.html">assets/pages/steak.html</file>
+ <file alias="icons/edit.svg">assets/icons/edit.svg</file>
+ <file alias="icons/stylesheets.svg">assets/icons/stylesheets.svg</file>
+ <file alias="icons/add.svg">assets/icons/add.svg</file>
+ <file alias="icons/remove.svg">assets/icons/remove.svg</file>
+ <file alias="icons/view.svg">assets/icons/view.svg</file>
+ </qresource>
+</RCC>
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp b/examples/webenginewidgets/recipebrowser/stylesheetdialog.cpp
index 7351ab75f..2137617c3 100644
--- a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.cpp
+++ b/examples/webenginewidgets/recipebrowser/stylesheetdialog.cpp
@@ -1,65 +1,18 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include "stylesheetdialog.h"
#include "ui_stylesheetdialog.h"
-StylesheetDialog::StylesheetDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::StylesheetDialog)
+StylesheetDialog::StylesheetDialog(QWidget *parent) : QDialog(parent), ui(new Ui::StylesheetDialog)
{
ui->setupUi(this);
- connect(ui->styleSheetList, &QListWidget::currentItemChanged, this, &StylesheetDialog::currentStyleSheetChanged);
- connect(ui->styleSheetList, &QListWidget::itemClicked, this, &StylesheetDialog::listItemClicked);
+ connect(ui->styleSheetList, &QListWidget::currentItemChanged, this,
+ &StylesheetDialog::currentStyleSheetChanged);
+ connect(ui->styleSheetList, &QListWidget::itemClicked, this,
+ &StylesheetDialog::listItemClicked);
connect(ui->fileNameEdit, &QLineEdit::textChanged, this, &StylesheetDialog::fileNameChanged);
connect(ui->addButton, &QPushButton::clicked, this, &StylesheetDialog::addButtonClicked);
@@ -67,8 +20,8 @@ StylesheetDialog::StylesheetDialog(QWidget *parent) :
QSettings settings;
settings.beginGroup("styleSheets");
- for (auto name : settings.allKeys()) {
- QListWidgetItem *listItem = new QListWidgetItem(name, ui->styleSheetList);
+ for (const auto &name : settings.allKeys()) {
+ QListWidgetItem *listItem = new QListWidgetItem(name, ui->styleSheetList);
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable);
bool checked = settings.value(name).value<StyleSheet>().second;
listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
@@ -106,9 +59,8 @@ void StylesheetDialog::listItemClicked(QListWidgetItem *item)
{
MainWindow *window = static_cast<MainWindow *>(parent());
const QString name = item->text();
- bool checkedStateChanged =
- (item->checkState() == Qt::Checked && !window->hasStyleSheet(name)) ||
- (item->checkState() == Qt::Unchecked && window->hasStyleSheet(name));
+ bool checkedStateChanged = (item->checkState() == Qt::Checked && !window->hasStyleSheet(name))
+ || (item->checkState() == Qt::Unchecked && window->hasStyleSheet(name));
if (!checkedStateChanged)
return;
@@ -143,7 +95,7 @@ void StylesheetDialog::addButtonClicked()
if (name.isEmpty() || source.isEmpty())
return;
- QListWidgetItem *listItem = new QListWidgetItem(ui->fileNameEdit->text(), ui->styleSheetList);
+ QListWidgetItem *listItem = new QListWidgetItem(ui->fileNameEdit->text(), ui->styleSheetList);
listItem->setFlags(listItem->flags() | Qt::ItemIsUserCheckable);
listItem->setCheckState(Qt::Checked);
diff --git a/examples/webenginewidgets/recipebrowser/stylesheetdialog.h b/examples/webenginewidgets/recipebrowser/stylesheetdialog.h
new file mode 100644
index 000000000..ca1b4ae99
--- /dev/null
+++ b/examples/webenginewidgets/recipebrowser/stylesheetdialog.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef STYLESHEETDIALOG_H
+#define STYLESHEETDIALOG_H
+
+#include <QDialog>
+#include <QListWidgetItem>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class StylesheetDialog;
+}
+QT_END_NAMESPACE
+
+typedef QPair<QString, bool> StyleSheet; // <source, isEnabled>
+Q_DECLARE_METATYPE(StyleSheet);
+
+class StylesheetDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit StylesheetDialog(QWidget *parent = 0);
+ ~StylesheetDialog();
+
+private slots:
+ void currentStyleSheetChanged(QListWidgetItem *current, QListWidgetItem *previous);
+ void listItemClicked(QListWidgetItem *item);
+ void fileNameChanged(const QString &text);
+
+ void addButtonClicked();
+ void removeButtonClicked();
+
+private:
+ Ui::StylesheetDialog *ui;
+};
+
+#endif // STYLESHEETDIALOG_H
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui b/examples/webenginewidgets/recipebrowser/stylesheetdialog.ui
index 19db267e8..6ef389195 100644
--- a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.ui
+++ b/examples/webenginewidgets/recipebrowser/stylesheetdialog.ui
@@ -68,6 +68,10 @@
<property name="text">
<string>Add</string>
</property>
+ <property name="icon">
+ <iconset resource="recipebrowser.qrc">
+ <normaloff>:/icons/add.svg</normaloff>:/icons/add.svg</iconset>
+ </property>
</widget>
</item>
<item>
@@ -75,6 +79,10 @@
<property name="text">
<string>Remove</string>
</property>
+ <property name="icon">
+ <iconset resource="recipebrowser.qrc">
+ <normaloff>:/icons/remove.svg</normaloff>:/icons/remove.svg</iconset>
+ </property>
</widget>
</item>
</layout>
@@ -84,7 +92,9 @@
</item>
</layout>
</widget>
- <resources/>
+ <resources>
+ <include location="recipebrowser.qrc"/>
+ </resources>
<connections>
<connection>
<sender>buttonBox</sender>
diff --git a/examples/webenginewidgets/simplebrowser/CMakeLists.txt b/examples/webenginewidgets/simplebrowser/CMakeLists.txt
index 21ae993e5..cbaffa6d9 100644
--- a/examples/webenginewidgets/simplebrowser/CMakeLists.txt
+++ b/examples/webenginewidgets/simplebrowser/CMakeLists.txt
@@ -1,21 +1,19 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(simplebrowser LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/simplebrowser")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(simplebrowser
browser.cpp browser.h
@@ -29,25 +27,35 @@ qt_add_executable(simplebrowser
webpage.cpp webpage.h
webpopupwindow.cpp webpopupwindow.h
webview.cpp webview.h
+ webauthdialog.cpp webauthdialog.h webauthdialog.ui
)
+
+if(WIN32)
+ set_property(
+ TARGET simplebrowser
+ APPEND PROPERTY
+ SOURCES simplebrowser.exe.manifest)
+endif()
+
set_target_properties(simplebrowser PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
+ MACOSX_BUNDLE_GUI_IDENTIFIER "io.qt.examples.webenginewidgets.simplebrowser"
)
+
target_link_libraries(simplebrowser PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(simplebrowser_resource_files
"data/AppLogoColor.png"
"data/ninja.png"
)
-qt6_add_resources(simplebrowser "simplebrowser"
+qt_add_resources(simplebrowser "simplebrowser"
PREFIX
"/"
BASE
@@ -55,6 +63,7 @@ qt6_add_resources(simplebrowser "simplebrowser"
FILES
${simplebrowser_resource_files}
)
+
set(simplebrowser1_resource_files
"data/3rdparty/dialog-error.png"
"data/3rdparty/edit-clear.png"
@@ -66,7 +75,7 @@ set(simplebrowser1_resource_files
"data/3rdparty/view-refresh.png"
)
-qt6_add_resources(simplebrowser "simplebrowser1"
+qt_add_resources(simplebrowser "simplebrowser1"
PREFIX
"/"
BASE
@@ -75,6 +84,24 @@ qt6_add_resources(simplebrowser "simplebrowser1"
${simplebrowser1_resource_files}
)
+if (APPLE)
+ set_target_properties(simplebrowser PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.cmake.macos.plist"
+ )
+
+ if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
+ # Need to sign application for location permissions to work
+ if(QT_FEATURE_debug_and_release)
+ set(exe_path "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/")
+ else()
+ unset(exe_path)
+ endif()
+ add_custom_command(TARGET simplebrowser
+ POST_BUILD COMMAND codesign --force -s - ${exe_path}simplebrowser.app
+ )
+ endif()
+endif()
+
install(TARGETS simplebrowser
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/webenginewidgets/simplebrowser/Info.cmake.macos.plist b/examples/webenginewidgets/simplebrowser/Info.cmake.macos.plist
new file mode 100644
index 000000000..7abb7e01a
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/Info.cmake.macos.plist
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>NSSupportsAutomaticGraphicsSwitching</key>
+ <true/>
+ <key>NSLocationUsageDescription</key>
+ <string>Simple Browser would like to give web sites access to your location for demo purposes.</string>
+ <key>NSMicrophoneUsageDescription</key>
+ <string>Simple Browser would like to give web sites access to your computer's microphone for demo purposes.</string>
+ <key>NSCameraUsageDescription</key>
+ <string>Simple Browser would like to give web sites access to your computer's camera for demo purposes.</string>
+</dict>
+</plist>
diff --git a/examples/webenginewidgets/simplebrowser/browser.cpp b/examples/webenginewidgets/simplebrowser/browser.cpp
index c3f66cb38..fd68246d0 100644
--- a/examples/webenginewidgets/simplebrowser/browser.cpp
+++ b/examples/webenginewidgets/simplebrowser/browser.cpp
@@ -1,58 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
#include "browserwindow.h"
#include <QWebEngineSettings>
+using namespace Qt::StringLiterals;
+
Browser::Browser()
{
// Quit application if the download manager window is the only remaining window
@@ -63,13 +18,16 @@ Browser::Browser()
&m_downloadManagerWidget, &DownloadManagerWidget::downloadRequested);
}
-BrowserWindow *Browser::createWindow(bool offTheRecord)
+BrowserWindow *Browser::createHiddenWindow(bool offTheRecord)
{
if (!offTheRecord && !m_profile) {
- m_profile.reset(new QWebEngineProfile(
- QString::fromLatin1("simplebrowser.%1").arg(qWebEngineChromiumVersion())));
+ const QString name = u"simplebrowser."_s + QLatin1StringView(qWebEngineChromiumVersion());
+ m_profile.reset(new QWebEngineProfile(name));
m_profile->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
m_profile->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
+ m_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
+ m_profile->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls, false);
+ m_profile->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled, true);
QObject::connect(m_profile.get(), &QWebEngineProfile::downloadRequested,
&m_downloadManagerWidget, &DownloadManagerWidget::downloadRequested);
}
@@ -79,6 +37,12 @@ BrowserWindow *Browser::createWindow(bool offTheRecord)
QObject::connect(mainWindow, &QObject::destroyed, [this, mainWindow]() {
m_windows.removeOne(mainWindow);
});
+ return mainWindow;
+}
+
+BrowserWindow *Browser::createWindow(bool offTheRecord)
+{
+ auto *mainWindow = createHiddenWindow(offTheRecord);
mainWindow->show();
return mainWindow;
}
diff --git a/examples/webenginewidgets/simplebrowser/browser.h b/examples/webenginewidgets/simplebrowser/browser.h
index 2296eda9a..dcee68c79 100644
--- a/examples/webenginewidgets/simplebrowser/browser.h
+++ b/examples/webenginewidgets/simplebrowser/browser.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BROWSER_H
#define BROWSER_H
@@ -65,6 +18,7 @@ public:
QList<BrowserWindow*> windows() { return m_windows; }
+ BrowserWindow *createHiddenWindow(bool offTheRecord = false);
BrowserWindow *createWindow(bool offTheRecord = false);
BrowserWindow *createDevToolsWindow();
diff --git a/examples/webenginewidgets/simplebrowser/browserwindow.cpp b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
index 26639117c..a5a83a2d3 100644
--- a/examples/webenginewidgets/simplebrowser/browserwindow.cpp
+++ b/examples/webenginewidgets/simplebrowser/browserwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
#include "browserwindow.h"
@@ -68,18 +21,12 @@
#include <QWebEngineFindTextResult>
#include <QWebEngineProfile>
+using namespace Qt::StringLiterals;
+
BrowserWindow::BrowserWindow(Browser *browser, QWebEngineProfile *profile, bool forDevTools)
: m_browser(browser)
, m_profile(profile)
, m_tabWidget(new TabWidget(profile, this))
- , m_progressBar(nullptr)
- , m_historyBackAction(nullptr)
- , m_historyForwardAction(nullptr)
- , m_stopAction(nullptr)
- , m_reloadAction(nullptr)
- , m_stopReloadAction(nullptr)
- , m_urlLineEdit(nullptr)
- , m_favAction(nullptr)
{
setAttribute(Qt::WA_DeleteOnClose, true);
setFocusPolicy(Qt::ClickFocus);
@@ -105,7 +52,7 @@ BrowserWindow::BrowserWindow(Browser *browser, QWebEngineProfile *profile, bool
m_progressBar->setMaximumHeight(1);
m_progressBar->setTextVisible(false);
- m_progressBar->setStyleSheet(QStringLiteral("QProgressBar {border: 0px} QProgressBar::chunk {background-color: #da4453}"));
+ m_progressBar->setStyleSheet(u"QProgressBar {border: 0px} QProgressBar::chunk {background-color: #da4453}"_s);
layout->addWidget(m_progressBar);
}
@@ -153,7 +100,11 @@ QSize BrowserWindow::sizeHint() const
QMenu *BrowserWindow::createFileMenu(TabWidget *tabWidget)
{
QMenu *fileMenu = new QMenu(tr("&File"));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ fileMenu->addAction(tr("&New Window"), QKeySequence::New, this, &BrowserWindow::handleNewWindowTriggered);
+#else
fileMenu->addAction(tr("&New Window"), this, &BrowserWindow::handleNewWindowTriggered, QKeySequence::New);
+#endif
fileMenu->addAction(tr("New &Incognito Window"), this, &BrowserWindow::handleNewIncognitoWindowTriggered);
QAction *newTabAction = new QAction(tr("New &Tab"), this);
@@ -164,7 +115,11 @@ QMenu *BrowserWindow::createFileMenu(TabWidget *tabWidget)
});
fileMenu->addAction(newTabAction);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ fileMenu->addAction(tr("&Open File..."), QKeySequence::Open, this, &BrowserWindow::handleFileOpenTriggered);
+#else
fileMenu->addAction(tr("&Open File..."), this, &BrowserWindow::handleFileOpenTriggered, QKeySequence::Open);
+#endif
fileMenu->addSeparator();
QAction *closeTabAction = new QAction(tr("&Close Tab"), this);
@@ -305,11 +260,19 @@ QMenu *BrowserWindow::createWindowMenu(TabWidget *tabWidget)
previousTabAction->setShortcuts(shortcuts);
connect(previousTabAction, &QAction::triggered, tabWidget, &TabWidget::previousTab);
- connect(menu, &QMenu::aboutToShow, [this, menu, nextTabAction, previousTabAction]() {
+ QAction *inspectorAction = new QAction(tr("Open inspector in new window"), this);
+ shortcuts.clear();
+ shortcuts.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_I));
+ inspectorAction->setShortcuts(shortcuts);
+ connect(inspectorAction, &QAction::triggered, [this]() { emit currentTab()->devToolsRequested(currentTab()->page()); });
+
+ connect(menu, &QMenu::aboutToShow, [this, menu, nextTabAction, previousTabAction, inspectorAction]() {
menu->clear();
menu->addAction(nextTabAction);
menu->addAction(previousTabAction);
menu->addSeparator();
+ menu->addAction(inspectorAction);
+ menu->addSeparator();
QList<BrowserWindow*> windows = m_browser->windows();
int index(-1);
@@ -331,6 +294,20 @@ QMenu *BrowserWindow::createHelpMenu()
return helpMenu;
}
+static bool isBackspace(const QKeySequence &k)
+{
+ return (k[0].key() & Qt::Key_unknown) == Qt::Key_Backspace;
+}
+
+// Chromium already handles navigate on backspace when appropriate.
+static QList<QKeySequence> removeBackspace(QList<QKeySequence> keys)
+{
+ const auto it = std::find_if(keys.begin(), keys.end(), isBackspace);
+ if (it != keys.end())
+ keys.erase(it);
+ return keys;
+}
+
QToolBar *BrowserWindow::createToolBar()
{
QToolBar *navigationBar = new QToolBar(tr("Navigation"));
@@ -338,19 +315,13 @@ QToolBar *BrowserWindow::createToolBar()
navigationBar->toggleViewAction()->setEnabled(false);
m_historyBackAction = new QAction(this);
- QList<QKeySequence> backShortcuts = QKeySequence::keyBindings(QKeySequence::Back);
- for (auto it = backShortcuts.begin(); it != backShortcuts.end();) {
- // Chromium already handles navigate on backspace when appropriate.
- if ((*it)[0].key() == Qt::Key_Backspace)
- it = backShortcuts.erase(it);
- else
- ++it;
- }
+ auto backShortcuts = removeBackspace(QKeySequence::keyBindings(QKeySequence::Back));
// For some reason Qt doesn't bind the dedicated Back key to Back.
backShortcuts.append(QKeySequence(Qt::Key_Back));
m_historyBackAction->setShortcuts(backShortcuts);
m_historyBackAction->setIconVisibleInMenu(false);
- m_historyBackAction->setIcon(QIcon(QStringLiteral(":go-previous.png")));
+ m_historyBackAction->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::GoPrevious,
+ QIcon(":go-previous.png"_L1)));
m_historyBackAction->setToolTip(tr("Go back in history"));
connect(m_historyBackAction, &QAction::triggered, [this]() {
m_tabWidget->triggerWebPageAction(QWebEnginePage::Back);
@@ -358,17 +329,12 @@ QToolBar *BrowserWindow::createToolBar()
navigationBar->addAction(m_historyBackAction);
m_historyForwardAction = new QAction(this);
- QList<QKeySequence> fwdShortcuts = QKeySequence::keyBindings(QKeySequence::Forward);
- for (auto it = fwdShortcuts.begin(); it != fwdShortcuts.end();) {
- if (((*it)[0].key() & Qt::Key_unknown) == Qt::Key_Backspace)
- it = fwdShortcuts.erase(it);
- else
- ++it;
- }
+ auto fwdShortcuts = removeBackspace(QKeySequence::keyBindings(QKeySequence::Forward));
fwdShortcuts.append(QKeySequence(Qt::Key_Forward));
m_historyForwardAction->setShortcuts(fwdShortcuts);
m_historyForwardAction->setIconVisibleInMenu(false);
- m_historyForwardAction->setIcon(QIcon(QStringLiteral(":go-next.png")));
+ m_historyForwardAction->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::GoNext,
+ QIcon(":go-next.png"_L1)));
m_historyForwardAction->setToolTip(tr("Go forward in history"));
connect(m_historyForwardAction, &QAction::triggered, [this]() {
m_tabWidget->triggerWebPageAction(QWebEnginePage::Forward);
@@ -388,12 +354,11 @@ QToolBar *BrowserWindow::createToolBar()
navigationBar->addWidget(m_urlLineEdit);
auto downloadsAction = new QAction(this);
- downloadsAction->setIcon(QIcon(QStringLiteral(":go-bottom.png")));
+ downloadsAction->setIcon(QIcon(u":go-bottom.png"_s));
downloadsAction->setToolTip(tr("Show downloads"));
navigationBar->addAction(downloadsAction);
- connect(downloadsAction, &QAction::triggered, [this]() {
- m_browser->downloadManagerWidget().show();
- });
+ connect(downloadsAction, &QAction::triggered,
+ &m_browser->downloadManagerWidget(), &QWidget::show);
return navigationBar;
}
@@ -493,8 +458,10 @@ WebView *BrowserWindow::currentTab() const
void BrowserWindow::handleWebViewLoadProgress(int progress)
{
- static QIcon stopIcon(QStringLiteral(":process-stop.png"));
- static QIcon reloadIcon(QStringLiteral(":view-refresh.png"));
+ static QIcon stopIcon = QIcon::fromTheme(QIcon::ThemeIcon::ProcessStop,
+ QIcon(":process-stop.png"_L1));
+ static QIcon reloadIcon = QIcon::fromTheme(QIcon::ThemeIcon::ViewRefresh,
+ QIcon(":view-refresh.png"_L1));
if (0 < progress && progress < 100) {
m_stopReloadAction->setData(QWebEnginePage::Stop);
diff --git a/examples/webenginewidgets/simplebrowser/browserwindow.h b/examples/webenginewidgets/simplebrowser/browserwindow.h
index 11a655469..55eeb46c2 100644
--- a/examples/webenginewidgets/simplebrowser/browserwindow.h
+++ b/examples/webenginewidgets/simplebrowser/browserwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef BROWSERWINDOW_H
#define BROWSERWINDOW_H
@@ -69,7 +22,8 @@ class BrowserWindow : public QMainWindow
Q_OBJECT
public:
- BrowserWindow(Browser *browser, QWebEngineProfile *profile, bool forDevTools = false);
+ explicit BrowserWindow(Browser *browser, QWebEngineProfile *profile,
+ bool forDevTools = false);
QSize sizeHint() const override;
TabWidget *tabWidget() const;
WebView *currentTab() const;
@@ -102,14 +56,14 @@ private:
Browser *m_browser;
QWebEngineProfile *m_profile;
TabWidget *m_tabWidget;
- QProgressBar *m_progressBar;
- QAction *m_historyBackAction;
- QAction *m_historyForwardAction;
- QAction *m_stopAction;
- QAction *m_reloadAction;
- QAction *m_stopReloadAction;
- QLineEdit *m_urlLineEdit;
- QAction *m_favAction;
+ QProgressBar *m_progressBar = nullptr;
+ QAction *m_historyBackAction = nullptr;
+ QAction *m_historyForwardAction = nullptr;
+ QAction *m_stopAction = nullptr;
+ QAction *m_reloadAction = nullptr;
+ QAction *m_stopReloadAction = nullptr;
+ QLineEdit *m_urlLineEdit = nullptr;
+ QAction *m_favAction = nullptr;
QString m_lastSearch;
};
diff --git a/examples/webenginewidgets/simplebrowser/data/3rdparty/qt_attribution.json b/examples/webenginewidgets/simplebrowser/data/3rdparty/qt_attribution.json
index 853adeb20..fbc96416e 100644
--- a/examples/webenginewidgets/simplebrowser/data/3rdparty/qt_attribution.json
+++ b/examples/webenginewidgets/simplebrowser/data/3rdparty/qt_attribution.json
@@ -9,16 +9,16 @@
"Homepage": "http://tango.freedesktop.org/Tango_Icon_Library",
"Version": "0.8.90",
"DownloadLocation": "http://tango.freedesktop.org/releases/tango-icon-theme-0.8.90.tar.gz",
- "LicenseId": "DocumentRef-PublicDomain",
+ "LicenseId": "urn:dje:license:public-domain",
"License": "Public Domain",
"LicenseFile": "COPYING",
- "Copyright": "Ulisse Perusin <uli.peru@gmail.com>
-Steven Garrity <sgarrity@silverorange.com>
-Lapo Calamandrei <calamandrei@gmail.com>
-Ryan Collier <rcollier@novell.com>
-Rodney Dawes <dobey@novell.com>
-Andreas Nilsson <nisses.mail@home.se>
-Tuomas Kuosmanen <tigert@tigert.com>
-Garrett LeSage <garrett@novell.com>
-Jakub Steiner <jimmac@novell.com>"
+ "Copyright": ["Ulisse Perusin <uli.peru@gmail.com>",
+ "Steven Garrity <sgarrity@silverorange.com>",
+ "Lapo Calamandrei <calamandrei@gmail.com>",
+ "Ryan Collier <rcollier@novell.com>",
+ "Rodney Dawes <dobey@novell.com>",
+ "Andreas Nilsson <nisses.mail@home.se>",
+ "Tuomas Kuosmanen <tigert@tigert.com>",
+ "Garrett LeSage <garrett@novell.com>",
+ "Jakub Steiner <jimmac@novell.com>"]
}
diff --git a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
index b10c6d4f0..dd7a8b998 100644
--- a/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
+++ b/examples/webenginewidgets/simplebrowser/doc/src/simplebrowser.qdoc
@@ -1,35 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/simplebrowser
\title WebEngine Widgets Simple Browser Example
\ingroup webengine-widgetexamples
\brief A simple browser based on \QWE Widgets.
+ \examplecategory {Web Technologies}
\image simplebrowser.png
@@ -91,6 +68,9 @@
\skipto main
\printuntil }
+ To suppress flicker when switching the window to OpenGL rendering, we call
+ show after the first browser tab has been added.
+
\section1 Creating Tabs
The \c BrowserWindow constructor initializes all the necessary user interface
@@ -280,6 +260,8 @@
\skipto /^class Browser$/
\printuntil public:
\dots
+ \skipto createHiddenWindow
+ \printline createHiddenWindow
\skipto createWindow
\printline createWindow
\skipto private:
@@ -295,7 +277,7 @@
\quotefromfile webenginewidgets/simplebrowser/browser.cpp
- \skipto Browser::createWindow
+ \skipto Browser::createHiddenWindow
\printuntil m_profile.reset
\dots
@@ -340,6 +322,37 @@
finished or when an error occurs. See \c downloadmanagerwidget.cpp for an
example of how these signals can be handled.
+ \section1 Managing WebAuth/FIDO UX Requests
+
+ WebAuth UX requests are associated with \l QWebEnginePage. Whenever an authenticator
+ requires user interaction, a UX request is triggered on the QWebEnginePage and
+ the \l QWebEnginePage::webAuthUxRequested signal is emitted with
+ \l QWebEngineWebAuthUxRequest, which in this example is forwarded
+ to \c WebView::handleAuthenticatorRequired:
+
+ \quotefromfile webenginewidgets/simplebrowser/webview.cpp
+ \skipto connect(page, &QWebEnginePage::webAuthUxRequested
+ \printline connect(page, &QWebEnginePage::webAuthUxRequested
+
+ This method creates a WebAuth UX dialog and initiates the UX request flow.
+
+ \quotefromfile webenginewidgets/simplebrowser/webview.cpp
+ \skipto void WebView::handleWebAuthUxRequested(QWebEngineWebAuthUxRequest *request)
+ \printuntil /^\}/
+
+ The \l QWebEngineWebAuthUxRequest object periodically emits the \l
+ {QWebEngineWebAuthUxRequest::}{stateChanged} signal to notify potential
+ observers of the current WebAuth UX states. The observers update the WebAuth
+ dialog accordingly. See \c webview.cpp and \c webauthdialog.cpp for an example
+ of how these signals can be handled.
+
+ \section1 Signing Requirement for macOS
+
+ To allow web sites access to the location, camera, and microphone when running
+ \e {Simple Browser} on macOS, the application needs to be signed. This is
+ done automatically when building, but you need to set up a valid signing identity
+ for the build environment.
+
\section1 Files and Attributions
The example uses icons from the Tango Icon Library:
diff --git a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp
index cdd3a414a..fdddc4fb0 100644
--- a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp
+++ b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "downloadmanagerwidget.h"
@@ -60,7 +13,6 @@
DownloadManagerWidget::DownloadManagerWidget(QWidget *parent)
: QWidget(parent)
- , m_numDownloads(0)
{
setupUi(this);
}
diff --git a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h
index 221cd261f..67df492b9 100644
--- a/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h
+++ b/examples/webenginewidgets/simplebrowser/downloadmanagerwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DOWNLOADMANAGERWIDGET_H
#define DOWNLOADMANAGERWIDGET_H
@@ -77,7 +30,7 @@ private:
void add(DownloadWidget *downloadWidget);
void remove(DownloadWidget *downloadWidget);
- int m_numDownloads;
+ int m_numDownloads = 0;
};
#endif // DOWNLOADMANAGERWIDGET_H
diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp
index 1ce97e0e9..2fb65e1a8 100644
--- a/examples/webenginewidgets/simplebrowser/downloadwidget.cpp
+++ b/examples/webenginewidgets/simplebrowser/downloadwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "downloadwidget.h"
@@ -54,6 +7,8 @@
#include <QUrl>
#include <QWebEngineDownloadRequest>
+using namespace Qt::StringLiterals;
+
DownloadWidget::DownloadWidget(QWebEngineDownloadRequest *download, QWidget *parent)
: QFrame(parent)
, m_download(download)
@@ -85,12 +40,11 @@ inline QString DownloadWidget::withUnit(qreal bytes)
{
if (bytes < (1 << 10))
return tr("%L1 B").arg(bytes);
- else if (bytes < (1 << 20))
+ if (bytes < (1 << 20))
return tr("%L1 KiB").arg(bytes / (1 << 10), 0, 'f', 2);
- else if (bytes < (1 << 30))
+ if (bytes < (1 << 30))
return tr("%L1 MiB").arg(bytes / (1 << 20), 0, 'f', 2);
- else
- return tr("%L1 GiB").arg(bytes / (1 << 30), 0, 'f', 2);
+ return tr("%L1 GiB").arg(bytes / (1 << 30), 0, 'f', 2);
}
void DownloadWidget::updateWidget()
@@ -110,16 +64,14 @@ void DownloadWidget::updateWidget()
m_progressBar->setDisabled(false);
m_progressBar->setFormat(
tr("%p% - %1 of %2 downloaded - %3/s")
- .arg(withUnit(receivedBytes))
- .arg(withUnit(totalBytes))
- .arg(withUnit(bytesPerSecond)));
+ .arg(withUnit(receivedBytes), withUnit(totalBytes),
+ withUnit(bytesPerSecond)));
} else {
m_progressBar->setValue(0);
m_progressBar->setDisabled(false);
m_progressBar->setFormat(
tr("unknown size - %1 downloaded - %2/s")
- .arg(withUnit(receivedBytes))
- .arg(withUnit(bytesPerSecond)));
+ .arg(withUnit(receivedBytes), withUnit(bytesPerSecond)));
}
break;
case QWebEngineDownloadRequest::DownloadCompleted:
@@ -127,16 +79,14 @@ void DownloadWidget::updateWidget()
m_progressBar->setDisabled(true);
m_progressBar->setFormat(
tr("completed - %1 downloaded - %2/s")
- .arg(withUnit(receivedBytes))
- .arg(withUnit(bytesPerSecond)));
+ .arg(withUnit(receivedBytes), withUnit(bytesPerSecond)));
break;
case QWebEngineDownloadRequest::DownloadCancelled:
m_progressBar->setValue(0);
m_progressBar->setDisabled(true);
m_progressBar->setFormat(
tr("cancelled - %1 downloaded - %2/s")
- .arg(withUnit(receivedBytes))
- .arg(withUnit(bytesPerSecond)));
+ .arg(withUnit(receivedBytes), withUnit(bytesPerSecond)));
break;
case QWebEngineDownloadRequest::DownloadInterrupted:
m_progressBar->setValue(0);
@@ -148,11 +98,13 @@ void DownloadWidget::updateWidget()
}
if (state == QWebEngineDownloadRequest::DownloadInProgress) {
- static QIcon cancelIcon(QStringLiteral(":process-stop.png"));
+ static QIcon cancelIcon(QIcon::fromTheme(QIcon::ThemeIcon::ProcessStop,
+ QIcon(":process-stop.png"_L1)));
m_cancelButton->setIcon(cancelIcon);
m_cancelButton->setToolTip(tr("Stop downloading"));
} else {
- static QIcon removeIcon(QStringLiteral(":edit-clear.png"));
+ static QIcon removeIcon(QIcon::fromTheme(QIcon::ThemeIcon::EditClear,
+ QIcon(":edit-clear.png"_L1)));
m_cancelButton->setIcon(removeIcon);
m_cancelButton->setToolTip(tr("Remove from list"));
}
diff --git a/examples/webenginewidgets/simplebrowser/downloadwidget.h b/examples/webenginewidgets/simplebrowser/downloadwidget.h
index c59b1b4b7..bf24d242c 100644
--- a/examples/webenginewidgets/simplebrowser/downloadwidget.h
+++ b/examples/webenginewidgets/simplebrowser/downloadwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef DOWNLOADWIDGET_H
#define DOWNLOADWIDGET_H
diff --git a/examples/webenginewidgets/simplebrowser/main.cpp b/examples/webenginewidgets/simplebrowser/main.cpp
index 61acee4d1..ff4811eae 100644
--- a/examples/webenginewidgets/simplebrowser/main.cpp
+++ b/examples/webenginewidgets/simplebrowser/main.cpp
@@ -1,68 +1,24 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
#include "browserwindow.h"
#include "tabwidget.h"
#include <QApplication>
+#include <QLoggingCategory>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
+using namespace Qt::StringLiterals;
+
QUrl commandLineUrlArgument()
{
const QStringList args = QCoreApplication::arguments();
for (const QString &arg : args.mid(1)) {
- if (!arg.startsWith(QLatin1Char('-')))
+ if (!arg.startsWith(u'-'))
return QUrl::fromUserInput(arg);
}
- return QUrl(QStringLiteral("https://www.qt.io"));
+ return QUrl(u"chrome://qt"_s);
}
int main(int argc, char **argv)
@@ -70,16 +26,19 @@ int main(int argc, char **argv)
QCoreApplication::setOrganizationName("QtExamples");
QApplication app(argc, argv);
- app.setWindowIcon(QIcon(QStringLiteral(":AppLogoColor.png")));
+ app.setWindowIcon(QIcon(u":AppLogoColor.png"_s));
+ QLoggingCategory::setFilterRules(u"qt.webenginecontext.debug=true"_s);
QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
QWebEngineProfile::defaultProfile()->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
+ QWebEngineProfile::defaultProfile()->settings()->setAttribute(
+ QWebEngineSettings::ScreenCaptureEnabled, true);
QUrl url = commandLineUrlArgument();
Browser browser;
- BrowserWindow *window = browser.createWindow();
+ BrowserWindow *window = browser.createHiddenWindow();
window->tabWidget()->setUrl(url);
-
+ window->show();
return app.exec();
}
diff --git a/examples/webenginewidgets/simplebrowser/simplebrowser.exe.manifest b/examples/webenginewidgets/simplebrowser/simplebrowser.exe.manifest
new file mode 100644
index 000000000..acc401776
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/simplebrowser.exe.manifest
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+ <application>
+ <!--The ID below indicates application support for Windows Vista -->
+ <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+ <!--The ID below indicates application support for Windows 7 -->
+ <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+ <!--The ID below indicates application support for Windows 8 -->
+ <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+ <!--The ID below indicates application support for Windows 8.1 -->
+ <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+ <!--The ID below indicates application support for Windows 10/11 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+ </application>
+</compatibility>
+</assembly>
diff --git a/examples/webenginewidgets/simplebrowser/simplebrowser.pro b/examples/webenginewidgets/simplebrowser/simplebrowser.pro
index 7584cfb01..8598d237a 100644
--- a/examples/webenginewidgets/simplebrowser/simplebrowser.pro
+++ b/examples/webenginewidgets/simplebrowser/simplebrowser.pro
@@ -10,7 +10,8 @@ HEADERS += \
tabwidget.h \
webpage.h \
webpopupwindow.h \
- webview.h
+ webview.h \
+ webauthdialog.h
SOURCES += \
browser.cpp \
@@ -21,13 +22,20 @@ SOURCES += \
tabwidget.cpp \
webpage.cpp \
webpopupwindow.cpp \
- webview.cpp
+ webview.cpp \
+ webauthdialog.cpp
+
+win32 {
+ CONFIG -= embed_manifest_exe
+ QMAKE_MANIFEST = $$PWD/simplebrowser.exe.manifest
+}
FORMS += \
certificateerrordialog.ui \
passworddialog.ui \
downloadmanagerwidget.ui \
- downloadwidget.ui
+ downloadwidget.ui \
+ webauthdialog.ui
RESOURCES += data/simplebrowser.qrc
diff --git a/examples/webenginewidgets/simplebrowser/tabwidget.cpp b/examples/webenginewidgets/simplebrowser/tabwidget.cpp
index b706a3ab7..f9037a8e1 100644
--- a/examples/webenginewidgets/simplebrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/simplebrowser/tabwidget.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "tabwidget.h"
#include "webpage.h"
@@ -56,6 +9,8 @@
#include <QTabBar>
#include <QWebEngineProfile>
+using namespace Qt::StringLiterals;
+
TabWidget::TabWidget(QWebEngineProfile *profile, QWidget *parent)
: QTabWidget(parent)
, m_profile(profile)
@@ -79,9 +34,9 @@ TabWidget::TabWidget(QWebEngineProfile *profile, QWidget *parent)
if (profile->isOffTheRecord()) {
QLabel *icon = new QLabel(this);
- QPixmap pixmap(QStringLiteral(":ninja.png"));
+ QPixmap pixmap(u":ninja.png"_s);
icon->setPixmap(pixmap.scaledToHeight(tabBar->height()));
- setStyleSheet(QStringLiteral("QTabWidget::tab-bar { left: %1px; }").
+ setStyleSheet(u"QTabWidget::tab-bar { left: %1px; }"_s.
arg(icon->pixmap().width()));
}
}
@@ -115,7 +70,11 @@ void TabWidget::handleCurrentChanged(int index)
void TabWidget::handleContextMenuRequested(const QPoint &pos)
{
QMenu menu;
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ menu.addAction(tr("New &Tab"), QKeySequence::AddTab, this, &TabWidget::createTab);
+#else
menu.addAction(tr("New &Tab"), this, &TabWidget::createTab, QKeySequence::AddTab);
+#endif
int index = tabBar()->tabAt(pos);
if (index != -1) {
QAction *action = menu.addAction(tr("Clone Tab"));
diff --git a/examples/webenginewidgets/simplebrowser/tabwidget.h b/examples/webenginewidgets/simplebrowser/tabwidget.h
index 06f3db829..a1a893b62 100644
--- a/examples/webenginewidgets/simplebrowser/tabwidget.h
+++ b/examples/webenginewidgets/simplebrowser/tabwidget.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef TABWIDGET_H
#define TABWIDGET_H
@@ -66,7 +19,7 @@ class TabWidget : public QTabWidget
Q_OBJECT
public:
- TabWidget(QWebEngineProfile *profile, QWidget *parent = nullptr);
+ explicit TabWidget(QWebEngineProfile *profile, QWidget *parent = nullptr);
WebView *currentWebView() const;
diff --git a/examples/webenginewidgets/simplebrowser/webauthdialog.cpp b/examples/webenginewidgets/simplebrowser/webauthdialog.cpp
new file mode 100644
index 000000000..85d944db6
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/webauthdialog.cpp
@@ -0,0 +1,294 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#include "webauthdialog.h"
+
+#include <QVBoxLayout>
+#include <QRadioButton>
+#include <QLineEdit>
+#include <QTextEdit>
+#include <QPushButton>
+#include <QWebEngineView>
+
+WebAuthDialog::WebAuthDialog(QWebEngineWebAuthUxRequest *request, QWidget *parent)
+ : QDialog(parent), uxRequest(request), uiWebAuthDialog(new Ui::WebAuthDialog)
+{
+ uiWebAuthDialog->setupUi(this);
+
+ buttonGroup = new QButtonGroup(this);
+ buttonGroup->setExclusive(true);
+
+ scrollArea = new QScrollArea(this);
+ selectAccountWidget = new QWidget(this);
+ scrollArea->setWidget(selectAccountWidget);
+ scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ selectAccountWidget->resize(400, 150);
+ selectAccountLayout = new QVBoxLayout(selectAccountWidget);
+ uiWebAuthDialog->m_mainVerticalLayout->addWidget(scrollArea);
+ selectAccountLayout->setAlignment(Qt::AlignTop);
+
+ updateDisplay();
+
+ connect(uiWebAuthDialog->buttonBox, &QDialogButtonBox::rejected, this,
+ qOverload<>(&WebAuthDialog::onCancelRequest));
+
+ connect(uiWebAuthDialog->buttonBox, &QDialogButtonBox::accepted, this,
+ qOverload<>(&WebAuthDialog::onAcceptRequest));
+ QAbstractButton *button = uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry);
+ connect(button, &QAbstractButton::clicked, this, qOverload<>(&WebAuthDialog::onRetry));
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+}
+
+WebAuthDialog::~WebAuthDialog()
+{
+ QList<QAbstractButton *> buttons = buttonGroup->buttons();
+ auto itr = buttons.begin();
+ while (itr != buttons.end()) {
+ QAbstractButton *radioButton = *itr;
+ delete radioButton;
+ itr++;
+ }
+
+ if (buttonGroup) {
+ delete buttonGroup;
+ buttonGroup = nullptr;
+ }
+
+ if (uiWebAuthDialog) {
+ delete uiWebAuthDialog;
+ uiWebAuthDialog = nullptr;
+ }
+
+ // selectAccountWidget and it's children will get deleted when scroll area is destroyed
+ if (scrollArea) {
+ delete scrollArea;
+ scrollArea = nullptr;
+ }
+}
+
+void WebAuthDialog::updateDisplay()
+{
+ switch (uxRequest->state()) {
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::SelectAccount:
+ setupSelectAccountUI();
+ break;
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::CollectPin:
+ setupCollectPinUI();
+ break;
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::FinishTokenCollection:
+ setupFinishCollectTokenUI();
+ break;
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::RequestFailed:
+ setupErrorUI();
+ break;
+ default:
+ break;
+ }
+ adjustSize();
+}
+
+void WebAuthDialog::setupSelectAccountUI()
+{
+ uiWebAuthDialog->m_headingLabel->setText(tr("Choose a Passkey"));
+ uiWebAuthDialog->m_description->setText(tr("Which passkey do you want to use for ")
+ + uxRequest->relyingPartyId() + tr("? "));
+ uiWebAuthDialog->m_pinGroupBox->setVisible(false);
+ uiWebAuthDialog->m_mainVerticalLayout->removeWidget(uiWebAuthDialog->m_pinGroupBox);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setVisible(false);
+
+ clearSelectAccountButtons();
+ scrollArea->setVisible(true);
+ selectAccountWidget->resize(this->width(), this->height());
+ QStringList userNames = uxRequest->userNames();
+ // Create radio buttons for each name
+ for (const QString &name : userNames) {
+ QRadioButton *radioButton = new QRadioButton(name);
+ selectAccountLayout->addWidget(radioButton);
+ buttonGroup->addButton(radioButton);
+ }
+
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Ok"));
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Cancel)->setVisible(true);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setVisible(false);
+}
+
+void WebAuthDialog::setupFinishCollectTokenUI()
+{
+ clearSelectAccountButtons();
+ uiWebAuthDialog->m_headingLabel->setText(tr("Use your security key with")
+ + uxRequest->relyingPartyId());
+ uiWebAuthDialog->m_description->setText(
+ tr("Touch your security key again to complete the request."));
+ uiWebAuthDialog->m_pinGroupBox->setVisible(false);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setVisible(false);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setVisible(false);
+ scrollArea->setVisible(false);
+}
+void WebAuthDialog::setupCollectPinUI()
+{
+ clearSelectAccountButtons();
+ uiWebAuthDialog->m_mainVerticalLayout->addWidget(uiWebAuthDialog->m_pinGroupBox);
+ uiWebAuthDialog->m_pinGroupBox->setVisible(true);
+ uiWebAuthDialog->m_confirmPinLabel->setVisible(false);
+ uiWebAuthDialog->m_confirmPinLineEdit->setVisible(false);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Next"));
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setVisible(true);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Cancel)->setVisible(true);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setVisible(false);
+ scrollArea->setVisible(false);
+
+ QWebEngineWebAuthPinRequest pinRequestInfo = uxRequest->pinRequest();
+
+ if (pinRequestInfo.reason == QWebEngineWebAuthUxRequest::PinEntryReason::Challenge) {
+ uiWebAuthDialog->m_headingLabel->setText(tr("PIN Required"));
+ uiWebAuthDialog->m_description->setText(tr("Enter the PIN for your security key"));
+ uiWebAuthDialog->m_confirmPinLabel->setVisible(false);
+ uiWebAuthDialog->m_confirmPinLineEdit->setVisible(false);
+ } else {
+ if (pinRequestInfo.reason == QWebEngineWebAuthUxRequest::PinEntryReason::Set) {
+ uiWebAuthDialog->m_headingLabel->setText(tr("New PIN Required"));
+ uiWebAuthDialog->m_description->setText(tr("Set new PIN for your security key"));
+ } else {
+ uiWebAuthDialog->m_headingLabel->setText(tr("Change PIN Required"));
+ uiWebAuthDialog->m_description->setText(tr("Change PIN for your security key"));
+ }
+ uiWebAuthDialog->m_confirmPinLabel->setVisible(true);
+ uiWebAuthDialog->m_confirmPinLineEdit->setVisible(true);
+ }
+
+ QString errorDetails;
+ switch (pinRequestInfo.error) {
+ case QWebEngineWebAuthUxRequest::PinEntryError::NoError:
+ break;
+ case QWebEngineWebAuthUxRequest::PinEntryError::InternalUvLocked:
+ errorDetails = tr("Internal User Verification Locked ");
+ break;
+ case QWebEngineWebAuthUxRequest::PinEntryError::WrongPin:
+ errorDetails = tr("Wrong PIN");
+ break;
+ case QWebEngineWebAuthUxRequest::PinEntryError::TooShort:
+ errorDetails = tr("Too Short");
+ break;
+ case QWebEngineWebAuthUxRequest::PinEntryError::InvalidCharacters:
+ errorDetails = tr("Invalid Characters");
+ break;
+ case QWebEngineWebAuthUxRequest::PinEntryError::SameAsCurrentPin:
+ errorDetails = tr("Same as current PIN");
+ break;
+ }
+ if (!errorDetails.isEmpty()) {
+ errorDetails += tr(" ") + QString::number(pinRequestInfo.remainingAttempts)
+ + tr(" attempts remaining");
+ }
+ uiWebAuthDialog->m_pinEntryErrorLabel->setText(errorDetails);
+}
+
+void WebAuthDialog::onCancelRequest()
+{
+ uxRequest->cancel();
+}
+
+void WebAuthDialog::onAcceptRequest()
+{
+ switch (uxRequest->state()) {
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::SelectAccount:
+ if (buttonGroup->checkedButton()) {
+ uxRequest->setSelectedAccount(buttonGroup->checkedButton()->text());
+ }
+ break;
+ case QWebEngineWebAuthUxRequest::WebAuthUxState::CollectPin:
+ uxRequest->setPin(uiWebAuthDialog->m_pinLineEdit->text());
+ break;
+ default:
+ break;
+ }
+}
+
+void WebAuthDialog::setupErrorUI()
+{
+ clearSelectAccountButtons();
+ QString errorDescription;
+ QString errorHeading = tr("Something went wrong");
+ bool isVisibleRetry = false;
+ switch (uxRequest->requestFailureReason()) {
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::Timeout:
+ errorDescription = tr("Request Timeout");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::KeyNotRegistered:
+ errorDescription = tr("Key not registered");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::KeyAlreadyRegistered:
+ errorDescription = tr("You already registered this device."
+ "Try again with device");
+ isVisibleRetry = true;
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::SoftPinBlock:
+ errorDescription =
+ tr("The security key is locked because the wrong PIN was entered too many times."
+ "To unlock it, remove and reinsert it.");
+ isVisibleRetry = true;
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::HardPinBlock:
+ errorDescription =
+ tr("The security key is locked because the wrong PIN was entered too many times."
+ " You'll need to reset the security key.");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::AuthenticatorRemovedDuringPinEntry:
+ errorDescription =
+ tr("Authenticator removed during verification. Please reinsert and try again");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::AuthenticatorMissingResidentKeys:
+ errorDescription = tr("Authenticator doesn't have resident key support");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::AuthenticatorMissingUserVerification:
+ errorDescription = tr("Authenticator missing user verification");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::AuthenticatorMissingLargeBlob:
+ errorDescription = tr("Authenticator missing Large Blob support");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::NoCommonAlgorithms:
+ errorDescription = tr("Authenticator missing Large Blob support");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::StorageFull:
+ errorDescription = tr("Storage Full");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::UserConsentDenied:
+ errorDescription = tr("User consent denied");
+ break;
+ case QWebEngineWebAuthUxRequest::RequestFailureReason::WinUserCancelled:
+ errorDescription = tr("User Cancelled Request");
+ break;
+ }
+
+ uiWebAuthDialog->m_headingLabel->setText(errorHeading);
+ uiWebAuthDialog->m_description->setText(errorDescription);
+ uiWebAuthDialog->m_description->adjustSize();
+ uiWebAuthDialog->m_pinGroupBox->setVisible(false);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Ok)->setVisible(false);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setVisible(isVisibleRetry);
+ if (isVisibleRetry)
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Retry)->setFocus();
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Cancel)->setVisible(true);
+ uiWebAuthDialog->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close"));
+ scrollArea->setVisible(false);
+}
+
+void WebAuthDialog::onRetry()
+{
+ uxRequest->retry();
+}
+
+void WebAuthDialog::clearSelectAccountButtons()
+{
+ QList<QAbstractButton *> buttons = buttonGroup->buttons();
+ auto itr = buttons.begin();
+ while (itr != buttons.end()) {
+ QAbstractButton *radioButton = *itr;
+ selectAccountLayout->removeWidget(radioButton);
+ buttonGroup->removeButton(radioButton);
+ delete radioButton;
+ itr++;
+ }
+}
diff --git a/examples/webenginewidgets/simplebrowser/webauthdialog.h b/examples/webenginewidgets/simplebrowser/webauthdialog.h
new file mode 100644
index 000000000..47832c1bb
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/webauthdialog.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef WEBAUTHDIALOG_H
+#define WEBAUTHDIALOG_H
+
+#include <QDialog>
+#include <QButtonGroup>
+#include <QScrollArea>
+#include "ui_webauthdialog.h"
+#include "qwebenginewebauthuxrequest.h"
+
+class WebAuthDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ WebAuthDialog(QWebEngineWebAuthUxRequest *request, QWidget *parent = nullptr);
+ ~WebAuthDialog();
+
+ void updateDisplay();
+
+private:
+ QWebEngineWebAuthUxRequest *uxRequest;
+ QButtonGroup *buttonGroup = nullptr;
+ QScrollArea *scrollArea = nullptr;
+ QWidget *selectAccountWidget = nullptr;
+ QVBoxLayout *selectAccountLayout = nullptr;
+
+ void setupSelectAccountUI();
+ void setupCollectPinUI();
+ void setupFinishCollectTokenUI();
+ void setupErrorUI();
+ void onCancelRequest();
+ void onRetry();
+ void onAcceptRequest();
+ void clearSelectAccountButtons();
+
+ Ui::WebAuthDialog *uiWebAuthDialog;
+};
+
+#endif // WEBAUTHDIALOG_H
diff --git a/examples/webenginewidgets/simplebrowser/webauthdialog.ui b/examples/webenginewidgets/simplebrowser/webauthdialog.ui
new file mode 100644
index 000000000..c8a0456d6
--- /dev/null
+++ b/examples/webenginewidgets/simplebrowser/webauthdialog.ui
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>WebAuthDialog</class>
+ <widget class="QDialog" name="WebAuthDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>563</width>
+ <height>397</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>320</y>
+ <width>471</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Retry</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="m_headingLabel">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>20</y>
+ <width>321</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Heading</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="m_description">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>60</y>
+ <width>491</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>100</y>
+ <width>471</width>
+ <height>171</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="m_mainVerticalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="m_pinGroupBox">
+ <property name="title">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <widget class="QLabel" name="m_pinLabel">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>58</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>PIN</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="m_pinLineEdit">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>20</y>
+ <width>113</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="m_confirmPinLabel">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>81</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Confirm PIN</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="m_confirmPinLineEdit">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>50</y>
+ <width>113</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="m_pinEntryErrorLabel">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>80</y>
+ <width>441</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/webenginewidgets/simplebrowser/webpage.cpp b/examples/webenginewidgets/simplebrowser/webpage.cpp
index 985e83ca2..807cdf0ff 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.cpp
+++ b/examples/webenginewidgets/simplebrowser/webpage.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browserwindow.h"
#include "tabwidget.h"
@@ -60,6 +13,8 @@ WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
{
connect(this, &QWebEnginePage::selectClientCertificate, this, &WebPage::handleSelectClientCertificate);
connect(this, &QWebEnginePage::certificateError, this, &WebPage::handleCertificateError);
+ connect(this, &QWebEnginePage::desktopMediaRequested, this,
+ &WebPage::handleDesktopMediaRequest);
}
void WebPage::handleCertificateError(QWebEngineCertificateError error)
@@ -69,31 +24,14 @@ void WebPage::handleCertificateError(QWebEngineCertificateError error)
[this, error]() mutable { emit createCertificateErrorDialog(error); });
}
-inline QString questionForFeature(QWebEnginePage::Feature feature)
-{
- switch (feature) {
- case QWebEnginePage::Geolocation:
- return WebPage::tr("Allow %1 to access your location information?");
- case QWebEnginePage::MediaAudioCapture:
- return WebPage::tr("Allow %1 to access your microphone?");
- case QWebEnginePage::MediaVideoCapture:
- return WebPage::tr("Allow %1 to access your webcam?");
- case QWebEnginePage::MediaAudioVideoCapture:
- return WebPage::tr("Allow %1 to access your microphone and webcam?");
- case QWebEnginePage::MouseLock:
- return WebPage::tr("Allow %1 to lock your mouse cursor?");
- case QWebEnginePage::DesktopVideoCapture:
- return WebPage::tr("Allow %1 to capture video of your desktop?");
- case QWebEnginePage::DesktopAudioVideoCapture:
- return WebPage::tr("Allow %1 to capture audio and video of your desktop?");
- case QWebEnginePage::Notifications:
- return WebPage::tr("Allow %1 to show notification on your desktop?");
- }
- return QString();
-}
-
void WebPage::handleSelectClientCertificate(QWebEngineClientCertificateSelection selection)
{
// Just select one.
selection.select(selection.certificates().at(0));
}
+
+void WebPage::handleDesktopMediaRequest(const QWebEngineDesktopMediaRequest &request)
+{
+ // select the primary screen
+ request.selectScreen(request.screensModel()->index(0));
+}
diff --git a/examples/webenginewidgets/simplebrowser/webpage.h b/examples/webenginewidgets/simplebrowser/webpage.h
index e01d1e1eb..56740f817 100644
--- a/examples/webenginewidgets/simplebrowser/webpage.h
+++ b/examples/webenginewidgets/simplebrowser/webpage.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WEBPAGE_H
#define WEBPAGE_H
@@ -54,13 +7,14 @@
#include <QWebEnginePage>
#include <QWebEngineRegisterProtocolHandlerRequest>
#include <QWebEngineCertificateError>
+#include <QWebEngineDesktopMediaRequest>
class WebPage : public QWebEnginePage
{
Q_OBJECT
public:
- WebPage(QWebEngineProfile *profile, QObject *parent = nullptr);
+ explicit WebPage(QWebEngineProfile *profile, QObject *parent = nullptr);
signals:
void createCertificateErrorDialog(QWebEngineCertificateError error);
@@ -68,6 +22,7 @@ signals:
private slots:
void handleCertificateError(QWebEngineCertificateError error);
void handleSelectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
+ void handleDesktopMediaRequest(const QWebEngineDesktopMediaRequest &request);
};
#endif // WEBPAGE_H
diff --git a/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp b/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp
index 566723e1f..bed956fd0 100644
--- a/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp
+++ b/examples/webenginewidgets/simplebrowser/webpopupwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "webpage.h"
#include "webpopupwindow.h"
diff --git a/examples/webenginewidgets/simplebrowser/webpopupwindow.h b/examples/webenginewidgets/simplebrowser/webpopupwindow.h
index 9cecb28a7..0726bf0c2 100644
--- a/examples/webenginewidgets/simplebrowser/webpopupwindow.h
+++ b/examples/webenginewidgets/simplebrowser/webpopupwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WEBPOPUPWINDOW_H
#define WEBPOPUPWINDOW_H
@@ -66,7 +19,7 @@ class WebPopupWindow : public QWidget
Q_OBJECT
public:
- WebPopupWindow(QWebEngineProfile *profile);
+ explicit WebPopupWindow(QWebEngineProfile *profile);
WebView *view() const;
private slots:
diff --git a/examples/webenginewidgets/simplebrowser/webview.cpp b/examples/webenginewidgets/simplebrowser/webview.cpp
index 5bd0a5ef4..08e044f70 100644
--- a/examples/webenginewidgets/simplebrowser/webview.cpp
+++ b/examples/webenginewidgets/simplebrowser/webview.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "browser.h"
#include "browserwindow.h"
@@ -56,6 +9,7 @@
#include "webview.h"
#include "ui_certificateerrordialog.h"
#include "ui_passworddialog.h"
+#include "webauthdialog.h"
#include <QContextMenuEvent>
#include <QDebug>
#include <QMenu>
@@ -64,9 +18,10 @@
#include <QTimer>
#include <QStyle>
+using namespace Qt::StringLiterals;
+
WebView::WebView(QWidget *parent)
: QWebEngineView(parent)
- , m_loadProgress(100)
{
connect(this, &QWebEngineView::loadStarted, [this]() {
m_loadProgress = 0;
@@ -104,10 +59,18 @@ WebView::WebView(QWidget *parent)
tr("Render process exited with code: %1\n"
"Do you want to reload the page ?").arg(statusCode));
if (btn == QMessageBox::Yes)
- QTimer::singleShot(0, [this] { reload(); });
+ QTimer::singleShot(0, this, &WebView::reload);
});
}
+WebView::~WebView()
+{
+ if (m_imageAnimationGroup)
+ delete m_imageAnimationGroup;
+
+ m_imageAnimationGroup = nullptr;
+}
+
inline QString questionForFeature(QWebEnginePage::Feature feature)
{
switch (feature) {
@@ -127,23 +90,32 @@ inline QString questionForFeature(QWebEnginePage::Feature feature)
return QObject::tr("Allow %1 to capture audio and video of your desktop?");
case QWebEnginePage::Notifications:
return QObject::tr("Allow %1 to show notification on your desktop?");
+ case QWebEnginePage::ClipboardReadWrite:
+ return QObject::tr("Allow %1 to read from and write to the clipboard?");
}
return QString();
}
void WebView::setPage(WebPage *page)
{
- WebPage *oldPage = qobject_cast<WebPage *>(QWebEngineView::page());
- disconnect(oldPage, &WebPage::createCertificateErrorDialog, this,
- &WebView::handleCertificateError);
- disconnect(oldPage, &QWebEnginePage::authenticationRequired, this,
- &WebView::handleAuthenticationRequired);
- disconnect(oldPage, &QWebEnginePage::featurePermissionRequested, this,
- &WebView::handleFeaturePermissionRequested);
- disconnect(oldPage, &QWebEnginePage::proxyAuthenticationRequired, this,
- &WebView::handleProxyAuthenticationRequired);
- disconnect(oldPage, &QWebEnginePage::registerProtocolHandlerRequested, this,
- &WebView::handleRegisterProtocolHandlerRequested);
+ if (auto oldPage = qobject_cast<WebPage *>(QWebEngineView::page())) {
+ disconnect(oldPage, &WebPage::createCertificateErrorDialog, this,
+ &WebView::handleCertificateError);
+ disconnect(oldPage, &QWebEnginePage::authenticationRequired, this,
+ &WebView::handleAuthenticationRequired);
+ disconnect(oldPage, &QWebEnginePage::featurePermissionRequested, this,
+ &WebView::handleFeaturePermissionRequested);
+ disconnect(oldPage, &QWebEnginePage::proxyAuthenticationRequired, this,
+ &WebView::handleProxyAuthenticationRequired);
+ disconnect(oldPage, &QWebEnginePage::registerProtocolHandlerRequested, this,
+ &WebView::handleRegisterProtocolHandlerRequested);
+ disconnect(oldPage, &QWebEnginePage::webAuthUxRequested, this,
+ &WebView::handleWebAuthUxRequested);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
+ disconnect(oldPage, &QWebEnginePage::fileSystemAccessRequested, this,
+ &WebView::handleFileSystemAccessRequested);
+#endif
+ }
createWebActionTrigger(page,QWebEnginePage::Forward);
createWebActionTrigger(page,QWebEnginePage::Back);
createWebActionTrigger(page,QWebEnginePage::Reload);
@@ -158,6 +130,11 @@ void WebView::setPage(WebPage *page)
&WebView::handleProxyAuthenticationRequired);
connect(page, &QWebEnginePage::registerProtocolHandlerRequested, this,
&WebView::handleRegisterProtocolHandlerRequested);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
+ connect(page, &QWebEnginePage::fileSystemAccessRequested, this,
+ &WebView::handleFileSystemAccessRequested);
+#endif
+ connect(page, &QWebEnginePage::webAuthUxRequested, this, &WebView::handleWebAuthUxRequested);
}
int WebView::loadProgress() const
@@ -185,15 +162,17 @@ QIcon WebView::favIcon() const
return favIcon;
if (m_loadProgress < 0) {
- static QIcon errorIcon(QStringLiteral(":dialog-error.png"));
+ static QIcon errorIcon(u":dialog-error.png"_s);
return errorIcon;
- } else if (m_loadProgress < 100) {
- static QIcon loadingIcon(QStringLiteral(":view-refresh.png"));
+ }
+ if (m_loadProgress < 100) {
+ static QIcon loadingIcon = QIcon::fromTheme(QIcon::ThemeIcon::ViewRefresh,
+ QIcon(":view-refresh.png"_L1));
return loadingIcon;
- } else {
- static QIcon defaultIcon(QStringLiteral(":text-html.png"));
- return defaultIcon;
}
+
+ static QIcon defaultIcon(u":text-html.png"_s);
+ return defaultIcon;
}
QWebEngineView *WebView::createWindow(QWebEnginePage::WebWindowType type)
@@ -231,15 +210,54 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (viewSource == actions.cend())
menu->addSeparator();
- QAction *action = new QAction(menu);
- action->setText("Open inspector in new window");
+ QAction *action = menu->addAction("Open inspector in new window");
connect(action, &QAction::triggered, [this]() { emit devToolsRequested(page()); });
-
- QAction *before(inspectElement == actions.cend() ? nullptr : *inspectElement);
- menu->insertAction(before, action);
} else {
(*inspectElement)->setText(tr("Inspect element"));
}
+
+ // add conext menu for image policy
+ QMenu *editImageAnimation = new QMenu(tr("Image animation policy"));
+
+ m_imageAnimationGroup = new QActionGroup(editImageAnimation);
+ m_imageAnimationGroup->setExclusive(true);
+
+ QAction *disableImageAnimation =
+ editImageAnimation->addAction(tr("Disable all image animation"));
+ disableImageAnimation->setCheckable(true);
+ m_imageAnimationGroup->addAction(disableImageAnimation);
+ connect(disableImageAnimation, &QAction::triggered, [this]() {
+ handleImageAnimationPolicyChange(QWebEngineSettings::DisallowImageAnimation);
+ });
+ QAction *allowImageAnimationOnce =
+ editImageAnimation->addAction(tr("Allow animated images, but only once"));
+ allowImageAnimationOnce->setCheckable(true);
+ m_imageAnimationGroup->addAction(allowImageAnimationOnce);
+ connect(allowImageAnimationOnce, &QAction::triggered,
+ [this]() { handleImageAnimationPolicyChange(QWebEngineSettings::AnimateImageOnce); });
+ QAction *allowImageAnimation = editImageAnimation->addAction(tr("Allow all animated images"));
+ allowImageAnimation->setCheckable(true);
+ m_imageAnimationGroup->addAction(allowImageAnimation);
+ connect(allowImageAnimation, &QAction::triggered, [this]() {
+ handleImageAnimationPolicyChange(QWebEngineSettings::AllowImageAnimation);
+ });
+
+ switch (page()->settings()->imageAnimationPolicy()) {
+ case QWebEngineSettings::AllowImageAnimation:
+ allowImageAnimation->setChecked(true);
+ break;
+ case QWebEngineSettings::AnimateImageOnce:
+ allowImageAnimationOnce->setChecked(true);
+ break;
+ case QWebEngineSettings::DisallowImageAnimation:
+ disableImageAnimation->setChecked(true);
+ break;
+ default:
+ allowImageAnimation->setChecked(true);
+ break;
+ }
+
+ menu->addMenu(editImageAnimation);
menu->popup(event->globalPos());
}
@@ -277,8 +295,8 @@ void WebView::handleAuthenticationRequired(const QUrl &requestUrl, QAuthenticato
passwordDialog.m_iconLabel->setPixmap(icon.pixmap(32, 32));
QString introMessage(tr("Enter username and password for \"%1\" at %2")
- .arg(auth->realm())
- .arg(requestUrl.toString().toHtmlEscaped()));
+ .arg(auth->realm(),
+ requestUrl.toString().toHtmlEscaped()));
passwordDialog.m_infoLabel->setText(introMessage);
passwordDialog.m_infoLabel->setWordWrap(true);
@@ -332,6 +350,32 @@ void WebView::handleProxyAuthenticationRequired(const QUrl &, QAuthenticator *au
}
}
+void WebView::handleWebAuthUxRequested(QWebEngineWebAuthUxRequest *request)
+{
+ if (m_authDialog)
+ delete m_authDialog;
+
+ m_authDialog = new WebAuthDialog(request, window());
+ m_authDialog->setModal(false);
+ m_authDialog->setWindowFlags(m_authDialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
+
+ connect(request, &QWebEngineWebAuthUxRequest::stateChanged, this, &WebView::onStateChanged);
+ m_authDialog->show();
+}
+
+void WebView::onStateChanged(QWebEngineWebAuthUxRequest::WebAuthUxState state)
+{
+ if (QWebEngineWebAuthUxRequest::WebAuthUxState::Completed == state
+ || QWebEngineWebAuthUxRequest::WebAuthUxState::Cancelled == state) {
+ if (m_authDialog) {
+ delete m_authDialog;
+ m_authDialog = nullptr;
+ }
+ } else {
+ m_authDialog->updateDisplay();
+ }
+}
+
//! [registerProtocolHandlerRequested]
void WebView::handleRegisterProtocolHandlerRequested(
QWebEngineRegisterProtocolHandlerRequest request)
@@ -346,3 +390,41 @@ void WebView::handleRegisterProtocolHandlerRequested(
request.reject();
}
//! [registerProtocolHandlerRequested]
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
+void WebView::handleFileSystemAccessRequested(QWebEngineFileSystemAccessRequest request)
+{
+ QString accessType;
+ switch (request.accessFlags()) {
+ case QWebEngineFileSystemAccessRequest::Read:
+ accessType = "read";
+ break;
+ case QWebEngineFileSystemAccessRequest::Write:
+ accessType = "write";
+ break;
+ case QWebEngineFileSystemAccessRequest::Read | QWebEngineFileSystemAccessRequest::Write:
+ accessType = "read and write";
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
+
+ auto answer = QMessageBox::question(window(), tr("File system access request"),
+ tr("Give %1 %2 access to %3?")
+ .arg(request.origin().host())
+ .arg(accessType)
+ .arg(request.filePath().toString()));
+ if (answer == QMessageBox::Yes)
+ request.accept();
+ else
+ request.reject();
+}
+
+void WebView::handleImageAnimationPolicyChange(QWebEngineSettings::ImageAnimationPolicy policy)
+{
+ if (!page())
+ return;
+
+ page()->settings()->setImageAnimationPolicy(policy);
+}
+#endif // QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
diff --git a/examples/webenginewidgets/simplebrowser/webview.h b/examples/webenginewidgets/simplebrowser/webview.h
index 0dc7c33ad..c7e7f394c 100644
--- a/examples/webenginewidgets/simplebrowser/webview.h
+++ b/examples/webenginewidgets/simplebrowser/webview.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WEBVIEW_H
#define WEBVIEW_H
@@ -54,17 +7,25 @@
#include <QIcon>
#include <QWebEngineView>
#include <QWebEngineCertificateError>
+#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
+#include <QWebEngineFileSystemAccessRequest>
+#endif
#include <QWebEnginePage>
#include <QWebEngineRegisterProtocolHandlerRequest>
+#include <QWebEngineWebAuthUxRequest>
+#include <QWebEngineSettings>
+#include <QActionGroup>
class WebPage;
+class WebAuthDialog;
class WebView : public QWebEngineView
{
Q_OBJECT
public:
- WebView(QWidget *parent = nullptr);
+ explicit WebView(QWidget *parent = nullptr);
+ ~WebView();
void setPage(WebPage *page);
int loadProgress() const;
@@ -87,12 +48,20 @@ private slots:
void handleProxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *auth,
const QString &proxyHost);
void handleRegisterProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
+ void handleFileSystemAccessRequested(QWebEngineFileSystemAccessRequest request);
+ void handleWebAuthUxRequested(QWebEngineWebAuthUxRequest *request);
+#endif
+ void handleImageAnimationPolicyChange(QWebEngineSettings::ImageAnimationPolicy policy);
private:
void createWebActionTrigger(QWebEnginePage *page, QWebEnginePage::WebAction);
+ void onStateChanged(QWebEngineWebAuthUxRequest::WebAuthUxState state);
private:
- int m_loadProgress;
+ int m_loadProgress = 100;
+ WebAuthDialog *m_authDialog = nullptr;
+ QActionGroup *m_imageAnimationGroup = nullptr;
};
#endif
diff --git a/examples/webenginewidgets/spellchecker/CMakeLists.txt b/examples/webenginewidgets/spellchecker/CMakeLists.txt
index f05cd74fe..3a5ea08ca 100644
--- a/examples/webenginewidgets/spellchecker/CMakeLists.txt
+++ b/examples/webenginewidgets/spellchecker/CMakeLists.txt
@@ -1,45 +1,42 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(spellchecker LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/spellchecker")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(spellchecker
main.cpp
webview.cpp webview.h
)
+
set_target_properties(spellchecker PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(spellchecker PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(spellchecker_resource_files
- "data/icon.svg"
"data/index.html"
"data/style.css"
)
-qt6_add_resources(spellchecker "spellchecker"
+qt_add_resources(spellchecker "spellchecker"
PREFIX
"/"
BASE
@@ -55,35 +52,14 @@ install(TARGETS spellchecker
)
file(GLOB_RECURSE dicts
- RELATIVE ${CMAKE_CURRENT_LIST_DIR}/dict
+ ABSOLUTE ${CMAKE_CURRENT_LIST_DIR}/dict
*/*.dic
)
-if(QT_GENERATOR_IS_MULTI_CONFIG)
- set(spellcheckerDir ${CMAKE_CURRENT_BINARY_DIR}/dict/qtwebengine_dictionaries)
-else()
- set(spellcheckerDir ${CMAKE_CURRENT_BINARY_DIR}/qtwebengine_dictionaries)
-endif()
-
foreach(dictFile ${dicts})
- get_filename_component(dictName ${dictFile} NAME_WE)
- add_custom_command(TARGET spellchecker
- PRE_BUILD
- COMMAND ${CMAKE_COMMAND} -E make_directory ${spellcheckerDir}
- COMMAND $<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::qwebengine_convert_dict>
- ${CMAKE_CURRENT_SOURCE_DIR}/dict/${dictFile}
- ${spellcheckerDir}/${dictName}.bdic
- COMMENT "Running qwebengine_convert_dict"
+ qt_add_webengine_dictionary(
+ TARGET spellchecker
+ SOURCE "${dictFile}"
+ OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
-
-# copy dictionaries to $<CONFIG> build dir
-if(QT_GENERATOR_IS_MULTI_CONFIG)
- add_custom_command(TARGET spellchecker
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E echo Copying dictionares
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/dict
- ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>
- )
-endif()
-
diff --git a/examples/webenginewidgets/spellchecker/data/icon.svg b/examples/webenginewidgets/spellchecker/data/icon.svg
deleted file mode 100644
index b90ff26dd..000000000
--- a/examples/webenginewidgets/spellchecker/data/icon.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
- width="94px" height="94px" viewBox="0 0 94 94" enable-background="new 0 0 94 94" xml:space="preserve">
-<g>
- <circle fill="none" cx="47" cy="47" r="47"/>
- <g>
- <path fill="#46A2DA" d="M47,92.979c-11.779,0-23.559-4.484-32.526-13.451C-3.461,61.591-3.461,32.409,14.472,14.474
- C32.41-3.463,61.592-3.461,79.526,14.473c17.935,17.936,17.935,47.119,0.002,65.054l-0.002,0.001
- C70.559,88.495,58.779,92.979,47,92.979z"/>
- </g>
- <path fill="#80C342" d="M93,47C93,21.595,72.405,1,47,1C34.297,1,22.797,6.149,14.473,14.473l65.054,65.054
- C87.851,71.203,93,59.703,93,47z"/>
- <g>
- <path fill="#46A2DA" d="M47,65c-4.808,0-9.328-1.873-12.728-5.272c-7.018-7.019-7.018-18.438,0-25.456
- C37.672,30.873,42.192,29,47,29s9.328,1.873,12.728,5.272c7.018,7.019,7.018,18.438,0,25.456C56.328,63.127,51.808,65,47,65z"/>
- <path fill="#FFFFFF" d="M62.248,59.919c6.671-7.858,6.312-19.644-1.105-27.061C57.237,28.953,52.118,27,47,27
- c-5.118,0-10.237,1.953-14.142,5.858c-7.81,7.81-7.81,20.474,0,28.284C36.763,65.047,41.882,67,47,67
- c4.379,0,8.752-1.441,12.372-4.3L77.88,81.209c0.989-0.895,1.935-1.837,2.843-2.814L62.248,59.919z M35.686,58.314
- c-6.238-6.238-6.238-16.389,0-22.627C38.708,32.664,42.726,31,47,31c4.274,0,8.292,1.664,11.314,4.686
- c6.238,6.238,6.238,16.389,0,22.627C55.292,61.336,51.274,63,47,63C42.726,63,38.708,61.336,35.686,58.314z"/>
- </g>
-</g>
-</svg>
diff --git a/examples/webenginewidgets/spellchecker/data/index.html b/examples/webenginewidgets/spellchecker/data/index.html
index b6cec5fe0..f68d64bc4 100644
--- a/examples/webenginewidgets/spellchecker/data/index.html
+++ b/examples/webenginewidgets/spellchecker/data/index.html
@@ -6,28 +6,29 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
- <form class="form">
- <img class="logo" src="icon.svg" alt="qtwebengine">
- <div class="header">
- <h1>Contact us</h1>
- <h2>We are here to help</h2>
- </div>
- <label>
- <span>First Name:</span><input id="firstname" type="text" name="name" />
- </label>
- <label>
- <span>Last Name:</span><input id="lastName" type="text" name="name" />
- </label>
- <label>
- <span>Email Address:</span><input id="email" type="text" name="email" />
- </label>
- <label>
- <span>Subject:</span><input id="subject" type="text" name="subject" />
- </label>
- <label>
- <span>Message:</span><textarea id="feedback" name="feedback"></textarea>
- </label>
- <input type="submit" value="Send" />
- </form>
+ <main>
+ <form class="form">
+ <div class="header">
+ <h1>Contact us</h1>
+ <h2>We are here to help</h2>
+ </div>
+ <label>
+ <span>First Name</span><input id="firstname" type="text" name="name" />
+ </label>
+ <label>
+ <span>Last Name</span><input id="lastName" type="text" name="name" />
+ </label>
+ <label>
+ <span>Email</span><input id="email" type="text" name="email" />
+ </label>
+ <label>
+ <span>Subject</span><input id="subject" type="text" name="subject" />
+ </label>
+ <label>
+ <span>Message</span><textarea id="feedback" name="feedback"></textarea>
+ </label>
+ <input type="submit" value="Send" />
+ </form>
+ </main>
</body>
</html>
diff --git a/examples/webenginewidgets/spellchecker/data/spellchecker.qrc b/examples/webenginewidgets/spellchecker/data/spellchecker.qrc
index a9c76cc7e..b5e0b1fe0 100644
--- a/examples/webenginewidgets/spellchecker/data/spellchecker.qrc
+++ b/examples/webenginewidgets/spellchecker/data/spellchecker.qrc
@@ -2,6 +2,5 @@
<qresource prefix="/">
<file>index.html</file>
<file>style.css</file>
- <file>icon.svg</file>
</qresource>
</RCC>
diff --git a/examples/webenginewidgets/spellchecker/data/style.css b/examples/webenginewidgets/spellchecker/data/style.css
index 7b6736f1f..38873c5a0 100644
--- a/examples/webenginewidgets/spellchecker/data/style.css
+++ b/examples/webenginewidgets/spellchecker/data/style.css
@@ -1,90 +1,119 @@
-.logo {
- width: 50px;
- height: 50px;
- float: left;
- margin: 20px 20px 0px 20px;
- -webkit-animation:spin 8s linear infinite;
+@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700&display=swap');
+* {
+ padding: 0;
+ margin: 0;
+ box-sizing: border-box;
+}
+
+
+body {
+ width: 100%;
+ padding: 0px;
+ margin: 0px;
}
-@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
.header {
- display: inline
+ display: inline;
+}
+
+.main {
+ max-width: 100%;
}
.form {
- width: 450px;
- height: 600px;
- background: -webkit-linear-gradient(bottom, #ddd, #fff);
- border: 1px solid #999;
- border-radius: 12px;
- color: #46a;
- font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
- font-size: 14px;
- font-style: italic;
- font-weight: bold;
- margin: auto;
- padding: 10px;
- position: relative;
- line-height: 26px;
- text-decoration: none;
- -webkit-box-shadow: 0px 0px 5px #444;
+ width: 100%;
+ height: 100%;
+ background: #fff;
+ border: 0px solid #999;
+ border-radius: 8px;
+ color: #46a;
+ font-family: 'Titillium Web', sans-serif;
+ font-size: 1rem;
+ margin: auto;
+ padding: 40px;
+ position: relative;
+ line-height: 26px;
+ text-decoration: none;
}
h1 {
- padding-left:40px;
- color: #46a2da;
+ padding-left: 20px;
+ color: #00414A;
+ font-size: 2.5rem;
+ font-weight: 700;
+ margin-bottom: 1rem;
}
h2 {
- color: #80c342;
- font-size: 13px;
- margin-top: -20px;
+ padding-left: 20px;
+ color: #00414A;
+ font-size: 1.125rem;
+ font-weight: 400;
+ font-style: italic;
+ margin-bottom: 1.75rem;
}
span {
- margin-left: 20px;
+ font-size: 1.5rem;
+ margin-left: 20px;
+ color: #00414A;
+ font-weight: 700;
}
input {
- width: 400px;
- display: block;
- border: 1px solid #999;
- height: 25px;
- margin-left: 20px;
- margin-bottom: 10px;
- padding-left: 10px;
- -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
+ width: 90%;
+ display: block;
+ height: 2.25rem;
+ margin-left: 20px;
+ margin-right: 20px;
+ margin-bottom: 8px;
+ padding-left: 10px;
+ box-shadow: 1px 1px 4px 0px rgba(0, 0, 0, 0.15);
+ border-radius: var(--radius-radius-minimal, 0.25rem);
+ border: 1px solid var(--color-background-normal, #CCC);
+ background: var(--color-text-input-background, #FFF);
}
textarea {
- width: 400px;
- max-width: 400px;
- height: 180px;
- max-height: 400px;
- display: block;
- margin-left: 20px;
- padding-left: 10px;
- padding-right: 10px;
- -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
+ width: 90%;
+ max-width: 90%;
+ height: 10rem;
+ max-height: 14rem;
+ display: block;
+ margin-left: 20px;
+ margin-right: 20px;
+ padding-left: 10px;
+ padding-top: 10px;
+ box-shadow: 1px 1px 4px 0px rgba(0, 0, 0, 0.15);
+ border-radius: var(--radius-radius-minimal, 0.25rem);
+ border: 1px solid var(--color-background-normal, #CCC);
+ background: var(--color-text-input-background, #FFF);
}
input:focus, textarea:focus {
- outline:none;
- border: 1px solid #46a2da;
+ outline: none;
+ border: 1px solid #00414A;
}
input[type=submit] {
- width: 100px;
- left: 170px;
- bottom: 10px;
- background: #46a2da;
- color: #fff;
- height: 30px;
- position: absolute;
- border-radius: 14px;
+ display: flex;
+ align-items: center;
+ justify-content: center; /* Add this to horizontally center the content */
+ padding: 0.4444em 0.8889em;
+ height: 2.4em;
+ cursor: pointer;
+ width: 6.5rem;
+ background: #00414A;
+ color: #fff;
+ border-radius: 4px;
+ margin-top: 28px;
+ font-family: 'Titillium Web', sans-serif;
+ font-size: 1.125rem;
+ font-weight: 400;
+ transition: color 300ms ease-out, border 300ms ease-out;
}
input[type=submit]:hover {
- background: #80c342;
+ background: #19545C;
}
diff --git a/examples/webenginewidgets/spellchecker/doc/images/spellchecker-example.png b/examples/webenginewidgets/spellchecker/doc/images/spellchecker-example.png
index cc4e74946..1cbe9e6d3 100644
--- a/examples/webenginewidgets/spellchecker/doc/images/spellchecker-example.png
+++ b/examples/webenginewidgets/spellchecker/doc/images/spellchecker-example.png
Binary files differ
diff --git a/examples/webenginewidgets/spellchecker/doc/src/spellchecker.qdoc b/examples/webenginewidgets/spellchecker/doc/src/spellchecker.qdoc
index ecdb1c818..1d9d7b73c 100644
--- a/examples/webenginewidgets/spellchecker/doc/src/spellchecker.qdoc
+++ b/examples/webenginewidgets/spellchecker/doc/src/spellchecker.qdoc
@@ -1,35 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/spellchecker
\title WebEngine Widgets Spellchecker Example
\ingroup webengine-widgetexamples
\brief Integrates a spellchecker into a simple HTML form.
+ \examplecategory {Web Technologies}
\image spellchecker-example.png
diff --git a/examples/webenginewidgets/spellchecker/main.cpp b/examples/webenginewidgets/spellchecker/main.cpp
index c2951fe00..55e06a874 100644
--- a/examples/webenginewidgets/spellchecker/main.cpp
+++ b/examples/webenginewidgets/spellchecker/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "webview.h"
#include <QApplication>
@@ -58,7 +11,7 @@ int main(int argc, char *argv[])
WebView view;
view.setUrl(QUrl(QStringLiteral("qrc:/index.html")));
- view.resize(500, 640);
+ view.resize(500, 750);
view.show();
return app.exec();
diff --git a/examples/webenginewidgets/spellchecker/spellchecker.pro b/examples/webenginewidgets/spellchecker/spellchecker.pro
index d652e4b1f..a720776ca 100644
--- a/examples/webenginewidgets/spellchecker/spellchecker.pro
+++ b/examples/webenginewidgets/spellchecker/spellchecker.pro
@@ -1,4 +1,3 @@
-include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri) # workaround for QTBUG-68093
QT_FOR_CONFIG += webenginecore
TEMPLATE = app
@@ -10,7 +9,7 @@ QT += webenginewidgets
}
qtConfig(webengine-native-spellchecker) {
- error("Spellcheck example can not be built when using native OS dictionaries.")
+ error("Spellchecker example can not be built when using native OS dictionaries.")
}
HEADERS += \
@@ -34,7 +33,7 @@ DISTFILES += \
target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/spellchecker
INSTALLS += target
-qtPrepareTool(CONVERT_TOOL, qwebengine_convert_dict)
+qtPrepareTool(CONVERT_TOOL, qwebengine_convert_dict, "", "", $$[QT_INSTALL_LIBEXECS])
debug_and_release {
CONFIG(debug, debug|release): DICTIONARIES_DIR = debug/qtwebengine_dictionaries
diff --git a/examples/webenginewidgets/spellchecker/webview.cpp b/examples/webenginewidgets/spellchecker/webview.cpp
index b532dd417..388146d31 100644
--- a/examples/webenginewidgets/spellchecker/webview.cpp
+++ b/examples/webenginewidgets/spellchecker/webview.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "webview.h"
#include <QContextMenuEvent>
diff --git a/examples/webenginewidgets/spellchecker/webview.h b/examples/webenginewidgets/spellchecker/webview.h
index 8c877b6e4..598f8b830 100644
--- a/examples/webenginewidgets/spellchecker/webview.h
+++ b/examples/webenginewidgets/spellchecker/webview.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef WEBVIEW_H
#define WEBVIEW_H
diff --git a/examples/webenginewidgets/stylesheetbrowser/3rdparty/COPYING b/examples/webenginewidgets/stylesheetbrowser/3rdparty/COPYING
deleted file mode 100644
index 220881da6..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/3rdparty/COPYING
+++ /dev/null
@@ -1 +0,0 @@
-The icons in this repository are herefore released into the Public Domain.
diff --git a/examples/webenginewidgets/stylesheetbrowser/3rdparty/qt_attribution.json b/examples/webenginewidgets/stylesheetbrowser/3rdparty/qt_attribution.json
deleted file mode 100644
index ffca1812b..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/3rdparty/qt_attribution.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "Id": "stylesheetbrowser-tango",
- "Name": "Tango Icon Library",
- "QDocModule": "qtwebengine",
- "QtUsage": "Used in WebEngine StyleSheet Browser example.",
-
- "QtParts": [ "examples" ],
- "Description": "Selected icons from the Tango Icon Library",
- "Homepage": "http://tango.freedesktop.org/Tango_Icon_Library",
- "Version": "0.8.90",
- "DownloadLocation": "http://tango.freedesktop.org/releases/tango-icon-theme-0.8.90.tar.gz",
- "LicenseId": "DocumentRef-PublicDomain",
- "License": "Public Domain",
- "LicenseFile": "COPYING",
- "Copyright": "Ulisse Perusin <uli.peru@gmail.com>
-Steven Garrity <sgarrity@silverorange.com>
-Lapo Calamandrei <calamandrei@gmail.com>
-Ryan Collier <rcollier@novell.com>
-Rodney Dawes <dobey@novell.com>
-Andreas Nilsson <nisses.mail@home.se>
-Tuomas Kuosmanen <tigert@tigert.com>
-Garrett LeSage <garrett@novell.com>
-Jakub Steiner <jimmac@novell.com>"
-}
diff --git a/examples/webenginewidgets/stylesheetbrowser/3rdparty/view-refresh.png b/examples/webenginewidgets/stylesheetbrowser/3rdparty/view-refresh.png
deleted file mode 100644
index cab4d02c7..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/3rdparty/view-refresh.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginewidgets/stylesheetbrowser/CMakeLists.txt b/examples/webenginewidgets/stylesheetbrowser/CMakeLists.txt
deleted file mode 100644
index 596da7964..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(stylesheetbrowser LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/stylesheetbrowser")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
-
-qt_add_executable(stylesheetbrowser
- main.cpp
- mainwindow.cpp mainwindow.h mainwindow.ui
- stylesheetdialog.cpp stylesheetdialog.h stylesheetdialog.ui
-)
-set_target_properties(stylesheetbrowser PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(stylesheetbrowser PUBLIC
- Qt::Core
- Qt::Gui
- Qt::WebEngineWidgets
-)
-
-
-# Resources:
-set(stylesheetbrowser_resource_files
- "3rdparty/view-refresh.png"
-)
-
-qt6_add_resources(stylesheetbrowser "stylesheetbrowser"
- PREFIX
- "/"
- BASE
- "3rdparty"
- FILES
- ${stylesheetbrowser_resource_files}
-)
-
-install(TARGETS stylesheetbrowser
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png b/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png
deleted file mode 100644
index 32c7c43ed..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/doc/images/stylesheetbrowser.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc b/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc
deleted file mode 100644
index 5b271bafb..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/doc/src/stylesheetbrowser.qdoc
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example webenginewidgets/stylesheetbrowser
- \title WebEngine StyleSheet Browser Example
- \ingroup webengine-widgetexamples
- \brief Demonstrates how to inject CSS into web pages using user scripts.
-
- \image stylesheetbrowser.png
-
- \e {StyleSheet Browser} demonstrates how to use the \l{Qt WebEngine Widgets C++ Classes}
- {Qt WebEngine C++ classes} to inject user stylesheets into web pages.
-
- \include examples-run.qdocinc
-
- \section1 Working With Stylesheets
-
- We use JavaScript to create and append CSS elements to the documents.
- After declaring the script source, QWebEnginePage::runJavaScript() can run it
- immediately and apply newly created styles on the current content of the web view.
- Encapsulating the script into a QWebEngineScript and adding it to the script collection
- of QWebEnginePage makes its effect permanent.
-
- \quotefromfile webenginewidgets/stylesheetbrowser/mainwindow.cpp
- \skipto MainWindow::insertStyleSheet
- \printuntil /^\}/
-
- Removing stylesheets can be done similarly:
-
- \quotefromfile webenginewidgets/stylesheetbrowser/mainwindow.cpp
- \skipto MainWindow::removeStyleSheet
- \printuntil /^\}/
-
- \section1 Files and Attributions
-
- The example uses icons from the Tango Icon Library:
-
- \table
- \row
- \li \l{stylesheetbrowser-tango}{Tango Icon Library}
- \li Public Domain
- \endtable
-*/
diff --git a/examples/webenginewidgets/stylesheetbrowser/main.cpp b/examples/webenginewidgets/stylesheetbrowser/main.cpp
deleted file mode 100644
index 571fccb11..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/main.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "stylesheetdialog.h"
-#include <QApplication>
-#include <QUrl>
-
-int main(int argc, char *argv[])
-{
- qRegisterMetaType<StyleSheet>("StyleSheet");
-
- QCoreApplication::setOrganizationName("QtExamples");
- QApplication a(argc, argv);
- MainWindow w(QUrl("http://qt.io"));
- w.show();
- return a.exec();
-}
diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp b/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp
deleted file mode 100644
index bdf3c56bf..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/mainwindow.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "mainwindow.h"
-#include "stylesheetdialog.h"
-#include "ui_mainwindow.h"
-
-static QMap<QString, QString> defaultStyleSheets = {
- {"Upside down", "body { -webkit-transform: rotate(180deg); }"}
-};
-
-MainWindow::MainWindow(const QUrl &url) :
- QMainWindow(),
- ui(new Ui::MainWindow)
-{
- ui->setupUi(this);
-
- connect(ui->urlBar, &QLineEdit::returnPressed, this, &MainWindow::urlEntered);
- connect(ui->webEngineView, &QWebEngineView::urlChanged, this, &MainWindow::urlChanged);
- connect(ui->settingsButton, &QPushButton::clicked, this, &MainWindow::showStyleSheetsDialog);
- connect(ui->reloadButton, &QPushButton::clicked, this, &MainWindow::reloadRequested);
-
- QSettings settings;
- settings.beginGroup("styleSheets");
- QStringList styleSheets = settings.allKeys();
- if (styleSheets.empty()) {
- // Add back default style sheets if the user cleared them out
- loadDefaultStyleSheets();
- } else {
- for (auto name : qAsConst(styleSheets)) {
- StyleSheet styleSheet = settings.value(name).value<StyleSheet>();
- if (styleSheet.second)
- insertStyleSheet(name, styleSheet.first, false);
- }
- }
- settings.endGroup();
-
- ui->webEngineView->setUrl(url);
-}
-
-MainWindow::~MainWindow()
-{
- delete ui;
-}
-
-void MainWindow::insertStyleSheet(const QString &name, const QString &source, bool immediately)
-{
- QWebEngineScript script;
- QString s = QString::fromLatin1("(function() {"\
- " css = document.createElement('style');"\
- " css.type = 'text/css';"\
- " css.id = '%1';"\
- " document.head.appendChild(css);"\
- " css.innerText = '%2';"\
- "})()").arg(name).arg(source.simplified());
- if (immediately)
- ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld);
-
- script.setName(name);
- script.setSourceCode(s);
- script.setInjectionPoint(QWebEngineScript::DocumentReady);
- script.setRunsOnSubFrames(true);
- script.setWorldId(QWebEngineScript::ApplicationWorld);
- ui->webEngineView->page()->scripts().insert(script);
-}
-
-void MainWindow::removeStyleSheet(const QString &name, bool immediately)
-{
- QString s = QString::fromLatin1("(function() {"\
- " var element = document.getElementById('%1');"\
- " element.outerHTML = '';"\
- " delete element;"\
- "})()").arg(name);
- if (immediately)
- ui->webEngineView->page()->runJavaScript(s, QWebEngineScript::ApplicationWorld);
-
- const QList<QWebEngineScript> scripts = ui->webEngineView->page()->scripts().find(name);
- if (!scripts.isEmpty())
- ui->webEngineView->page()->scripts().remove(scripts.first());
-}
-
-bool MainWindow::hasStyleSheet(const QString &name)
-{
- const QList<QWebEngineScript> scripts = ui->webEngineView->page()->scripts().find(name);
- return !scripts.isEmpty();
-}
-
-void MainWindow::loadDefaultStyleSheets()
-{
- QSettings settings;
- settings.beginGroup("styleSheets");
-
- auto it = defaultStyleSheets.constBegin();
- while (it != defaultStyleSheets.constEnd()) {
- settings.setValue(it.key(), QVariant::fromValue(qMakePair(it.value(), true)));
- insertStyleSheet(it.key(), it.value(), false);
- ++it;
- }
-
- settings.endGroup();
-}
-
-void MainWindow::urlEntered()
-{
- ui->webEngineView->setUrl(QUrl::fromUserInput(ui->urlBar->text()));
-}
-
-void MainWindow::urlChanged(const QUrl &url)
-{
- ui->urlBar->setText(url.toString());
-}
-
-void MainWindow::showStyleSheetsDialog()
-{
- StylesheetDialog *dialog = new StylesheetDialog(this);
- dialog->show();
-}
-
-void MainWindow::reloadRequested()
-{
- ui->webEngineView->reload();
-}
diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.h b/examples/webenginewidgets/stylesheetbrowser/mainwindow.h
deleted file mode 100644
index c39735af8..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/mainwindow.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QSettings>
-#include <QWebEngineScriptCollection>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class MainWindow;
-}
-QT_END_NAMESPACE
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-
-public:
- explicit MainWindow(const QUrl &url);
- ~MainWindow();
-
- void insertStyleSheet(const QString &name, const QString &source, bool immediately);
- void removeStyleSheet(const QString &name, bool immediately);
- bool hasStyleSheet(const QString &name);
- void loadDefaultStyleSheets();
-
-private slots:
- void urlEntered();
- void urlChanged(const QUrl &url);
- void showStyleSheetsDialog();
- void reloadRequested();
-
-private:
- Ui::MainWindow *ui;
-};
-
-#endif // MAINWINDOW_H
diff --git a/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui b/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui
deleted file mode 100644
index bc68c16bb..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/mainwindow.ui
+++ /dev/null
@@ -1,133 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>713</width>
- <height>455</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>StyleSheet Browser</string>
- </property>
- <property name="unifiedTitleAndToolBarOnMac">
- <bool>false</bool>
- </property>
- <widget class="QWidget" name="centralWidget">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QWidget" name="webContentsWidget" native="true">
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QWidget" name="urlBarWidget" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLineEdit" name="urlBar"/>
- </item>
- <item>
- <widget class="QPushButton" name="reloadButton">
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="stylesheetbrowser.qrc">
- <normaloff>:/view-refresh.png</normaloff>:/view-refresh.png</iconset>
- </property>
- <property name="shortcut">
- <string>Ctrl+R</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="settingsButton">
- <property name="text">
- <string>Settings</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QWebEngineView" name="webEngineView" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="url" stdset="0">
- <url>
- <string>about:blank</string>
- </url>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QMenuBar" name="menuBar">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>713</width>
- <height>20</height>
- </rect>
- </property>
- </widget>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
- <customwidget>
- <class>QWebEngineView</class>
- <extends>QWidget</extends>
- <header location="global">QtWebEngineWidgets/QWebEngineView</header>
- </customwidget>
- </customwidgets>
- <resources>
- <include location="stylesheetbrowser.qrc"/>
- </resources>
- <connections/>
-</ui>
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc b/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc
deleted file mode 100644
index a1cebd6a7..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/stylesheetbrowser.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file alias="view-refresh.png">3rdparty/view-refresh.png</file>
- </qresource>
-</RCC>
diff --git a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h b/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h
deleted file mode 100644
index 3bf3219ca..000000000
--- a/examples/webenginewidgets/stylesheetbrowser/stylesheetdialog.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef STYLESHEETDIALOG_H
-#define STYLESHEETDIALOG_H
-
-#include <QDialog>
-#include <QListWidgetItem>
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
-class StylesheetDialog;
-}
-QT_END_NAMESPACE
-
-typedef QPair<QString, bool> StyleSheet; // <source, isEnabled>
-Q_DECLARE_METATYPE(StyleSheet);
-
-class StylesheetDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit StylesheetDialog(QWidget *parent = 0);
- ~StylesheetDialog();
-
-private slots:
- void currentStyleSheetChanged(QListWidgetItem *current, QListWidgetItem *previous);
- void listItemClicked(QListWidgetItem *item);
- void fileNameChanged(const QString &text);
-
- void addButtonClicked();
- void removeButtonClicked();
-
-private:
- Ui::StylesheetDialog *ui;
-};
-
-#endif // STYLESHEETDIALOG_H
diff --git a/examples/webenginewidgets/videoplayer/CMakeLists.txt b/examples/webenginewidgets/videoplayer/CMakeLists.txt
index f6db97149..0aff069d7 100644
--- a/examples/webenginewidgets/videoplayer/CMakeLists.txt
+++ b/examples/webenginewidgets/videoplayer/CMakeLists.txt
@@ -1,21 +1,18 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
cmake_minimum_required(VERSION 3.16)
project(videoplayer LANGUAGES CXX)
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
+ set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/videoplayer")
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui WebEngineWidgets)
qt_add_executable(videoplayer
fullscreennotification.cpp fullscreennotification.h
@@ -23,23 +20,24 @@ qt_add_executable(videoplayer
main.cpp
mainwindow.cpp mainwindow.h
)
+
set_target_properties(videoplayer PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
+
target_link_libraries(videoplayer PUBLIC
Qt::Core
Qt::Gui
Qt::WebEngineWidgets
)
-
# Resources:
set(videoplayer_resource_files
"data/index.html"
)
-qt6_add_resources(videoplayer "videoplayer"
+qt_add_resources(videoplayer "videoplayer"
PREFIX
"/"
BASE
diff --git a/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
index 256a69baf..931f08558 100644
--- a/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
+++ b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
@@ -1,32 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example webenginewidgets/videoplayer
+ \examplecategory {Web Technologies}
\title WebEngine Widgets Video Player Example
\ingroup webengine-widgetexamples
\brief Displays full screen video using \l QWebEngineView.
diff --git a/examples/webenginewidgets/videoplayer/fullscreennotification.cpp b/examples/webenginewidgets/videoplayer/fullscreennotification.cpp
index dbbf4660d..effd85ded 100644
--- a/examples/webenginewidgets/videoplayer/fullscreennotification.cpp
+++ b/examples/webenginewidgets/videoplayer/fullscreennotification.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "fullscreennotification.h"
diff --git a/examples/webenginewidgets/videoplayer/fullscreennotification.h b/examples/webenginewidgets/videoplayer/fullscreennotification.h
index 31fa0b59d..eebe3b85d 100644
--- a/examples/webenginewidgets/videoplayer/fullscreennotification.h
+++ b/examples/webenginewidgets/videoplayer/fullscreennotification.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FULLSCREENNOTIFICATION_H
#define FULLSCREENNOTIFICATION_H
diff --git a/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp b/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp
index fbc899d83..fe2e72d86 100644
--- a/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp
+++ b/examples/webenginewidgets/videoplayer/fullscreenwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "fullscreenwindow.h"
diff --git a/examples/webenginewidgets/videoplayer/fullscreenwindow.h b/examples/webenginewidgets/videoplayer/fullscreenwindow.h
index a5d53bcd8..d7af0b655 100644
--- a/examples/webenginewidgets/videoplayer/fullscreenwindow.h
+++ b/examples/webenginewidgets/videoplayer/fullscreenwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef FULLSCREENWINDOW_H
#define FULLSCREENWINDOW_H
diff --git a/examples/webenginewidgets/videoplayer/main.cpp b/examples/webenginewidgets/videoplayer/main.cpp
index 4a0fedb7b..550546130 100644
--- a/examples/webenginewidgets/videoplayer/main.cpp
+++ b/examples/webenginewidgets/videoplayer/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
#include <QApplication>
diff --git a/examples/webenginewidgets/videoplayer/mainwindow.cpp b/examples/webenginewidgets/videoplayer/mainwindow.cpp
index e930041a8..7de2446f1 100644
--- a/examples/webenginewidgets/videoplayer/mainwindow.cpp
+++ b/examples/webenginewidgets/videoplayer/mainwindow.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mainwindow.h"
diff --git a/examples/webenginewidgets/videoplayer/mainwindow.h b/examples/webenginewidgets/videoplayer/mainwindow.h
index cdbe5d98e..3138800b5 100644
--- a/examples/webenginewidgets/videoplayer/mainwindow.h
+++ b/examples/webenginewidgets/videoplayer/mainwindow.h
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
diff --git a/examples/webenginewidgets/webenginewidgets.pro b/examples/webenginewidgets/webenginewidgets.pro
index f783fc681..2a24686cf 100644
--- a/examples/webenginewidgets/webenginewidgets.pro
+++ b/examples/webenginewidgets/webenginewidgets.pro
@@ -1,27 +1,26 @@
-QT_FOR_CONFIG += webenginecore webenginecore-private
+QT_FOR_CONFIG += webenginecore webenginecore-private network-private
TEMPLATE=subdirs
SUBDIRS += \
- minimal \
contentmanipulation \
cookiebrowser \
notifications \
simplebrowser \
- stylesheetbrowser \
- videoplayer \
- webui
+ push-notifications \
+ videoplayer
qtConfig(webengine-geolocation): SUBDIRS += maps
-qtConfig(webengine-webchannel): SUBDIRS += markdowneditor
+qtConfig(webengine-webchannel): SUBDIRS += recipebrowser
qtConfig(webengine-printing-and-pdf) {
SUBDIRS += printme html2pdf
}
-#qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
-# SUBDIRS += spellchecker
-#} else {
-# message("Spellcheck example will not be built because it depends on usage of Hunspell dictionaries.")
-#}
+qtConfig(webengine-spellchecker):!qtConfig(webengine-native-spellchecker):!cross_compile {
+ SUBDIRS += spellchecker
+} else {
+ message("Spellchecker example will not be built because it depends on usage of Hunspell dictionaries.")
+}
+qtConfig(ssl): SUBDIRS += clientcertificate
diff --git a/examples/webenginewidgets/webui/CMakeLists.txt b/examples/webenginewidgets/webui/CMakeLists.txt
deleted file mode 100644
index b4a6683c8..000000000
--- a/examples/webenginewidgets/webui/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-cmake_minimum_required(VERSION 3.16)
-project(webui LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/webenginewidgets/webui")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS WebEngineWidgets)
-
-qt_add_executable(webui
- main.cpp
- webuihandler.cpp webuihandler.h
-)
-set_target_properties(webui PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-target_link_libraries(webui PUBLIC
- Qt::Core
- Qt::Gui
- Qt::WebEngineWidgets
-)
-
-
-# Resources:
-set(webui_resource_files
- "about.html"
-)
-
-qt6_add_resources(webui "webui"
- PREFIX
- "/"
- FILES
- ${webui_resource_files}
-)
-
-install(TARGETS webui
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/webenginewidgets/webui/about.html b/examples/webenginewidgets/webui/about.html
deleted file mode 100644
index 7b5a58969..000000000
--- a/examples/webenginewidgets/webui/about.html
+++ /dev/null
@@ -1,129 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <title>Qt WebEngine WebUI Example</title>
- <style>
- html {
- background: #f0f0f0;
- color: #303030;
- font: 16px system-ui;
- height: 100%;
- }
-
- body {
- margin: 0;
- padding: 0;
- height: 100%;
- display: flex;
- flex-direction: column;
- align-items: stretch;
- }
-
- body > * {
- padding-left: 20px;
- padding-right: 20px;
- }
-
- header {
- flex: none;
- display: flex;
- align-items: center;
- background: #f0fff0;
- border-bottom: 1px solid #e0e0e0;
- padding-top: 20px;
- padding-bottom: 20px;
- }
-
- header > h1 {
- font: bold 20px system-ui;
- margin-left: 18px;
- }
-
- main {
- flex: auto;
- }
-
- footer {
- flex: none;
- display: flex;
- justify-content: center;
- padding-bottom: 20px;
- }
-
- button {
- background: #41cd52;
- color: #f0f0f0;
- font: 16px system-ui;
- border: 0;
- box-shadow: 0px 1px 3px rgb(0,0,0,0.5);
- cursor: pointer;
- margin: 0 0 1px;
- padding: 10px 24px;
- }
-
- button:hover {
- background: #50dc61;
- }
-
- button:active {
- background: #50dc61;
- box-shadow: 0px 1px 2px rgb(0,0,0,0.5);
- margin: 1px 0 0;
- }
-
- button:focus {
- outline: 0;
- }
-
- </style>
- </head>
- <body>
- <header>
- <img width="48px" height="48px"
- src="qrc:/qt-project.org/qmessagebox/images/qtlogo-64.png">
- <h1>WebEngine Widgets<br>WebUI Example</h1>
- </header>
- <main>
- <p>
- Aside from the built-in schemes, such as <code>http</code> and
- <code>qrc</code>, Qt WebEngine may be extended with <em>custom
- schemes</em> by creating <em>custom scheme handlers</em>.
- </p>
-
- <p>
- This is a simple HTML page loaded from a custom scheme and
- displayed by a <code>QWebEngineView</code>. Even the Quit button
- below is a standard HTML <code>&lt;button&gt;</code> element.
- </p>
-
- <p>
- Read the documentation to find out
- </p>
- <ul>
- <li>
- <p>
- How to create a custom scheme handler which serves HTML
- and handles HTML form submissions.
- </p>
- </li>
- <li>
- <p>
- How to prevent ordinary web content from accessing the
- custom scheme.
- </p>
- </li>
- <li>
- <p>
- How to prevent any other scheme from submitting HTML
- form data.
- </p>
- </li>
- </ul>
- </main>
- <footer>
- <form action="" method="post">
- <button name="quit">Quit</button>
- </form>
- </footer>
- </body>
-</html>
diff --git a/examples/webenginewidgets/webui/doc/images/webui-example.png b/examples/webenginewidgets/webui/doc/images/webui-example.png
deleted file mode 100644
index 84e2c7fc3..000000000
--- a/examples/webenginewidgets/webui/doc/images/webui-example.png
+++ /dev/null
Binary files differ
diff --git a/examples/webenginewidgets/webui/doc/src/webui.qdoc b/examples/webenginewidgets/webui/doc/src/webui.qdoc
deleted file mode 100644
index 949b358a7..000000000
--- a/examples/webenginewidgets/webui/doc/src/webui.qdoc
+++ /dev/null
@@ -1,165 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \example webenginewidgets/webui
- \title WebEngine Widgets WebUI Example
- \ingroup webengine-widgetexamples
- \brief Displays HTML over a custom scheme.
-
- \image webui-example.png
-
- \e {WebUI} demonstrates how to implement a custom scheme in a secure way.
-
- Aside from the built-in URL schemes, such as \c {http} and \c {qrc},
- \QWE may be extended with \e {custom schemes} by creating \e {custom
- scheme handlers}. This example shows:
-
- \list
- \li How to create a custom scheme handler which serves HTML and handles
- HTML form submissions.
- \li How to prevent ordinary web content from accessing the custom scheme.
- \li How to prevent any other scheme from submitting HTML form data.
- \endlist
-
- \include examples-run.qdocinc
-
- \section1 Overview
-
- The example program consists of a single \l {QWebEngineView} showing a
- simple HTML page loaded from the URL \c {webui:about}, over our custom
- scheme. Pressing the button at the bottom of the page will trigger an HTML
- form submission via POST to the same URL, at which point our custom scheme
- handler will cause the application to exit.
-
- The program is divided into two parts, the \c {main} function for setting
- everything up, and the \c {WebUiHandler} class for implementing our custom
- scheme handler. The \c {main} function is quite short:
-
- \quotefromfile webenginewidgets/webui/main.cpp
- \skipto int main
- \printuntil /^\}/
-
- Aside from the relatively standard setup of widgets, two points are
- noteworthy. First, we call the static method \c
- {WebUiHandler::registerUrlScheme()} to register our custom scheme with the
- web engine. Second, we create and install our custom scheme handler \c
- {WebUiHandler} using \l
- {QWebEngineProfile::installUrlSchemeHandler()}{installUrlSchemeHandler()}.
- The following sections describe these aspects in more detail.
-
- \section1 Registering the Scheme
-
- As custom schemes are integrated directly into the web engine, they do not
- necessarily need to follow the standard security rules which apply to
- ordinary web content. Depending on the chosen configuration, content served
- over a custom scheme may be given access to local resources, be set to
- ignore Content-Security-Policy rules, or conversely, be denied access to any
- other content entirely.
-
- In order to take advantage of these possibilities, the custom scheme must
- first be registered. This means creating and configuring a \l
- {QWebEngineUrlScheme} object and then handing it over to \l
- {QWebEngineUrlScheme::registerScheme()}. The example program does exactly this in
- the static method \c {WebUiHandler::registerUrlScheme()}:
-
- \quotefromfile webenginewidgets/webui/webuihandler.cpp
- \skipto void WebUiHandler::registerUrlScheme
- \printuntil /^\}/
-
- A custom scheme needs a name, which can be set by passing it to
- the constructor of \c {QWebEngineUrlScheme} or by calling \l
- {QWebEngineUrlScheme::setName}. In the above, the name \c {webui} is set
- through the constructor. Additionally, we activate the flags \l
- {QWebEngineUrlScheme::SecureScheme}{SecureScheme}, \l
- {QWebEngineUrlScheme::LocalScheme}{LocalScheme} and \l
- {QWebEngineUrlScheme::LocalAccessAllowed}{LocalAccessAllowed}. Since our
- custom scheme handler will not deliver resources received from insecure
- network connections, we can safely mark it as a \c {SecureScheme}. The \c {LocalScheme}
- flag prevents content from non-local schemes (such as \c {http}) from
- interacting with our custom scheme. Without this flag it would be possible,
- for example, to embed the \c {webui:about} page in an \c <iframe> element on
- a remotely loaded HTML page, perhaps to attempt a phishing attack. We also
- need the \c {LocalAccessAllowed} flag without which we would not be able to
- access the \c {webui} scheme from our \c {webui:about} page.
-
- Earlier we saw that the call to \c {WebUiHandler::registerUrlScheme()} is
- made already at the top of the \c {main} function. This is so because custom
- schemes need to be registered as early as possible so that that they can be
- passed to all subprocesses. Specifically, custom schemes need to be registered
- before any other \QWE classes are instantiated by the application.
-
- \section1 Handling Requests
-
- A custom scheme handler is, broadly speaking, similar to a web application
- served over HTTP. However, because custom schemes are integrated directly
- into the web engine, they have the advantage in terms of efficiency: there's
- no need for generating and parsing HTTP messages or for transferring data
- over sockets.
-
- Implementing a handler means creating a subclass of \l
- {QWebEngineUrlSchemeHandler}, which is just what is done by the \c
- {WebUiHandler} class of the example program:
-
- \quotefromfile webenginewidgets/webui/webuihandler.h
- \skipto class WebUiHandler
- \printuntil /^\}/
-
- For each request to a \c {webui} URL, the \c
- {WebUiHandler::requestStarted()} method will be called:
-
- \quotefromfile webenginewidgets/webui/webuihandler.cpp
- \skipto void WebUiHandler::requestStarted
- \printuntil /^\}/
-
- The \l {QWebEngineUrlRequestJob} object \c {job} contains the request's
- attributes and provides methods for replying to the request with a response.
- Responses are generated asynchronously by reading them from the \l
- {QIODevice} that the application passes to \l
- {QWebEngineUrlRequestJob::reply()}{reply()}.
-
- \warning The \c requestStarted() method is not called from the main thread,
- but from the web engine's IO thread. Care must be taken to synchronize
- access to any resources on the main thread.
-
- Aside from the usual fare of \l
- {QWebEngineUrlRequestJob::requestMethod()}{requestMethod} and \l
- {QWebEngineUrlRequestJob::requestUrl()}{requestUrl}, there is also the \l
- {QWebEngineUrlRequestJob::initiator()}{initiator}, holding the origin of the
- content which initiated the request. An empty \c initiator means the request
- was initiated directly by the application (via \l
- {QWebEnginePage::setUrl()}, for example). The special value \c "null"
- corresponds to an opaque origin (a sandboxed \c {<iframe>} element, for
- example). Otherwise, the \c initiator will contain the URL scheme, hostname,
- and port of the content which initiated the request.
-
- In this example, the \c initiator is used to ensure that \c {POST} requests
- to \c {webui:about} will only trigger the application's exit if they
- originate from the \c {webui} scheme. This prevents content loaded over
- other schemes from triggering the application's exit.
-
-*/
diff --git a/examples/webenginewidgets/webui/main.cpp b/examples/webenginewidgets/webui/main.cpp
deleted file mode 100644
index 92c1b8e7d..000000000
--- a/examples/webenginewidgets/webui/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "webuihandler.h"
-
-#include <QApplication>
-#include <QWebEnginePage>
-#include <QWebEngineProfile>
-#include <QWebEngineView>
-
-int main(int argc, char *argv[])
-{
- QCoreApplication::setOrganizationName("QtExamples");
-
- WebUiHandler::registerUrlScheme();
-
- QApplication app(argc, argv);
-
- QWebEngineProfile profile;
-
- WebUiHandler handler;
- profile.installUrlSchemeHandler(WebUiHandler::schemeName, &handler);
-
- QWebEnginePage page(&profile);
- page.load(WebUiHandler::aboutUrl);
-
- QWebEngineView view;
- view.setPage(&page);
- view.setContextMenuPolicy(Qt::NoContextMenu);
- view.resize(500, 600);
- view.show();
-
- return app.exec();
-}
diff --git a/examples/webenginewidgets/webui/webui.pro b/examples/webenginewidgets/webui/webui.pro
deleted file mode 100644
index 714833587..000000000
--- a/examples/webenginewidgets/webui/webui.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-
-QT += webenginewidgets
-
-HEADERS += \
- webuihandler.h
-
-SOURCES += \
- main.cpp \
- webuihandler.cpp
-
-RESOURCES += \
- webui.qrc
-
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/webui
-INSTALLS += target
diff --git a/examples/webenginewidgets/webui/webuihandler.cpp b/examples/webenginewidgets/webui/webuihandler.cpp
deleted file mode 100644
index 63c249368..000000000
--- a/examples/webenginewidgets/webui/webuihandler.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "webuihandler.h"
-
-#include <QApplication>
-#include <QFile>
-#include <QWebEngineUrlRequestJob>
-#include <QWebEngineUrlScheme>
-
-#define SCHEMENAME "webui"
-
-const QByteArray WebUiHandler::schemeName = QByteArrayLiteral(SCHEMENAME);
-const QUrl WebUiHandler::aboutUrl = QUrl(QStringLiteral(SCHEMENAME ":about"));
-
-WebUiHandler::WebUiHandler(QObject *parent)
- : QWebEngineUrlSchemeHandler(parent)
-{
-}
-
-void WebUiHandler::requestStarted(QWebEngineUrlRequestJob *job)
-{
- static const QUrl webUiOrigin(QStringLiteral(SCHEMENAME ":"));
- static const QByteArray GET(QByteArrayLiteral("GET"));
- static const QByteArray POST(QByteArrayLiteral("POST"));
-
- QByteArray method = job->requestMethod();
- QUrl url = job->requestUrl();
- QUrl initiator = job->initiator();
-
- if (method == GET && url == aboutUrl) {
- QFile *file = new QFile(QStringLiteral(":/about.html"), job);
- file->open(QIODevice::ReadOnly);
- job->reply(QByteArrayLiteral("text/html"), file);
- } else if (method == POST && url == aboutUrl && initiator == webUiOrigin) {
- job->fail(QWebEngineUrlRequestJob::RequestAborted);
- QApplication::exit();
- } else {
- job->fail(QWebEngineUrlRequestJob::UrlNotFound);
- }
-}
-
-// static
-void WebUiHandler::registerUrlScheme()
-{
- QWebEngineUrlScheme webUiScheme(schemeName);
- webUiScheme.setFlags(QWebEngineUrlScheme::SecureScheme |
- QWebEngineUrlScheme::LocalScheme |
- QWebEngineUrlScheme::LocalAccessAllowed);
- QWebEngineUrlScheme::registerScheme(webUiScheme);
-}
diff --git a/examples/webenginewidgets/webui/webuihandler.h b/examples/webenginewidgets/webui/webuihandler.h
deleted file mode 100644
index f2ac0dcef..000000000
--- a/examples/webenginewidgets/webui/webuihandler.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * 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.
-** * Neither the name of The Qt Company Ltd 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
-** OWNER 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."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WEBUIHANDLER_H
-#define WEBUIHANDLER_H
-
-#include <QWebEngineUrlSchemeHandler>
-
-class WebUiHandler : public QWebEngineUrlSchemeHandler
-{
- Q_OBJECT
-public:
- explicit WebUiHandler(QObject *parent = nullptr);
-
- void requestStarted(QWebEngineUrlRequestJob *job) override;
-
- static void registerUrlScheme();
-
- const static QByteArray schemeName;
- const static QUrl aboutUrl;
-};
-
-#endif // !WEBUIHANDLER_H