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

View File

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