Re-worked hide after copy to pasteboard. It now works for all copy actions that securely copy to the clipboard (closed #906)

This commit is contained in:
Michael Starke
2019-04-05 08:53:51 +02:00
parent 853e47c43f
commit 7c2cf6eadb
9 changed files with 56 additions and 34 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -23,13 +23,13 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1">
<customView translatesAutoresizingMaskIntoConstraints="NO" id="1">
<rect key="frame" x="0.0" y="0.0" width="411" height="524"/>
<subviews>
<box autoresizesSubviews="NO" verticalHuggingPriority="500" borderType="line" title="Security" translatesAutoresizingMaskIntoConstraints="NO" id="465">
<rect key="frame" x="17" y="16" width="366" height="357"/>
<rect key="frame" x="17" y="16" width="377" height="357"/>
<view key="contentView" id="mNh-3L-Z6E">
<rect key="frame" x="3" y="3" width="360" height="339"/>
<rect key="frame" x="3" y="3" width="371" height="339"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="431">
@@ -44,10 +44,7 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="419">
<rect key="frame" x="177" y="308" width="170" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="165" id="877"/>
</constraints>
<rect key="frame" x="138" y="308" width="143" height="21"/>
<popUpButtonCell key="cell" type="push" title="Never" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="429" id="420">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
@@ -75,7 +72,7 @@
</buttonCell>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="584">
<rect key="frame" x="177" y="168" width="170" height="25"/>
<rect key="frame" x="111" y="168" width="125" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="585">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
@@ -114,7 +111,7 @@
</buttonCell>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5cV-xX-SUU">
<rect key="frame" x="18" y="41" width="324" height="56"/>
<rect key="frame" x="18" y="41" width="335" height="56"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="ACh-7H-42N">
<font key="font" metaFont="smallSystem"/>
<string key="title">Enabling this compromises security. If enabled, your preferences will contain mappings from database to keyfile. Key locations for databases without a password will not be saved.</string>
@@ -123,7 +120,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oQr-FC-HkN">
<rect key="frame" x="160" y="5" width="190" height="32"/>
<rect key="frame" x="171" y="5" width="190" height="32"/>
<buttonCell key="cell" type="push" title="Clear all stored locations" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="8Ri-2s-c39">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -147,7 +144,7 @@
</buttonCell>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hy4-RL-dAa">
<rect key="frame" x="18" y="200" width="324" height="56"/>
<rect key="frame" x="18" y="200" width="335" height="56"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="JGX-Tp-KJk">
<font key="font" metaFont="smallSystem"/>
<string key="title">Disabling this compromises security. If enabled, anything copied to the Clipboard in MacPass will be available on your connected iOS devices. You should clear the clipboard on those devices manually.</string>
@@ -166,9 +163,9 @@
<constraint firstItem="5SP-Vi-1sn" firstAttribute="leading" secondItem="447" secondAttribute="leading" id="Ylr-aA-jaD"/>
<constraint firstItem="hy4-RL-dAa" firstAttribute="top" secondItem="nqZ-rB-mFS" secondAttribute="bottom" constant="8" symbolic="YES" id="a3i-tc-gUU"/>
<constraint firstItem="5SP-Vi-1sn" firstAttribute="top" secondItem="630" secondAttribute="bottom" constant="6" symbolic="YES" id="acg-vp-LeB"/>
<constraint firstItem="584" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="805" secondAttribute="trailing" constant="8" symbolic="YES" id="aoz-sS-O0n"/>
<constraint firstItem="584" firstAttribute="leading" secondItem="805" secondAttribute="trailing" constant="8" symbolic="YES" id="aoz-sS-O0n"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="447" secondAttribute="trailing" constant="20" symbolic="YES" id="i8H-ad-IKb"/>
<constraint firstItem="419" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="431" secondAttribute="trailing" constant="8" symbolic="YES" id="pN3-pB-Z5I"/>
<constraint firstItem="419" firstAttribute="leading" secondItem="431" secondAttribute="trailing" constant="8" symbolic="YES" id="pN3-pB-Z5I"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="5SP-Vi-1sn" secondAttribute="trailing" constant="20" symbolic="YES" id="q0v-Wo-mHx"/>
<constraint firstItem="nqZ-rB-mFS" firstAttribute="top" secondItem="447" secondAttribute="bottom" constant="11" id="qLm-ih-A04"/>
<constraint firstAttribute="trailing" secondItem="5cV-xX-SUU" secondAttribute="trailing" constant="20" symbolic="YES" id="qY0-io-RZ0"/>
@@ -178,8 +175,8 @@
</constraints>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="419" secondAttribute="trailing" constant="16" id="1de-jU-TAq"/>
<constraint firstAttribute="trailing" secondItem="584" secondAttribute="trailing" constant="16" id="GAz-Mn-Z2y"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="419" secondAttribute="trailing" constant="16" id="1de-jU-TAq"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="584" secondAttribute="trailing" constant="16" id="GAz-Mn-Z2y"/>
<constraint firstAttribute="bottom" secondItem="oQr-FC-HkN" secondAttribute="bottom" constant="11" id="M71-WV-WFc"/>
<constraint firstItem="5cV-xX-SUU" firstAttribute="top" secondItem="bSt-Wf-FNZ" secondAttribute="bottom" constant="9" id="NYW-dJ-CHg"/>
<constraint firstItem="805" firstAttribute="centerY" secondItem="584" secondAttribute="centerY" id="OOq-TD-dmj"/>
@@ -195,15 +192,14 @@
<constraint firstItem="oQr-FC-HkN" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="465" secondAttribute="leading" constant="16" id="kZ7-HL-y2Q"/>
<constraint firstItem="oQr-FC-HkN" firstAttribute="top" secondItem="5cV-xX-SUU" secondAttribute="bottom" constant="8" id="qsT-Cs-vVj"/>
<constraint firstItem="447" firstAttribute="top" secondItem="419" secondAttribute="bottom" constant="8" symbolic="YES" id="u35-aE-Ui9"/>
<constraint firstItem="419" firstAttribute="leading" secondItem="584" secondAttribute="leading" id="xws-PK-qQU"/>
<constraint firstItem="630" firstAttribute="leading" secondItem="447" secondAttribute="leading" id="ybt-cQ-JwG"/>
<constraint firstItem="447" firstAttribute="top" secondItem="431" secondAttribute="bottom" constant="8" symbolic="YES" id="zkd-Hf-09b"/>
</constraints>
</box>
<box autoresizesSubviews="NO" verticalHuggingPriority="500" borderType="line" title="File Handling" translatesAutoresizingMaskIntoConstraints="NO" id="888">
<rect key="frame" x="17" y="375" width="366" height="129"/>
<rect key="frame" x="17" y="375" width="377" height="129"/>
<view key="contentView" id="cpg-tt-SHE">
<rect key="frame" x="3" y="3" width="360" height="111"/>
<rect key="frame" x="3" y="3" width="371" height="111"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="252" translatesAutoresizingMaskIntoConstraints="NO" id="530">
@@ -220,8 +216,8 @@
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="3Bo-Ml-1KB">
<rect key="frame" x="18" y="45" width="324" height="14"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Bo-Ml-1KB">
<rect key="frame" x="18" y="45" width="335" height="14"/>
<textFieldCell key="cell" controlSize="small" title="Close and open all documents for changes to take effect" id="ya5-ps-c4W">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -237,7 +233,7 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="wIu-Sh-2a2">
<rect key="frame" x="111" y="14" width="232" height="25"/>
<rect key="frame" x="111" y="14" width="38" height="25"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="1R2-5t-LWk">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
@@ -247,7 +243,7 @@
</subviews>
<constraints>
<constraint firstItem="3Bo-Ml-1KB" firstAttribute="leading" secondItem="cpg-tt-SHE" secondAttribute="leading" constant="20" symbolic="YES" id="2Jh-pk-bN7"/>
<constraint firstAttribute="trailing" secondItem="wIu-Sh-2a2" secondAttribute="trailing" constant="20" id="2Qw-fT-Dd8"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="wIu-Sh-2a2" secondAttribute="trailing" constant="20" id="2Qw-fT-Dd8"/>
<constraint firstAttribute="trailing" secondItem="3Bo-Ml-1KB" secondAttribute="trailing" constant="20" symbolic="YES" id="2UW-ao-hrC"/>
<constraint firstAttribute="bottom" secondItem="h3w-Ms-ohK" secondAttribute="bottom" constant="20" symbolic="YES" id="3KB-kR-5d6"/>
<constraint firstItem="h3w-Ms-ohK" firstAttribute="leading" secondItem="530" secondAttribute="leading" id="4Fi-rX-8e0"/>
@@ -273,7 +269,7 @@
<constraint firstItem="888" firstAttribute="leading" secondItem="1" secondAttribute="leading" constant="20" symbolic="YES" id="891"/>
<constraint firstAttribute="trailing" secondItem="888" secondAttribute="trailing" constant="20" symbolic="YES" id="893"/>
<constraint firstItem="888" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="903"/>
<constraint firstAttribute="width" constant="400" id="918"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="400" id="918"/>
<constraint firstAttribute="bottom" secondItem="465" secondAttribute="bottom" constant="20" symbolic="YES" id="uwq-az-XwJ"/>
<constraint firstItem="465" firstAttribute="top" secondItem="cpg-tt-SHE" secondAttribute="bottom" constant="5" id="wyH-HB-i2U"/>
</constraints>

View File

@@ -11,6 +11,7 @@
<outlet property="browserPopup" destination="ehI-gq-lsb" id="YMy-L1-pQw"/>
<outlet property="doubleClickTitlePopup" destination="40" id="aKJ-q9-xjb"/>
<outlet property="doubleClickURLPopup" destination="13" id="fGP-5I-0XK"/>
<outlet property="hideAfterCopyToClipboardCheckButton" destination="vT4-wF-ned" id="d7e-vc-cAQ"/>
<outlet property="updatePasswordOnTemplateEntriesCheckButton" destination="LPY-sM-hjS" id="wav-op-uck"/>
<outlet property="view" destination="1" id="52"/>
</connections>
@@ -139,8 +140,8 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vT4-wF-ned">
<rect key="frame" x="18" y="18" width="307" height="18"/>
<buttonCell key="cell" type="check" title="Hide application after copying to the clipboard " bezelStyle="regularSquare" imagePosition="left" enabled="NO" inset="2" id="1Vr-nY-Ogv">
<rect key="frame" x="18" y="18" width="283" height="18"/>
<buttonCell key="cell" type="check" title="Hide application after copying to clipboard " bezelStyle="regularSquare" imagePosition="left" inset="2" id="1Vr-nY-Ogv">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>

View File

@@ -749,7 +749,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
}
- (void)_columnDoubleClick:(id)sender {
if(0 == [[self.entryArrayController arrangedObjects] count]) {
if(0 == [self.entryArrayController.arrangedObjects count]) {
return; // No data available
}
NSInteger columnIndex = [self.entryTable clickedColumn];
@@ -800,4 +800,5 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
break;
}
}
@end

