diff options
| author | Christian Tismer <tismer@stackless.com> | 2022-08-25 11:54:56 +0200 |
|---|---|---|
| committer | Christian Tismer <tismer@stackless.com> | 2022-09-01 11:47:15 +0200 |
| commit | 20729eb6ffda8771c192e1614f8e53823108cab1 (patch) | |
| tree | a0c083b1c6ef3fc0b63bef9004a01d6ff2ce880d /sources/pyside6/tests/pysidetest/qvariant_test.py | |
| parent | edbee6b65aeafc0fb9a5cdb8d53e04e15a94edbe (diff) | |
PyEnum: Improve the handling of QKeyCombination
After turning IntEnum into Enum, a few classes need more
attention because the simple int coercion is no more
sufficient. Instead, a bit of help is necessary to make
the usage of the __or__ operator consistent, again.
On first sight, this coercion to KeyCombination looks slightly
unpythonic. But this originates in the complex matters. If you
observe what types are actually added, this is very correct.
Using the IntEnum version instead is not better. It is just
hiding the ongoings by using int, which would also allow
to combine two characters as a bad side effect.
[ChangeLog][PySide6] PyEnum now handles QKeyCombination correctly
with "|" or (deprecated) "+" operators, without falling back
to using IntEnum.
Task-number: PYSIDE-1735
Change-Id: I08b93b8b7ece75ca650f2916ec6f6f5bb711a70b
Pick-to: 6.3
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/qvariant_test.py')
| -rw-r--r-- | sources/pyside6/tests/pysidetest/qvariant_test.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sources/pyside6/tests/pysidetest/qvariant_test.py b/sources/pyside6/tests/pysidetest/qvariant_test.py index b0dfc96a8..2e7c8b2e8 100644 --- a/sources/pyside6/tests/pysidetest/qvariant_test.py +++ b/sources/pyside6/tests/pysidetest/qvariant_test.py @@ -11,8 +11,8 @@ from init_paths import init_test_paths init_test_paths(True) from testbinding import TestObject -from PySide6.QtCore import Qt -from PySide6.QtGui import QKeySequence +from PySide6.QtCore import Qt, QKeyCombination +from PySide6.QtGui import QKeySequence, QAction from helper.usesqapplication import UsesQApplication @@ -24,6 +24,16 @@ class QVariantTest(UsesQApplication): ks = QKeySequence(Qt.ShiftModifier, Qt.ControlModifier, Qt.Key_P, Qt.Key_R) self.assertEqual(TestObject.checkType(ks), 4107) + # PYSIDE-1735: Test the new way to address QKeyCombination after moving IntEnum to Enum + def testQKeySequenceMoreVariations(self): + QAction().setShortcut(Qt.CTRL | Qt.Key_B) + QAction().setShortcut(Qt.CTRL | Qt.ALT | Qt.Key_B) + QAction().setShortcut(Qt.CTRL | Qt.AltModifier | Qt.Key_B) + QAction().setShortcut(QKeySequence(QKeyCombination(Qt.CTRL | Qt.Key_B))) + QKeySequence(Qt.CTRL | Qt.Key_Q) + # Issues a warning but works as well + QKeySequence(Qt.CTRL + Qt.Key_Q) + if __name__ == '__main__': unittest.main() |
