From a169df74fb6592497e5bfe60b5e4b63a478149d7 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sat, 3 Jan 2026 23:36:03 -0500 Subject: [PATCH] Open thumbnail results in default viewer --- main.go | 17 +++++++++++++++++ thumb_module.go | 36 +++++++++++++++++------------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index 0d8bc9c..08d01bd 100644 --- a/main.go +++ b/main.go @@ -480,6 +480,23 @@ func openFolder(path string) error { return cmd.Start() } +// openFile tries to open a file in the OS default viewer. +func openFile(path string) error { + if strings.TrimSpace(path) == "" { + return fmt.Errorf("path is empty") + } + var cmd *exec.Cmd + switch runtime.GOOS { + case "windows": + cmd = utils.CreateCommandRaw("explorer", path) + case "darwin": + cmd = utils.CreateCommandRaw("open", path) + default: + cmd = utils.CreateCommandRaw("xdg-open", path) + } + return cmd.Start() +} + func (s *appState) showAbout() { version := fmt.Sprintf("VideoTools %s", appVersion) dev := "Leak Technologies" diff --git a/thumb_module.go b/thumb_module.go index da6870a..2a8229b 100644 --- a/thumb_module.go +++ b/thumb_module.go @@ -352,32 +352,30 @@ func buildThumbView(state *appState) fyne.CanvasObject { return } - // If contact sheet mode, try to show contact sheet image + // If contact sheet mode, try to open contact sheet image if state.thumbContactSheet { contactSheetPath := filepath.Join(outputDir, fmt.Sprintf("%s_contact_sheet.jpg", videoBaseName)) if _, err := os.Stat(contactSheetPath); err == nil { - // Show contact sheet in a dialog - go func() { - img := canvas.NewImageFromFile(contactSheetPath) - img.FillMode = canvas.ImageFillContain - // Adaptive size for small screens - use scrollable dialog - // img.SetMinSize(fyne.NewSize(640, 480)) // Removed for flexible sizing - - fyne.CurrentApp().Driver().DoFromGoroutine(func() { - // Wrap in scroll container for large contact sheets - scroll := container.NewScroll(img) - d := dialog.NewCustom("Contact Sheet", "Close", scroll, state.window) - // Adaptive dialog size that fits on 1280x768 screens - d.Resize(fyne.NewSize(700, 600)) - d.Show() - }, false) - }() + if err := openFile(contactSheetPath); err != nil { + dialog.ShowError(fmt.Errorf("failed to open contact sheet: %w", err), state.window) + } return } } - // Otherwise, open folder - openFolder(outputDir) + // Otherwise, open first thumbnail + firstThumb := filepath.Join(outputDir, "thumb_0001.jpg") + if _, err := os.Stat(firstThumb); err == nil { + if err := openFile(firstThumb); err != nil { + dialog.ShowError(fmt.Errorf("failed to open thumbnail: %w", err), state.window) + } + return + } + + // Fall back to opening the folder if no images found + if err := openFolder(outputDir); err != nil { + dialog.ShowError(fmt.Errorf("failed to open results folder: %w", err), state.window) + } }) viewResultsBtn.Importance = widget.MediumImportance if state.thumbFile == nil {