|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
import Cocoa
|
|
import Cocoa
|
|
|
|
|
|
-@objc class KMPurchaseFirstTrialWindowController: NSWindowController,NSTextFieldDelegate,NSTextViewDelegate {
|
|
|
|
|
|
+@objc class KMPurchaseFirstTrialWindowController: NSWindowController,NSTextFieldDelegate,NSTextViewDelegate, NSWindowDelegate {
|
|
@IBOutlet weak var contentImageView: NSImageView!
|
|
@IBOutlet weak var contentImageView: NSImageView!
|
|
@IBOutlet weak var titleField: NSTextField!
|
|
@IBOutlet weak var titleField: NSTextField!
|
|
@IBOutlet weak var rView: NSView!
|
|
@IBOutlet weak var rView: NSView!
|
|
@@ -49,27 +49,19 @@ import Cocoa
|
|
@IBOutlet weak var enterLicenseBox: NSBox!
|
|
@IBOutlet weak var enterLicenseBox: NSBox!
|
|
@IBOutlet weak var enterLicenseBtn: HyperLinkButton!
|
|
@IBOutlet weak var enterLicenseBtn: HyperLinkButton!
|
|
|
|
|
|
|
|
+ static var currentWindowController: KMPurchaseFirstTrialWindowController!
|
|
|
|
+
|
|
@objc var buttonActionBlock: ((_ firstTrialWinVC: KMPurchaseFirstTrialWindowController, _ btn: KMButton, _ email : String, _ name : String)->Void)?
|
|
@objc var buttonActionBlock: ((_ firstTrialWinVC: KMPurchaseFirstTrialWindowController, _ btn: KMButton, _ email : String, _ name : String)->Void)?
|
|
|
|
|
|
//MARK: 打开文件
|
|
//MARK: 打开文件
|
|
@objc static func currentFirstTrialWC() -> KMPurchaseFirstTrialWindowController {
|
|
@objc static func currentFirstTrialWC() -> KMPurchaseFirstTrialWindowController {
|
|
- if let controller: KMPurchaseFirstTrialWindowController = KMPurchaseFirstTrialWindowController.fetchSampleController() {
|
|
|
|
- return controller
|
|
|
|
- } else {
|
|
|
|
- let purchaseLimitWC: KMPurchaseFirstTrialWindowController = KMPurchaseFirstTrialWindowController.init(windowNibName: "KMPurchaseFirstTrialWindowController")
|
|
|
|
- return purchaseLimitWC
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static func fetchSampleController() -> KMPurchaseFirstTrialWindowController? {
|
|
|
|
- for window in NSApp.windows {
|
|
|
|
- let controller = window.windowController
|
|
|
|
- if controller is KMPurchaseFirstTrialWindowController {
|
|
|
|
- return controller as? KMPurchaseFirstTrialWindowController
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
|
|
+ if currentWindowController != nil {
|
|
|
|
+ return currentWindowController
|
|
|
|
+ } else {
|
|
|
|
+ let configWC: KMPurchaseFirstTrialWindowController = KMPurchaseFirstTrialWindowController.init(windowNibName: "KMPurchaseFirstTrialWindowController")
|
|
|
|
+ currentWindowController = configWC;
|
|
|
|
+ return currentWindowController
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
deinit {
|
|
deinit {
|
|
@@ -79,8 +71,12 @@ import Cocoa
|
|
|
|
|
|
override func windowDidLoad() {
|
|
override func windowDidLoad() {
|
|
super.windowDidLoad()
|
|
super.windowDidLoad()
|
|
|
|
+
|
|
DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name(rawValue:"AppleInterfaceThemeChangedNotification"), object: nil)
|
|
DistributedNotificationCenter.default.addObserver(self, selector: #selector(themeChanged(_:)), name: NSNotification.Name(rawValue:"AppleInterfaceThemeChangedNotification"), object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(windowDidBecomeVisible(_:)), name: NSWindow.didBecomeKeyNotification, object: nil)
|
|
NotificationCenter.default.addObserver(self, selector: #selector(windowDidBecomeVisible(_:)), name: NSWindow.didBecomeKeyNotification, object: nil)
|
|
|
|
+
|
|
|
|
+ self.window?.delegate = self
|
|
|
|
+
|
|
self.activateTrialNowBtn.tag = 10001
|
|
self.activateTrialNowBtn.tag = 10001
|
|
self.buyNowBtn.tag = 10002
|
|
self.buyNowBtn.tag = 10002
|
|
self.enterLicenseBtn.tag = 10003
|
|
self.enterLicenseBtn.tag = 10003
|
|
@@ -234,7 +230,7 @@ import Cocoa
|
|
self.btnBox.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor
|
|
self.btnBox.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.setTitleColor(NSColor(red: 7.0/255.0, green: 1.0/255.0, blue: 34.0/255.0, alpha: 1))
|
|
self.activateTrialNowBtn.setTitleColor(NSColor(red: 7.0/255.0, green: 1.0/255.0, blue: 34.0/255.0, alpha: 1))
|
|
- self.activateTrialNowBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.activateTrialNowBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1).cgColor
|
|
self.btnBox.fillColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)
|
|
self.btnBox.fillColor = NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1)
|
|
@@ -254,7 +250,7 @@ import Cocoa
|
|
self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "")
|
|
self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "")
|
|
|
|
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1))
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1))
|
|
- self.buyNowBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.buyNowBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
} else {
|
|
} else {
|
|
@@ -264,7 +260,7 @@ import Cocoa
|
|
|
|
|
|
self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "")
|
|
self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "")
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1))
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 181.0/255.0, green: 177.0/255.0, blue: 239.0/255.0, alpha: 1))
|
|
- self.enterLicenseBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.enterLicenseBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
} else {
|
|
} else {
|
|
@@ -309,7 +305,7 @@ import Cocoa
|
|
self.btnBox.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor
|
|
self.btnBox.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
self.activateTrialNowBtn.setTitleColor(NSColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
- self.activateTrialNowBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.activateTrialNowBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1).cgColor
|
|
self.activateTrialNowBtn.layer?.backgroundColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1).cgColor
|
|
self.btnBox.fillColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1)
|
|
self.btnBox.fillColor = NSColor(red: 0.0/255.0, green: 207.0/255.0, blue: 133.0/255.0, alpha: 1)
|
|
@@ -326,7 +322,7 @@ import Cocoa
|
|
|
|
|
|
self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "")
|
|
self.buyNowBtn.title = NSLocalizedString("Buy Now", comment: "")
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1))
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1))
|
|
- self.buyNowBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.buyNowBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
self.buyNowBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
} else {
|
|
} else {
|
|
@@ -336,7 +332,7 @@ import Cocoa
|
|
|
|
|
|
self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "")
|
|
self.enterLicenseBtn.title = NSLocalizedString("Enter License", comment: "")
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1))
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 39.0/255.0, green: 60.0/255.0, blue: 98.0/255.0, alpha: 1))
|
|
- self.enterLicenseBtn.mouseMoveCallback = { (mouseEntered) in
|
|
|
|
|
|
+ self.enterLicenseBtn.mouseMoveCallback = {[unowned self] (mouseEntered) in
|
|
if mouseEntered {
|
|
if mouseEntered {
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
self.enterLicenseBtn.setTitleColor(NSColor(red: 8.0/255.0, green: 124.0/255.0, blue: 255.0/255.0, alpha: 1))
|
|
} else {
|
|
} else {
|
|
@@ -529,4 +525,8 @@ import Cocoa
|
|
|
|
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func windowWillClose(_ notification: Notification) {
|
|
|
|
+ KMPurchaseFirstTrialWindowController.currentWindowController = nil
|
|
|
|
+ }
|
|
}
|
|
}
|