Added a window with information about the program.

This commit is contained in:
Leonid Nikitin 2024-02-03 17:47:32 +06:00
parent 2afc5f5b1a
commit eec298bfd7
Signed by: kor-elf
GPG Key ID: 7DE8F80C5CEC2C0D
10 changed files with 419 additions and 20 deletions

View File

@ -17,6 +17,8 @@ import (
type ConvertorHandlerContract interface { type ConvertorHandlerContract interface {
MainConvertor() MainConvertor()
FfPathSelection() FfPathSelection()
GetFfmpegVersion() (string, error)
GetFfprobeVersion() (string, error)
} }
type ConvertorHandler struct { type ConvertorHandler struct {
@ -54,6 +56,14 @@ func (h ConvertorHandler) FfPathSelection() {
h.convertorView.SelectFFPath(ffmpeg, ffprobe, h.saveSettingFFPath, h.MainConvertor) h.convertorView.SelectFFPath(ffmpeg, ffprobe, h.saveSettingFFPath, h.MainConvertor)
} }
func (h ConvertorHandler) GetFfmpegVersion() (string, error) {
return h.convertorService.GetFFmpegVesrion()
}
func (h ConvertorHandler) GetFfprobeVersion() (string, error) {
return h.convertorService.GetFFprobeVersion()
}
func (h ConvertorHandler) runConvert(setting convertor.HandleConvertSetting, progressbar *widget.ProgressBar) error { func (h ConvertorHandler) runConvert(setting convertor.HandleConvertSetting, progressbar *widget.ProgressBar) error {
totalDuration, err := h.convertorService.GetTotalDuration(setting.VideoFileInput) totalDuration, err := h.convertorService.GetTotalDuration(setting.VideoFileInput)
if err != nil { if err != nil {

View File

@ -2,6 +2,7 @@ package handler
import ( import (
"ffmpegGui/localizer" "ffmpegGui/localizer"
"ffmpegGui/menu"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
) )
@ -18,6 +19,7 @@ type menuItems struct {
type MenuHandler struct { type MenuHandler struct {
convertorHandler ConvertorHandlerContract convertorHandler ConvertorHandlerContract
menuView menu.ViewContract
localizerService localizer.ServiceContract localizerService localizer.ServiceContract
localizerView localizer.ViewContract localizerView localizer.ViewContract
localizerRepository localizer.RepositoryContract localizerRepository localizer.RepositoryContract
@ -26,12 +28,14 @@ type MenuHandler struct {
func NewMenuHandler( func NewMenuHandler(
convertorHandler ConvertorHandlerContract, convertorHandler ConvertorHandlerContract,
menuView menu.ViewContract,
localizerService localizer.ServiceContract, localizerService localizer.ServiceContract,
localizerView localizer.ViewContract, localizerView localizer.ViewContract,
localizerRepository localizer.RepositoryContract, localizerRepository localizer.RepositoryContract,
) *MenuHandler { ) *MenuHandler {
return &MenuHandler{ return &MenuHandler{
convertorHandler: convertorHandler, convertorHandler: convertorHandler,
menuView: menuView,
localizerService: localizerService, localizerService: localizerService,
localizerView: localizerView, localizerView: localizerView,
localizerRepository: localizerRepository, localizerRepository: localizerRepository,
@ -40,6 +44,13 @@ func NewMenuHandler(
} }
func (h MenuHandler) GetMainMenu() *fyne.MainMenu { func (h MenuHandler) GetMainMenu() *fyne.MainMenu {
settings := h.getMenuSettings()
help := h.getMenuHelp()
return fyne.NewMainMenu(settings, help)
}
func (h MenuHandler) getMenuSettings() *fyne.Menu {
quit := fyne.NewMenuItem(h.localizerService.GetMessage(&i18n.LocalizeConfig{ quit := fyne.NewMenuItem(h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "exit", MessageID: "exit",
}), nil) }), nil)
@ -61,7 +72,38 @@ func (h MenuHandler) GetMainMenu() *fyne.MainMenu {
}), languageSelection, ffPathSelection, quit) }), languageSelection, ffPathSelection, quit)
h.menuItems.menu["settings"] = settings h.menuItems.menu["settings"] = settings
return fyne.NewMainMenu(settings) return settings
}
func (h MenuHandler) getMenuHelp() *fyne.Menu {
about := fyne.NewMenuItem(h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "about",
}), h.openAbout)
h.menuItems.menuItem["about"] = about
help := fyne.NewMenu(h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "help",
}), about)
h.menuItems.menu["help"] = help
return help
}
func (h MenuHandler) openAbout() {
ffmpeg, err := h.convertorHandler.GetFfmpegVersion()
if err != nil {
ffmpeg = h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "errorFFmpegVersion",
})
}
ffprobe, err := h.convertorHandler.GetFfprobeVersion()
if err != nil {
ffprobe = h.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "errorFFprobeVersion",
})
}
h.menuView.About(ffmpeg, ffprobe)
} }
func (h MenuHandler) LanguageSelection() { func (h MenuHandler) LanguageSelection() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,3 +1,11 @@
[about]
hash = "sha1-3da0b9ef719fd707f443ac00404447f29445976f"
other = "About"
[aboutText]
hash = "sha1-8bd565814118ba8b90c40eb5b62acf8d2676e7d6"
other = "A simple interface for the FFmpeg console utility. \nBut I am not the author of the FFmpeg utility itself."
[buttonForSelectedDirTitle] [buttonForSelectedDirTitle]
hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b" hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b"
other = "Folder where it will be saved:" other = "Folder where it will be saved:"
@ -46,10 +54,18 @@ other = "could not create file 'database' in folder 'data'"
hash = "sha1-ccf0b95c0d1b392dc215258d917eb4e5d0b88ed0" hash = "sha1-ccf0b95c0d1b392dc215258d917eb4e5d0b88ed0"
other = "this is not FFmpeg" other = "this is not FFmpeg"
[errorFFmpegVersion]
hash = "sha1-9a4148d42186b6b32cf83bef726e23022c53283f"
other = "Could not determine FFmpeg version"
[errorFFprobe] [errorFFprobe]
hash = "sha1-86d1b0b4c4ccd6a4f71e758fc67ce11aff4ba9b8" hash = "sha1-86d1b0b4c4ccd6a4f71e758fc67ce11aff4ba9b8"
other = "this is not FFprobe" other = "this is not FFprobe"
[errorFFprobeVersion]
hash = "sha1-da7b37d7df3fafbd153665b13888413d52b24c17"
other = "Failed to determine FFprobe version"
[errorSelectedFolderSave] [errorSelectedFolderSave]
hash = "sha1-83da899677cdc90e4344e3b94ee03c46b51bee4c" hash = "sha1-83da899677cdc90e4344e3b94ee03c46b51bee4c"
other = "You haven't selected a folder to save!" other = "You haven't selected a folder to save!"
@ -58,10 +74,22 @@ other = "You haven't selected a folder to save!"
hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f" hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f"
other = "Exit" other = "Exit"
[ffmpegLGPL]
hash = "sha1-d395b16cc8f8eab98a8a970307c5b010ba22dde6"
other = "This software uses libraries from the **FFmpeg** project under the **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)**."
[ffmpegTrademark]
hash = "sha1-45f772b2eca5098cd6d31f2d1dc6edec1987a617"
other = "**FFmpeg** is a trademark of **[Fabrice Bellard](http://bellard.org/)**, originator of the **[FFmpeg](https://ffmpeg.org/about.html)** project."
[fileVideoForConversionTitle] [fileVideoForConversionTitle]
hash = "sha1-5e727d4a2ff3f21080e51e81641595b2e668f3be" hash = "sha1-5e727d4a2ff3f21080e51e81641595b2e668f3be"
other = "File for conversion:" other = "File for conversion:"
[help]
hash = "sha1-6a45cef900c668effcb2ab10da05855c1fd10f6f"
other = "Help"
[languageSelectionFormHead] [languageSelectionFormHead]
hash = "sha1-0ff5fa82cf684112660128cba1711297acf11003" hash = "sha1-0ff5fa82cf684112660128cba1711297acf11003"
other = "Switch language" other = "Switch language"
@ -70,13 +98,25 @@ other = "Switch language"
hash = "sha1-daf1108fc10d3b1a908288d611f749b3cc651e4b" hash = "sha1-daf1108fc10d3b1a908288d611f749b3cc651e4b"
other = "Choose language" other = "Choose language"
[licenseLink]
hash = "sha1-ea18ab849f0eea030d770da82c2a6b3484a7bd13"
other = "License information"
[pathToFfmpeg] [pathToFfmpeg]
hash = "sha1-2eba439f365640ff77e0ed6a7486fcb662573850" hash = "sha1-fafc50f1db0f720fe83a96cd70a9e1ad824e96b6"
other = "Path to ffmpeg:" other = "Path to FFmpeg:"
[pathToFfprobe] [pathToFfprobe]
hash = "sha1-02ad53337801906f8ebfee4616100dd9f43eabd7" hash = "sha1-b872edc9633a2e81ef678dc46fe46a7e91732024"
other = "Path to ffprobe:" other = "Path to FFprobe:"
[programmLink]
hash = "sha1-18f9a3fad6aacefe1b05eed23122800b391ff5ca"
other = "Project website"
[programmVersion]
hash = "sha1-fa2e4994a301bb24bc2a8fa166e5486ea95a7475"
other = "**Program version:** {{.Version}}"
[save] [save]
hash = "sha1-4864057d626a868fa60f999bed3191d61d045ddc" hash = "sha1-4864057d626a868fa60f999bed3191d61d045ddc"

View File

@ -1,3 +1,11 @@
[about]
hash = "sha1-3da0b9ef719fd707f443ac00404447f29445976f"
other = "Бағдарлама туралы"
[aboutText]
hash = "sha1-8bd565814118ba8b90c40eb5b62acf8d2676e7d6"
other = "FFmpeg консоль утилитасы үшін қарапайым интерфейс. \nБірақ мен FFmpeg утилитасының авторы емеспін."
[buttonForSelectedDirTitle] [buttonForSelectedDirTitle]
hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b" hash = "sha1-52b13f1b13e82d22e8c4102332db5d4ec551247b"
other = "Файлды сақтауға арналған каталог:" other = "Файлды сақтауға арналған каталог:"
@ -46,10 +54,18 @@ other = "'data' қалтасында 'database' файлын жасау мүмк
hash = "sha1-ccf0b95c0d1b392dc215258d917eb4e5d0b88ed0" hash = "sha1-ccf0b95c0d1b392dc215258d917eb4e5d0b88ed0"
other = "бұл FFmpeg емес" other = "бұл FFmpeg емес"
[errorFFmpegVersion]
hash = "sha1-9a4148d42186b6b32cf83bef726e23022c53283f"
other = "FFmpeg нұсқасын анықтау мүмкін болмады"
[errorFFprobe] [errorFFprobe]
hash = "sha1-86d1b0b4c4ccd6a4f71e758fc67ce11aff4ba9b8" hash = "sha1-86d1b0b4c4ccd6a4f71e758fc67ce11aff4ba9b8"
other = "бұл FFprobe емес" other = "бұл FFprobe емес"
[errorFFprobeVersion]
hash = "sha1-da7b37d7df3fafbd153665b13888413d52b24c17"
other = "FFprobe нұсқасын анықтау мүмкін болмады"
[errorSelectedFolderSave] [errorSelectedFolderSave]
hash = "sha1-83da899677cdc90e4344e3b94ee03c46b51bee4c" hash = "sha1-83da899677cdc90e4344e3b94ee03c46b51bee4c"
other = "Сіз сақталатын қалтаны таңдамадыңыз!" other = "Сіз сақталатын қалтаны таңдамадыңыз!"
@ -58,10 +74,22 @@ other = "Сіз сақталатын қалтаны таңдамадыңыз!"
hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f" hash = "sha1-c42457057d1ab7950cea00719cbe0b078891775f"
other = "Шығу" other = "Шығу"
[ffmpegLGPL]
hash = "sha1-d395b16cc8f8eab98a8a970307c5b010ba22dde6"
other = "Бұл бағдарламалық құрал **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)** астында **FFmpeg** жобасының кітапханаларын пайдаланады."
[ffmpegTrademark]
hash = "sha1-45f772b2eca5098cd6d31f2d1dc6edec1987a617"
other = "FFmpeg — **[FFmpeg](https://ffmpeg.org/about.html)** жобасын жасаушы **[Fabrice Bellard](http://bellard.org/)** сауда белгісі."
[fileVideoForConversionTitle] [fileVideoForConversionTitle]
hash = "sha1-5e727d4a2ff3f21080e51e81641595b2e668f3be" hash = "sha1-5e727d4a2ff3f21080e51e81641595b2e668f3be"
other = "Түрлендіруге арналған файл:" other = "Түрлендіруге арналған файл:"
[help]
hash = "sha1-6a45cef900c668effcb2ab10da05855c1fd10f6f"
other = "Анықтама"
[languageSelectionFormHead] [languageSelectionFormHead]
hash = "sha1-0ff5fa82cf684112660128cba1711297acf11003" hash = "sha1-0ff5fa82cf684112660128cba1711297acf11003"
other = "Тілді ауыстыру" other = "Тілді ауыстыру"
@ -70,13 +98,25 @@ other = "Тілді ауыстыру"
hash = "sha1-daf1108fc10d3b1a908288d611f749b3cc651e4b" hash = "sha1-daf1108fc10d3b1a908288d611f749b3cc651e4b"
other = "Тілді таңдаңыз" other = "Тілді таңдаңыз"
[licenseLink]
hash = "sha1-ea18ab849f0eea030d770da82c2a6b3484a7bd13"
other = "Лицензия туралы ақпарат"
[pathToFfmpeg] [pathToFfmpeg]
hash = "sha1-2eba439f365640ff77e0ed6a7486fcb662573850" hash = "sha1-fafc50f1db0f720fe83a96cd70a9e1ad824e96b6"
other = "ffmpeg жол:" other = "FFmpeg жол:"
[pathToFfprobe] [pathToFfprobe]
hash = "sha1-02ad53337801906f8ebfee4616100dd9f43eabd7" hash = "sha1-b872edc9633a2e81ef678dc46fe46a7e91732024"
other = "ffprobe жол:" other = "FFprobe жол:"
[programmLink]
hash = "sha1-18f9a3fad6aacefe1b05eed23122800b391ff5ca"
other = "Жобаның веб-сайты"
[programmVersion]
hash = "sha1-fa2e4994a301bb24bc2a8fa166e5486ea95a7475"
other = "**Бағдарлама нұсқасы:** {{.Version}}"
[save] [save]
hash = "sha1-4864057d626a868fa60f999bed3191d61d045ddc" hash = "sha1-4864057d626a868fa60f999bed3191d61d045ddc"

View File

@ -1,3 +1,5 @@
about = "О программе"
aboutText = "Простенький интерфейс для консольной утилиты FFmpeg. \nНо я не являюсь автором самой утилиты FFmpeg."
buttonForSelectedDirTitle = "Папка куда будет сохраняться:" buttonForSelectedDirTitle = "Папка куда будет сохраняться:"
cancel = "Отмена" cancel = "Отмена"
changeFFPath = "FFmpeg и FFprobe" changeFFPath = "FFmpeg и FFprobe"
@ -10,14 +12,22 @@ error = "Произошла ошибка!"
errorConverter = "не смогли отконвертировать видео" errorConverter = "не смогли отконвертировать видео"
errorDatabase = "не смогли создать файл 'database' в папке 'data'" errorDatabase = "не смогли создать файл 'database' в папке 'data'"
errorFFmpeg = "это не FFmpeg" errorFFmpeg = "это не FFmpeg"
errorFFmpegVersion = "Не смогли определить версию FFmpeg"
errorFFprobe = "это не FFprobe" errorFFprobe = "это не FFprobe"
errorFFprobeVersion = "Не смогли определить версию FFprobe"
errorSelectedFolderSave = "Не выбрали папку для сохранения!" errorSelectedFolderSave = "Не выбрали папку для сохранения!"
exit = "Выход" exit = "Выход"
ffmpegLGPL = "Это программное обеспечение использует библиотеки из проекта **FFmpeg** под **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)**."
ffmpegTrademark = "**FFmpeg** — торговая марка **[Fabrice Bellard](http://bellard.org/)** , создателя проекта **[FFmpeg](https://ffmpeg.org/about.html)**."
fileVideoForConversionTitle = "Файл для ковертации:" fileVideoForConversionTitle = "Файл для ковертации:"
help = "Справка"
languageSelectionFormHead = "Переключить язык" languageSelectionFormHead = "Переключить язык"
languageSelectionHead = "Выберите язык" languageSelectionHead = "Выберите язык"
pathToFfmpeg = "Путь к ffmpeg:" licenseLink = "Сведения о лицензии"
pathToFfprobe = "Путь к ffprobe:" pathToFfmpeg = "Путь к FFmpeg:"
pathToFfprobe = "Путь к FFprobe:"
programmLink = "Сайт проекта"
programmVersion = "**Версия программы:** {{.Version}}"
save = "Сохранить" save = "Сохранить"
selectFFPathTitle = "Укажите путь к FFmpeg и к FFprobe" selectFFPathTitle = "Укажите путь к FFmpeg и к FFprobe"
settings = "Настройки" settings = "Настройки"

View File

@ -1,3 +1,47 @@
[changeFFPath] [about]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491" hash = "sha1-3da0b9ef719fd707f443ac00404447f29445976f"
other = "FFmpeg and FFprobe" other = "About"
[aboutText]
hash = "sha1-8bd565814118ba8b90c40eb5b62acf8d2676e7d6"
other = "A simple interface for the FFmpeg console utility. \nBut I am not the author of the FFmpeg utility itself."
[errorFFmpegVersion]
hash = "sha1-9a4148d42186b6b32cf83bef726e23022c53283f"
other = "Could not determine FFmpeg version"
[errorFFprobeVersion]
hash = "sha1-da7b37d7df3fafbd153665b13888413d52b24c17"
other = "Failed to determine FFprobe version"
[ffmpegLGPL]
hash = "sha1-d395b16cc8f8eab98a8a970307c5b010ba22dde6"
other = "This software uses libraries from the **FFmpeg** project under the **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)**."
[ffmpegTrademark]
hash = "sha1-45f772b2eca5098cd6d31f2d1dc6edec1987a617"
other = "**FFmpeg** is a trademark of **[Fabrice Bellard](http://bellard.org/)**, originator of the **[FFmpeg](https://ffmpeg.org/about.html)** project."
[help]
hash = "sha1-6a45cef900c668effcb2ab10da05855c1fd10f6f"
other = "Help"
[licenseLink]
hash = "sha1-ea18ab849f0eea030d770da82c2a6b3484a7bd13"
other = "License information"
[pathToFfmpeg]
hash = "sha1-fafc50f1db0f720fe83a96cd70a9e1ad824e96b6"
other = "Path to FFmpeg:"
[pathToFfprobe]
hash = "sha1-b872edc9633a2e81ef678dc46fe46a7e91732024"
other = "Path to FFprobe:"
[programmLink]
hash = "sha1-18f9a3fad6aacefe1b05eed23122800b391ff5ca"
other = "Project website"
[programmVersion]
hash = "sha1-fa2e4994a301bb24bc2a8fa166e5486ea95a7475"
other = "**Program version:** {{.Version}}"

View File

@ -1,3 +1,47 @@
[changeFFPath] [about]
hash = "sha1-46793a2844600d0eb19fa3540fb9564ee5705491" hash = "sha1-3da0b9ef719fd707f443ac00404447f29445976f"
other = "FFmpeg және FFprobe" other = "Бағдарлама туралы"
[aboutText]
hash = "sha1-8bd565814118ba8b90c40eb5b62acf8d2676e7d6"
other = "FFmpeg консоль утилитасы үшін қарапайым интерфейс. \nБірақ мен FFmpeg утилитасының авторы емеспін."
[errorFFmpegVersion]
hash = "sha1-9a4148d42186b6b32cf83bef726e23022c53283f"
other = "FFmpeg нұсқасын анықтау мүмкін болмады"
[errorFFprobeVersion]
hash = "sha1-da7b37d7df3fafbd153665b13888413d52b24c17"
other = "FFprobe нұсқасын анықтау мүмкін болмады"
[ffmpegLGPL]
hash = "sha1-d395b16cc8f8eab98a8a970307c5b010ba22dde6"
other = "Бұл бағдарламалық құрал **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)** астында **FFmpeg** жобасының кітапханаларын пайдаланады."
[ffmpegTrademark]
hash = "sha1-45f772b2eca5098cd6d31f2d1dc6edec1987a617"
other = "FFmpeg — **[FFmpeg](https://ffmpeg.org/about.html)** жобасын жасаушы **[Fabrice Bellard](http://bellard.org/)** сауда белгісі."
[help]
hash = "sha1-6a45cef900c668effcb2ab10da05855c1fd10f6f"
other = "Анықтама"
[licenseLink]
hash = "sha1-ea18ab849f0eea030d770da82c2a6b3484a7bd13"
other = "Лицензия туралы ақпарат"
[pathToFfmpeg]
hash = "sha1-fafc50f1db0f720fe83a96cd70a9e1ad824e96b6"
other = "FFmpeg жол:"
[pathToFfprobe]
hash = "sha1-b872edc9633a2e81ef678dc46fe46a7e91732024"
other = "FFprobe жол:"
[programmLink]
hash = "sha1-18f9a3fad6aacefe1b05eed23122800b391ff5ca"
other = "Жобаның веб-сайты"
[programmVersion]
hash = "sha1-fa2e4994a301bb24bc2a8fa166e5486ea95a7475"
other = "**Бағдарлама нұсқасы:** {{.Version}}"

View File

@ -6,6 +6,7 @@ import (
error2 "ffmpegGui/error" error2 "ffmpegGui/error"
"ffmpegGui/handler" "ffmpegGui/handler"
"ffmpegGui/localizer" "ffmpegGui/localizer"
"ffmpegGui/menu"
"ffmpegGui/migration" "ffmpegGui/migration"
"ffmpegGui/setting" "ffmpegGui/setting"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
@ -19,7 +20,7 @@ import (
"os" "os"
) )
//const appVersion string = "0.2.0" const appVersion string = "0.3.0"
func main() { func main() {
a := app.New() a := app.New()
@ -27,7 +28,7 @@ func main() {
if err == nil { if err == nil {
a.SetIcon(iconResource) a.SetIcon(iconResource)
} }
w := a.NewWindow("FFMpeg GUI!") w := a.NewWindow("GUI for FFmpeg")
w.Resize(fyne.Size{Width: 800, Height: 600}) w.Resize(fyne.Size{Width: 800, Height: 600})
w.CenterOnScreen() w.CenterOnScreen()
@ -85,7 +86,8 @@ func main() {
convertorHandler := handler.NewConvertorHandler(convertorService, convertorView, convertorRepository, localizerService) convertorHandler := handler.NewConvertorHandler(convertorService, convertorView, convertorRepository, localizerService)
localizerRepository := localizer.NewRepository(settingRepository) localizerRepository := localizer.NewRepository(settingRepository)
mainMenu := handler.NewMenuHandler(convertorHandler, localizerService, localizerView, localizerRepository) menuView := menu.NewView(w, a, appVersion, localizerService)
mainMenu := handler.NewMenuHandler(convertorHandler, menuView, localizerService, localizerView, localizerRepository)
mainHandler := handler.NewMainHandler(convertorHandler, mainMenu, localizerRepository, localizerService) mainHandler := handler.NewMainHandler(convertorHandler, mainMenu, localizerRepository, localizerService)
mainHandler.Start() mainHandler.Start()

167
src/menu/view.go Normal file
View File

@ -0,0 +1,167 @@
package menu
import (
"ffmpegGui/localizer"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/image/colornames"
"net/url"
)
type ViewContract interface {
About(ffmpegVersion string, ffprobeVersion string)
}
type View struct {
w fyne.Window
app fyne.App
appVersion string
localizerService localizer.ServiceContract
}
func NewView(w fyne.Window, app fyne.App, appVersion string, localizerService localizer.ServiceContract) *View {
return &View{
w: w,
app: app,
appVersion: appVersion,
localizerService: localizerService,
}
}
func (v View) About(ffmpegVersion string, ffprobeVersion string) {
view := v.app.NewWindow(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "about",
}))
view.Resize(fyne.Size{Width: 793, Height: 550})
view.SetFixedSize(true)
programmName := canvas.NewText(" GUI for FFmpeg", colornames.Darkgreen)
programmName.TextStyle = fyne.TextStyle{Bold: true}
programmName.TextSize = 20
programmLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "programmLink",
}), &url.URL{
Scheme: "https",
Host: "git.kor-elf.net",
Path: "kor-elf/gui-for-ffmpeg/releases",
})
licenseLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "licenseLink",
}), &url.URL{
Scheme: "https",
Host: "git.kor-elf.net",
Path: "kor-elf/gui-for-ffmpeg/src/branch/main/LICENSE",
})
programmVersion := widget.NewRichTextFromMarkdown(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "programmVersion",
TemplateData: map[string]string{
"Version": v.appVersion,
},
}))
aboutText := widget.NewRichText(
&widget.TextSegment{
Text: v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "aboutText",
}),
},
)
image := canvas.NewImageFromFile("icon.png")
image.SetMinSize(fyne.Size{Width: 100, Height: 100})
image.FillMode = canvas.ImageFillContain
ffmpegTrademark := widget.NewRichTextFromMarkdown(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "ffmpegTrademark",
}))
ffmpegLGPL := widget.NewRichTextFromMarkdown(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "ffmpegLGPL",
}))
view.SetContent(
container.NewScroll(container.NewVBox(
container.NewBorder(nil, nil, container.NewVBox(image), nil, container.NewVBox(
programmName,
programmVersion,
aboutText,
ffmpegTrademark,
ffmpegLGPL,
v.getCopyright(),
container.NewHBox(programmLink, licenseLink),
)),
v.getAboutFfmpeg(ffmpegVersion),
v.getAboutFfprobe(ffprobeVersion),
)),
)
view.CenterOnScreen()
view.Show()
}
func (v View) getCopyright() *widget.RichText {
return widget.NewRichTextFromMarkdown("Copyright (c) 2024 **[Leonid Nikitin (kor-elf)](https://git.kor-elf.net/kor-elf/)**.")
}
func (v View) getAboutFfmpeg(version string) *fyne.Container {
programmName := canvas.NewText(" FFmpeg", colornames.Darkgreen)
programmName.TextStyle = fyne.TextStyle{Bold: true}
programmName.TextSize = 20
programmLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "programmLink",
}), &url.URL{
Scheme: "https",
Host: "ffmpeg.org",
Path: "",
})
licenseLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "licenseLink",
}), &url.URL{
Scheme: "https",
Host: "ffmpeg.org",
Path: "legal.html",
})
return container.NewVBox(
programmName,
widget.NewLabel(version),
widget.NewRichTextFromMarkdown("**FFmpeg** is a trademark of **[Fabrice Bellard](http://bellard.org/)**, originator of the **[FFmpeg](https://ffmpeg.org/about.html)** project."),
widget.NewRichTextFromMarkdown("This software uses libraries from the **FFmpeg** project under the **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)**."),
container.NewHBox(programmLink, licenseLink),
)
}
func (v View) getAboutFfprobe(version string) *fyne.Container {
programmName := canvas.NewText(" FFprobe", colornames.Darkgreen)
programmName.TextStyle = fyne.TextStyle{Bold: true}
programmName.TextSize = 20
programmLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "programmLink",
}), &url.URL{
Scheme: "https",
Host: "ffmpeg.org",
Path: "ffprobe.html",
})
licenseLink := widget.NewHyperlink(v.localizerService.GetMessage(&i18n.LocalizeConfig{
MessageID: "licenseLink",
}), &url.URL{
Scheme: "https",
Host: "ffmpeg.org",
Path: "legal.html",
})
return container.NewVBox(
programmName,
widget.NewLabel(version),
widget.NewRichTextFromMarkdown("**FFmpeg** is a trademark of **[Fabrice Bellard](http://bellard.org/)**, originator of the **[FFmpeg](https://ffmpeg.org/about.html)** project."),
widget.NewRichTextFromMarkdown("This software uses libraries from the **FFmpeg** project under the **[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)**."),
container.NewHBox(programmLink, licenseLink),
)
}