View File

@@ -58,6 +58,18 @@ FOUNDATION_EXPORT NSString *const MPPasteBoardControllerDidClearClipboard;
- (void)copyObjects:(NSArray<id<NSPasteboardWriting>> *)objects;
- (void)copyObjectsWithoutTimeout:(NSArray<id<NSPasteboardWriting>> *)objects;
/**
The pastboard controller will copy the object to the clipboard, display an appropriate overlay image
and text and will set the clear time out if any is set. Additinally it will hide the application if
the user has set this option. This call should always be used when a user is directly copying anything
to the clipboard. If the clipboard is used internally (e.g. for autotype) you should call copyObjects:
or even copyObjectsWithoutTimeout:
@param objects object so be copied
@param overlayInfoType infotype discribing what is copied
@param name a custom name
@param view the view that initiated the copy action
*/
- (void)copyObjects:(NSArray<id<NSPasteboardWriting>> *)objects overlayInfo:(MPPasteboardOverlayInfoType)overlayInfoType name:(NSString *)name atView:(NSView *)view;
@end

View File

@@ -143,7 +143,7 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
infoImage = [NSBundle.mainBundle imageForResource:@"00_PasswordTemplate"];
infoText = [NSString stringWithFormat:NSLocalizedString(@"COPIED_FIELD_%@", "Field name that was copied to the pasteboard"), name];
break;
case MPPasteboardOverlayInfoReference:
infoImage = [NSBundle.mainBundle imageForResource:@"04_KlipperTemplate"];
infoText = name;
@@ -151,6 +151,13 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
}
[MPOverlayWindowController.sharedController displayOverlayImage:infoImage label:infoText atView:view];
BOOL hide = [NSUserDefaults.standardUserDefaults boolForKey:kMPSettingsKeyHideAfterCopyToClipboard];
if(hide) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(400 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
[NSApplication.sharedApplication hide:nil];
});
}
}
- (void)_clearPasteboardContents {

View File

@@ -80,6 +80,7 @@ APPKIT_EXTERN NSString *const kMPSettingsKeyEnableQuicklookPreview;
APPKIT_EXTERN NSString *const kMPSettingsKeyDoubleClickURLAction;
APPKIT_EXTERN NSString *const kMPSettingsKeyDoubleClickTitleAction;
APPKIT_EXTERN NSString *const kMPSettingsKeyUpdatePasswordOnTemplateEntries;
APPKIT_EXTERN NSString *const kMPSettingsKeyHideAfterCopyToClipboard;
/* Plugins */
APPKIT_EXTERN NSString *const kMPSettingsKeyLoadUnsecurePlugins; // If set to YES this will load all plugins regardless of their codesignature status

View File

@@ -78,6 +78,7 @@ NSString *const kMPSettingsKeyPasswordDefaultsForEntry = @"Passwo
NSString *const kMPSettingsKeyDoubleClickURLAction = @"DoubleClickURLAction";
NSString *const kMPSettingsKeyDoubleClickTitleAction = @"DoubleClickTitleAction";
NSString *const kMPSettingsKeyUpdatePasswordOnTemplateEntries = @"UpdatePasswordOnTemplateEntries";
NSString *const kMPSettingsKeyHideAfterCopyToClipboard = @"HideAfterCopyToClipboard";
NSString *const kMPSettingsKeyLoadUnsecurePlugins = @"LoadUnsecurePlugins";
NSString *const kMPSettingsKeyLoadIncompatiblePlugins = @"LoadIncompatiblePlugins";
@@ -159,7 +160,8 @@ NSString *const kMPDepricatedSettingsKeyLoadUnsecurePlugins = @"MP
kMPSettingsKeyDisabledPlugins: @[],
kMPSettingsKeyLoadIncompatiblePlugins: @NO,
kMPSettingsKeyQuitOnLastWindowClose: @NO,
kMPSettingsKeyEnableAutosave: @YES
kMPSettingsKeyEnableAutosave: @YES,
kMPSettingsKeyHideAfterCopyToClipboard: @NO
};
});
return standardDefaults;

