Merge pull request #1575 from pijyoi/reduce_shim
Reduce number of shims for PyQt6
This commit is contained in:
commit
d9eb8e1afb
@ -425,18 +425,18 @@ if QT_LIB == PYQT6:
|
|||||||
# QKeyEvent::key() returns an int
|
# QKeyEvent::key() returns an int
|
||||||
# so comparison with a Key_* enum will always be False
|
# so comparison with a Key_* enum will always be False
|
||||||
# here we convert the enum to its int value
|
# here we convert the enum to its int value
|
||||||
for e in QtCore.Qt.Key:
|
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)
|
setattr(QtCore.Qt, e.name, e.value)
|
||||||
|
|
||||||
# shim the old names for QPointF mouse coords
|
# shim the old names for QPointF mouse coords
|
||||||
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
|
QtGui.QSinglePointEvent.localPos = lambda o : o.position()
|
||||||
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()
|
QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition()
|
||||||
QtGui.QSinglePointEvent.screenPos = lambda o : o.globalPosition()
|
QtGui.QSinglePointEvent.screenPos = lambda o : o.globalPosition()
|
||||||
QtGui.QDropEvent.posF = lambda o : o.position()
|
|
||||||
|
|
||||||
QtWidgets.QApplication.exec_ = QtWidgets.QApplication.exec
|
QtWidgets.QApplication.exec_ = QtWidgets.QApplication.exec
|
||||||
QtWidgets.QDialog.exec_ = lambda o : o.exec()
|
|
||||||
QtGui.QDrag.exec_ = lambda o : o.exec()
|
|
||||||
|
|
||||||
# PyQt6 6.0.0 has a bug where it can't handle certain Type values returned
|
# PyQt6 6.0.0 has a bug where it can't handle certain Type values returned
|
||||||
# by the Qt library.
|
# by the Qt library.
|
||||||
|
@ -198,7 +198,7 @@ class Dock(QtGui.QWidget, DockDrop):
|
|||||||
self.drag.setMimeData(mime)
|
self.drag.setMimeData(mime)
|
||||||
self.widgetArea.setStyleSheet(self.dragStyle)
|
self.widgetArea.setStyleSheet(self.dragStyle)
|
||||||
self.update()
|
self.update()
|
||||||
action = self.drag.exec_()
|
action = self.drag.exec_() if hasattr(self.drag, 'exec_') else self.drag.exec()
|
||||||
self.updateStyle()
|
self.updateStyle()
|
||||||
|
|
||||||
def float(self):
|
def float(self):
|
||||||
|
@ -30,9 +30,12 @@ class DockDrop(object):
|
|||||||
|
|
||||||
def dragMoveEvent(self, ev):
|
def dragMoveEvent(self, ev):
|
||||||
#print "drag move"
|
#print "drag move"
|
||||||
ld = ev.posF().x()
|
# QDragMoveEvent inherits QDropEvent which provides posF()
|
||||||
|
# PyQt6 provides only position()
|
||||||
|
posF = ev.posF() if hasattr(ev, 'posF') else ev.position()
|
||||||
|
ld = posF.x()
|
||||||
rd = self.width() - ld
|
rd = self.width() - ld
|
||||||
td = ev.posF().y()
|
td = posF.y()
|
||||||
bd = self.height() - td
|
bd = self.height() - td
|
||||||
|
|
||||||
mn = min(ld, rd, td, bd)
|
mn = min(ld, rd, td, bd)
|
||||||
|
@ -368,7 +368,7 @@ class TableWidget(QtGui.QTableWidget):
|
|||||||
self.contextMenu.popup(ev.globalPos())
|
self.contextMenu.popup(ev.globalPos())
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev.key() == QtCore.Qt.Key_C and ev.modifiers() == QtCore.Qt.ControlModifier:
|
if ev.matches(QtGui.QKeySequence.Copy):
|
||||||
ev.accept()
|
ev.accept()
|
||||||
self.copySel()
|
self.copySel()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user