mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 18:42:24 +00:00
Database settings now store and load color of db and compression algorithm
Fixed wrong sort descriptor for modificationDate on entry view table
This commit is contained in:
2
HNHUi
2
HNHUi
Submodule HNHUi updated: 7bf39a4be9...435f37c254
Submodule KeePassKit updated: 4ab7411926...a232bbd601
File diff suppressed because it is too large
Load Diff
@@ -11,11 +11,7 @@
|
|||||||
|
|
||||||
@implementation MPAttachmentTableDataSource
|
@implementation MPAttachmentTableDataSource
|
||||||
|
|
||||||
- (NSDragOperation)tableView:(NSTableView *)tableView
|
- (NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation {
|
||||||
validateDrop:(id<NSDraggingInfo>)info
|
|
||||||
proposedRow:(NSInteger)row
|
|
||||||
proposedDropOperation:(NSTableViewDropOperation)dropOperation {
|
|
||||||
|
|
||||||
NSPasteboard *draggingPasteBoard = [info draggingPasteboard];
|
NSPasteboard *draggingPasteBoard = [info draggingPasteboard];
|
||||||
NSArray *classArray = [NSArray arrayWithObject:[NSURL class]];
|
NSArray *classArray = [NSArray arrayWithObject:[NSURL class]];
|
||||||
NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:classArray options:nil];
|
NSArray *arrayOfURLs = [draggingPasteBoard readObjectsForClasses:classArray options:nil];
|
||||||
@@ -37,11 +33,7 @@
|
|||||||
return NSDragOperationCopy;
|
return NSDragOperationCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)tableView:(NSTableView *)tableView
|
- (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation {
|
||||||
acceptDrop:(id<NSDraggingInfo>)info
|
|
||||||
row:(NSInteger)row
|
|
||||||
dropOperation:(NSTableViewDropOperation)dropOperation {
|
|
||||||
|
|
||||||
MPDocument *document = [[[tableView window] windowController] document];
|
MPDocument *document = [[[tableView window] windowController] document];
|
||||||
id entry = document.selectedEntry;
|
id entry = document.selectedEntry;
|
||||||
|
|
||||||
@@ -54,8 +46,10 @@
|
|||||||
}
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
|
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
/*
|
||||||
NSString *extension;
|
NSString *extension;
|
||||||
|
|
||||||
if([rowIndexes count] != 1) {
|
if([rowIndexes count] != 1) {
|
||||||
@@ -77,42 +71,7 @@
|
|||||||
|
|
||||||
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFilePromiseContent];
|
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFilePromiseContent];
|
||||||
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFileURLPromise ];
|
[pboard setPropertyList:@[uti] forType:(NSString *)kPasteboardTypeFileURLPromise ];
|
||||||
return YES;
|
return YES;*/
|
||||||
}
|
}
|
||||||
- (NSArray *)tableView:(NSTableView *)tableView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedRowsWithIndexes:(NSIndexSet *)indexSet {
|
|
||||||
if([indexSet count] != 1) {
|
|
||||||
return nil; // We only work with one file at a time
|
|
||||||
}
|
|
||||||
|
|
||||||
if(![dropDestination isFileURL]) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSUInteger row = [indexSet lastIndex];
|
|
||||||
NSData *fileData;
|
|
||||||
NSString *filename;
|
|
||||||
|
|
||||||
MPDocument *document = [[[tableView window] windowController] document];
|
|
||||||
id entry = document.selectedEntry;
|
|
||||||
|
|
||||||
if([entry isKindOfClass:[Kdb3Entry class]]) {
|
|
||||||
Kdb3Entry *entryV3 = (Kdb3Entry *)entry;
|
|
||||||
filename = entryV3.binaryDesc;
|
|
||||||
fileData = entryV3.binary;
|
|
||||||
}
|
|
||||||
else if([entry isKindOfClass:[Kdb4Entry class]]) {
|
|
||||||
Kdb4Entry *entryV4 = (Kdb4Entry *)entry;
|
|
||||||
BinaryRef *binaryRef = entryV4.binaries[row];
|
|
||||||
filename = binaryRef.key;
|
|
||||||
fileData = [document attachmentDataForItem:binaryRef];
|
|
||||||
}
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
|
|
||||||
NSURL *writeURL = [dropDestination URLByAppendingPathComponent:filename];
|
|
||||||
// Create unique filename if already present
|
|
||||||
[fileData writeToURL:writeURL atomically:YES];
|
|
||||||
});
|
|
||||||
return @[filename];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ typedef NS_ENUM(NSUInteger, MPDatabaseSettingsTab) {
|
|||||||
|
|
||||||
/* General Tab */
|
/* General Tab */
|
||||||
@property (weak) IBOutlet NSTextField *databaseNameTextField;
|
@property (weak) IBOutlet NSTextField *databaseNameTextField;
|
||||||
|
@property (weak) IBOutlet NSPopUpButton *databaseCompressionPopupButton;
|
||||||
@property (unsafe_unretained) IBOutlet NSTextView *databaseDescriptionTextView;
|
@property (unsafe_unretained) IBOutlet NSTextView *databaseDescriptionTextView;
|
||||||
|
@property (weak) IBOutlet NSColorWell *databaseColorColorWell;
|
||||||
|
|
||||||
/* Security Tab */
|
/* Security Tab */
|
||||||
@property (weak) IBOutlet NSButton *protectTitleCheckButton;
|
@property (weak) IBOutlet NSButton *protectTitleCheckButton;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#import "MPSettingsHelper.h"
|
#import "MPSettingsHelper.h"
|
||||||
#import "MPNumericalInputFormatter.h"
|
#import "MPNumericalInputFormatter.h"
|
||||||
|
|
||||||
|
#import "KPKXmlFormat.h"
|
||||||
#import "KPKGroup.h"
|
#import "KPKGroup.h"
|
||||||
#import "KPKTree.h"
|
#import "KPKTree.h"
|
||||||
#import "KPKMetaData.h"
|
#import "KPKMetaData.h"
|
||||||
@@ -66,9 +67,19 @@
|
|||||||
KPKMetaData *metaData = _document.tree.metaData;
|
KPKMetaData *metaData = _document.tree.metaData;
|
||||||
metaData.databaseDescription = [self.databaseDescriptionTextView string];
|
metaData.databaseDescription = [self.databaseDescriptionTextView string];
|
||||||
metaData.databaseName = [self.databaseNameTextField stringValue];
|
metaData.databaseName = [self.databaseNameTextField stringValue];
|
||||||
|
|
||||||
/* Display */
|
NSInteger compressionIndex = [self.databaseCompressionPopupButton indexOfSelectedItem];
|
||||||
|
if(compressionIndex >= KPKCompressionNone && compressionIndex < KPKCompressionCount) {
|
||||||
|
metaData.compressionAlgorithm = compressionIndex;
|
||||||
|
}
|
||||||
|
NSColor *databaseColor = [self.databaseColorColorWell color];
|
||||||
|
if([databaseColor isEqual:[NSColor clearColor]]) {
|
||||||
|
metaData.color = nil;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
metaData.color = databaseColor;
|
||||||
|
}
|
||||||
|
|
||||||
/* Advanced */
|
/* Advanced */
|
||||||
metaData.recycleBinEnabled = self.trashEnabled;
|
metaData.recycleBinEnabled = self.trashEnabled;
|
||||||
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
|
NSMenuItem *trashMenuItem = [self.selectRecycleBinGroupPopUpButton selectedItem];
|
||||||
@@ -122,7 +133,7 @@
|
|||||||
}
|
}
|
||||||
/* Update all stuff that might have changed */
|
/* Update all stuff that might have changed */
|
||||||
KPKMetaData *metaData = _document.tree.metaData;
|
KPKMetaData *metaData = _document.tree.metaData;
|
||||||
[self _setupDatabase:metaData];
|
[self _setupDatabaseTab:metaData];
|
||||||
[self _setupProtectionTab:metaData];
|
[self _setupProtectionTab:metaData];
|
||||||
[self _setupAdvancedTab:_document.tree];
|
[self _setupAdvancedTab:_document.tree];
|
||||||
self.isDirty = NO;
|
self.isDirty = NO;
|
||||||
@@ -154,9 +165,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark Private Helper
|
#pragma mark Private Helper
|
||||||
- (void)_setupDatabase:(KPKMetaData *)metaData {
|
- (void)_setupDatabaseTab:(KPKMetaData *)metaData {
|
||||||
[self.databaseNameTextField setStringValue:metaData.databaseName];
|
[self.databaseNameTextField setStringValue:metaData.databaseName];
|
||||||
[self.databaseDescriptionTextView setString:metaData.databaseDescription];
|
[self.databaseDescriptionTextView setString:metaData.databaseDescription];
|
||||||
|
[self.databaseCompressionPopupButton selectItemAtIndex:metaData.compressionAlgorithm];
|
||||||
|
NSColor *databaseColor = metaData.color ? metaData.color : [NSColor clearColor];
|
||||||
|
[self.databaseColorColorWell setColor:databaseColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)_setupProtectionTab:(KPKMetaData *)metaData {
|
- (void)_setupProtectionTab:(KPKMetaData *)metaData {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
NSSortDescriptor *userNameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"username" 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 *urlSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"url" ascending:YES selector:@selector(compare:)];
|
||||||
NSSortDescriptor *groupnameSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"parent.name" 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:)];
|
NSSortDescriptor *dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"timeInfo.lastModificationTime" ascending:YES selector:@selector(compare:)];
|
||||||
|
|
||||||
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
|
[titleColumn setSortDescriptorPrototype:titleColumSortDescriptor];
|
||||||
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
|
[userNameColumn setSortDescriptorPrototype:userNameSortDescriptor];
|
||||||
|
|||||||
Reference in New Issue
Block a user