Skip to content

Commit

Permalink
Explicitly accept() more events, use menu.popup()
Browse files Browse the repository at this point in the history
Accept more events
  • Loading branch information
ferdnyc committed Oct 23, 2020
1 parent 2a4d895 commit 6c7f07e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/windows/cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ def close(self):
log.info('close')

def closeEvent(self, event):
log.info('closeEvent')
log.debug('closeEvent')
event.accept()

# Stop playback
self.preview_parent.worker.Stop()
Expand Down
12 changes: 8 additions & 4 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,9 +811,13 @@ def promptImageSequence(self, filename=None):
return False

# Get translations
_ = get_app()._tr
app = get_app()
_ = app._tr

# Process the event queue first, since we've been ignoring input
app.processEvents()

# Handle exception
# Display prompt dialog
ret = QMessageBox.question(
self,
_("Import Image Sequence"),
Expand Down Expand Up @@ -1541,6 +1545,7 @@ def keyPressEvent(self, event):
return

# A valid keysequence was detected
event.accept()
key = QKeySequence(modifiers + key_value)

# Get the video player object
Expand Down Expand Up @@ -1646,7 +1651,6 @@ def keyPressEvent(self, event):
elif key.matches(self.getShortcutByName("actionAnimatedTitle")) == QKeySequence.ExactMatch:
self.actionAnimatedTitle.trigger()
elif key.matches(self.getShortcutByName("actionDuplicateTitle")) == QKeySequence.ExactMatch:
log.info("Duplicating title, %s", event)
self.actionDuplicateTitle.trigger()
elif key.matches(self.getShortcutByName("actionEditTitle")) == QKeySequence.ExactMatch:
self.actionEditTitle.trigger()
Expand Down Expand Up @@ -1750,7 +1754,7 @@ def keyPressEvent(self, event):

# If we didn't act on the event, forward it to the base class
else:
super(MainWindow, self).keyPressEvent(event)
QMainWindow.keyPressEvent(self, event)

def actionProfile_trigger(self):
# Show dialog
Expand Down
6 changes: 6 additions & 0 deletions src/windows/video_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def changed(self, action):

def paintEvent(self, event, *args):
""" Custom paint event """
event.accept()
self.mutex.lock()

# Paint custom frame image on QWidget
Expand Down Expand Up @@ -309,6 +310,7 @@ def connectSignals(self, renderer):

def mousePressEvent(self, event):
"""Capture mouse press event on video preview window"""
event.accept()
self.mouse_pressed = True
self.mouse_dragging = False
self.mouse_position = event.pos()
Expand All @@ -318,6 +320,7 @@ def mousePressEvent(self, event):
get_app().updates.ignore_history = True

def mouseReleaseEvent(self, event):
event.accept()
"""Capture mouse release event on video preview window"""
self.mouse_pressed = False
self.mouse_dragging = False
Expand All @@ -342,6 +345,7 @@ def rotateCursor(self, pixmap, rotation, shear_x, shear_y):
def mouseMoveEvent(self, event):
"""Capture mouse events on video preview window """
self.mutex.lock()
event.accept()

if self.mouse_pressed:
self.mouse_dragging = True
Expand Down Expand Up @@ -697,6 +701,7 @@ def transformTriggered(self, clip_id):

def resizeEvent(self, event):
"""Widget resize event"""
event.accept()
self.delayed_size = self.size()
self.delayed_resize_timer.start()

Expand All @@ -722,6 +727,7 @@ def delayed_resize_callback(self):

# Capture wheel event to alter zoom/scale of widget
def wheelEvent(self, event):
event.accept()
# For each 120 (standard scroll unit) adjust the zoom slider
tick_scale = 1024
self.zoom += event.angleDelta().y() / tick_scale
Expand Down
2 changes: 1 addition & 1 deletion src/windows/views/effects_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def contextMenuEvent(self, event):

menu = QMenu(self)
menu.addAction(self.win.actionDetailsView)
menu.exec_(event.globalPos())
menu.popup(event.globalPos())

def startDrag(self, event):
""" Override startDrag method to display custom icon """
Expand Down
5 changes: 3 additions & 2 deletions src/windows/views/effects_treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ class EffectsTreeView(QTreeView):

def contextMenuEvent(self, event):
# Set context menu mode
event.accept()
app = get_app()
app.context_menu_object = "effects"

menu = QMenu(self)
menu.addAction(self.win.actionThumbnailView)
menu.exec_(event.globalPos())
menu.popup(event.globalPos())

def startDrag(self, event):
def startDrag(self, supportedActions):
""" Override startDrag method to display custom icon """

# Get first column indexes for all selected rows
Expand Down
13 changes: 8 additions & 5 deletions src/windows/views/files_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class FilesListView(QListView):
drag_item_size = 48

def contextMenuEvent(self, event):
event.accept()

# Set context menu mode
app = get_app()
Expand Down Expand Up @@ -80,13 +81,15 @@ def contextMenuEvent(self, event):
menu.addSeparator()

# Show menu
menu.exec_(event.globalPos())
menu.popup(event.globalPos())

def dragEnterEvent(self, event):
# If dragging urls onto widget, accept
if event.mimeData().hasUrls():
event.setDropAction(Qt.CopyAction)
event.accept()
if not event.mimeData().hasUrls():
event.ignore()
return
event.accept()
event.setDropAction(Qt.CopyAction)

def startDrag(self, supportedActions):
""" Override startDrag method to display custom icon """
Expand Down Expand Up @@ -115,7 +118,7 @@ def startDrag(self, supportedActions):

# Without defining this method, the 'copy' action doesn't show with cursor
def dragMoveEvent(self, event):
pass
event.accept()

# Handle a drag and drop being dropped on widget
def dropEvent(self, event):
Expand Down
7 changes: 4 additions & 3 deletions src/windows/views/files_treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def contextMenuEvent(self, event):
app = get_app()
app.context_menu_object = "files"

event.accept()
index = self.indexAt(event.pos())

# Build menu
Expand Down Expand Up @@ -83,7 +84,7 @@ def contextMenuEvent(self, event):
menu.addSeparator()

# Show menu
menu.exec_(event.globalPos())
menu.popup(event.globalPos())

def dragEnterEvent(self, event):
# If dragging urls onto widget, accept
Expand Down Expand Up @@ -118,13 +119,13 @@ def startDrag(self, supportedActions):

# Without defining this method, the 'copy' action doesn't show with cursor
def dragMoveEvent(self, event):
pass
event.accept()

# Handle a drag and drop being dropped on widget
def dropEvent(self, event):
if not event.mimeData().hasUrls():
# Nothing we're interested in
event.reject()
event.ignore()
return
event.accept()
# Use try/finally so we always reset the cursor
Expand Down
5 changes: 4 additions & 1 deletion src/windows/views/properties_tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ def mouseMoveEvent(self, event):
if row is None:
return

event.accept()

if model.item(row, 0):
self.selected_label = model.item(row, 0)
self.selected_item = model.item(row, 1)
Expand Down Expand Up @@ -268,6 +270,7 @@ def mouseMoveEvent(self, event):

def mouseReleaseEvent(self, event):
# Inform UpdateManager to accept updates, and only store our final update
event.accept()
get_app().updates.ignore_history = False

# Add final update to undo/redo history
Expand Down Expand Up @@ -500,7 +503,7 @@ def contextMenuEvent(self, event=None, release=False):
Insert_Action.triggered.connect(self.Insert_Action_Triggered)
Remove_Action = menu.addAction(_("Remove Keyframe"))
Remove_Action.triggered.connect(self.Remove_Action_Triggered)
menu.popup(QCursor.pos())
menu.popup(event.globalPos())

# Menu for choices
if not self.choices:
Expand Down
7 changes: 3 additions & 4 deletions src/windows/views/transitions_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ class TransitionsListView(QListView):
drag_item_size = 48

def contextMenuEvent(self, event):
event.accept()

# Set context menu mode
app = get_app()
app.context_menu_object = "transitions"

menu = QMenu(self)
menu.addAction(self.win.actionDetailsView)
menu.exec_(event.globalPos())

# Ignore event, propagate to parent
event.ignore()
menu.popup(event.globalPos())

def startDrag(self, supportedActions):
""" Override startDrag method to display custom icon """
Expand Down
2 changes: 1 addition & 1 deletion src/windows/views/transitions_treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def contextMenuEvent(self, event):

menu = QMenu(self)
menu.addAction(self.win.actionThumbnailView)
menu.exec_(event.globalPos())
menu.popup(event.globalPos())

def startDrag(self, event):
""" Override startDrag method to display custom icon """
Expand Down

0 comments on commit 6c7f07e

Please sign in to comment.