From 653e6721da8c8567517f1f0ee6312f9d221e241e Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Thu, 4 Dec 2025 03:03:19 -0500 Subject: [PATCH] Fix drag-and-drop to intelligently fill Compare slots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed issue where dragging single videos would overwrite existing data: Smart slot filling logic: - Single video dropped: Fills first empty slot (File 1 then File 2) - If both slots full: Shows dialog asking user to Clear first - Multiple videos dropped: Fills both slots (replaces existing) Behavior changes: 1. Drag first video → goes to slot 1 2. Drag second video → goes to slot 2 3. Drag third video → shows "Both Slots Full" message 4. Drag 2+ videos together → replaces both slots User experience improvements: - No more accidental overwrites when loading one at a time - Clear feedback when slots are full - Can now build comparison by dragging videos individually - Or drag both at once to start fresh Main menu drag-and-drop to Compare tile: - Already working correctly - Loads both videos sequentially then shows module - No changes needed to that path This makes the Compare workflow much more intuitive and prevents losing loaded video data when adding the second video. --- main.go | 79 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/main.go b/main.go index b17447e..4d8c6a2 100644 --- a/main.go +++ b/main.go @@ -3701,36 +3701,65 @@ func (s *appState) handleDrop(pos fyne.Position, items []fyne.URI) { // Load videos sequentially to avoid race conditions go func() { - // Load first video - src1, err := probeVideo(videoPaths[0]) - if err != nil { - logging.Debug(logging.CatModule, "failed to load first video: %v", err) - fyne.CurrentApp().Driver().DoFromGoroutine(func() { - dialog.ShowError(fmt.Errorf("failed to load video 1: %w", err), s.window) - }, false) - return - } - - // Load second video if available - var src2 *videoSource - if len(videoPaths) >= 2 { - src2, err = probeVideo(videoPaths[1]) + if len(videoPaths) == 1 { + // Single video dropped - fill first empty slot + src, err := probeVideo(videoPaths[0]) if err != nil { - logging.Debug(logging.CatModule, "failed to load second video: %v", err) - // Continue with just first video + logging.Debug(logging.CatModule, "failed to load video: %v", err) fyne.CurrentApp().Driver().DoFromGoroutine(func() { - dialog.ShowError(fmt.Errorf("failed to load video 2: %w", err), s.window) + dialog.ShowError(fmt.Errorf("failed to load video: %w", err), s.window) }, false) + return } - } - // Update state and refresh view once with both files - fyne.CurrentApp().Driver().DoFromGoroutine(func() { - s.compareFile1 = src1 - s.compareFile2 = src2 - s.showCompareView() - logging.Debug(logging.CatModule, "loaded %d video(s) via drag-and-drop", len(videoPaths)) - }, false) + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + // Fill first empty slot + if s.compareFile1 == nil { + s.compareFile1 = src + logging.Debug(logging.CatModule, "loaded video into slot 1") + } else if s.compareFile2 == nil { + s.compareFile2 = src + logging.Debug(logging.CatModule, "loaded video into slot 2") + } else { + // Both slots full - ask which to replace + dialog.ShowInformation("Both Slots Full", + "Both comparison slots are full. Use the Clear button to empty a slot first.", + s.window) + return + } + s.showCompareView() + }, false) + } else { + // Multiple videos dropped - load into both slots + src1, err := probeVideo(videoPaths[0]) + if err != nil { + logging.Debug(logging.CatModule, "failed to load first video: %v", err) + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + dialog.ShowError(fmt.Errorf("failed to load video 1: %w", err), s.window) + }, false) + return + } + + var src2 *videoSource + if len(videoPaths) >= 2 { + src2, err = probeVideo(videoPaths[1]) + if err != nil { + logging.Debug(logging.CatModule, "failed to load second video: %v", err) + // Continue with just first video + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + dialog.ShowError(fmt.Errorf("failed to load video 2: %w", err), s.window) + }, false) + } + } + + // Update both slots and refresh view once + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + s.compareFile1 = src1 + s.compareFile2 = src2 + s.showCompareView() + logging.Debug(logging.CatModule, "loaded %d video(s) into both slots", len(videoPaths)) + }, false) + } }() return