mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
Don't show parent window's context menu on viewers
* When right clicking on image viewers while they are docked, the context menu of the Results window showed up. * This also enables capture of right click and middle click buttons to drag around images, which solves a conflict with some theme engines that enable left mouse button click to drag a window's position regardless of where the event happens, hence blocking the panning. * Probably unnecessary to check which button is released.
This commit is contained in:
parent
089f00adb8
commit
b8af2a4eb5
@ -758,11 +758,15 @@ class QWidgetImageViewer(QWidget):
|
|||||||
return
|
return
|
||||||
self.disconnectMouseSignals()
|
self.disconnectMouseSignals()
|
||||||
|
|
||||||
|
def contextMenuEvent(self, event):
|
||||||
|
"""Block parent's (main window) context menu on right click."""
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self.bestFit or not self.isEnabled():
|
if self.bestFit or not self.isEnabled():
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() & (Qt.LeftButton | Qt.MidButton | Qt.RightButton):
|
||||||
self._drag = True
|
self._drag = True
|
||||||
else:
|
else:
|
||||||
self._drag = False
|
self._drag = False
|
||||||
@ -790,7 +794,7 @@ class QWidgetImageViewer(QWidget):
|
|||||||
if self.bestFit or not self.isEnabled():
|
if self.bestFit or not self.isEnabled():
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
# if event.button() == Qt.LeftButton:
|
||||||
self._drag = False
|
self._drag = False
|
||||||
|
|
||||||
self._app.restoreOverrideCursor()
|
self._app.restoreOverrideCursor()
|
||||||
@ -956,11 +960,18 @@ class ScrollAreaImageViewer(QScrollArea):
|
|||||||
self._horizontalScrollBar.valueChanged.connect(
|
self._horizontalScrollBar.valueChanged.connect(
|
||||||
self.controller.onHScrollBarChanged, Qt.UniqueConnection)
|
self.controller.onHScrollBarChanged, Qt.UniqueConnection)
|
||||||
|
|
||||||
|
def contextMenuEvent(self, event):
|
||||||
|
"""Block parent's (main window) context menu on right click."""
|
||||||
|
# Even though we don't have a context menu right now, and the default
|
||||||
|
# contextMenuPolicy is DefaultContextMenu, we leverage that handler to
|
||||||
|
# avoid raising the Result window's Actions menu
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self.bestFit:
|
if self.bestFit:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() & (Qt.LeftButton | Qt.MidButton | Qt.RightButton):
|
||||||
self._drag = True
|
self._drag = True
|
||||||
else:
|
else:
|
||||||
self._drag = False
|
self._drag = False
|
||||||
@ -985,7 +996,6 @@ class ScrollAreaImageViewer(QScrollArea):
|
|||||||
if self.bestFit:
|
if self.bestFit:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
|
||||||
self._drag = False
|
self._drag = False
|
||||||
self._app.restoreOverrideCursor()
|
self._app.restoreOverrideCursor()
|
||||||
self.setMouseTracking(False)
|
self.setMouseTracking(False)
|
||||||
@ -1203,11 +1213,15 @@ class GraphicsViewViewer(QGraphicsView):
|
|||||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
|
||||||
|
|
||||||
|
def contextMenuEvent(self, event):
|
||||||
|
"""Block parent's (main window) context menu on right click."""
|
||||||
|
event.accept()
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
if self.bestFit:
|
if self.bestFit:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
if event.button() & (Qt.LeftButton | Qt.MidButton | Qt.RightButton):
|
||||||
self._drag = True
|
self._drag = True
|
||||||
else:
|
else:
|
||||||
self._drag = False
|
self._drag = False
|
||||||
@ -1223,7 +1237,6 @@ class GraphicsViewViewer(QGraphicsView):
|
|||||||
if self.bestFit:
|
if self.bestFit:
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
if event.button() == Qt.LeftButton:
|
|
||||||
self._drag = False
|
self._drag = False
|
||||||
self._app.restoreOverrideCursor()
|
self._app.restoreOverrideCursor()
|
||||||
self.setMouseTracking(False)
|
self.setMouseTracking(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user