mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
fixed #62 application now shows a welcome screen if no other window is opened
fixed #79 modification data can be used as table column fixed #74 added group sorting in search results
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import "KdbEntry+Undo.h"
|
||||
|
||||
#import "Kdb4Node.h"
|
||||
#import "KdbGroup+Undo.h"
|
||||
#import "KdbGroup+KVOAdditions.h"
|
||||
#import "KdbGroup+MPTreeTools.h"
|
||||
@@ -48,7 +50,7 @@ if(![[self undoManager] isUndoing]) {\
|
||||
[[self undoManager] registerUndoWithTarget:self selector:@selector(setTitleUndoable:) object:self.title];
|
||||
MPSetActionName(@"SET_TITLE", "");
|
||||
|
||||
[self setLastModificationTime:[NSDate date]];
|
||||
[self _touchModifcationDate];
|
||||
[self setTitle:title];
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ if(![[self undoManager] isUndoing]) {\
|
||||
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUsernameUndoable:) object:self.username];
|
||||
MPSetActionName(@"SET_USERNAME", "");
|
||||
|
||||
[self setLastModificationTime:[NSDate date]];
|
||||
[self _touchModifcationDate];
|
||||
[self setUsername:username];
|
||||
}
|
||||
|
||||
@@ -64,7 +66,7 @@ if(![[self undoManager] isUndoing]) {\
|
||||
[[self undoManager] registerUndoWithTarget:self selector:@selector(setPasswordUndoable:) object:self.password];
|
||||
MPSetActionName(@"SET_PASSWORT", "Undo set password");
|
||||
|
||||
[self setLastModificationTime:[NSDate date]];
|
||||
[self _touchModifcationDate];
|
||||
[self setPassword:password];
|
||||
}
|
||||
|
||||
@@ -72,7 +74,7 @@ if(![[self undoManager] isUndoing]) {\
|
||||
[[self undoManager] registerUndoWithTarget:self selector:@selector(setUrlUndoable:) object:self.url];
|
||||
MPSetActionName(@"SET_URL", "Undo set URL");
|
||||
|
||||
[self setLastModificationTime:[NSDate date]];
|
||||
[self _touchModifcationDate];
|
||||
[self setUrl:url];
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ if(![[self undoManager] isUndoing]) {\
|
||||
[[self undoManager] registerUndoWithTarget:self selector:@selector(setNotesUndoable:) object:self.notes];
|
||||
MPSetActionName(@"SET_NOTES", "Set Notes");
|
||||
|
||||
[self setLastModificationTime:[NSDate date]];
|
||||
[self _touchModifcationDate];
|
||||
[self setNotes:notes];
|
||||
}
|
||||
|
||||
@@ -124,8 +126,14 @@ if(![[self undoManager] isUndoing]) {\
|
||||
// Old indices might be wrong, correct them if necessary
|
||||
index = MIN(index, [group.entries count]);
|
||||
[group insertObject:self inEntriesAtIndex:index];
|
||||
if([self respondsToSelector:@selector(setLocationChanged:)]) {
|
||||
id entry = self;
|
||||
[entry setLocationChanged:[NSDate date]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)_touchModifcationDate {
|
||||
self.lastModificationTime = [NSDate date];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -48,6 +48,14 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag {
|
||||
if(!flag) {
|
||||
[self _loadWelcomeWindow];
|
||||
[self.welcomeWindow orderFront:self];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {
|
||||
return [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyOpenEmptyDatabaseOnLaunch];
|
||||
}
|
||||
@@ -101,8 +109,7 @@
|
||||
|
||||
}
|
||||
else {
|
||||
NSArray *topLevelObject;
|
||||
[[NSBundle mainBundle] loadNibNamed:@"WelcomeWindow" owner:self topLevelObjects:&topLevelObject];
|
||||
[self _loadWelcomeWindow];
|
||||
[self.welcomeWindow orderFront:self];
|
||||
}
|
||||
}
|
||||
@@ -159,4 +166,12 @@
|
||||
_restoredWindows = [documents count] > 0;
|
||||
}
|
||||
|
||||
- (void)_loadWelcomeWindow {
|
||||
if(!_welcomeWindow) {
|
||||
NSArray *topLevelObject;
|
||||
[[NSBundle mainBundle] loadNibNamed:@"WelcomeWindow" owner:self topLevelObjects:&topLevelObject];
|
||||
//CFRelease((__bridge CFTypeRef)_welcomeWindow);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -57,6 +57,7 @@ NSString *const MPEntryTableParentColumnIdentifier = @"MPParentColumnIdentifier"
|
||||
NSString *const MPEntryTableURLColumnIdentifier = @"MPEntryTableURLColumnIdentifier";
|
||||
NSString *const MPEntryTableNotesColumnIdentifier = @"MPEntryTableNotesColumnIdentifier";
|
||||
NSString *const MPEntryTableAttachmentColumnIdentifier = @"MPEntryTableAttachmentColumnIdentifier";
|
||||
NSString *const MPEntryTableModfiedColumnIdentifier = @"MPEntryTableModfiedColumnIdentifier";
|
||||
|
||||
NSString *const _MPTableImageCellView = @"ImageCell";
|
||||
NSString *const _MPTableStringCellView = @"StringCell";
|
||||
@@ -153,8 +154,10 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
NSTableColumn *urlColumn = [self.entryTable tableColumns][4];
|
||||
NSTableColumn *attachmentsColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableAttachmentColumnIdentifier];
|
||||
NSTableColumn *notesColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableNotesColumnIdentifier];
|
||||
NSTableColumn *modifiedColumn = [[NSTableColumn alloc] initWithIdentifier:MPEntryTableModfiedColumnIdentifier];
|
||||
[self.entryTable addTableColumn:notesColumn];
|
||||
[self.entryTable addTableColumn:attachmentsColumn];
|
||||
[self.entryTable addTableColumn:modifiedColumn];
|
||||
|
||||
[parentColumn setIdentifier:MPEntryTableParentColumnIdentifier];
|
||||
[titleColumn setIdentifier:MPEntryTableTitleColumnIdentifier];
|
||||
@@ -168,10 +171,14 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
NSSortDescriptor *titleColumSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"title" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" ascending:YES selector:@selector(compare:)];
|
||||
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"lastModificationTime" ascending:YES selector:@selector(compare:)];
|
||||
|
||||
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
|
||||
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
|
||||
[urlColumn setSortDescriptorPrototype:urlSortDescriptor];
|
||||
[parentColumn setSortDescriptorPrototype:groupnameSortDescriptor];
|
||||
[modifiedColumn setSortDescriptorPrototype:dateSortDescriptor];
|
||||
|
||||
[[parentColumn headerCell] setStringValue:NSLocalizedString(@"GROUP", "")];
|
||||
[[titleColumn headerCell] setStringValue:NSLocalizedString(@"TITLE", "")];
|
||||
@@ -180,6 +187,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
[[urlColumn headerCell] setStringValue:NSLocalizedString(@"URL", "")];
|
||||
[[notesColumn headerCell] setStringValue:NSLocalizedString(@"NOTES", "")];
|
||||
[[attachmentsColumn headerCell] setStringValue:NSLocalizedString(@"ATTACHMENTS", "")];
|
||||
[[modifiedColumn headerCell] setStringValue:NSLocalizedString(@"MODIFIED", "")];
|
||||
|
||||
[self.entryTable bind:NSContentBinding toObject:self.entryArrayController withKeyPath:@"arrangedObjects" options:nil];
|
||||
[self.entryTable bind:NSSortDescriptorsBinding toObject:self.entryArrayController withKeyPath:@"sortDescriptors" options:nil];
|
||||
@@ -209,6 +217,7 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
BOOL isURLColumn = [[tableColumn identifier] isEqualToString:MPEntryTableURLColumnIdentifier];
|
||||
BOOL isAttachmentColumn = [[tableColumn identifier] isEqualToString:MPEntryTableAttachmentColumnIdentifier];
|
||||
BOOL isNotesColumn = [[tableColumn identifier] isEqualToString:MPEntryTableNotesColumnIdentifier];
|
||||
BOOL isModifedColumn = [[tableColumn identifier] isEqualToString:MPEntryTableModfiedColumnIdentifier];
|
||||
|
||||
NSTableCellView *view = nil;
|
||||
if(isTitleColumn || isGroupColumn) {
|
||||
@@ -244,6 +253,13 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
[[view textField] setStringValue:@""];
|
||||
//[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"countOfBinaries" options:nil];
|
||||
}
|
||||
else if( isModifedColumn ) {
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterMediumStyle];
|
||||
[[view textField] setFormatter:formatter];
|
||||
[[view textField] bind:NSValueBinding toObject:entry withKeyPath:@"lastModificationTime" options:nil];
|
||||
}
|
||||
}
|
||||
|
||||
return view;
|
||||
@@ -556,13 +572,15 @@ NSString *const _toggleFilterUsernameButton = @"SearchUsername";
|
||||
[headerMenu addItemWithTitle:NSLocalizedString(@"URL", "") action:NULL keyEquivalent:@""];
|
||||
[headerMenu addItemWithTitle:NSLocalizedString(@"NOTES", "") action:NULL keyEquivalent:@""];
|
||||
[headerMenu addItemWithTitle:NSLocalizedString(@"ATTACHMENTS", "") action:NULL keyEquivalent:@""];
|
||||
[headerMenu addItemWithTitle:NSLocalizedString(@"MODIFIED", "") action:NULL keyEquivalent:@""];
|
||||
|
||||
NSArray *identifier = @[ MPEntryTableTitleColumnIdentifier,
|
||||
MPEntryTableUserNameColumnIdentifier,
|
||||
MPEntryTablePasswordColumnIdentifier,
|
||||
MPEntryTableURLColumnIdentifier,
|
||||
MPEntryTableNotesColumnIdentifier,
|
||||
MPEntryTableAttachmentColumnIdentifier ];
|
||||
MPEntryTableAttachmentColumnIdentifier,
|
||||
MPEntryTableModfiedColumnIdentifier ];
|
||||
|
||||
NSDictionary *options = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
|
||||
for(NSMenuItem *item in [headerMenu itemArray]) {
|
||||
|
||||
@@ -90,7 +90,6 @@
|
||||
validTarget &= index != [self.draggedGroup.parent.groups indexOfObject:self.draggedGroup];
|
||||
}
|
||||
BOOL isAnchesor = [self.draggedGroup isAnchestorOfGroup:targetGroup];
|
||||
NSLog(@"DraggedGroup:%@ isAnchestor:%d ofTargetGroup:%@", self.draggedGroup.name, isAnchesor, targetGroup.name);
|
||||
validTarget &= !isAnchesor;
|
||||
}
|
||||
else if(self.draggedEntry) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<int key="NSWindowStyleMask">7</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{196, 240}, {448, 255}}</string>
|
||||
<int key="NSWTFlags">544735232</int>
|
||||
<int key="NSWTFlags">1618477056</int>
|
||||
<string key="NSWindowTitle">Welcome</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<nil key="NSViewClass"/>
|
||||
@@ -186,7 +186,6 @@
|
||||
<string key="NSFrame">{{372, 18}, {56, 25}}</string>
|
||||
<reference key="NSSuperview" ref="1006"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:22</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="138204662">
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user