From 21b0053ccba81882178407b274e1c72644a36bda Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Wed, 8 Apr 2020 19:36:19 -0400 Subject: [PATCH] Copy login name on shift & update UI to reflect it. --- platform-darwin/Source/Mac/MPSiteModel.m | 7 ++++++- .../Source/Mac/MPSitesWindowController.m | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/platform-darwin/Source/Mac/MPSiteModel.m b/platform-darwin/Source/Mac/MPSiteModel.m index 73080cda..01907209 100644 --- a/platform-darwin/Source/Mac/MPSiteModel.m +++ b/platform-darwin/Source/Mac/MPSiteModel.m @@ -270,7 +270,9 @@ PearlMainQueue( ^{ self.content = result; - self.displayedContent = displayResult; + + if (!([NSEvent modifierFlags] & NSShiftKeyMask)) + self.displayedContent = displayResult; } ); } @@ -278,6 +280,9 @@ PearlMainQueue( ^{ self.loginName = loginName; + + if ([NSEvent modifierFlags] & NSShiftKeyMask) + self.displayedContent = loginName; } ); } diff --git a/platform-darwin/Source/Mac/MPSitesWindowController.m b/platform-darwin/Source/Mac/MPSitesWindowController.m index f1bedb3a..9fd8a2a4 100644 --- a/platform-darwin/Source/Mac/MPSitesWindowController.m +++ b/platform-darwin/Source/Mac/MPSitesWindowController.m @@ -66,7 +66,7 @@ [self updateUser]; } ); [self observeKeyPath:@"sitesController.selection" withBlock:^(id from, id to, NSKeyValueChange cause, id self) { - [self updateSelection]; + [self updateTable]; }]; prof_rewind( @"observers" ); @@ -105,14 +105,18 @@ - (void)flagsChanged:(NSEvent *)theEvent { BOOL shiftPressed = (theEvent.modifierFlags & NSShiftKeyMask) != 0; - if (shiftPressed != self.shiftPressed) + if (shiftPressed != self.shiftPressed) { self.shiftPressed = shiftPressed; + [self.selectedSite updateContent]; + [self updateSelection]; + } BOOL alternatePressed = (theEvent.modifierFlags & NSAlternateKeyMask) != 0; if (alternatePressed != self.alternatePressed) { self.alternatePressed = alternatePressed; self.showVersionContainer = self.alternatePressed || self.selectedSite.outdated; [self.selectedSite updateContent]; + [self updateSelection]; if (self.locked) { NSTextField *passwordField = self.securePasswordField; @@ -477,7 +481,7 @@ } // Performing action while content is available. Copy it. - [self copyContent:self.shiftPressed? selectedSite.answer: selectedSite.content]; + [self copyContent:self.shiftPressed? selectedSite.loginName: selectedSite.content]; [NSApp hide:nil]; NSUserNotification *notification = [NSUserNotification new]; @@ -582,7 +586,7 @@ }]; } -- (void)updateSelection { +- (void)updateTable { [self.siteTable scrollRowToVisible:(NSInteger)self.sitesController.selectionIndex]; @@ -596,8 +600,13 @@ (__bridge id)[NSColor colorWithDeviceWhite:1 alpha:gradientOpacity].CGColor ]; + [self updateSelection]; +} + +- (void)updateSelection { self.showVersionContainer = self.alternatePressed || self.selectedSite.outdated; - [self.sitePasswordTipField setAttributedStringValue:straf( @"Your password for %@:", self.selectedSite.displayedName )]; + [self.sitePasswordTipField setAttributedStringValue: + straf( @"Your %@ for %@:", self.shiftPressed? @"login": @"password", self.selectedSite.displayedName )]; } - (void)createNewSite:(NSString *)siteName {