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.updateAuthorSummary()
if state.authorChaptersRefresh != nil {
state.authorChaptersRefresh()
}
})
chapterToggle.SetChecked(state.authorTreatAsChapters)
@ -213,12 +216,30 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
}
chapterList := container.NewVBox()
sourceLabel := widget.NewLabel("")
refreshChapters := func() {
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 {
chapterList.Add(widget.NewLabel("No chapters detected yet"))
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 {
title := ch.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))))
}
}
state.authorChaptersRefresh = refreshChapters
selectBtn := widget.NewButton("Select Video", func() {
dialog.ShowFileOpen(func(uc fyne.URIReadCloser, err error) {
@ -312,6 +334,7 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
detectBtn,
widget.NewSeparator(),
widget.NewLabel("Chapters:"),
sourceLabel,
container.NewScroll(chapterList),
container.NewHBox(addChapterBtn, exportBtn),
)
@ -596,12 +619,18 @@ func (s *appState) loadEmbeddedChapters(path string) {
s.authorChapters = nil
s.authorChapterSource = ""
s.updateAuthorSummary()
if s.authorChaptersRefresh != nil {
s.authorChaptersRefresh()
}
}
return
}
s.authorChapters = chapters
s.authorChapterSource = "embedded"
s.updateAuthorSummary()
if s.authorChaptersRefresh != nil {
s.authorChaptersRefresh()
}
}
func chaptersFromClips(clips []authorClip) []authorChapter {

View File

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