0.3.0 Saving config on changes. /JL
This commit is contained in:
28
config.go
28
config.go
@@ -12,6 +12,27 @@ var (
|
||||
ConfigFile string = "BeadImager.conf"
|
||||
)
|
||||
|
||||
func SetConfigShowBeads(s string) {
|
||||
log.Printf("Setting showbeads to: %s\n", s)
|
||||
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||
Config.Set("canvas", "showbeads", s)
|
||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||
}
|
||||
|
||||
func SetConfigShowGrid(s string) {
|
||||
log.Printf("Setting showgrid to: %s\n", s)
|
||||
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||
Config.Set("canvas", "showgrid", s)
|
||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||
}
|
||||
|
||||
func SetConfigScale(s string) {
|
||||
log.Printf("Setting scale to: %s\n", s)
|
||||
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||
Config.Set("canvas", "scale", s)
|
||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||
}
|
||||
|
||||
func ReadConfig() {
|
||||
log.Printf("Reading config file: %s\n", ConfigFile)
|
||||
Config, _ = configparser.Parse(UserPath + Sep + ConfigFile)
|
||||
@@ -49,10 +70,3 @@ func CreateDefaultConfig() {
|
||||
Config.Set("canvas", "backgroundcolor", "#ffffff")
|
||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||
}
|
||||
|
||||
func SetConfigScale(s string) {
|
||||
log.Printf("Setting scale to: %s\n", s)
|
||||
Config, _ := configparser.Parse(UserPath + Sep + ConfigFile)
|
||||
Config.Set("canvas", "scale", s)
|
||||
Config.SaveWithDelimiter(UserPath+Sep+ConfigFile, "=")
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -30,7 +30,7 @@ type MyMainWindow struct {
|
||||
|
||||
const (
|
||||
AppName string = "BeadImager"
|
||||
Version string = "0.2.5"
|
||||
Version string = "0.3.0"
|
||||
CopyRight string = "©2022 Jan Lerking"
|
||||
STD_MESS string = "Ready"
|
||||
LogFile string = "BeadImager.log"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
@@ -104,6 +105,7 @@ func CreateScaleProperties(mw *MyMainWindow) {
|
||||
nn := float64(slider.Value())
|
||||
log.Println("Setting scale number edit value to: ", nn)
|
||||
sc.SetValue(nn)
|
||||
SetConfigScale(fmt.Sprintf("%0.0f", nn))
|
||||
})
|
||||
sc.SetDecimals(0)
|
||||
sc.SetRange(10, 200)
|
||||
@@ -114,6 +116,7 @@ func CreateScaleProperties(mw *MyMainWindow) {
|
||||
nn := float64(sc.Value())
|
||||
log.Println("Setting scale slider value to: ", nn)
|
||||
slider.SetValue(int(nn))
|
||||
SetConfigScale(fmt.Sprintf("%0.0f", nn))
|
||||
})
|
||||
log.Println("Setting background color...")
|
||||
bg, _ := walk.NewSolidColorBrush(walk.RGB(255, 255, 255))
|
||||
@@ -146,6 +149,14 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
||||
case "false":
|
||||
cb.SetChecked(false)
|
||||
}
|
||||
cb.CheckedChanged().Attach(func() {
|
||||
log.Println("Grid checkbox changed")
|
||||
if cb.Checked() {
|
||||
SetConfigShowGrid("false")
|
||||
} else {
|
||||
SetConfigShowGrid("true")
|
||||
}
|
||||
})
|
||||
log.Println("Grid checkbox created")
|
||||
walk.NewHSpacer(grcom)
|
||||
log.Println("Creating grid color button")
|
||||
@@ -163,6 +174,14 @@ func CreateCanvasProperties(mw *MyMainWindow) {
|
||||
case "false":
|
||||
cb.SetChecked(false)
|
||||
}
|
||||
cb.CheckedChanged().Attach(func() {
|
||||
log.Println("Grid checkbox changed")
|
||||
if !cb.Checked() {
|
||||
SetConfigShowBeads("false")
|
||||
} else {
|
||||
SetConfigShowBeads("true")
|
||||
}
|
||||
})
|
||||
log.Println("Pixels checkbox created")
|
||||
log.Println("Creating canvas background color button")
|
||||
grcolb, _ = walk.NewPushButton(mw.properties.propCanvas.property)
|
||||
|
||||
Reference in New Issue
Block a user