Skip to content

Commit 5cb2e74

Browse files
authored
Merge pull request #6 from SAP-samples/feature/gui-config-editor
feat(tray): add GUI config editor
2 parents 4b34db1 + fbdcbba commit 5cb2e74

13 files changed

Lines changed: 4107 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ sap-devs-cli.exe
1313
*.bak
1414
*.swp
1515
sap-devs-news
16+
/cmd/sap-devs-tray/data/cities.json

build.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ if ($LASTEXITCODE -eq 0) {
1414
}
1515

1616
if (Test-Path "cmd\sap-devs-tray\go.mod") {
17+
# Copy cities.json for embedding in tray binary
18+
$citiesSrc = "internal\geo\cities.json"
19+
$citiesDst = "cmd\sap-devs-tray\data\cities.json"
20+
if (Test-Path $citiesSrc) {
21+
New-Item -ItemType Directory -Path (Split-Path $citiesDst) -Force | Out-Null
22+
Copy-Item $citiesSrc $citiesDst -Force
23+
}
1724
$env:CGO_ENABLED = "1"
1825
Push-Location cmd\sap-devs-tray
1926
go build -ldflags "-X main.version=$Version" -o ..\..\sap-devs-tray.exe .

cmd/sap-devs-tray/app.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,25 @@ func startApp(srv *Server) error {
4747

4848
srv.hideFunc = func() { panel.Hide() }
4949

50+
configWin := app.Window.NewWithOptions(application.WebviewWindowOptions{
51+
Name: "sap-devs Config",
52+
Width: 520,
53+
Height: 700,
54+
URL: srv.ConfigURL(),
55+
Hidden: true,
56+
})
57+
58+
configWin.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
59+
configWin.Hide()
60+
e.Cancel()
61+
})
62+
63+
srv.configWindowFunc = func() {
64+
configWin.SetURL(srv.ConfigURL())
65+
configWin.Show()
66+
configWin.Focus()
67+
}
68+
5069
systemTray := app.SystemTray.New()
5170
systemTray.SetIcon(trayIcon)
5271
systemTray.SetTooltip("sap-devs")
@@ -68,6 +87,13 @@ func startApp(srv *Server) error {
6887
}()
6988
})
7089

90+
menu.AddSeparator()
91+
menu.Add("Config...").OnClick(func(ctx *application.Context) {
92+
if srv.configWindowFunc != nil {
93+
srv.configWindowFunc()
94+
}
95+
})
96+
7197
menu.AddSeparator()
7298
menu.Add("Open Terminal...").OnClick(func(ctx *application.Context) {
7399
openTerminal()

0 commit comments

Comments
 (0)