Skip to content

Commit

Permalink
add QEvent.ignore where an event is captured but not used; closes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
RazinShaikh committed Jul 8, 2024
1 parent 1782340 commit 2a1d542
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion zxlive/graphview.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def mousePressEvent(self, e: QMouseEvent) -> None:
self.wand_path.show()
if self.sparkle_mode:
self.sparkles.emit_sparkles(pos, 10)
else:
e.ignore()
else:
e.ignore()

Expand Down Expand Up @@ -165,7 +167,8 @@ def mouseMoveEvent(self, e: QMouseEvent) -> None:
if item not in self.wand_trace.hit:
self.wand_trace.hit[item] = []
self.wand_trace.hit[item].append(ipos)

else:
e.ignore()
else:
e.ignore()

Expand Down Expand Up @@ -200,6 +203,8 @@ def mouseReleaseEvent(self, e: QMouseEvent) -> None:
self.wand_path = None
self.wand_trace_finished.emit(self.wand_trace)
self.wand_trace = None
else:
e.ignore()
else:
e.ignore()

Expand Down Expand Up @@ -364,6 +369,7 @@ def emit_sparkles(self, pos: QPointF, mult: int) -> None:

def timerEvent(self, event: QTimerEvent) -> None:
if event.timerId() != self.timer_id:
event.ignore()
return
for sparkle in self.sparkles:
sparkle.timer_step()
Expand Down
12 changes: 8 additions & 4 deletions zxlive/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,16 @@ def closeEvent(self, e: QCloseEvent) -> None:
self.settings.setValue("main_window_geometry", self.saveGeometry())
e.accept()

def undo(self,e: QEvent) -> None:
if self.active_panel is None: return
def undo(self, e: QEvent) -> None:
if self.active_panel is None:
e.ignore()
return
self.active_panel.undo_stack.undo()

def redo(self,e: QEvent) -> None:
if self.active_panel is None: return
def redo(self, e: QEvent) -> None:
if self.active_panel is None:
e.ignore()
return
self.active_panel.undo_stack.redo()

def update_tab_name(self, clean:bool) -> None:
Expand Down
7 changes: 7 additions & 0 deletions zxlive/vitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def itemChange(self, change: QGraphicsItem.GraphicsItemChange, value: Any) -> An
def mouseDoubleClickEvent(self, e: QGraphicsSceneMouseEvent) -> None:
super().mouseDoubleClickEvent(e)
if self.is_animated:
e.ignore()
return
scene = self.scene()
if TYPE_CHECKING: assert isinstance(scene, GraphScene)
Expand All @@ -268,12 +269,14 @@ def mouseDoubleClickEvent(self, e: QGraphicsSceneMouseEvent) -> None:
def mousePressEvent(self, e: QGraphicsSceneMouseEvent) -> None:
super().mousePressEvent(e)
if self.is_animated:
e.ignore()
return
self._old_pos = self.pos()

def mouseMoveEvent(self, e: QGraphicsSceneMouseEvent) -> None:
super().mouseMoveEvent(e)
if self.is_animated:
e.ignore()
return
scene = self.scene()
if TYPE_CHECKING: assert isinstance(scene, GraphScene)
Expand All @@ -287,6 +290,7 @@ def mouseMoveEvent(self, e: QGraphicsSceneMouseEvent) -> None:
elif self.is_dragging and self.ty == VertexType.W_INPUT:
w_out = get_w_partner_vitem(self)
if w_out is None:
e.ignore()
return
w_out.set_vitem_rotation()
if self.is_dragging and len(scene.selectedItems()) == 1:
Expand Down Expand Up @@ -316,6 +320,7 @@ def mouseReleaseEvent(self, e: QGraphicsSceneMouseEvent) -> None:
# manually detect mouse releases.
super().mouseReleaseEvent(e)
if self.is_animated:
e.ignore()
return
if e.button() == Qt.MouseButton.LeftButton:
if self._old_pos != self.pos():
Expand Down Expand Up @@ -343,6 +348,8 @@ def mouseReleaseEvent(self, e: QGraphicsSceneMouseEvent) -> None:
scene.vertices_moved.emit([(it.v, *pos_from_view(it.pos().x(), it.pos().y())) for it in moved_vertices])
self._dragged_on = None
self._old_pos = None
else:
e.ignore()
else:
e.ignore()

Expand Down

0 comments on commit 2a1d542

Please sign in to comment.