Kaynağa Gözat

Merge branch 'develop_PDFReaderProNew' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderProNew

niehaoyu 1 yıl önce
ebeveyn
işleme
5c10c72e84

+ 32 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -2340,6 +2340,12 @@
 		ADF9ED3329A850D200C4A943 /* KMAccountInfoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADF9ED3229A850D200C4A943 /* KMAccountInfoView.xib */; };
 		ADF9ED3429A850D200C4A943 /* KMAccountInfoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADF9ED3229A850D200C4A943 /* KMAccountInfoView.xib */; };
 		ADF9ED3529A850D200C4A943 /* KMAccountInfoView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ADF9ED3229A850D200C4A943 /* KMAccountInfoView.xib */; };
+		ADFCEB322B4F78150001EBAF /* KMFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB312B4F78150001EBAF /* KMFileManager.swift */; };
+		ADFCEB332B4F78150001EBAF /* KMFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB312B4F78150001EBAF /* KMFileManager.swift */; };
+		ADFCEB342B4F78150001EBAF /* KMFileManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB312B4F78150001EBAF /* KMFileManager.swift */; };
+		ADFCEB362B4F78220001EBAF /* KMFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB352B4F78220001EBAF /* KMFile.swift */; };
+		ADFCEB372B4F78220001EBAF /* KMFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB352B4F78220001EBAF /* KMFile.swift */; };
+		ADFCEB382B4F78220001EBAF /* KMFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADFCEB352B4F78220001EBAF /* KMFile.swift */; };
 		BB00300F298CA383002DD1A0 /* KMPreferenceSegementControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB00300E298CA383002DD1A0 /* KMPreferenceSegementControl.swift */; };
 		BB003010298CA383002DD1A0 /* KMPreferenceSegementControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB00300E298CA383002DD1A0 /* KMPreferenceSegementControl.swift */; };
 		BB003011298CA383002DD1A0 /* KMPreferenceSegementControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB00300E298CA383002DD1A0 /* KMPreferenceSegementControl.swift */; };
