Update CSVirtualCamera output settings view to display a link to installer if it is not installed.

Don't use hardcoded test camera UID
This commit is contained in:
Zakk 2020-05-25 18:46:54 -04:00
parent 5c331e0513
commit 787da4129d
3 changed files with 51 additions and 1 deletions

View file

@ -14,6 +14,12 @@
@synthesize persistOnDisconnect = _persistOnDisconnect;
+(bool)isInstalled
{
return [NSFileManager.defaultManager fileExistsAtPath:CSVC_DAL_PATH isDirectory:NULL];
}
-(void)connectToAssistant
{
NSXPCInterface *assistantInterface = [NSXPCInterface interfaceWithProtocol:@protocol(CSVirtualCameraProtocol)];

View file

@ -19,7 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (strong) NSDictionary *pixelFormats;
@property (strong) NSArray *formatSortDescriptors;
@property (strong) NSArray *audioOutputs;
@property (readonly) bool virtualCameraInstalled;
@property (readonly) NSMutableAttributedString *descriptionText;
@property (weak) IBOutlet NSTextField *descriptionTextField;
@end
NS_ASSUME_NONNULL_END

View file

@ -41,6 +41,48 @@
}
}
if (self.descriptionTextField)
{
self.descriptionTextField.allowsEditingTextAttributes = YES;
self.descriptionTextField.selectable = YES;
self.descriptionTextField.attributedStringValue = self.descriptionText;
}
}
-(bool)virtualCameraInstalled
{
return [CSVirtualCameraDevice isInstalled];
}
-(NSAttributedString *)descriptionText
{
NSMutableAttributedString *urlStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithUTF8String:"https://www.cocoasplit.com/releases/CSVirtualCamera"]];
NSString *availableStr = [NSString stringWithFormat:@"CocoaSplit Virtual Camera is not installed. You can download the latest release from "];
NSMutableAttributedString *retStr = [[NSMutableAttributedString alloc] initWithString:availableStr];
NSRange range = NSMakeRange(0, urlStr.length);
[urlStr beginEditing];
NSURL *URL = [NSURL URLWithString:[NSString stringWithUTF8String:"https://www.cocoasplit.com/releases/CSVirtualCamera"]];
[urlStr addAttribute:NSLinkAttributeName value:URL range:range];
[urlStr addAttribute:NSForegroundColorAttributeName value:[NSColor blueColor] range:range];
[urlStr addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:range];
[urlStr endEditing];
[retStr appendAttributedString:urlStr];
return retStr;
}
@end