Версия 0.3.0 #3

Merged
kor-elf merged 13 commits from develop into main 2024-02-04 20:50:55 +06:00
11 changed files with 112 additions and 53 deletions
Showing only changes of commit 0d5cfab38d - Show all commits

View 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)
}

View File

@ -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(),
)
}

View File

@ -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}

View File

@ -6,7 +6,6 @@ import (
"ffmpegGui/convertor"
"ffmpegGui/helper"
"ffmpegGui/localizer"
"ffmpegGui/setting"
"fyne.io/fyne/v2/widget"
"github.com/nicksnyder/go-i18n/v2/i18n"
"io"
@ -17,26 +16,27 @@ import (
type ConvertorHandlerContract interface {
MainConvertor()
FfPathSelection()
}
type ConvertorHandler struct {
convertorService convertor.ServiceContract
convertorView convertor.ViewContract
settingRepository setting.RepositoryContract
localizerService localizer.ServiceContract
convertorService convertor.ServiceContract
convertorView convertor.ViewContract
convertorRepository convertor.RepositoryContract
localizerService localizer.ServiceContract
}
func NewConvertorHandler(
convertorService convertor.ServiceContract,
convertorView convertor.ViewContract,
settingRepository setting.RepositoryContract,
convertorRepository convertor.RepositoryContract,
localizerService localizer.ServiceContract,
) *ConvertorHandler {
return &ConvertorHandler{
convertorService: convertorService,
convertorView: convertorView,
settingRepository: settingRepository,
localizerService: localizerService,
convertorService: convertorService,
convertorView: convertorView,
convertorRepository: convertorRepository,
localizerService: localizerService,
}
}
@ -45,7 +45,13 @@ func (h ConvertorHandler) MainConvertor() {
h.convertorView.Main(h.runConvert)
return
}
h.convertorView.SelectFFPath(h.saveSettingFFPath)
h.convertorView.SelectFFPath("", "", h.saveSettingFFPath, nil)
}
func (h ConvertorHandler) FfPathSelection() {
ffmpeg, _ := h.convertorRepository.GetPathFfmpeg()
ffprobe, _ := h.convertorRepository.GetPathFfprobe()
h.convertorView.SelectFFPath(ffmpeg, ffprobe, h.saveSettingFFPath, h.MainConvertor)
}
func (h ConvertorHandler) runConvert(setting convertor.HandleConvertSetting, progressbar *widget.ProgressBar) error {
@ -84,10 +90,8 @@ func (h ConvertorHandler) checkingFFPathUtilities() bool {
if ffprobeChecking == false {
continue
}
ffmpegEntity := setting.Setting{Code: "ffmpeg", Value: item.FFmpeg}
_, _ = h.settingRepository.Create(ffmpegEntity)
ffprobeEntity := setting.Setting{Code: "ffprobe", Value: item.FFprobe}
_, _ = h.settingRepository.Create(ffprobeEntity)
_, _ = h.convertorRepository.SavePathFfmpeg(item.FFmpeg)
_, _ = h.convertorRepository.SavePathFfprobe(item.FFprobe)
return true
}
@ -111,10 +115,8 @@ func (h ConvertorHandler) saveSettingFFPath(ffmpegPath string, ffprobePath strin
return errors.New(errorText)
}
ffmpegEntity := setting.Setting{Code: "ffmpeg", Value: ffmpegPath}
_, _ = h.settingRepository.Create(ffmpegEntity)
ffprobeEntity := setting.Setting{Code: "ffprobe", Value: ffprobePath}
_, _ = h.settingRepository.Create(ffprobeEntity)
_, _ = h.convertorRepository.SavePathFfmpeg(ffmpegPath)
_, _ = h.convertorRepository.SavePathFfprobe(ffprobePath)
h.MainConvertor()

View File

@ -51,9 +51,14 @@ func (h MenuHandler) GetMainMenu() *fyne.MainMenu {
}), h.LanguageSelection)
h.menuItems.menuItem["changeLanguage"] = languageSelection
ffPathSelection := fyne.NewMenuItem(h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "changeFFPath",
}), h.convertorHandler.FfPathSelection)
h.menuItems.menuItem["changeFFPath"] = ffPathSelection
settings := fyne.NewMenu(h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "settings",
}), languageSelection, quit)
}), languageSelection, ffPathSelection, quit)
h.menuItems.menu["settings"] = settings
return fyne.NewMainMenu(settings)

