Show clip-based chapters in author chapters tab

This commit is contained in:
Stu Leak 2025-12-23 17:58:45 -05:00
parent 71021f5585
commit f3f4ee0f3a
2 changed files with 30 additions and 0 deletions

View File

@ -169,6 +169,9 @@ func buildVideoClipsTab(state *appState) fyne.CanvasObject {
state.authorChapters = nil state.authorChapters = nil
} }
state.updateAuthorSummary() state.updateAuthorSummary()
if state.authorChaptersRefresh != nil {
state.authorChaptersRefresh()
}
}) })
chapterToggle.SetChecked(state.authorTreatAsChapters) chapterToggle.SetChecked(state.authorTreatAsChapters)
@ -213,12 +216,30 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
} }
chapterList := container.NewVBox() chapterList := container.NewVBox()
sourceLabel := widget.NewLabel("")
refreshChapters := func() { refreshChapters := func() {
chapterList.Objects = nil chapterList.Objects = nil
sourceLabel.SetText("")
if len(state.authorChapters) == 0 {
if state.authorTreatAsChapters && len(state.authorClips) > 1 {
state.authorChapters = chaptersFromClips(state.authorClips)
state.authorChapterSource = "clips"
}
}
if len(state.authorChapters) == 0 { if len(state.authorChapters) == 0 {
chapterList.Add(widget.NewLabel("No chapters detected yet")) chapterList.Add(widget.NewLabel("No chapters detected yet"))
return return
} }
switch state.authorChapterSource {
case "clips":
sourceLabel.SetText("Source: Video clips (treat as chapters)")
case "embedded":
sourceLabel.SetText("Source: Embedded chapters")
case "scenes":
sourceLabel.SetText("Source: Scene detection")
default:
sourceLabel.SetText("Source: Chapters")
}
for i, ch := range state.authorChapters { for i, ch := range state.authorChapters {
title := ch.Title title := ch.Title
if title == "" { if title == "" {
@ -227,6 +248,7 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
chapterList.Add(widget.NewLabel(fmt.Sprintf("%02d. %s (%s)", i+1, title, formatChapterTime(ch.Timestamp)))) chapterList.Add(widget.NewLabel(fmt.Sprintf("%02d. %s (%s)", i+1, title, formatChapterTime(ch.Timestamp))))
} }
} }
state.authorChaptersRefresh = refreshChapters
selectBtn := widget.NewButton("Select Video", func() { selectBtn := widget.NewButton("Select Video", func() {
dialog.ShowFileOpen(func(uc fyne.URIReadCloser, err error) { dialog.ShowFileOpen(func(uc fyne.URIReadCloser, err error) {
@ -312,6 +334,7 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
detectBtn, detectBtn,
widget.NewSeparator(), widget.NewSeparator(),
widget.NewLabel("Chapters:"), widget.NewLabel("Chapters:"),
sourceLabel,
container.NewScroll(chapterList), container.NewScroll(chapterList),
container.NewHBox(addChapterBtn, exportBtn), container.NewHBox(addChapterBtn, exportBtn),
) )
@ -596,12 +619,18 @@ func (s *appState) loadEmbeddedChapters(path string) {
s.authorChapters = nil s.authorChapters = nil
s.authorChapterSource = "" s.authorChapterSource = ""
s.updateAuthorSummary() s.updateAuthorSummary()
if s.authorChaptersRefresh != nil {
s.authorChaptersRefresh()
}
} }
return return
} }
s.authorChapters = chapters s.authorChapters = chapters
s.authorChapterSource = "embedded" s.authorChapterSource = "embedded"
s.updateAuthorSummary() s.updateAuthorSummary()
if s.authorChaptersRefresh != nil {
s.authorChaptersRefresh()
}
} }
func chaptersFromClips(clips []authorClip) []authorChapter { func chaptersFromClips(clips []authorClip) []authorChapter {

View File

@ -918,6 +918,7 @@ type appState struct {
authorSummaryLabel *widget.Label authorSummaryLabel *widget.Label
authorTreatAsChapters bool // Treat multiple clips as chapters authorTreatAsChapters bool // Treat multiple clips as chapters
authorChapterSource string // embedded, scenes, clips, manual authorChapterSource string // embedded, scenes, clips, manual
authorChaptersRefresh func() // Refresh hook for chapter list UI
} }
type mergeClip struct { type mergeClip struct {