From f7ccb5bcfb6b9f87f18d01e7f23f9e4ca8055ff7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 24 Sep 2020 03:43:53 +0100 Subject: [PATCH] Allow to use canvas cut operations without prior window focus Fixes #1176 Signed-off-by: falkTX --- source/frontend/patchcanvas/scene.py | 4 ++++ source/frontend/widgets/draggablegraphicsview.py | 14 +------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/source/frontend/patchcanvas/scene.py b/source/frontend/patchcanvas/scene.py index e7b26724f..2761350c1 100644 --- a/source/frontend/patchcanvas/scene.py +++ b/source/frontend/patchcanvas/scene.py @@ -280,6 +280,10 @@ class PatchScene(QGraphicsScene): ) self.m_mouse_rubberband = False + # FIXME stop using self.m_ctrl_down + if event.modifiers() & Qt.ControlModifier: + self.m_ctrl_down = True + if event.button() == Qt.MidButton and self.m_ctrl_down: self.m_mid_button_down = True self.startConnectionCut() diff --git a/source/frontend/widgets/draggablegraphicsview.py b/source/frontend/widgets/draggablegraphicsview.py index d06c941d6..212c20e19 100644 --- a/source/frontend/widgets/draggablegraphicsview.py +++ b/source/frontend/widgets/draggablegraphicsview.py @@ -36,7 +36,6 @@ class DraggableGraphicsView(QGraphicsView): QGraphicsView.__init__(self, parent) self.fPanning = False - self.fCtrlDown = False try: self.fMiddleButton = Qt.MiddleButton @@ -73,7 +72,6 @@ class DraggableGraphicsView(QGraphicsView): def dragEnterEvent(self, event): urls = event.mimeData().urls() - print(urls) for url in urls: if self.isDragUrlValid(url.toLocalFile()): @@ -116,7 +114,7 @@ class DraggableGraphicsView(QGraphicsView): # -------------------------------------------------------------------------------------------------------- def mousePressEvent(self, event): - if event.button() == self.fMiddleButton and not self.fCtrlDown: + if event.button() == self.fMiddleButton and not (event.modifiers() & Qt.ControlModifier): buttons = event.buttons() buttons &= ~self.fMiddleButton buttons |= Qt.LeftButton @@ -154,13 +152,3 @@ class DraggableGraphicsView(QGraphicsView): QGraphicsView.wheelEvent(self, event) # -------------------------------------------------------------------------------------------------------- - - def keyPressEvent(self, event): - if event.key() == Qt.Key_Control: - self.fCtrlDown = True - QGraphicsView.keyPressEvent(self, event) - - def keyReleaseEvent(self, event): - if event.key() == Qt.Key_Control: - self.fCtrlDown = False - QGraphicsView.keyReleaseEvent(self, event)