mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 12:52:21 +00:00
Clearing and custom setting auto type sequences is working roughly in the Fix-Tool
This commit is contained in:
Submodule KeePassKit updated: ecc58b8a56...cb5cae7244
@@ -7,6 +7,7 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="MPFixAutotypeWindowController">
|
<customObject id="-2" userLabel="File's Owner" customClass="MPFixAutotypeWindowController">
|
||||||
<connections>
|
<connections>
|
||||||
|
<outlet property="tableView" destination="nVa-6i-9j2" id="3Y1-qK-moe"/>
|
||||||
<outlet property="window" destination="F0z-JX-Cv5" id="2rB-5S-9w4"/>
|
<outlet property="window" destination="F0z-JX-Cv5" id="2rB-5S-9w4"/>
|
||||||
</connections>
|
</connections>
|
||||||
</customObject>
|
</customObject>
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="196" y="240" width="419" height="490"/>
|
<rect key="contentRect" x="196" y="240" width="419" height="490"/>
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
|
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1028"/>
|
||||||
<view key="contentView" id="se5-gp-TjO">
|
<view key="contentView" id="se5-gp-TjO">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="419" height="490"/>
|
<rect key="frame" x="0.0" y="0.0" width="419" height="490"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
</tableColumn>
|
</tableColumn>
|
||||||
<tableColumn identifier="IsDefaultCell" width="108" minWidth="10" maxWidth="3.4028234663852886e+38" id="0uz-Re-mk3">
|
<tableColumn identifier="IsDefaultCell" width="107.5" minWidth="10" maxWidth="3.4028234663852886e+38" id="0uz-Re-mk3">
|
||||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Is default">
|
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Is default">
|
||||||
<font key="font" metaFont="smallSystem"/>
|
<font key="font" metaFont="smallSystem"/>
|
||||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
@@ -87,7 +88,7 @@
|
|||||||
<rect key="frame" x="1" y="391" width="515" height="16"/>
|
<rect key="frame" x="1" y="391" width="515" height="16"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
</scroller>
|
</scroller>
|
||||||
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="37" horizontal="NO" id="W8o-DQ-iiR">
|
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="W8o-DQ-iiR">
|
||||||
<rect key="frame" x="-15" y="17" width="16" height="0.0"/>
|
<rect key="frame" x="-15" y="17" width="16" height="0.0"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
</scroller>
|
</scroller>
|
||||||
@@ -99,10 +100,13 @@
|
|||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Ui-5h-uFs">
|
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Ui-5h-uFs">
|
||||||
<rect key="frame" x="271" y="13" width="134" height="32"/>
|
<rect key="frame" x="271" y="13" width="134" height="32"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<buttonCell key="cell" type="push" title="Clear Autotype" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sGh-Ec-oIL">
|
<buttonCell key="cell" type="push" title="Clear Autotype" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="sGh-Ec-oIL">
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="clearAutotype:" target="-2" id="ePc-iQ-f9g"/>
|
||||||
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iZd-HT-6CT">
|
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iZd-HT-6CT">
|
||||||
<rect key="frame" x="189" y="13" width="82" height="32"/>
|
<rect key="frame" x="189" y="13" width="82" height="32"/>
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
MPServerDaemon *serverDaemon;
|
MPServerDaemon *serverDaemon;
|
||||||
MPLockDaemon *lockDaemon;
|
MPLockDaemon *lockDaemon;
|
||||||
MPAutotypeDaemon *autotypeDaemon;
|
MPAutotypeDaemon *autotypeDaemon;
|
||||||
BOOL _restoredWindows; // YES if windows where restored at launch
|
|
||||||
BOOL _shouldOpenFile; // YES if app was started to open a
|
BOOL _shouldOpenFile; // YES if app was started to open a
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void)dealloc {
|
||||||
[self unbind:@"isAllowedToStoreKeyFile"];
|
[self unbind:NSStringFromSelector(@selector(isAllowedToStoreKeyFile))];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +87,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
[[self.saveMenuItem menu] setDelegate:self];
|
[[self.saveMenuItem menu] setDelegate:self];
|
||||||
|
|
||||||
/* We want to inform anyone about the changes to keyFile remmebering */
|
/* We want to inform anyone about the changes to keyFile remmebering */
|
||||||
[self bind:@"isAllowedToStoreKeyFile"
|
[self bind:NSStringFromSelector(@selector(isAllowedToStoreKeyFile))
|
||||||
toObject:[NSUserDefaultsController sharedUserDefaultsController]
|
toObject:[NSUserDefaultsController sharedUserDefaultsController]
|
||||||
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyRememberKeyFilesForDatabases]
|
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyRememberKeyFilesForDatabases]
|
||||||
options:nil];
|
options:nil];
|
||||||
@@ -117,7 +116,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
|
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
||||||
_restoredWindows = NO;
|
|
||||||
_shouldOpenFile = NO;
|
_shouldOpenFile = NO;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(_applicationDidFinishRestoringWindows:)
|
selector:@selector(_applicationDidFinishRestoringWindows:)
|
||||||
@@ -149,15 +147,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
serverDaemon = [[MPServerDaemon alloc] init];
|
serverDaemon = [[MPServerDaemon alloc] init];
|
||||||
lockDaemon = [[MPLockDaemon alloc] init];
|
lockDaemon = [[MPLockDaemon alloc] init];
|
||||||
autotypeDaemon = [[MPAutotypeDaemon alloc] init];
|
autotypeDaemon = [[MPAutotypeDaemon alloc] init];
|
||||||
|
|
||||||
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
|
||||||
BOOL showWelcomeScreen = !_restoredWindows && !_shouldOpenFile;
|
|
||||||
if(reopen && !_restoredWindows && !_shouldOpenFile) {
|
|
||||||
showWelcomeScreen = ![self _reopenLastDocument];
|
|
||||||
}
|
|
||||||
if(showWelcomeScreen) {
|
|
||||||
[self _showWelcomeWindow];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)applicationName {
|
- (NSString *)applicationName {
|
||||||
@@ -226,6 +215,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init];
|
self.fixAutotypeWindowController = [[MPFixAutotypeWindowController alloc] init];
|
||||||
}
|
}
|
||||||
[self.fixAutotypeWindowController reset];
|
[self.fixAutotypeWindowController reset];
|
||||||
|
[self.fixAutotypeWindowController setDocument:[[NSDocumentController sharedDocumentController] currentDocument]];
|
||||||
[[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender];
|
[[self.fixAutotypeWindowController window] makeKeyAndOrderFront:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +224,16 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi
|
|||||||
- (void)_applicationDidFinishRestoringWindows:(NSNotification *)notification {
|
- (void)_applicationDidFinishRestoringWindows:(NSNotification *)notification {
|
||||||
NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
|
NSDocumentController *documentController = [NSDocumentController sharedDocumentController];
|
||||||
NSArray *documents = [documentController documents];
|
NSArray *documents = [documentController documents];
|
||||||
_restoredWindows = [documents count] > 0;
|
BOOL restoredWindows = [documents count] > 0;
|
||||||
|
|
||||||
|
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];
|
||||||
|
BOOL showWelcomeScreen = !restoredWindows && !_shouldOpenFile;
|
||||||
|
if(reopen && !restoredWindows && !_shouldOpenFile) {
|
||||||
|
showWelcomeScreen = ![self _reopenLastDocument];
|
||||||
|
}
|
||||||
|
if(showWelcomeScreen) {
|
||||||
|
[self _showWelcomeWindow];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_showWelcomeWindow {
|
- (void)_showWelcomeWindow {
|
||||||
|
|||||||
@@ -8,8 +8,19 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
@class MPDocument;
|
||||||
|
|
||||||
@interface MPFixAutotypeWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate>
|
@interface MPFixAutotypeWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate>
|
||||||
|
|
||||||
|
@property (weak) IBOutlet NSTableView *tableView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the autotype sequences for the selected entries
|
||||||
|
*
|
||||||
|
* @param sender sender of the action
|
||||||
|
*/
|
||||||
|
- (IBAction)clearAutotype:(id)sender;
|
||||||
|
|
||||||
- (void)reset;
|
- (void)reset;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
#import "KPKGroup.h"
|
#import "KPKGroup.h"
|
||||||
#import "KPKAutotype.h"
|
#import "KPKAutotype.h"
|
||||||
|
|
||||||
|
NSString *const kMPAutotypeCell = @"AutotypeCell";
|
||||||
|
NSString *const kMPTitleCell = @"TitleCell";
|
||||||
|
NSString *const kMPIsDefaultCell = @"IsDefaultCell";
|
||||||
|
|
||||||
@interface KPKGroup (Breadcrumb)
|
@interface KPKGroup (Breadcrumb)
|
||||||
|
|
||||||
- (NSString *)breadcrumb;
|
- (NSString *)breadcrumb;
|
||||||
@@ -34,8 +38,6 @@
|
|||||||
NSMutableArray *_elements;
|
NSMutableArray *_elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (weak) NSTableView *tableView;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MPFixAutotypeWindowController
|
@implementation MPFixAutotypeWindowController
|
||||||
@@ -61,33 +63,52 @@
|
|||||||
[self.tableView reloadData];
|
[self.tableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#pragma mark -
|
||||||
|
#pragma mark Actions
|
||||||
|
|
||||||
|
- (void)clearAutotype:(id)sender {
|
||||||
|
|
||||||
|
MPDocument *document = [self document];
|
||||||
|
[[document undoManager] beginUndoGrouping];
|
||||||
|
NSIndexSet *indexes = [self.tableView selectedRowIndexes];
|
||||||
|
MPFixAutotypeWindowController __weak *weakSelf = self;
|
||||||
|
[indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
|
id item = [weakSelf entriesAndGroups][idx];
|
||||||
|
if([item respondsToSelector:@selector(defaultAutoTypeSequence)]) {
|
||||||
|
[item setDefaultAutoTypeSequence:nil];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[item autotype].defaultKeystrokeSequence = nil;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
[[document undoManager] endUndoGrouping];
|
||||||
|
[[document undoManager] setActionName:@"Clear Autotype"];
|
||||||
|
[self.tableView reloadDataForRowIndexes:indexes columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0,2)]];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark NSTableViewDataSource
|
#pragma mark NSTableViewDataSource
|
||||||
|
|
||||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
|
||||||
|
|
||||||
self.tableView = tableView;
|
|
||||||
|
|
||||||
return [[self entriesAndGroups] count];
|
return [[self entriesAndGroups] count];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||||
|
|
||||||
self.tableView = tableView;
|
|
||||||
id node = [self entriesAndGroups][row];
|
id node = [self entriesAndGroups][row];
|
||||||
if([[tableColumn identifier] isEqualToString:@"TitleCell"]) {
|
if([[tableColumn identifier] isEqualToString:kMPTitleCell]) {
|
||||||
if( [node respondsToSelector:@selector(title)]) {
|
if( [node respondsToSelector:@selector(title)]) {
|
||||||
return [node title];
|
return [node title];
|
||||||
}
|
}
|
||||||
return [node breadcrumb];
|
return [node breadcrumb];
|
||||||
}
|
}
|
||||||
else if ([[tableColumn identifier] isEqualToString:@"AutotypeCell"]) {
|
else if ([[tableColumn identifier] isEqualToString:kMPAutotypeCell]) {
|
||||||
if([node respondsToSelector:@selector(defaultAutoTypeSequence)]) {
|
if([node respondsToSelector:@selector(defaultAutoTypeSequence)]) {
|
||||||
return [node defaultAutoTypeSequence];
|
return [node defaultAutoTypeSequence];
|
||||||
}
|
}
|
||||||
return [[node autotype] defaultKeystrokeSequence];
|
return [[node autotype] defaultKeystrokeSequence];
|
||||||
}
|
}
|
||||||
else if([[tableColumn identifier] isEqualToString:@"IsDefaultCell"]) {
|
else if([[tableColumn identifier] isEqualToString:kMPIsDefaultCell]) {
|
||||||
BOOL isDefault = NO;
|
BOOL isDefault = NO;
|
||||||
if([node respondsToSelector:@selector(hasDefaultAutotypeSequence)]) {
|
if([node respondsToSelector:@selector(hasDefaultAutotypeSequence)]) {
|
||||||
isDefault = [node hasDefaultAutotypeSequence];
|
isDefault = [node hasDefaultAutotypeSequence];
|
||||||
@@ -100,9 +121,24 @@
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||||
|
id item = [self entriesAndGroups][row];
|
||||||
|
if([item respondsToSelector:@selector(defaultAutoTypeSequence)]) {
|
||||||
|
[item setDefaultAutoTypeSequence:object];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[[item autotype] setDefaultKeystrokeSequence:object];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark NSTableViewDelegate
|
#pragma mark NSTableViewDelegate
|
||||||
|
|
||||||
|
- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
|
||||||
|
return [[tableColumn identifier] isEqualToString:kMPAutotypeCell];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
|
- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row {
|
||||||
id item = [self entriesAndGroups][row];
|
id item = [self entriesAndGroups][row];
|
||||||
return [item isKindOfClass:[KPKGroup class]];
|
return [item isKindOfClass:[KPKGroup class]];
|
||||||
@@ -113,15 +149,9 @@
|
|||||||
|
|
||||||
- (NSArray *)entriesAndGroups {
|
- (NSArray *)entriesAndGroups {
|
||||||
if(nil == _elements) {
|
if(nil == _elements) {
|
||||||
NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
|
|
||||||
_elements = [[NSMutableArray alloc] init];
|
_elements = [[NSMutableArray alloc] init];
|
||||||
for(MPDocument *document in documents) {
|
MPDocument *document = [self document];
|
||||||
if(!document.root) {
|
[self flattenGroup:document.root toArray:_elements];
|
||||||
continue;
|
|
||||||
}
|
|
||||||
KPKGroup *group = document.root;
|
|
||||||
[self flattenGroup:group toArray:_elements];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return _elements;
|
return _elements;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user