mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
Merge pull request #601 from Hinton/feature/fit-finish
Desktop fit & finish
This commit is contained in:
commit
fcbd43a9f8
@ -113,30 +113,50 @@
|
|||||||
<label for="enableMinToTray">
|
<label for="enableMinToTray">
|
||||||
<input id="enableMinToTray" type="checkbox" name="EnableMinToTray"
|
<input id="enableMinToTray" type="checkbox" name="EnableMinToTray"
|
||||||
[(ngModel)]="enableMinToTray" (change)="saveMinToTray()">
|
[(ngModel)]="enableMinToTray" (change)="saveMinToTray()">
|
||||||
{{'enableMinToTray' | i18n}}
|
{{enableMinToTrayText}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<small class="help-block">{{'enableMinToTrayDesc' | i18n}}</small>
|
<small class="help-block">{{enableMinToTrayDescText}}</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" *ngIf="showMinToTray">
|
<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"
|
||||||
[(ngModel)]="enableCloseToTray" (change)="saveCloseToTray()">
|
[(ngModel)]="enableCloseToTray" (change)="saveCloseToTray()">
|
||||||
{{'enableCloseToTray' | i18n}}
|
{{enableCloseToTrayText}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<small class="help-block">{{'enableCloseToTrayDesc' | i18n}}</small>
|
<small class="help-block">{{enableCloseToTrayDescText}}</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" *ngIf="showMinToTray">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label for="startToTray">
|
<label for="startToTray">
|
||||||
<input id="startToTray" type="checkbox" name="StartToTray" [(ngModel)]="startToTray"
|
<input id="startToTray" type="checkbox" name="StartToTray" [(ngModel)]="startToTray"
|
||||||
(change)="saveStartToTray()">
|
(change)="saveStartToTray()">
|
||||||
{{'startToTray' | i18n}}
|
{{startToTrayText}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<small class="help-block">{{'startToTrayDesc' | i18n}}</small>
|
<small class="help-block">{{startToTrayDescText}}</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label for="openAtLogin">
|
||||||
|
<input id="openAtLogin" type="checkbox" name="OpenAtLogin" [(ngModel)]="openAtLogin"
|
||||||
|
(change)="saveOpenAtLogin()">
|
||||||
|
{{'openAtLogin' | i18n}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<small class="help-block">{{'openAtLoginDesc' | i18n}}</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group" *ngIf="showAlwaysShowDock">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label for="alwaysShowDock">
|
||||||
|
<input id="alwaysShowDock" type="checkbox" name="AlwaysShowDock" [(ngModel)]="alwaysShowDock"
|
||||||
|
(change)="saveAlwaysShowDock()">
|
||||||
|
{{'alwaysShowDock' | i18n}}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<small class="help-block">{{'alwaysShowDockDesc' | i18n}}</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="theme">{{'theme' | i18n}}</label>
|
<label for="theme">{{'theme' | i18n}}</label>
|
||||||
|
@ -47,21 +47,45 @@ export class SettingsComponent implements OnInit {
|
|||||||
themeOptions: any[];
|
themeOptions: any[];
|
||||||
clearClipboard: number;
|
clearClipboard: number;
|
||||||
clearClipboardOptions: any[];
|
clearClipboardOptions: any[];
|
||||||
enableTrayText: string;
|
|
||||||
enableTrayDescText: string;
|
|
||||||
supportsBiometric: boolean;
|
supportsBiometric: boolean;
|
||||||
biometric: boolean;
|
biometric: boolean;
|
||||||
biometricText: string;
|
biometricText: string;
|
||||||
|
alwaysShowDock: boolean;
|
||||||
|
showAlwaysShowDock: boolean = false;
|
||||||
|
openAtLogin: boolean;
|
||||||
|
|
||||||
|
enableTrayText: string;
|
||||||
|
enableTrayDescText: string;
|
||||||
|
enableMinToTrayText: string;
|
||||||
|
enableMinToTrayDescText: string;
|
||||||
|
enableCloseToTrayText: string;
|
||||||
|
enableCloseToTrayDescText: string;
|
||||||
|
startToTrayText: string;
|
||||||
|
startToTrayDescText: string;
|
||||||
|
|
||||||
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
constructor(private analytics: Angulartics2, private toasterService: ToasterService,
|
||||||
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
private i18nService: I18nService, private platformUtilsService: PlatformUtilsService,
|
||||||
private storageService: StorageService, private vaultTimeoutService: VaultTimeoutService,
|
private storageService: StorageService, private vaultTimeoutService: VaultTimeoutService,
|
||||||
private stateService: StateService, private messagingService: MessagingService,
|
private stateService: StateService, private messagingService: MessagingService,
|
||||||
private userService: UserService, private cryptoService: CryptoService) {
|
private userService: UserService, private cryptoService: CryptoService) {
|
||||||
const trayKey = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop ?
|
const isMac = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
|
||||||
'enableMenuBar' : 'enableTray';
|
|
||||||
|
const trayKey = isMac ? 'enableMenuBar' : 'enableTray';
|
||||||
this.enableTrayText = this.i18nService.t(trayKey);
|
this.enableTrayText = this.i18nService.t(trayKey);
|
||||||
this.enableTrayDescText = this.i18nService.t(trayKey + 'Desc');
|
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 = [
|
this.vaultTimeouts = [
|
||||||
// { name: i18nService.t('immediately'), value: 0 },
|
// { name: i18nService.t('immediately'), value: 0 },
|
||||||
{ name: i18nService.t('oneMinute'), value: 1 },
|
{ name: i18nService.t('oneMinute'), value: 1 },
|
||||||
@ -114,7 +138,7 @@ export class SettingsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
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.vaultTimeout = await this.storageService.get<number>(ConstantsService.vaultTimeoutKey);
|
||||||
this.vaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
|
this.vaultTimeoutAction = await this.storageService.get<string>(ConstantsService.vaultTimeoutActionKey);
|
||||||
const pinSet = await this.vaultTimeoutService.isPinLockSet();
|
const pinSet = await this.vaultTimeoutService.isPinLockSet();
|
||||||
@ -133,6 +157,9 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
||||||
this.biometric = await this.vaultTimeoutService.isBiometricLockSet();
|
this.biometric = await this.vaultTimeoutService.isBiometricLockSet();
|
||||||
this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText);
|
this.biometricText = await this.storageService.get<string>(ConstantsService.biometricText);
|
||||||
|
this.alwaysShowDock = await this.storageService.get<boolean>(ElectronConstants.alwaysShowDock);
|
||||||
|
this.showAlwaysShowDock = this.platformUtilsService.getDevice() === DeviceType.MacOsDesktop;
|
||||||
|
this.openAtLogin = await this.storageService.get<boolean>(ElectronConstants.openAtLogin);
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveVaultTimeoutOptions() {
|
async saveVaultTimeoutOptions() {
|
||||||
@ -279,6 +306,15 @@ export class SettingsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveAlwaysShowDock() {
|
||||||
|
await this.storageService.save(ElectronConstants.alwaysShowDock, this.alwaysShowDock);
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveOpenAtLogin() {
|
||||||
|
this.storageService.save(ElectronConstants.openAtLogin, this.openAtLogin);
|
||||||
|
this.messagingService.send(this.openAtLogin ? 'addOpenAtLogin' : 'removeOpenAtLogin');
|
||||||
|
}
|
||||||
|
|
||||||
async saveBrowserIntegration() {
|
async saveBrowserIntegration() {
|
||||||
await this.storageService.save(ElectronConstants.enableBrowserIntegration, this.enableBrowserIntegration);
|
await this.storageService.save(ElectronConstants.enableBrowserIntegration, this.enableBrowserIntegration);
|
||||||
this.messagingService.send(this.enableBrowserIntegration ? 'enableBrowserIntegration' : 'disableBrowserIntegration');
|
this.messagingService.send(this.enableBrowserIntegration ? 'enableBrowserIntegration' : 'disableBrowserIntegration');
|
||||||
|
@ -852,12 +852,24 @@
|
|||||||
"enableMinToTrayDesc": {
|
"enableMinToTrayDesc": {
|
||||||
"message": "When minimizing the window, show an icon in the system tray instead."
|
"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": {
|
"enableCloseToTray": {
|
||||||
"message": "Close to Tray Icon"
|
"message": "Close to Tray Icon"
|
||||||
},
|
},
|
||||||
"enableCloseToTrayDesc": {
|
"enableCloseToTrayDesc": {
|
||||||
"message": "When closing the window, show an icon in the system tray instead."
|
"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": {
|
"enableTray": {
|
||||||
"message": "Enable Tray Icon"
|
"message": "Enable Tray Icon"
|
||||||
},
|
},
|
||||||
@ -870,6 +882,24 @@
|
|||||||
"startToTrayDesc": {
|
"startToTrayDesc": {
|
||||||
"message": "When the application is first started, only show an icon in the system tray."
|
"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."
|
||||||
|
},
|
||||||
|
"openAtLogin": {
|
||||||
|
"message": "Start automatically on login"
|
||||||
|
},
|
||||||
|
"openAtLoginDesc": {
|
||||||
|
"message": "Start the Bitwarden Desktop application automatically on login."
|
||||||
|
},
|
||||||
|
"alwaysShowDock": {
|
||||||
|
"message": "Always show in the Dock"
|
||||||
|
},
|
||||||
|
"alwaysShowDockDesc": {
|
||||||
|
"message": "Show the Bitwarden icon in the Dock even when minimized to the menu bar."
|
||||||
|
},
|
||||||
"language": {
|
"language": {
|
||||||
"message": "Language"
|
"message": "Language"
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { ipcMain } from 'electron';
|
import { app, ipcMain } from 'electron';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
import { Main } from '../main';
|
import { Main } from '../main';
|
||||||
|
|
||||||
@ -15,6 +17,12 @@ export class MessagingMain {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.scheduleNextSync();
|
this.scheduleNextSync();
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
this.storageService.save(ElectronConstants.openAtLogin, fs.existsSync(this.linuxStartupFile()));
|
||||||
|
} else {
|
||||||
|
const loginSettings = app.getLoginItemSettings();
|
||||||
|
this.storageService.save(ElectronConstants.openAtLogin, loginSettings.openAtLogin);
|
||||||
|
}
|
||||||
ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message));
|
ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +52,11 @@ export class MessagingMain {
|
|||||||
case 'hideToTray':
|
case 'hideToTray':
|
||||||
this.main.trayMain.hideToTray();
|
this.main.trayMain.hideToTray();
|
||||||
break;
|
break;
|
||||||
|
case 'addOpenAtLogin':
|
||||||
|
this.addOpenAtLogin();
|
||||||
|
break;
|
||||||
|
case 'removeOpenAtLogin':
|
||||||
|
this.removeOpenAtLogin();
|
||||||
case 'setFocus':
|
case 'setFocus':
|
||||||
this.setFocus();
|
this.setFocus();
|
||||||
break;
|
break;
|
||||||
@ -86,6 +99,41 @@ export class MessagingMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private addOpenAtLogin() {
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
const data = `[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Version=${app.getVersion()}
|
||||||
|
Name=Bitwarden
|
||||||
|
Comment=Bitwarden startup script
|
||||||
|
Exec=${app.getPath('exe')}
|
||||||
|
StartupNotify=false
|
||||||
|
Terminal=false`;
|
||||||
|
|
||||||
|
const dir = path.dirname(this.linuxStartupFile());
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(this.linuxStartupFile(), data);
|
||||||
|
} else {
|
||||||
|
app.setLoginItemSettings({openAtLogin: true});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeOpenAtLogin() {
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
if (fs.existsSync(this.linuxStartupFile())) {
|
||||||
|
fs.unlinkSync(this.linuxStartupFile());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.setLoginItemSettings({openAtLogin: false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private linuxStartupFile(): string {
|
||||||
|
return path.join(app.getPath('home'), '.config', 'autostart', 'bitwarden.desktop');
|
||||||
|
}
|
||||||
|
|
||||||
private setFocus() {
|
private setFocus() {
|
||||||
this.main.trayMain.restoreFromTray();
|
this.main.trayMain.restoreFromTray();
|
||||||
this.main.windowMain.win.focusOnWebView();
|
this.main.windowMain.win.focusOnWebView();
|
||||||
|
Loading…
Reference in New Issue
Block a user