@@ -937,6 +937,7 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
937937 deleted_count : int = 0
938938
939939 selected = self .selected
940+ library_dir = unwrap (self .lib .library_dir )
940941
941942 if len (selected ) <= 1 and origin_path :
942943 origin_id_ = origin_id
@@ -945,7 +946,7 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
945946 origin_id_ = selected [0 ]
946947
947948 pending .append ((origin_id_ , Path (origin_path )))
948- elif ( len ( selected ) > 1 ) or ( len ( selected ) <= 1 ) :
949+ else :
949950 for item in selected :
950951 entry = self .lib .get_entry (item )
951952 filepath : Path = entry .path
@@ -962,39 +963,30 @@ def delete_files_callback(self, origin_path: str | Path, origin_id: int | None =
962963 e_id , f = tup
963964 if (origin_path == f ) or (not origin_path ):
964965 self .main_window .preview_panel .preview_thumb .media_player .stop ()
965- if delete_file (self .lib .library_dir / f ):
966- self .main_window .status_bar .showMessage (
967- Translations .format (
968- "status.deleting_file" , i = i , count = len (pending ), path = f
969- )
970- )
971- self .main_window .status_bar .repaint ()
972- self .lib .remove_entries ([e_id ])
973966
967+ msg = Translations .format (
968+ "status.deleting_file" , i = i , count = len (pending ), path = f
969+ )
970+ self .main_window .status_bar .showMessage (msg )
971+ self .main_window .status_bar .repaint ()
972+
973+ self .lib .remove_entries ([e_id ])
974+ if delete_file (library_dir / f ):
974975 deleted_count += 1
975- selected .clear ()
976- self .clear_select_action_callback ()
977-
978- if deleted_count > 0 :
979- self .update_browsing_state ()
980- self .main_window .preview_panel .set_selection (selected )
981-
982- if len (selected ) <= 1 and deleted_count == 0 :
983- self .main_window .status_bar .showMessage (Translations ["status.deleted_none" ])
984- elif len (selected ) <= 1 and deleted_count == 1 :
985- self .main_window .status_bar .showMessage (
986- Translations .format ("status.deleted_file_plural" , count = deleted_count )
987- )
988- elif len (selected ) > 1 and deleted_count == 0 :
989- self .main_window .status_bar .showMessage (Translations ["status.deleted_none" ])
990- elif len (selected ) > 1 and deleted_count < len (selected ):
991- self .main_window .status_bar .showMessage (
992- Translations .format ("status.deleted_partial_warning" , count = deleted_count )
993- )
994- elif len (selected ) > 1 and deleted_count == len (selected ):
995- self .main_window .status_bar .showMessage (
996- Translations .format ("status.deleted_file_plural" , count = deleted_count )
997- )
976+
977+ self .clear_select_action_callback ()
978+ self .update_browsing_state ()
979+
980+ if deleted_count > 0 and deleted_count != len (pending ):
981+ msg = Translations .format ("status.deleted_partial_warning" , count = deleted_count )
982+ else :
983+ index = min (deleted_count , 2 )
984+ msg = (
985+ Translations ["status.deleted_none" ],
986+ Translations ["status.deleted_file_singular" ],
987+ Translations .format ("status.deleted_file_plural" , count = deleted_count ),
988+ )[index ]
989+ self .main_window .status_bar .showMessage (msg )
998990 self .main_window .status_bar .repaint ()
999991
1000992 def delete_file_confirmation (self , count : int , filename : Path | None = None ) -> int :
0 commit comments