1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //
- // KMPropertiesViewPopController.swift
- // PDF Master
- //
- // 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 popOver: NSPopover?
- var block: (() -> Void)?
- class func defaultManager() -> KMPropertiesViewPopController {
- let singleton = KMPropertiesViewPopController()
- return singleton
- }
- class func showChangeColorDetails() -> Bool {
- let isOpenConvertDetails = UserDefaults.standard.bool(forKey: "KMPropertiesHaveChangeColorDetails")
- if !isOpenConvertDetails {
- return true
- }
- return false
- }
- func showChangeColorDetailsView(_ view: NSView) {
- let popViewController = KMPropertiesViewPopController()
- popViewController.block = { [unowned self] in
- self.popOver?.close()
- }
- self.popOver = NSPopover()
- self.popOver?.contentViewController = popViewController
- self.popOver?.animates = false
- self.popOver?.behavior = .transient
- // self.popOver?.appearance = .minimal
- self.popOver?.contentSize = popViewController.view.frame.size
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
- if view.superview?.window == nil {
- return
- }
- UserDefaults.standard.set(true, forKey: "KMPropertiesHaveChangeColorDetails")
- UserDefaults.standard.synchronize()
- self.popOver?.show(relativeTo: view.bounds, of: view, preferredEdge: .maxY)
- }
- }
- 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
- }
- }
|