forked from Leak_Technologies/VideoTools
Harden drag/drop path handling and user feedback
This commit is contained in:
parent
ffca39811a
commit
b7b5788938
15
main.go
15
main.go
|
|
@ -3805,6 +3805,10 @@ func (s *appState) handleDropPlayer(items []fyne.URI) {
|
|||
var videoPaths []string
|
||||
for _, uri := range items {
|
||||
path := uriPath(uri)
|
||||
if path == "" {
|
||||
logging.Debug(logging.CatModule, "drop received empty path; uri=%v", uri)
|
||||
continue
|
||||
}
|
||||
logging.Debug(logging.CatModule, "drop received path=%s", path)
|
||||
|
||||
if info, err := os.Stat(path); err == nil && info.IsDir() {
|
||||
|
|
@ -3817,6 +3821,9 @@ func (s *appState) handleDropPlayer(items []fyne.URI) {
|
|||
|
||||
if len(videoPaths) == 0 {
|
||||
logging.Debug(logging.CatUI, "no valid video files in dropped items")
|
||||
fyne.Do(func() {
|
||||
dialog.ShowInformation("No videos found", "Drop a video file or a folder containing videos.", s.window)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -3837,6 +3844,14 @@ func uriPath(u fyne.URI) string {
|
|||
return p
|
||||
}
|
||||
raw := u.String()
|
||||
if raw == "" {
|
||||
return ""
|
||||
}
|
||||
if parsed, err := url.Parse(raw); err == nil {
|
||||
if parsed.Scheme == "file" {
|
||||
return parsed.Path
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(raw, "file://") {
|
||||
raw = strings.TrimPrefix(raw, "file://")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user