retry solving merge conflict in Qt.py

This commit is contained in:
Nils Nemitz 2021-06-13 02:38:18 +09:00
parent 002e77a124
commit df4a3c1d95

View File

@ -318,73 +318,6 @@ if QT_LIB in [PYQT5, PYQT6]:
QtCore.Signal = QtCore.pyqtSignal
# QtCore.Slot = QtCore.pyqtSlot # The current policy is to avoid slot decorators.
if QT_LIB == PYSIDE6:
# PySide6 6.0 has a missing binding
if not hasattr(QtGui.QGradient, 'setStops'):
def __setStops(self, stops):
for pos, color in stops:
self.setColorAt(pos, color)
QtGui.QGradient.setStops = __setStops
if QT_LIB == PYQT6:
# module.Class.EnumClass.Enum -> module.Class.Enum
def promote_enums(module):
class_names = [x for x in dir(module) if x.startswith('Q')]
for class_name in class_names:
klass = getattr(module, class_name)
if not isinstance(klass, sip.wrappertype):
continue
attrib_names = [x for x in dir(klass) if x[0].isupper()]
for attrib_name in attrib_names:
attrib = getattr(klass, attrib_name)
if not isinstance(attrib, enum.EnumMeta):
continue
for e in attrib:
setattr(klass, e.name, e)
promote_enums(QtCore)
promote_enums(QtGui)
promote_enums(QtWidgets)
# QKeyEvent::key() returns an int
# so comparison with a Key_* enum will always be False
# here we convert the enum to its int value
keys = ['Up', 'Down', 'Right', 'Left', 'Return', 'Enter', 'Delete', 'Backspace',
'PageUp', 'PageDown', 'Home', 'End', 'Tab', 'Backtab', 'Escape', 'Space']
for name in keys:
e = getattr(QtCore.Qt.Key, 'Key_' + name)
setattr(QtCore.Qt, e.name, e.value)
# shim the old names for QPointF mouse coords
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()
QtGui.QSinglePointEvent.screenPos = lambda o : o.globalPosition()
QtWidgets.QApplication.exec_ = QtWidgets.QApplication.exec
# PyQt6 6.0.0 has a bug where it can't handle certain Type values returned
# by the Qt library.
if QtCore.PYQT_VERSION == 0x60000:
def new_method(self, old_method=QtCore.QEvent.type):
try:
typ = old_method(self)
except ValueError:
typ = QtCore.QEvent.Type.None_
return typ
QtCore.QEvent.type = new_method
del new_method
# PyQt6 6.1 renames some enums and flags to be in line with the other bindings.
# "Alignment" and "Orientations" are PyQt6 6.0 and are used in the generated
# ui files. Pending a regeneration of the template files, which would mean a
# drop in support for PyQt6 6.0, provide the old names for PyQt6 6.1.
# This is strictly a temporary private shim. Do not depend on it in your code.
if hasattr(QtCore.Qt, 'AlignmentFlag') and not hasattr(QtCore.Qt, 'Alignment'):
QtCore.Qt.Alignment = QtCore.Qt.AlignmentFlag
if hasattr(QtCore.Qt, 'Orientation') and not hasattr(QtCore.Qt, 'Orientations'):
QtCore.Qt.Orientations = QtCore.Qt.Orientation
# USE_XXX variables are deprecated
USE_PYSIDE = QT_LIB == PYSIDE
USE_PYQT4 = QT_LIB == PYQT4