diff --git a/Classes/SBMediaTagsController.h b/Classes/SBMediaTagsController.h index d79acd0..887f530 100644 --- a/Classes/SBMediaTagsController.h +++ b/Classes/SBMediaTagsController.h @@ -13,6 +13,14 @@ NS_ASSUME_NONNULL_BEGIN @class MP42Track; @class SBMediaTag; +/** + * A SBMediaTagsControllert takes a MP42Track in input, + * and show a windows to configure the media characteristic tags + * of the input track. The new set of tags is added to the track + * after the user press the OK button. + * + * Custom media tags are preserved. + */ @interface SBMediaTagsController : NSWindowController { @private MP42Track *_track; @@ -21,6 +29,14 @@ NS_ASSUME_NONNULL_BEGIN IBOutlet NSTableView *_tableView; } +/** + * Initializes an SBMediaTagsController with the tags + * from the provided track. + * + * @param track the track + * + * @return an SBMediaTagsController. + */ - (instancetype)initWithTrack:(MP42Track *)track; @end diff --git a/Classes/SBMediaTagsController.m b/Classes/SBMediaTagsController.m index d77b31e..10afe40 100644 --- a/Classes/SBMediaTagsController.m +++ b/Classes/SBMediaTagsController.m @@ -11,6 +11,11 @@ #pragma mark - Helpers +NS_ASSUME_NONNULL_BEGIN + +/** + * A SBMediaTag is composed of a tag value and a boolean state. + */ @interface SBMediaTag : NSObject { @private BOOL _state; @@ -19,17 +24,35 @@ NSString *_localizedDescription; } +/** + * Returns the complete array of the predefined tags. + */ + (NSArray *)predefinedTags; + +/** + * Returns the predefined supported media tags + * for a particular media type. + * + * @param mediaType a MP42MediaType type. + * + * @return an array of NSString with the supported tags. + */ + (NSArray *)predefinedTagsForMediaType:(NSString *)mediaType; -+ (nullable NSString *)localizedDescriptionForTag:(NSString *)tag; + +/** + * Returns the localized human readable title of a partical tag. + */ ++ (nullable NSString *)localizedTitleForTag:(NSString *)tag; @property (nonatomic, readwrite) BOOL state; -@property (nonatomic, readonly, nonnull) NSString *value; -@property (nonatomic, readonly, nonnull) NSString *localizedTitle; -@property (nonatomic, readonly, nonnull) NSString *localizedDescription; +@property (nonatomic, readonly) NSString *value; +@property (nonatomic, readonly) NSString *localizedTitle; +@property (nonatomic, readonly) NSString *localizedDescription; @end +NS_ASSUME_NONNULL_END + @implementation SBMediaTag - (instancetype)initWithValue:(NSString *)value state:(BOOL)state { @@ -37,7 +60,7 @@ if (self) { _state = state; _value = [value copy]; - _localizedTitle = [[SBMediaTag localizedDescriptionForTag:_value] copy]; + _localizedTitle = [[SBMediaTag localizedTitleForTag:_value] copy]; if (_localizedTitle == nil) { _localizedTitle = [_value retain]; @@ -76,8 +99,9 @@ } - else if ([mediaType isEqualToString:MP42MediaTypeSubtitle] || - [mediaType isEqualToString:MP42MediaTypeClosedCaption]) { + if ([mediaType isEqualToString:MP42MediaTypeSubtitle] || + [mediaType isEqualToString:MP42MediaTypeClosedCaption] || + [mediaType isEqualToString:MP42MediaTypeAudio]) { [tags addObjectsFromArray:@[@"public.translation"]]; } @@ -85,7 +109,7 @@ return tags; } -+ (nullable NSString *)localizedDescriptionForTag:(NSString *)tag { ++ (nullable NSString *)localizedTitleForTag:(NSString *)tag { NSDictionary *localizedDescriptions = @{@"public.main-program-content": NSLocalizedString(@"Main Program Content", nil), @"public.auxiliary-content": NSLocalizedString(@"Auxiliary Content", nil), @"public.subtitles.forced-only": NSLocalizedString(@"Contains Only Forced Subtitles", nil), @@ -117,16 +141,23 @@ @end +NS_ASSUME_NONNULL_BEGIN + +/** + * A NSTableCellView that contains a single checkbox. + */ @interface SBCheckBoxTableCellView : NSTableCellView { IBOutlet NSButton *_checkBox; SBMediaTag *_representedTag; } -@property (nonatomic, readwrite, retain, nonnull) SBMediaTag *representedTag; +@property (nonatomic, readwrite, retain) SBMediaTag *representedTag; @end +NS_ASSUME_NONNULL_END + @implementation SBCheckBoxTableCellView @synthesize representedTag = _representedTag; diff --git a/Classes/SBMetadataSearchController.h b/Classes/SBMetadataSearchController.h old mode 100755 new mode 100644 diff --git a/English.lproj/SBMediaTagsController.xib b/English.lproj/SBMediaTagsController.xib index eb99f10..0ae8f8b 100644 --- a/English.lproj/SBMediaTagsController.xib +++ b/English.lproj/SBMediaTagsController.xib @@ -16,20 +16,20 @@ - + - + - + - + - + @@ -101,7 +101,7 @@ - + @@ -156,7 +156,7 @@ DQ - + diff --git a/Subler.xcodeproj/project.pbxproj b/Subler.xcodeproj/project.pbxproj index 05fe544..594c0ea 100644 --- a/Subler.xcodeproj/project.pbxproj +++ b/Subler.xcodeproj/project.pbxproj @@ -389,10 +389,10 @@ A961476213F567E10068F161 /* SBPresetManager.m */, A9B46A7E12B79B240040517A /* SBFileImport.h */, A9B46A7F12B79B240040517A /* SBFileImport.m */, - CD71FEA112F1B5AF00F0A98D /* SBMetadataSearchController.h */, - CD71FEA212F1B5AF00F0A98D /* SBMetadataSearchController.m */, A96946501BA3F83D0048C004 /* SBMediaTagsController.h */, A96946511BA3F83D0048C004 /* SBMediaTagsController.m */, + CD71FEA112F1B5AF00F0A98D /* SBMetadataSearchController.h */, + CD71FEA212F1B5AF00F0A98D /* SBMetadataSearchController.m */, CD56963012FAAD680029FADB /* SBArtworkSelector.h */, CD56963112FAAD680029FADB /* SBArtworkSelector.m */, A9B46A8212B79B240040517A /* SBPrefsController.h */,