From e27cde95bc353b2f34ba3ef86a62c38b7231b6a4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 May 2018 15:50:58 +0200 Subject: Add QProxyStyle Task-number: PYSIDE-487 Change-Id: Ib862be9c0c62be09a34c3a79740d147b9788cb34 Reviewed-by: Alexandru Croitor --- sources/pyside2/PySide2/QtWidgets/CMakeLists.txt | 1 + .../QtWidgets/typesystem_widgets_common.xml | 7 ++++++ sources/pyside2/tests/QtWidgets/qstyle_test.py | 26 +++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'sources/pyside2') diff --git a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt index 31f241687..dee79744f 100644 --- a/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtWidgets/CMakeLists.txt @@ -123,6 +123,7 @@ ${QtWidgets_GEN_DIR}/qplaintextdocumentlayout_wrapper.cpp ${QtWidgets_GEN_DIR}/qplaintextedit_wrapper.cpp ${QtWidgets_GEN_DIR}/qprogressbar_wrapper.cpp ${QtWidgets_GEN_DIR}/qprogressdialog_wrapper.cpp +${QtWidgets_GEN_DIR}/qproxystyle_wrapper.cpp ${QtWidgets_GEN_DIR}/qpushbutton_wrapper.cpp ${QtWidgets_GEN_DIR}/qradiobutton_wrapper.cpp ${QtWidgets_GEN_DIR}/qrubberband_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index 2a837fbc8..52b1c41d5 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -997,6 +997,13 @@ + + + + + + + diff --git a/sources/pyside2/tests/QtWidgets/qstyle_test.py b/sources/pyside2/tests/QtWidgets/qstyle_test.py index 38b457a82..eb2a73d29 100644 --- a/sources/pyside2/tests/QtWidgets/qstyle_test.py +++ b/sources/pyside2/tests/QtWidgets/qstyle_test.py @@ -29,7 +29,20 @@ import unittest from helper import UsesQApplication -from PySide2.QtWidgets import QWidget, QLabel, QFontComboBox, QStyleFactory +from PySide2.QtGui import QWindow +from PySide2.QtWidgets import (QApplication, QFontComboBox, QLabel, QProxyStyle, + QStyleFactory, QWidget) + +class ProxyStyle(QProxyStyle): + + def __init__(self, style): + QProxyStyle.__init__(self, style) + self.polished = 0 + + def polish(self, widget): + self.polished = self.polished + 1 + super(ProxyStyle, self).polish(widget) + class SetStyleTest(UsesQApplication): '''Tests setting the same QStyle for all objects in a UI hierarchy.''' @@ -54,6 +67,17 @@ class SetStyleTest(UsesQApplication): style = QStyleFactory.create(QStyleFactory.keys()[0]) setStyleHelper(container, style) + def testSetProxyStyle(self): + label = QLabel("QtWidgets/ProxyStyle test") + baseStyle = QStyleFactory.create(QApplication.instance().style().objectName()) + self.assertTrue(baseStyle) + proxyStyle = ProxyStyle(baseStyle) + label.setStyle(proxyStyle) + label.show() + while not label.windowHandle().isExposed(): + QApplication.instance().processEvents() + self.assertTrue(proxyStyle.polished > 0) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3