From 1bc86b7ec55f9a366622b40f1f229311b502797e Mon Sep 17 00:00:00 2001 From: Joshua Rich Date: Mon, 3 Jul 2023 11:01:21 +0000 Subject: [PATCH] fix(agent): tray menu entries did not display windows and quit did not work --- internal/agent/ui.go | 10 ++- internal/translations/catalog.go | 36 +++++----- .../translations/locales/en/out.gotext.json | 70 +++++++++++-------- 3 files changed, 69 insertions(+), 47 deletions(-) diff --git a/internal/agent/ui.go b/internal/agent/ui.go index 707f69f50..6042ea006 100644 --- a/internal/agent/ui.go +++ b/internal/agent/ui.go @@ -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. @@ -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) } } diff --git a/internal/translations/catalog.go b/internal/translations/catalog.go index 08692d27c..be6709a69 100644 --- a/internal/translations/catalog.go +++ b/internal/translations/catalog.go @@ -38,35 +38,37 @@ func init() { } var messageKeyToIndex = map[string]int{ - "%s: %s": 12, + "%s: %s": 14, + "About": 6, "App Registration": 0, - "App Version: %s\tHA Version: %s": 6, + "App Version: %s\tHA Version: %s": 12, "As an initial step, this app will need to log into your Home Assistant server and register itself.\nPlease enter the relevant details for your Home Assistant server url/port and a long-lived access token.": 5, "Auto-discovered Servers": 2, "Manual Server Entry": 4, - "Ok": 7, - "Report Issue": 8, - "Request Feature": 9, - "Sensors": 11, - "Settings": 10, + "Ok": 13, + "Quit": 11, + "Report Issue": 7, + "Request Feature": 8, + "Sensors": 10, + "Settings": 9, "Token": 1, "Use Custom Server?": 3, } -var enIndex = []uint32{ // 14 elements +var enIndex = []uint32{ // 16 elements 0x00000000, 0x00000011, 0x00000017, 0x0000002f, - 0x00000042, 0x00000056, 0x00000122, 0x00000147, - 0x0000014a, 0x00000157, 0x00000167, 0x00000170, - 0x00000178, 0x00000185, -} // Size: 80 bytes + 0x00000042, 0x00000056, 0x00000122, 0x00000128, + 0x00000135, 0x00000145, 0x0000014e, 0x00000156, + 0x0000015b, 0x00000180, 0x00000183, 0x00000190, +} // Size: 88 bytes -const enData string = "" + // Size: 389 bytes +const enData string = "" + // Size: 400 bytes "\x02App Registration\x02Token\x02Auto-discovered Servers\x02Use Custom S" + "erver?\x02Manual Server Entry\x02As an initial step, this app will need " + "to log into your Home Assistant server and register itself.\x0aPlease en" + "ter the relevant details for your Home Assistant server url/port and a l" + - "ong-lived access token.\x02App Version: %[1]s\x09HA Version: %[2]s\x02Ok" + - "\x02Report Issue\x02Request Feature\x02Settings\x02Sensors\x02%[1]s: %[2" + - "]s" + "ong-lived access token.\x02About\x02Report Issue\x02Request Feature\x02S" + + "ettings\x02Sensors\x02Quit\x02App Version: %[1]s\x09HA Version: %[2]s" + + "\x02Ok\x02%[1]s: %[2]s" - // Total table size 469 bytes (0KiB); checksum: ACEB68F6 + // Total table size 488 bytes (0KiB); checksum: A4215158 diff --git a/internal/translations/locales/en/out.gotext.json b/internal/translations/locales/en/out.gotext.json index 4597907b7..f709e2924 100644 --- a/internal/translations/locales/en/out.gotext.json +++ b/internal/translations/locales/en/out.gotext.json @@ -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 }, @@ -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}",