mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 11:42:30 +00:00
drag and drop for icon files is working
This commit is contained in:
@@ -83,7 +83,7 @@
|
|||||||
<constraint firstItem="57" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="iuz-pK-yXC"/>
|
<constraint firstItem="57" firstAttribute="top" secondItem="1" secondAttribute="top" constant="20" symbolic="YES" id="iuz-pK-yXC"/>
|
||||||
<constraint firstItem="101" firstAttribute="leading" secondItem="8kv-BJ-IEk" secondAttribute="trailing" constant="8" symbolic="YES" id="nvi-CZ-a6L"/>
|
<constraint firstItem="101" firstAttribute="leading" secondItem="8kv-BJ-IEk" secondAttribute="trailing" constant="8" symbolic="YES" id="nvi-CZ-a6L"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<point key="canvasLocation" x="-43" y="90"/>
|
<point key="canvasLocation" x="-143" y="15"/>
|
||||||
</customView>
|
</customView>
|
||||||
<collectionViewItem id="61">
|
<collectionViewItem id="61">
|
||||||
<connections>
|
<connections>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
self.iconCollectionView.selectable = YES;
|
self.iconCollectionView.selectable = YES;
|
||||||
self.iconCollectionView.allowsMultipleSelection = NO;
|
self.iconCollectionView.allowsMultipleSelection = NO;
|
||||||
self.iconCollectionView.delegate = self;
|
self.iconCollectionView.delegate = self;
|
||||||
//[self.iconCollectionView registerForDraggedTypes:@[(NSString *)kUTTypeURL, (NSString *)kUTTypeFileURL]];
|
[self.iconCollectionView registerForDraggedTypes:@[(NSString *)kUTTypeURL, (NSString *)kUTTypeFileURL]];
|
||||||
|
|
||||||
MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument;
|
MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument;
|
||||||
self.iconCollectionView.content = document.tree.metaData.customIcons;
|
self.iconCollectionView.content = document.tree.metaData.customIcons;
|
||||||
@@ -95,8 +95,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id <NSDraggingInfo>)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation {
|
- (BOOL)collectionView:(NSCollectionView *)collectionView acceptDrop:(id <NSDraggingInfo>)draggingInfo index:(NSInteger)index dropOperation:(NSCollectionViewDropOperation)dropOperation {
|
||||||
NSLog(@"Index:%ld", index);
|
NSPasteboard *pBoard = [draggingInfo draggingPasteboard];
|
||||||
return YES;
|
NSArray *urls = [pBoard readObjectsForClasses:@[NSURL.class] options:@{ NSPasteboardURLReadingFileURLsOnlyKey : @YES }];
|
||||||
|
if(urls.count == 0) {
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
BOOL success = NO;
|
||||||
|
MPDocument *document = [NSDocumentController sharedDocumentController].currentDocument;
|
||||||
|
for(NSURL *url in urls) {
|
||||||
|
KPKIcon *icon = [[KPKIcon alloc] initWithImageAtURL:url];
|
||||||
|
if(icon.image) {
|
||||||
|
NSLog(@"Added Icon at:%@", url);
|
||||||
|
[document.tree.metaData addCustomIcon:icon];
|
||||||
|
success = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(success) {
|
||||||
|
self.iconCollectionView.content = document.tree.metaData.customIcons;
|
||||||
|
self.iconCollectionView.content = [[MPIconHelper databaseIcons] arrayByAddingObjectsFromArray:document.tree.metaData.customIcons];
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user