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"
|
||||
"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/setting"
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
"image/color"
|
||||
"path/filepath"
|
||||
@ -40,13 +41,13 @@ type HandleConvertSetting struct {
|
||||
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.TextSize = 16
|
||||
conversionMessage.TextStyle = fyne.TextStyle{Bold: true}
|
||||
|
||||
fileForConversion := newFileForConversion(app)
|
||||
directoryForSaving := newDirectoryForSaving(app)
|
||||
directoryForSaving := newDirectoryForSaving(app, settingDirectoryForSaving)
|
||||
overwriteOutputFiles := newOverwriteOutputFiles(app)
|
||||
selectEncoder := newSelectEncoder(app, formats)
|
||||
|
||||
@ -247,7 +248,7 @@ type directoryForSaving struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
||||
func newDirectoryForSaving(app kernel.AppContract, settingDirectoryForSaving setting.DirectoryForSavingContract) *directoryForSaving {
|
||||
directoryForSaving := &directoryForSaving{
|
||||
path: "",
|
||||
}
|
||||
@ -262,6 +263,13 @@ func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
||||
|
||||
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() {
|
||||
app.GetWindow().NewFolderOpen(func(r fyne.ListableURI, err error) {
|
||||
if err != nil {
|
||||
@ -277,7 +285,11 @@ func newDirectoryForSaving(app kernel.AppContract) *directoryForSaving {
|
||||
|
||||
directoryForSaving.message.Text = r.Path()
|
||||
setStringSuccessStyle(directoryForSaving.message)
|
||||
locationURI, _ = storage.ListerForURI(r)
|
||||
locationURI, err = storage.ListerForURI(r)
|
||||
|
||||
if err == nil {
|
||||
_, _ = settingDirectoryForSaving.SaveDirectoryForSaving(locationURI.Path())
|
||||
}
|
||||
|
||||
}, locationURI)
|
||||
})
|
||||
@ -285,6 +297,24 @@ func newDirectoryForSaving(app kernel.AppContract) *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 {
|
||||
checkbox *widget.Check
|
||||
isChecked bool
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
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/kernel"
|
||||
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/setting"
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
)
|
||||
|
||||
@ -18,10 +19,11 @@ type ConvertorHandlerContract interface {
|
||||
}
|
||||
|
||||
type ConvertorHandler struct {
|
||||
app kernel.AppContract
|
||||
convertorView convertor.ViewContract
|
||||
errorView error2.ViewContract
|
||||
convertorRepository convertor.RepositoryContract
|
||||
app kernel.AppContract
|
||||
convertorView convertor.ViewContract
|
||||
errorView error2.ViewContract
|
||||
convertorRepository convertor.RepositoryContract
|
||||
settingDirectoryForSaving setting.DirectoryForSavingContract
|
||||
}
|
||||
|
||||
func NewConvertorHandler(
|
||||
@ -29,12 +31,14 @@ func NewConvertorHandler(
|
||||
convertorView convertor.ViewContract,
|
||||
errorView error2.ViewContract,
|
||||
convertorRepository convertor.RepositoryContract,
|
||||
settingDirectoryForSaving setting.DirectoryForSavingContract,
|
||||
) *ConvertorHandler {
|
||||
return &ConvertorHandler{
|
||||
app: app,
|
||||
convertorView: convertorView,
|
||||
errorView: errorView,
|
||||
convertorRepository: convertorRepository,
|
||||
app: app,
|
||||
convertorView: convertorView,
|
||||
errorView: errorView,
|
||||
convertorRepository: convertorRepository,
|
||||
settingDirectoryForSaving: settingDirectoryForSaving,
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +49,7 @@ func (h ConvertorHandler) MainConvertor() {
|
||||
h.errorView.PanicError(err)
|
||||
return
|
||||
}
|
||||
conversion := view.NewConversion(h.app, formats, h.runConvert)
|
||||
conversion := view.NewConversion(h.app, formats, h.runConvert, h.settingDirectoryForSaving)
|
||||
h.convertorView.Main(conversion)
|
||||
return
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ package handler
|
||||
import (
|
||||
"archive/zip"
|
||||
"errors"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"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)
|
||||
settingDirectoryForSaving := setting.NewSettingDirectoryForSaving(settingRepository)
|
||||
|
||||
convertorRepository := convertor.NewRepository(settingRepository)
|
||||
pathFFmpeg, err := convertorRepository.GetPathFfmpeg()
|
||||
if err != nil && errors.Is(err, dberror.ErrRecordNotFound) == false {
|
||||
@ -95,7 +97,7 @@ func main() {
|
||||
|
||||
localizerView := localizer.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)
|
||||
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