123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- //
- // KMTabbingHintWindowController.swift
- // Cisdem PDFMaster
- //
- // Created by liujiajie on 2/28/24.
- //
- import Cocoa
- typealias homeClickedTabbingShowBlock = (_ continueOrNot: Bool) -> Void
- let KMTabbingHintShowFlag = "KMTabbingHintShowFlag"
- class KMTabbingHintWindowController: NSWindowController{
- @IBOutlet var hintLabel: NSTextField!
- @IBOutlet var newTabInWindowButton: NSButton!
- @IBOutlet var newWindowButton: NSButton!
- @IBOutlet var notShowAgainButton: NSButton!
- @IBOutlet var gapView: NSView!
- @IBOutlet var cancelButton: NSButton!
- @IBOutlet var doneButton: NSButton!
- var selectCallBack: homeClickedTabbingShowBlock?
-
- convenience init() {
- self.init(windowNibName: "KMTabbingHintWindowController")
- }
-
- override func windowDidLoad() {
- super.windowDidLoad()
- localiedLanguage()
- configuViewsUI()
- }
-
- func localiedLanguage() {
- hintLabel.stringValue = String(format: "%@:", NSLocalizedString("Open a document in", comment: ""))
- newTabInWindowButton.title = NSLocalizedString("a new tab in the same window", comment: "")
- newWindowButton.title = NSLocalizedString("a new window", comment: "")
- notShowAgainButton.title = NSLocalizedString("No longer prompt", comment: "")
- cancelButton.title = NSLocalizedString("Cancel", comment: "")
- doneButton.title = NSLocalizedString("Done", comment: "")
- }
- func configuViewsUI() {
- hintLabel.font = NSFont.boldSystemFont(ofSize: 16)
-
- newTabInWindowButton.state = .off
- newWindowButton.state = .on
- notShowAgainButton.state = .off
-
- gapView.wantsLayer = true
- gapView.layer?.backgroundColor = NSColor(red: 218/255.0, green: 218/255.0, blue: 218/255.0, alpha: 1).cgColor
- window?.contentView?.wantsLayer = true
- var color = NSColor.white
- if #available(macOS 10.14, *) {
- if let appearanceName = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]),
- appearanceName == .darkAqua {
- color = KMAppearance.viewBackgroundColor()
- }
- }
- color = NSColor(deviceRed: 74.0/255.0, green: 74.0/255.0, blue: 74.0/255.0, alpha: 1.0)
- if #available(macOS 10.14, *) {
- if let appearanceName = NSApp.effectiveAppearance.bestMatch(from: [.aqua, .darkAqua]),
- appearanceName == .darkAqua {
- color = NSColor(deviceRed: 1.0, green: 1.0, blue: 1.0, alpha: 0.7)
- }
- }
- hintLabel.textColor = color
- newTabInWindowButton?.setTitleColor(color)
- newWindowButton?.setTitleColor(color)
- notShowAgainButton?.setTitleColor(color)
- }
- @IBAction func buttonClicked_NewTabInWindowButton(_ sender: NSButton) {
- sender.state = NSControl.StateValue.off;
- KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
- }
-
- @IBAction func buttonClicked_NewWindow(_ sender: NSButton) {
- sender.state = NSControl.StateValue.on;
- }
- @IBAction func buttonClicked_DonotHintAgain(_ sender: NSButton) {
-
- }
- @IBAction func buttonClicked_Cancel(_ sender: NSButton) {
- self.km_quick_endSheet()
- if let callback = self.selectCallBack {
- callback(false)
- }
- }
- @IBAction func buttonClicked_Done(_ sender: NSButton) {
- UserDefaults.standard.set(self.notShowAgainButton.state, forKey: KMTabbingHintShowFlag)
- UserDefaults.standard.synchronize()
- self.km_quick_endSheet()
- if let callback = self.selectCallBack {
- callback(true)
- }
- }
- }
|