Skip to content

Commit

Permalink
fix(agent): tray menu entries did not display windows and quit did no…
Browse files Browse the repository at this point in the history
…t work
  • Loading branch information
joshuar committed Jul 3, 2023
1 parent e36bdf4 commit 1bc86b7
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 47 deletions.
10 changes: 8 additions & 2 deletions internal/agent/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func newUI(appID string) fyne.App {
func (agent *Agent) setupSystemTray(ctx context.Context) {
log.Debug().Caller().Msg("Creating tray icon.")
if desk, ok := agent.app.(desktop.App); ok {
menuItemAbout := fyne.NewMenuItem("About", func() {
log.Debug().Caller().Msg("Running in desktop mode. Setting tray menu.")
menuItemAbout := fyne.NewMenuItem(translator.Translate("About"), func() {
agent.aboutWindow(ctx)
})
menuItemIssue := fyne.
Expand All @@ -57,12 +58,17 @@ func (agent *Agent) setupSystemTray(ctx context.Context) {
NewMenuItem(translator.Translate("Sensors"), func() {
agent.sensorsWindow(ctx)
})
menuItemQuit := fyne.NewMenuItem(translator.Translate("Quit"), func() {
close(agent.done)
})
menuItemQuit.IsQuit = true
menu := fyne.NewMenu(agent.Name,
menuItemAbout,
menuItemIssue,
menuItemFeatureRequest,
menuItemSettings,
menuItemSensors)
menuItemSensors,
menuItemQuit)
desk.SetSystemTrayMenu(menu)
}
}
Expand Down
36 changes: 19 additions & 17 deletions internal/translations/catalog.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 42 additions & 28 deletions internal/translations/locales/en/out.gotext.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,9 @@
"fuzzy": true
},
{
"id": "App Version: {Version}\tHA Version: {HassVersion}",
"message": "App Version: {Version}\tHA Version: {HassVersion}",
"translation": "App Version: {Version}\tHA Version: {HassVersion}",
"translatorComment": "Copied from source.",
"placeholders": [
{
"id": "Version",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "agent.Version"
},
{
"id": "HassVersion",
"string": "%[2]s",
"type": "interface{}",
"underlyingType": "interface{}",
"argNum": 2,
"expr": "hassVersion"
}
],
"fuzzy": true
},
{
"id": "Ok",
"message": "Ok",
"translation": "Ok",
"id": "About",
"message": "About",
"translation": "About",
"translatorComment": "Copied from source.",
"fuzzy": true
},
Expand Down Expand Up @@ -103,6 +78,45 @@
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "Quit",
"message": "Quit",
"translation": "Quit",
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "App Version: {Version}\tHA Version: {HassVersion}",
"message": "App Version: {Version}\tHA Version: {HassVersion}",
"translation": "App Version: {Version}\tHA Version: {HassVersion}",
"translatorComment": "Copied from source.",
"placeholders": [
{
"id": "Version",
"string": "%[1]s",
"type": "string",
"underlyingType": "string",
"argNum": 1,
"expr": "agent.Version"
},
{
"id": "HassVersion",
"string": "%[2]s",
"type": "interface{}",
"underlyingType": "interface{}",
"argNum": 2,
"expr": "hassVersion"
}
],
"fuzzy": true
},
{
"id": "Ok",
"message": "Ok",
"translation": "Ok",
"translatorComment": "Copied from source.",
"fuzzy": true
},
{
"id": "{Name}: {S}",
"message": "{Name}: {S}",
Expand Down

0 comments on commit 1bc86b7

Please sign in to comment.