main: move appname to constant

This commit is contained in:
mappu 2024-06-28 11:53:01 +12:00
parent 5b8883d31a
commit 975e120530
2 changed files with 10 additions and 5 deletions

View File

@ -7,7 +7,7 @@ import (
type noLoadedDatabase struct{} type noLoadedDatabase struct{}
func (n *noLoadedDatabase) DisplayName() string { func (n *noLoadedDatabase) DisplayName() string {
return "yvbolt" return APPNAME
} }
func (n *noLoadedDatabase) DriverName() string { func (n *noLoadedDatabase) DriverName() string {

13
main.go
View File

@ -12,6 +12,11 @@ import (
"github.com/ying32/govcl/vcl/types/colors" "github.com/ying32/govcl/vcl/types/colors"
) )
const (
APPNAME = "yvbolt"
HOMEPAGE_URL = "https://code.ivysaur.me/yvbolt"
)
type TMainForm struct { type TMainForm struct {
*vcl.TForm *vcl.TForm
@ -40,7 +45,7 @@ func main() {
func (f *TMainForm) OnFormCreate(sender vcl.IObject) { func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
f.ImageList = loadImages(f) f.ImageList = loadImages(f)
f.SetCaption("yvbolt") f.SetCaption(APPNAME)
f.ScreenCenter() f.ScreenCenter()
f.ImageList.GetIcon(imgDatabaseLightning, f.Icon()) f.ImageList.GetIcon(imgDatabaseLightning, f.Icon())
@ -127,7 +132,7 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
mnuHelp.Add(mnuHelpVersion) mnuHelp.Add(mnuHelpVersion)
mnuHelpHomepage := vcl.NewMenuItem(mnuHelp) mnuHelpHomepage := vcl.NewMenuItem(mnuHelp)
mnuHelpHomepage.SetCaption("About yvbolt") mnuHelpHomepage.SetCaption("About " + APPNAME)
mnuHelpHomepage.SetShortCutFromString("F1") mnuHelpHomepage.SetShortCutFromString("F1")
mnuHelpHomepage.SetOnClick(f.OnMnuHelpHomepage) mnuHelpHomepage.SetOnClick(f.OnMnuHelpHomepage)
mnuHelp.Add(mnuHelpHomepage) mnuHelp.Add(mnuHelpHomepage)
@ -341,7 +346,7 @@ func (f *TMainForm) OnMnuFileExitClick(sender vcl.IObject) {
} }
func (f *TMainForm) OnMnuHelpHomepage(sender vcl.IObject) { func (f *TMainForm) OnMnuHelpHomepage(sender vcl.IObject) {
err := browser.OpenURL("https://code.ivysaur.me/yvbolt") err := browser.OpenURL(HOMEPAGE_URL)
if err != nil { if err != nil {
vcl.ShowMessage("Opening browser: " + err.Error()) vcl.ShowMessage("Opening browser: " + err.Error())
} }
@ -354,7 +359,7 @@ func (f *TMainForm) OnMenuHelpVersion(sender vcl.IObject) {
return return
} }
info := "This version of yvbolt was compiled with:\n" info := "This version of " + APPNAME + " was compiled with:\n"
for _, dep := range bi.Deps { for _, dep := range bi.Deps {
// Filter to only interesting things // Filter to only interesting things