Explorar o código

【fix】 【测量】开多页签操作测量时,会出现多个测量结果弹窗?不会自动将上一个关闭吗?

tangchao hai 6 meses
pai
achega
413c254781

+ 5 - 0
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -524,6 +524,11 @@ import Cocoa
         
         if let _userInfo = notification.userInfo, let _newContents = _userInfo[CTTabNewContentsUserInfoKey] as? KMMainDocument {
             _newContents.addWindowController(self)
+            
+            _newContents.mainViewController?.showMeasureFloatingWindowsIfNeed()
+        }
+        if let _userInfo = notification.userInfo, let _oldContents = _userInfo[CTTabContentsUserInfoKey] as? KMMainDocument {
+            _oldContents.mainViewController?.hideMeasureFloatingWindows()
         }
     }
     

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

@@ -122,7 +122,8 @@
     NSMutableParagraphStyle *ps = [[NSMutableParagraphStyle alloc] init];
     ps.lineSpacing = 10;
     ps.alignment = NSTextAlignmentCenter;
-    self.subTitleLabel.attributedStringValue = [[NSAttributedString alloc] initWithString:self.subTitleLabel.stringValue attributes:@{
+    NSString *subTitle = self.subTitleLabel.stringValue != nil ? self.subTitleLabel.stringValue : @"";
+    self.subTitleLabel.attributedStringValue = [[NSAttributedString alloc] initWithString:subTitle attributes:@{
         NSForegroundColorAttributeName : [NSColor colorWithRed:148/255.f green:152/255.f blue:156/255.f alpha:1.f],
         NSFontAttributeName : [NSFont fontWithName:@"SFProText-Regular" size:12],
         NSParagraphStyleAttributeName : ps}];

+ 23 - 2
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -623,6 +623,12 @@ import Cocoa
     }
     
     @objc func cancelMeasureType() {
+        self.hideMeasureFloatingWindows()
+        
+        self.toolbarController.findItem(KMToolbarMeasureItemIdentifier)?.isSelected = false
+    }
+    
+    func hideMeasureFloatingWindows() {
         if distanceMeasureInfoWindowController?.window?.isVisible == true {
             distanceMeasureInfoWindowController?.hideFloatingWindow()
         } else if perimeterMeasureInfoWindowController?.window?.isVisible == true {
@@ -630,8 +636,23 @@ import Cocoa
         } else if areaMeasureInfoWindowController?.window?.isVisible == true {
             areaMeasureInfoWindowController?.hideFloatingWindow()
         }
-        
-        self.toolbarController.findItem(KMToolbarMeasureItemIdentifier)?.isSelected = false
+    }
+    
+    func showMeasureFloatingWindowsIfNeed() {
+        let toolMode = self.listView?.toolMode ?? .none
+        if toolMode != .measureToolMode {
+            return
+        }
+        let type = self.listView?.annotationType ?? .none
+        if type == .line {
+            self.distanceMeasureInfoWindowController?.window?.orderFront(nil)
+        } else if type == .polyLine {
+            self.perimeterMeasureInfoWindowController?.window?.orderFront(nil)
+        } else if type == .polyGon {
+            self.areaMeasureInfoWindowController?.window?.orderFront(nil)
+        } else if type == .square {
+            self.areaMeasureInfoWindowController?.window?.orderFront(nil)
+        }
     }
     
     // MARK: Set Methods