|
@@ -7,8 +7,7 @@
|
|
|
|
|
|
import Cocoa
|
|
import Cocoa
|
|
|
|
|
|
-@objcMembers class KMMainViewController: NSViewController,NSTextFieldDelegate {
|
|
|
|
-
|
|
|
|
|
|
+@objcMembers class KMMainViewController: KMBaseViewController, NSTextFieldDelegate {
|
|
@IBOutlet var PDFContendView: NSView!
|
|
@IBOutlet var PDFContendView: NSView!
|
|
@IBOutlet var centerContentView: NSView!
|
|
@IBOutlet var centerContentView: NSView!
|
|
@IBOutlet var listView: CPDFListView!
|
|
@IBOutlet var listView: CPDFListView!
|
|
@@ -149,7 +148,6 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
var autoSaveTimer: Timer?
|
|
var autoSaveTimer: Timer?
|
|
- var progressController: SKProgressController?
|
|
|
|
private var _documentFirstLoad: Bool = true
|
|
private var _documentFirstLoad: Bool = true
|
|
|
|
|
|
var eventMonitor: Any?
|
|
var eventMonitor: Any?
|
|
@@ -708,6 +706,7 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - AI
|
|
//MARK: - AI
|
|
|
|
+
|
|
func loadAIIconView() -> Void {
|
|
func loadAIIconView() -> Void {
|
|
NotificationCenter.default.addObserver(self, selector: #selector(aiTipIconViewShowStateChangeNoti), name: NSNotification.Name(rawValue: "kAIIconShowStateChangeNotification"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(aiTipIconViewShowStateChangeNoti), name: NSNotification.Name(rawValue: "kAIIconShowStateChangeNotification"), object: nil)
|
|
if self.aiTipView == nil {
|
|
if self.aiTipView == nil {
|
|
@@ -797,7 +796,6 @@ import Cocoa
|
|
var rect = self.aiTipView.bounds
|
|
var rect = self.aiTipView.bounds
|
|
rect.origin.y += 20
|
|
rect.origin.y += 20
|
|
popover.show(relativeTo: rect, of: self.aiTipView, preferredEdge: .minY)
|
|
popover.show(relativeTo: rect, of: self.aiTipView, preferredEdge: .minY)
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
func loadAIConfigWindowWithType(_ type: AIConfigType) -> Void {
|
|
func loadAIConfigWindowWithType(_ type: AIConfigType) -> Void {
|
|
@@ -838,6 +836,7 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - 引导
|
|
//MARK: - 引导
|
|
|
|
+
|
|
func loadFunctionGuide() -> Void {
|
|
func loadFunctionGuide() -> Void {
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
|
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1) {
|
|
if self.view.window != nil {
|
|
if self.view.window != nil {
|
|
@@ -1155,7 +1154,8 @@ import Cocoa
|
|
return pageCount > 30
|
|
return pageCount > 30
|
|
}
|
|
}
|
|
|
|
|
|
- // MARK: Redact 【标记密文】
|
|
|
|
|
|
+ // MARK: - Redact 【标记密文】
|
|
|
|
+
|
|
func exeRedactConfirm(_ type: KMRedactConfirmType, callback: @escaping () -> ()?) {
|
|
func exeRedactConfirm(_ type: KMRedactConfirmType, callback: @escaping () -> ()?) {
|
|
let windowController = KMRedactConfirmWindowController(type)
|
|
let windowController = KMRedactConfirmWindowController(type)
|
|
self.currentWindowController = windowController
|
|
self.currentWindowController = windowController
|
|
@@ -1273,6 +1273,7 @@ import Cocoa
|
|
}
|
|
}
|
|
|
|
|
|
//MARK: - Form
|
|
//MARK: - Form
|
|
|
|
+
|
|
func showFormAlertView() {
|
|
func showFormAlertView() {
|
|
if (formAlertView == nil) {
|
|
if (formAlertView == nil) {
|
|
formAlertView = KMFormAlertView()
|
|
formAlertView = KMFormAlertView()
|
|
@@ -1305,8 +1306,7 @@ import Cocoa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // MARK: -
|
|
|
|
- // MARK: 显示合并窗口
|
|
|
|
|
|
+ // MARK: - 显示合并窗口
|
|
|
|
|
|
public func showMergeWindow(url: URL? = nil, _ password: String?) {
|
|
public func showMergeWindow(url: URL? = nil, _ password: String?) {
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
@@ -1401,8 +1401,7 @@ import Cocoa
|
|
NSWindow.currentWindow().beginSheet(controller.window!)
|
|
NSWindow.currentWindow().beginSheet(controller.window!)
|
|
}
|
|
}
|
|
|
|
|
|
- // MARK: -
|
|
|
|
- // MARK: 保存文档
|
|
|
|
|
|
+ // MARK: - 保存文档
|
|
|
|
|
|
internal func needSaveDocument() -> Bool {
|
|
internal func needSaveDocument() -> Bool {
|
|
if (self.isPDFDocumentEdited) {
|
|
if (self.isPDFDocumentEdited) {
|
|
@@ -1470,13 +1469,13 @@ import Cocoa
|
|
internal func saveDocumentWithProgressAlert(callback:@escaping KMCommonBlock) {
|
|
internal func saveDocumentWithProgressAlert(callback:@escaping KMCommonBlock) {
|
|
// 显示进度
|
|
// 显示进度
|
|
self.showProgressWindow(message: NSLocalizedString("Save", comment: "") + "PDF")
|
|
self.showProgressWindow(message: NSLocalizedString("Save", comment: "") + "PDF")
|
|
- self.progressController?.maxValue = 3.0
|
|
|
|
- self.progressController?.increment(by: 1.0)
|
|
|
|
|
|
+ self.progressC?.maxValue = 3.0
|
|
|
|
+ self.progressC?.increment(by: 1.0)
|
|
// 保存文档
|
|
// 保存文档
|
|
self.asyncSaveDocument { [unowned self] params in
|
|
self.asyncSaveDocument { [unowned self] params in
|
|
// 执行进度 [假进度]
|
|
// 执行进度 [假进度]
|
|
- self.progressController?.increment(by: 1.0)
|
|
|
|
- self.progressController?.increment(by: 1.0)
|
|
|
|
|
|
+ self.progressC?.increment(by: 1.0)
|
|
|
|
+ self.progressC?.increment(by: 1.0)
|
|
|
|
|
|
// DispatchQueue.main.async {
|
|
// DispatchQueue.main.async {
|
|
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
|
|
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
|
|
@@ -1614,8 +1613,8 @@ import Cocoa
|
|
AutoSaveManager.manager.removeAutoSavePath(self.listView?.document?.documentURL.path ?? "")
|
|
AutoSaveManager.manager.removeAutoSavePath(self.listView?.document?.documentURL.path ?? "")
|
|
}
|
|
}
|
|
|
|
|
|
- // MARK: -
|
|
|
|
- // MARK: 选择 PDFDisplay 模式
|
|
|
|
|
|
+ // MARK: - 选择 PDFDisplay 模式
|
|
|
|
+
|
|
@objc public func selectDisplay(display: KMPDFDisplayType, viewSettingIsReload: Bool = true) {
|
|
@objc public func selectDisplay(display: KMPDFDisplayType, viewSettingIsReload: Bool = true) {
|
|
let toolModel = self.listView.toolMode
|
|
let toolModel = self.listView.toolMode
|
|
self.isReadMode = false
|
|
self.isReadMode = false
|
|
@@ -1703,35 +1702,9 @@ import Cocoa
|
|
self.homeVC?.newFromImages()
|
|
self.homeVC?.newFromImages()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // MARK: -
|
|
|
|
- // MARK: Progress
|
|
|
|
-
|
|
|
|
- func showProgressWindow(message: String = "") {
|
|
|
|
- if (self.progressController != nil) {
|
|
|
|
- self.hiddenProgressWindow()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let progress = SKProgressController()
|
|
|
|
- progress.window?.backgroundColor = NSColor.km_init(hex: "#36383B")
|
|
|
|
- progress.window?.contentView?.wantsLayer = true
|
|
|
|
- progress.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#36383B").cgColor
|
|
|
|
- progress.progressField.textColor = NSColor.white
|
|
|
|
- progress.showClose = false
|
|
|
|
- progress.message = message
|
|
|
|
-
|
|
|
|
- self.progressController = progress
|
|
|
|
- self.view.window?.beginSheet(progress.window!)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- func hiddenProgressWindow() {
|
|
|
|
- if (self.progressController != nil) {
|
|
|
|
- self.view.window?.endSheet((self.progressController?.window)!)
|
|
|
|
- self.progressController = nil
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- // MARK -
|
|
|
|
// MARK - Event 监听
|
|
// MARK - Event 监听
|
|
|
|
+
|
|
private func addEventMonitor() {
|
|
private func addEventMonitor() {
|
|
if (self.eventMonitor != nil) {
|
|
if (self.eventMonitor != nil) {
|
|
self.removeEventMonitor()
|
|
self.removeEventMonitor()
|
|
@@ -1838,8 +1811,7 @@ import Cocoa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // MARK: -
|
|
|
|
- // MARK: Tools
|
|
|
|
|
|
+ // MARK: - Tools
|
|
|
|
|
|
func pdfViewCanHorizontalScroll() -> Bool {
|
|
func pdfViewCanHorizontalScroll() -> Bool {
|
|
let scroll = self.listView.scroll()
|
|
let scroll = self.listView.scroll()
|
|
@@ -2140,10 +2112,6 @@ import Cocoa
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if self.interactionMode == .presentation {
|
|
if self.interactionMode == .presentation {
|
|
- // if _isShowToolbar {
|
|
|
|
- // self.toolbarViewController.hiddenToolbar(true)
|
|
|
|
- // }
|
|
|
|
- //
|
|
|
|
// if self.pdfView().currentPage()?.isEqual(page) == false {
|
|
// if self.pdfView().currentPage()?.isEqual(page) == false {
|
|
// self.pdfView().go(to: page)
|
|
// self.pdfView().go(to: page)
|
|
// }
|
|
// }
|
|
@@ -2191,77 +2159,6 @@ import Cocoa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- func addTopTip(_ view: NSView?) {
|
|
|
|
- if (Thread.isMainThread) {
|
|
|
|
- if (view == nil) {
|
|
|
|
- let contentView: NSView = self.topTipBox.contentView!
|
|
|
|
- for subview in contentView.subviews {
|
|
|
|
- subview.removeFromSuperview()
|
|
|
|
- }
|
|
|
|
- self.topTipBox.isHidden = true
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let contentView: NSView = self.topTipBox.contentView!
|
|
|
|
- for subview in contentView.subviews {
|
|
|
|
- subview.removeFromSuperview()
|
|
|
|
- }
|
|
|
|
- self.topTipBox.isHidden = false
|
|
|
|
- self.topTipBox.contentView?.addSubview(view!)
|
|
|
|
- } else {
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if (view == nil) {
|
|
|
|
- let contentView: NSView = self.topTipBox.contentView!
|
|
|
|
- for subview in contentView.subviews {
|
|
|
|
- subview.removeFromSuperview()
|
|
|
|
- }
|
|
|
|
- self.topTipBox.isHidden = true
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let contentView: NSView = self.topTipBox.contentView!
|
|
|
|
- for subview in contentView.subviews {
|
|
|
|
- subview.removeFromSuperview()
|
|
|
|
- }
|
|
|
|
- self.topTipBox.isHidden = false
|
|
|
|
- self.topTipBox.contentView?.addSubview(view!)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- func pdfListView(_ sender: CPDFListView!, showSnapshotAtPageNumber pageNum: Int, for rect: NSRect, scaleFactor: CGFloat, autoFits: Bool) {
|
|
|
|
- let swc = KMSnapshotWindowController(windowNibName: "SnapshotWindow")
|
|
|
|
- swc.delegate = self
|
|
|
|
- swc.setPdfDocument(self.listView.document, goToPageNumber: pageNum, rect: rect, scaleFactor: scaleFactor, autoFits: autoFits)
|
|
|
|
- swc.forceOnTop = self.interactionMode != .normal
|
|
|
|
- self.myDocument?.addWindowController(swc)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- func pdfListView(_ pdfView: CPDFListView!, documentDataDidChanged docData: Any!, withInfo info: [AnyHashable : Any]!) {
|
|
|
|
- if let data = info?[CPDFListView.outlineKey] as? Bool, data { // 大纲改变
|
|
|
|
- guard let ol = docData as? CPDFOutline else {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- let add = info?[CPDFListView.outlineAddKey] as? Bool ?? false
|
|
|
|
- let remove = info?[CPDFListView.outlineRemoveKey] as? Bool ?? false
|
|
|
|
- if add {
|
|
|
|
- self.leftSideViewController.addOutlineAfter(ol)
|
|
|
|
- }
|
|
|
|
- if remove {
|
|
|
|
- self.leftSideViewController.removeOutlineAfter(ol)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- let demote = info?[CPDFListView.outlineDemoteKey] as? Bool ?? false
|
|
|
|
- let promote = info?[CPDFListView.outlinePromoteKey] as? Bool ?? false
|
|
|
|
- if demote {
|
|
|
|
- self.leftSideViewController.demoteOutlineAfter(ol)
|
|
|
|
- }
|
|
|
|
- if promote {
|
|
|
|
- self.leftSideViewController.promoteOutlineAfter(ol)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// MARK: Split View
|
|
// MARK: Split View
|
|
|
|
|
|
func changePDFDocument(isChange: Bool, replaceBlock: @escaping (String) -> Void) {
|
|
func changePDFDocument(isChange: Bool, replaceBlock: @escaping (String) -> Void) {
|
|
@@ -2327,13 +2224,13 @@ extension KMMainViewController {
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Recommond活动
|
|
// MARK: - Recommond活动
|
|
|
|
+
|
|
func loadRecommondPopWindow() {
|
|
func loadRecommondPopWindow() {
|
|
if IAPProductsManager.default().isAvailableAllFunction() {
|
|
if IAPProductsManager.default().isAvailableAllFunction() {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
if let info = KMAdvertisementManager.manager.info.popWindowContent?.content?.first {
|
|
if let info = KMAdvertisementManager.manager.info.popWindowContent?.content?.first {
|
|
-
|
|
|
|
if recommondPopWindowVC == nil {
|
|
if recommondPopWindowVC == nil {
|
|
recommondPopWindowVC = KMRecommondPopWindow()
|
|
recommondPopWindowVC = KMRecommondPopWindow()
|
|
}
|
|
}
|