View File

@ -2,6 +2,14 @@
hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b"
other = "Folder where it will be saved:"
[cancel]
hash = "sha1-0ec753be8df955a117404fb634b01b45eb386e2a"
other = "Cancel"
[changeFFPath]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491"
other = "FFmpeg and FFprobe"
[changeLanguage]
hash = "sha1-8b276eaf378d485c769fb3d5dcc06dfc25b0c01b"
other = "Change language"

View File

@ -2,6 +2,14 @@
hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b"
other = "Файлды сақтауға арналған каталог:"
[cancel]
hash = "sha1-0ec753be8df955a117404fb634b01b45eb386e2a"
other = "Болдырмау"
[changeFFPath]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491"
other = "FFmpeg және FFprobe"
[changeLanguage]
hash = "sha1-8b276eaf378d485c769fb3d5dcc06dfc25b0c01b"
other = "Тілді өзгерту"

View File

@ -1,4 +1,6 @@
buttonForSelectedDirTitle = "Папка куда будет сохраняться:"
cancel = "Отмена"
changeFFPath = "FFmpeg и FFprobe"
changeLanguage = "Поменять язык"
checkboxOverwriteOutputFilesTitle = "Разрешить перезаписать файл"
choose = "выбрать"

View File

@ -1,11 +1,3 @@
[changeLanguage]
hash = "sha1-8b276eaf378d485c769fb3d5dcc06dfc25b0c01b"
other = "Change language"
[exit]
hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f"
other = "Exit"
[settings]
hash = "sha1-7f17c7c62a7fd8d1a508481f4778688927734c2f"
other = "Settings"
[changeFFPath]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491"
other = "FFmpeg and FFprobe"

View File

@ -1,11 +1,3 @@
[changeLanguage]
hash = "sha1-8b276eaf378d485c769fb3d5dcc06dfc25b0c01b"
other = "Тілді өзгерту"
[exit]
hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f"
other = "Шығу"
[settings]
hash = "sha1-7f17c7c62a7fd8d1a508481f4778688927734c2f"
other = "Параметрлер"
[changeFFPath]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491"
other = "FFmpeg және FFprobe"

View File

@ -62,13 +62,14 @@ func main() {
}
settingRepository := setting.NewRepository(db)
pathFFmpeg, err := settingRepository.GetValue("ffmpeg")
convertorRepository := convertor.NewRepository(settingRepository)
pathFFmpeg, err := convertorRepository.GetPathFfmpeg()
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) == false {
errorView.PanicError(err)
w.ShowAndRun()
return
}
pathFFprobe, err := settingRepository.GetValue("ffprobe")
pathFFprobe, err := convertorRepository.GetPathFfprobe()
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) == false {
errorView.PanicError(err)
w.ShowAndRun()
@ -81,7 +82,7 @@ func main() {
convertorView := convertor.NewView(w, localizerService)
convertorService := convertor.NewService(ffPathUtilities)
defer appCloseWithConvert(convertorService)
convertorHandler := handler.NewConvertorHandler(convertorService, convertorView, settingRepository, localizerService)
convertorHandler := handler.NewConvertorHandler(convertorService, convertorView, convertorRepository, localizerService)
localizerRepository := localizer.NewRepository(settingRepository)
mainMenu := handler.NewMenuHandler(convertorHandler, localizerService, localizerView, localizerRepository)