aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-10-07 14:40:40 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-10-08 14:01:32 +0200
commit5b5d85509cc62f3fc4929a3eba47a2653f04cafa (patch)
treeb6288a1b006bfd4136d3b6cc1cb4911608030207 /sources/pyside6/PySide6
parent072bbd5e641f0f45654d738690203c07a9b959b8 (diff)
PySide6: Add QWebEngineFrame
QWebEngineFrame is used like a value type (stored in QList, etc), but does not have a default-constructor. Hack around by by adding a function returning a default-constructed instance using a struct with the same data members. Task-number: PYSIDE-2620 Pick-to: 6.8 Change-Id: Id792a47fa9cc3f3c55eb1e52c06d01e03a104a74 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6')
-rw-r--r--sources/pyside6/PySide6/QtWebEngineCore/CMakeLists.txt3
-rw-r--r--sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.cpp26
-rw-r--r--sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.h17
-rw-r--r--sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml39
-rw-r--r--sources/pyside6/PySide6/doc/qtwebenginecore.rst15
-rw-r--r--sources/pyside6/PySide6/glue/qtwebenginecore.cpp17
6 files changed, 117 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtWebEngineCore/CMakeLists.txt b/sources/pyside6/PySide6/QtWebEngineCore/CMakeLists.txt
index 374b0b54d..ec649b249 100644
--- a/sources/pyside6/PySide6/QtWebEngineCore/CMakeLists.txt
+++ b/sources/pyside6/PySide6/QtWebEngineCore/CMakeLists.txt
@@ -6,6 +6,8 @@ project(QtWebEngineCore)
set(QtWebEngineCore_static_sources
"${QtWebEngineCore_SOURCE_DIR}/glue/webenginepage_functors.cpp"
"${QtWebEngineCore_SOURCE_DIR}/glue/webenginepage_functors.h"
+ "${QtWebEngineCore_SOURCE_DIR}/glue/webengineframe.cpp"
+ "${QtWebEngineCore_SOURCE_DIR}/glue/webengineframe.h"
)
set(QtWebEngineCore_SRC
@@ -20,6 +22,7 @@ ${QtWebEngineCore_GEN_DIR}/qwebenginecookiestore_filterrequest_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebenginedownloadrequest_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebenginefilesystemaccessrequest_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebenginefindtextresult_wrapper.cpp
+${QtWebEngineCore_GEN_DIR}/qwebengineframe_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebenginefullscreenrequest_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebengineglobalsettings_wrapper.cpp
${QtWebEngineCore_GEN_DIR}/qwebengineglobalsettings_dnsmode_wrapper.cpp
diff --git a/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.cpp b/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.cpp
new file mode 100644
index 000000000..fb209d51b
--- /dev/null
+++ b/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.cpp
@@ -0,0 +1,26 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "webengineframe.h"
+
+#include <QtWebEngineCore/qwebengineframe.h>
+
+QT_BEGIN_NAMESPACE
+
+// Enable using QWebEngineFrame as a value-type by adding a way of
+// default-constructing by creating a replica with the same data members.
+// (see attribute "default-constructor").
+QWebEngineFrame defaultConstructedWebEngineFrame()
+{
+ class FriendlyWebEngineFrame // Keep in sync with QWebEngineFrame
+ {
+ public:
+ QWeakPointer<QObject> m_w;
+ quint64 m_id = 0;
+ };
+
+ FriendlyWebEngineFrame frame;
+ return std::move(*reinterpret_cast<QWebEngineFrame*>(&frame));
+}
+
+QT_END_NAMESPACE
diff --git a/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.h b/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.h
new file mode 100644
index 000000000..a792c7baf
--- /dev/null
+++ b/sources/pyside6/PySide6/QtWebEngineCore/glue/webengineframe.h
@@ -0,0 +1,17 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef WEBENGINEFRAME_H
+#define WEBENGINEFRAME_H
+
+#include <QtCore/QtClassHelperMacros>
+
+QT_FORWARD_DECLARE_CLASS(QWebEngineFrame)
+
+QT_BEGIN_NAMESPACE
+
+QWebEngineFrame defaultConstructedWebEngineFrame();
+
+QT_END_NAMESPACE
+
+#endif // WEBENGINEFRAME_H
diff --git a/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml b/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
index 54bf222b9..ed00c2b62 100644
--- a/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
+++ b/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
@@ -11,6 +11,10 @@
<load-typesystem name="QtPrintSupport/typesystem_printsupport.xml" generate="no"/>
<load-typesystem name="QtWebChannel/typesystem_webchannel.xml" generate="no"/>
+ <extra-includes>
+ <include file-name="glue/webengineframe.h" location="global"/>
+ </extra-includes>
+
<rejection class="extensions"/>
<function signature="qWebEngineChromiumVersion()"/>
@@ -55,6 +59,35 @@
<modify-function signature="swap(QWebEngineFileSystemAccessRequest&amp;)" remove="all"/>
</value-type>
+ <value-type name="QWebEngineFrame" default-constructor="defaultConstructedWebEngineFrame()"
+ since="6.8">
+ <extra-includes>
+ <include file-name="glue/webenginepage_functors.h" location="global"/>
+ <include file-name="glue/webengineframe.h" location="global"/>
+ </extra-includes>
+ <modify-function signature="^runJavaScript\(.*\)$" remove="yes"/>
+ <add-function signature="runJavaScript(const QString &amp;@scriptSource@,PyCallable*@resultCallback@)">
+ <inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebenginepage-runjavascript-2"/>
+ </add-function>
+ <add-function signature="runJavaScript(const QString &amp;@scriptSource@,quint32@worldId@,PyCallable*@resultCallback@={})">
+ <inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebenginepage-runjavascript-3"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtwebenginecore.rst"
+ snippet="qwebenginepage-runjavascript"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtwebenginecore.rst"
+ snippet="qwebenginepage-async-note"/>
+ </add-function>
+ <add-function signature="printToPdf(PyCallable*@resultCallback@)">
+ <inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebengineframe-printtopdf"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtwebenginecore.rst"
+ snippet="qwebengineframe-printtopdf"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtwebenginecore.rst"
+ snippet="qwebenginepage-async-note"/>
+ </add-function>
+ </value-type>
+
<value-type name="QWebEngineFullScreenRequest"/>
<object-type name="QWebEngineHistory"/>
@@ -97,6 +130,12 @@
<inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
snippet="qwebenginepage-javascriptprompt-return"/>
</modify-function>
+ <add-function signature="findFrameByName(QString@name@)" return-type="QWebEngineFrame">
+ <inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebenginepage-findframebyname"/>
+ <inject-documentation format="target" mode="append" file="../doc/qtwebenginecore.rst"
+ snippet="qwebenginepage-findframebyname"/>
+ </add-function>
<add-function signature="findText(const QString &amp;@subString@,QWebEnginePage::FindFlags@options@,PyCallable*@resultCallback@)">
<inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
snippet="qwebenginepage-findtext"/>
diff --git a/sources/pyside6/PySide6/doc/qtwebenginecore.rst b/sources/pyside6/PySide6/doc/qtwebenginecore.rst
index a3741dbf8..75e2e32d4 100644
--- a/sources/pyside6/PySide6/doc/qtwebenginecore.rst
+++ b/sources/pyside6/PySide6/doc/qtwebenginecore.rst
@@ -58,3 +58,18 @@ values specified in ``layout``, while the range of pages printed is taken from
.. note:: The ``QWebEnginePage.WebAction.Stop`` web action can be used to
interrupt this operation.
// @snippet qwebenginepage-printtopdf
+
+// @snippet qwebenginepage-findframebyname
+Returns the frame with the given ``name``. If there are multiple frames with
+the same name, which one is returned is arbitrary. If no frame was found,
+returns ``None``.
+// @snippet qwebenginepage-findframebyname
+
+// @snippet qwebengineframe-printtopdf
+Renders the current content of the frame into a PDF document and returns a byte
+array containing the PDF data as parameter to ``resultCallback``. Printing uses
+a page size of A4, portrait layout, and includes the full range of pages.
+
+.. note:: The ``QWebEnginePage.WebAction.Stop`` web action can be used to
+ interrupt this operation.
+// @snippet qwebengineframe-printtopdf
diff --git a/sources/pyside6/PySide6/glue/qtwebenginecore.cpp b/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
index 36b3b5cbc..9ce620bff 100644
--- a/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
+++ b/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
@@ -140,3 +140,20 @@ using PrintToPdfCallback = std::function<void(const QByteArray &)>;
%CPPSELF.%FUNCTION_NAME(PrintToPdfCallback(PrintToPdfFunctor(%PYARG_1)), %2, %3);
// @snippet qwebenginepage-printtopdf
+
+// @snippet qwebenginepage-findframebyname
+auto frameOptional = %CPPSELF.%FUNCTION_NAME(%1);
+if (frameOptional.has_value()) {
+ const %RETURN_TYPE &frame = frameOptional.value();
+ %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](frame);
+} else {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+}
+// @snippet qwebenginepage-findframebyname
+
+// @snippet qwebengineframe-printtopdf
+using PrintToPdfCallback = std::function<void(const QByteArray &)>;
+
+%CPPSELF.%FUNCTION_NAME(PrintToPdfCallback(PrintToPdfFunctor(%PYARG_1)));
+// @snippet qwebengineframe-printtopdf