From 3e60815c7fe6bd9d8e5454758d29166bb4d271b7 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sun, 4 Jan 2026 00:22:52 -0500 Subject: [PATCH] Load multiple thumbnails like convert --- main.go | 32 ++------------------------- thumb_module.go | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 30 deletions(-) diff --git a/main.go b/main.go index 6650021..5681ecf 100644 --- a/main.go +++ b/main.go @@ -11132,38 +11132,10 @@ func (s *appState) handleDrop(pos fyne.Position, items []fyne.URI) { return } - // Multi-drop: add lightweight list entries and queue jobs - go func() { - fyne.CurrentApp().Driver().DoFromGoroutine(func() { - var sources []*videoSource - for _, path := range videoPaths { - sources = append(sources, &videoSource{ - Path: path, - DisplayName: filepath.Base(path), - }) - } - s.thumbFiles = sources - s.thumbFile = sources[0] - s.showThumbView() - s.loadThumbSourceAtIndex(0) - logging.Debug(logging.CatModule, "loaded %d videos into thumb module (lazy probe)", len(sources)) - }, false) - - if s.jobQueue != nil { - for _, path := range videoPaths { - s.jobQueue.Add(s.createThumbJobForPath(path)) - } - if !s.jobQueue.IsRunning() { - s.jobQueue.Start() - } - fyne.CurrentApp().Driver().DoFromGoroutine(func() { - dialog.ShowInformation("Thumbnails", fmt.Sprintf("Queued %d thumbnail jobs.", len(videoPaths)), s.window) - }, false) - } - }() + go s.loadMultipleThumbVideos(videoPaths) return - } + } // If in filters module, handle single video file if s.active == "filters" { diff --git a/thumb_module.go b/thumb_module.go index 9994ea3..42f982a 100644 --- a/thumb_module.go +++ b/thumb_module.go @@ -70,6 +70,43 @@ func (s *appState) loadThumbSourceAtIndex(idx int) { }() } +func (s *appState) loadMultipleThumbVideos(paths []string) { + if len(paths) == 0 { + return + } + logging.Debug(logging.CatModule, "loading %d videos into thumbnails", len(paths)) + + var valid []*videoSource + var failed []string + for _, path := range paths { + src, err := probeVideo(path) + if err != nil { + logging.Debug(logging.CatFFMPEG, "ffprobe failed for %s: %v", path, err) + failed = append(failed, filepath.Base(path)) + continue + } + valid = append(valid, src) + } + + if len(valid) == 0 { + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + msg := fmt.Sprintf("Failed to analyze %d file(s):\n%s", len(failed), strings.Join(failed, ", ")) + s.showErrorWithCopy("Load Failed", fmt.Errorf("%s", msg)) + }, false) + return + } + + s.thumbFiles = valid + s.thumbFile = valid[0] + + fyne.CurrentApp().Driver().DoFromGoroutine(func() { + s.showThumbView() + if len(failed) > 0 { + logging.Debug(logging.CatModule, "%d file(s) failed to analyze: %s", len(failed), strings.Join(failed, ", ")) + } + }, false) +} + func buildThumbView(state *appState) fyne.CanvasObject { thumbColor := moduleColor("thumb") @@ -347,6 +384,25 @@ func buildThumbView(state *appState) fyne.CanvasObject { addQueueBtn.Disable() } + addAllBtn := widget.NewButton("Add All to Queue", func() { + if len(state.thumbFiles) == 0 { + dialog.ShowInformation("No Videos", "Load videos first to add to queue.", state.window) + return + } + if state.jobQueue == nil { + dialog.ShowInformation("Queue", "Queue not initialized.", state.window) + return + } + for _, src := range state.thumbFiles { + if src == nil || src.Path == "" { + continue + } + state.jobQueue.Add(state.createThumbJobForPath(src.Path)) + } + dialog.ShowInformation("Queue", fmt.Sprintf("Queued %d thumbnail jobs.", len(state.thumbFiles)), state.window) + }) + addAllBtn.Importance = widget.MediumImportance + // View Queue button viewQueueBtn := widget.NewButton("View Queue", func() { state.showQueue() @@ -410,6 +466,7 @@ func buildThumbView(state *appState) fyne.CanvasObject { widget.NewSeparator(), generateNowBtn, addQueueBtn, + addAllBtn, viewQueueBtn, viewResultsBtn, )