main.go 887 Bytes
Newer Older
1
2
package main

Loïck Bonniot's avatar
Loïck Bonniot committed
3
4
import (
	"dfss"
5
	"dfss/gui/authform"
6
	"dfss/gui/config"
Loïck Bonniot's avatar
Loïck Bonniot committed
7
	"dfss/gui/contractform"
Loïck Bonniot's avatar
Loïck Bonniot committed
8
9
10
11
	"dfss/gui/userform"
	"github.com/visualfc/goqt/ui"
)

12
func main() {
13
14
15
16
	// Load configuration
	conf := config.Load()

	// Start first window
17
	ui.Run(func() {
Loïck Bonniot's avatar
Loïck Bonniot committed
18
		window := ui.NewMainWindow()
19
20
21

		var newuser *userform.Widget
		var newauth *authform.Widget
Loïck Bonniot's avatar
Loïck Bonniot committed
22
		var newcontract *contractform.Widget
23
24

		newauth = authform.NewWidget(&conf, func() {
Loïck Bonniot's avatar
Loïck Bonniot committed
25
			window.SetCentralWidget(newcontract)
26
27
28
		})

		newuser = userform.NewWidget(&conf, func(pwd string) {
Loïck Bonniot's avatar
Loïck Bonniot committed
29
			window.SetCentralWidget(newauth)
30
31
		})

Loïck Bonniot's avatar
Loïck Bonniot committed
32
33
		newcontract = contractform.NewWidget(&conf)

34
		if conf.Authenticated {
Loïck Bonniot's avatar
Loïck Bonniot committed
35
			window.SetCentralWidget(newcontract)
36
		} else if conf.Registered {
Loïck Bonniot's avatar
Loïck Bonniot committed
37
			window.SetCentralWidget(newauth)
38
		} else {
Loïck Bonniot's avatar
Loïck Bonniot committed
39
			window.SetCentralWidget(newuser)
40
		}
41

Loïck Bonniot's avatar
Loïck Bonniot committed
42
43
		window.SetWindowTitle("DFSS Client v" + dfss.Version)
		window.Show()
44
45
	})
}