feat: add disablement of button before selecting mode
All checks were successful
Cross-Compile Binaries / compile-linux (push) Successful in 5m38s
Cross-Compile Binaries / compile-windows (push) Successful in 12m11s

This commit is contained in:
2026-02-11 13:16:28 +01:00
parent 0989192e9f
commit 90b4d5ddcf
2 changed files with 13 additions and 10 deletions

View File

@@ -78,7 +78,7 @@ func drawSeparator(preNewLine, postNewLine bool) *fyne.Container {
return separContainer
}
func drawModeRow(pathLabel *widget.Label, localPath *string, targetMode *int) *fyne.Container {
func drawModeRow(localPath *string, targetMode *int, fSelecBtn *widget.Button, pathLabel *widget.Label) *fyne.Container {
actionText := widget.NewLabel("Select Mode")
// targetMode is defined as:
// 0 undefined / not used
@@ -87,6 +87,7 @@ func drawModeRow(pathLabel *widget.Label, localPath *string, targetMode *int) *f
var presModeBtn *widget.Button
var videoModeBtn *widget.Button
presModeBtn = widget.NewButton("Presentation", func() {
fSelecBtn.Enable()
*targetMode = 1
presModeBtn.Importance = widget.HighImportance
videoModeBtn.Importance = widget.LowImportance
@@ -103,6 +104,7 @@ func drawModeRow(pathLabel *widget.Label, localPath *string, targetMode *int) *f
)
videoModeBtn = widget.NewButton("Video", func() {
fSelecBtn.Enable()
*targetMode = 2
presModeBtn.Importance = widget.LowImportance
videoModeBtn.Importance = widget.HighImportance
@@ -197,12 +199,11 @@ func drawTargetSection(raspiNames []string, raspiTarget *string, uploadBtn, relo
return wholeCol
}
func drawFileSelection(localPath *string, targetMode *int, parentWindow fyne.Window) (*fyne.Container, *widget.Label) {
func drawFileSelection(localPath *string, targetMode *int, fSelecBtn *widget.Button, parentWindow fyne.Window) (*fyne.Container, *widget.Button, *widget.Label) {
actionText := widget.NewLabel("Select File")
pathLabel := widget.NewLabel("No File Selected Yet...")
var uploadBtn *widget.Button
uploadBtn = widget.NewButton("Click to Select File", func() {
fSelecBtn = widget.NewButton("Click to Select File", func() {
// Use NewFileOpen to get the dialog object
uploadSelecDiag := dialog.NewFileOpen(func(r fyne.URIReadCloser, err error) {
if r != nil {
@@ -211,8 +212,8 @@ func drawFileSelection(localPath *string, targetMode *int, parentWindow fyne.Win
pathLabel.SetText(r.URI().Name())
*localPath = r.URI().Path()
uploadBtn.Importance = widget.HighImportance
refreshButtons(uploadBtn)
fSelecBtn.Importance = widget.HighImportance
refreshButtons(fSelecBtn)
log.Println("Local path of selected file:", *localPath)
}
}, parentWindow)
@@ -233,7 +234,7 @@ func drawFileSelection(localPath *string, targetMode *int, parentWindow fyne.Win
})
uploadWide := container.NewGridWrap(
buttonSize,
uploadBtn,
fSelecBtn,
)
fileSelecRow := container.NewHBox(
@@ -246,7 +247,8 @@ func drawFileSelection(localPath *string, targetMode *int, parentWindow fyne.Win
fileSelecRow,
)
return fileSelecCol, pathLabel
fSelecBtn.Disable()
return fileSelecCol, fSelecBtn, pathLabel
}
// targetMode *int

View File

@@ -77,6 +77,7 @@ func main() {
// Predefine the buttons for future reference
var uploadBtn *widget.Button
var reloadBtn *widget.Button
var fSelecBtn *widget.Button
// Predefine some of the labels
var pathLabel *widget.Label
@@ -90,8 +91,8 @@ func main() {
// Call the draw functions -> ./src/draw.go
footerRow, uploadBtn, reloadBtn = drawFooter(app, &raspiTarget, &localUploadPath, &targetMode, cfg)
fileSelectRow, pathLabel = drawFileSelection(&localUploadPath, &targetMode, w)
modeBtnRow = drawModeRow(pathLabel, &localUploadPath, &targetMode)
fileSelectRow, fSelecBtn, pathLabel = drawFileSelection(&localUploadPath, &targetMode, fSelecBtn, w)
modeBtnRow = drawModeRow(&localUploadPath, &targetMode, fSelecBtn, pathLabel)
tgrtSelectionRow = drawTargetSection(raspiNames, &raspiTarget, uploadBtn, reloadBtn, cfg)
center := container.NewVBox(