aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/glue/qtgui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/PySide6/glue/qtgui.cpp')
-rw-r--r--sources/pyside6/PySide6/glue/qtgui.cpp299
1 files changed, 258 insertions, 41 deletions
diff --git a/sources/pyside6/PySide6/glue/qtgui.cpp b/sources/pyside6/PySide6/glue/qtgui.cpp
index 81181dac4..5c860a2bf 100644
--- a/sources/pyside6/PySide6/glue/qtgui.cpp
+++ b/sources/pyside6/PySide6/glue/qtgui.cpp
@@ -1,46 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** 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 Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2018 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
/*********************************************************************
* INJECT CODE
********************************************************************/
+// @snippet gui-declarations
+QT_BEGIN_NAMESPACE
+void qt_set_sequence_auto_mnemonic(bool);
+QT_END_NAMESPACE
+// @snippet gui-declarations
+
// @snippet qaccessible-pysidefactory
// Helper for QAccessible::installFactory() that forwards the calls to
// Python callables.
@@ -136,6 +106,140 @@ QAccessibleInterface *PySideAccessibleFactory::callFactories(const QString &key,
PySideAccessibleFactory::ensureInstance()->installFactory(%1);
// @snippet qaccessible-installfactory
+// @snippet qaction-menu
+// %CPPSELF->menu(); // pretend it was called.
+QObject *object = %CPPSELF->menu<QObject *>();
+%PYARG_0 = %CONVERTTOPYTHON[QObject*](object);
+// @snippet qaction-menu
+
+// @snippet qopenglfunctions-glgetv-return-size
+// Return the number of return values of the glGetBoolean/Double/Integerv functions
+// cf https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGet.xhtml
+static int glGetVReturnSize(GLenum pname)
+{
+ switch (pname) {
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ case GL_DEPTH_RANGE:
+ case GL_MAX_VIEWPORT_DIMS:
+#if !QT_CONFIG(opengles2)
+ case GL_POINT_SIZE_RANGE:
+ case GL_SMOOTH_LINE_WIDTH_RANGE:
+ case GL_VIEWPORT_BOUNDS_RANGE:
+#endif
+ return 2;
+ case GL_BLEND_COLOR:
+ case GL_COLOR_CLEAR_VALUE:
+ case GL_COLOR_WRITEMASK:
+ case GL_SCISSOR_BOX:
+ case GL_VIEWPORT:
+ return 4;
+ case GL_COMPRESSED_TEXTURE_FORMATS:
+ return GL_NUM_COMPRESSED_TEXTURE_FORMATS;
+ default:
+ break;
+ }
+ return 1;
+}
+// @snippet qopenglfunctions-glgetv-return-size
+
+// @snippet qopenglextrafunctions-glgeti-v-return-size
+// Return the number of return values of the indexed
+// glGetBoolean/Double/Integeri_v functions
+// cf https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGet.xhtml
+static int glGetI_VReturnSize(GLenum pname)
+{
+ return pname == GL_VIEWPORT ? 4 : 1;
+}
+// @snippet qopenglextrafunctions-glgeti-v-return-size
+
+// @snippet qopenglfunctions-glgetbooleanv
+const int size = glGetVReturnSize(%1);
+QVarLengthArray<GLboolean> result(size, GL_FALSE);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[bool](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createByteArray1(size, result.constData());
+}
+// @snippet qopenglfunctions-glgetbooleanv
+
+// @snippet qopenglfunctions-glgetdoublev
+const int size = glGetVReturnSize(%1);
+QVarLengthArray<GLdouble> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[double](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createDoubleArray1(size, result.constData());
+}
+// @snippet qopenglfunctions-glgetdoublev
+
+// @snippet qopenglfunctions-glgetfloatv
+const int size = glGetVReturnSize(%1);
+QVarLengthArray<GLfloat> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[float](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createFloatArray1(size, result.constData());
+}
+// @snippet qopenglfunctions-glgetfloatv
+
+// @snippet qopenglfunctions-glgetintegerv
+const int size = glGetVReturnSize(%1);
+QVarLengthArray<GLint> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[int](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createIntArray1(size, result.constData());
+}
+// @snippet qopenglfunctions-glgetintegerv
+
+// @snippet qopenglextrafunctions-glgetbooleani-v
+const int size = glGetI_VReturnSize(%1);
+QVarLengthArray<GLboolean> result(size, GL_FALSE);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[bool](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createByteArray1(size, result.constData());
+}
+// @snippet qopenglextrafunctions-glgetbooleani-v
+
+// @snippet qopenglextrafunctions-glgetdoublei-v
+const int size = glGetI_VReturnSize(%1);
+QVarLengthArray<GLdouble> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[double](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createDoubleArray1(size, result.constData());
+}
+// @snippet qopenglextrafunctions-glgetdoublei-v
+
+// @snippet qopenglextrafunctions-glgetfloati-v
+const int size = glGetI_VReturnSize(%1);
+QVarLengthArray<GLfloat> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[float](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createFloatArray1(size, result.constData());
+}
+// @snippet qopenglextrafunctions-glgetfloati-v
+
+// @snippet qopenglextrafunctions-glgetintegeri-v
+const int size = glGetI_VReturnSize(%1);
+QVarLengthArray<GLint> result(size, 0);
+%CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES, result.data());
+if (size == 1) {
+ %PYARG_0 = %CONVERTTOPYTHON[int](result[0]);
+} else {
+ %PYARG_0 = Shiboken::Numpy::createIntArray1(size, result.constData());
+}
+// @snippet qopenglextrafunctions-glgetintegeri-v
+
// @snippet glgetshadersource
GLsizei bufSize = 4096;
GLsizei length = bufSize - 1;
@@ -210,10 +314,19 @@ if (_i < 0 || _i >= %CPPSELF.count()) {
PyErr_SetString(PyExc_IndexError, "index out of bounds");
return 0;
}
-int item = (*%CPPSELF)[_i];
-return %CONVERTTOPYTHON[int](item);
+QKeyCombination item = (*%CPPSELF)[_i];
+return %CONVERTTOPYTHON[QKeyCombination](item);
// @snippet qkeysequence-getitem
+// @snippet qkeysequence-repr
+auto ObTuple_Type = reinterpret_cast<PyObject *>(&PyTuple_Type);
+auto ObSelf_Type = reinterpret_cast<PyObject *>(Py_TYPE(%PYSELF));
+Shiboken::AutoDecRef surrogate(PyObject_CallFunctionObjArgs(ObTuple_Type, %PYSELF, nullptr));
+Shiboken::AutoDecRef argstr(PyObject_Repr(surrogate));
+Shiboken::AutoDecRef name(PyObject_GetAttrString(ObSelf_Type, "__name__"));
+return PyUnicode_Concat(name, argstr);
+// @snippet qkeysequence-repr
+
// @snippet qpicture-data
%PYARG_0 = Shiboken::Buffer::newObject(%CPPSELF.data(), %CPPSELF.size());
// @snippet qpicture-data
@@ -235,7 +348,7 @@ if (doc) {
// @snippet qtextblock-userdata
// @snippet qpolygon-reduce
-const Py_ssize_t count = %CPPSELF.count();
+const Py_ssize_t count = %CPPSELF.size();
PyObject *points = PyList_New(count);
for (Py_ssize_t i = 0; i < count; ++i){
int x, y;
@@ -255,6 +368,21 @@ for (Py_ssize_t i = 0; i < count; ++i){
%0 = new %TYPE(QPixmap::fromImage(%1));
// @snippet qpixmap
+// @snippet qicon-addpixmap
+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)
{
@@ -572,6 +700,15 @@ const auto points = PySide::Numpy::xyDataToQPointFList(%PYARG_1, %PYARG_2);
%CPPSELF.%FUNCTION_NAME(%1.constData(), %1.size(), %2);
// @snippet qpainter-drawpolygon
+// @snippet qpainter-enter
+Py_INCREF(%PYSELF);
+pyResult = %PYSELF;
+// @snippet qpainter-enter
+
+// @snippet qpainter-exit
+%CPPSELF.end();
+// @snippet qpainter-exit
+
// @snippet qmatrix4x4
// PYSIDE-795: All PySequences can be made iterable with PySequence_Fast.
Shiboken::AutoDecRef seq(PySequence_Fast(%PYARG_1, "Can't turn into sequence"));
@@ -640,12 +777,51 @@ if (!PyTuple_SetItem(empty, 0, PyList_New(0))) {
}
// @snippet qguiapplication-2
+// @snippet qguiapplication-setoverridecursor
+auto *cppResult = new QtGuiHelper::QOverrideCursorGuard();
+%PYARG_0 = %CONVERTTOPYTHON[QtGuiHelper::QOverrideCursorGuard*](cppResult);
+Shiboken::Object::getOwnership(%PYARG_0); // Ensure the guard is removed
+// @snippet qguiapplication-setoverridecursor
+
+// @snippet qguiapplication-nativeInterface
+bool hasNativeApp = false;
+#if QT_CONFIG(xcb)
+if (auto *x11App = %CPPSELF.nativeInterface<QNativeInterface::QX11Application>()) {
+ hasNativeApp = true;
+ %PYARG_0 = %CONVERTTOPYTHON[QNativeInterface::QX11Application*](x11App);
+}
+#endif
+if (!hasNativeApp) {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+}
+// @snippet qguiapplication-nativeInterface
+
// @snippet qscreen-grabWindow
WId id = %1;
%RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(id, %2, %3, %4, %5);
%PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](retval);
// @snippet qscreen-grabWindow
+// @snippet qscreen-nativeInterface
+bool hasNativeScreen = false;
+#ifdef Q_OS_WIN
+if (auto *winScreen = %CPPSELF.nativeInterface<QNativeInterface::QWindowsScreen>()) {
+ hasNativeScreen = true;
+ %PYARG_0 = %CONVERTTOPYTHON[QNativeInterface::QWindowsScreen*](winScreen);
+}
+#endif
+if (!hasNativeScreen) {
+ Py_INCREF(Py_None);
+ %PYARG_0 = Py_None;
+}
+// @snippet qscreen-nativeInterface
+
+// @snippet qx11application-resource-ptr
+ auto *resource = %CPPSELF.%FUNCTION_NAME();
+%PYARG_0 = PyLong_FromVoidPtr(resource);
+// @snippet qx11application-resource-ptr
+
// @snippet qwindow-fromWinId
WId id = %1;
%RETURN_TYPE retval = %CPPSELF.%FUNCTION_NAME(id);
@@ -713,6 +889,47 @@ else
%PYARG_0 = %CONVERTTOPYTHON[int](cppResult);
// @snippet qdrag-exec-arg2
+// @snippet qquaternion-getaxisandangle-vector3d-float
+QVector3D outVec{};
+float angle{};
+%CPPSELF.%FUNCTION_NAME(&outVec, &angle);
+%PYARG_0 = PyTuple_New(2);
+PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[QVector3D](outVec));
+PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[float](angle));
+// @snippet qquaternion-getaxisandangle-vector3d-float
+
+// @snippet qquaternion-geteulerangles
+float pitch{}, yaw{}, roll{};
+%CPPSELF.%FUNCTION_NAME(&pitch, &yaw, &roll);
+%PYARG_0 = PyTuple_New(3);
+PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[float](pitch));
+PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[float](yaw));
+PyTuple_SET_ITEM(%PYARG_0, 2, %CONVERTTOPYTHON[float](roll));
+// @snippet qquaternion-geteulerangles
+
+// @snippet qregion-len
+return %CPPSELF.rectCount();
+// @snippet qregion-len
+
+// @snippet qregion-getitem
+if (_i < 0 || _i >= %CPPSELF.rectCount())
+ return PyErr_Format(PyExc_IndexError, "index out of bounds");
+
+const QRect cppResult = *(%CPPSELF.cbegin() + _i);
+return %CONVERTTOPYTHON[QRect](cppResult);
+// @snippet qregion-getitem
+
+// Some RHI functions take a std::initializer_list<>. Add functions
+// to convert from list.
+
+// @snippet qrhi-initializer-list
+%CPPSELF.%FUNCTION_NAME(%1.cbegin(), %1.cend());
+// @snippet qrhi-initializer-list
+
+// @snippet qrhi-commandbuffer-setvertexinput
+%CPPSELF.%FUNCTION_NAME(%1, %2.size(), %2.constData(), %3, %4, %5);
+// @snippet qrhi-commandbuffer-setvertexinput
+
/*********************************************************************
* CONVERSIONS
********************************************************************/