mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
Dragging URLs now uses the host as entry name.
This commit is contained in:
@@ -38,24 +38,21 @@
|
|||||||
|
|
||||||
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];
|
||||||
BOOL ok = NO;
|
BOOL ok = YES;
|
||||||
for(NSURL *url in arrayOfURLs) {
|
for(NSURL *url in arrayOfURLs) {
|
||||||
if([url isFileURL] || [url isFileReferenceURL]) {
|
if([url isFileURL] || [url isFileReferenceURL]) {
|
||||||
continue;
|
|
||||||
ok = NO;
|
ok = NO;
|
||||||
|
break; // OK stays NO;
|
||||||
}
|
}
|
||||||
ok = YES;
|
|
||||||
}
|
}
|
||||||
return ok ? NSDragOperationCopy : NSDragOperationNone;
|
return ok ? NSDragOperationCopy : NSDragOperationNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender {
|
- (BOOL)wantsPeriodicDraggingUpdates {
|
||||||
return YES;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
|
|
||||||
|
|
||||||
NSPasteboard *draggingPasteBoard = [sender draggingPasteboard];
|
NSPasteboard *draggingPasteBoard = [sender 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];
|
||||||
@@ -66,16 +63,22 @@
|
|||||||
}
|
}
|
||||||
/* Currently not working, as the underlying operations do not get the unomanager */
|
/* Currently not working, as the underlying operations do not get the unomanager */
|
||||||
MPDocument *document = [[[sender draggingDestinationWindow] windowController] document];
|
MPDocument *document = [[[sender draggingDestinationWindow] windowController] document];
|
||||||
BOOL ok = NO;
|
KPKGroup *parentGroup = document.selectedGroup ? document.selectedGroup : document.root;
|
||||||
if(document.selectedGroup) {
|
[document.undoManager beginUndoGrouping];
|
||||||
[[document undoManager] beginUndoGrouping];
|
KPKEntry *entry = [document createEntry:parentGroup];
|
||||||
KPKEntry *entry = [document createEntry:document.selectedGroup];
|
BOOL didOk = (entry != nil);
|
||||||
ok = (nil != entry);
|
if(url.absoluteString) {
|
||||||
entry.url = [url absoluteString];
|
entry.url = url.absoluteString;
|
||||||
[[document undoManager] endUndoGrouping];
|
|
||||||
[[document undoManager] setActionName:NSLocalizedString(@"IMPORT_URL", @"Imports a dragged URL for a new entry")];
|
|
||||||
}
|
}
|
||||||
return ok;
|
else {
|
||||||
|
didOk = NO;
|
||||||
|
}
|
||||||
|
if(url.host) {
|
||||||
|
entry.title = url.host;
|
||||||
|
}
|
||||||
|
[document.undoManager endUndoGrouping];
|
||||||
|
[document.undoManager setActionName:NSLocalizedString(@"IMPORT_URL", @"Imports a dragged URL for a new entry")];
|
||||||
|
return didOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user