Fix drag-and-drop to intelligently fill Compare slots

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.
This commit is contained in:
Stu Leak 2025-12-04 03:03:19 -05:00
parent 4ce71fb894
commit 653e6721da

79
main.go
View File

@ -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