Properly enable the copy menu item
This commit is contained in:
3 files changed
+8
-8
No files matched your search
@@ -62,7 +62,7 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
private let standardSize = NSSize(width: 154, height: 192)
|
private let standardSize = NSSize(width: 154, height: 192)
|
||||||
|
|
||||||
@IBOutlet var removeArtworkButton: NSButton!
|
@IBOutlet var removeArtworkButton: NSButton!
|
||||||
@IBOutlet var artworksView: NSCollectionView!
|
@IBOutlet var artworksView: CollectionView!
|
||||||
|
|
||||||
override var nibName: NSNib.Name? {
|
override var nibName: NSNib.Name? {
|
||||||
return "MovieView"
|
return "MovieView"
|
||||||
@@ -125,11 +125,11 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
artworksView.register(ArtworkSelectorViewItem.self, forItemWithIdentifier: ArtworkSelectorController.itemView)
|
artworksView.register(ArtworkSelectorViewItem.self, forItemWithIdentifier: ArtworkSelectorController.itemView)
|
||||||
artworksView.registerForDraggedTypes(NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0)})
|
artworksView.registerForDraggedTypes(NSFilePromiseReceiver.readableDraggedTypes.map { NSPasteboard.PasteboardType($0)})
|
||||||
artworksView.registerForDraggedTypes([.fileURL, .artworkDragType])
|
artworksView.registerForDraggedTypes([.fileURL, .artworkDragType])
|
||||||
|
artworksView.pasteboardTypes = [.fileURL, .tiff, .MP42PasteboardTypeArtwork]
|
||||||
|
|
||||||
// Determine the kind of source drag originating from this app.
|
// Determine the kind of source drag originating from this app.
|
||||||
// Note, if you want to allow your app to drag items to the Finder's trash can, add ".delete".
|
// Note, if you want to allow your app to drag items to the Finder's trash can, add ".delete".
|
||||||
artworksView.setDraggingSourceOperationMask([.copy, .delete], forLocal: false)
|
artworksView.setDraggingSourceOperationMask([.copy, .delete], forLocal: false)
|
||||||
artworksView.setDraggingSourceOperationMask([.copy, .move], forLocal: true)
|
|
||||||
|
|
||||||
reloadData()
|
reloadData()
|
||||||
}
|
}
|
||||||
@@ -866,7 +866,6 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func replace(metadataArtworks items: [MP42MetadataItem], withItems newItems: [MP42MetadataItem]) {
|
private func replace(metadataArtworks items: [MP42MetadataItem], withItems newItems: [MP42MetadataItem]) {
|
||||||
|
|
||||||
metadata.removeItems(items)
|
metadata.removeItems(items)
|
||||||
metadata.addItems(newItems)
|
metadata.addItems(newItems)
|
||||||
|
|
||||||
@@ -882,12 +881,14 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
|
|
||||||
updateArtworksArray()
|
updateArtworksArray()
|
||||||
artworksView.reloadData()
|
artworksView.reloadData()
|
||||||
|
updateSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func removeArtwork(_ sender: Any?) {
|
@IBAction func removeArtwork(_ sender: Any?) {
|
||||||
let selectedIndexes = artworksView.selectionIndexes
|
let selectedIndexes = artworksView.selectionIndexes
|
||||||
artworks = IndexSet(artworks.indices).subtracting(selectedIndexes).map {artworks[$0]}
|
artworks = IndexSet(artworks.indices).subtracting(selectedIndexes).map {artworks[$0]}
|
||||||
artworksView.deleteItems(at: artworksView.selectionIndexPaths)
|
artworksView.deleteItems(at: artworksView.selectionIndexPaths)
|
||||||
|
updateSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func add(artworks: [Any], toIndexPath: IndexPath) -> Bool {
|
private func add(artworks: [Any], toIndexPath: IndexPath) -> Bool {
|
||||||
@@ -914,6 +915,7 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
add(metadataArtworks: items)
|
add(metadataArtworks: items)
|
||||||
|
updateSelection()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1246,9 +1248,7 @@ class MovieViewController: PropertyView, NSTableViewDataSource, ExpandedTableVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
func collectionViewDelete(in collectionView: NSCollectionView) {
|
func collectionViewDelete(in collectionView: NSCollectionView) {
|
||||||
let itemIndexes = collectionView.selectionIndexPaths.compactMap { $0.last }
|
removeArtwork(self)
|
||||||
let items = itemIndexes.map { artworks[$0] }
|
|
||||||
remove(metadataArtworks: items)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionViewCopy(in collectionView: NSCollectionView) {
|
func collectionViewCopy(in collectionView: NSCollectionView) {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class CollectionView: NSCollectionView, NSMenuItemValidation {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
case #selector(paste(_:)):
|
case #selector(paste(_:)):
|
||||||
if isSelectionEmpty || implements(selector: #selector(CollectionViewDelegate.collectionViewPaste(to:))) == false {
|
if pasteboardHasSupportedType == false || implements(selector: #selector(CollectionViewDelegate.collectionViewPaste(to:))) == false {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
+1
-1
Submodule MP42Foundation updated: 5555a95ee6...cb5149390f.
Reference in new issue
Block a user