Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
7174Andy committed Dec 20, 2024
1 parent 4d50c87 commit 7acd5b7
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions sleap/gui/widgets/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -2126,19 +2126,17 @@ def hoverLeaveEvent(self, event):
return super().hoverLeaveEvent(event)

def mousePressEvent(self, event):
"""Custom event handler to emit signal on event."""
if event.buttons() == Qt.LeftButton:
if event.modifiers() == Qt.ControlModifier:
self._duplicate_instance(event)
self._duplicate_instance()

def _duplicate_instance(self, event):
def _duplicate_instance(self):
"""Duplicate the instance and add it to the scene."""
scene = self.scene()

# Add instance to the context
context = self.player.context
context.newInstance(copy_instance=self.instance)

# Find the new instance and its last label
lf = context.labels.find(
context.state["video"], context.state["frame_idx"], return_new=True
)[0]
Expand All @@ -2163,7 +2161,6 @@ def on_selection_update():
# Optionally grab the mouse and change cursor, so user can immediately drag
qt_inst.setCursor(Qt.ClosedHandCursor)
qt_inst.grabMouse()
qt_inst.updateBox()
break

self.player.view.updatedSelection.connect(on_selection_update)
Expand All @@ -2181,7 +2178,6 @@ def mouseReleaseEvent(self, event):
"""Custom event handler to emit signal on event."""
if self.flags() & QGraphicsItem.ItemIsMovable:
self.setFlag(QGraphicsItem.ItemIsMovable, False)
self.setCursor(Qt.ArrowCursor)
self.updatePoints(user_change=True)
self.updateBox()
self.ungrabMouse()
Expand Down

0 comments on commit 7acd5b7

Please sign in to comment.