|
@@ -87,6 +87,9 @@ import Cocoa
|
|
|
//密码弹窗
|
|
|
var passwordWindow: KMPasswordInputWindow?
|
|
|
|
|
|
+ //
|
|
|
+ var securityWindowController: KMSecurityWindowController?
|
|
|
+
|
|
|
//春季活动
|
|
|
var recommondPopWindowVC: KMRecommondPopWindow?
|
|
|
|
|
@@ -1403,25 +1406,22 @@ import Cocoa
|
|
|
// MARK: - 显示加密弹窗
|
|
|
|
|
|
public func showSecureWindow(_ url: URL) {
|
|
|
- let controller = KMSecurityWindowController(windowNibName: "KMSecurityWindowController")
|
|
|
- controller.documentURL = self.listView.document.documentURL
|
|
|
- self.currentWindowController = controller
|
|
|
-
|
|
|
- controller.batchAction = { [unowned self] controller, files in
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
- self.currentWindowController = nil
|
|
|
+ self.securityWindowController = KMSecurityWindowController(windowNibName: "KMSecurityWindowController")
|
|
|
+ guard let securityWindowController = securityWindowController else { return }
|
|
|
+
|
|
|
+ securityWindowController.documentURL = self.listView.document.documentURL
|
|
|
+ securityWindowController.batchAction = { [unowned self] controller, files in
|
|
|
+ self.view.window?.endSheet((securityWindowController.window)!)
|
|
|
|
|
|
self.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
|
|
|
|
|
|
let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
-// batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
let batchOperateFile = KMBatchOperateFile(filePath: self.document?.documentURL.path ?? "", type: .AddPassword)
|
|
|
batchWindowController.switchToOperateType(.AddPassword, files: [batchOperateFile])
|
|
|
batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
}
|
|
|
|
|
|
- controller.doneAction = { [unowned self] controller, options, attribute in
|
|
|
-// let windowController_secure = self.currentWindowController as! KMSecureEncryptWindowController
|
|
|
+ securityWindowController.doneAction = { [unowned self] controller, options, attribute in
|
|
|
let openPanel = NSOpenPanel()
|
|
|
openPanel.canChooseFiles = false
|
|
|
openPanel.canChooseDirectories = true
|
|
@@ -1436,9 +1436,7 @@ import Cocoa
|
|
|
let path = fileURL.path.stringByAppendingPathComponent(url.deletingPathExtension().lastPathComponent) + "_SetPassword" + "." + url.pathExtension
|
|
|
let success = document!.write(to: NSURL(fileURLWithPath: path) as URL, withOptions: options)
|
|
|
if success {
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
- self.currentWindowController = nil
|
|
|
-
|
|
|
+ self.view.window?.endSheet((securityWindowController.window)!)
|
|
|
|
|
|
NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: path)])
|
|
|
}
|
|
@@ -1448,11 +1446,10 @@ import Cocoa
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- controller.cancelAction = { [unowned self] controller in
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
- self.currentWindowController = nil
|
|
|
+ securityWindowController.cancelAction = { [unowned self] controller in
|
|
|
+ self.view.window?.endSheet((securityWindowController.window)!)
|
|
|
}
|
|
|
- NSWindow.currentWindow().beginSheet(controller.window!)
|
|
|
+ NSWindow.currentWindow().beginSheet(securityWindowController.window!)
|
|
|
}
|
|
|
|
|
|
// MARK: - 保存文档
|