aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtgui.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QAction: Add setMenu() and menu()Cristián Maureira-Fredes2022-04-081-0/+6
| | | | | | | | | | | | | | | | | | | | After the changes in Qt6 related to moving QAction completely to QtGui, the 'on-demand' functions associated to QMenu were not properly exposed. This patch manually adds setMenu()/menu() using QObject's. A simple test case was added. [ChangeLog] QAction.setMenu() and QAction.menu() were implemented. Done-with: Friedemann Kleint <Friedemann.Kleint@qt.io> Pick-to: 6.2 Fixes: PYSIDE-1627 Change-Id: Ib8102a9cf513ee2e13ff71751b1167ca0146af31 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add a context manager for override cursorsFriedemann Kleint2022-03-181-0/+6
| | | | | | | | | | [ChangeLog][PySide] A context manager for override cursors has been added. It is now possible to write code like: with QApplication.setOverrideCursor(Qt.WaitCursor):... Change-Id: I443ce82389b48656f21c98df17d97e1b3b3323b5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Port code to use size() instead of count() of Qt containersFriedemann Kleint2022-03-171-1/+1
| | | | | | | | | | | count() will be deprecated. Fix some integer types in loops and modernize code in changed lines. Pick-to: 6.2 Change-Id: Idf21927661ea6c8866ee36e7c623043271e21620 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyPySide: Implement a context manager for QPainterChristian Tismer2022-01-261-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Context managers existed in Python since 2005 (PEP 343). They were invented to support resource management for different Python implementations that cannot rely on immediate object destruction. PyPy is the first alternate Python implementation that can run PySide. QPainter does not work in PyPy without an explicit end() call. For convenience, we supply a context manager that handles this. Like in file I/O, we now prefer instead of painter = QPainter(paintable) the new indented form with QPainter(paintable) as painter: [ChangeLog][PySide6] QPainter has become a context manager. Using a with statement saves the need to call painter.end() . Task-number: PYSIDE-535 Change-Id: Ib8bebbe121dc08334d31c9663a1e5bc8042c3b62 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide6: Add a sequence protocol for QRegionFriedemann Kleint2021-11-191-0/+14
| | | | | | | Pick-to: 6.2 Fixes: PYSIDE-1714 Change-Id: I581e8088e25ab31afdfc6cd5a15c55a5b418ffdc Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix QIcon.addPixmap() to accept a PyPathLike argumentFriedemann Kleint2021-10-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By modifying functions to accept a PyPathLike argument, we saw the side-effect of disabling implicit conversions. In an alternative branch, we tried to re-enable implicit conversion by adding new functions with a PyPathLike argument. This worked, but had drawbacks: * the signatures become redundant, and some post-processing must be implemented * the implicit conversion works fine, but only with a string argument. Much better would be to supply a PyPathLike This patch leaves the modifications of function arguments and simply adds the missing icon.addPixmap(PyPathLike). Other implicit conversions which might be found missing should be added the same way. [ChangeLog][shiboken6] The implicit conversion of icon.addPixmap(str) was replaced by an explicit version which takes PyPathLike. Change-Id: I48a2887e28473718f027059df2aafdd516f66dc3 Fixes: PYSIDE-1669 Task-number: PYSIDE-1499 Pick-to: 6.2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* PySide6: Add QAccessible::installFactory()Friedemann Kleint2021-08-311-0/+95
| | | | | | Fixes: PYSIDE-1650 Change-Id: I05926888aa4de8c3a34c712ed2000ba59e524833 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Shiboken: Remove cheating macrosChristian Tismer2021-08-061-2/+2
| | | | | | | | | | | | | | | There are a number of cheating macros that allow to use the same code in Python 2 and 3. Because Python 2 is gone, remove these macros. This conversion was partially difficult since certain types collapsed in the XML files and generated functions contained substrings of the macros. This is actually the fourth attempt. Task-number: PYSIDE-1019 Pick-to: 6.1 Change-Id: I116877afc8aa36f4710a40df1769f600b6b750ea Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide6: Use constData() in snippets where applicableFriedemann Kleint2021-07-271-1/+1
| | | | | | Pick-to: 6.1 Change-Id: Iafa3a7f4e0a81733c5a99a907e808391270ce8c6 Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide6: Add QKey support for the setShortcut methodCristian Maureira-Fredes2021-06-181-0/+4
| | | | | | | | | | | | | | | | | | When this method is used in Qt/C++, the argument gets internally cast to a QKeyCombination if it is a QKey, but in Python land this is not automatically covered. A workaround was for the users to manually cast the QKey, but this adds an extra step to achieve the same. This patch adds a new method to QAction and QAbstractButton to use setShortcut with a QKey as an argument. Pick-to: 6.1 Change-Id: I9e9ebe16a65cb5aeb26a367faecbbbd414d80e03 Fixes: PYSIDE-907 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix error about not holding the GIL when releasing QImage memoryFriedemann Kleint2021-06-031-0/+3
| | | | | | | | | | | | | | Fix: "Fatal Python error: Python memory allocator called without holding the GIL" when running sources/pyside6/tests/QtWidgets/qimage_test.py Acquire the GIL for releasing. Amends a97698f0a5d011fd206db94cf73dba6353f39b29. Pick-to: 6.1 5.15 Task-number: PYSIDE-1563 Change-Id: Idf8dbf857f6dde76f80a78f581dacb3cf5fea16b Reviewed-by: Christian Tismer <tismer@stackless.com>
* Fix crashes when using the QImage(uchar *) data constructors, take 2Friedemann Kleint2021-05-251-0/+7
| | | | | | | | | | | | | | | The constructors expect a range of memory that remains valid through the lifetime of the image and may also modify it. Crashes occurred since apparently the Py_Buffer was released before it. To fix this, inject code to increase the reference count and decrease it in the cleanup function. Pick-to: 6.1 5.15 Fixes: PYSIDE-1563 Change-Id: Ic4a47e0f458ed5b59b88813139102a9f1490a9df Reviewed-by: Christian Tismer <tismer@stackless.com>
* Enable the exec() functionsCristian Maureira-Fredes2021-05-041-0/+45
| | | | | | | | | | | With Qt6, PySide dropped support for Python 2.7, thus it does not make sense to keep our exec_() renaming inplace. This patch will enable the exec() functions, and adds a deprecation note for exec_(), which will enable us to safely remove it in the future. Change-Id: I7375e10632e7ab534ca264304a5a65f380b9b1bb Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add a numpy overload for some functions taking lists of QPointFFriedemann Kleint2021-04-211-0/+5
| | | | | | | | | | | | | | | | | | | | Add functions taking x,y data in the form of numpy-vectors (as common for matplotlib, etc) for: QPainter::drawPoints() QXYSeries::append(), QXYSeries::replace() They are added as separate functions instead of overloads since there is a restriction in that numpy arrays cause an error: FIXME Subscripted generics cannot be used with class and instance checks when passed to other type check macros. Task-number: PYSIDE-1540 Task-number: PYSIDE-1503 Change-Id: Ie1521ce19127bb0641fbdb4f7320a8707682724e Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Remove const_cast<char *> which are no longer needed in Python 3Friedemann Kleint2021-03-151-3/+1
| | | | | | | | Remove from code as well as from the generator. Change-Id: Ia863788bfa57d52258836c1cbcccb8c9815b7421 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* PySide6: Move injected code snippets where they belongFriedemann Kleint2021-03-101-10/+14
| | | | | | | | Adapt to the restructuring in Qt 6. Change-Id: I3cd65b8ee428fcc75de010efaa3595664a00eb97 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Brush up the injected code snippets and templatesFriedemann Kleint2021-03-101-7/+8
| | | | | | | | | | | - Use qsizetype (or equivalent Py_ssize_t) for containers - Introduce some auto - Use constData() for QByteArray - Use Qt 5 connection syntax - Use nullptr Change-Id: Ie9134a4f756219d6e5c5710ab64c09a236febd4d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Remove unused glue codeFriedemann Kleint2021-03-101-5/+0
| | | | | Change-Id: I3f5adb202722aecbd34766e782c218720926b73d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix broken return type conversions of QOpenGLExtraFunctions::glGetStringi()Friedemann Kleint2021-03-101-0/+4
| | | | | | | | | | | | | | | The function returns const unsigned char*, which was converted using the wrong snippet (QString conversion of parameter 1). Add a new snippet using the char *conversion of the return value at the end. Fixes warning: PySide6/QtGui/PySide6/QtGui/qopenglextrafunctions_wrapper.cpp:4630:35: warning: unused variable cppResunused-variable] const unsigned char * cppResult = cppSelf->glGetStringi(cppArg0, cppArg1); Pick-to: 6.0 5.15 Change-Id: Iae3f0abd4a34fb3b6a41534508fb5d64a3eae224 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PySide6: Add QOpenGLFunctions.glShaderSource()/glGetShaderSource()Friedemann Kleint2021-03-041-0/+22
| | | | | | | | | Add a simple signature taking and returning a string. Fixes: PYSIDE-1511 Pick-to: 5.15 Change-Id: Ie52d5f55f168075ee6ee71fdb35463895f768c04 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Rename PySide2 to PySide6Friedemann Kleint2020-11-021-0/+547
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>