diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-28 16:43:36 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-05-03 07:04:36 +0000 |
commit | 2e9f955a086fa7676c9eda60ca9e28cc03d9c5e2 (patch) | |
tree | 0a3a05cf33acb5acbc8cd91415e97605ad029090 | |
parent | 616e56ad6ae6ce240e22e5227c241d42ce73e7ac (diff) |
QtGui: Add more non-GL related bindings
Add:
QBackingStore
QEnterEvent
QMarginsF
QPageLayout
QPageSize
QPaintDeviceWindow
QPixelFormat
QPdfWriter
QRasterWindow
QRawFont
QPaintDeviceWindow
QStaticText
QStyleHints
Task-number: PYSIDE-487
Change-Id: I8926f55e4a5c71fc7e5b2293c4d300e305c6b56d
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | PySide2/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | PySide2/QtCore/typesystem_core_common.xml | 1 | ||||
-rw-r--r-- | PySide2/QtGui/CMakeLists.txt | 11 | ||||
-rw-r--r-- | PySide2/QtGui/typesystem_gui_common.xml | 36 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/QtGui/qpdfwriter_test.py | 47 | ||||
-rw-r--r-- | tests/QtGui/qpixelformat_test.py | 50 | ||||
-rw-r--r-- | tests/QtGui/qrasterwindow_test.py | 86 | ||||
-rw-r--r-- | tests/QtGui/qstylehints_test.py | 42 |
9 files changed, 278 insertions, 0 deletions
diff --git a/PySide2/QtCore/CMakeLists.txt b/PySide2/QtCore/CMakeLists.txt index 74f486f2..4e833f58 100644 --- a/PySide2/QtCore/CMakeLists.txt +++ b/PySide2/QtCore/CMakeLists.txt @@ -71,6 +71,7 @@ ${QtCore_GEN_DIR}/qline_wrapper.cpp ${QtCore_GEN_DIR}/qlinef_wrapper.cpp ${QtCore_GEN_DIR}/qlocale_wrapper.cpp ${QtCore_GEN_DIR}/qmargins_wrapper.cpp +${QtCore_GEN_DIR}/qmarginsf_wrapper.cpp ${QtCore_GEN_DIR}/qmessagelogcontext_wrapper.cpp ${QtCore_GEN_DIR}/qmetaclassinfo_wrapper.cpp ${QtCore_GEN_DIR}/qmetaenum_wrapper.cpp diff --git a/PySide2/QtCore/typesystem_core_common.xml b/PySide2/QtCore/typesystem_core_common.xml index f7960647..3bcf3d1b 100644 --- a/PySide2/QtCore/typesystem_core_common.xml +++ b/PySide2/QtCore/typesystem_core_common.xml @@ -3952,6 +3952,7 @@ s1.addTransition(button.clicked, s1h)</code> </object-type> <value-type name="QMargins" since="4.6"/> + <value-type name="QMarginsF" since="5.3"/> <object-type name="QParallelAnimationGroup" since="4.6"/> diff --git a/PySide2/QtGui/CMakeLists.txt b/PySide2/QtGui/CMakeLists.txt index 3fa2effd..68c6bc79 100644 --- a/PySide2/QtGui/CMakeLists.txt +++ b/PySide2/QtGui/CMakeLists.txt @@ -8,6 +8,7 @@ ${QtGui_GEN_DIR}/qabstracttextdocumentlayout_selection_wrapper.cpp ${QtGui_GEN_DIR}/qabstracttextdocumentlayout_wrapper.cpp ${QtGui_GEN_DIR}/qaccessibleevent_wrapper.cpp ${QtGui_GEN_DIR}/qactionevent_wrapper.cpp +${QtGui_GEN_DIR}/qbackingstore_wrapper.cpp ${QtGui_GEN_DIR}/qbitmap_wrapper.cpp ${QtGui_GEN_DIR}/qbrush_wrapper.cpp ${QtGui_GEN_DIR}/qclipboard_wrapper.cpp @@ -23,6 +24,7 @@ ${QtGui_GEN_DIR}/qdragenterevent_wrapper.cpp ${QtGui_GEN_DIR}/qdragleaveevent_wrapper.cpp ${QtGui_GEN_DIR}/qdragmoveevent_wrapper.cpp ${QtGui_GEN_DIR}/qdropevent_wrapper.cpp +${QtGui_GEN_DIR}/qenterevent_wrapper.cpp ${QtGui_GEN_DIR}/qexposeevent_wrapper.cpp ${QtGui_GEN_DIR}/qfileopenevent_wrapper.cpp ${QtGui_GEN_DIR}/qfocusevent_wrapper.cpp @@ -66,7 +68,10 @@ ${QtGui_GEN_DIR}/qmoveevent_wrapper.cpp ${QtGui_GEN_DIR}/qmovie_wrapper.cpp ${QtGui_GEN_DIR}/qpagedpaintdevice_margins_wrapper.cpp ${QtGui_GEN_DIR}/qpagedpaintdevice_wrapper.cpp +${QtGui_GEN_DIR}/qpagelayout_wrapper.cpp +${QtGui_GEN_DIR}/qpagesize_wrapper.cpp ${QtGui_GEN_DIR}/qpaintdevice_wrapper.cpp +${QtGui_GEN_DIR}/qpaintdevicewindow_wrapper.cpp ${QtGui_GEN_DIR}/qpaintengine_wrapper.cpp ${QtGui_GEN_DIR}/qpaintenginestate_wrapper.cpp ${QtGui_GEN_DIR}/qpainter_pixmapfragment_wrapper.cpp @@ -76,12 +81,14 @@ ${QtGui_GEN_DIR}/qpainterpath_wrapper.cpp ${QtGui_GEN_DIR}/qpainterpathstroker_wrapper.cpp ${QtGui_GEN_DIR}/qpaintevent_wrapper.cpp ${QtGui_GEN_DIR}/qpalette_wrapper.cpp +${QtGui_GEN_DIR}/qpdfwriter_wrapper.cpp ${QtGui_GEN_DIR}/qpen_wrapper.cpp ${QtGui_GEN_DIR}/qpicture_wrapper.cpp ${QtGui_GEN_DIR}/qpictureio_wrapper.cpp ${QtGui_GEN_DIR}/qpixmap_wrapper.cpp ${QtGui_GEN_DIR}/qpixmapcache_key_wrapper.cpp ${QtGui_GEN_DIR}/qpixmapcache_wrapper.cpp +${QtGui_GEN_DIR}/qpixelformat_wrapper.cpp ${QtGui_GEN_DIR}/qpolygon_wrapper.cpp ${QtGui_GEN_DIR}/qpolygonf_wrapper.cpp ${QtGui_GEN_DIR}/qpytextobject_wrapper.cpp @@ -106,6 +113,10 @@ ${QtGui_GEN_DIR}/qscreen_wrapper.cpp ${QtGui_GEN_DIR}/qopenglshader_wrapper.cpp #${QtGui_GEN_DIR}/qopenglshaderprogram_wrapper.cpp ${QtGui_GEN_DIR}/qopenglframebufferobject_wrapper.cpp +${QtGui_GEN_DIR}/qrasterwindow_wrapper.cpp +${QtGui_GEN_DIR}/qrawfont_wrapper.cpp +${QtGui_GEN_DIR}/qstatictext_wrapper.cpp +${QtGui_GEN_DIR}/qstylehints_wrapper.cpp ${QtGui_GEN_DIR}/qsurface_wrapper.cpp ${QtGui_GEN_DIR}/qsurfaceformat_wrapper.cpp ${QtGui_GEN_DIR}/qsyntaxhighlighter_wrapper.cpp diff --git a/PySide2/QtGui/typesystem_gui_common.xml b/PySide2/QtGui/typesystem_gui_common.xml index 90ba5f9a..439ca3c9 100644 --- a/PySide2/QtGui/typesystem_gui_common.xml +++ b/PySide2/QtGui/typesystem_gui_common.xml @@ -105,6 +105,10 @@ <rejection class="QAccessibleEvent" field-name="m_type"/> + <rejection class="QEnterEvent" field-name="l"/> + <rejection class="QEnterEvent" field-name="w"/> + <rejection class="QEnterEvent" field-name="s"/> + <rejection class="QInputEvent" field-name="modState"/> <rejection class="QInputEvent" field-name="modState"/> @@ -291,6 +295,9 @@ </add-function> </value-type> + <value-type name="QStaticText"> + <enum-type name="PerformanceHint"/> + </value-type> <value-type name="QTextFragment" /> <value-type name="QBitmap" > <modify-function signature="fromData(QSize,const uchar*,QImage::Format)"> @@ -1738,6 +1745,7 @@ </modify-argument> </modify-function> </object-type> + <object-type name="QEnterEvent" copyable="false" polymorphic-id-expression="%1->type() == QEvent::Enter"/> <object-type name="QExposeEvent" polymorphic-id-expression="%1->type() == QEvent::Expose" /> <object-type name="QFileOpenEvent" polymorphic-id-expression="%1->type() == QEvent::FileOpen" /> <object-type name="QFocusEvent" polymorphic-id-expression="%1->type() == QEvent::FocusIn || %1->type() == QEvent::FocusOut" /> @@ -3186,6 +3194,7 @@ <suppress-warning text="enum 'QCoreApplication::ApplicationFlags' is specified in typesystem, but not declared" /> <!-- Qt5: here the new QWindow stuff and what it pulls in --> + <object-type name="QBackingStore"/> <object-type name="QSurface"> <enum-type name="SurfaceClass"/> <enum-type name="SurfaceType"/> @@ -3267,7 +3276,34 @@ typesystem. <object-type name="QOpenGLShaderProgram" /> --> + <value-type name="QPageLayout"> + <enum-type name="Mode"/> + <enum-type name="Orientation"/> + <enum-type name="Unit"/> + </value-type> + <value-type name="QPageSize"> + <enum-type name="PageSizeId"/> + <enum-type name="Unit"/> + <enum-type name="SizeMatchPolicy"/> + </value-type> + <object-type name="QPaintDeviceWindow"/> + <value-type name="QPixelFormat"> + <enum-type name="AlphaUsage"/> + <enum-type name="AlphaPosition"/> + <enum-type name="AlphaPremultiplied"/> + <enum-type name="ByteOrder"/> + <enum-type name="ColorModel"/> + <enum-type name="TypeInterpretation"/> + <enum-type name="YUVLayout"/> + </value-type> + <object-type name="QPdfWriter"/> + <value-type name="QRawFont"> + <enum-type name="AntialiasingType"/> + <enum-type name="LayoutFlag" flags="LayoutFlags"/> + </value-type> + <object-type name="QRasterWindow"/> <object-type name="QScreen" /> + <object-type name="QStyleHints"/> </typesystem> diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index f41a0f8b..63cf3c35 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -29,12 +29,16 @@ PYSIDE_TEST(qitemselection_test.py) PYSIDE_TEST(qmatrix_test.py) PYSIDE_TEST(qopenglbuffer_test.py) PYSIDE_TEST(qpainter_test.py) +PYSIDE_TEST(qpdfwriter_test.py) +PYSIDE_TEST(qpixelformat_test.py) PYSIDE_TEST(qpixmap_test.py) PYSIDE_TEST(qpixmapcache_test.py) PYSIDE_TEST(qpolygonf_test.py) PYSIDE_TEST(qkeysequence_test.py) PYSIDE_TEST(qradialgradient_test.py) +PYSIDE_TEST(qrasterwindow_test.py) PYSIDE_TEST(qregion_test.py) +PYSIDE_TEST(qstylehints_test.py) PYSIDE_TEST(qtextdocument_undoredo_test.py) PYSIDE_TEST(qtextdocumentwriter_test.py) PYSIDE_TEST(qtextline_test.py) diff --git a/tests/QtGui/qpdfwriter_test.py b/tests/QtGui/qpdfwriter_test.py new file mode 100644 index 00000000..f97c85b3 --- /dev/null +++ b/tests/QtGui/qpdfwriter_test.py @@ -0,0 +1,47 @@ +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## 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-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import unittest +from helper import UsesQApplication +from PySide2.QtGui import QPageLayout, QPageSize, QPdfWriter, QTextDocument +from PySide2.QtCore import QDir, QMarginsF, QTemporaryFile + +class QPdfWriterTest(UsesQApplication): + + def testWrite(self): + temporaryFile = QTemporaryFile(QDir.tempPath() + "/pdfwriter_test_XXXXXX.pdf") + self.assertTrue(temporaryFile.open()) + pdfWriter = QPdfWriter(temporaryFile) + pdfWriter.setPageLayout(QPageLayout(QPageSize(QPageSize.A4), QPageLayout.Portrait, QMarginsF(10, 10, 10, 10))) + doc = QTextDocument("Some text") + doc.print_(pdfWriter) + temporaryFile.close() + self.assertTrue(temporaryFile.size() > 0) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qpixelformat_test.py b/tests/QtGui/qpixelformat_test.py new file mode 100644 index 00000000..c7f14ff2 --- /dev/null +++ b/tests/QtGui/qpixelformat_test.py @@ -0,0 +1,50 @@ +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## 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-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Unit test for QPixelFormat''' + +import unittest + +from helper import UsesQApplication +from PySide2.QtCore import QSize, Qt +from PySide2.QtGui import QColor, QImage, QPixelFormat + +class QPixelFormatTest(UsesQApplication): + def test(self): + image = QImage(QSize(200, 200), QImage.Format_ARGB32) + image.fill(QColor(Qt.red)) + pixelFormat = image.pixelFormat() + print(pixelFormat.greenSize()) + self.assertEqual(pixelFormat.alphaSize(), 8) + self.assertEqual(pixelFormat.redSize(), 8) + self.assertEqual(pixelFormat.greenSize(), 8) + self.assertEqual(pixelFormat.blueSize(), 8) + self.assertEqual(pixelFormat.bitsPerPixel(), 32) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qrasterwindow_test.py b/tests/QtGui/qrasterwindow_test.py new file mode 100644 index 00000000..db756ff8 --- /dev/null +++ b/tests/QtGui/qrasterwindow_test.py @@ -0,0 +1,86 @@ +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## 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-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Unit test for QBackingStore, QRasterWindow and QStaticText''' + +import unittest + +from helper import UsesQApplication +from PySide2.QtCore import QEvent, QPoint, QRect, QSize, QTimer, Qt +from PySide2.QtGui import QColor, QBackingStore, QPaintDevice, QPainter, QWindow, QPaintDeviceWindow, QRasterWindow, QRegion, QStaticText + +# QWindow rendering via QBackingStore +class TestBackingStoreWindow(QWindow): + def __init__(self): + super(TestBackingStoreWindow, self).__init__() + self.backingStore = QBackingStore(self) + self.text = QStaticText("BackingStoreWindow") + + def event(self, event): + if event.type() == QEvent.Resize: + self.backingStore.resize(self.size()) + self.render() + elif event.type() == QEvent.UpdateRequest or event.type() == QEvent.Expose: + self.backingStore.flush(QRegion(QRect(QPoint(0, 0), self.size()))) + + return QWindow.event(self, event) + + def render(self): + clientRect = QRect(QPoint(0, 0), self.size()) + painter = QPainter(self.backingStore.paintDevice()) + painter.fillRect(clientRect, QColor(Qt.green)) + painter.drawStaticText(QPoint(10, 10), self.text) + +# Window using convenience class QRasterWindow +class TestRasterWindow(QRasterWindow): + def __init__(self): + super(TestRasterWindow, self).__init__() + self.text = QStaticText("QRasterWindow") + + def paintEvent(self, event): + clientRect = QRect(QPoint(0, 0), self.size()) + painter = QPainter(self) + painter.fillRect(clientRect, QColor(Qt.red)) + painter.drawStaticText(QPoint(10, 10), self.text) + +class QRasterWindowTest(UsesQApplication): + def test(self): + rasterWindow = TestRasterWindow() + rasterWindow.setFramePosition(QPoint(100, 100)) + rasterWindow.resize(QSize(400, 400)) + rasterWindow.show() + backingStoreWindow = TestBackingStoreWindow() + backingStoreWindow.setFramePosition(QPoint(600, 100)) + backingStoreWindow.resize(QSize(400, 400)) + backingStoreWindow.show() + + QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qstylehints_test.py b/tests/QtGui/qstylehints_test.py new file mode 100644 index 00000000..c3d99aa3 --- /dev/null +++ b/tests/QtGui/qstylehints_test.py @@ -0,0 +1,42 @@ +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## 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-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +'''Unit test for QStyleHints''' + +import unittest + +from helper import UsesQApplication +from PySide2.QtGui import QStyleHints + +class QStyleHintsTest(UsesQApplication): + def test(self): + styleHints = self.app.styleHints() + self.assertTrue(styleHints.startDragDistance() > 0) + +if __name__ == '__main__': + unittest.main() |