Jelajahi Sumber

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

tangchao 10 bulan lalu
induk
melakukan
74faed44eb

+ 2 - 2
PDF Office/PDF Master/Class/ChromiumTabs/src/Tab Strip/CTTabStripModel.m

@@ -367,11 +367,11 @@ const int kNoTab = NSNotFound;
 														object:self 
 													  userInfo:userInfo];
 }
-
+//关闭所有标签页,除了第一个主标签
 - (void)closeAllTabs {
 	closingAll_ = YES;
 	NSMutableArray *closing_tabs = [NSMutableArray array];
-	for (int i = [self count] - 1; i >= 0; --i)
+	for (int i = [self count] - 1; i > 0; --i)
 		[closing_tabs addObject:[NSNumber numberWithInt:i]];
 	[self internalCloseTabs:closing_tabs closeTypes:CLOSE_CREATE_HISTORICAL_TAB];
 }

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

@@ -106,10 +106,14 @@ class KMHomeContentView: KMBaseXibView {
         }
         
         cleanButton.mouseMoveCallback = { [unowned self] enter in
-            if enter {
-                self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletHor")
-            } else {
+            if self.historyListView.data.count == 0 {
                 self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletNor")
+            } else {
+                if enter {
+                    self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletHor")
+                } else {
+                    self.cleanButton.image = NSImage(named: "KMImageNameHomeDeletNor")
+                }
             }
         }
         
@@ -173,6 +177,12 @@ class KMHomeContentView: KMBaseXibView {
     
     override func reloadData() {
         self.historyListView.reloadData()
+        
+        if self.historyListView.data.count == 0 {
+            self.cleanButton.isEnabled = false
+        } else {
+            self.cleanButton.isEnabled = true
+        }
     }
 }
 
@@ -246,7 +256,6 @@ extension KMHomeContentView {
     
     @IBAction func cleanButtonAction(_ sender: Any) {
         guard let callBack = historyRemoveAllFileAction else { return }
-        
         callBack(self)
     }
 }

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

@@ -354,7 +354,7 @@ extension KMHomeViewController {
                 }
             }
             
-            self.homeContentView.historyListView.reloadData()
+            self.homeContentView.reloadData()
         }
     }
     

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

@@ -448,7 +448,7 @@ import Cocoa
     
     func updateUI() {
         self.leftBox.fillColor = KMAppearance.Layout.l0Color()
-        self.homeSplitView.backgroundColor(KMAppearance.Layout.l0Color())
+//        self.homeSplitView.backgroundColor(KMAppearance.Layout.l0Color())
     }
     
     @objc func changeEffectiveAppearance() {

+ 8 - 14
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/KMMergeWindowController.swift

@@ -116,20 +116,14 @@ extension KMMergeWindowController {
                     array.append(fileURL)
                 }
                 
-//                var size = 0.0
-//                var files = self.mergeView.files
-//                for file in files {
-//                    size = size + file.fileSize
-//                }
-//                
-//                let file = KMFileAttribute()
-//                file.filePath = openPanel.urls.first!.path
-//                size = file.fileSize + size
-////                
-//                if !IAPProductsManager.default().isAvailableAllFunction() && (files.count >= 2 || size > 20 * 1024 * 1024) {
-//                    KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
-//                    return
-//                }
+                let attribe = try?FileManager.default.attributesOfItem(atPath: openPanel.urls.first!.path)
+                let fileSize = attribe?[FileAttributeKey.size] as? CGFloat ?? 0
+                size = fileSize + size
+
+                if !IAPProductsManager.default().isAvailableAllFunction() && (files.count >= 2 || size > 20 * 1024 * 1024) {
+                    KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+                    return
+                }
                 
                 self.mergeView.addFilePaths(urls: array)
             }

+ 2 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -4948,7 +4948,8 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
 }
 
 - (IBAction)menuItemClick_FitWidth:(id)sender {
-    self.autoScales = YES;
+//    self.autoScales = YES;
+    [self setAutoScales:[self autoScales] == NO];
     //    self.autoScales = NO;
 }
 

