From 0577491eeed09c2ba96cf64e3a5c7d83d7bf5ab2 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sat, 13 Dec 2025 08:37:26 -0500 Subject: [PATCH] Fix drag-and-drop for Merge module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Merge module's ui.NewDroppable wrappers weren't receiving drop events because the window-level handleDrop function was intercepting them first. Added merge module handling to handleDrop function: - Accepts individual video files and adds them sequentially to merge clips - Accepts multiple files at once and processes all in order - Accepts folders and recursively finds all video files - Probes each video to get duration and metadata - Sets chapter names defaulting to filename - Auto-sets output path to "merged.mkv" once 2+ clips are added - Refreshes UI after each clip is added Now drag-and-drop works consistently across all modules (Convert, Compare, Inspect, Merge). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- main.go | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/main.go b/main.go index 80317e2..e245b79 100644 --- a/main.go +++ b/main.go @@ -6039,6 +6039,68 @@ func (s *appState) handleDrop(pos fyne.Position, items []fyne.URI) { return } + // If in merge module, handle multiple video files + if s.active == "merge" { + // Collect all video files from the dropped items + var videoPaths []string + for _, uri := range items { + if uri.Scheme() != "file" { + continue + } + path := uri.Path() + logging.Debug(logging.CatModule, "drop received path=%s", path) + + // Check if it's a directory + if info, err := os.Stat(path); err == nil && info.IsDir() { + logging.Debug(logging.CatModule, "processing directory: %s", path) + videos := s.findVideoFiles(path) + videoPaths = append(videoPaths, videos...) + } else if s.isVideoFile(path) { + videoPaths = append(videoPaths, path) + } + } + + if len(videoPaths) == 0 { + logging.Debug(logging.CatUI, "no valid video files in dropped items") + return + } + + // Add all videos to merge clips sequentially + go func() { + for _, path := range videoPaths { + src, err := probeVideo(path) + if err != nil { + logging.Debug(logging.CatModule, "failed to probe %s: %v", path, err) + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + dialog.ShowError(fmt.Errorf("failed to probe %s: %w", filepath.Base(path), err), s.window) + }, false) + continue + } + + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + s.mergeClips = append(s.mergeClips, mergeClip{ + Path: path, + Chapter: strings.TrimSuffix(filepath.Base(path), filepath.Ext(path)), + Duration: src.Duration, + }) + + // Set default output path if not set and we have at least 2 clips + if len(s.mergeClips) >= 2 && strings.TrimSpace(s.mergeOutput) == "" { + first := filepath.Dir(s.mergeClips[0].Path) + s.mergeOutput = filepath.Join(first, "merged.mkv") + } + + // Refresh the merge view to show the new clips + s.showMergeView() + }, false) + } + + logging.Debug(logging.CatModule, "added %d clips to merge list", len(videoPaths)) + }() + + return + } + // Other modules don't handle file drops yet logging.Debug(logging.CatUI, "drop ignored; module %s cannot handle files", s.active) }