12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- //
- // 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
- 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
- }
- }
|