Made it possible to change the path to FFmpeg and FFprobe.
This commit is contained in:
36
src/convertor/repository.go
Normal file
36
src/convertor/repository.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package convertor
|
||||
|
||||
import (
|
||||
"ffmpegGui/setting"
|
||||
)
|
||||
|
||||
type RepositoryContract interface {
|
||||
GetPathFfmpeg() (string, error)
|
||||
SavePathFfmpeg(code string) (setting.Setting, error)
|
||||
GetPathFfprobe() (string, error)
|
||||
SavePathFfprobe(code string) (setting.Setting, error)
|
||||
}
|
||||
|
||||
type Repository struct {
|
||||
settingRepository setting.RepositoryContract
|
||||
}
|
||||
|
||||
func NewRepository(settingRepository setting.RepositoryContract) *Repository {
|
||||
return &Repository{settingRepository: settingRepository}
|
||||
}
|
||||
|
||||
func (r Repository) GetPathFfmpeg() (string, error) {
|
||||
return r.settingRepository.GetValue("ffmpeg")
|
||||
}
|
||||
|
||||
func (r Repository) SavePathFfmpeg(path string) (setting.Setting, error) {
|
||||
return r.settingRepository.CreateOrUpdate("ffmpeg", path)
|
||||
}
|
||||
|
||||
func (r Repository) GetPathFfprobe() (string, error) {
|
||||
return r.settingRepository.GetValue("ffprobe")
|
||||
}
|
||||
|
||||
func (r Repository) SavePathFfprobe(path string) (setting.Setting, error) {
|
||||
return r.settingRepository.CreateOrUpdate("ffprobe", path)
|
||||
}
|
@@ -18,7 +18,10 @@ type ViewContract interface {
|
||||
runConvert func(setting HandleConvertSetting, progressbar *widget.ProgressBar) error,
|
||||
)
|
||||
SelectFFPath(
|
||||
func(ffmpegPath string, ffprobePath string) error,
|
||||
ffmpegPath string,
|
||||
ffprobePath string,
|
||||
save func(ffmpegPath string, ffprobePath string) error,
|
||||
cancel func(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -12,13 +12,18 @@ import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func (v View) SelectFFPath(save func(ffmpegPath string, ffprobePath string) error) {
|
||||
func (v View) SelectFFPath(
|
||||
currentPathFfmpeg string,
|
||||
currentPathFfprobe string,
|
||||
save func(ffmpegPath string, ffprobePath string) error,
|
||||
cancel func(),
|
||||
) {
|
||||
errorMessage := canvas.NewText("", color.RGBA{255, 0, 0, 255})
|
||||
errorMessage.TextSize = 16
|
||||
errorMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
ffmpegPath, buttonFFmpeg, buttonFFmpegMessage := v.getButtonSelectFile()
|
||||
ffprobePath, buttonFFprobe, buttonFFprobeMessage := v.getButtonSelectFile()
|
||||
ffmpegPath, buttonFFmpeg, buttonFFmpegMessage := v.getButtonSelectFile(currentPathFfmpeg)
|
||||
ffprobePath, buttonFFprobe, buttonFFprobeMessage := v.getButtonSelectFile(currentPathFfprobe)
|
||||
|
||||
link := widget.NewHyperlink("https://ffmpeg.org/download.html", &url.URL{
|
||||
Scheme: "https",
|
||||
@@ -60,23 +65,28 @@ func (v View) SelectFFPath(save func(ffmpegPath string, ffprobePath string) erro
|
||||
MessageID: "save",
|
||||
}),
|
||||
OnSubmit: func() {
|
||||
err := save(string(*ffmpegPath), string(*ffprobePath))
|
||||
err := save(*ffmpegPath, *ffprobePath)
|
||||
if err != nil {
|
||||
errorMessage.Text = err.Error()
|
||||
}
|
||||
},
|
||||
}
|
||||
if cancel != nil {
|
||||
form.OnCancel = cancel
|
||||
form.CancelText = v.localizerService.GetMessage(&i18n.LocalizeConfig{
|
||||
MessageID: "cancel",
|
||||
})
|
||||
}
|
||||
selectFFPathTitle := v.localizerService.GetMessage(&i18n.LocalizeConfig{
|
||||
MessageID: "selectFFPathTitle",
|
||||
})
|
||||
v.w.SetContent(widget.NewCard(selectFFPathTitle, "", container.NewVBox(form)))
|
||||
}
|
||||
|
||||
func (v View) getButtonSelectFile() (filePath *string, button *widget.Button, buttonMessage *canvas.Text) {
|
||||
path := ""
|
||||
func (v View) getButtonSelectFile(path string) (filePath *string, button *widget.Button, buttonMessage *canvas.Text) {
|
||||
filePath = &path
|
||||
|
||||
buttonMessage = canvas.NewText("", color.RGBA{255, 0, 0, 255})
|
||||
buttonMessage = canvas.NewText(path, color.RGBA{49, 127, 114, 255})
|
||||
buttonMessage.TextSize = 16
|
||||
buttonMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
|
Reference in New Issue
Block a user