Browse Source

【2025】【综合】菜单栏逻辑完善

niehaoyu 3 weeks ago
parent
commit
da9a8c934c

+ 27 - 0
PDF Office/KMComponentLibrary/KMComponentLibrary/View/SideBar/SideBarItem/PageTurner/ComponentSidebarPageTurner.swift

@@ -151,6 +151,7 @@ public class ComponentSidebarPageTurner: ComponentBaseXibView {
     private func setupUI() {
         
         totalCountLabel.stringValue = String(format: "/%d", properties.totalCount)
+//        self.adjustFontSize(for: totalCountLabel)
         
         formatter.minSize = 1
         formatter.maxSize = properties.totalCount
@@ -224,6 +225,32 @@ public class ComponentSidebarPageTurner: ComponentBaseXibView {
         
     }
     
+    func adjustFontSize(for textField: NSTextField) {
+        guard let font = textField.font else { return }
+        let text = textField.stringValue
+        let maxWidth = textField.bounds.width
+        var fontSize = font.pointSize
+
+        // 计算文本宽度
+        let attributes: [NSAttributedString.Key: Any] = [.font: font]
+        var textWidth = (text as NSString).size(withAttributes: attributes).width
+
+        // 如果文本宽度超过控件宽度,缩小字体
+        while textWidth > maxWidth && fontSize > 1 {
+            fontSize -= 1
+            let newFont = NSFont(descriptor: font.fontDescriptor, size: fontSize) ?? font
+            textWidth = (text as NSString).size(withAttributes: [.font: newFont]).width + 4
+        }
+
+        // 设置新的字体大小
+        textField.font = NSFont(descriptor: font.fontDescriptor, size: fontSize)
+        if fontSize == 13 {
+            textField.alignment = .center
+        } else {
+            textField.alignment = .justified
+        }
+    }
+ 
     private func actionFinish() {
         delegate?.componentSidebarPageTurnerDidValueChanged?(pageTurner: self)
     }

+ 2 - 1
PDF Office/PDF Master/AppDelegate+MenuAction.swift

@@ -1139,7 +1139,8 @@ extension AppDelegate {
     }
     
     @IBAction func menuItemAction_Feedback(_ sender: NSMenuItem) -> Void {
-        KMTools.feekback()
+        let help = KMUserFeekbackHanddler()
+        help.showFeekbackWindow(with: KMLocalizedString("Feedback", comment: ""))
     }
     
     @IBAction func menuItemAction_FiveStar(_ sender: NSMenuItem) -> Void {

+ 10 - 6
PDF Office/PDF Master/Class/UserFeekback/View/KMUserFbTypeItemView.swift

@@ -24,20 +24,24 @@ class KMUserFbTypeItemView: NSView, NibLoadable {
         
         self.comBoBox.isEditable = false
         self.comBoBox.removeAllItems()
-        self.comBoBox.addItems(withObjectValues: [NSLocalizedString("Feedback", comment: ""), NSLocalizedString("Report a Bug", comment: ""), NSLocalizedString("Propose a New Feature", comment: ""), NSLocalizedString("General Questions", comment: ""), NSLocalizedString("Other", comment: "")])
+        self.comBoBox.addItems(withObjectValues: [KMLocalizedString("Feedback", comment: ""),
+                                                  KMLocalizedString("Report a Bug", comment: ""),
+                                                  KMLocalizedString("Propose a New Feature", comment: ""),
+                                                  KMLocalizedString("General Questions", comment: ""),
+                                                  KMLocalizedString("Other", comment: "")])
     }
     
     func string() -> String {
         let stringV = self.comBoBox.stringValue
-        if stringV == NSLocalizedString("Feedback", comment: "") {
+        if stringV == KMLocalizedString("Feedback", comment: "") {
             return "Feedback"
-        } else if stringV == NSLocalizedString("Report a Bug", comment: "") {
+        } else if stringV == KMLocalizedString("Report a Bug", comment: "") {
             return "Report a Bug"
-        } else if stringV == NSLocalizedString("Propose a New Feature", comment: "") {
+        } else if stringV == KMLocalizedString("Propose a New Feature", comment: "") {
             return "Propose a New Feature"
-        } else if stringV == NSLocalizedString("General Questions", comment: "") {
+        } else if stringV == KMLocalizedString("General Questions", comment: "") {
             return "General Questions"
-        } else if stringV == NSLocalizedString("Other", comment: "") {
+        } else if stringV == KMLocalizedString("Other", comment: "") {
             return "Other"
         }
         return self.comBoBox.stringValue