// // KMPropertiesViewPopController.swift // PDF Reader Pro // // Created by lizhe on 2023/10/12. // import Cocoa @objcMembers class KMPropertiesViewPopController: NSViewController { @IBOutlet var titleLabel: NSTextField! @IBOutlet var titlesubLabel: NSTextField! @IBOutlet var closeBtn: NSButton! var guideInfoWindowController: KMGuideInfoWindowController? var popOver: NSPopover? var block: (() -> Void)? // class func defaultManager() -> KMPropertiesViewPopController { // let singleton = KMPropertiesViewPopController() // return singleton // } static let defaultManager = KMPropertiesViewPopController() class func showChangeColorDetails() -> Bool { // let isOpenConvertDetails = UserDefaults.standard.bool(forKey: "KMPropertiesHaveChangeColorDetails") // if !isOpenConvertDetails { return true // } // return false } func showChangeColorDetailsView(_ view: NSView) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { if KMGuideInfoWindowController.availableShow(.customColor) { self.guideInfoWindowController = KMGuideInfoWindowController.currentWC() guard let guideWC = self.guideInfoWindowController else { return } guideWC.type = .customColor guideWC.digitalBoxRect = view.superview?.convert(view.frame, to: view.window?.contentView) ?? .zero if NSLocalizedString("Right click a color and select “Change Color...“.", comment: "") == "انقر بزر الماوس الأيمن فوق اللون وحدد \"تغيير اللون...\"." { // 阿拉伯语适配 var frame = guideWC.digitalBoxRect let offset: CGFloat = 15 let winFrame = view.window?.frame ?? .zero frame.origin.x = winFrame.size.width - frame.origin.x - offset guideWC.digitalBoxRect = frame } var beh = view.window?.collectionBehavior ?? [] beh.insert(.canJoinAllSpaces) guideWC.window?.collectionBehavior = beh var rect = view.window?.frame ?? .zero rect.size.height -= 20 guideWC.window?.setFrame(rect, display: false) guideWC.window?.minSize = rect.size guideWC.window?.maxSize = rect.size view.window?.addChildWindow(guideWC.window!, ordered: .above) guideWC.show() } } } override func viewDidLoad() { super.viewDidLoad() view.wantsLayer = true view.layer?.backgroundColor = NSColor.gray.cgColor titleLabel.stringValue = NSLocalizedString("Customize colors", comment: "") titlesubLabel.stringValue = NSLocalizedString("Right click a color and select \"Change Color...\".", comment: "") closeBtn.title = NSLocalizedString("Close", comment: "") closeBtn.wantsLayer = true closeBtn.layer?.cornerRadius = 1.0 closeBtn.layer?.backgroundColor = NSColor.gray.cgColor closeBtn.contentTintColor = NSColor.white } @IBAction func buttonItemClick_Close(_ sender: Any) { block?() block = nil } }