Commit 6b15de31 authored by Loïck Bonniot's avatar Loïck Bonniot

[gui] Refactor to simplify custom Widgets

parent ab8cd887
Pipeline #407 passed with stage
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
) )
type Widget struct { type Widget struct {
W *ui.QWidget *ui.QWidget
} }
func NewWidget(conf *config.Config, onAuth func()) *Widget { func NewWidget(conf *config.Config, onAuth func()) *Widget {
...@@ -39,7 +39,5 @@ func NewWidget(conf *config.Config, onAuth func()) *Widget { ...@@ -39,7 +39,5 @@ func NewWidget(conf *config.Config, onAuth func()) *Widget {
} }
}) })
return &Widget{ return &Widget{QWidget: form}
W: form,
}
} }
set GOARCH=386
set CGO_ENABLED=1
..\..\github.com\visualfc\goqt\bin\goqt_rcc.exe -go main -o application.qrc.go application.qrc
go build -v -ldflags "-H windowsgui" -o ..\bin\gui.exe
\ No newline at end of file
...@@ -23,22 +23,22 @@ func main() { ...@@ -23,22 +23,22 @@ func main() {
var newauth *authform.Widget var newauth *authform.Widget
newauth = authform.NewWidget(&conf, func() { newauth = authform.NewWidget(&conf, func() {
layout.RemoveWidget(newauth.W) layout.RemoveWidget(newauth)
newauth.W.Hide() newauth.Hide()
}) })
newuser = userform.NewWidget(&conf, func(pwd string) { newuser = userform.NewWidget(&conf, func(pwd string) {
layout.RemoveWidget(newuser.W) layout.RemoveWidget(newuser)
newuser.W.Hide() newuser.Hide()
layout.AddWidget(newauth.W) layout.AddWidget(newauth)
}) })
if conf.Authenticated { if conf.Authenticated {
// TODO // TODO
} else if conf.Registered { } else if conf.Registered {
layout.AddWidget(newauth.W) layout.AddWidget(newauth)
} else { } else {
layout.AddWidget(newuser.W) layout.AddWidget(newuser)
} }
w := ui.NewWidget() w := ui.NewWidget()
...@@ -46,8 +46,5 @@ func main() { ...@@ -46,8 +46,5 @@ func main() {
w.SetWindowTitle("DFSS Client v" + dfss.Version) w.SetWindowTitle("DFSS Client v" + dfss.Version)
w.SetFixedSizeWithWidthHeight(WIDTH, HEIGHT) w.SetFixedSizeWithWidthHeight(WIDTH, HEIGHT)
w.Show() w.Show()
ev := ui.NewCloseEvent()
w.CloseEvent(ev)
}) })
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
) )
type Widget struct { type Widget struct {
W *ui.QWidget *ui.QWidget
} }
func NewWidget(conf *config.Config, onRegistered func(pw string)) *Widget { func NewWidget(conf *config.Config, onRegistered func(pw string)) *Widget {
...@@ -65,7 +65,7 @@ func NewWidget(conf *config.Config, onRegistered func(pw string)) *Widget { ...@@ -65,7 +65,7 @@ func NewWidget(conf *config.Config, onRegistered func(pw string)) *Widget {
feedbackLabel.SetText("Registration aborted.") feedbackLabel.SetText("Registration aborted.")
}) })
return &Widget{W: form} return &Widget{QWidget: form}
} }
func copyCA(from string, to string) error { func copyCA(from string, to string) error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment