KMVerificationInfoViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 "NSObject+DeviceInfo.h"
  10. #import "VerificationManager.h"
  11. @interface KMVerificationInfoViewController ()
  12. @property (nonatomic, assign) IBOutlet NSTextField *label;
  13. @property (nonatomic, assign) IBOutlet NSTextField *licenseLabel;
  14. @property (nonatomic, assign) IBOutlet NSTextField *license;
  15. @property (nonatomic, assign) IBOutlet NSTextField *deviceLabel;
  16. @property (nonatomic, assign) IBOutlet NSTextField *device;
  17. @property (nonatomic, assign) IBOutlet KMCustomButton *continueButton;
  18. @property (assign) IBOutlet NSButton *unbindButton;
  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.title = NSLocalizedString(@"Unbind License Code", nil);
  44. NSString *cdkey = [VerificationManager manager].detailInfo[@"device"][@"cdkey"];
  45. NSString *unique_sn = [VerificationManager manager].detailInfo[@"device"][@"uniqueSn"];
  46. self.license.stringValue = cdkey ? : @"";
  47. self.device.stringValue = unique_sn ? : [self udid];
  48. self.continueButtonLayer = [CALayer layer];
  49. [self.continueButton.layer addSublayer:self.continueButtonLayer];
  50. self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds));
  51. self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  52. self.continueButtonLayer.cornerRadius = 0;
  53. self.continueButtonLayer.hidden = YES;
  54. __weak typeof(self) weakSelf = self;
  55. self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  56. if (mouseEntered)
  57. weakSelf.continueButtonLayer.hidden = NO;
  58. else
  59. weakSelf.continueButtonLayer.hidden = YES;
  60. };
  61. [self.label setTextColor:[KMAppearance KMColor_Layout_H0]];
  62. [self.licenseLabel setTextColor:[KMAppearance KM_242424_Color75]];
  63. [self.deviceLabel setTextColor:[KMAppearance KM_242424_Color75]];
  64. [self.license setTextColor:[KMAppearance KM_242424_Color75]];
  65. [self.device setTextColor:[KMAppearance KM_242424_Color75]];
  66. }
  67. #pragma mark - Getter
  68. - (NSString *)udid {
  69. return GetHardwareUUID()?:@"";
  70. }
  71. #pragma mark - IBAction
  72. - (IBAction)continueButtonAction:(id)sender {
  73. if (self.callback) {
  74. self.callback();
  75. }
  76. }
  77. - (IBAction)unbindAction:(NSButton *)sender {
  78. if ([VerificationManager defaultManager].allowUnbind) {
  79. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/license-retrieval"];
  80. [[NSWorkspace sharedWorkspace] openURL:url];
  81. return;
  82. }
  83. if (self.unbindAction) {
  84. self.unbindAction();
  85. }
  86. }
  87. - (IBAction)guideAction:(NSButton *)sender {
  88. if (self.popover.isShown) {
  89. return;
  90. }
  91. if (!self.popover) {
  92. self.popover = [[NSPopover alloc] init];
  93. }
  94. self.popover.behavior = NSPopoverBehaviorTransient;
  95. KMMergePopoverViewController *controller = [[KMMergePopoverViewController alloc] initWithNibName:@"KMMergePopoverViewController" bundle:nil];
  96. controller.titleString = NSLocalizedString(@"You can unbind your license through our website.", nil);
  97. self.popover.contentViewController = controller;
  98. [self.popover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxYEdge];
  99. [controller reloadData];
  100. }
  101. @end