Merge pull request #1771 from pijyoi/fix_pyside6.1
some fixes PySide6 6.1.0
This commit is contained in:
commit
eed220e874
|
@ -273,6 +273,13 @@ if QT_LIB in [PYQT5, PYQT6, PYSIDE2, PYSIDE6]:
|
|||
QtGui.QApplication.setGraphicsSystem = None
|
||||
|
||||
|
||||
if QT_LIB in [PYQT5, PYSIDE2]:
|
||||
# Some constructs are getting deprecated in Qt6
|
||||
# recreate the Qt6 structure
|
||||
|
||||
QtWidgets.QApplication.exec = QtWidgets.QApplication.exec_
|
||||
|
||||
|
||||
if QT_LIB in [PYQT6, PYSIDE6]:
|
||||
# We're using Qt6 which has a different structure so we're going to use a shim to
|
||||
# recreate the Qt5 structure
|
||||
|
@ -327,6 +334,10 @@ if QT_LIB == PYSIDE6:
|
|||
self.setColorAt(pos, color)
|
||||
QtGui.QGradient.setStops = __setStops
|
||||
|
||||
if not hasattr(QtWidgets.QApplication, 'exec'):
|
||||
# PySide6 6.0 forwards compatibility to PySide6 6.1
|
||||
QtWidgets.QApplication.exec = QtWidgets.QApplication.exec_
|
||||
|
||||
|
||||
if QT_LIB == PYQT6:
|
||||
# module.Class.EnumClass.Enum -> module.Class.Enum
|
||||
|
|
|
@ -40,6 +40,9 @@ class Vector(QtGui.QVector3D):
|
|||
if len(vals) != 3:
|
||||
raise Exception('Cannot init Vector with sequence of length %d' % len(args[0]))
|
||||
initArgs = vals
|
||||
elif isinstance(args[0], QtGui.QVector3D):
|
||||
# PySide6 6.1 does not accept initialization from QVector3D
|
||||
initArgs = args[0].x(), args[0].y(), args[0].z()
|
||||
elif len(args) == 2:
|
||||
initArgs = (args[0], args[1], 0)
|
||||
QtGui.QVector3D.__init__(self, *initArgs)
|
||||
|
|
|
@ -198,7 +198,7 @@ class Dock(QtGui.QWidget, DockDrop):
|
|||
self.drag.setMimeData(mime)
|
||||
self.widgetArea.setStyleSheet(self.dragStyle)
|
||||
self.update()
|
||||
action = self.drag.exec_() if hasattr(self.drag, 'exec_') else self.drag.exec()
|
||||
action = self.drag.exec() if hasattr(self.drag, 'exec') else self.drag.exec_()
|
||||
self.updateStyle()
|
||||
|
||||
def float(self):
|
||||
|
@ -329,13 +329,15 @@ class DockLabel(VerticalLabel):
|
|||
self.updateStyle()
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
self.pressPos = ev.localPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
self.pressPos = lpos
|
||||
self.mouseMoved = False
|
||||
ev.accept()
|
||||
|
||||
def mouseMoveEvent(self, ev):
|
||||
if not self.mouseMoved:
|
||||
self.mouseMoved = (ev.localPos() - self.pressPos).manhattanLength() > QtGui.QApplication.startDragDistance()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
self.mouseMoved = (lpos - self.pressPos).manhattanLength() > QtGui.QApplication.startDragDistance()
|
||||
|
||||
if self.mouseMoved and ev.buttons() == QtCore.Qt.LeftButton:
|
||||
self.dock.startDrag()
|
||||
|
|
|
@ -343,7 +343,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||
|
||||
if not self.mouseEnabled:
|
||||
return
|
||||
lpos = ev.localPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
self.lastMousePos = lpos
|
||||
self.mousePressPos = lpos
|
||||
self.clickAccepted = ev.isAccepted()
|
||||
|
@ -360,7 +360,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||
return ## Everything below disabled for now..
|
||||
|
||||
def mouseMoveEvent(self, ev):
|
||||
lpos = ev.localPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
if self.lastMousePos is None:
|
||||
self.lastMousePos = lpos
|
||||
delta = Point(lpos - self.lastMousePos)
|
||||
|
|
|
@ -19,11 +19,13 @@ class JoystickButton(QtGui.QPushButton):
|
|||
|
||||
def mousePressEvent(self, ev):
|
||||
self.setChecked(True)
|
||||
self.pressPos = ev.localPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
self.pressPos = lpos
|
||||
ev.accept()
|
||||
|
||||
def mouseMoveEvent(self, ev):
|
||||
dif = ev.localPos()-self.pressPos
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
dif = lpos - self.pressPos
|
||||
self.setState(dif.x(), -dif.y())
|
||||
|
||||
def mouseReleaseEvent(self, ev):
|
||||
|
|
|
@ -100,7 +100,8 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||
return args
|
||||
|
||||
def serialize_mouse_event(self, ev):
|
||||
lpos, gpos = ev.localPos(), ev.screenPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
gpos = ev.globalPosition() if hasattr(ev, 'globalPosition') else ev.screenPos()
|
||||
typ, btn, btns, mods = self.serialize_mouse_enum(
|
||||
ev.type(), ev.button(), ev.buttons(), ev.modifiers())
|
||||
return (typ, lpos, gpos, btn, btns, mods)
|
||||
|
@ -137,7 +138,11 @@ class RemoteGraphicsView(QtGui.QWidget):
|
|||
return super().wheelEvent(ev)
|
||||
|
||||
def enterEvent(self, ev):
|
||||
lws = ev.localPos(), ev.windowPos(), ev.screenPos()
|
||||
lpos = ev.position() if hasattr(ev, 'position') else ev.localPos()
|
||||
wpos = ev.scenePosition() if hasattr(ev, 'scenePosition') else ev.windowPos()
|
||||
gpos = ev.globalPosition() if hasattr(ev, 'globalPosition') else ev.screenPos()
|
||||
|
||||
lws = lpos, wpos, gpos
|
||||
self._view.enterEvent(lws, _callSync='off')
|
||||
return super().enterEvent(ev)
|
||||
|
||||
|
|
Loading…
Reference in New Issue