Load multiple thumbnails like convert

This commit is contained in:
Stu Leak 2026-01-04 00:22:52 -05:00
parent ba378cf2f4
commit 3e60815c7f
2 changed files with 59 additions and 30 deletions

32
main.go
View File

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

View File

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