+ 40 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift

@@ -86,7 +86,11 @@ let KMColorPickerViewHeight: CGFloat = 64
     var subType: KMSelfSignAnnotationFreeTextSubType = .none
     var _activeAnnotationType: KMActiveAnnotationType = .highlight
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var annotationModel: CPDFAnnotationModel? {
+        didSet {
+            self.initAnnotationMode()
+        }
+    }
 //    var annotationCallback: ((CPDFAnnotation) -> Void)?
     
     @IBOutlet private weak var imageBox: NSBox!
@@ -595,6 +599,9 @@ let KMColorPickerViewHeight: CGFloat = 64
     // MARK: Set & Get
     
     var annotations: [CPDFAnnotation] {
+        set {
+            print(annotations)
+        }
         get {
             return annotationModel?.annotations as? [CPDFAnnotation] ?? []
         }
@@ -612,6 +619,34 @@ let KMColorPickerViewHeight: CGFloat = 64
         }
     }
     
+    func initAnnotationMode() {
+        if annotationModel?.annotationType == .freeText {
+            let sud = UserDefaults.standard
+            let bounds = NSMakeRect(0, 0, 50, 50)
+            let annotation = CPDFFreeTextAnnotation()
+//            defaults.safe_setColor(annotation.color, forKey: CFreeTextNoteColorKey)
+//            defaults.safe_setColor((annotation as! CPDFFreeTextAnnotation).fontColor, forKey: CFreeTextNoteFontColorKey)
+//            defaults.set((annotation as! CPDFFreeTextAnnotation).alignment.rawValue, forKey: CFreeTextNoteAlignmentKey)
+//            defaults.set((annotation as! CPDFFreeTextAnnotation).fontName(), forKey: CFreeTextNoteFontNameKey)
+//            defaults.set((annotation as! CPDFFreeTextAnnotation).fontSize(), forKey: CFreeTextNoteFontSizeKey)
+//            defaults.set(annotation.lineWidth(), forKey: CFreeTextNoteLineWidthKey)
+//            defaults.set(annotation.borderStyle().rawValue, forKey: CFreeTextNoteLineStyleKey)
+//            defaults.set(annotation.dashPattern(), forKey: CFreeTextNoteDashPatternKey)
+            annotation.bounds = bounds;
+            annotation.color = sud.color(forKey: CFreeTextNoteColorKey)
+            annotation.fontColor = sud.color(forKey: CFreeTextNoteFontColorKey)
+            annotation.alignment = NSTextAlignment(rawValue: sud.integer(forKey: CFreeTextNoteAlignmentKey))!
+            let font = sud.font(forNameKey: CFreeTextNoteFontNameKey, sizeKey: CFreeTextNoteFontSizeKey)
+            if (font != nil) {
+                annotation.font = font
+            }
+            annotation.setLineWidth(CGFloat(sud.float(forKey: CFreeTextNoteLineWidthKey)))
+            annotation.setDashPattern(sud.array(forKey: CFreeTextNoteDashPatternKey) ?? [])
+            annotation.setBorderStyle(CPDFBorderStyle(rawValue: sud.integer(forKey: CFreeTextNoteLineStyleKey))!)
+//            annotationModel?.annotations = [annotation]
+        }
+    }
+    
     func updateannotationMode() {
         let defaults = UserDefaults.standard
         if annotationType == .freeText {
@@ -879,13 +914,13 @@ let KMColorPickerViewHeight: CGFloat = 64
     }
     
     func openFreeTextStylesViewController() {
-        if annotations.count == 0 {
-            return
-        }
-        
         let vc = KMFreeTextStylesViewController()
         vc.annotations = annotations
+        vc.annotationModel = self.annotationModel
         vc.view.frame = CGRect(x: 0, y: 0, width: 280, height: CGRectGetHeight(self.view.window?.frame ?? CGRect.zero) - 300)
+        vc.didSelect = { [unowned self] data in
+            self.updateAnnotation()
+        }
         
         let createFilePopover = NSPopover()
         createFilePopover.contentViewController = vc

+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMFreeTextStylesViewController/KMFreeTextStylesViewController.h

@@ -6,9 +6,12 @@
 //
 
 #import <Cocoa/Cocoa.h>
+#import "CPDFAnnotationModel.h"
 
 @interface KMFreeTextStylesViewController : NSViewController
 
+@property (nonatomic, copy) void (^didSelect) (NSDictionary *data);
 @property (nonatomic, retain) NSArray *annotations;
+@property (nonatomic, retain) CPDFAnnotationModel *annotationModel;
 
 @end

+ 22 - 10
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/View/KMFreeTextStylesViewController/KMFreeTextStylesViewController.m

@@ -623,6 +623,17 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
     NSColor *fontColor = [self colorForData:dict[@"Font Color"]];
     NSString *fontAlignment = dict[@"Font Alignment"];
     
+    NSTextAlignment alignment = NSTextAlignmentLeft;
+    if ([fontAlignment isEqualToString:@"NSTextAlignmentLeft"]) {
+        alignment = NSTextAlignmentLeft;
+    } else if ([fontAlignment isEqualToString:@"NSTextAlignmentCenter"]) {
+        alignment = NSTextAlignmentCenter;
+    } else if ([fontAlignment isEqualToString:@"NSTextAlignmentRight"]) {
+        alignment = NSTextAlignmentRight;
+    } else if ([fontAlignment isEqualToString:@"NSTextAlignmentJustified"]) {
+        alignment = NSTextAlignmentJustified;
+    }
+    
     for (PDFAnnotation *tAnnotation in self.annotations) {
         NSFontDescriptor *attributeFontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:@{NSFontFamilyAttribute:fontName,NSFontFaceAttribute:fontWeight}];
         NSFont *font = [NSFont fontWithDescriptor:attributeFontDescriptor size:fontSize];
@@ -632,17 +643,18 @@ typedef NS_ENUM(NSUInteger, KMFreeTextMenuActionType) {
         if (fontColor) {
             tAnnotation.fontColor = fontColor;
         }
-        
-        if ([fontAlignment isEqualToString:@"NSTextAlignmentLeft"]) {
-            tAnnotation.alignment = NSTextAlignmentLeft;
-        } else if ([fontAlignment isEqualToString:@"NSTextAlignmentCenter"]) {
-            tAnnotation.alignment = NSTextAlignmentCenter;
-        } else if ([fontAlignment isEqualToString:@"NSTextAlignmentRight"]) {
-            tAnnotation.alignment = NSTextAlignmentRight;
-        } else if ([fontAlignment isEqualToString:@"NSTextAlignmentJustified"]) {
-            tAnnotation.alignment = NSTextAlignmentJustified;
-        }
+        tAnnotation.alignment = alignment;
     }
+    
+    if (self.annotationModel != nil) {
+        [self.annotationModel setFontName: fontName];
+        [self.annotationModel setFontSize:fontSize];
+        [self.annotationModel setFontColor:fontColor];
+        [self.annotationModel setAlignment:alignment];
+    }
+    
+    if (_didSelect != nil)
+        self.didSelect(dict);
 }
 
 - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row {

+ 2 - 1
PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings

@@ -1609,7 +1609,8 @@
 "Converter" = "转档工具";
 
 "Close Tab" = "关闭当前窗口";
-"Close Other Tabs" = "关闭所有窗口";
+"Close Other Tabs" = "关闭其他标签页";
+"Close All Tabs" = "关闭所有标签页";
 "Verify" = "确认密码";
 "Decrypt" = "解除密码";
 "Please upload the document to Kdan Cloud before sharing the file link." = "请在分享链接之前将文件上传到凯钿云。";

+ 1 - 0
PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

@@ -1579,6 +1579,7 @@
 
 "Close Tab" = "關閉當前視窗";
 "Close Other Tabs" = "關閉其他所有視窗";
+"Close All Tabs" = "關閉所有視窗";
 
 "Processing" = "處理中";
 "Processing..."="處理中...";