aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-16 10:43:47 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-22 13:17:31 +0200
commitb27e1e5fe85ad7697ebbd571d1097ff656503803 (patch)
tree134649066c17e4f72657ffe7e61a0ec92ebd3b63 /sources/pyside6
parent5b19cf6ab082c6be5f9177925f3e3180ca02ed4c (diff)
shiboken6: Generate Python override code for added virtuals
Introduce "Python override" as a special type of user-added function which will cause a function calling a Python override into the native wrapper. This can then be called from a virtual that has a signature which cannot be handled in Python. Fixes: PYSIDE-2602 Pick-to: 6.7 Change-Id: I5fc44ebe3f585078e87d3230d5e6f4faa67a4ee1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml10
-rw-r--r--sources/pyside6/PySide6/glue/qtwebenginecore.cpp14
2 files changed, 24 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml b/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
index a72cfaefa..ae0cbbbf1 100644
--- a/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
+++ b/sources/pyside6/PySide6/QtWebEngineCore/typesystem_webenginecore.xml
@@ -74,6 +74,16 @@
<enum-type name="FileSelectionMode"/>
<enum-type name="JavaScriptConsoleMessageLevel"/>
<enum-type name="RenderProcessTerminationStatus"/>
+ <add-function signature="javaScriptPromptPyOverride(QUrl@securityOrigin@,QString@msg@,QString@defaultValue@)"
+ return-type="std::pair&lt;bool,QString&gt;" python-override="true"/>
+ <modify-function signature="javaScriptPrompt(QUrl,QString,QString,QString*)">
+ <inject-code class="shell" position="override" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebenginepage-javascriptprompt-virtual-redirect"/>
+ <modify-argument index="return" pyi-type="Tuple[bool, str]"/>
+ <modify-argument index="4"><remove-default-expression/><remove-argument/></modify-argument>
+ <inject-code class="target" position="beginning" file="../glue/qtwebenginecore.cpp"
+ snippet="qwebenginepage-javascriptprompt-return"/>
+ </modify-function>
<add-function signature="findText(const QString &amp;,QWebEnginePage::FindFlags,PyObject*)">
<inject-code class="target" position="beginning" file="../glue/qtwebenginewidgets.cpp" snippet="qwebenginepage-findtext"/>
</add-function>
diff --git a/sources/pyside6/PySide6/glue/qtwebenginecore.cpp b/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
index 50ef554f0..76a7c6d73 100644
--- a/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
+++ b/sources/pyside6/PySide6/glue/qtwebenginecore.cpp
@@ -48,3 +48,17 @@ void QWebEngineNotificationFunctor::operator()
// @snippet qwebengineprofile-setnotificationpresenter
%CPPSELF.%FUNCTION_NAME(QWebEngineNotificationFunctor(%PYARG_1));
// @snippet qwebengineprofile-setnotificationpresenter
+
+// @snippet qwebenginepage-javascriptprompt-virtual-redirect
+std::pair<bool, QString> resultPair = javaScriptPromptPyOverride(gil, pyOverride.object(), securityOrigin, msg, defaultValue);
+result->assign(resultPair.second);
+return resultPair.first;
+// @snippet qwebenginepage-javascriptprompt-virtual-redirect
+
+// @snippet qwebenginepage-javascriptprompt-return
+QString str;
+%RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, &str);
+%PYARG_0 = PyTuple_New(2);
+PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
+PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[QString](str));
+// @snippet qwebenginepage-javascriptprompt-return