diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Base.lproj/Video.xib | 10 | ||||
-rw-r--r-- | macosx/HBVideo+UIAdditions.h | 6 | ||||
-rw-r--r-- | macosx/HBVideo+UIAdditions.m | 75 | ||||
-rw-r--r-- | macosx/HBVideo.m | 22 |
4 files changed, 99 insertions, 14 deletions
diff --git a/macosx/Base.lproj/Video.xib b/macosx/Base.lproj/Video.xib index 529bf0a0f..b38b993f0 100644 --- a/macosx/Base.lproj/Video.xib +++ b/macosx/Base.lproj/Video.xib @@ -477,13 +477,17 @@ x264 is lossless at RF 0.</string> </popUpButtonCell> <connections> <accessibilityConnection property="title" destination="gzq-SL-YVY" id="W8X-Zk-cQD"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.tune" previousBinding="puD-Y8-zxp" id="yp7-SK-DVh"> + <dictionary key="options"> + <string key="NSValueTransformerName">HBTuneTransformer</string> + </dictionary> + </binding> <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="jwX-If-Tz7"/> - <binding destination="-2" name="selectedValue" keyPath="self.video.tune" previousBinding="ziN-5r-CNJ" id="gu5-Qw-6oi"> + <binding destination="-2" name="contentValues" keyPath="self.video.tunes" id="puD-Y8-zxp"> <dictionary key="options"> - <string key="NSNullPlaceholder">none</string> + <string key="NSValueTransformerName">HBTunesTransformer</string> </dictionary> </binding> - <binding destination="-2" name="content" keyPath="self.video.tunes" id="ziN-5r-CNJ"/> </connections> </popUpButton> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CPP-lh-FbN"> diff --git a/macosx/HBVideo+UIAdditions.h b/macosx/HBVideo+UIAdditions.h index 22c9d85b6..a8fe73b6e 100644 --- a/macosx/HBVideo+UIAdditions.h +++ b/macosx/HBVideo+UIAdditions.h @@ -44,6 +44,12 @@ @interface HBFrameRateTransformer : NSValueTransformer @end +@interface HBTuneTransformer : NSValueTransformer +@end + +@interface HBTunesTransformer : NSValueTransformer +@end + @interface HBPresetsTransformer : NSValueTransformer - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithEncoder:(int)encoder NS_DESIGNATED_INITIALIZER; diff --git a/macosx/HBVideo+UIAdditions.m b/macosx/HBVideo+UIAdditions.m index 5f8740287..bc38c6081 100644 --- a/macosx/HBVideo+UIAdditions.m +++ b/macosx/HBVideo+UIAdditions.m @@ -424,6 +424,81 @@ @end +@implementation HBTuneTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + if ([value isEqualToString:@"none"]) + { + return HBKitLocalizedString(@"none", @"HBVideo -> tune"); + } + else + { + return value; + } +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + if ([value isEqualTo:HBKitLocalizedString(@"none", @"HBVideo -> tune")]) + { + return @"none"; + } + else + { + return value; + } +} + +@end + +@implementation HBTunesTransformer + ++ (Class)transformedValueClass +{ + return [NSArray class]; +} + +- (id)transformedValue:(id)value +{ + if (value != nil) + { + NSMutableArray *localizedArray = [NSMutableArray array]; + + for (NSString *text in value) + { + if ([text isEqualToString:@"none"]) + { + [localizedArray addObject:HBKitLocalizedString(@"none", @"HBVideo -> tune")]; + } + else + { + [localizedArray addObject:text]; + } + } + return localizedArray; + } + + return value; +} + ++ (BOOL)allowsReverseTransformation +{ + return NO; +} + +@end + @implementation HBVideo (EncoderAdditions) - (BOOL)isUnparsedSupported:(int)encoder diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index bf8c00d67..3de3ef66f 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -39,7 +39,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; _job = job; _preset = @"medium"; - _tune = @""; + _tune = @"none"; _profile = @"auto"; _level = @"auto"; @@ -223,13 +223,13 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; [[self.undo prepareWithInvocationTarget:self] setTune:_tune]; } - if (![tune isEqualToString:@"none"]) + if (tune == nil || [tune isEqualToString:@""]) { - _tune = [tune copy]; + _tune = @"none"; } else { - _tune = @""; + _tune = [tune copy]; } [self postChangedNotification]; @@ -379,9 +379,9 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; return [NSSet setWithObjects:@"encoder", nil]; } -- (NSArray *)tunes +- (NSArray<NSString *> *)tunes { - NSMutableArray *temp = [NSMutableArray array]; + NSMutableArray<NSString *> *temp = [NSMutableArray array]; [temp addObject:@"none"]; @@ -404,9 +404,9 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; return [NSSet setWithObjects:@"encoder", nil]; } -- (NSArray *)profiles +- (NSArray<NSString *> *)profiles { - NSMutableArray *temp = [NSMutableArray array]; + NSMutableArray<NSString *> *temp = [NSMutableArray array]; const char * const *profiles = hb_video_encoder_get_profiles(self.encoder); for (int i = 0; profiles != NULL && profiles[i] != NULL; i++) @@ -426,9 +426,9 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; return [NSSet setWithObjects:@"encoder", nil]; } -- (NSArray *)levels +- (NSArray<NSString *> *)levels { - NSMutableArray *temp = [NSMutableArray array]; + NSMutableArray<NSString *> *temp = [NSMutableArray array]; const char * const *levels = hb_video_encoder_get_levels(self.encoder); for (int i = 0; levels != NULL && levels[i] != NULL; i++) @@ -572,7 +572,7 @@ fail: { NSMutableString *string = [[NSMutableString alloc] init]; - if (self.tune) + if (self.tune && ![self.tune isEqualToString:@"none"]) { [string appendString:self.tune]; } |