From 2cbe7f3d0a888fbf80455c28999ab339250d89e8 Mon Sep 17 00:00:00 2001 From: Hinton Date: Fri, 20 Nov 2020 17:20:51 +0100 Subject: [PATCH] Add support on mac for minimize to menu bar on close, minimize or start --- src/app/accounts/settings.component.html | 12 ++++----- src/app/accounts/settings.component.ts | 31 ++++++++++++++++++++---- src/locales/en/messages.json | 18 ++++++++++++++ 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/app/accounts/settings.component.html b/src/app/accounts/settings.component.html index 496cc085f5..bd790948e4 100644 --- a/src/app/accounts/settings.component.html +++ b/src/app/accounts/settings.component.html @@ -103,30 +103,30 @@ - {{'enableMinToTrayDesc' | i18n}} + {{enableMinToTrayDescText}}
- {{'enableCloseToTrayDesc' | i18n}} + {{enableCloseToTrayDescText}}
- {{'startToTrayDesc' | i18n}} + {{startToTrayDescText}}
diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 7ceda1fd11..8563296e2e 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -46,23 +46,44 @@ export class SettingsComponent implements OnInit { themeOptions: any[]; clearClipboard: number; clearClipboardOptions: any[]; - enableTrayText: string; - enableTrayDescText: string; supportsBiometric: boolean; biometric: boolean; biometricText: string; alwaysShowDock: boolean; showAlwaysShowDock: boolean = false; + enableTrayText: string; + enableTrayDescText: string; + enableMinToTrayText: string; + enableMinToTrayDescText: string; + enableCloseToTrayText: string; + enableCloseToTrayDescText: string; + startToTrayText: string; + startToTrayDescText: string; + constructor(private analytics: Angulartics2, private toasterService: ToasterService, private i18nService: I18nService, private platformUtilsService: PlatformUtilsService, private storageService: StorageService, private vaultTimeoutService: VaultTimeoutService, private stateService: StateService, private messagingService: MessagingService, private userService: UserService, private cryptoService: CryptoService) { - const trayKey = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop ? - 'enableMenuBar' : 'enableTray'; + const isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop; + + const trayKey = isMac ? 'enableMenuBar' : 'enableTray'; this.enableTrayText = this.i18nService.t(trayKey); this.enableTrayDescText = this.i18nService.t(trayKey + 'Desc'); + + const minToTrayKey = isMac ? 'enableMinToMenuBar' : 'enableMinToTray'; + this.enableMinToTrayText = this.i18nService.t(minToTrayKey) + this.enableMinToTrayDescText = this.i18nService.t(minToTrayKey + 'Desc'); + + const closeToTrayKey = isMac ? 'enableCloseToMenuBar' : 'enableCloseToTray'; + this.enableCloseToTrayText = this.i18nService.t(closeToTrayKey) + this.enableCloseToTrayDescText = this.i18nService.t(closeToTrayKey + 'Desc'); + + const startToTrayKey = isMac ? 'startToMenuBar' : 'startToTray'; + this.startToTrayText = this.i18nService.t(startToTrayKey) + this.startToTrayDescText = this.i18nService.t(startToTrayKey + 'Desc'); + this.vaultTimeouts = [ // { name: i18nService.t('immediately'), value: 0 }, { name: i18nService.t('oneMinute'), value: 1 }, @@ -115,7 +136,7 @@ export class SettingsComponent implements OnInit { } async ngOnInit() { - this.showMinToTray = this.platformUtilsService.getDevice() === DeviceType.WindowsDesktop; + this.showMinToTray = this.platformUtilsService.getDevice() !== DeviceType.LinuxDesktop; this.vaultTimeout = await this.storageService.get(ConstantsService.vaultTimeoutKey); this.vaultTimeoutAction = await this.storageService.get(ConstantsService.vaultTimeoutActionKey); const pinSet = await this.vaultTimeoutService.isPinLockSet(); diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 27cd720c76..dab599731e 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -852,12 +852,24 @@ "enableMinToTrayDesc": { "message": "When minimizing the window, show an icon in the system tray instead." }, + "enableMinToMenuBar": { + "message": "Minimize to menu bar" + }, + "enableMinToMenuBarDesc": { + "message": "When minimizing the window, show an icon in the menu bar instead." + }, "enableCloseToTray": { "message": "Close to Tray Icon" }, "enableCloseToTrayDesc": { "message": "When closing the window, show an icon in the system tray instead." }, + "enableCloseToMenuBar": { + "message": "Close to menu bar" + }, + "enableCloseToMenuBarDesc": { + "message": "When closing the window, show an icon in the menu bar instead." + }, "enableTray": { "message": "Enable Tray Icon" }, @@ -870,6 +882,12 @@ "startToTrayDesc": { "message": "When the application is first started, only show an icon in the system tray." }, + "startToMenuBar": { + "message": "Start to menu bar" + }, + "startToMenuBarDesc": { + "message": "When the application is first started, only show an icon in the menu bar." + }, "alwaysShowDock": { "message": "Always show in the Dock" },