|
@@ -734,9 +734,9 @@ extension KMMainViewController {
|
|
|
|
|
|
func enterPresentationMode() {
|
|
|
let scrollView = listView.documentView().enclosingScrollView
|
|
|
- savedNormalSetup.setValue(scrollView?.hasHorizontalScroller, forKey: HASHORIZONTALSCROLLER_KEY)
|
|
|
- savedNormalSetup.setValue(scrollView?.hasVerticalScroller, forKey: HASVERTICALSCROLLER_KEY)
|
|
|
- savedNormalSetup.setValue(scrollView?.autohidesScrollers, forKey: AUTOHIDESSCROLLERS_KEY)
|
|
|
+ savedNormalSetup.setValue(scrollView?.hasHorizontalScroller, forKey: KMMainModel.Key.kHasHorizontalScroller)
|
|
|
+ savedNormalSetup.setValue(scrollView?.hasVerticalScroller, forKey: KMMainModel.Key.kHasVerticalsCroller)
|
|
|
+ savedNormalSetup.setValue(scrollView?.autohidesScrollers, forKey: KMMainModel.Key.kAutoHidesScrollers)
|
|
|
// Set up presentation mode
|
|
|
// if RUNNING(version: 10_12) {
|
|
|
// pdfView.setBackgroundColor(NSColor.black)
|
|
@@ -791,24 +791,24 @@ extension KMMainViewController {
|
|
|
}
|
|
|
|
|
|
func applyPDFSettings(_ setup: NSDictionary) {
|
|
|
- if let data = setup.object(forKey: AUTOSCALES_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kAutoScales) as? NSNumber {
|
|
|
self.listView.autoScales = data.boolValue
|
|
|
}
|
|
|
if self.listView.autoScales == false {
|
|
|
- if let data = setup.object(forKey: SCALEFACTOR_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kScaleFactor) as? NSNumber {
|
|
|
self.listView.scaleFactor = data.floatValue.cgFloat
|
|
|
}
|
|
|
}
|
|
|
- if let data = setup.object(forKey: DISPLAYSPAGEBREAKS_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kDisplaysPageBreaks) as? NSNumber {
|
|
|
self.listView.displaysPageBreaks = data.boolValue
|
|
|
}
|
|
|
- if let data = setup.object(forKey: DISPLAYSASBOOK_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kDisplaysAsBook) as? NSNumber {
|
|
|
self.listView.displaysAsBook = data.boolValue
|
|
|
}
|
|
|
- if let data = setup.object(forKey: DISPLAYMODE_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kDisplayMode) as? NSNumber {
|
|
|
self.listView.displayMode = CPDFDisplayMode(rawValue: data.intValue) ?? .normal
|
|
|
}
|
|
|
- if let data = setup.object(forKey: DISPLAYBOX_KEY) as? NSNumber {
|
|
|
+ if let data = setup.object(forKey: KMMainModel.Key.kDisplayBox) as? NSNumber {
|
|
|
self.listView.displayBox = CPDFDisplayBox(rawValue: data.intValue) ?? .cropBox
|
|
|
}
|
|
|
}
|
|
@@ -825,12 +825,12 @@ extension KMMainViewController {
|
|
|
|
|
|
func currentPDFSettings() -> NSDictionary {
|
|
|
var setup = NSMutableDictionary()
|
|
|
- setup[DISPLAYSPAGEBREAKS_KEY] = NSNumber(value: listView.displaysPageBreaks)
|
|
|
- setup[DISPLAYSASBOOK_KEY] = NSNumber(value: listView.displaysAsBook)
|
|
|
- setup[DISPLAYBOX_KEY] = NSNumber(value: listView.displayBox.rawValue)
|
|
|
- setup[SCALEFACTOR_KEY] = NSNumber(value: listView.scaleFactor)
|
|
|
- setup[AUTOSCALES_KEY] = NSNumber(value: listView.autoScales)
|
|
|
- setup[DISPLAYMODE_KEY] = NSNumber(value: listView.displayMode.rawValue)
|
|
|
+ setup[KMMainModel.Key.kDisplaysPageBreaks] = NSNumber(value: listView.displaysPageBreaks)
|
|
|
+ setup[KMMainModel.Key.kDisplaysAsBook] = NSNumber(value: listView.displaysAsBook)
|
|
|
+ setup[KMMainModel.Key.kDisplayBox] = NSNumber(value: listView.displayBox.rawValue)
|
|
|
+ setup[KMMainModel.Key.kScaleFactor] = NSNumber(value: listView.scaleFactor)
|
|
|
+ setup[KMMainModel.Key.kAutoScales] = NSNumber(value: listView.autoScales)
|
|
|
+ setup[KMMainModel.Key.kDisplayMode] = NSNumber(value: listView.displayMode.rawValue)
|
|
|
|
|
|
return setup
|
|
|
}
|
|
@@ -1118,7 +1118,7 @@ extension KMMainViewController {
|
|
|
// let parent = current.parent ?? CPDFOutline()
|
|
|
// let index = current.index + 1
|
|
|
// parent.insertChild(newOutline, at: index)
|
|
|
- if self.leftPanelOpen == false || self.leftSideViewController.type.methodType != .Outline {
|
|
|
+ if self.model.leftPanelOpen == false || self.leftSideViewController.type.methodType != .Outline {
|
|
|
self.leftSideViewController.refreshMethodType(methodType: .Outline)
|
|
|
}
|
|
|
// self.leftSideViewController.outlineViewController.addItemAction()
|
|
@@ -1249,7 +1249,7 @@ extension KMMainViewController {
|
|
|
switch sender.tag {
|
|
|
case 0:
|
|
|
self.toolbarController.ignoreCurrentAnnotationTypeChange = true
|
|
|
- self.rightMouseEventing = true
|
|
|
+ self.model.rightMouseEventing = true
|
|
|
if(self.toolbarController.toolbarType == .None) {
|
|
|
self.toolbarController.toolbarType = .Annatiton
|
|
|
}
|
|
@@ -1375,7 +1375,7 @@ extension KMMainViewController {
|
|
|
if self.isReadMode {
|
|
|
|
|
|
} else {
|
|
|
- if self.leftPanelOpen == false || self.leftSideViewController.type.methodType != .BookMark {
|
|
|
+ if self.model.leftPanelOpen == false || self.leftSideViewController.type.methodType != .BookMark {
|
|
|
self.leftSideViewController.refreshMethodType(methodType: .BookMark)
|
|
|
}
|
|
|
let bookMark = self.listView.document.bookmark(forPageIndex: UInt(self.listView.currentPageIndex))
|
|
@@ -1420,7 +1420,7 @@ extension KMMainViewController {
|
|
|
return
|
|
|
}
|
|
|
// 解除权限
|
|
|
- self?.isSaveKeyChain = false
|
|
|
+ self?.model.isSaveKeyChain = false
|
|
|
self?.listView.document.unlock(withPassword: password)
|
|
|
// 隐藏提示
|
|
|
self?.hiddenSecureLimitTip()
|
|
@@ -1455,7 +1455,7 @@ extension KMMainViewController {
|
|
|
self.view.window?.makeFirstResponder(nil)
|
|
|
}
|
|
|
|
|
|
- self._mainWindow = self.view.window
|
|
|
+ self.mainWindow = self.view.window
|
|
|
let fullScreenWindow = KMFullScreenWindow(screen: (self.mainWindow?.screen ?? NSScreen.main)!, bgColor: backgroundColor, level: NSWindow.Level.popUpMenu.rawValue, isMain: true)
|
|
|
fullScreenWindow.interactionParent = self.view.window
|
|
|
|
|
@@ -1925,21 +1925,15 @@ extension KMMainViewController {
|
|
|
// progress.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#ffffff").cgColor
|
|
|
// progress.progressField.textColor = NSColor.black
|
|
|
progress.message = NSLocalizedString("Converting...", comment: "")
|
|
|
- progressController = progress
|
|
|
- progressController?.message = message
|
|
|
+ self.progressC = progress
|
|
|
+ self.progressC?.message = message
|
|
|
if maxValue > 0 {
|
|
|
- progressController?.indeterminate = false
|
|
|
- progressController?.maxValue = Double(maxValue)
|
|
|
+ progressC?.indeterminate = false
|
|
|
+ progressC?.maxValue = Double(maxValue)
|
|
|
} else {
|
|
|
- progressController?.indeterminate = true
|
|
|
+ progressC?.indeterminate = true
|
|
|
}
|
|
|
- if maxValue > 0 {
|
|
|
- progressController?.indeterminate = false
|
|
|
- progressController?.maxValue = Double(maxValue)
|
|
|
- } else {
|
|
|
- progressController?.indeterminate = true
|
|
|
- }
|
|
|
- self.km_beginSheet(windowC: progressController!)
|
|
|
+ self.km_beginSheet(windowC: progressC!)
|
|
|
}
|
|
|
|
|
|
// 白边距
|
|
@@ -1954,8 +1948,8 @@ extension KMMainViewController {
|
|
|
beginProgressSheet(with: KMLocalizedString("Cropping Pages", "Message for progress sheet"), maxValue: min(18, self.listView.document.pageCount))
|
|
|
var rectArray: Array<NSRect> = []
|
|
|
for i in 0 ..< self.listView.document.pageCount {
|
|
|
- progressController?.increment(by: Double(i))
|
|
|
- progressController?.doubleValue = Double(i)
|
|
|
+ progressC?.increment(by: Double(i))
|
|
|
+ progressC?.doubleValue = Double(i)
|
|
|
let page = self.listView.document.page(at: i)
|
|
|
var rect = KMCropTools.getPageForegroundBox(page!)
|
|
|
let bounds: NSRect = (page?.bounds(for: .mediaBox))!
|
|
@@ -2004,8 +1998,8 @@ extension KMMainViewController {
|
|
|
beginProgressSheet(with: KMLocalizedString("Cropping Pages", "Message for progress sheet"), maxValue: min(18, self.listView.document.pageCount))
|
|
|
var rectArray: Array<NSRect> = []
|
|
|
for i in 0 ..< self.listView.document.pageCount {
|
|
|
- progressController?.increment(by: Double(i))
|
|
|
- progressController?.doubleValue = Double(i)
|
|
|
+ progressC?.increment(by: Double(i))
|
|
|
+ progressC?.doubleValue = Double(i)
|
|
|
let page = self.listView.document.page(at: i)
|
|
|
var rect = KMCropTools.getPageForegroundBox(page!)
|
|
|
let bounds: NSRect = (page?.bounds(for: .mediaBox))!
|
|
@@ -2058,12 +2052,12 @@ extension KMMainViewController {
|
|
|
if let page = self.listView.document.page(at: 0) {
|
|
|
rect[0] = KMCropTools.getPageForegroundBox(page)
|
|
|
}
|
|
|
- progressController?.increment(by: 1)
|
|
|
+ progressC?.increment(by: 1)
|
|
|
} else if (count < 19) {
|
|
|
for i in 0 ..< 19 {
|
|
|
if let page = self.listView.document.page(at: UInt(i)) {
|
|
|
rect[i % 2] = NSUnionRect(rect[i % 2], KMCropTools.getPageForegroundBox(page))
|
|
|
- progressController?.increment(by: Double(i))
|
|
|
+ progressC?.increment(by: Double(i))
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -2075,7 +2069,7 @@ extension KMMainViewController {
|
|
|
if let page = self.listView.document.page(at: UInt(k)) {
|
|
|
rect[k % 2] = NSUnionRect(rect[k % 2], KMCropTools.getPageForegroundBox(page))
|
|
|
cnt += 1
|
|
|
- progressController?.increment(by: Double(cnt))
|
|
|
+ progressC?.increment(by: Double(cnt))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2132,150 +2126,6 @@ extension KMMainViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private func cropCustomArea() {
|
|
|
- self.listView.toolMode = .selectToolMode
|
|
|
-
|
|
|
- self.listView.autoScales = true
|
|
|
- self.listView.autoScales = false
|
|
|
- var pageHeight: CGFloat = NSHeight(self.listView.currentPage().bounds(for: self.listView.displayBox))
|
|
|
- if (self.listView.displaysPageBreaks) {
|
|
|
- pageHeight += 8
|
|
|
- }
|
|
|
-
|
|
|
- var scaleFactor: CGFloat = fmax(self.listView.minimumScaleFactor, NSHeight(self.listView.frame)/pageHeight)
|
|
|
-// if (scaleFactor < self.preView.scaleFactor) {
|
|
|
- self.listView.scaleFactor = scaleFactor
|
|
|
-// }
|
|
|
-
|
|
|
- let tipView = KMCropTipView()
|
|
|
- tipView.setString(string: "请框选裁剪区域")
|
|
|
- tipView.frame = self.topTipBox.contentView!.frame
|
|
|
- tipView.autoresizingMask = NSView.AutoresizingMask(rawValue: 18)
|
|
|
- self.addTopTip(tipView)
|
|
|
-
|
|
|
- tipView.enterAction = {
|
|
|
- () in
|
|
|
- var rect = NSIntegralRect(self.listView.currentSelectionRect())
|
|
|
- if (NSIsEmptyRect(rect)) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- let window = KMCropSettingWindowController(windowNibName: "KMCropSettingWindowController")
|
|
|
- self.view.window?.beginSheet(window.window!)
|
|
|
- self.cropSettingWindowController = window
|
|
|
-
|
|
|
- window.itemClick = { [self]
|
|
|
- (index: Int) in
|
|
|
- if (index == 1) { /// 取消
|
|
|
- self.view.window?.endSheet((self.cropSettingWindowController?.window)!)
|
|
|
- self.cropSettingWindowController = nil
|
|
|
- return
|
|
|
- }
|
|
|
- let pageRangeType = self.cropSettingWindowController.pageRangeIndex
|
|
|
- let pageCount: Int = Int(self.listView.document.pageCount)
|
|
|
- var pages: Array<Int> = []
|
|
|
- if (pageRangeType == 0) { /// 当前页面
|
|
|
- pages.append(self.listView.currentPageIndex)
|
|
|
- } else if (pageRangeType == 1) { /// 全部页面
|
|
|
- for i in 0 ..< pageCount {
|
|
|
- pages.append(i)
|
|
|
- }
|
|
|
- } else if (pageRangeType == 2) { /// 奇数页面
|
|
|
- var string: String = ""
|
|
|
- for i in 0 ..< pageCount {
|
|
|
- if (i % 2 == 1) {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- pages.append(i)
|
|
|
- }
|
|
|
- } else if (pageRangeType == 3) { /// 偶数页面
|
|
|
- var string: String = ""
|
|
|
- for i in 0 ..< pageCount {
|
|
|
- if (i % 2 == 0) {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- pages.append(i)
|
|
|
- }
|
|
|
- } else { /// 自定义
|
|
|
- for i in self.cropSettingWindowController.pageRangePages {
|
|
|
- pages.append(i)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (pages.count < 0) {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.messageText = "请选择页面"
|
|
|
- alert.runModal()
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- var pageSize: NSSize = NSZeroSize
|
|
|
- if (self.cropSettingWindowController.pageSize == "None") {
|
|
|
-
|
|
|
- } else {
|
|
|
- pageSize = KMCropTools.getPageSizeValue(self.cropSettingWindowController.pageSize)
|
|
|
- }
|
|
|
-
|
|
|
- for i in pages {
|
|
|
- var page: CPDFPage = self.listView.document.page(at: UInt(i))
|
|
|
- var rect = NSIntegralRect(self.listView.selectionRect)
|
|
|
-
|
|
|
- if (NSIsEmptyRect(rect)) {
|
|
|
- rect = KMCropTools.getPageForegroundBox(page)
|
|
|
- }
|
|
|
-
|
|
|
- var newRect = NSIntersectionRect(rect, (page.bounds(for: .mediaBox)))
|
|
|
- page.setBounds(newRect, for: .cropBox)
|
|
|
-
|
|
|
- if (pageSize.width == 0 && pageSize.height == 0) {
|
|
|
-
|
|
|
- } else {
|
|
|
-// let tiffData = page.pdfListViewTIFFData(for: rect)
|
|
|
- let index: UInt = (page.pageIndex())
|
|
|
-// let newPage: CPDFPage = nil
|
|
|
-// self.listView.document.removePage(at: index)
|
|
|
-// newPage.setBounds(NSMakeRect(0, 0, pageSize.width, pageSize.height), for: .cropBox)
|
|
|
- // let result = self.preView.document.insertPageObject(newPage, at: index)
|
|
|
- let result = self.listView.document.insertPage(pageSize, at: index)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /// 保存到临时路径
|
|
|
- let toPath: String = self.listView.document.documentURL.path
|
|
|
- let documentPath = NSTemporaryDirectory()
|
|
|
- let tempPath: String = "\(documentPath)/\(toPath.lastPathComponent)"
|
|
|
- if (FileManager.default.fileExists(atPath: tempPath)) {
|
|
|
- try?FileManager.default.removeItem(atPath: tempPath)
|
|
|
- }
|
|
|
-
|
|
|
- let result = self.listView.document.write(to: URL(fileURLWithPath: tempPath))
|
|
|
- if (result) {
|
|
|
- if (FileManager.default.fileExists(atPath: toPath)) {
|
|
|
- try?FileManager.default.removeItem(atPath: toPath)
|
|
|
- }
|
|
|
-
|
|
|
- try?FileManager.default.moveItem(atPath: tempPath, toPath: toPath)
|
|
|
- } else {
|
|
|
- try?FileManager.default.removeItem(atPath: tempPath)
|
|
|
- }
|
|
|
- DispatchQueue.main.async {
|
|
|
- self.listView.toolMode = .textToolMode
|
|
|
-
|
|
|
- /// 刷新预览视图
|
|
|
- self.listView.layoutDocumentView()
|
|
|
-
|
|
|
- self.listView.displayBox = .cropBox
|
|
|
- }
|
|
|
-
|
|
|
- self.view.window?.endSheet((self.cropSettingWindowController?.window)!)
|
|
|
- self.cropSettingWindowController = nil
|
|
|
- self.addTopTip(nil)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
@objc private func shareDocument(sender:KMToolbarViewController, limit: Bool = false) {
|
|
|
if (limit) {
|
|
|
var doucumentURL : URL = self.listView.document.documentURL
|
|
@@ -2456,8 +2306,8 @@ extension KMMainViewController {
|
|
|
// 开启/关闭左边栏
|
|
|
@objc func toggleLeftPane() -> Void {
|
|
|
// if lastLeftPanWidth >= functionWidth {
|
|
|
- leftPanelOpen = true
|
|
|
- applyLeftSideWidth(panelWidth+functionWidth, rightSideWidth: lastRightPanWidth)
|
|
|
+ self.model.leftPanelOpen = true
|
|
|
+ applyLeftSideWidth(self.model.panelWidth+functionWidth, rightSideWidth: self.model.lastRightPanWidth)
|
|
|
// } else {
|
|
|
// leftPanelOpen = false
|
|
|
// applyLeftSideWidth(functionWidth, rightSideWidth: lastRightPanWidth)
|
|
@@ -2466,47 +2316,47 @@ extension KMMainViewController {
|
|
|
|
|
|
// 开启左边栏
|
|
|
@objc func openLeftPane() -> Void {
|
|
|
- leftPanelOpen = true
|
|
|
- applyLeftSideWidth(panelWidth+functionWidth, rightSideWidth: lastRightPanWidth)
|
|
|
+ self.model.leftPanelOpen = true
|
|
|
+ applyLeftSideWidth(self.model.panelWidth+functionWidth, rightSideWidth: self.model.lastRightPanWidth)
|
|
|
|
|
|
self.toolbarController.findItem(KMLeftControlToolbarItemIdentifier)?.isSelected = true
|
|
|
}
|
|
|
|
|
|
// 关闭左边栏
|
|
|
@objc func closeLeftPane() -> Void {
|
|
|
- leftPanelOpen = false
|
|
|
- applyLeftSideWidth(functionWidth, rightSideWidth: lastRightPanWidth)
|
|
|
+ self.model.leftPanelOpen = false
|
|
|
+ applyLeftSideWidth(functionWidth, rightSideWidth: self.model.lastRightPanWidth)
|
|
|
|
|
|
self.toolbarController.findItem(KMLeftControlToolbarItemIdentifier)?.isSelected = false
|
|
|
}
|
|
|
|
|
|
// 开启/关闭右边栏
|
|
|
@objc func toggleRightPane() -> Void {
|
|
|
- if lastRightPanWidth > 5 {
|
|
|
- self.rightPanelIsOpen = false
|
|
|
- applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: 0)
|
|
|
+ if self.model.lastRightPanWidth > 5 {
|
|
|
+ self.model.rightPanelIsOpen = false
|
|
|
+ applyLeftSideWidth(self.model.lastLeftPanWidth, rightSideWidth: 0)
|
|
|
} else {
|
|
|
- self.rightPanelIsOpen = true
|
|
|
- applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: defaultRightWidth)
|
|
|
+ self.model.rightPanelIsOpen = true
|
|
|
+ applyLeftSideWidth(self.model.lastLeftPanWidth, rightSideWidth: self.model.defaultRightWidth)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@objc func openRightPane() -> Void {
|
|
|
if (KMPreferenceManager.shared.autoExpandPropertyPanel) {
|
|
|
- if self.rightPanelIsOpen {
|
|
|
+ if self.model.rightPanelIsOpen {
|
|
|
return
|
|
|
}
|
|
|
- self.rightPanelIsOpen = true
|
|
|
+ self.model.rightPanelIsOpen = true
|
|
|
self.toolbarController.selectItem(KMRightControlToolbarItemIdentifier)
|
|
|
- applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: defaultRightWidth)
|
|
|
+ applyLeftSideWidth(self.model.lastLeftPanWidth, rightSideWidth: self.model.defaultRightWidth)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@objc func closeRightPane() -> Void {
|
|
|
if (KMPreferenceManager.shared.autoExpandPropertyPanel) {
|
|
|
- self.rightPanelIsOpen = false
|
|
|
+ self.model.rightPanelIsOpen = false
|
|
|
self.toolbarController.cancelSelected(KMRightControlToolbarItemIdentifier)
|
|
|
- applyLeftSideWidth(lastLeftPanWidth, rightSideWidth: 0)
|
|
|
+ applyLeftSideWidth(self.model.lastLeftPanWidth, rightSideWidth: 0)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2552,7 +2402,7 @@ extension KMMainViewController {
|
|
|
tabController?.title = outputSavePanel.url!.lastPathComponent
|
|
|
|
|
|
if let newPdfDocument = CPDFDocument(url: newFileURL) {
|
|
|
- self.isSaveKeyChain = false
|
|
|
+ self.model.isSaveKeyChain = false
|
|
|
newPdfDocument.unlock(withPassword: self.document?.password)
|
|
|
if (newPdfDocument.pageCount > 0) {
|
|
|
self.setDocument = newPdfDocument
|
|
@@ -3115,21 +2965,21 @@ extension KMMainViewController {
|
|
|
progress.window?.contentView?.layer?.backgroundColor = NSColor.km_init(hex: "#36383B").cgColor
|
|
|
progress.progressField.textColor = NSColor.white
|
|
|
progress.message = NSLocalizedString("Converting...", comment: "")
|
|
|
- progressController = progress
|
|
|
- progressController?.message = message
|
|
|
+ progressC = progress
|
|
|
+ progressC?.message = message
|
|
|
if maxValue > 0 {
|
|
|
- progressController?.indeterminate = false
|
|
|
- progressController?.maxValue = Double(maxValue)
|
|
|
+ progressC?.indeterminate = false
|
|
|
+ progressC?.maxValue = Double(maxValue)
|
|
|
} else {
|
|
|
- progressController?.indeterminate = true
|
|
|
+ progressC?.indeterminate = true
|
|
|
}
|
|
|
- self.km_beginSheet(windowC: progressController!)
|
|
|
+ self.km_beginSheet(windowC: progressC!)
|
|
|
}
|
|
|
|
|
|
func dismissProgressSheet() {
|
|
|
- progressController?.stopAnimation()
|
|
|
+ progressC?.stopAnimation()
|
|
|
self.km_endSheet()
|
|
|
- progressController = nil
|
|
|
+ progressC = nil
|
|
|
}
|
|
|
|
|
|
func converFilesToPath(files: Array<KMBatchOperateFile>) -> [String] {
|
|
@@ -3699,7 +3549,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
|
|
|
private func _aiTranslationPDFFileAction() {
|
|
|
let isExceedsLimit = self.isPDFPageCountExceedsLimit(filePath: (self.document?.documentURL.path)!)
|
|
|
- if self.isFileGreaterThan10MB(atPath: (self.document?.documentURL.path)!) {
|
|
|
+ if KMTools.isFileGreaterThan10MB(atPath: (self.document?.documentURL.path)!) {
|
|
|
let alert = NSAlert()
|
|
|
alert.alertStyle = .critical
|
|
|
alert.messageText = NSLocalizedString("The uploaded file size cannot exceed 10MB", comment: "")
|
|
@@ -3992,7 +3842,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
guard let _url = KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
|
|
|
return
|
|
|
}
|
|
|
- self.showMergeWindow(url: _url, password)
|
|
|
+ self.showMergeWindow(url: _url, self.model.password)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -4162,7 +4012,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
}
|
|
|
|
|
|
if (index == 1) { /// 取消
|
|
|
- if (self.hasAddRedact) {
|
|
|
+ if (self.model.hasAddRedact) {
|
|
|
let alert = NSAlert()
|
|
|
alert.messageText = NSLocalizedString("You can save a document with unapplied cipher text and edit it again. If you do not save, all changes will be lost.", comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("Don’t Save", comment: ""))
|
|
@@ -4333,7 +4183,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
|
|
|
|
/// 删除安全性设置
|
|
|
if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
|
|
|
- self.isSaveKeyChain = false
|
|
|
+ self.model.isSaveKeyChain = false
|
|
|
self.listView.document.unlock(withPassword: resultPassword)
|
|
|
}
|
|
|
|
|
@@ -5112,7 +4962,7 @@ extension KMMainViewController: KMPageNumberDisplayViewDelegate {
|
|
|
|
|
|
func commitEditingIfNeed() {
|
|
|
let isEdited = self.listView?.isEdited() ?? false
|
|
|
- if isEdited || self.isPDFTextImageEdited {
|
|
|
+ if isEdited || self.model.isPDFTextImageEdited {
|
|
|
self.listView.commitEditing()
|
|
|
}
|
|
|
}
|