From 055f53c553de1ba10a4e83063c8af3eeb2fa6007 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 10 Apr 2019 16:37:14 +0200 Subject: ui: implement about dialog, version info still TODO requires https://github.com/lxn/walk/commit/4e27c2831aefc0a8aece021877aa6c8c6e95e290 Signed-off-by: Alexander Neumann Signed-off-by: Jason A. Donenfeld --- ui/tray.go | 2 +- ui/ui.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 58 insertions(+), 8 deletions(-) (limited to 'ui') diff --git a/ui/tray.go b/ui/tray.go index e5260ae1..c9091211 100644 --- a/ui/tray.go +++ b/ui/tray.go @@ -70,7 +70,7 @@ func (tray *Tray) setup() error { {label: "&Manage tunnels...", handler: tray.mtw.Show, enabled: true}, {label: "&Import tunnel(s) from file...", handler: tray.mtw.onImport, enabled: true}, {separator: true}, - {label: "&About WireGuard", handler: onAbout, enabled: true}, + {label: "&About WireGuard", handler: func() { onAbout(tray.mtw) }, enabled: true}, {label: "&Quit", handler: onQuit, enabled: true}, } { var action *walk.Action diff --git a/ui/ui.go b/ui/ui.go index 7cc96ee2..8ba8725d 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -92,13 +92,63 @@ func onQuit() { walk.App().Exit(0) } -const aboutText = ` -WireGuard -TODO. +func onAbout(owner walk.Form) { + vbl := walk.NewVBoxLayout() + vbl.SetMargins(walk.Margins{80, 20, 80, 20}) + vbl.SetSpacing(10) -Copyright (C) 2019 WireGuard LLC. All Rights Reserved. -` + dlg, _ := walk.NewDialogWithFixedSize(owner) + dlg.SetTitle("About WireGuard") + dlg.SetLayout(vbl) -func onAbout() { - walk.MsgBox(nil, "About WireGuard", aboutText, walk.MsgBoxOK) + font, _ := walk.NewFont("Segoe UI", 9, 0) + dlg.SetFont(font) + + icon, err := walk.NewIconFromResourceIdWithSize(1, walk.Size{128, 128}) + if err != nil { + panic(err) + } + dlg.AddDisposable(icon) + + iv, _ := walk.NewImageView(dlg) + iv.SetImage(icon) + + wgFont, _ := walk.NewFont("Segoe UI", 16, walk.FontBold) + + wgLbl, _ := walk.NewLabel(dlg) + wgLbl.SetFont(wgFont) + wgLbl.SetTextAlignment(walk.AlignCenter) + wgLbl.SetText("WireGuard") + + detailsLbl, _ := walk.NewTextLabel(dlg) + detailsLbl.SetTextAlignment(walk.AlignHCenterVNear) + + detailsLbl.SetText(fmt.Sprintf(`App version: %s +Go backend version: %s + +Copyright © 2019 WireGuard LLC. +All Rights Reserved.`, + "TODO", "TODO")) + + hbl := walk.NewHBoxLayout() + hbl.SetMargins(walk.Margins{VNear: 10}) + + buttonCP, _ := walk.NewComposite(dlg) + buttonCP.SetLayout(hbl) + + walk.NewHSpacer(buttonCP) + + closePB, _ := walk.NewPushButton(buttonCP) + closePB.SetAlignment(walk.AlignHCenterVNear) + closePB.SetText("Close") + closePB.Clicked().Attach(func() { + dlg.Accept() + }) + + walk.NewHSpacer(buttonCP) + + dlg.SetDefaultButton(closePB) + dlg.SetCancelButton(closePB) + + dlg.Run() } -- cgit v1.2.3-59-g8ed1b