Add support on mac for minimize to menu bar on close, minimize or start

This commit is contained in:
Hinton 2020-11-20 17:20:51 +01:00
parent ae5a5082db
commit 2cbe7f3d0a
3 changed files with 50 additions and 11 deletions

View File

@ -103,30 +103,30 @@
<label for="enableMinToTray">
<input id="enableMinToTray" type="checkbox" name="EnableMinToTray"
[(ngModel)]="enableMinToTray" (change)="saveMinToTray()">
{{'enableMinToTray' | i18n}}
{{enableMinToTrayText}}
</label>
</div>
<small class="help-block">{{'enableMinToTrayDesc' | i18n}}</small>
<small class="help-block">{{enableMinToTrayDescText}}</small>
</div>
<div class="form-group" *ngIf="showMinToTray">
<div class="checkbox">
<label for="enableCloseToTray">
<input id="enableCloseToTray" type="checkbox" name="EnableCloseToTray"
[(ngModel)]="enableCloseToTray" (change)="saveCloseToTray()">
{{'enableCloseToTray' | i18n}}
{{enableCloseToTrayText}}
</label>
</div>
<small class="help-block">{{'enableCloseToTrayDesc' | i18n}}</small>
<small class="help-block">{{enableCloseToTrayDescText}}</small>
</div>
<div class="form-group" *ngIf="showMinToTray">
<div class="checkbox">
<label for="startToTray">
<input id="startToTray" type="checkbox" name="StartToTray" [(ngModel)]="startToTray"
(change)="saveStartToTray()">
{{'startToTray' | i18n}}
{{startToTrayText}}
</label>
</div>
<small class="help-block">{{'startToTrayDesc' | i18n}}</small>
<small class="help-block">{{startToTrayDescText}}</small>
</div>
<div class="form-group" *ngIf="showAlwaysShowDock">
<div class="checkbox">

View File

@ -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<number>(ConstantsService.vaultTimeoutKey);
this.vaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
const pinSet = await this.vaultTimeoutService.isPinLockSet();

View File

@ -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"
},