@@ -509,7 +509,7 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
509509 self .buttonTrimEnd .contextMenuEvent = self .trimButtonContextMenuEvent
510510 self .buttonExploreMediaPath .contextMenuEvent = self .openMediaLocationButtonContextMenuEvent
511511 self .buttonMarkDeleted .contextMenuEvent = self .buttonMarkDeletedContextMenuEvent
512- self .buttonSnapshot .contextMenuEvent = lambda event : self .menuSnapshots . exec ( event . globalPos ())
512+ self .buttonSnapshot .contextMenuEvent = self .buttonSnapshotContextMenuEvent
513513 self .menuRecent .contextMenuEvent = self .menuRecentContextMenuEvent
514514 self .buttonLoop .setIcon (self .icons ['loop' ])
515515 self .buttonAutoplay .setIcon (self .icons ['autoplay' ])
@@ -866,16 +866,18 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
866866
867867
868868 def pauseButtonContextMenuEvent (self , event : QtGui .QContextMenuEvent ): # should these use QWidget.actions() instead of contextMenuEvent?
869+ ''' Handles the context (right-click) menu for the pause button. '''
869870 context = QtW .QMenu (self )
870871 context .addAction (self .actionStop )
871872 context .addAction ('Restart' , set_and_update_progress ) # TODO this might have timing issues with update_thread
872873 context .exec (event .globalPos ())
873874
874875
875876 def trimButtonContextMenuEvent (self , event : QtGui .QContextMenuEvent ):
876- ''' Handles creating the context (right-click) menu for the start/end trim buttons. Includes
877- the fade-mode menu, actions for instantly setting new start/end positions, and disabled
878- (grayed out) actions containing information about the current start/end positions. '''
877+ ''' Handles the context (right-click) menu for the start/end
878+ trim buttons. Includes the fade-mode menu, actions for
879+ instantly setting new start/end positions, and disabled
880+ actions displaying information about the current trim. '''
879881 is_trim_mode = self .is_trim_mode ()
880882 show_length_label = is_trim_mode and self .minimum or self .maximum != self .frame_count
881883
@@ -929,7 +931,7 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
929931
930932
931933 def openMediaLocationButtonContextMenuEvent (self , event : QtGui .QContextMenuEvent ):
932- ''' Handles creating the context (right-click) menu for the open media location button. '''
934+ ''' Handles the context (right-click) menu for the open media location button. '''
933935 if not self .video : return # do not render context menu if no media is playing
934936 context = QtW .QMenu (self )
935937 context .addAction (self .actionExploreMediaPath )
@@ -938,7 +940,7 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
938940
939941
940942 def buttonMarkDeletedContextMenuEvent (self , event : QtGui .QContextMenuEvent ): # should these use QWidget.actions() instead of contextMenuEvent?
941- ''' Handles creating the context (right-click) menu for buttonMarkDeleted. '''
943+ ''' Handles the context (right-click) menu for buttonMarkDeleted. '''
942944 context = QtW .QMenu (self )
943945 context .setToolTipsVisible (True )
944946 context .addAction (self .actionMarkDeleted )
@@ -949,8 +951,16 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
949951 context .exec (event .globalPos ())
950952
951953
954+ def buttonSnapshotContextMenuEvent (self , event ):
955+ ''' Handles the context (right-click) menu for the snapshot button.
956+ Side note: PyQt does NOT like it if you do QMenu.exec() in a
957+ lambda. As soon as it returns, you get: `TypeError: invalid
958+ argument to sipBadCatcherResult()`. And it's uncatchable. '''
959+ self .menuSnapshots .exec (event .globalPos ())
960+
961+
952962 def menuRecentContextMenuEvent (self , event : QtGui .QContextMenuEvent ):
953- ''' Handles creating the context (right-click) menus for individual recent files. '''
963+ ''' Handles the context (right-click) menus for individual recent files. '''
954964 action = self .menuRecent .actionAt (event .pos ())
955965 if action is self .actionClearRecent or not action : return
956966 path = action .toolTip ()
@@ -1753,7 +1763,7 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
17531763 self .log ('There are no remaining files to play.' )
17541764
17551765 recycle = self .dialog_settings .checkRecycleBin .isChecked ()
1756- verb = 'recycl' if recycle else 'delet'
1766+ verb = 'recycl' if recycle else 'delet' # we're appending "ing" to these words
17571767 if recycle : import send2trash
17581768 logging .info (f'{ verb .capitalize ()} ing { len (files )} files...' )
17591769
@@ -1762,12 +1772,12 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
17621772 send2trash .send2trash (file ) if recycle else os .remove (file )
17631773 logging .info (f'File { file } { verb } ed successfully.' )
17641774 except Exception as error : self .log (f'File could not be deleted: { file } - { error } ' )
1765- if not os .path .exists (file ): # if file doesn't exist, unmark file (even if error occurred)
1775+ if not os .path .exists (file ): # if file doesn't exist, unmark file (even if error occurred)
17661776 if file in self .recent_files : self .recent_files .remove (file )
17671777 if file in self .marked_for_deletion : self .marked_for_deletion .remove (file )
17681778
17691779
1770- def snapshot (self , * args , mode = None ): # uses libvlc_video_take_snapshot. *args to capture unused signal args
1780+ def snapshot (self , * args , mode = None ): # *args to capture unused signal args
17711781 ''' libvlc_video_take_snapshot's docstring: TODO: add a real docstring here
17721782 "Take a snapshot of the current video window. If `i_width` AND `i_height` is 0, original
17731783 size is used. If `i_width` XOR `i_height` is 0, original aspect-ratio is preserved."
@@ -3460,10 +3470,10 @@ class GUI_Instance(QtW.QMainWindow, Ui_MainWindow):
34603470 ''' Saves image at `path` as a JPEG file with the desired quality in the settings
34613471 dialog, using PIL. Assumes that `path` already ends in a valid file-extension. '''
34623472 jpeg_quality = self .dialog_settings .spinSnapshotJpegQuality .value ()
3463- self .log (f'Saving JPEG snapshot at { jpeg_quality } % quality to { path } .' )
34643473 if image_data is None :
34653474 with get_PIL_Image ().open (path ) as image :
3466- self .convert_snapshot_to_jpeg (path , image )
3475+ return self .convert_snapshot_to_jpeg (path , image )
3476+ self .log (f'Saving JPEG snapshot at { jpeg_quality } % quality to { path } .' )
34673477 image_data .convert ('RGB' )
34683478 image_data .save (path , quality = jpeg_quality )
34693479
0 commit comments