1
0
mirror of https://github.com/bitwarden/desktop synced 2025-12-31 23:53:23 +00:00

Add minimize when copying to clipboard option

This commit is contained in:
Elias Papavasileiou
2020-02-24 01:15:25 +02:00
parent 4e2ee15456
commit e7a9a294bf
6 changed files with 51 additions and 2 deletions

View File

@@ -38,6 +38,16 @@
</select>
<small class="help-block">{{'clearClipboardDesc' | i18n}}</small>
</div>
<div class="form-group">
<div class="checkbox">
<label for="minimizeOnCopyToClipboard">
<input id="minimizeOnCopyToClipboard" type="checkbox" name="MinimizeOnCopyToClipboard"
[(ngModel)]="minimizeOnCopyToClipboard" (change)="saveMinOnCopyToClipboard()">
{{'minimizeOnCopyToClipboard' | i18n}}
</label>
</div>
<small class="help-block">{{'minimizeOnCopyToClipboardDesc' | i18n}}</small>
</div>
<div class="form-group">
<div class="checkbox">
<label for="disableFavicons">

View File

@@ -37,6 +37,7 @@ export class SettingsComponent implements OnInit {
enableTray: boolean = false;
showMinToTray: boolean = false;
startToTray: boolean = false;
minimizeOnCopyToClipboard: boolean = false;
locale: string;
lockOptions: any[];
localeOptions: any[];
@@ -120,6 +121,8 @@ export class SettingsComponent implements OnInit {
this.locale = await this.storageService.get<string>(ConstantsService.localeKey);
this.theme = await this.storageService.get<string>(ConstantsService.themeKey);
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
this.minimizeOnCopyToClipboard =
await this.storageService.get<boolean>(ConstantsService.minimizeOnCopyToClipboardKey);
}
async saveLockOption() {
@@ -224,6 +227,11 @@ export class SettingsComponent implements OnInit {
window.setTimeout(() => window.location.reload(), 200);
}
async saveMinOnCopyToClipboard() {
await this.storageService.save(ConstantsService.minimizeOnCopyToClipboardKey, this.minimizeOnCopyToClipboard);
this.callAnalytics('MinOnCopyToClipboard', this.minimizeOnCopyToClipboard);
}
async saveClearClipboard() {
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
this.analytics.eventTrack.next({

View File

@@ -44,8 +44,11 @@ import { EventService } from 'jslib/abstractions/event.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { StorageService } from 'jslib/abstractions/storage.service';
import { SyncService } from 'jslib/abstractions/sync.service';
import { ConstantsService } from 'jslib/services/constants.service';
const SyncInterval = 6 * 60 * 60 * 1000; // 6 hours
const BroadcasterSubscriptionId = 'VaultComponent';
@@ -84,7 +87,8 @@ export class VaultComponent implements OnInit, OnDestroy {
private broadcasterService: BroadcasterService, private changeDetectorRef: ChangeDetectorRef,
private ngZone: NgZone, private syncService: SyncService, private analytics: Angulartics2,
private toasterService: ToasterService, private messagingService: MessagingService,
private platformUtilsService: PlatformUtilsService, private eventService: EventService) { }
private platformUtilsService: PlatformUtilsService, private eventService: EventService,
private storageService: StorageService) { }
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
@@ -159,6 +163,7 @@ export class VaultComponent implements OnInit, OnDestroy {
if (this.cipherId != null && uCipher != null && uCipher.id === this.cipherId &&
uCipher.login != null && uCipher.login.username != null) {
this.copyValue(uCipher.login.username, 'username');
this.minimizeIfNeeded();
}
break;
case 'copyPassword':
@@ -167,6 +172,7 @@ export class VaultComponent implements OnInit, OnDestroy {
if (this.cipherId != null && pCipher != null && pCipher.id === this.cipherId &&
pCipher.login != null && pCipher.login.password != null) {
this.copyValue(pCipher.login.password, 'password');
this.minimizeIfNeeded();
}
break;
default:
@@ -663,6 +669,14 @@ export class VaultComponent implements OnInit, OnDestroy {
});
}
private async minimizeIfNeeded(): Promise<void> {
const shouldMinimize =
await this.storageService.get<boolean>(ConstantsService.minimizeOnCopyToClipboardKey);
if (shouldMinimize) {
this.messagingService.send('minimize');
}
}
private functionWithChangeDetection(func: Function) {
this.ngZone.run(() => {
func();

View File

@@ -112,6 +112,12 @@
"message": "Copy Value",
"description": "Copy value to clipboard"
},
"minimizeOnCopyToClipboard": {
"message": "Minimize when copying to clipboard"
},
"minimizeOnCopyToClipboardDesc": {
"message": "Bitwarden will minimize when credentials are copied to clipboard."
},
"toggleVisibility": {
"message": "Toggle Visibility"
},

View File

@@ -112,6 +112,12 @@
"message": "Copy value",
"description": "Copy value to clipboard"
},
"minimizeOnCopyToClipboard": {
"message": "Minimize when copying to clipboard"
},
"minimizeOnCopyToClipboardDesc": {
"message": "Bitwarden will minimize when credentials are copied to clipboard."
},
"toggleVisibility": {
"message": "Toggle visibility"
},
@@ -1274,4 +1280,4 @@
"unsavedChangesTitle": {
"message": "Unsaved Changes"
}
}
}

View File

@@ -23,6 +23,11 @@ export class MessagingMain {
this.main.menuMain.updateApplicationMenuState(message.isAuthenticated, message.isLocked);
this.updateTrayMenu(message.isAuthenticated, message.isLocked);
break;
case 'minimize':
if (this.main.windowMain.win != null) {
this.main.windowMain.win.minimize();
}
break;
case 'showTray':
this.main.trayMain.showTray();
break;