|
@@ -94,7 +94,7 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
self.lockFileIndex = 0
|
|
self.lockFileIndex = 0
|
|
self.progressInt = 0
|
|
self.progressInt = 0
|
|
|
|
|
|
- self.selectFileButton.title = NSLocalizedString("Add Files", comment: "")
|
|
|
|
|
|
+ self.selectFileButton.title = NSLocalizedString(" Add Files", comment: "")
|
|
self.selectFileButton.wantsLayer = true
|
|
self.selectFileButton.wantsLayer = true
|
|
self.selectFileButton.layer?.borderWidth = 1.0
|
|
self.selectFileButton.layer?.borderWidth = 1.0
|
|
self.selectFileButton.layer?.borderColor = KMAppearance.Interactive.m0Color().cgColor
|
|
self.selectFileButton.layer?.borderColor = KMAppearance.Interactive.m0Color().cgColor
|
|
@@ -587,32 +587,38 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
var result: NSDragOperation = []
|
|
var result: NSDragOperation = []
|
|
let pboard = info.draggingPasteboard
|
|
let pboard = info.draggingPasteboard
|
|
if pboard.availableType(from: [.fileURL]) != nil {
|
|
if pboard.availableType(from: [.fileURL]) != nil {
|
|
- if let fileURLs = pboard.propertyList(forType: .fileURL) as? [URL] {
|
|
|
|
- for url in fileURLs {
|
|
|
|
- var isDirectory: ObjCBool = false
|
|
|
|
- let fileExists = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
|
|
|
|
- if fileExists && isDirectory.boolValue {
|
|
|
|
- let containFile = folderContainAvailableFile(url.path)
|
|
|
|
- if containFile {
|
|
|
|
- isCanDrag = true
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if let UTType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, url.pathExtension as CFString, nil)?.takeRetainedValue() as String? {
|
|
|
|
- if self.type == .CreatePDF {
|
|
|
|
- if UTTypeConformsTo(UTType as CFString, kUTTypeImage) {
|
|
|
|
- isCanDrag = true
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if UTTypeConformsTo(UTType as CFString, kUTTypePDF) {
|
|
|
|
- isCanDrag = true
|
|
|
|
- }
|
|
|
|
|
|
+ guard let pbItems = pboard.pasteboardItems else {
|
|
|
|
+ return NSDragOperation(rawValue: 0)
|
|
|
|
+ }
|
|
|
|
+ var hasValidFile = false
|
|
|
|
+
|
|
|
|
+ for item in pbItems {
|
|
|
|
+ guard let data = item.string(forType: .fileURL), let _url = URL(string: data) else {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ var isDirectory: ObjCBool = false
|
|
|
|
+ let fileExists = FileManager.default.fileExists(atPath: _url.path, isDirectory: &isDirectory)
|
|
|
|
+ if fileExists && isDirectory.boolValue {
|
|
|
|
+ let containFile = folderContainAvailableFile(_url.path)
|
|
|
|
+ if containFile {
|
|
|
|
+ isCanDrag = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if let UTType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, _url.pathExtension as CFString, nil)?.takeRetainedValue() as String? {
|
|
|
|
+ if self.type == .CreatePDF {
|
|
|
|
+ if UTTypeConformsTo(UTType as CFString, kUTTypeImage) {
|
|
|
|
+ isCanDrag = true
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if UTTypeConformsTo(UTType as CFString, kUTTypePDF) {
|
|
|
|
+ isCanDrag = true
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if isCanDrag {
|
|
|
|
- break
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if isCanDrag {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if isCanDrag {
|
|
if isCanDrag {
|
|
@@ -661,30 +667,28 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
self.tableView.reloadData()
|
|
self.tableView.reloadData()
|
|
return true
|
|
return true
|
|
} else if pboard.availableType(from: [.fileURL]) != nil {
|
|
} else if pboard.availableType(from: [.fileURL]) != nil {
|
|
- guard let fileNames = pboard.propertyList(forType: .fileURL) as? [String]
|
|
|
|
- else {
|
|
|
|
- return false
|
|
|
|
|
|
+ if (pboard.pasteboardItems == nil) {
|
|
|
|
+
|
|
|
|
+ return true
|
|
}
|
|
}
|
|
|
|
+
|
|
let allFilesArray = NSMutableArray()
|
|
let allFilesArray = NSMutableArray()
|
|
- for path in fileNames {
|
|
|
|
|
|
+ for item in pboard.pasteboardItems! {
|
|
|
|
+ let fileURL = item.string(forType: .fileURL)
|
|
|
|
+ if (fileURL == nil) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ let path = URL.init(string: fileURL!)
|
|
|
|
+ if (path == nil) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
var isFolder = ObjCBool(false)
|
|
var isFolder = ObjCBool(false)
|
|
- FileManager.default.fileExists(atPath: path, isDirectory: &isFolder)
|
|
|
|
|
|
+ FileManager.default.fileExists(atPath: path!.path, isDirectory: &isFolder)
|
|
if isFolder.boolValue {
|
|
if isFolder.boolValue {
|
|
- let containFiles = fetchAvailableFilesInFolder(path)
|
|
|
|
|
|
+ let containFiles = fetchAvailableFilesInFolder(path!.path)
|
|
allFilesArray.addObjects(from: containFiles)
|
|
allFilesArray.addObjects(from: containFiles)
|
|
} else {
|
|
} else {
|
|
- let UTTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, path.customPathExtension as CFString, nil)
|
|
|
|
- let TypeCFString = UTTypeString as! CFString
|
|
|
|
-
|
|
|
|
- if self.type == .CreatePDF {
|
|
|
|
- if UTTypeConformsTo(TypeCFString, kUTTypeImage) {
|
|
|
|
- allFilesArray.add(path)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- if UTTypeConformsTo(TypeCFString, kUTTypePDF) {
|
|
|
|
- allFilesArray.add(path)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ allFilesArray.add(path!.path)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var insertArray = NSMutableArray()
|
|
var insertArray = NSMutableArray()
|
|
@@ -692,40 +696,32 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
lockFileIndex = 0
|
|
lockFileIndex = 0
|
|
for i in 0..<allFilesArray.count {
|
|
for i in 0..<allFilesArray.count {
|
|
let filePath: String = allFilesArray[i] as! String
|
|
let filePath: String = allFilesArray[i] as! String
|
|
- let UTTypeString = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, filePath.customPathExtension as CFString, nil)
|
|
|
|
- let TypeCFString = UTTypeString as! CFString
|
|
|
|
- if UTTypeConformsTo(TypeCFString, kUTTypePDF) {
|
|
|
|
- let document = CPDFDocument(url: URL(fileURLWithPath: filePath))
|
|
|
|
- if let pdf = CPDFDocument(url: URL(fileURLWithPath: filePath)) {
|
|
|
|
- if !pdf.allowsPrinting || !pdf.allowsCopying {
|
|
|
|
- let alert = NSAlert()
|
|
|
|
- alert.alertStyle = .critical
|
|
|
|
- alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
|
|
|
|
- alert.runModal()
|
|
|
|
- continue
|
|
|
|
- } else if document?.isLocked ?? false {
|
|
|
|
- lockFilePathArr?.add(filePath)
|
|
|
|
- } else {
|
|
|
|
- let file = KMBatchOperateFile(filePath: filePath, type: self.type!)
|
|
|
|
- if !(self.files.contains(file) ) {
|
|
|
|
- insertArray.add(file)
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ let document = CPDFDocument(url: URL(fileURLWithPath: filePath))
|
|
|
|
+ if let pdf = CPDFDocument(url: URL(fileURLWithPath: filePath)) {
|
|
|
|
+ if !pdf.allowsPrinting || !pdf.allowsCopying {
|
|
|
|
+ let alert = NSAlert()
|
|
|
|
+ alert.alertStyle = .critical
|
|
|
|
+ alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
|
|
|
|
+ alert.runModal()
|
|
|
|
+ continue
|
|
|
|
+ } else if document?.isLocked ?? false {
|
|
|
|
+ lockFilePathArr?.add(filePath)
|
|
|
|
+ } else {
|
|
|
|
+ let file = KMBatchOperateFile(filePath: filePath, type: self.type!)
|
|
|
|
+ if !(self.files.contains(file) ) {
|
|
|
|
+ insertArray.add(file)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- let file = KMBatchOperateFile(filePath: filePath, type: self.type!)
|
|
|
|
- if !(self.files.contains(file) ) {
|
|
|
|
- insertArray.add(file)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// if !(IAPProductsManager.defaultManager.isAvailableAllFunction) {
|
|
// if !(IAPProductsManager.defaultManager.isAvailableAllFunction) {
|
|
- if self.files.count < 1 {
|
|
|
|
- insertArray = [insertArray.first].compactMap { $0 } as! NSMutableArray
|
|
|
|
- } else {
|
|
|
|
- // KMPurchaseCompareWindowController.sharedInstance.showWindow(nil)
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
|
|
+// if self.files.count < 1 {
|
|
|
|
+// insertArray = [insertArray.first].compactMap { $0 } as! NSMutableArray
|
|
|
|
+// } else {
|
|
|
|
+// // KMPurchaseCompareWindowController.sharedInstance.showWindow(nil)
|
|
|
|
+// return false
|
|
|
|
+// }
|
|
// }
|
|
// }
|
|
for i in 0..<insertArray.count {
|
|
for i in 0..<insertArray.count {
|
|
self.files.insert(insertArray[i] as! KMBatchOperateFile, at: row + i)
|
|
self.files.insert(insertArray[i] as! KMBatchOperateFile, at: row + i)
|