Add debug logging and separate droppable panels for subtitle module
- Wrap left and right panels separately in droppables for better drop coverage - Add extensive debug logging to trace drop events and state changes - Log when handleDrop and handleSubtitlesModuleDrop are called - Log file identification (video vs subtitle) and state updates - Log videoEntry creation with current subtitleVideoPath value This will help diagnose why video path isn't populating on drop
This commit is contained in:
parent
00443c4a3a
commit
e5acceeb22
|
|
@ -139,6 +139,7 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
|
||||||
|
|
||||||
videoEntry := widget.NewEntry()
|
videoEntry := widget.NewEntry()
|
||||||
videoEntry.SetPlaceHolder("Video file path")
|
videoEntry.SetPlaceHolder("Video file path")
|
||||||
|
logging.Debug(logging.CatModule, "buildSubtitlesView: creating videoEntry with subtitleVideoPath=%s", state.subtitleVideoPath)
|
||||||
videoEntry.SetText(state.subtitleVideoPath)
|
videoEntry.SetText(state.subtitleVideoPath)
|
||||||
videoEntry.OnChanged = func(val string) {
|
videoEntry.OnChanged = func(val string) {
|
||||||
state.subtitleVideoPath = strings.TrimSpace(val)
|
state.subtitleVideoPath = strings.TrimSpace(val)
|
||||||
|
|
@ -250,25 +251,31 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
|
||||||
state.subtitleCuesRefresh = rebuildCues
|
state.subtitleCuesRefresh = rebuildCues
|
||||||
|
|
||||||
handleDrop := func(items []fyne.URI) {
|
handleDrop := func(items []fyne.URI) {
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop called with %d items", len(items))
|
||||||
var videoPath string
|
var videoPath string
|
||||||
var subtitlePath string
|
var subtitlePath string
|
||||||
for _, uri := range items {
|
for _, uri := range items {
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop: uri scheme=%s path=%s", uri.Scheme(), uri.Path())
|
||||||
if uri.Scheme() != "file" {
|
if uri.Scheme() != "file" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
path := uri.Path()
|
path := uri.Path()
|
||||||
if videoPath == "" && state.isVideoFile(path) {
|
if videoPath == "" && state.isVideoFile(path) {
|
||||||
videoPath = path
|
videoPath = path
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop: identified as video: %s", path)
|
||||||
}
|
}
|
||||||
if subtitlePath == "" && state.isSubtitleFile(path) {
|
if subtitlePath == "" && state.isSubtitleFile(path) {
|
||||||
subtitlePath = path
|
subtitlePath = path
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop: identified as subtitle: %s", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if videoPath != "" {
|
if videoPath != "" {
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop: setting video path to %s", videoPath)
|
||||||
state.subtitleVideoPath = videoPath
|
state.subtitleVideoPath = videoPath
|
||||||
videoEntry.SetText(videoPath)
|
videoEntry.SetText(videoPath)
|
||||||
}
|
}
|
||||||
if subtitlePath != "" {
|
if subtitlePath != "" {
|
||||||
|
logging.Debug(logging.CatModule, "subtitles handleDrop: setting subtitle path to %s", subtitlePath)
|
||||||
subtitleEntry.SetText(subtitlePath)
|
subtitleEntry.SetText(subtitlePath)
|
||||||
if err := state.loadSubtitleFile(subtitlePath); err != nil {
|
if err := state.loadSubtitleFile(subtitlePath); err != nil {
|
||||||
state.setSubtitleStatus(err.Error())
|
state.setSubtitleStatus(err.Error())
|
||||||
|
|
@ -487,9 +494,11 @@ func buildSubtitlesView(state *appState) fyne.CanvasObject {
|
||||||
|
|
||||||
rebuildCues()
|
rebuildCues()
|
||||||
|
|
||||||
content := container.NewGridWithColumns(2, left, right)
|
// Wrap both panels in droppable so drops anywhere will work
|
||||||
droppableContent := ui.NewDroppable(content, handleDrop)
|
droppableLeft := ui.NewDroppable(left, handleDrop)
|
||||||
return container.NewBorder(topBar, bottomBar, nil, nil, droppableContent)
|
droppableRight := ui.NewDroppable(right, handleDrop)
|
||||||
|
content := container.NewGridWithColumns(2, droppableLeft, droppableRight)
|
||||||
|
return container.NewBorder(topBar, bottomBar, nil, nil, content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *appState) setSubtitleStatus(msg string) {
|
func (s *appState) setSubtitleStatus(msg string) {
|
||||||
|
|
@ -511,33 +520,41 @@ func (s *appState) setSubtitleStatusAsync(msg string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *appState) handleSubtitlesModuleDrop(items []fyne.URI) {
|
func (s *appState) handleSubtitlesModuleDrop(items []fyne.URI) {
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop called with %d items", len(items))
|
||||||
var videoPath string
|
var videoPath string
|
||||||
var subtitlePath string
|
var subtitlePath string
|
||||||
for _, uri := range items {
|
for _, uri := range items {
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: uri scheme=%s path=%s", uri.Scheme(), uri.Path())
|
||||||
if uri.Scheme() != "file" {
|
if uri.Scheme() != "file" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
path := uri.Path()
|
path := uri.Path()
|
||||||
if videoPath == "" && s.isVideoFile(path) {
|
if videoPath == "" && s.isVideoFile(path) {
|
||||||
videoPath = path
|
videoPath = path
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: identified as video: %s", path)
|
||||||
}
|
}
|
||||||
if subtitlePath == "" && s.isSubtitleFile(path) {
|
if subtitlePath == "" && s.isSubtitleFile(path) {
|
||||||
subtitlePath = path
|
subtitlePath = path
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: identified as subtitle: %s", path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if videoPath == "" && subtitlePath == "" {
|
if videoPath == "" && subtitlePath == "" {
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: no video or subtitle found, returning")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if videoPath != "" {
|
if videoPath != "" {
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: setting subtitleVideoPath to %s", videoPath)
|
||||||
s.subtitleVideoPath = videoPath
|
s.subtitleVideoPath = videoPath
|
||||||
}
|
}
|
||||||
if subtitlePath != "" {
|
if subtitlePath != "" {
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: loading subtitle file %s", subtitlePath)
|
||||||
if err := s.loadSubtitleFile(subtitlePath); err != nil {
|
if err := s.loadSubtitleFile(subtitlePath); err != nil {
|
||||||
s.setSubtitleStatus(err.Error())
|
s.setSubtitleStatus(err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to subtitles module to show the loaded files
|
// Switch to subtitles module to show the loaded files
|
||||||
|
logging.Debug(logging.CatModule, "handleSubtitlesModuleDrop: calling showModule(subtitles), subtitleVideoPath=%s", s.subtitleVideoPath)
|
||||||
s.showModule("subtitles")
|
s.showModule("subtitles")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user