From f4d685f7bdad479e6e76344917bb3fe5228ac117 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 14 Feb 2021 07:36:07 +0800 Subject: [PATCH 1/4] remove QDialog.exec_ shim only used by PrinterExport.py which is currently disabled --- pyqtgraph/Qt.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 91c4d1b0..f2b01d69 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -435,7 +435,6 @@ if QT_LIB == PYQT6: QtGui.QDropEvent.posF = lambda o : o.position() 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 From 968286a1cf39e5fc80455bcc1f4992b2beea3dcd Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 14 Feb 2021 07:44:00 +0800 Subject: [PATCH 2/4] remove drag and drop shims used only in one place in the codebase --- pyqtgraph/Qt.py | 2 -- pyqtgraph/dockarea/Dock.py | 2 +- pyqtgraph/dockarea/DockDrop.py | 7 +++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index f2b01d69..63d9eee5 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -432,10 +432,8 @@ if QT_LIB == PYQT6: QtGui.QSinglePointEvent.localPos = lambda o : o.position() QtGui.QSinglePointEvent.windowPos = lambda o : o.scenePosition() QtGui.QSinglePointEvent.screenPos = lambda o : o.globalPosition() - QtGui.QDropEvent.posF = lambda o : o.position() QtWidgets.QApplication.exec_ = QtWidgets.QApplication.exec - QtGui.QDrag.exec_ = lambda o : o.exec() # PyQt6 6.0.0 has a bug where it can't handle certain Type values returned # by the Qt library. diff --git a/pyqtgraph/dockarea/Dock.py b/pyqtgraph/dockarea/Dock.py index a4997b8c..7a5e09d4 100644 --- a/pyqtgraph/dockarea/Dock.py +++ b/pyqtgraph/dockarea/Dock.py @@ -198,7 +198,7 @@ class Dock(QtGui.QWidget, DockDrop): self.drag.setMimeData(mime) self.widgetArea.setStyleSheet(self.dragStyle) self.update() - action = self.drag.exec_() + action = self.drag.exec_() if hasattr(self.drag, 'exec_') else self.drag.exec() self.updateStyle() def float(self): diff --git a/pyqtgraph/dockarea/DockDrop.py b/pyqtgraph/dockarea/DockDrop.py index e16f3e7a..b7f0c2dc 100644 --- a/pyqtgraph/dockarea/DockDrop.py +++ b/pyqtgraph/dockarea/DockDrop.py @@ -30,9 +30,12 @@ class DockDrop(object): def dragMoveEvent(self, ev): #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 - td = ev.posF().y() + td = posF.y() bd = self.height() - td mn = min(ld, rd, td, bd) From 6ad1d752fe3da2737853171742546b08eacba5c0 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Wed, 3 Feb 2021 10:40:51 +0800 Subject: [PATCH 3/4] use QKeySequence to detect platform dependent copy keys --- pyqtgraph/widgets/TableWidget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqtgraph/widgets/TableWidget.py b/pyqtgraph/widgets/TableWidget.py index 194b23f9..2e91ec7e 100644 --- a/pyqtgraph/widgets/TableWidget.py +++ b/pyqtgraph/widgets/TableWidget.py @@ -368,7 +368,7 @@ class TableWidget(QtGui.QTableWidget): self.contextMenu.popup(ev.globalPos()) 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() self.copySel() else: From a1f9100ef1854c9be52e411e7f93b2a0484ef7cb Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 14 Feb 2021 07:56:05 +0800 Subject: [PATCH 4/4] shim only the keys we actually use --- pyqtgraph/Qt.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyqtgraph/Qt.py b/pyqtgraph/Qt.py index 63d9eee5..6e0610ce 100644 --- a/pyqtgraph/Qt.py +++ b/pyqtgraph/Qt.py @@ -425,7 +425,10 @@ if QT_LIB == PYQT6: # QKeyEvent::key() returns an int # so comparison with a Key_* enum will always be False # 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) # shim the old names for QPointF mouse coords