|
@@ -3995,18 +3995,16 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
if (type == .bates) {
|
|
|
windowController = KMHeaderFooterWindowController(windowNibName: "KMHeaderFooterWindowController")
|
|
|
(windowController as! KMHeaderFooterWindowController).operateCallBack = { [unowned self] controller, headerFooter in
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddBates, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddBates, filepaths: [fpath])
|
|
|
}
|
|
|
|
|
|
windowController.isBates = true
|
|
|
} else if (type == .headerAndFooter) {
|
|
|
windowController = KMHeaderFooterWindowController(windowNibName: "KMHeaderFooterWindowController")
|
|
|
(windowController as! KMHeaderFooterWindowController).operateCallBack = { [unowned self] controller, headerFooter in
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddHeaderFooter, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddHeaderFooter, filepaths: [fpath])
|
|
|
}
|
|
|
} else if (type == .background) {
|
|
|
} else if (type == .watermark) {
|
|
@@ -4032,20 +4030,18 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
self.closeRightPane()
|
|
|
return
|
|
|
} else if index == 3 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
if type == .bates {
|
|
|
- self.showBatchWindow(type: .AddBates, files: [file])
|
|
|
+ self.showBatchWindow(type: .AddBates, filepaths: [fpath])
|
|
|
} else {
|
|
|
- self.showBatchWindow(type: .AddHeaderFooter, files: [file])
|
|
|
+ self.showBatchWindow(type: .AddHeaderFooter, filepaths: [fpath])
|
|
|
}
|
|
|
} else if index == 4 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
if type == .bates {
|
|
|
- self.showBatchWindow(type: .RemoveBates, files: [file])
|
|
|
+ self.showBatchWindow(type: .RemoveBates, filepaths: [fpath])
|
|
|
} else {
|
|
|
- self.showBatchWindow(type: .RemoveHeaderFooter, files: [file])
|
|
|
+ self.showBatchWindow(type: .RemoveHeaderFooter, filepaths: [fpath])
|
|
|
}
|
|
|
} else if (index == 2) { //// 移除
|
|
|
if type == .headerAndFooter {
|
|
@@ -4405,11 +4401,8 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
self.currentWindowController = nil
|
|
|
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddWatermark, files: [file])
|
|
|
-
|
|
|
-
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddWatermark, filepaths: [fpath])
|
|
|
}
|
|
|
// NSWindow.currentWindow().beginSheet(controller.window!)
|
|
|
NSWindow.currentWindow().beginSheet(controller.window!, completionHandler: nil)
|
|
@@ -4465,13 +4458,11 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
}
|
|
|
} else if index == 3 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddWatermark, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddWatermark, filepaths: [fpath])
|
|
|
} else if index == 4 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .RemoveWatermark, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .RemoveWatermark, filepaths: [fpath])
|
|
|
} else if index == 5 {
|
|
|
self.rightSideViewController.isHidden = false
|
|
|
self.rightSideViewController.subViewType = KMWatermarkAdjectiveTools.KMToolBarTypeToRightSubViewType(type)
|
|
@@ -4499,9 +4490,8 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
|
|
|
controller.operateCallBack = { [unowned self] controller, background, countType in
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddBackground, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddBackground, filepaths: [fpath])
|
|
|
}
|
|
|
|
|
|
await NSWindow.currentWindow().beginSheet(controller.window!)
|
|
@@ -4538,13 +4528,11 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
})
|
|
|
}
|
|
|
} else if index == 3 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .AddBackground, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .AddBackground, filepaths: [fpath])
|
|
|
} else if index == 4 {
|
|
|
- let file = KMFileAttribute()
|
|
|
- file.filePath = (self.document?.documentURL.path)!
|
|
|
- self.showBatchWindow(type: .RemoveBackground, files: [file])
|
|
|
+ let fpath = self.document?.documentURL?.path ?? ""
|
|
|
+ self.showBatchWindow(type: .RemoveBackground, filepaths: [fpath])
|
|
|
} else if index == 5 {
|
|
|
self.rightSideViewController.isHidden = false
|
|
|
self.rightSideViewController.subViewType = KMWatermarkAdjectiveTools.KMToolBarTypeToRightSubViewType(type)
|
|
@@ -4555,13 +4543,25 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func showBatchWindow(type: KMBatchOperationType, files: [KMFileAttribute]?) {
|
|
|
- let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
+// func showBatchWindow(type: KMBatchOperationType, files: [KMFileAttribute]?) {
|
|
|
+// let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
+//// batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
+//
|
|
|
+// var array: [KMBatchOperateFile] = []
|
|
|
+// for file in files ?? [] {
|
|
|
+// let batchOperateFile = KMBatchOperateFile(filePath: file.filePath, type: type)
|
|
|
+// array.append(batchOperateFile)
|
|
|
+// }
|
|
|
+// batchWindowController.switchToOperateType(type, files: array)
|
|
|
// batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
+// }
|
|
|
+
|
|
|
+ func showBatchWindow(type: KMBatchOperationType, filepaths: [String]?) {
|
|
|
+ let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
|
|
|
var array: [KMBatchOperateFile] = []
|
|
|
- for file in files! {
|
|
|
- let batchOperateFile = KMBatchOperateFile(filePath: file.filePath, type: type)
|
|
|
+ for fpath in filepaths ?? [] {
|
|
|
+ let batchOperateFile = KMBatchOperateFile(filePath: fpath, type: type)
|
|
|
array.append(batchOperateFile)
|
|
|
}
|
|
|
batchWindowController.switchToOperateType(type, files: array)
|