Compare commits
2 Commits
cf2a0933b4
...
16b32e0167
Author | SHA1 | Date | |
---|---|---|---|
16b32e0167 | |||
2a7d860cbf |
@ -11,6 +11,7 @@ import (
|
|||||||
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
encoder2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/encoder"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel/encoder"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel/encoder"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||||
"image/color"
|
"image/color"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -40,13 +41,13 @@ type HandleConvertSetting struct {
|
|||||||
Encoder encoder2.EncoderContract
|
Encoder encoder2.EncoderContract
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConversion(app kernel.AppContract, formats encoder.ConvertorFormatsContract, runConvert func(setting HandleConvertSetting)) *Conversion {
|
func NewConversion(app kernel.AppContract, formats encoder.ConvertorFormatsContract, runConvert func(setting HandleConvertSetting), settingDirectoryForSaving setting.DirectoryForSavingContract) *Conversion {
|
||||||
conversionMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
conversionMessage := canvas.NewText("", color.RGBA{R: 255, G: 0, B: 0, A: 255})
|
||||||
conversionMessage.TextSize = 16
|
conversionMessage.TextSize = 16
|
||||||
conversionMessage.TextStyle = fyne.TextStyle{Bold: true}
|
conversionMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||||
|
|
||||||
fileForConversion := newFileForConversion(app)
|
fileForConversion := newFileForConversion(app)
|
||||||
directoryForSaving := newDirectoryForSaving(app)
|
directoryForSaving := newDirectoryForSaving(app, settingDirectoryForSaving)
|
||||||
overwriteOutputFiles := newOverwriteOutputFiles(app)
|
overwriteOutputFiles := newOverwriteOutputFiles(app)
|
||||||
selectEncoder := newSelectEncoder(app, formats)
|
selectEncoder := newSelectEncoder(app, formats)
|
||||||
|
|
||||||
@ -247,7 +248,7 @@ type directoryForSaving struct {
|
|||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
func newDirectoryForSaving(app kernel.AppContract, settingDirectoryForSaving setting.DirectoryForSavingContract) *directoryForSaving {
|
||||||
directoryForSaving := &directoryForSaving{
|
directoryForSaving := &directoryForSaving{
|
||||||
path: "",
|
path: "",
|
||||||
}
|
}
|
||||||
@ -262,6 +263,13 @@ func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
|||||||
|
|
||||||
var locationURI fyne.ListableURI
|
var locationURI fyne.ListableURI
|
||||||
|
|
||||||
|
location, err := getDirectoryForSaving(settingDirectoryForSaving)
|
||||||
|
if err == nil {
|
||||||
|
directoryForSaving.path = location.Path()
|
||||||
|
directoryForSaving.message.Text = location.Path()
|
||||||
|
setStringSuccessStyle(directoryForSaving.message)
|
||||||
|
}
|
||||||
|
|
||||||
directoryForSaving.button = widget.NewButton(buttonTitle, func() {
|
directoryForSaving.button = widget.NewButton(buttonTitle, func() {
|
||||||
app.GetWindow().NewFolderOpen(func(r fyne.ListableURI, err error) {
|
app.GetWindow().NewFolderOpen(func(r fyne.ListableURI, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -277,7 +285,11 @@ func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
|||||||
|
|
||||||
directoryForSaving.message.Text = r.Path()
|
directoryForSaving.message.Text = r.Path()
|
||||||
setStringSuccessStyle(directoryForSaving.message)
|
setStringSuccessStyle(directoryForSaving.message)
|
||||||
locationURI, _ = storage.ListerForURI(r)
|
locationURI, err = storage.ListerForURI(r)
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
_, _ = settingDirectoryForSaving.SaveDirectoryForSaving(locationURI.Path())
|
||||||
|
}
|
||||||
|
|
||||||
}, locationURI)
|
}, locationURI)
|
||||||
})
|
})
|
||||||
@ -285,6 +297,24 @@ func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
|||||||
return directoryForSaving
|
return directoryForSaving
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDirectoryForSaving(settingDirectoryForSaving setting.DirectoryForSavingContract) (fyne.ListableURI, error) {
|
||||||
|
path, err := settingDirectoryForSaving.GetDirectoryForSaving()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(path) > 0 {
|
||||||
|
path = "file://" + path
|
||||||
|
}
|
||||||
|
|
||||||
|
uri, err := storage.ParseURI(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage.ListerForURI(uri)
|
||||||
|
}
|
||||||
|
|
||||||
type overwriteOutputFiles struct {
|
type overwriteOutputFiles struct {
|
||||||
checkbox *widget.Check
|
checkbox *widget.Check
|
||||||
isChecked bool
|
isChecked bool
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
error2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/error"
|
error2 "git.kor-elf.net/kor-elf/gui-for-ffmpeg/error"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/helper"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/helper"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||||
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,10 +19,11 @@ type ConvertorHandlerContract interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConvertorHandler struct {
|
type ConvertorHandler struct {
|
||||||
app kernel.AppContract
|
app kernel.AppContract
|
||||||
convertorView convertor.ViewContract
|
convertorView convertor.ViewContract
|
||||||
errorView error2.ViewContract
|
errorView error2.ViewContract
|
||||||
convertorRepository convertor.RepositoryContract
|
convertorRepository convertor.RepositoryContract
|
||||||
|
settingDirectoryForSaving setting.DirectoryForSavingContract
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConvertorHandler(
|
func NewConvertorHandler(
|
||||||
@ -29,12 +31,14 @@ func NewConvertorHandler(
|
|||||||
convertorView convertor.ViewContract,
|
convertorView convertor.ViewContract,
|
||||||
errorView error2.ViewContract,
|
errorView error2.ViewContract,
|
||||||
convertorRepository convertor.RepositoryContract,
|
convertorRepository convertor.RepositoryContract,
|
||||||
|
settingDirectoryForSaving setting.DirectoryForSavingContract,
|
||||||
) *ConvertorHandler {
|
) *ConvertorHandler {
|
||||||
return &ConvertorHandler{
|
return &ConvertorHandler{
|
||||||
app: app,
|
app: app,
|
||||||
convertorView: convertorView,
|
convertorView: convertorView,
|
||||||
errorView: errorView,
|
errorView: errorView,
|
||||||
convertorRepository: convertorRepository,
|
convertorRepository: convertorRepository,
|
||||||
|
settingDirectoryForSaving: settingDirectoryForSaving,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +49,7 @@ func (h ConvertorHandler) MainConvertor() {
|
|||||||
h.errorView.PanicError(err)
|
h.errorView.PanicError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conversion := view.NewConversion(h.app, formats, h.runConvert)
|
conversion := view.NewConversion(h.app, formats, h.runConvert, h.settingDirectoryForSaving)
|
||||||
h.convertorView.Main(conversion)
|
h.convertorView.Main(conversion)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/kernel"
|
||||||
|
4
main.go
4
main.go
@ -73,6 +73,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
settingRepository := setting.NewRepository(db)
|
settingRepository := setting.NewRepository(db)
|
||||||
|
settingDirectoryForSaving := setting.NewSettingDirectoryForSaving(settingRepository)
|
||||||
|
|
||||||
convertorRepository := convertor.NewRepository(settingRepository)
|
convertorRepository := convertor.NewRepository(settingRepository)
|
||||||
pathFFmpeg, err := convertorRepository.GetPathFfmpeg()
|
pathFFmpeg, err := convertorRepository.GetPathFfmpeg()
|
||||||
if err != nil && errors.Is(err, dberror.ErrRecordNotFound) == false {
|
if err != nil && errors.Is(err, dberror.ErrRecordNotFound) == false {
|
||||||
@ -95,7 +97,7 @@ func main() {
|
|||||||
|
|
||||||
localizerView := localizer.NewView(application)
|
localizerView := localizer.NewView(application)
|
||||||
convertorView := convertor.NewView(application)
|
convertorView := convertor.NewView(application)
|
||||||
convertorHandler := handler.NewConvertorHandler(application, convertorView, errorView, convertorRepository)
|
convertorHandler := handler.NewConvertorHandler(application, convertorView, errorView, convertorRepository, settingDirectoryForSaving)
|
||||||
|
|
||||||
localizerRepository := localizer.NewRepository(settingRepository)
|
localizerRepository := localizer.NewRepository(settingRepository)
|
||||||
menuView := menu.NewView(application)
|
menuView := menu.NewView(application)
|
||||||
|
22
setting/directory_for_saving.go
Normal file
22
setting/directory_for_saving.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package setting
|
||||||
|
|
||||||
|
type DirectoryForSavingContract interface {
|
||||||
|
GetDirectoryForSaving() (string, error)
|
||||||
|
SaveDirectoryForSaving(path string) (Setting, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type DirectoryForSaving struct {
|
||||||
|
settingRepository RepositoryContract
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSettingDirectoryForSaving(settingRepository RepositoryContract) *DirectoryForSaving {
|
||||||
|
return &DirectoryForSaving{settingRepository: settingRepository}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (setting DirectoryForSaving) GetDirectoryForSaving() (string, error) {
|
||||||
|
return setting.settingRepository.GetValue("directoryForSaving")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (setting DirectoryForSaving) SaveDirectoryForSaving(path string) (Setting, error) {
|
||||||
|
return setting.settingRepository.CreateOrUpdate("directoryForSaving", path)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user