aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2023-07-14 15:38:45 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2023-07-25 19:01:43 +0000
commit12ba61a242312edb3fe6a19f9f03f578d55336a5 (patch)
treeaf8eada37caea3336d900f9225765395805e8516 /sources/pyside6/PySide6
parentfde182c043e6366994175390df1e2dea1c65d768 (diff)
Fix stub and signature for QClipboard setPixmap and setImage
Incorrectly, the pyi file described that it was possible to pass a: Union[PySide6.QtGui.QPixmap, PySide6.QtGui.QImage, str] for setPixmap, and: Union[PySide6.QtGui.QImage, str] for setImage. This uses the typesystem entry to restrict the setPixmap to accept a QPixmap and only a QImage for setImage. Additionally, this enable a PyPathLike signature, so users can pass 'str', 'bytes', 'pathlib.Path' as well, so the accepted arguments are: setImage(...) - PySide6.QtGui.QImage - Union[str, bytes, os.PathLike] setPixmap(...): - PySide6.QtGui.QPixmap - Union[str, bytes, os.PathLike] Pick-to: 6.5 Fixes: PYSIDE-2395 Change-Id: I521980dbc781a72e54f49fc84af5349733385133 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6')
-rw-r--r--sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml12
-rw-r--r--sources/pyside6/PySide6/glue/qtgui.cpp10
2 files changed, 22 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
index a2873ea41..5d84c689d 100644
--- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml
@@ -1745,6 +1745,18 @@
<include file-name="QPixmap" location="global"/>
</extra-includes>
<enum-type name="Mode"/>
+ <modify-function signature="setPixmap(const QPixmap&amp;, QClipboard::Mode)">
+ <modify-argument index="1" pyi-type="PySide6.QtGui.QPixmap"/>
+ </modify-function>
+ <add-function signature="setPixmap(PyPathLike@path@)">
+ <inject-code file="../glue/qtgui.cpp" snippet="qclipboard-setpixmap"/>
+ </add-function>
+ <modify-function signature="setImage(const QImage&amp;, QClipboard::Mode)">
+ <modify-argument index="1" pyi-type="PySide6.QtGui.QImage"/>
+ </modify-function>
+ <add-function signature="setImage(PyPathLike@path@)">
+ <inject-code file="../glue/qtgui.cpp" snippet="qclipboard-setimage"/>
+ </add-function>
<modify-function signature="setMimeData(QMimeData*,QClipboard::Mode)" allow-thread="yes">
<modify-argument index="1">
<!-- TODO: maybe this is not the best solution -->
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp
index 38e01f24c..443495389 100644
--- a/sources/pyside6/PySide6/glue/qtgui.cpp
+++ b/sources/pyside6/PySide6/glue/qtgui.cpp
@@ -371,6 +371,16 @@ const auto path = PySide::pyPathToQString(%PYARG_1);
%CPPSELF->addPixmap(path);
// @snippet qicon-addpixmap
+// @snippet qclipboard-setpixmap
+const auto path = PySide::pyPathToQString(%PYARG_1);
+%CPPSELF->setPixmap(QPixmap(path));
+// @snippet qclipboard-setpixmap
+
+// @snippet qclipboard-setimage
+const auto path = PySide::pyPathToQString(%PYARG_1);
+%CPPSELF->setImage(QImage(path));
+// @snippet qclipboard-setimage
+
// @snippet qimage-decref-image-data
static void imageDecrefDataHandler(void *data)
{