KMVerificationInfoViewController.m 4.2 KB

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