1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-25 12:06:07 +01:00

Allow app to start minimized (as tray icon) (#169)

* Allow app to start minimized (as tray icon)

* Rever german locale
This commit is contained in:
h44z 2019-02-02 18:16:32 +01:00 committed by Kyle Spearrin
parent b55ab576ef
commit a380188120
4 changed files with 28 additions and 0 deletions

View File

@ -53,6 +53,16 @@
<small class="help-block">{{'enableMinToTrayDesc' | i18n}}</small> <small class="help-block">{{'enableMinToTrayDesc' | i18n}}</small>
</div> </div>
<div class="form-group" *ngIf="showMinToTray"> <div class="form-group" *ngIf="showMinToTray">
<div class="checkbox">
<label for="startMinimized">
<input id="startMinimized" type="checkbox" name="StartMinimized"
[(ngModel)]="startMinimized" (change)="saveStartMinimized()">
{{'startMinimized' | i18n}}
</label>
</div>
<small class="help-block">{{'startMinimizedDesc' | i18n}}</small>
</div>
<div class="form-group">
<div class="checkbox"> <div class="checkbox">
<label for="enableCloseToTray"> <label for="enableCloseToTray">
<input id="enableCloseToTray" type="checkbox" name="EnableCloseToTray" <input id="enableCloseToTray" type="checkbox" name="EnableCloseToTray"

View File

@ -32,6 +32,7 @@ export class SettingsComponent implements OnInit {
enableCloseToTray: boolean = false; enableCloseToTray: boolean = false;
enableTray: boolean = false; enableTray: boolean = false;
showMinToTray: boolean = false; showMinToTray: boolean = false;
startMinimized: boolean = false;
locale: string; locale: string;
lockOptions: any[]; lockOptions: any[];
localeOptions: any[]; localeOptions: any[];
@ -80,6 +81,7 @@ export class SettingsComponent implements OnInit {
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey); this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
this.enableCloseToTray = await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey); this.enableCloseToTray = await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey);
this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey); this.enableTray = await this.storageService.get<boolean>(ElectronConstants.enableTrayKey);
this.startMinimized = await this.storageService.get<boolean>(ElectronConstants.enableStartMinimizedKey);
this.locale = await this.storageService.get<string>(ConstantsService.localeKey); this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey); this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
} }
@ -111,6 +113,11 @@ export class SettingsComponent implements OnInit {
this.messagingService.send(this.enableTray ? 'showTray' : 'removeTray'); this.messagingService.send(this.enableTray ? 'showTray' : 'removeTray');
} }
async saveStartMinimized() {
await this.storageService.save(ElectronConstants.enableStartMinimizedKey, this.startMinimized);
this.callAnalytics('StartMinimized', this.startMinimized);
}
async saveLocale() { async saveLocale() {
await this.storageService.save(ConstantsService.localeKey, this.locale); await this.storageService.save(ConstantsService.localeKey, this.locale);
this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale }); this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale });

View File

@ -821,6 +821,12 @@
"enableTrayDesc": { "enableTrayDesc": {
"message": "Always show an icon in the system tray." "message": "Always show an icon in the system tray."
}, },
"startMinimized": {
"message": "Start minimized"
},
"startMinimizedDesc": {
"message": "When starting the application, it will only show an icon in the system tray."
},
"language": { "language": {
"message": "Language" "message": "Language"
}, },

View File

@ -12,6 +12,7 @@ import { MessagingMain } from './main/messaging.main';
import { PowerMonitorMain } from './main/powerMonitor.main'; import { PowerMonitorMain } from './main/powerMonitor.main';
import { ConstantsService } from 'jslib/services/constants.service'; import { ConstantsService } from 'jslib/services/constants.service';
import { ElectronConstants } from 'jslib/electron/electronConstants';
import { LowdbStorageService } from 'jslib/services/lowdbStorage.service'; import { LowdbStorageService } from 'jslib/services/lowdbStorage.service';
import { KeytarStorageListener } from 'jslib/electron/keytarStorageListener'; import { KeytarStorageListener } from 'jslib/electron/keytarStorageListener';
@ -103,6 +104,10 @@ export class Main {
click: () => this.messagingService.send('lockVault'), click: () => this.messagingService.send('lockVault'),
}]); }]);
await this.updaterMain.init(); await this.updaterMain.init();
if(await this.storageService.get<boolean>(ElectronConstants.enableStartMinimizedKey)) {
this.trayMain.hideToTray();
}
}, (e: any) => { }, (e: any) => {
// tslint:disable-next-line // tslint:disable-next-line
console.error(e); console.error(e);