Compare commits

..

No commits in common. "019388667655ec940723a65ebf627808d1b1f825" and "e3aebdcbb73e979de99232b85d9bd17f677d5176" have entirely different histories.

2 changed files with 10 additions and 27 deletions

View File

@ -1 +0,0 @@
Adding to documentation: Need to simplify Whisper and Whisper usage in Subtitles module

View File

@ -139,7 +139,6 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
videoEntry := widget.NewEntry()
videoEntry.SetPlaceHolder("Video file path")
logging.Debug(logging.CatModule, "buildSubtitlesView: creating videoEntry with subtitleVideoPath=%s", state.subtitleVideoPath)
videoEntry.SetText(state.subtitleVideoPath)
videoEntry.OnChanged = func(val string) {
state.subtitleVideoPath = strings.TrimSpace(val)
@ -251,32 +250,25 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
state.subtitleCuesRefresh = rebuildCues
handleDrop := func(items []fyne.URI) {
logging.Debug(logging.CatModule, "subtitles handleDrop called with %d items", len(items))
var videoPath string
var subtitlePath string
for _, uri := range items {
logging.Debug(logging.CatModule, "subtitles handleDrop: uri scheme=%s path=%s", uri.Scheme(), uri.Path())
if uri.Scheme() != "file" {
continue
}
path := uri.Path()
if videoPath == "" && state.isVideoFile(path) {
videoPath = path
logging.Debug(logging.CatModule, "subtitles handleDrop: identified as video: %s", path)
}
if subtitlePath == "" && state.isSubtitleFile(path) {
subtitlePath = path
logging.Debug(logging.CatModule, "subtitles handleDrop: identified as subtitle: %s", path)
}
}
if videoPath != "" {
logging.Debug(logging.CatModule, "subtitles handleDrop: setting video path to %s", videoPath)
state.subtitleVideoPath = videoPath
videoEntry.SetText(videoPath)
logging.Debug(logging.CatModule, "subtitles handleDrop: videoEntry text set to %s", videoPath)
}
if subtitlePath != "" {
logging.Debug(logging.CatModule, "subtitles handleDrop: setting subtitle path to %s", subtitlePath)
subtitleEntry.SetText(subtitlePath)
if err := state.loadSubtitleFile(subtitlePath); err != nil {
state.setSubtitleStatus(err.Error())
@ -289,7 +281,7 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
emptyLabel.Alignment = fyne.TextAlignCenter
emptyOverlay = container.NewCenter(emptyLabel)
listArea := container.NewMax(listScroll, emptyOverlay)
listArea := container.NewMax(ui.NewDroppable(listScroll, handleDrop), emptyOverlay)
addCueBtn := widget.NewButton("Add Cue", func() {
start := 0.0
@ -457,8 +449,8 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
left := container.NewVBox(
widget.NewLabelWithStyle("Sources", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
container.NewBorder(nil, nil, nil, browseVideoBtn, videoEntry),
container.NewBorder(nil, nil, nil, browseSubtitleBtn, subtitleEntry),
container.NewBorder(nil, nil, nil, browseVideoBtn, ui.NewDroppable(videoEntry, handleDrop)),
container.NewBorder(nil, nil, nil, browseSubtitleBtn, ui.NewDroppable(subtitleEntry, handleDrop)),
widget.NewSeparator(),
widget.NewLabelWithStyle("Timing Adjustment", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
widget.NewLabel("Shift all subtitle times by offset (seconds):"),
@ -495,11 +487,9 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
rebuildCues()
// Wrap both panels in droppable so drops anywhere will work
droppableLeft := ui.NewDroppable(left, handleDrop)
droppableRight := ui.NewDroppable(right, handleDrop)
content := container.NewGridWithColumns(2, droppableLeft, droppableRight)
return container.NewBorder(topBar, bottomBar, nil, nil, content)
content := container.NewGridWithColumns(2, left, right)
droppableContent := ui.NewDroppable(content, handleDrop)
return container.NewBorder(topBar, bottomBar, nil, nil, droppableContent)
}
func (s *appState) setSubtitleStatus(msg string) {
@ -521,42 +511,36 @@ func (s *appState) setSubtitleStatusAsync(msg string) {
}
func (s *appState) handleSubtitlesModuleDrop(items []fyne.URI) {
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop called with %d items", len(items))
var videoPath string
var subtitlePath string
for _, uri := range items {
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: uri scheme=%s path=%s", uri.Scheme(), uri.Path())
if uri.Scheme() != "file" {
continue
}
path := uri.Path()
if videoPath == "" && s.isVideoFile(path) {
videoPath = path
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: identified as video: %s", path)
}
if subtitlePath == "" && s.isSubtitleFile(path) {
subtitlePath = path
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: identified as subtitle: %s", path)
}
}
if videoPath == "" && subtitlePath == "" {
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: no video or subtitle found, returning")
return
}
if videoPath != "" {
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: setting subtitleVideoPath to %s", videoPath)
s.subtitleVideoPath = videoPath
}
if subtitlePath != "" {
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: loading subtitle file %s", subtitlePath)
if err := s.loadSubtitleFile(subtitlePath); err != nil {
s.setSubtitleStatus(err.Error())
}
}
// Switch to subtitles module to show the loaded files
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: calling showModule(subtitles), subtitleVideoPath=%s", s.subtitleVideoPath)
s.showModule("subtitles")
// Refresh the view to show the loaded files
if s.active == "subtitles" {
s.showSubtitlesView()
}
}
func (s *appState) loadSubtitleFile(path string) error {