Code refactoring.
Added files with functions for various OS (//go:build windows, //go:build !windows).
This commit is contained in:
parent
7cc22e1553
commit
adf9bc9c27
@ -2,6 +2,7 @@ package convertor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"ffmpegGui/helper"
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@ -131,6 +132,7 @@ func (v View) getButtonFileVideoForConversion(form *widget.Form, progress *widge
|
|||||||
progress.Refresh()
|
progress.Refresh()
|
||||||
conversionMessage.Text = ""
|
conversionMessage.Text = ""
|
||||||
}, v.w)
|
}, v.w)
|
||||||
|
helper.FileDialogResize(fileDialog, v.w)
|
||||||
fileDialog.Show()
|
fileDialog.Show()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -162,6 +164,7 @@ func (v View) getButtonForSelectingDirectoryForSaving() (button *widget.Button,
|
|||||||
buttonMessage.Text = r.Path()
|
buttonMessage.Text = r.Path()
|
||||||
setStringSuccessStyle(buttonMessage)
|
setStringSuccessStyle(buttonMessage)
|
||||||
}, v.w)
|
}, v.w)
|
||||||
|
helper.FileDialogResize(fileDialog, v.w)
|
||||||
fileDialog.Show()
|
fileDialog.Show()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -69,12 +68,7 @@ func (h ConvertorHandler) checkingFFPathUtilities() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var pathsToFF []convertor.FFPathUtilities
|
pathsToFF := getPathsToFF()
|
||||||
if runtime.GOOS == "windows" {
|
|
||||||
pathsToFF = []convertor.FFPathUtilities{{"ffmpeg\\bin\\ffmpeg.exe", "ffmpeg\\bin\\ffprobe.exe"}}
|
|
||||||
} else {
|
|
||||||
pathsToFF = []convertor.FFPathUtilities{{"ffmpeg/bin/ffmpeg", "ffmpeg/bin/ffprobe"}, {"ffmpeg", "ffprobe"}}
|
|
||||||
}
|
|
||||||
for _, item := range pathsToFF {
|
for _, item := range pathsToFF {
|
||||||
ffmpegChecking, _ := h.convertorService.ChangeFFmpegPath(item.FFmpeg)
|
ffmpegChecking, _ := h.convertorService.ChangeFFmpegPath(item.FFmpeg)
|
||||||
if ffmpegChecking == false {
|
if ffmpegChecking == false {
|
||||||
|
10
src/handler/convertor_anyos.go
Normal file
10
src/handler/convertor_anyos.go
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//go:build !windows
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import "ffmpegGui/convertor"
|
||||||
|
|
||||||
|
func getPathsToFF() []convertor.FFPathUtilities {
|
||||||
|
return []convertor.FFPathUtilities{{"ffmpeg/bin/ffmpeg", "ffmpeg/bin/ffprobe"}, {"ffmpeg", "ffprobe"}}
|
||||||
|
}
|
8
src/handler/convertor_windows.go
Normal file
8
src/handler/convertor_windows.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build windows
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package handler
|
||||||
|
|
||||||
|
func getPathsToFF() []convertor.FFPathUtilities {
|
||||||
|
return []convertor.FFPathUtilities{{"ffmpeg\\bin\\ffmpeg.exe", "ffmpeg\\bin\\ffprobe.exe"}}
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package helper
|
package helper
|
||||||
|
|
||||||
import "runtime"
|
import (
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/dialog"
|
||||||
|
)
|
||||||
|
|
||||||
func PathSeparator() string {
|
func FileDialogResize(fileDialog *dialog.FileDialog, w fyne.Window) {
|
||||||
if runtime.GOOS == "windows" {
|
contentSize := w.Content().Size()
|
||||||
return "\\"
|
fileDialog.Resize(fyne.Size{Width: contentSize.Width - 50, Height: contentSize.Height - 50})
|
||||||
}
|
|
||||||
return "/"
|
|
||||||
}
|
}
|
||||||
|
8
src/helper/path_separator.go
Normal file
8
src/helper/path_separator.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build !windows
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package helper
|
||||||
|
|
||||||
|
func PathSeparator() string {
|
||||||
|
return "/"
|
||||||
|
}
|
8
src/helper/path_separator_window.go
Normal file
8
src/helper/path_separator_window.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build windows
|
||||||
|
// +build windows
|
||||||
|
|
||||||
|
package helper
|
||||||
|
|
||||||
|
func PathSeparator() string {
|
||||||
|
return "\\"
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package setting
|
package setting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"ffmpegGui/helper"
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@ -81,6 +82,7 @@ func (v View) getButtonSelectFile() (filePath *string, button *widget.Button, bu
|
|||||||
buttonMessage.Text = r.URI().Path()
|
buttonMessage.Text = r.URI().Path()
|
||||||
setStringSuccessStyle(buttonMessage)
|
setStringSuccessStyle(buttonMessage)
|
||||||
}, v.w)
|
}, v.w)
|
||||||
|
helper.FileDialogResize(fileDialog, v.w)
|
||||||
fileDialog.Show()
|
fileDialog.Show()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user