|
@@ -12,6 +12,7 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
@IBOutlet var _titleLbl : NSTextField!
|
|
|
@IBOutlet var _degreeInfoLbl : NSTextField!
|
|
|
|
|
|
+ @IBOutlet var _activityView : NSProgressIndicator!
|
|
|
|
|
|
@IBOutlet var _contentView : NSView!
|
|
|
@IBOutlet var _imageView01 : NSImageView!
|
|
@@ -72,7 +73,12 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
let image2 = NSImage.init(contentsOfFile: resultPath)
|
|
|
_imageView02.image = image2;
|
|
|
|
|
|
- setTitle(String("[\(_fileInfo.objc().fileType()):\(_fileInfo.objc().name())]:\(_fileInfo.fileName())"))
|
|
|
+ if (nil == _fileInfo.refFilePath()) {
|
|
|
+ setTitle(String("[\(_fileInfo.objc().fileType()):\(_fileInfo.objc().name())]\(_fileInfo.fileName())"))
|
|
|
+ }else {
|
|
|
+ let lastPathComponent = NSString(string: _fileInfo.refFilePath()!).lastPathComponent
|
|
|
+ setTitle(String("[\(_fileInfo.objc().fileType()):\(_fileInfo.objc().name())]\(_fileInfo.fileName())/\(lastPathComponent)"))
|
|
|
+ }
|
|
|
|
|
|
let degree = _fileInfo.degree()
|
|
|
if degree == -1 {
|
|
@@ -90,6 +96,12 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
setTitle("")
|
|
|
_degreeInfoLbl.stringValue = ""
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ _activityView.isHidden = true;
|
|
|
+ _activityView.stopAnimation(nil)
|
|
|
+
|
|
|
+ _showCoverBtn.isHidden = _segmentedControl.indexOfSelectedItem == 0
|
|
|
}
|
|
|
|
|
|
public func fileInfo() -> NSMutableDictionary {
|
|
@@ -131,15 +143,39 @@ class ImageCompareCellView : NSTableCellView {
|
|
|
|
|
|
let image = NSImage.init(contentsOfFile: comparePath)
|
|
|
_imageView03.image = image;
|
|
|
+ self._imageView04.image = nil;
|
|
|
_imageView04.isHidden = _showCoverBtn.state == .off || _segmentedControl.indexOfSelectedItem != 1
|
|
|
|
|
|
// let image2 = NSImage.init(contentsOfFile: resultPath)
|
|
|
// _imageView04.image = image2;
|
|
|
- DispatchQueue.global().async {
|
|
|
- let image2 = ImageProcess.processImage(resultPath, checkPath: comparePath)
|
|
|
-
|
|
|
- DispatchQueue.main.sync {
|
|
|
- self._imageView04.image = image2
|
|
|
+ let degree = _fileInfo.degree()
|
|
|
+ if (abs(degree - 100) > 0) {
|
|
|
+ _activityView.isHidden = false
|
|
|
+ _activityView.startAnimation(sender)
|
|
|
+ DispatchQueue.global().async {
|
|
|
+ var image2 = nil as NSImage?
|
|
|
+
|
|
|
+ let coverPath = NSString(format: "%@_cover.png", NSString(string: resultPath).deletingPathExtension) as! String
|
|
|
+
|
|
|
+ if FileManager.default.fileExists(atPath: coverPath) {
|
|
|
+ image2 = NSImage.init(contentsOfFile: coverPath)
|
|
|
+ }else {
|
|
|
+ image2 = ImageProcess.processImage(resultPath, checkPath: comparePath)
|
|
|
+
|
|
|
+ if nil != image2 {
|
|
|
+ let rep = NSBitmapImageRep.init(cgImage: image2!.cgImage(forProposedRect: nil, context: nil, hints: nil)!)
|
|
|
+ let data = rep.representation(using: NSBitmapImageRep.FileType.png, properties: [:]);
|
|
|
+
|
|
|
+ let url = URL.init(fileURLWithPath: coverPath, isDirectory: false)
|
|
|
+ try? data!.write(to: url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DispatchQueue.main.sync {
|
|
|
+ self._imageView04.image = image2
|
|
|
+ self._activityView.isHidden = true
|
|
|
+ self._activityView.stopAnimation(sender)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|