@@ -5481,6 +5487,8 @@
 		ADF6B87D2A485A8F0090CB78 /* KMComparativeViewCollectionItemItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMComparativeViewCollectionItemItem.xib; sourceTree = "<group>"; };
 		ADF9ED2E29A8507400C4A943 /* KMAccountInfoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KMAccountInfoView.swift; sourceTree = "<group>"; };
 		ADF9ED3229A850D200C4A943 /* KMAccountInfoView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMAccountInfoView.xib; sourceTree = "<group>"; };
+		ADFCEB312B4F78150001EBAF /* KMFileManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMFileManager.swift; sourceTree = "<group>"; };
+		ADFCEB352B4F78220001EBAF /* KMFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMFile.swift; sourceTree = "<group>"; };
 		BB00300E298CA383002DD1A0 /* KMPreferenceSegementControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPreferenceSegementControl.swift; sourceTree = "<group>"; };
 		BB003013298CA446002DD1A0 /* KMPreferenceGeneralController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPreferenceGeneralController.swift; sourceTree = "<group>"; };
 		BB003014298CA446002DD1A0 /* KMPreferenceGeneralController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMPreferenceGeneralController.xib; sourceTree = "<group>"; };
@@ -9238,6 +9246,23 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		ADFCEB2F2B4F77CC0001EBAF /* KMFileManager */ = {
+			isa = PBXGroup;
+			children = (
+				ADFCEB302B4F77E30001EBAF /* KMFile */,
+				ADFCEB312B4F78150001EBAF /* KMFileManager.swift */,
+			);
+			path = KMFileManager;
+			sourceTree = "<group>";
+		};
+		ADFCEB302B4F77E30001EBAF /* KMFile */ = {
+			isa = PBXGroup;
+			children = (
+				ADFCEB352B4F78220001EBAF /* KMFile.swift */,
+			);
+			path = KMFile;
+			sourceTree = "<group>";
+		};
 		BB00300D298CA367002DD1A0 /* View */ = {
 			isa = PBXGroup;
 			children = (
@@ -9741,6 +9766,7 @@
 		BB2C6A7128F2652500478A33 /* Class */ = {
 			isa = PBXGroup;
 			children = (
+				ADFCEB2F2B4F77CC0001EBAF /* KMFileManager */,
 				BB42C7EB2B46421B003FF2D4 /* README.md */,
 				BBFEF7112B3A766C00C28AC0 /* SystemMenu */,
 				ADDF82E02B391A5C00A81A4E /* DigtalSignature */,
@@ -13533,6 +13559,7 @@
 				BB897236294B38DC0045787C /* KMWatermarkAdjectivePropertyBaseController.swift in Sources */,
 				AD85D19E2AEF927D000F4D28 /* KMQucikToolsModel.swift in Sources */,
 				BB10FAF62AFE2C2900F18D65 /* KMNumberArrayFormatter.swift in Sources */,
+				ADFCEB362B4F78220001EBAF /* KMFile.swift in Sources */,
 				9F1F82D2292F6D510092C4B4 /* KMPDFInsertPreviewViewController.swift in Sources */,
 				AD02573F2A8601CD00EAD5D5 /* KMAppleLoginManager.swift in Sources */,
 				BB96A0B02AFCD56100559E24 /* KMToolCompareWindowController.swift in Sources */,
@@ -14281,6 +14308,7 @@
 				BBB1A3A629F6B66400E54E47 /* NSPanel+KMExtension.swift in Sources */,
 				BB3A81AC2AC2A4E4006FC66C /* NSTextView+KMExtension.swift in Sources */,
 				BB65A0802AF8FE7A003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.swift in Sources */,
+				ADFCEB322B4F78150001EBAF /* KMFileManager.swift in Sources */,
 				ADE86AD62B05A52B00414DFA /* KMCompareFilesConfig.swift in Sources */,
 				BB147047299DC0D200784A6A /* OIDServiceConfiguration.m in Sources */,
 				BB89726D294DB67D0045787C /* KMWatermarkAdjectiveBaseView.swift in Sources */,
@@ -14617,6 +14645,7 @@
 				ADF9ED3029A8507400C4A943 /* KMAccountInfoView.swift in Sources */,
 				BB60138D2AD3A94200A76FB2 /* CPDFSignatureAnnotation+PDFListView.swift in Sources */,
 				BB03D6952B021124008C9976 /* NSSegmentedControl+KMExtension.swift in Sources */,
+				ADFCEB332B4F78150001EBAF /* KMFileManager.swift in Sources */,
 				ADAFDA832AEB804B00F084BC /* KMQucikToolCollectionViewItem.swift in Sources */,
 				89D2D2DF294C451400BFF5FE /* KMThumbnailViewController.swift in Sources */,
 				AD3AAD6E2B0DCC6800DE5FE7 /* KMCompareSaveWindow.swift in Sources */,
@@ -15388,6 +15417,7 @@
 				9F0CB49029683DEE00007028 /* KMPropertiesPanelLineSubVC.swift in Sources */,
 				AD53B6FF29AC5FCD00D61E81 /* KMLightMemberToken.swift in Sources */,
 				9FB220F22B1863C800A5B208 /* KMAnnotationFromSignature.swift in Sources */,
+				ADFCEB372B4F78220001EBAF /* KMFile.swift in Sources */,
 				BB0542162965705D00F2665C /* KMCropTipView.swift in Sources */,
 				BBC348542958465C008D2CD1 /* KMBackgroundFilePropertyInfoController.swift in Sources */,
 				AD02573B2A8601AA00EAD5D5 /* KMLoginManager.swift in Sources */,
@@ -15841,6 +15871,7 @@
 				BBEC00DB295C39FD00A26C98 /* KMBatesPropertyInfoController.swift in Sources */,
 				BB3A66922B07099F00575343 /* KMFindTableviewCell.swift in Sources */,
 				BB0A551A2A3074F400B6E84B /* KMHoverView.swift in Sources */,
+				ADFCEB342B4F78150001EBAF /* KMFileManager.swift in Sources */,
 				BB4F7E7B2B0C45BB0077EC8C /* KMNoteOutlineFilterViewController.swift in Sources */,
 				9F1FE4AA29406E4700E952CA /* CTBrowserWindowController.m in Sources */,
 				ADAFDA6A2AEB46F500F084BC /* KMHomeHistoryListView.swift in Sources */,
@@ -16014,6 +16045,7 @@
 				BBD1F791296FE6A500343885 /* KMPageEditSplitWindowController.swift in Sources */,
 				BB8810A22B4F7D1000AFA63E /* KMVerificationActivateViewController.m in Sources */,
 				BBE78F212B3875B50071AC1A /* KMLeftSideViewController+Search.swift in Sources */,
+				ADFCEB382B4F78220001EBAF /* KMFile.swift in Sources */,
 				ADD1B6EA2946C02600C3FFF7 /* KMPrintChoosePageSizeMultipageView.swift in Sources */,
 				BBF2455F2AE78FF900037D08 /* KMBatchWindow.swift in Sources */,
 				BBE9D0A12AF0D10F002E83CE /* KMSlider.swift in Sources */,

+ 4 - 4
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift

@@ -148,7 +148,7 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
     }
     func updateLanguageButton(_ languages: [String]?) {
         if languages?.count ?? 0 < 1 {
-            self.languageButton.title = KMLocalizedString("Auto Detection", nil)
+            self.languageButton.title = " " + KMLocalizedString("Auto Detection", nil)
             return
         }
         var languageName: String = ""
@@ -165,7 +165,7 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
             languageName = ""
         }
         
-        self.languageButton.title = languageName
+        self.languageButton.title = " " + languageName
     }
     func converArrType(arr: Array<KMBatchOperateFile>, keyString: String) -> [String] {
         let newArr = NSMutableArray()
@@ -325,9 +325,9 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
     func OCRSelectedPlanChangeAction() {
         let plan = UserDefaults.standard.integer(forKey: "KMOCRCurrentPlanKey")
         if plan == 0 {
-            self.planButton.title = KMLocalizedString("Plan 1 (Online)", nil)
+            self.planButton.title = " " + KMLocalizedString("Plan 1 (Online)", nil)
         } else {
-            self.planButton.title = KMLocalizedString("Plan 2 (Offline)", nil)
+            self.planButton.title = " " + KMLocalizedString("Plan 2 (Offline)", nil)
         }
         KMGOCRManager.default().selectedLanguages = NSMutableArray()
         self.updateLanguageButton(KMGOCRManager.default().selectedLanguages?.value(forKeyPath: KMGOCRLanguageStringKey) as? [String])

+ 10 - 11
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/Cell/KMHomeHistoryCollectionItem.swift

@@ -8,10 +8,10 @@
 import Cocoa
 
 
-typealias KMHomeHistoryCollectionItemShowPathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
-typealias KMHomeHistoryCollectionItemRemovePathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryCollectionItemShowPathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMFile) -> Void
+typealias KMHomeHistoryCollectionItemRemovePathAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMFile) -> Void
 //typealias KMHomeHistoryCollectionItemMouseMoveAction = (_ view: KMHomeHistoryCollectionItem, _ enter: Bool) -> Void
-typealias KMHomeHistoryCollectionItemMouseDobleClickAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryCollectionItemMouseDobleClickAction = (_ view: KMHomeHistoryCollectionItem, _ item: KMFile) -> Void
 
 class KMHomeHistoryCollectionItem: NSCollectionViewItem {
 
@@ -32,7 +32,7 @@ class KMHomeHistoryCollectionItem: NSCollectionViewItem {
     @IBOutlet weak var verticalTitleLabel: NSTextField!
     @IBOutlet weak var showImageView: NSImageView!
     
-    var model: KMHomeHistoryListViewModel? {
+    var model: KMFile? {
         didSet {
             self.reloadData()
         }
@@ -154,20 +154,19 @@ extension KMHomeHistoryCollectionItem {
     func updateFilesData() -> Void {
         guard let model = model else { return }
         
-        horizontalTitleLabel.stringValue = model.fileName
-        verticalTitleLabel.stringValue = model.fileName
+        horizontalTitleLabel.stringValue = model.info.fileName
+        verticalTitleLabel.stringValue = model.info.fileName
         pathLabel.stringValue = model.showPath
             
         let paragraphStyle = NSMutableParagraphStyle()
         paragraphStyle.lineSpacing = 22.0
-        sizeLabel.attributedStringValue = NSAttributedString(string: model.fileSize, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
-        timeLabel.attributedStringValue = NSAttributedString(string: model.modificationTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        sizeLabel.attributedStringValue = NSAttributedString(string: model.info.sizeString, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+        timeLabel.attributedStringValue = NSAttributedString(string: model.info.modificationTime, attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
 
         
-        showImageView.image = model.iconImage
+        showImageView.image = model.image
         
-        self.view.toolTip = model.fileName
-
+        self.view.toolTip = model.info.fileName
     }
 }
                      

+ 7 - 5
PDF Office/PDF Master/Class/Home/View/HomeContentView/History/KMHomeHistoryListView.swift

@@ -13,9 +13,9 @@ enum KMHomeHistoryListViewShowType: Int {
     case vertical //纵
 }
 
-typealias KMHomeHistoryListViewItemDidSelect = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
-typealias KMHomeHistoryListViewItemShowPathAction = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
-typealias KMHomeHistoryListViewItemRemovePathAction = (_ view: KMHomeHistoryListView, _ item: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeHistoryListViewItemDidSelect = (_ view: KMHomeHistoryListView, _ item: KMFile) -> Void
+typealias KMHomeHistoryListViewItemShowPathAction = (_ view: KMHomeHistoryListView, _ item: KMFile) -> Void
+typealias KMHomeHistoryListViewItemRemovePathAction = (_ view: KMHomeHistoryListView, _ item: KMFile) -> Void
 
 class KMHomeHistoryListView: KMBaseXibView {
     @IBOutlet weak var collectionView: NSCollectionView!
@@ -25,7 +25,7 @@ class KMHomeHistoryListView: KMBaseXibView {
     var showPathAction: KMHomeHistoryListViewItemShowPathAction?
     var removeFileAction: KMHomeHistoryListViewItemRemovePathAction?
     
-    var data:[KMHomeHistoryListViewModel] = []
+    var data:[KMFile] = []
     var showType:KMHomeHistoryListViewShowType = .horizontal {
         didSet {
             self.collectionView.reloadData()
@@ -60,7 +60,9 @@ class KMHomeHistoryListView: KMBaseXibView {
         self.data.removeAll()
         for url in NSDocumentController.shared.recentDocumentURLs {
             if FileManager.default.fileExists(atPath: url.path) {
-                self.data.append(KMHomeHistoryListViewModel.init(filePath: url))
+                let file = KMFile()
+                file.filePath = url.path
+                self.data.append(file)
             }
         }
 

+ 3 - 3
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.swift

@@ -7,9 +7,9 @@
 
 import Cocoa
 
-typealias KMHomeContentViewHistoryDidSelect = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
-typealias KMHomeContentViewHistoryShowPathAction = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
-typealias KMHomeContentViewHistoryrRemoveFileAction = (_ view: KMHomeContentView, _ url: KMHomeHistoryListViewModel) -> Void
+typealias KMHomeContentViewHistoryDidSelect = (_ view: KMHomeContentView, _ url: KMFile) -> Void
+typealias KMHomeContentViewHistoryShowPathAction = (_ view: KMHomeContentView, _ url: KMFile) -> Void
+typealias KMHomeContentViewHistoryrRemoveFileAction = (_ view: KMHomeContentView, _ url: KMFile) -> Void
 typealias KMHomeContentViewHistoryrRemoveAllFileAction = (_ view: KMHomeContentView) -> Void
 
 typealias KMHomeContentViewQucikToolsDidSelect = (_ view: KMHomeContentView, _ item: KMQucikToolsModel) -> Void

+ 7 - 8
PDF Office/PDF Master/Class/Home/View/KMComboBox.swift

@@ -22,7 +22,7 @@ class KMComboBox: NSComboBox {
         switch type {
         case .none:
             var p = comboxRect.origin
-            p.x += comboxRect.width - 20
+            p.x += comboxRect.width - 23
             p.y += (comboxRect.height - 16) / 2
 
             NSColor.clear.setFill()
@@ -50,8 +50,8 @@ class KMComboBox: NSComboBox {
                 self.wantsLayer = true
                 self.layer?.cornerRadius = 1.0
                 self.layer?.borderWidth = 0.5
-                self.layer?.borderColor = .black
-                self.backgroundColor = .white
+                self.layer?.borderColor = KMAppearance.Interactive.s0Color().cgColor
+                self.backgroundColor = KMAppearance.Layout.w0Color()
                 self.isButtonBordered = false
             default:
                 break
@@ -63,8 +63,7 @@ class KMComboBox: NSComboBox {
 class KMComboBoxCell: NSComboBoxCell {
     private func adjustedFrameToVerticallyCenterText(_ frame: NSRect) -> NSRect {
         let offset = floor((frame.size.height / 2 - (font!.ascender + font!.descender)))
-        let rect = NSRect(x: 8, y: 0, width: frame.size.width, height: frame.size.height)
-        return NSInsetRect(rect, 0.0, offset)
+        return NSInsetRect(frame, 0.0, offset)
     }
     
     override func edit(withFrame aRect: NSRect, in controlView: NSView, editor textObj: NSText, delegate anObject: Any?, event: NSEvent?) {
@@ -82,12 +81,12 @@ class KMComboBoxCell: NSComboBoxCell {
 
 class KMStampComboBoxCell: NSComboBoxCell {
     override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {
-        self.backgroundColor = NSColor.white
+        backgroundColor = KMAppearance.Layout.l1Color()
         super.drawInterior(withFrame: adjustedFrameToVerticallyCenterText(cellFrame), in: controlView)
     }
     
     func adjustedFrameToVerticallyCenterText(_ frame: NSRect) -> NSRect {
-        let offset = floor((NSHeight(frame) / 2 - (font!.ascender + font!.descender)))
-        return frame.insetBy(dx: 0.0, dy: offset)
+        let offset = floor((frame.height / 2 - (font?.ascender ?? 0.0 + font!.descender)))
+        return NSInsetRect(frame, 0.0, offset)
     }
 }

+ 3 - 3
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController.swift

@@ -189,15 +189,15 @@ import Cocoa
         
         //history
         self.homeContentView.historyDidSelect = { [unowned self] view, item in
-            self.openHistoryFilePath(url: item.filePath!)
+            self.openHistoryFilePath(url: item.url!)
         }
         
         self.homeContentView.historyRemoveFileAction = { [unowned self] view, item in
-            self.historyFile(deleteDocuments: [item.filePath!])
+            self.historyFile(deleteDocuments: [ item.url!])
         }
         
         self.homeContentView.historyShowPathAction = { [unowned self] view, item in
-            NSWorkspace.shared.open(item.filePath!.deletingLastPathComponent())
+            NSWorkspace.shared.open( item.url!.deletingLastPathComponent())
         }
         
         self.homeContentView.historyRemoveAllFileAction = { [unowned self] view in

+ 144 - 0
PDF Office/PDF Master/Class/KMFileManager/KMFile/KMFile.swift

@@ -0,0 +1,144 @@
+//
+//  KMFile.swift
+//  PDF Master
+//
+//  Created by lizhe on 2024/1/11.
+//
+
+import Cocoa
+
+class KMFile: NSObject {
+    var filePath: String = "" {
+        didSet {
+            self.url = NSURL(fileURLWithPath: filePath) as URL
+            reloadData()
+        }
+    }
+    
+    var url: URL?
+    
+    var showPath: String = ""
+    var pdfDocument: CPDFDocument?
+    var systemPDFDocument: PDFDocument?
+    var password: String = ""
+    var isLocked: Bool = false
+    var info: KMFileInfo = KMFileInfo()
+    var attributes: [FileAttributeKey : Any]?
+    var image: NSImage = NSImage()
+    
+    func reloadData() {
+        if filePath.count != 0 {
+            let attribe = try?FileManager.default.attributesOfItem(atPath: filePath)
+            if attribe != nil {
+                let document = CPDFDocument.init(url: URL(fileURLWithPath: filePath))
+                document?.unlock(withPassword: self.password)
+                
+                let dateFormatter: DateFormatter = DateFormatter.init()
+                let fileDate: Date = attribe![FileAttributeKey(rawValue: "NSFileModificationDate")] as! Date
+                var fileTime: String = ""
+                if fileDate.isToday() {
+                    dateFormatter.dateFormat = "HH:mm"
+                } else if self.isDateInCurrentWeek(fileDate) {
+                    dateFormatter.dateFormat = "EEE, HH:mm"
+                } else {
+                    dateFormatter.dateFormat = "MMM d, yyyy"
+                }
+                
+                let fileType = ""
+                let sizeFloat: Float = attribe![FileAttributeKey(rawValue: "NSFileSize")] as? Float ?? 0.0
+                let fileSize = fileSizeString(sizeFloat).isEmpty ? "" : fileSizeString(sizeFloat)
+                let lastTime = dateFormatter.string(from: fileDate)
+                if fileDate.isToday() {
+                    fileTime = String(format: "%@, %@", NSLocalizedString("Today", comment: ""), lastTime)
+                } else if isDateInCurrentWeek(fileDate) {
+                    fileTime = lastTime
+                } else {
+                    fileTime = lastTime
+                }
+                
+                //path
+                let array = filePath
+                    .deletingLastPathComponent
+                    .components(separatedBy: "/")
+                let string = NSMutableString()
+                
+                if array.count > 4 {
+                    string.append(".../")
+                    string.append(array[array.count - 3])
+                    string.append("/")
+                    string.append(array[array.count - 2])
+                    string.append("/")
+                    string.append(array[array.count - 1])
+                } else {
+                    string.setString(filePath.deletingLastPathComponent)
+                }
+                
+                var image: NSImage
+                if #available(macOS 13.0, *) {
+                    image = NSImage.previewForFile(path: URL(filePath: filePath), ofSize: CGSizeMake(136, 214), asIcon: true) ?? NSImage()
+                } else {
+                    let page = document?.page(at: 0) ?? CPDFPage()
+                    image = page.thumbnail(of: page.size) ?? NSImage()
+                }
+                
+                var info = KMFileInfo()
+                info.size = CGFloat(sizeFloat)
+                info.fileName = filePath.lastPathComponent
+                info.modificationTime = fileTime
+                
+                self.image = image
+                self.info = info
+                self.pdfDocument = document
+                self.isLocked = document!.isLocked
+                self.showPath = string.description
+            }
+        }
+    }
+    
+    
+}
+
+class KMFileInfo: NSObject {
+    var fileName: String = ""
+    var size: CGFloat = 0
+    var sizeString = ""
+    var modificationTime = ""
+}
+
+//MARK: 文件时间相关处理
+extension KMFile {
+    func fileSizeString(_ fSize: Float) -> String {
+        let fileSize = fSize / 1024
+        let size = fileSize >= 1024 ? (fileSize < 1048576 ? fileSize/1024 : fileSize/1048576.0) : fileSize
+        let unit = fileSize >= 1024 ? (fileSize < 1048576 ? "M" : "G") : "K"
+        return String(format: "%0.1f %@", size, unit)
+    }
+    
+    func isSameWeek (withDate date: Date) -> Bool {
+        let currentWeekOfYear = getWeekOfYear(date: Date.init())
+        let targetWeekOfYear = getWeekOfYear(date: date)
+        if targetWeekOfYear == currentWeekOfYear {
+            return false
+        } else {
+            return true
+        }
+    }
+    
+    func isDateInCurrentWeek(_ date: Date) -> Bool {
+        let calendar = Calendar.current
+        // 获取当前日期的星期几
+        let weekday = calendar.component(.weekday, from: Date())
+        // 获取一周的第一天(周日)的日期
+        let firstDayOfWeek = calendar.date(byAdding: .day, value: -weekday, to: Date())!
+        // 获取一周的最后一天(下周的第一天)的日期
+        let lastDayOfWeek = calendar.date(byAdding: .day, value: 7, to: firstDayOfWeek)!
+        // 判断日期是否在当前周的范围内
+        return date > firstDayOfWeek && date < lastDayOfWeek
+    }
+     
+    func getWeekOfYear(date: Date) -> Int {
+        let components = Calendar.current.dateComponents([Calendar.Component.weekOfYear], from: date)
+        return components.weekOfYear ?? 0
+    }
+}
+

+ 12 - 0
PDF Office/PDF Master/Class/KMFileManager/KMFileManager.swift

@@ -0,0 +1,12 @@
+//
+//  KMFileManager.swift
+//  PDF Master
+//
+//  Created by lizhe on 2024/1/11.
+//
+
+import Cocoa
+
+class KMFileManager: NSObject {
+
+}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 9 - 9
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/LeftSideView.xib


+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -226,12 +226,12 @@
             newAnnotation.annotationType == CAnnotationTypeSignCircle ||
             newAnnotation.annotationType == CAnnotationTypeSignLine ||
             newAnnotation.annotationType == CAnnotationTypeSignDot) {
-            KMFillSignShapePanel *vc = [[KMFillSignShapePanel alloc] init];
+            KMAnnotationSelfSignViewController *vc = [[KMAnnotationSelfSignViewController alloc] init];
             vc.pdfView = self.pdfView;
             vc.annotationModel = annotationModel;
             self.propertiesBox.contentView = vc.view;
             self.contentViewController = vc;
-            vc.callback = ^(CAnnotationType type) {
+            vc.callBack = ^(CAnnotationType type) {
                 if (type == CAnnotationTypeSignFalse) {
                     self.titleLabel.stringValue = NSLocalizedString(@"Fork", nil);
                 } else if (type == CAnnotationTypeSignTure) {
@@ -456,12 +456,12 @@
         if(_annotations.count > 1) {
             annotationModel = [[CPDFAnnotationModel alloc] initWithPDFAnnotations:_annotations];
         }
-        KMFillSignShapePanel *vc = [[KMFillSignShapePanel alloc] init];
+        KMAnnotationSelfSignViewController *vc = [[KMAnnotationSelfSignViewController alloc] init];
         vc.pdfView = self.pdfView;
         vc.annotationModel = annotationModel;
         self.propertiesBox.contentView = vc.view;
         self.contentViewController = vc;
-        vc.callback = ^(CAnnotationType type) {
+        vc.callBack = ^(CAnnotationType type) {
             if (type == CAnnotationTypeSignFalse) {
                 self.titleLabel.stringValue = NSLocalizedString(@"Fork", nil);
             } else if (type == CAnnotationTypeSignTure) {

+ 15 - 11
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/KMAnnotationSelfSignViewController.swift

@@ -9,13 +9,15 @@ import Cocoa
 
 typealias KMAnnotationSelfSignViewControllerCallBack = (CAnnotationType) -> Void
 
-class KMAnnotationSelfSignViewController: NSViewController {
+@objcMembers class KMAnnotationSelfSignViewController: NSViewController {
 
     var _annotations: [KMSelfSignAnnotation]?
     var selfSignType: CAnnotationType = .signText
     var pdfview: CPDFListView?
     var callBack: KMAnnotationSelfSignViewControllerCallBack?
-    
+    var pdfView: CPDFListView?
+    var annotationModel: CPDFAnnotationModel?
+
     @IBOutlet var colorLabel: NSTextField!
     @IBOutlet var imageBox: NSBox!
     @IBOutlet var imageBoxTop: NSLayoutConstraint!
@@ -105,14 +107,16 @@ class KMAnnotationSelfSignViewController: NSViewController {
             lineWidthView.isHidden = true
             lineWidthViewTopConstraint.constant = -6 - lineWidthView.bounds.size.height
         }
-
-        if annotations.count > 1 {
-            imageBoxTop.constant = -imageBox.bounds.size.height
-            imageBox.isHidden = true
-        } else {
-            imageBoxTop.constant = 10
-            imageBox.isHidden = false
-        }
+        
+//        if annotationModel?.annotations != nil {
+//            if (annotationModel?.annotations.count)! > 0 {
+//                imageBoxTop.constant = -imageBox.bounds.size.height
+//                imageBox.isHidden = true
+//            } else {
+//                imageBoxTop.constant = 10
+//                imageBox.isHidden = false
+//            }
+//        }
 
         // PickView Configuration
         colorPickView.annotationType = .selfSignColors
@@ -371,7 +375,7 @@ class KMAnnotationSelfSignViewController: NSViewController {
         imageView.image = drawImage(with: selfSignType)
     }
     
-    @IBAction func buttonClickedTypeSwitch(_ sender: NSButton) {
+    @IBAction func buttonClicked_TypeAwitch(_ sender: NSButton) {
         let tag = sender.tag
         
         for tAnnotation in annotations {

+ 5 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/KMAnnotationSelfSignViewController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMAnnotationSelfSignViewController">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMAnnotationSelfSignViewController" customModule="PDF_Master" customModuleProvider="target">
             <connections>
                 <outlet property="bottomView" destination="WyR-kR-Qty" id="wAo-5V-PWm"/>
                 <outlet property="circletypeButton" destination="ahQ-Ib-yZf" id="dcQ-jt-a4K"/>
@@ -26,7 +26,7 @@
                 <outlet property="opacityLabel" destination="enu-GO-p3q" id="y0U-Tl-INl"/>
                 <outlet property="opacitySlider" destination="U8k-K1-qQT" id="uby-2z-GnQ"/>
                 <outlet property="selfSignTypeLabel" destination="x0t-6o-bFa" id="cq9-jU-KVL"/>
-                <outlet property="tureTypeButton" destination="Vu3-og-LXM" id="BDX-qm-61k"/>
+                <outlet property="trueTypeButton" destination="Vu3-og-LXM" id="3UG-oW-Uuz"/>
                 <outlet property="view" destination="j0h-GU-ZZz" id="vbc-yH-dWN"/>
                 <outlet property="widthView" destination="4d3-Eg-lwC" id="e5B-Y6-3A6"/>
             </connections>
@@ -82,7 +82,7 @@
                                             <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                                         </textFieldCell>
                                     </textField>
-                                    <customView placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="26" translatesAutoresizingMaskIntoConstraints="NO" id="N4p-PV-4Fm" customClass="KMColorPickerView">
+                                    <customView placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="26" translatesAutoresizingMaskIntoConstraints="NO" id="N4p-PV-4Fm" customClass="KMColorPickerView" customModule="PDF_Master" customModuleProvider="target">
                                         <rect key="frame" x="0.0" y="0.0" width="341" height="32"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="32" id="KbU-gi-MOC"/>
@@ -122,7 +122,7 @@
                                             <action selector="lineWidthSliderAction:" target="-2" id="A5d-d7-f2f"/>
                                         </connections>
                                     </slider>
-                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aoL-Gs-1II" customClass="KMComboBox">
+                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="aoL-Gs-1II" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
                                         <rect key="frame" x="267" y="2" width="74" height="27"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="24" id="T2u-M7-u4V"/>
@@ -180,7 +180,7 @@
                                             <action selector="opacitySliderAction:" target="-2" id="fbd-rc-JlO"/>
                                         </connections>
                                     </slider>
-                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Sbs-rL-zfE" customClass="KMComboBox">
+                                    <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Sbs-rL-zfE" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
                                         <rect key="frame" x="267" y="2" width="74" height="27"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="24" id="leo-Fd-Od0"/>