added update check, save set path

This commit is contained in:
aomizu
2025-05-21 13:51:44 +09:00
parent cb57bdab57
commit 5bda331bde
6 changed files with 138 additions and 24 deletions

33
main.go
View File

@@ -1,20 +1,45 @@
package main
import (
"turtlesilicon/pkg/ui"
"turtlesilicon/pkg/utils" /
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"turtlesilicon/pkg/ui" // Updated import path
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
)
const appVersion = "1.0.5"
const appVersion = "1.0.6"
func main() {
myApp := app.NewWithID("com.tairasu.turtlesilicon")
myWindow := myApp.NewWindow("TurtleSilicon v" + appVersion) // Updated title
myWindow := myApp.NewWindow("TurtleSilicon v" + appVersion)
myWindow.Resize(fyne.NewSize(650, 450))
myWindow.SetFixedSize(true)
content := ui.CreateUI(myWindow) // Use the CreateUI function from the ui package
// Check for updates
go func() {
prefs, _ := utils.LoadPrefs()
latest, notes, update, err := utils.CheckForUpdate(appVersion)
if err == nil && update && prefs.SuppressedUpdateVersion != latest {
checkbox := widget.NewCheck("Do not show this anymore", func(bool) {})
content := container.NewVBox(
widget.NewLabel("A new version ("+latest+") is available!"),
widget.NewLabel("Release notes:\n\n"+notes),
checkbox,
)
dialog.ShowCustomConfirm("Update Available", "OK", "Cancel", content, func(ok bool) {
if checkbox.Checked {
prefs.SuppressedUpdateVersion = latest
utils.SavePrefs(prefs)
}
}, myWindow)
}
}()
content := ui.CreateUI(myWindow)
myWindow.SetContent(content)
myWindow.ShowAndRun()