|
@@ -208,6 +208,35 @@ extension KMHomeViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ func showSecurityWindow() {
|
|
|
+ Task { @MainActor in
|
|
|
+ if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
|
|
|
+ let _ = KMComparativeTableViewController.show(window: self.view.window!, .secure)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
+ let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
+ if (isClose) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ self.km_secure_openPanel_security(limit: true)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ self.km_secure_openPanel_security()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func km_secure_openPanel_security(limit: Bool = false) {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ NSOpenPanel.km_secure_openPanel_success(window: self.view.window!, needOwner: true) { url, password in
|
|
|
+ self._showSecurityWindow(url: url, password: password, limit: limit)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// MARK: - Private Methods
|
|
|
|
|
|
fileprivate func _showConvertWindow(type: KMPDFConvertType, url: URL, password: String? = nil) {
|
|
@@ -250,6 +279,66 @@ extension KMHomeViewController {
|
|
|
self.view.window?.beginSheet((windowController?.window)!)
|
|
|
self.currentWindowController = windowController
|
|
|
}
|
|
|
+
|
|
|
+ fileprivate func _showSecurityWindow(url: URL, password: String?, limit: Bool = false) { // 安全
|
|
|
+ let windowC = KMSecureEncryptWindowController(windowNibName: "KMSecureEncryptWindowController")
|
|
|
+ windowC.documentURL = url
|
|
|
+ windowC.myDocument = CPDFDocument(url: url)
|
|
|
+ if let _password = password {
|
|
|
+ windowC.myDocument.unlock(withPassword: _password)
|
|
|
+ }
|
|
|
+ self.currentWindowController = windowC
|
|
|
+
|
|
|
+ let newDocument: CPDFDocument = CPDFDocument(url: url)
|
|
|
+ windowC.itemClick = { [weak self] _ in
|
|
|
+ if let _currentWindow = self?.currentWindowController?.window {
|
|
|
+ self?.view.window?.endSheet(_currentWindow)
|
|
|
+ }
|
|
|
+ self?.currentWindowController = nil
|
|
|
+ }
|
|
|
+
|
|
|
+ windowC.resultCallback = { [weak self] _ in
|
|
|
+ let windowController_secure: KMSecureEncryptWindowController = self?.currentWindowController as! KMSecureEncryptWindowController
|
|
|
+ if let _currentWindow = self?.currentWindowController?.window {
|
|
|
+ self?.view.window?.endSheet(_currentWindow)
|
|
|
+ }
|
|
|
+ self?.currentWindowController = nil
|
|
|
+ if let _password = password {
|
|
|
+ newDocument.unlock(withPassword: _password)
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!limit) {
|
|
|
+ newDocument.setPasswordOptions(windowController_secure.options)
|
|
|
+ let result = KMPasswordInputWindow.saveDocument(newDocument)
|
|
|
+ if result {
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([newDocument.documentURL])
|
|
|
+ } else {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.messageText = NSLocalizedString("Failure", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NSPanel.savePanel((self?.view.window)!, panel: { panel in
|
|
|
+ panel.nameFieldStringValue = url.lastPathComponent
|
|
|
+ }) { response, saveUrl in
|
|
|
+ if (response == .cancel) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if let fileUrl = KMTools.saveWatermarkDocument(document: newDocument, to: saveUrl!, secureOptions: windowController_secure.options) {
|
|
|
+ NSWorkspace.shared.activateFileViewerSelecting([fileUrl])
|
|
|
+ } else {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.messageText = NSLocalizedString("Failure", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ self.view.window?.beginSheet(windowC.window!)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - NSSplitViewDelegate
|