View File

@@ -25,10 +25,11 @@
@interface MPWorkflowSettingsController : MPViewController <MPPreferencesTab>
@property (weak) IBOutlet NSPopUpButton *browserPopup;
@property (weak) IBOutlet NSPopUpButton *doubleClickURLPopup;
@property (weak) IBOutlet NSPopUpButton *doubleClickTitlePopup;
@property (weak) IBOutlet NSButton *updatePasswordOnTemplateEntriesCheckButton;
@property (strong) IBOutlet NSPopUpButton *browserPopup;
@property (strong) IBOutlet NSPopUpButton *doubleClickURLPopup;
@property (strong) IBOutlet NSPopUpButton *doubleClickTitlePopup;
@property (strong) IBOutlet NSButton *updatePasswordOnTemplateEntriesCheckButton;
@property (strong) IBOutlet NSButton *hideAfterCopyToClipboardCheckButton;
- (IBAction)_showCustomBrowserSelection:(id)sender;

View File

@@ -40,6 +40,7 @@
[self.doubleClickURLPopup bind:NSSelectedIndexBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyDoubleClickURLAction] options:nil];
[self.doubleClickTitlePopup bind:NSSelectedIndexBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyDoubleClickTitleAction] options:nil];
[self.updatePasswordOnTemplateEntriesCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyUpdatePasswordOnTemplateEntries] options:nil];
[self.hideAfterCopyToClipboardCheckButton bind:NSValueBinding toObject:defaultsController withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyHideAfterCopyToClipboard] options:nil];
[self _updateBrowserSelection];
}