Enable drag-and-drop loading in filters and upscale

This commit is contained in:
Stu Leak 2025-12-17 01:57:51 -05:00
parent 18d81cdbd4
commit 45c7b4f5c1

80
main.go
View File

@ -3784,7 +3784,7 @@ func (s *appState) executeUpscaleJob(ctx context.Context, job *queue.Job, progre
var h, m int var h, m int
var s float64 var s float64
if _, err := fmt.Sscanf(timeStr, "%d:%d:%f", &h, &m, &s); err == nil { if _, err := fmt.Sscanf(timeStr, "%d:%d:%f", &h, &m, &s); err == nil {
currentTime := float64(h*3600 + m*60) + s currentTime := float64(h*3600+m*60) + s
progress := currentTime / duration progress := currentTime / duration
if progress > 1.0 { if progress > 1.0 {
progress = 1.0 progress = 1.0
@ -7397,6 +7397,84 @@ func (s *appState) handleDrop(pos fyne.Position, items []fyne.URI) {
return return
} }
// If in filters module, handle single video file
if s.active == "filters" {
var videoPaths []string
for _, uri := range items {
if uri.Scheme() != "file" {
continue
}
path := uri.Path()
if s.isVideoFile(path) {
videoPaths = append(videoPaths, path)
}
}
if len(videoPaths) == 0 {
logging.Debug(logging.CatUI, "no valid video files in dropped items")
dialog.ShowInformation("Filters", "No video files found in dropped items.", s.window)
return
}
go func() {
src, err := probeVideo(videoPaths[0])
if err != nil {
logging.Debug(logging.CatModule, "failed to load video for filters: %v", err)
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
dialog.ShowError(fmt.Errorf("failed to load video: %w", err), s.window)
}, false)
return
}
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
s.filtersFile = src
s.showFiltersView()
logging.Debug(logging.CatModule, "loaded video into filters module")
}, false)
}()
return
}
// If in upscale module, handle single video file
if s.active == "upscale" {
var videoPaths []string
for _, uri := range items {
if uri.Scheme() != "file" {
continue
}
path := uri.Path()
if s.isVideoFile(path) {
videoPaths = append(videoPaths, path)
}
}
if len(videoPaths) == 0 {
logging.Debug(logging.CatUI, "no valid video files in dropped items")
dialog.ShowInformation("Upscale", "No video files found in dropped items.", s.window)
return
}
go func() {
src, err := probeVideo(videoPaths[0])
if err != nil {
logging.Debug(logging.CatModule, "failed to load video for upscale: %v", err)
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
dialog.ShowError(fmt.Errorf("failed to load video: %w", err), s.window)
}, false)
return
}
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
s.upscaleFile = src
s.showUpscaleView()
logging.Debug(logging.CatModule, "loaded video into upscale module")
}, false)
}()
return
}
// If in merge module, handle multiple video files // If in merge module, handle multiple video files
if s.active == "merge" { if s.active == "merge" {
// Collect all video files from the dropped items // Collect all video files from the dropped items