-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPreferences.go
49 lines (41 loc) · 1.06 KB
/
Preferences.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package Config
import (
"context"
"github.com/wailsapp/wails/v2/pkg/runtime"
"wails_vue/backend/FileStore"
)
type PaneSize struct {
Min float64 `json:"min"`
Max float64 `json:"max"`
Size float64 `json:"size"`
}
type Preferences struct {
Ctx context.Context `json:"-"`
EditorFontSize int `json:"editorFontSize"`
QueryResultFontSize int `json:"queryResultFontSize"`
PaneSizes []PaneSize `json:"paneSizes"`
PanelLayout string `json:"panelLayout"`
}
func (p *Preferences) Setup() {
p.PaneSizes = []PaneSize{
{Min: 10, Max: 100, Size: 90},
{Min: 10, Max: 100, Size: 10},
}
p.EditorFontSize = 16
p.QueryResultFontSize = 14
p.PanelLayout = "horizontal"
}
func (p *Preferences) Update(data *Preferences) {
p.EditorFontSize = data.EditorFontSize
p.QueryResultFontSize = data.QueryResultFontSize
p.PaneSizes = data.PaneSizes
p.PanelLayout = data.PanelLayout
err := FileStore.Save[Preferences](p)
if err != nil {
runtime.LogError(p.Ctx, err.Error())
}
}
func (p *Preferences) UpdatePaneSizes(panes []PaneSize) {
p.PaneSizes = panes
p.Update(p)
}