@@ -383,80 +383,84 @@ def delete_file(self):
383383 elif platform == "linux" :
384384 command = ["gio" , "trash" , selected_file ]
385385 elif platform == "win32" or platform == "cygwin" :
386- command = ["echo" ,
387- f"(new-object -comobject Shell.Application).Namespace(0).ParseName(\" { selected_file } \" )"
388- f".InvokeVerb(\" delete\" )" , "|" , "powershell" , "-command" , "-" ]
386+ command = (f"echo (new-object -comobject Shell.Application).Namespace(0).ParseName('{ selected_file } ')"
387+ f".InvokeVerb('delete') | powershell -command -" )
389388 else :
390389 command = None
390+
391391 # Moving the file to trash, after asking if necessary
392- if FF_Additional_UI .PopUps .show_delete_question (self .parent , selected_file ):
392+ if not FF_Additional_UI .PopUps .show_delete_question (self .parent , selected_file ):
393+ return
393394
394- try :
395- # Try to move the file to trash and add a date for uniqueness
395+ try :
396+ # Try to move the file to trash in an operating system specific way
397+ if platform == "win32" or platform == "cygwin" :
398+ subprocess .run (command , check = True , shell = True )
399+ else :
396400 subprocess .run (command , check = True )
397401
398- except (subprocess .CalledProcessError , FileNotFoundError ):
399-
400- # Error message
401- FF_Additional_UI .PopUps .show_critical_messagebox (
402- "Error!" , f"File not found: { selected_file } " , self .parent )
403-
404- # Debug
405- logging .error (f"File not found: { selected_file } " )
402+ except (subprocess .CalledProcessError , FileNotFoundError ):
406403
407- # If everything ran successful
408- else :
409- # Debug
410- logging .debug (f"Moved { selected_file } to trash" )
404+ # Error message
405+ FF_Additional_UI .PopUps .show_critical_messagebox (
406+ "Error!" , f"File not found: { selected_file } " , self .parent )
411407
412- if self .window == "compare" or self .window == "search" :
408+ # Debug
409+ logging .error (f"File not found: { selected_file } " )
413410
414- # Set the icon
415- icon = FF_Additional_UI .UIIcon (
416- os .path .join (FF_Files .ASSETS_FOLDER , "trash_icon_small.png" ),
417- icon_set_func = self .get_listbox ().item (self .get_listbox ().currentRow ()).setIcon ,
418- turn_auto = False )
411+ # If everything ran successful
412+ else :
413+ # Debug
414+ logging .debug (f"Moved { selected_file } to trash" )
419415
420- icon . turn_dark ()
416+ if self . window == "compare" or self . window == "search" :
421417
422- # Change the color to red
423- self . get_listbox (). item (
424- self . get_listbox (). currentRow ()). setBackground ( QColor ( FF_Files .RED_DARK_THEME_COLOR ))
425- # Change font color to white
426- self . get_listbox (). item ( self . get_listbox (). currentRow ()). setForeground ( QColor ( "white" ) )
418+ # Set the icon
419+ icon = FF_Additional_UI . UIIcon (
420+ os . path . join ( FF_Files .ASSETS_FOLDER , "trash_icon_small.png" ),
421+ icon_set_func = self . get_listbox (). item ( self . get_listbox (). currentRow ()). setIcon ,
422+ turn_auto = False )
427423
428- # Change font to italic
429- font = self .get_listbox ().item (self .get_listbox ().currentRow ()).font ()
430- font .setItalic (True )
431- self .get_listbox ().item (self .get_listbox ().currentRow ()).setFont (font )
424+ icon .turn_dark ()
432425
433- # QTreeWidget needs special treatment
434- elif self .window == "duplicated" :
435- # Icon
436- # Set the icon
437- icon = FF_Additional_UI .UIIcon (
438- os .path .join (FF_Files .ASSETS_FOLDER , "trash_icon_small.png" ),
439- icon_set_func = lambda x : self .get_listbox ().currentItem ().setIcon (0 , x ),
440- turn_auto = False )
426+ # Change the color to red
427+ self .get_listbox ().item (
428+ self .get_listbox ().currentRow ()).setBackground (QColor (FF_Files .RED_DARK_THEME_COLOR ))
429+ # Change font color to white
430+ self .get_listbox ().item (self .get_listbox ().currentRow ()).setForeground (QColor ("white" ))
441431
442- icon .turn_dark ()
432+ # Change font to italic
433+ font = self .get_listbox ().item (self .get_listbox ().currentRow ()).font ()
434+ font .setItalic (True )
435+ self .get_listbox ().item (self .get_listbox ().currentRow ()).setFont (font )
443436
444- # Change the color to red
445- self .get_listbox ().currentItem ().setBackground (0 , QColor (FF_Files .RED_LIGHT_THEME_COLOR ))
446- self .get_listbox ().currentItem ().setBackground (1 , QColor (FF_Files .RED_LIGHT_THEME_COLOR ))
447- # Change font color to white
448- self .get_listbox ().currentItem ().setForeground (0 , QColor ("white" ))
449- self .get_listbox ().currentItem ().setForeground (1 , QColor ("white" ))
437+ # QTreeWidget needs special treatment
438+ elif self .window == "duplicated" :
439+ # Icon
440+ # Set the icon
441+ icon = FF_Additional_UI .UIIcon (
442+ os .path .join (FF_Files .ASSETS_FOLDER , "trash_icon_small.png" ),
443+ icon_set_func = lambda x : self .get_listbox ().currentItem ().setIcon (0 , x ),
444+ turn_auto = False )
445+
446+ icon .turn_dark ()
447+
448+ # Change the color to red
449+ self .get_listbox ().currentItem ().setBackground (0 , QColor (FF_Files .RED_LIGHT_THEME_COLOR ))
450+ self .get_listbox ().currentItem ().setBackground (1 , QColor (FF_Files .RED_LIGHT_THEME_COLOR ))
451+ # Change font color to white
452+ self .get_listbox ().currentItem ().setForeground (0 , QColor ("white" ))
453+ self .get_listbox ().currentItem ().setForeground (1 , QColor ("white" ))
450454
451- # Change font to italic
452- font = self .get_listbox ().currentItem ().font (0 )
453- font .setItalic (True )
454- self .get_listbox ().currentItem ().setFont (0 , font )
455- self .get_listbox ().currentItem ().setFont (1 , font )
455+ # Change font to italic
456+ font = self .get_listbox ().currentItem ().font (0 )
457+ font .setItalic (True )
458+ self .get_listbox ().currentItem ().setFont (0 , font )
459+ self .get_listbox ().currentItem ().setFont (1 , font )
456460
457- # Removing file from cache
458- logging .info ("Removing file from cache..." )
459- self .remove_file_from_cache (selected_file )
461+ # Removing file from cache
462+ logging .info ("Removing file from cache..." )
463+ self .remove_file_from_cache (selected_file )
460464
461465 # Marks a file
462466 def mark_file (self , color , selected_file = None ):
@@ -646,11 +650,9 @@ def open_in_finder(self):
646650 # Opening the file, the specific command depends on the platform
647651 if platform == "darwin" :
648652 # Collecting the return code
649- return_code = run (["open" ,
650- "-R" ,
651- selected_file ]).returncode
653+ return_code = run (["open" , "-R" , selected_file ]).returncode
652654 elif platform == "win32" or platform == "cygwin" :
653- return_code = run (["start " , os . path . dirname ( selected_file ) ], shell = True ).returncode
655+ return_code = run (["explorer " , "/select" , selected_file ], shell = True ).returncode
654656 elif platform == "linux" :
655657 return_code = run (["xdg-open" , os .path .dirname (selected_file )]).returncode
656658
0 commit comments