Bladeren bron

【综合】UserDefault 全局数据兼容

tangchao 1 jaar geleden
bovenliggende
commit
2e47e4aa4d

+ 16 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/Split/View/KMSecondaryPDFView.swift

@@ -53,7 +53,7 @@ class KMSecondaryPDFView: CPDFView {
                     self.currentSelection = CPDFSelection(document: self.document)
                 }
                 self.toolModeButton?.state = self.selectsText ? .on : .off
-//                [[NSUserDefaults standardUserDefaults] setBool:selectsText forKey:SKLastSecondarySelectsTextKey];
+                KMDataManager.ud_set(newValue, forKey: SKLastSecondarySelectsTextKey)
             }
         }
     }
@@ -104,7 +104,7 @@ class KMSecondaryPDFView: CPDFView {
         self.pagePopUpButton = nil
         self.synchronizedPDFView = nil
         self.synchronizeZoom = false
-//        self.selectsText = [[NSUserDefaults standardUserDefaults] boolForKey:SKLastSecondarySelectsTextKey];
+        self.selectsText = KMDataManager.ud_bool(forKey: SKLastSecondarySelectsTextKey)
         
         NotificationCenter.default.addObserver(self, selector: #selector(handlePageChangedNotification), name: NSNotification.Name.CPDFViewPageChanged, object: self)
 //        if ([PDFView instancesRespondToSelector:@selector(magnifyWithEvent:)] == NO || [PDFView instanceMethodForSelector:@selector(magnifyWithEvent:)] == [NSView instanceMethodForSelector:@selector(magnifyWithEvent:)])
@@ -469,6 +469,20 @@ class KMSecondaryPDFView: CPDFView {
         return menu
     }
     
+    override func magnify(with event: NSEvent) {
+        if KMDataManager.ud_bool(forKey: SKDisablePinchZoomKey) == false && event.responds(to: NSSelectorFromString("magnification")) {
+            if event.responds(to: NSSelectorFromString("phase")) && event.phase == .began {
+                self.startScale = self.scaleFactor
+            }
+            
+            let magnifyFactor = (1.0 + fmax(-0.5, fmin(1.0 , event.magnification)))
+            super.scaleFactor = magnifyFactor * self.scaleFactor
+            if event.responds(to: NSSelectorFromString("phase")) && event.phase == .ended || event.phase == .cancelled && (fabs(self.startScale-self.scaleFactor) > 0.001) {
+                self.setScaleFactor(fmax(self.scaleFactor, SKMinDefaultScaleMenuFactor), adjustPopup: true)
+            }
+        }
+    }
+    
     /*
 
      // we don't want to steal the printDocument: action from the responder chain

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

@@ -616,7 +616,7 @@ let KMColorPickerViewHeight: CGFloat = 64
             defaults.set((annotation as! CPDFSquareAnnotation).borderStyle().rawValue, forKey: CSquareNoteLineStyleKey)
             defaults.set((annotation as! CPDFSquareAnnotation).dashPattern(), forKey: CSquareNoteDashPatternKey)
         } else if annotationType == .highlight {
-            defaults.safe_setColor(annotation.color, forKey: KMHighlightNoteColorKey)
+            defaults.safe_setColor(annotation.color, forKey: CHighlightNoteColorKey)
         } else if annotationType == .underline {
             defaults.safe_setColor(annotation.color, forKey: CUnderlineNoteColorKey)
         } else if annotationType == .strikeOut {

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonWidgetAppearanceViewController.swift

@@ -276,9 +276,9 @@ import Cocoa
         let annotationMode = self.formMode
         
         if annotationMode == .radioButton {
-            defaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationRadioButtonWidgetBackgroundColorKey)
+            defaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationRadioButtonWidgetBackgroundColorKey)
         } else if annotationMode == .checkBox {
-            defaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationCheckBoxWidgetBackgroundColorKey)
+            defaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationCheckBoxWidgetBackgroundColorKey)
         }
     }
 
@@ -366,9 +366,9 @@ import Cocoa
         
         let userDefaults = UserDefaults.standard
         if formMode == .radioButton {
-            userDefaults.setColor(textColorPickerView.color!, forKey: SKAnnotationRadioButtonWidgetFontColorKey)
+            userDefaults.safe_setColor(textColorPickerView.color!, forKey: SKAnnotationRadioButtonWidgetFontColorKey)
         } else if formMode == .checkBox {
-            userDefaults.setColor(textColorPickerView.color!, forKey: SKAnnotationCheckBoxWidgetFontColorKey)
+            userDefaults.safe_setColor(textColorPickerView.color!, forKey: SKAnnotationCheckBoxWidgetFontColorKey)
         }
         self.annotationFreeText?.fontColor = self.textColorPickerView.color
         updateAnnotation()

+ 6 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift

@@ -212,18 +212,18 @@ private enum KMPDFAnnotationFontWeightType: Int {
         
         switch annotationMode {
         case .actionButton:
-            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationActionButtonWidgetBackgroundColorKey)
-            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationActionButtonWidgetFontColorKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationActionButtonWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationActionButtonWidgetFontColorKey)
             userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationActionButtonWidgetFontNameKey)
             userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationActionButtonWidgetFontSizeKey)
         case .comboBox:
-            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
-            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceWidgetFontColorKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceWidgetFontColorKey)
             userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceWidgetFontNameKey)
             userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceWidgetFontSizeKey)
         case .listMenu:
-            userDefaults.setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
-            userDefaults.setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceListWidgetFontColorKey)
+            userDefaults.safe_setColor(annotationModel.backgroundColor(), forKey: SKAnnotationChoiceListWidgetBackgroundColorKey)
+            userDefaults.safe_setColor(annotationModel.fontColor(), forKey: SKAnnotationChoiceListWidgetFontColorKey)
             userDefaults.set(annotationModel.fontName(), forKey: SKAnnotationChoiceListWidgetFontNameKey)
             userDefaults.set(annotationModel.fontSize(), forKey: SKAnnotationChoiceListWidgetFontSizeKey)
         default:

+ 16 - 64
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -609,54 +609,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "44337E05-94FF-4B8A-8AB7-5A77E6B1BE81"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/Common/Category/NSUserDefaults_KMExtension.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "53"
-            endingLineNumber = "53"
-            landmarkName = "setColor(_:forKey:)"
-            landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "44337E05-94FF-4B8A-8AB7-5A77E6B1BE81 - a4a36b403e095cbc"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "__C.NSUserDefaults.setColor(_: __C.NSColor, forKey: Swift.String) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/Common/Category/NSUserDefaults_KMExtension.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "53"
-                  endingLineNumber = "53"
-                  offsetFromSymbolStart = "121">
-               </Location>
-               <Location
-                  uuid = "44337E05-94FF-4B8A-8AB7-5A77E6B1BE81 - a4a36b403e095cbc"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "__C.NSUserDefaults.setColor(_: __C.NSColor, forKey: Swift.String) -&gt; ()"
-                  moduleName = "PDF Reader Pro"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/Common/Category/NSUserDefaults_KMExtension.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "53"
-                  endingLineNumber = "53"
-                  offsetFromSymbolStart = "181">
-               </Location>
-            </Locations>
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -673,22 +625,6 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
-      <BreakpointProxy
-         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
-         <BreakpointContent
-            uuid = "67804CA5-D2E4-4EAE-B7B7-6478E95C27B2"
-            shouldBeEnabled = "Yes"
-            ignoreCount = "0"
-            continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMGeneralAnnotationViewController.swift"
-            startingColumnNumber = "9223372036854775807"
-            endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "601"
-            endingLineNumber = "601"
-            landmarkName = "updateannotationMode()"
-            landmarkType = "7">
-         </BreakpointContent>
-      </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
@@ -769,5 +705,21 @@
             landmarkType = "24">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "5C7E437A-3DF1-4F0E-B6F2-F6A3F06AF64C"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "360"
+            endingLineNumber = "360"
+            landmarkName = "-setPageBackgroundColorWithColor:viewMode:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>