feat(main.py): add overwrite and new file options for enter and shift+enter keys in video editor
This commit is contained in:
		@@ -1831,7 +1831,8 @@ class VideoEditor:
 | 
				
			|||||||
            if len(self.video_files) > 1:
 | 
					            if len(self.video_files) > 1:
 | 
				
			||||||
                print("  N: Next file")
 | 
					                print("  N: Next file")
 | 
				
			||||||
                print("  n: Previous file")
 | 
					                print("  n: Previous file")
 | 
				
			||||||
            print("  Enter: Save image")
 | 
					            print("  Enter: Save image (overwrites if '_edited_' in name)")
 | 
				
			||||||
 | 
					            print("  Shift+Enter: Save image as _edited_edited")
 | 
				
			||||||
            print("  Q/ESC: Quit")
 | 
					            print("  Q/ESC: Quit")
 | 
				
			||||||
            print()
 | 
					            print()
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
@@ -1862,7 +1863,8 @@ class VideoEditor:
 | 
				
			|||||||
            if len(self.video_files) > 1:
 | 
					            if len(self.video_files) > 1:
 | 
				
			||||||
                print("  N: Next video")
 | 
					                print("  N: Next video")
 | 
				
			||||||
                print("  n: Previous video")
 | 
					                print("  n: Previous video")
 | 
				
			||||||
            print("  Enter: Render video")
 | 
					            print("  Enter: Render video (overwrites if '_edited_' in name)")
 | 
				
			||||||
 | 
					            print("  Shift+Enter: Render video as _edited_edited")
 | 
				
			||||||
            print("  X: Cancel render")
 | 
					            print("  X: Cancel render")
 | 
				
			||||||
            print("  Q/ESC: Quit")
 | 
					            print("  Q/ESC: Quit")
 | 
				
			||||||
            print()
 | 
					            print()
 | 
				
			||||||
@@ -2007,11 +2009,11 @@ class VideoEditor:
 | 
				
			|||||||
                if len(self.video_files) > 1:
 | 
					                if len(self.video_files) > 1:
 | 
				
			||||||
                    self.next_video()
 | 
					                    self.next_video()
 | 
				
			||||||
            elif key == 13:  # Enter
 | 
					            elif key == 13:  # Enter
 | 
				
			||||||
                output_name = self._get_next_edited_filename(self.video_path)
 | 
					                # Only overwrite if file already contains "_edited_" in name
 | 
				
			||||||
                output_path = str(self.video_path.parent / output_name)
 | 
					                if "_edited_" in self.video_path.stem:
 | 
				
			||||||
 | 
					                    output_path = str(self.video_path)
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    # If we're overwriting the same file, use a temporary file first
 | 
					                    # If we're overwriting the same file, use a temporary file first
 | 
				
			||||||
                if output_name == self.video_path.name:
 | 
					 | 
				
			||||||
                    import tempfile
 | 
					                    import tempfile
 | 
				
			||||||
                    temp_dir = self.video_path.parent
 | 
					                    temp_dir = self.video_path.parent
 | 
				
			||||||
                    temp_fd, temp_path = tempfile.mkstemp(suffix=self.video_path.suffix, dir=temp_dir)
 | 
					                    temp_fd, temp_path = tempfile.mkstemp(suffix=self.video_path.suffix, dir=temp_dir)
 | 
				
			||||||
@@ -2045,7 +2047,22 @@ class VideoEditor:
 | 
				
			|||||||
                        if os.path.exists(temp_path):
 | 
					                        if os.path.exists(temp_path):
 | 
				
			||||||
                            os.remove(temp_path)
 | 
					                            os.remove(temp_path)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    # Normal case - render to new file
 | 
					                    print("Enter key only overwrites files with '_edited_' in the name. Use Shift+Enter to create new files.")
 | 
				
			||||||
 | 
					            elif key == ord("\r"):  # Shift+Enter (carriage return)
 | 
				
			||||||
 | 
					                # Create _edited_edited file
 | 
				
			||||||
 | 
					                directory = self.video_path.parent
 | 
				
			||||||
 | 
					                base_name = self.video_path.stem
 | 
				
			||||||
 | 
					                extension = self.video_path.suffix
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                # Create _edited_edited filename
 | 
				
			||||||
 | 
					                if "_edited_" in base_name:
 | 
				
			||||||
 | 
					                    # If already edited, create _edited_edited
 | 
				
			||||||
 | 
					                    new_name = f"{base_name}_edited{extension}"
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
 | 
					                    # If not edited, create _edited_edited
 | 
				
			||||||
 | 
					                    new_name = f"{base_name}_edited_edited{extension}"
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                output_path = str(directory / new_name)
 | 
				
			||||||
                success = self.render_video(output_path)
 | 
					                success = self.render_video(output_path)
 | 
				
			||||||
            elif key == ord("t"):
 | 
					            elif key == ord("t"):
 | 
				
			||||||
                # Marker looping only for videos
 | 
					                # Marker looping only for videos
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user