Add unit selector for target file size
This commit is contained in:
parent
cdecc9db04
commit
644ff1bc17
1
DONE.md
1
DONE.md
|
|
@ -767,6 +767,7 @@ This file tracks completed features, fixes, and milestones.
|
||||||
- ✅ Fixed aspect ratio default from 16:9 to Source (dev7)
|
- ✅ Fixed aspect ratio default from 16:9 to Source (dev7)
|
||||||
- ✅ Ranked benchmark results by score and added cancel confirmation
|
- ✅ Ranked benchmark results by score and added cancel confirmation
|
||||||
- ✅ Added estimated audio bitrate fallback when metadata is missing
|
- ✅ Added estimated audio bitrate fallback when metadata is missing
|
||||||
|
- ✅ Made target file size input unit-selectable with numeric-only entry
|
||||||
- ✅ Stabilized video seeking and embedded rendering
|
- ✅ Stabilized video seeking and embedded rendering
|
||||||
- ✅ Improved player window positioning
|
- ✅ Improved player window positioning
|
||||||
- ✅ Fixed clear video functionality
|
- ✅ Fixed clear video functionality
|
||||||
|
|
|
||||||
1
TODO.md
1
TODO.md
|
|
@ -42,6 +42,7 @@ This file tracks upcoming features, improvements, and known issues.
|
||||||
- Dynamic dropdown based on codec
|
- Dynamic dropdown based on codec
|
||||||
- Lossless + Target Size mode support
|
- Lossless + Target Size mode support
|
||||||
- Audio bitrate estimation when metadata is missing
|
- Audio bitrate estimation when metadata is missing
|
||||||
|
- Target size unit selector and numeric entry
|
||||||
|
|
||||||
## Priority Features for dev20+
|
## Priority Features for dev20+
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,15 +217,18 @@ func ParseFileSize(sizeStr string) (int64, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("invalid size format: %s", sizeStr)
|
return 0, fmt.Errorf("invalid size format: %s", sizeStr)
|
||||||
}
|
}
|
||||||
|
if unit == "" {
|
||||||
|
unit = "MB"
|
||||||
|
}
|
||||||
|
|
||||||
// Convert to bytes
|
// Convert to bytes
|
||||||
multiplier := int64(1)
|
multiplier := int64(1)
|
||||||
switch unit {
|
switch unit {
|
||||||
case "KB":
|
case "K", "KB":
|
||||||
multiplier = 1024
|
multiplier = 1024
|
||||||
case "MB":
|
case "M", "MB":
|
||||||
multiplier = 1024 * 1024
|
multiplier = 1024 * 1024
|
||||||
case "GB":
|
case "G", "GB":
|
||||||
multiplier = 1024 * 1024 * 1024
|
multiplier = 1024 * 1024 * 1024
|
||||||
case "B", "":
|
case "B", "":
|
||||||
multiplier = 1
|
multiplier = 1
|
||||||
|
|
|
||||||
96
main.go
96
main.go
|
|
@ -5966,7 +5966,61 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
// Target File Size with smart presets + manual entry
|
// Target File Size with smart presets + manual entry
|
||||||
targetFileSizeEntry = widget.NewEntry()
|
targetFileSizeEntry = widget.NewEntry()
|
||||||
targetFileSizeEntry.SetPlaceHolder("e.g., 25MB, 100MB, 8MB")
|
targetFileSizeEntry.SetPlaceHolder("e.g., 250")
|
||||||
|
targetFileSizeUnitSelect := widget.NewSelect([]string{"KB", "MB", "GB"}, func(value string) {})
|
||||||
|
targetFileSizeUnitSelect.SetSelected("MB")
|
||||||
|
targetSizeManualRow := container.NewBorder(nil, nil, nil, targetFileSizeUnitSelect, targetFileSizeEntry)
|
||||||
|
|
||||||
|
parseSizeParts := func(input string) (string, string, bool) {
|
||||||
|
trimmed := strings.TrimSpace(input)
|
||||||
|
if trimmed == "" {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
upper := strings.ToUpper(trimmed)
|
||||||
|
var num float64
|
||||||
|
var unit string
|
||||||
|
if _, err := fmt.Sscanf(upper, "%f%s", &num, &unit); err != nil {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
numStr := strconv.FormatFloat(num, 'f', -1, 64)
|
||||||
|
return numStr, unit, true
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTargetSizeState := func() {
|
||||||
|
val := strings.TrimSpace(targetFileSizeEntry.Text)
|
||||||
|
if val == "" {
|
||||||
|
state.convert.TargetFileSize = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if num, unit, ok := parseSizeParts(val); ok && unit != "" {
|
||||||
|
if num != val {
|
||||||
|
targetFileSizeEntry.SetText(num)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if unit != targetFileSizeUnitSelect.Selected {
|
||||||
|
targetFileSizeUnitSelect.SetSelected(unit)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val = num
|
||||||
|
}
|
||||||
|
unit := targetFileSizeUnitSelect.Selected
|
||||||
|
if unit == "" {
|
||||||
|
unit = "MB"
|
||||||
|
targetFileSizeUnitSelect.SetSelected(unit)
|
||||||
|
}
|
||||||
|
state.convert.TargetFileSize = val + unit
|
||||||
|
logging.Debug(logging.CatUI, "target file size set to %s", state.convert.TargetFileSize)
|
||||||
|
if buildCommandPreview != nil {
|
||||||
|
buildCommandPreview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetFileSizeUnitSelect.OnChanged = func(value string) {
|
||||||
|
if targetFileSizeEntry.Hidden {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updateTargetSizeState()
|
||||||
|
}
|
||||||
|
|
||||||
updateTargetSizeOptions := func() {
|
updateTargetSizeOptions := func() {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
|
|
@ -6010,8 +6064,17 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
targetFileSizeSelect = widget.NewSelect([]string{"Manual", "25MB", "50MB", "100MB", "200MB", "500MB", "1GB"}, func(value string) {
|
targetFileSizeSelect = widget.NewSelect([]string{"Manual", "25MB", "50MB", "100MB", "200MB", "500MB", "1GB"}, func(value string) {
|
||||||
if value == "Manual" {
|
if value == "Manual" {
|
||||||
targetFileSizeEntry.Show()
|
targetSizeManualRow.Show()
|
||||||
targetFileSizeEntry.SetText(state.convert.TargetFileSize)
|
if state.convert.TargetFileSize != "" {
|
||||||
|
if num, unit, ok := parseSizeParts(state.convert.TargetFileSize); ok {
|
||||||
|
targetFileSizeEntry.SetText(num)
|
||||||
|
if unit != "" {
|
||||||
|
targetFileSizeUnitSelect.SetSelected(unit)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetFileSizeEntry.SetText(state.convert.TargetFileSize)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Extract size from selection (handle "XMB (Y% smaller)" format)
|
// Extract size from selection (handle "XMB (Y% smaller)" format)
|
||||||
var sizeStr string
|
var sizeStr string
|
||||||
|
|
@ -6023,19 +6086,32 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
sizeStr = value
|
sizeStr = value
|
||||||
}
|
}
|
||||||
state.convert.TargetFileSize = sizeStr
|
state.convert.TargetFileSize = sizeStr
|
||||||
targetFileSizeEntry.SetText(sizeStr)
|
if num, unit, ok := parseSizeParts(sizeStr); ok {
|
||||||
targetFileSizeEntry.Hide()
|
targetFileSizeEntry.SetText(num)
|
||||||
|
if unit != "" {
|
||||||
|
targetFileSizeUnitSelect.SetSelected(unit)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetFileSizeEntry.SetText(sizeStr)
|
||||||
|
}
|
||||||
|
targetSizeManualRow.Hide()
|
||||||
}
|
}
|
||||||
logging.Debug(logging.CatUI, "target file size set to %s", state.convert.TargetFileSize)
|
logging.Debug(logging.CatUI, "target file size set to %s", state.convert.TargetFileSize)
|
||||||
})
|
})
|
||||||
targetFileSizeSelect.SetSelected("Manual")
|
targetFileSizeSelect.SetSelected("Manual")
|
||||||
updateTargetSizeOptions()
|
updateTargetSizeOptions()
|
||||||
|
|
||||||
targetFileSizeEntry.SetText(state.convert.TargetFileSize)
|
|
||||||
targetFileSizeEntry.OnChanged = func(val string) {
|
targetFileSizeEntry.OnChanged = func(val string) {
|
||||||
state.convert.TargetFileSize = val
|
updateTargetSizeState()
|
||||||
if buildCommandPreview != nil {
|
}
|
||||||
buildCommandPreview()
|
if state.convert.TargetFileSize != "" {
|
||||||
|
if num, unit, ok := parseSizeParts(state.convert.TargetFileSize); ok {
|
||||||
|
targetFileSizeEntry.SetText(num)
|
||||||
|
if unit != "" {
|
||||||
|
targetFileSizeUnitSelect.SetSelected(unit)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
targetFileSizeEntry.SetText(state.convert.TargetFileSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -6043,7 +6119,7 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
targetSizeContainer = container.NewVBox(
|
targetSizeContainer = container.NewVBox(
|
||||||
widget.NewLabelWithStyle("Target File Size", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
widget.NewLabelWithStyle("Target File Size", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
targetFileSizeSelect,
|
targetFileSizeSelect,
|
||||||
targetFileSizeEntry,
|
targetSizeManualRow,
|
||||||
)
|
)
|
||||||
|
|
||||||
encodingHint := widget.NewLabel("")
|
encodingHint := widget.NewLabel("")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user