1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-20 11:25:37 +01:00

hide to tray menu option

This commit is contained in:
Kyle Spearrin 2018-05-08 09:40:33 -04:00
parent f2b87edb83
commit 9772acad40
5 changed files with 56 additions and 6 deletions

2
jslib

@ -1 +1 @@
Subproject commit e614cffffbaf2b7e290aa5fe511d39e387efb4d5
Subproject commit 3270d8bd0ed46b62262575f5d59fca2414aaf8c7

View File

@ -42,7 +42,7 @@
</div>
<small class="help-block">{{'enableTrayDesc' | i18n}}</small>
</div>
<div class="form-group">
<div class="form-group" *ngIf="showMinToTray">
<div class="checkbox">
<label for="enableMinToTray">
<input id="enableMinToTray" type="checkbox" name="EnableMinToTray"

View File

@ -6,6 +6,8 @@ import {
import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2';
import { DeviceType } from 'jslib/enums/deviceType';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { LockService } from 'jslib/abstractions/lock.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
@ -27,6 +29,7 @@ export class SettingsComponent implements OnInit {
disableFavicons: boolean = false;
enableMinToTray: boolean = false;
enableTray: boolean = false;
showMinToTray: boolean = false;
locale: string;
lockOptions: any[];
localeOptions: any[];
@ -57,6 +60,7 @@ export class SettingsComponent implements OnInit {
}
async ngOnInit() {
this.showMinToTray = this.platformUtilsService.getDevice() === DeviceType.Windows;
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);

View File

@ -1050,5 +1050,8 @@
"showHide": {
"message": "Show / Hide",
"description": "Text for a button that toggles the visibility of the window. Shows the window when it is hidden or hides the window if it is currently open."
},
"hideToTray": {
"message": "Hide to Tray"
}
}

View File

@ -38,7 +38,7 @@ export class MenuMain extends BaseMenu {
unlockedRequiredMenuItems: MenuItem[] = [];
constructor(private main: Main) {
super(main.i18nService, main.windowMain, 'Bitwarden', () => this.main.messagingService.send('logout'));
super(main.i18nService, main.windowMain);
}
init() {
@ -135,7 +135,24 @@ export class MenuMain extends BaseMenu {
},
},
{ type: 'separator' },
this.logOutMenuItemOptions,
{
label: this.i18nService.t('logOut'),
id: 'logOut',
click: () => {
const result = dialog.showMessageBox(this.windowMain.win, {
title: this.i18nService.t('logOut'),
message: this.i18nService.t('logOut'),
detail: this.i18nService.t('logOutConfirmation'),
buttons: [this.i18nService.t('logOut'), this.i18nService.t('cancel')],
cancelId: 1,
defaultId: 0,
noLink: true,
});
if (result === 0) {
this.main.messagingService.send('logout');
}
},
},
];
if (!isMacAppStore() && !isWindowsStore()) {
@ -369,7 +386,7 @@ export class MenuMain extends BaseMenu {
}
template.unshift({
label: this.appName,
label: 'Bitwarden',
submenu: firstMenuPart.concat(firstMenuOptions, [
{ type: 'separator' },
], this.macAppMenuItemOptions),
@ -391,12 +408,38 @@ export class MenuMain extends BaseMenu {
aboutMenuAdditions.push(updateMenuItem);
}
aboutMenuAdditions.push(this.aboutMenuItemOptions);
aboutMenuAdditions.push({
label: this.i18nService.t('aboutBitwarden'),
click: () => {
const aboutInformation = this.i18nService.t('version', app.getVersion()) +
'\nShell ' + process.versions.electron +
'\nRenderer ' + process.versions.chrome +
'\nNode ' + process.versions.node +
'\nArchitecture ' + process.arch;
const result = dialog.showMessageBox(this.windowMain.win, {
title: 'Bitwarden',
message: 'Bitwarden',
detail: aboutInformation,
type: 'info',
noLink: true,
buttons: [this.i18nService.t('ok'), this.i18nService.t('copy')],
});
if (result === 1) {
clipboard.writeText(aboutInformation);
}
},
});
template[template.length - 1].submenu =
(template[template.length - 1].submenu as MenuItemConstructorOptions[]).concat(aboutMenuAdditions);
}
(template[template.length - 2].submenu as MenuItemConstructorOptions[]).splice(1, 0, {
label: this.main.i18nService.t('hideToTray'),
click: () => this.main.messagingService.send('hideToTray'),
accelerator: 'CmdOrCtrl+Shift+M',
});
this.menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(this.menu);
}