1
0
mirror of https://github.com/taigrr/crocgui synced 2025-01-18 04:03:16 -08:00

copy icon

This commit is contained in:
Chris Howey 2021-02-14 14:05:37 -06:00
parent 7aa7e5269f
commit 42175e97f0

15
main.go
View File

@ -48,6 +48,13 @@ func sendTabItem(w fyne.Window) *container.TabItem {
prog := widget.NewProgressBar() prog := widget.NewProgressBar()
prog.Hide() prog.Hide()
topline := widget.NewLabel("Pick a file to send") topline := widget.NewLabel("Pick a file to send")
var currentCode string
copyCodeButton := widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
if currentCode != "" {
w.Clipboard().SetContent(currentCode)
}
})
copyCodeButton.Hide()
return container.NewTabItemWithIcon("Send", theme.MailSendIcon(), return container.NewTabItemWithIcon("Send", theme.MailSendIcon(),
container.NewVBox( container.NewVBox(
topline, topline,
@ -72,7 +79,6 @@ func sendTabItem(w fyne.Window) *container.TabItem {
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} else if f != nil { } else if f != nil {
status.SetText("Receive Code: " + randomName)
fpath := fixpath(f.URI().Path()) fpath := fixpath(f.URI().Path())
fi, sterr := os.Stat(fpath) fi, sterr := os.Stat(fpath)
@ -80,6 +86,9 @@ func sendTabItem(w fyne.Window) *container.TabItem {
status.SetText(fmt.Sprintf("Stat error: %s - %s", fpath, sterr.Error())) status.SetText(fmt.Sprintf("Stat error: %s - %s", fpath, sterr.Error()))
return return
} }
status.SetText("Receive Code: " + randomName)
currentCode = randomName
copyCodeButton.Show()
filename = filepath.Base(fpath) filename = filepath.Base(fpath)
topline.SetText(fmt.Sprintf("Sending file: %s", filename)) topline.SetText(fmt.Sprintf("Sending file: %s", filename))
totalsize := fi.Size() totalsize := fi.Size()
@ -111,12 +120,14 @@ func sendTabItem(w fyne.Window) *container.TabItem {
} else { } else {
status.SetText(fmt.Sprintf("Sent file %s", filename)) status.SetText(fmt.Sprintf("Sent file %s", filename))
} }
currentCode = ""
copyCodeButton.Hide()
}() }()
} }
}, w) }, w)
}), }),
prog, prog,
status, container.NewHBox(status, copyCodeButton),
)) ))
} }