// // KMVerificationInfoViewController.m // PDF Reader Pro Edition // // Created by 王帅 on 2018/5/11. // #import "KMVerificationInfoViewController.h" #import #import "VerificationManager.h" @interface KMVerificationInfoViewController () @property (nonatomic, assign) IBOutlet NSTextField *label; @property (nonatomic, assign) IBOutlet NSTextField *licenseLabel; @property (nonatomic, assign) IBOutlet NSTextField *license; @property (nonatomic, assign) IBOutlet NSTextField *deviceLabel; @property (nonatomic, assign) IBOutlet NSTextField *device; @property (nonatomic, assign) IBOutlet KMCustomButton *continueButton; @property (assign) IBOutlet NSButton *unbindButton; @property (nonatomic, retain) CALayer *continueButtonLayer; @property (nonatomic, strong) NSPopover *popover; @end @implementation KMVerificationInfoViewController #pragma mark Init Methods - (instancetype)init { if (self = [super initWithNibName:@"KMVerificationInfoViewController" bundle:nil]) { } return self; } - (void)dealloc { } #pragma mark Setter Methods - (void)loadView { [super loadView]; // Do view setup here. self.continueButton.wantsLayer = YES; self.continueButton.layer.masksToBounds = YES; self.continueButton.layer.cornerRadius = 1.0; self.label.stringValue = NSLocalizedString(@"Successful Activation!", nil); self.licenseLabel.stringValue = NSLocalizedString(@"License ID:", nil); self.deviceLabel.stringValue = NSLocalizedString(@"UUID:", nil); self.continueButton.title = NSLocalizedString(@"Continue", nil); [self.continueButton setTitleColor:[NSColor whiteColor]]; self.unbindButton.title = NSLocalizedString(@"Unbind License Code", nil); NSString *cdkey = [VerificationManager manager].detailInfo[@"device"][@"cdkey"]; NSString *unique_sn = [VerificationManager manager].detailInfo[@"device"][@"unique_sn"]; self.license.stringValue = cdkey ? : @""; self.device.stringValue = unique_sn ? : @""; self.continueButtonLayer = [CALayer layer]; [self.continueButton.layer addSublayer:self.continueButtonLayer]; self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds)); self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor; self.continueButtonLayer.cornerRadius = 0; self.continueButtonLayer.hidden = YES; __block KMVerificationInfoViewController *blockSelf = self; self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) { if (mouseEntered) blockSelf.continueButtonLayer.hidden = NO; else blockSelf.continueButtonLayer.hidden = YES; }; [self.label setTextColor:[KMAppearance KMColor_Layout_H0]]; [self.licenseLabel setTextColor:[KMAppearance KM_242424_Color75]]; [self.deviceLabel setTextColor:[KMAppearance KM_242424_Color75]]; [self.license setTextColor:[KMAppearance KM_242424_Color75]]; [self.device setTextColor:[KMAppearance KM_242424_Color75]]; } #pragma mark - IBAction - (IBAction)continueButtonAction:(id)sender { if (self.callback) { self.callback(); } } - (IBAction)unbindAction:(NSButton *)sender { if ([VerificationManager defaultManager].allowUnbind) { NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/mac/license-retrieval"]; [[NSWorkspace sharedWorkspace] openURL:url]; return; } if (self.unbindAction) { self.unbindAction(); } } - (IBAction)guideAction:(NSButton *)sender { if (self.popover.isShown) { return; } if (!self.popover) { self.popover = [[NSPopover alloc] init]; } self.popover.behavior = NSPopoverBehaviorTransient; KMMergePopoverViewController *controller = [[KMMergePopoverViewController alloc] initWithNibName:@"KMMergePopoverViewController" bundle:nil]; controller.titleString = NSLocalizedString(@"You can unbind your license through our website.", nil); self.popover.contentViewController = controller; [self.popover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxYEdge]; [controller reloadData]; } @end