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

show license info in another window

This commit is contained in:
Chris Howey 2021-03-24 14:12:06 -05:00
parent ebe2f1d6d3
commit 359de29a9c

View File

@ -1,7 +1,10 @@
package main package main
import ( import (
"bufio"
"bytes"
_ "embed" _ "embed"
"fmt"
"net/url" "net/url"
"strings" "strings"
@ -30,14 +33,32 @@ func aboutTabItem() *container.TabItem {
longdesc = strings.ReplaceAll(longdesc, "</b>", "") longdesc = strings.ReplaceAll(longdesc, "</b>", "")
aboutInfo := widget.NewLabel(longdesc) aboutInfo := widget.NewLabel(longdesc)
aboutInfo.Wrapping = fyne.TextWrapWord aboutInfo.Wrapping = fyne.TextWrapWord
licenseInfo := widget.NewLabel(crocguiLicense + thirdPartyLicenses)
licenseInfo.Hide() acLicense := widget.NewAccordion()
licenseToggle := widget.NewButton("Toggle License Info", func() {
if licenseInfo.Visible() { licenseReader := bytes.NewBufferString(crocguiLicense + thirdPartyLicenses)
licenseInfo.Hide() currentLicense := ""
} else { currentLibrary := "croc"
licenseInfo.Show() scanner := bufio.NewScanner(licenseReader)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "-----") {
acLicense.Append(widget.NewAccordionItem(currentLibrary, widget.NewLabel(currentLicense)))
currentLicense = ""
scanner.Scan()
scanner.Scan()
currentLibrary = scanner.Text()
scanner.Scan()
continue
} }
currentLicense += fmt.Sprintln(line)
}
licenseToggle := widget.NewButton("License Info", func() {
w := fyne.CurrentApp().NewWindow("licenses")
w.SetContent(container.NewScroll(acLicense))
w.Resize(fyne.NewSize(450, 800))
w.Show()
}) })
return container.NewTabItemWithIcon("About", theme.InfoIcon(), container.NewBorder(nil, return container.NewTabItemWithIcon("About", theme.InfoIcon(), container.NewBorder(nil,
widget.NewForm( widget.NewForm(
@ -46,6 +67,6 @@ func aboutTabItem() *container.TabItem {
), ),
nil, nil,
nil, nil,
container.NewVScroll(container.NewVBox(aboutInfo, licenseToggle, licenseInfo)), container.NewVScroll(container.NewVBox(aboutInfo, licenseToggle)),
)) ))
} }