|
@@ -10,7 +10,7 @@ import KMComponentLibrary
|
|
|
|
|
|
let KMBatchDragType = "KMBatchDragType"
|
|
|
|
|
|
-class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NSTableViewDataSource{
|
|
|
+class KMBatchOperateLeftViewController: KMNBaseViewController,NSTableViewDelegate,NSTableViewDataSource{
|
|
|
|
|
|
@IBOutlet var selectFileButton: KMLongerButton!
|
|
|
|
|
@@ -47,9 +47,22 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
var popOver: NSPopover?
|
|
|
var progressInt: Int = 0
|
|
|
|
|
|
- private var addFileButton_: ComponentButton?
|
|
|
+ private var addFileButton_: ComponentDropdown?
|
|
|
private var deleteButton_: ComponentButton?
|
|
|
|
|
|
+ private var groupView_: ComponentGroup?
|
|
|
+
|
|
|
+ private var emptyViewTopLine: NSView = {
|
|
|
+ let view = NSView()
|
|
|
+ view.wantsLayer = true
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+ private var emptyView_: ComponentEmpty = {
|
|
|
+ let view = ComponentEmpty()
|
|
|
+ view.properties = ComponentEmptyProperty(emptyType: .add_File, state: .normal, image: NSImage(named: "KMEmptyIcon"), text: KMLocalizedString("Select Files"), subText: KMLocalizedString("Drop files here or Click Add Files at upper left corner. You can drag files to reorder as you need."))
|
|
|
+ return view
|
|
|
+ }()
|
|
|
+
|
|
|
deinit {
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
DistributedNotificationCenter.default().removeObserver(self)
|
|
@@ -100,51 +113,84 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
|
|
|
// self.selectFileButton.containerViewController = self
|
|
|
selectFileButton.title = ""
|
|
|
- addFileButton_ = ComponentButton()
|
|
|
- addFileButton_?.properties = ComponentButtonProperty(type: .gray, size: .s, state: .normal, showLeftIcon: true,buttonText: KMLocalizedString("Add Files"), icon: NSImage(named: "KMImageNameAddFilesIcon"))
|
|
|
+ addFileButton_ = ComponentDropdown()
|
|
|
+// addFileButton_?.properties = ComponentButtonProperty(type: .gray, size: .s, state: .normal, showLeftIcon: true,buttonText: KMLocalizedString("Add Files"), icon: NSImage(named: "KMImageNameAddFilesIcon"))
|
|
|
+ addFileButton_?.properties = ComponentDropdownProperty(type: .split_graySecondary, size: .s, split: true, text: KMLocalizedString("Add Files..."))
|
|
|
+// addFileButton_?.splitRightButton.properties.icon = NSImage(named: "ImageToPDFDropdownButtonIcon")
|
|
|
// addFileButton_?.setTarget(self, action: #selector(cancelButtonAction))
|
|
|
+
|
|
|
selectFileButton.addSubview(addFileButton_!)
|
|
|
addFileButton_?.frame = selectFileButton.bounds
|
|
|
addFileButton_?.autoresizingMask = [.width, .height]
|
|
|
+ addFileButton_?.componentDelegate = self
|
|
|
|
|
|
deleteButton_ = ComponentButton()
|
|
|
- deleteButton_?.properties = ComponentButtonProperty(type: .gray, size: .s, state: .normal, onlyIcon: true)
|
|
|
+ deleteButton_?.properties = ComponentButtonProperty(type: .text_gray_low, size: .s, state: .normal, onlyIcon: true)
|
|
|
deleteButton_?.setTarget(self, action: #selector(buttonClicked_DeleteFile))
|
|
|
+ deleteFileButton.image = nil
|
|
|
deleteFileButton.addSubview(deleteButton_!)
|
|
|
deleteButton_?.frame = deleteFileButton.bounds
|
|
|
deleteButton_?.autoresizingMask = [.width, .height]
|
|
|
deleteButton_?.properties.propertyInfo.leftIcon_nor = NSImage(named: "KMImageNameDeleteFileIcon")
|
|
|
+ deleteButton_?.setTarget(self, action: #selector(buttonClicked_DeleteFile))
|
|
|
|
|
|
- tableView.headerView?.wantsLayer = true
|
|
|
-// tableView.headerView?.layer?.backgroundColor = NSColor.red.cgColor
|
|
|
- var frame = tableView.headerView?.frame
|
|
|
- frame?.size.height = 32
|
|
|
- tableView.headerView?.frame = frame ?? .zero
|
|
|
-
|
|
|
+// tableView.headerView?.wantsLayer = true
|
|
|
+// tableView.headerView?.layer?.backgroundColor = NSColor.blue.cgColor
|
|
|
+// var frame = tableView.headerView?.frame
|
|
|
+// frame?.size.height = 32
|
|
|
+// tableView.headerView?.frame = frame ?? .zero
|
|
|
+ tableView.headerView = nil
|
|
|
|
|
|
self.showInFinderMenuItem.title = NSLocalizedString("Show in Finder", comment: "")
|
|
|
self.deleteMenuItem.title = NSLocalizedString("Delete", comment: "")
|
|
|
self.blankView.wantsLayer = true
|
|
|
self.blankView.layer?.backgroundColor = NSColor.clear.cgColor
|
|
|
- self.blankView.titleLabel.stringValue = NSLocalizedString("Select Files", comment: "")
|
|
|
+ self.blankView.titleLabel.stringValue = ""
|
|
|
self.blankView.imageView.isHidden = true
|
|
|
- self.blankView.addButton.isHidden = false
|
|
|
- self.blankView.secondTitleLabel.stringValue = NSLocalizedString("Drop files here or Click Add Files at upper left corner. You can drag files to reorder as you need.", comment: "")
|
|
|
+ self.blankView.addButton.isHidden = true
|
|
|
+ self.blankView.secondTitleLabel.stringValue = ""
|
|
|
self.blankView.mouseActionCallBack = { [weak self] mouseType in
|
|
|
- guard let self = self else { return }
|
|
|
- if mouseType == .mouseEnter {
|
|
|
- self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListHov")
|
|
|
- } else if mouseType == .mouseExit {
|
|
|
- self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListNor")
|
|
|
- } else if mouseType == .mouseDown {
|
|
|
- self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListPre")
|
|
|
- self.chooseFile()
|
|
|
- } else if mouseType == .mouseUp {
|
|
|
- self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListHov")
|
|
|
- }
|
|
|
+// guard let self = self else { return }
|
|
|
+// if mouseType == .mouseEnter {
|
|
|
+// self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListHov")
|
|
|
+// } else if mouseType == .mouseExit {
|
|
|
+// self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListNor")
|
|
|
+// } else if mouseType == .mouseDown {
|
|
|
+// self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListPre")
|
|
|
+// self.chooseFile()
|
|
|
+// } else if mouseType == .mouseUp {
|
|
|
+// self.blankView.imageView.image = NSImage(named: "KMImageNameEmptyListHov")
|
|
|
+// }
|
|
|
}
|
|
|
+ self.blankView.addSubview(emptyView_)
|
|
|
+
|
|
|
+ blankView.addSubview(emptyViewTopLine)
|
|
|
+ emptyViewTopLine.km_add_top_constraint(constant: 4)
|
|
|
+ emptyViewTopLine.km_add_left_constraint(constant: 24)
|
|
|
+ emptyViewTopLine.km_add_right_constraint(constant: -24)
|
|
|
+ emptyViewTopLine.km_add_height_constraint(constant: 1)
|
|
|
+ emptyViewTopLine.wantsLayer = true
|
|
|
+ let dividerColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider")
|
|
|
+ emptyViewTopLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+
|
|
|
+ emptyView_.km_add_top_constraint(constant: 96)
|
|
|
+ emptyView_.km_add_bottom_constraint()
|
|
|
+ emptyView_.km_add_leading_constraint()
|
|
|
+ emptyView_.km_add_trailing_constraint()
|
|
|
+ emptyView_.setTarget(self, action: #selector(emptyAddFileAction))
|
|
|
+
|
|
|
updateViewColor()
|
|
|
}
|
|
|
+
|
|
|
+ override func updateUILanguage() {
|
|
|
+ super.updateUILanguage()
|
|
|
+
|
|
|
+ KMMainThreadExecute {
|
|
|
+ self.addFileButton_?.properties.text = KMLocalizedString("Add Files...")
|
|
|
+ self.addFileButton_?.reloadData()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@objc func reloadData() {
|
|
|
if Thread.isMainThread {
|
|
|
tableView.reloadData()
|
|
@@ -371,9 +417,9 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
// if KMAlertWindowController.needShowRemoveAllFilesHint() {
|
|
|
let alert = NSAlert()
|
|
|
alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Clear All Recents", comment: "")+"?"
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Delete", comment: ""))
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
|
|
|
+ alert.messageText = KMLocalizedString("Clear All Recents", comment: "")+"?"
|
|
|
+ alert.addButton(withTitle: KMLocalizedString("Delete", comment: ""))
|
|
|
+ alert.addButton(withTitle: KMLocalizedString("Cancel", comment: ""))
|
|
|
alert.beginSheetModal(for: self.view.window!) {[weak self] response in
|
|
|
if response == NSApplication.ModalResponse.alertFirstButtonReturn {
|
|
|
self?.files.removeAll()
|
|
@@ -501,23 +547,176 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
}
|
|
|
addFilesToList(addArray: pdfArray)
|
|
|
}
|
|
|
+
|
|
|
+ // MARK: - Actions
|
|
|
+
|
|
|
+ @objc func emptyAddFileAction() {
|
|
|
+ self.chooseFile()
|
|
|
+ }
|
|
|
+
|
|
|
+ //MARK: - GroupView
|
|
|
+
|
|
|
+ func showGroupView() {
|
|
|
+ var viewHeight: CGFloat = 8
|
|
|
+ var menuItemArr: [ComponentMenuitemProperty] = []
|
|
|
+ for i in ["Add Files...", "Add Folder...", "Import from Clipboard...", "Import from Scanner..."] {
|
|
|
+ let properties_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
|
|
|
+ itemSelected: false,
|
|
|
+ isDisabled: false,
|
|
|
+ keyEquivalent: nil,
|
|
|
+ text: KMLocalizedString(i))
|
|
|
+ menuItemArr.append(properties_Menuitem)
|
|
|
+ viewHeight += 36
|
|
|
+ }
|
|
|
+
|
|
|
+ if groupView_ == nil {
|
|
|
+ groupView_ = ComponentGroup.createFromNib(in: ComponentLibrary.shared.componentBundle())
|
|
|
+ }
|
|
|
+ groupView_?.groupDelegate = self
|
|
|
+ groupView_?.frame = CGRectMake(310, 0, 200, viewHeight)
|
|
|
+ groupView_?.updateGroupInfo(menuItemArr)
|
|
|
+
|
|
|
+ var point = addFileButton_?.convert(addFileButton_!.frame.origin, to: nil) ?? .zero
|
|
|
+ point.y -= viewHeight
|
|
|
+ groupView_?.showWithPoint(point, relativeTo: addFileButton_)
|
|
|
+
|
|
|
+ addFileButton_?.properties.state = .pressed
|
|
|
+ addFileButton_?.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ func removeGroupView() {
|
|
|
+ if groupView_ != nil {
|
|
|
+ groupView_?.removeFromSuperview()
|
|
|
+ }
|
|
|
+ addFileButton_?.properties.state = .normal
|
|
|
+ addFileButton_?.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ func openDocumentWithImageFromPasteboard(_ pboard: NSPasteboard, error outError: AutoreleasingUnsafeMutablePointer<NSError?>?) -> CPDFDocument? {
|
|
|
+ var document: CPDFDocument? = nil
|
|
|
+ var data: Data? = nil
|
|
|
+
|
|
|
+ if pboard.canReadItem(withDataConformingToTypes: [NSPasteboard.PasteboardType.pdf.rawValue]) {
|
|
|
+ data = pboard.data(forType: NSPasteboard.PasteboardType.pdf)
|
|
|
+ } else if pboard.canReadItem(withDataConformingToTypes: [NSPasteboard.PasteboardType.postScript.rawValue]) {
|
|
|
+ data = pboard.data(forType: NSPasteboard.PasteboardType.postScript)
|
|
|
+ } else if pboard.canReadItem(withDataConformingToTypes: [NSPasteboard.PasteboardType.tiff.rawValue]) {
|
|
|
+ data = convertTIFFDataToPDF(pboard.data(forType: NSPasteboard.PasteboardType.tiff) ?? Data())
|
|
|
+ } else {
|
|
|
+ let images = pboard.readObjects(forClasses: [NSImage.self], options: [:])
|
|
|
+ let strings = pboard.readObjects(forClasses: [NSAttributedString.self], options: [:])
|
|
|
+ if images?.count ?? 0 > 0 {
|
|
|
+ data = convertTIFFDataToPDF((images![0] as AnyObject).tiffRepresentation!)
|
|
|
+ } else if strings?.count ?? 0 > 0 {
|
|
|
+ data = KMOCTool.convertStringsToPDF(withString: strings ?? [""]) // convertStringsToPDF(strings!)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if let data = data {
|
|
|
+ document = CPDFDocument(data: data)
|
|
|
+
|
|
|
+ } else if let outError = outError {
|
|
|
+ outError.pointee = NSError(domain: "SKDocumentErrorDomain", code: 3, userInfo: [NSLocalizedDescriptionKey: NSLocalizedString("Unable to load data from clipboard", comment: "Error description")])
|
|
|
+ }
|
|
|
+
|
|
|
+ return document
|
|
|
+ }
|
|
|
+
|
|
|
+ func convertTIFFDataToPDF(_ tiffData: Data) -> Data? {
|
|
|
+ guard let imsrc = CGImageSourceCreateWithData(tiffData as CFData, [kCGImageSourceTypeIdentifierHint: kUTTypeTIFF] as CFDictionary), CGImageSourceGetCount(imsrc) > 0, let cgImage = CGImageSourceCreateImageAtIndex(imsrc, 0, nil) else { return nil }
|
|
|
+ let pdfData = NSMutableData(capacity: tiffData.count)
|
|
|
+ let consumer = CGDataConsumer(data: pdfData! as CFMutableData)!
|
|
|
+
|
|
|
+ var rect = CGRect(x: 0, y: 0, width: CGFloat(cgImage.width), height: CGFloat(cgImage.height))
|
|
|
+ let ctxt = CGContext(consumer: consumer, mediaBox: &rect, nil)
|
|
|
+ ctxt!.beginPDFPage(nil)
|
|
|
+ ctxt!.draw(cgImage, in: rect)
|
|
|
+ ctxt!.endPDFPage()
|
|
|
+ ctxt!.closePDF()
|
|
|
+
|
|
|
+ return pdfData as? Data
|
|
|
+ }
|
|
|
+
|
|
|
+ // MARK: - Private Methods
|
|
|
+
|
|
|
+ private func _saveImagePath() -> String {
|
|
|
+ let rootPath = KMDataManager.fetchAppSupportOfBundleIdentifierDirectory()
|
|
|
+ let path = rootPath.appendingPathComponent("ImageToPDF").path
|
|
|
+ if FileManager.default.fileExists(atPath: path) == false {
|
|
|
+ try?FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false)
|
|
|
+ }
|
|
|
+ return path
|
|
|
+ }
|
|
|
+
|
|
|
+ private func _clearImageData() {
|
|
|
+ let path = self._saveImagePath()
|
|
|
+ if FileManager.default.fileExists(atPath: path) {
|
|
|
+ try?FileManager.default.removeItem(atPath: path)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
func numberOfRows(in tableView: NSTableView) -> Int {
|
|
|
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMBatchFilesCountNotification"), object: self.files, userInfo: [kObjectKey : self])
|
|
|
self.deleteFileButton.isEnabled = self.files.count > 0
|
|
|
+ deleteButton_?.properties.isDisabled = self.files.count <= 0
|
|
|
self.blankView.isHidden = self.files.count > 0
|
|
|
- return self.files.count;
|
|
|
+ if self.files.count == 0 {
|
|
|
+ return 0
|
|
|
+ }
|
|
|
+ return self.files.count + 1;
|
|
|
}
|
|
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
|
|
let identifier = tableColumn?.identifier
|
|
|
- let file = self.files[row]
|
|
|
+
|
|
|
+ let rowIdx = max(0, row-1)
|
|
|
+ let file = self.files[rowIdx]
|
|
|
+
|
|
|
+ let cellColor = ComponentLibrary.shared.getComponentColorFromKey("olorFill/4")
|
|
|
+ let dividerColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider")
|
|
|
+ let titleFont = ComponentLibrary.shared.getFontFromKey("mac/body-s-medium")
|
|
|
+ let titleColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/1")
|
|
|
|
|
|
if identifier?.rawValue == "index" {
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+// cellView.layer?.backgroundColor = NSColor(hex: "#F6F6F8").cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("")
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .Size)
|
|
|
_ = row + 1
|
|
|
cellView.textField?.stringValue = String(format: "%d", row + 1);
|
|
|
return cellView;
|
|
|
} else if identifier?.rawValue == "pageRange"{
|
|
|
if (file.currentOperateType == .CreatePDF) {
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("Dimensions")
|
|
|
+ cellView.titleLabel.font = titleFont
|
|
|
+ cellView.titleLabel.textColor = titleColor
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .Size)
|
|
|
|
|
|
if (file.fileType == .Image) {
|
|
@@ -532,6 +731,23 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
return cellView;
|
|
|
}
|
|
|
} else if identifier?.rawValue == "status"{
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("State")
|
|
|
+ cellView.titleLabel.font = titleFont
|
|
|
+ cellView.titleLabel.textColor = titleColor
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .Status)
|
|
|
if (file.currentOperateType == .CreatePDF) {
|
|
|
cellView.updateInterface(file: file, progress: file.progress ?? 0)
|
|
@@ -544,12 +760,51 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
}
|
|
|
return cellView;
|
|
|
} else if identifier?.rawValue == "size"{
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("Size")
|
|
|
+ cellView.titleLabel.font = titleFont
|
|
|
+ cellView.titleLabel.textColor = titleColor
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .Size)
|
|
|
cellView.updateInterface(file)
|
|
|
return cellView;
|
|
|
} else if identifier?.rawValue == "fileName"{
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("File Name")
|
|
|
+ cellView.titleLabel.font = titleFont
|
|
|
+ cellView.titleLabel.textColor = titleColor
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .FileName)
|
|
|
cellView.updateInterface(file)
|
|
|
+
|
|
|
+ cellView.fileIv?.wantsLayer = true
|
|
|
+ cellView.fileIv?.layer?.borderWidth = 1
|
|
|
+ cellView.fileIv?.layer?.borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/3-default").cgColor
|
|
|
+
|
|
|
let rowView: KMBatchTableRowView = tableView.rowView(atRow: row, makeIfNecessary: true) as! KMBatchTableRowView
|
|
|
if ((file.error) != nil) {
|
|
|
rowView.backgroundColor = KMAppearance.Status.errBGColor();
|
|
@@ -560,6 +815,24 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
cellView.updateInterface(file)
|
|
|
return cellView;
|
|
|
} else if identifier?.rawValue == "dimensions"{
|
|
|
+ if row == 0 {
|
|
|
+ let cellView = KMNTableHeaderCellView()
|
|
|
+ cellView.wantsLayer = true
|
|
|
+ cellView.layer?.backgroundColor = cellColor.cgColor
|
|
|
+
|
|
|
+ cellView.titleLabel.stringValue = KMLocalizedString("Dimensions")
|
|
|
+ cellView.titleLabel.font = titleFont
|
|
|
+ cellView.titleLabel.textColor = titleColor
|
|
|
+
|
|
|
+ cellView.leftLine.wantsLayer = true
|
|
|
+ cellView.leftLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.rightLine.wantsLayer = true
|
|
|
+ cellView.rightLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+ cellView.bottomLine.wantsLayer = true
|
|
|
+ cellView.bottomLine.layer?.backgroundColor = dividerColor.cgColor
|
|
|
+// cellView.
|
|
|
+ return cellView
|
|
|
+ }
|
|
|
let cellView = KMBatchTableCellView(type: .Size)
|
|
|
|
|
|
if (file.fileType == .Image) {
|
|
@@ -572,12 +845,16 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
return nil;
|
|
|
}
|
|
|
func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat {
|
|
|
- let file = self.files[row]
|
|
|
+ let rowIdx = max(0, row-1)
|
|
|
+ let file = self.files[rowIdx]
|
|
|
if self.type == .CreatePDF {
|
|
|
+ if row == 0 {
|
|
|
+ return 32
|
|
|
+ }
|
|
|
if (file.error != nil) {
|
|
|
- return 64
|
|
|
+ return 104
|
|
|
} else {
|
|
|
- return 40
|
|
|
+ return 80
|
|
|
}
|
|
|
} else {
|
|
|
if file.fileType == .PDF {
|
|
@@ -592,6 +869,15 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
|
|
|
}
|
|
|
}
|
|
|
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
|
|
+ if row == 0 {
|
|
|
+ let rowView = KMBatchTableRowView()
|
|
|
+ rowView.selectionBackgroundColorBlock = {
|
|
|
+ return .clear
|
|
|
+ }
|
|
|
+ rowView.selectionHighlightStyle = .none
|
|
|
+ rowView.isSelected = false
|
|
|
+ return rowView
|
|
|
+ }
|
|
|
let rowView = KMBatchTableRowView()
|
|
|
return rowView
|
|
|
}
|
|
@@ -832,3 +1118,46 @@ extension KMBatchOperateLeftViewController: NSMenuDelegate, NSMenuItemValidation
|
|
|
return true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+//MARK: - ComponentDropdownDelegate
|
|
|
+
|
|
|
+extension KMBatchOperateLeftViewController: ComponentDropdownDelegate {
|
|
|
+ func componentDropdownDidShowMenuItem(dropdown: ComponentDropdown) {
|
|
|
+ showGroupView()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//MARK: - ComponentGroupDelegate
|
|
|
+
|
|
|
+extension KMBatchOperateLeftViewController: ComponentGroupDelegate {
|
|
|
+ func componentGroupDidDismiss(group: ComponentGroup?) {
|
|
|
+
|
|
|
+ removeGroupView()
|
|
|
+ }
|
|
|
+
|
|
|
+ func componentGroupDidSelect(group: ComponentGroup?, menuItemProperty: ComponentMenuitemProperty?) {
|
|
|
+ if let selItem = menuItemProperty {
|
|
|
+ let index = group?.menuItemArr.firstIndex(of: selItem)
|
|
|
+ if index == 0 {
|
|
|
+ chooseFile()
|
|
|
+ } else if index == 1 {
|
|
|
+ chooseFile()
|
|
|
+ } else if index == 2 {
|
|
|
+ let pboard = NSPasteboard.general
|
|
|
+ if let document = self.openDocumentWithImageFromPasteboard(pboard, error: nil) {
|
|
|
+ // Document opened successfully
|
|
|
+ if let page = document.page(at: 0) {
|
|
|
+ let data = page.PDFListViewTIFFData(for: page.bounds)
|
|
|
+ var path = self._saveImagePath() + "/Untitled.png"
|
|
|
+ path = KMTools.getUniqueFilePath(filePath: path)
|
|
|
+ try?data?.write(to: URL(fileURLWithPath: path), options: .atomic)
|
|
|
+
|
|
|
+ self.addFilesToList(addArray: [path])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if index == 3 {
|
|
|
+ chooseFileFromCamera()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|