KMVerificationInfoViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // KMVerificationInfoViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/11.
  6. //
  7. #import "KMVerificationInfoViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. #import "VerificationManager.h"
  10. @interface KMVerificationInfoViewController ()
  11. @property (nonatomic, assign) IBOutlet NSTextField *label;
  12. @property (nonatomic, assign) IBOutlet NSTextField *licenseLabel;
  13. @property (nonatomic, assign) IBOutlet NSTextField *license;
  14. @property (nonatomic, assign) IBOutlet NSTextField *deviceLabel;
  15. @property (nonatomic, assign) IBOutlet NSTextField *device;
  16. @property (nonatomic, assign) IBOutlet KMCustomButton *continueButton;
  17. @property (assign) IBOutlet NSButton *unbindButton;
  18. @property (assign) IBOutlet NSButton *unbindHelpButton;
  19. @property (nonatomic, retain) CALayer *continueButtonLayer;
  20. @property (nonatomic, strong) NSPopover *popover;
  21. @end
  22. @implementation KMVerificationInfoViewController
  23. #pragma mark Init Methods
  24. - (instancetype)init {
  25. if (self = [super initWithNibName:@"KMVerificationInfoViewController" bundle:nil]) {
  26. }
  27. return self;
  28. }
  29. - (void)dealloc {
  30. }
  31. #pragma mark Setter Methods
  32. - (void)loadView {
  33. [super loadView];
  34. // Do view setup here.
  35. self.continueButton.wantsLayer = YES;
  36. self.continueButton.layer.masksToBounds = YES;
  37. self.continueButton.layer.cornerRadius = 1.0;
  38. self.label.stringValue = NSLocalizedString(@"Successful Activation!", nil);
  39. self.licenseLabel.stringValue = NSLocalizedString(@"License ID:", nil);
  40. self.deviceLabel.stringValue = NSLocalizedString(@"UUID:", nil);
  41. self.continueButton.title = NSLocalizedString(@"Continue", nil);
  42. [self.continueButton setTitleColor:[NSColor whiteColor]];
  43. self.unbindButton.hidden = true;
  44. self.unbindButton.title = NSLocalizedString(@"Unbind License Code", nil);
  45. self.unbindHelpButton.hidden = true;
  46. NSString *cdkey = [VerificationManager manager].detailInfo[@"device"][@"cdkey"];
  47. NSString *unique_sn = [VerificationManager manager].detailInfo[@"device"][@"unique_sn"];
  48. self.license.stringValue = cdkey ? : @"";
  49. self.device.stringValue = unique_sn ? : @"";
  50. self.continueButtonLayer = [CALayer layer];
  51. [self.continueButton.layer addSublayer:self.continueButtonLayer];
  52. self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds));
  53. self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  54. self.continueButtonLayer.cornerRadius = 0;
  55. self.continueButtonLayer.hidden = YES;
  56. __block KMVerificationInfoViewController *blockSelf = self;
  57. self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  58. if (mouseEntered)
  59. blockSelf.continueButtonLayer.hidden = NO;
  60. else
  61. blockSelf.continueButtonLayer.hidden = YES;
  62. };
  63. [self.label setTextColor:[KMAppearance KMColor_Layout_H0]];
  64. [self.licenseLabel setTextColor:[KMAppearance KM_242424_Color75]];
  65. [self.deviceLabel setTextColor:[KMAppearance KM_242424_Color75]];
  66. [self.license setTextColor:[KMAppearance KM_242424_Color75]];
  67. [self.device setTextColor:[KMAppearance KM_242424_Color75]];
  68. }
  69. #pragma mark - IBAction
  70. - (IBAction)continueButtonAction:(id)sender {
  71. if (self.callback) {
  72. self.callback();
  73. }
  74. }
  75. - (IBAction)unbindAction:(NSButton *)sender {
  76. if ([VerificationManager defaultManager].allowUnbind) {
  77. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/license-retrieval"];
  78. [[NSWorkspace sharedWorkspace] openURL:url];
  79. return;
  80. }
  81. if (self.unbindAction) {
  82. self.unbindAction();
  83. }
  84. }
  85. - (IBAction)guideAction:(NSButton *)sender {
  86. if (self.popover.isShown) {
  87. return;
  88. }
  89. if (!self.popover) {
  90. self.popover = [[NSPopover alloc] init];
  91. }
  92. self.popover.behavior = NSPopoverBehaviorTransient;
  93. KMMergePopoverViewController *controller = [[KMMergePopoverViewController alloc] initWithNibName:@"KMMergePopoverViewController" bundle:nil];
  94. controller.titleString = NSLocalizedString(@"You can unbind your license through our website.", nil);
  95. self.popover.contentViewController = controller;
  96. [self.popover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxYEdge];
  97. [controller reloadData];
  98. }
  99. @end