@@ -899,6 +899,7 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
899899 deleted_count : int = 0
900900
901901 selected = self .selected
902+ library_dir = unwrap (self .lib .library_dir )
902903
903904 if len (selected ) <= 1 and origin_path :
904905 origin_id_ = origin_id
@@ -907,7 +908,7 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
907908 origin_id_ = selected [0 ]
908909
909910 pending .append ((origin_id_ , Path (origin_path )))
910- elif ( len ( selected ) > 1 ) or ( len ( selected ) <= 1 ) :
911+ else :
911912 for item in selected :
912913 entry = self .lib .get_entry (item )
913914 filepath : Path = entry .path
@@ -924,39 +925,30 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
924925 e_id , f = tup
925926 if (origin_path == f ) or (not origin_path ):
926927 self .main_window .preview_panel .preview_thumb .media_player .stop ()
927- if delete_file (self .lib .library_dir / f ):
928- self .main_window .status_bar .showMessage (
929- Translations .format (
930- "status.deleting_file" , i = i , count = len (pending ), path = f
931- )
932- )
933- self .main_window .status_bar .repaint ()
934- self .lib .remove_entries ([e_id ])
935928
929+ msg = Translations .format (
930+ "status.deleting_file" , i = i , count = len (pending ), path = f
931+ )
932+ self .main_window .status_bar .showMessage (msg )
933+ self .main_window .status_bar .repaint ()
934+
935+ self .lib .remove_entries ([e_id ])
936+ if delete_file (library_dir / f ):
936937 deleted_count += 1
937- selected .clear ()
938- self .clear_select_action_callback ()
939-
940- if deleted_count > 0 :
941- self .update_browsing_state ()
942- self .main_window .preview_panel .set_selection (selected )
943-
944- if len (selected ) <= 1 and deleted_count == 0 :
945- self .main_window .status_bar .showMessage (Translations ["status.deleted_none" ])
946- elif len (selected ) <= 1 and deleted_count == 1 :
947- self .main_window .status_bar .showMessage (
948- Translations .format ("status.deleted_file_plural" , count = deleted_count )
949- )
950- elif len (selected ) > 1 and deleted_count == 0 :
951- self .main_window .status_bar .showMessage (Translations ["status.deleted_none" ])
952- elif len (selected ) > 1 and deleted_count < len (selected ):
953- self .main_window .status_bar .showMessage (
954- Translations .format ("status.deleted_partial_warning" , count = deleted_count )
955- )
956- elif len (selected ) > 1 and deleted_count == len (selected ):
957- self .main_window .status_bar .showMessage (
958- Translations .format ("status.deleted_file_plural" , count = deleted_count )
959- )
938+
939+ self .clear_select_action_callback ()
940+ self .update_browsing_state ()
941+
942+ if deleted_count > 0 and deleted_count != len (pending ):
943+ msg = Translations .format ("status.deleted_partial_warning" , count = deleted_count )
944+ else :
945+ index = min (deleted_count , 2 )
946+ msg = (
947+ Translations ["status.deleted_none" ],
948+ Translations ["status.deleted_file_singular" ],
949+ Translations .format ("status.deleted_file_plural" , count = deleted_count ),
950+ )[index ]
951+ self .main_window .status_bar .showMessage (msg )
960952 self .main_window .status_bar .repaint ()
961953
962954 def delete_file_confirmation (self , count : int , filename : Path | None = None ) -> int :
0 commit comments