diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Base.lproj/Subtitles.xib | 76 | ||||
-rw-r--r-- | macosx/HBJob+HBJobConversion.m | 11 | ||||
-rw-r--r-- | macosx/HBSubtitles.h | 2 | ||||
-rw-r--r-- | macosx/HBSubtitles.m | 34 | ||||
-rw-r--r-- | macosx/HBSubtitlesController.m | 20 | ||||
-rw-r--r-- | macosx/HBSubtitlesTrack.h | 2 | ||||
-rw-r--r-- | macosx/HBSubtitlesTrack.m | 18 |
7 files changed, 82 insertions, 81 deletions
diff --git a/macosx/Base.lproj/Subtitles.xib b/macosx/Base.lproj/Subtitles.xib index 35dacbc8b..c07e3fe70 100644 --- a/macosx/Base.lproj/Subtitles.xib +++ b/macosx/Base.lproj/Subtitles.xib @@ -1,9 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> <deployment identifier="macosx"/> - <development version="8000" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -31,18 +30,18 @@ <menuItem title="Tracks" state="on" hidden="YES" id="TJO-RZ-jgb"/> <menuItem title="Add All Tracks" id="4PX-In-DpF"> <connections> - <action selector="addAll:" target="-2" id="tuS-uF-dje"/> + <action selector="browseImportExternalFile:" target="-2" id="tuS-uF-dje"/> </connections> </menuItem> - <menuItem title="Add External SRT…" toolTip="Add new SRT subtitle to the list." id="HW0-PS-t0U"> + <menuItem title="Add External Subtitles Track…" toolTip="Add new SRT/SSA subtitle to the list." id="HW0-PS-t0U"> <connections> - <action selector="browseImportSrtFile:" target="-2" id="dog-BP-my4"/> + <action selector="browseImportExternalFile:" target="-2" id="dog-BP-my4"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="2hO-bG-5qB"/> <menuItem title="Remove All Tracks" id="mVi-zH-KUq"> <connections> - <action selector="removeAll:" target="-2" id="QsA-lb-0rD"/> + <action selector="browseImportExternalFile:" target="-2" id="QsA-lb-0rD"/> </connections> </menuItem> </items> @@ -57,14 +56,14 @@ </connections> </popUpButton> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QsM-28-Pya"> - <rect key="frame" x="110" y="282" width="132" height="28"/> + <rect key="frame" x="110" y="282" width="132" height="27"/> <string key="toolTip">Configure subtitle tracks Selection Behavior. These settings affect which tracks will be added to the subtitle tracks list, and the settings used for each track.</string> <buttonCell key="cell" type="push" title="Selection Behavior…" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="oxg-bs-1si"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="showSettingsSheet:" target="-2" id="OAA-S8-tfS"/> + <action selector="browseImportExternalFile:" target="-2" id="OAA-S8-tfS"/> <binding destination="-2" name="enabled" keyPath="self.subtitles" id="dpe-kM-iMF"> <dictionary key="options"> <string key="NSValueTransformerName">NSIsNotNil</string> @@ -73,13 +72,13 @@ </connections> </button> <button toolTip="Reload the subtitles tracks list using the configured Selection Behavior." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Vxx-gk-9kY"> - <rect key="frame" x="240" y="282" width="62" height="28"/> + <rect key="frame" x="240" y="282" width="62" height="27"/> <buttonCell key="cell" type="push" title="Reload" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jG8-uo-1tv"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="addTracksFromDefaults:" target="-2" id="GOz-FT-Atg"/> + <action selector="browseImportExternalFile:" target="-2" id="GOz-FT-Atg"/> <binding destination="-2" name="enabled" keyPath="self.subtitles" id="CSa-3s-GD6"> <dictionary key="options"> <string key="NSValueTransformerName">NSIsNotNil</string> @@ -95,7 +94,7 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="25" rowSizeStyle="automatic" headerView="IiW-3a-Drv" viewBased="YES" id="0yM-wE-D2x"> - <rect key="frame" x="0.0" y="0.0" width="884" height="234"/> + <rect key="frame" x="0.0" y="0.0" width="886" height="234"/> <autoresizingMask key="autoresizingMask"/> <size key="intercellSpacing" width="3" height="2"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> @@ -166,7 +165,7 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <button toolTip="Forced Only. Use only subtitles marked as “forced” in the selected source track." translatesAutoresizingMaskIntoConstraints="NO" id="HC5-ql-Vcr"> - <rect key="frame" x="26" y="3" width="23" height="20"/> + <rect key="frame" x="26" y="2" width="23" height="21"/> <buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="SPR-9q-XBK"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <font key="font" metaFont="smallSystem"/> @@ -203,7 +202,7 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <button toolTip="Burned In. Make the selected subtitles permanent by overlaying them onto the video track." translatesAutoresizingMaskIntoConstraints="NO" id="zpm-9Z-Hsq"> - <rect key="frame" x="20" y="3" width="23" height="20"/> + <rect key="frame" x="20" y="2" width="23" height="21"/> <buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="s2E-1o-mGs"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <font key="font" metaFont="smallSystem"/> @@ -264,7 +263,7 @@ </prototypeCellViews> </tableColumn> <tableColumn identifier="srt_lang" width="171" minWidth="10" maxWidth="3.4028229999999999e+38" id="9ka-9O-WDj"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="SRT Language"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Language"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -284,7 +283,7 @@ <rect key="frame" x="526" y="1" width="171" height="25"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <popUpButton toolTip="SRT Language. Language of the selected SRT format source track. Not applicable to other formats." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Inz-O5-B8g"> + <popUpButton toolTip="Language of the selected SRT/SSA format source track. Not applicable to other formats." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Inz-O5-B8g"> <rect key="frame" x="0.0" y="0.0" width="171" height="22"/> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="zIn-sc-xak"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -297,9 +296,9 @@ </items> </menu> </popUpButtonCell> - <accessibility description="SRT Language"/> + <accessibility description="SRT/SSA Language"/> <connections> - <binding destination="4bh-my-GeM" name="enabled" keyPath="objectValue.isSrt" id="p69-lt-dgE"/> + <binding destination="4bh-my-GeM" name="enabled" keyPath="objectValue.isExternal" id="cQ5-cT-bqm"/> <binding destination="4bh-my-GeM" name="selectedValue" keyPath="objectValue.isoLanguage" previousBinding="OIo-fF-3vU" id="Ubv-kn-nf5"> <dictionary key="options"> <string key="NSValueTransformerName">HBIsoLanguageTrasformer</string> @@ -318,7 +317,7 @@ </prototypeCellViews> </tableColumn> <tableColumn identifier="srt_charcode" width="113" minWidth="10" maxWidth="3.4028229999999999e+38" id="1Qg-We-ltR"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="SRT Encoding"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Encoding"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -334,7 +333,7 @@ <rect key="frame" x="700" y="1" width="113" height="25"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <popUpButton toolTip="SRT Encoding. Character encoding/codeset of the selected SRT format source track. Not applicable to other formats." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QV0-kE-4yR"> + <popUpButton toolTip="Character encoding/codeset of the selected SRT/SSA format source track. Not applicable to other formats." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QV0-kE-4yR"> <rect key="frame" x="0.0" y="0.0" width="113" height="22"/> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="jFr-2c-3Vv"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> @@ -347,11 +346,11 @@ </items> </menu> </popUpButtonCell> - <accessibility description="SRT Character Encoding"/> + <accessibility description="SRT/SSA Character Encoding"/> <connections> + <binding destination="ZBK-cc-m0z" name="enabled" keyPath="objectValue.isExternal" id="g9q-4R-uuX"/> <binding destination="ZBK-cc-m0z" name="selectedValue" keyPath="objectValue.charCode" previousBinding="NGt-sB-Sg2" id="eBc-20-eSF"/> <binding destination="ZBK-cc-m0z" name="content" keyPath="objectValue.encodings" id="NGt-sB-Sg2"/> - <binding destination="ZBK-cc-m0z" name="enabled" keyPath="objectValue.isSrt" id="ZIt-gt-iqy"/> </connections> </popUpButton> </subviews> @@ -363,8 +362,8 @@ </tableCellView> </prototypeCellViews> </tableColumn> - <tableColumn identifier="srt_offset" width="66" minWidth="10" maxWidth="3.4028229999999999e+38" id="Fgh-pZ-6uu"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="SRT Offset"> + <tableColumn identifier="srt_offset" width="68" minWidth="10" maxWidth="3.4028229999999999e+38" id="Fgh-pZ-6uu"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Offset"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -377,21 +376,20 @@ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="9tV-iL-oaF"> - <rect key="frame" x="816" y="1" width="66" height="17"/> + <rect key="frame" x="816" y="1" width="68" height="17"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aJi-zQ-0cg"> - <rect key="frame" x="0.0" y="-3" width="66" height="14"/> - <string key="toolTip">SRT Offset. Positive or negative offset in milliseconds (ms) for the selected SRT format source track. Not applicable to other formats.</string> + <textField toolTip="Positive or negative offset in milliseconds (ms) for the selected SRT/SSA format source track. Not applicable to other formats." verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aJi-zQ-0cg"> + <rect key="frame" x="0.0" y="-3" width="68" height="14"/> <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" alignment="center" title="0" id="hhH-c3-gD0"> <numberFormatter key="formatter" formatterBehavior="default10_4" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="2000000000" maximumFractionDigits="3" id="Jui-oB-oVO"/> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> - <accessibility description="SRT Offset"/> + <accessibility description="SRT/SSA Offset"/> <connections> - <binding destination="9tV-iL-oaF" name="enabled" keyPath="objectValue.isSrt" id="noe-Kh-7pa"/> + <binding destination="9tV-iL-oaF" name="enabled" keyPath="objectValue.isExternal" id="ab2-et-mrD"/> <binding destination="9tV-iL-oaF" name="value" keyPath="objectValue.offset" id="NlM-1C-Udf"> <dictionary key="options"> <integer key="NSNullPlaceholder" value="0"/> @@ -425,15 +423,15 @@ </tableView> </subviews> </clipView> - <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="toe-s0-pVk"> + <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="toe-s0-pVk"> <rect key="frame" x="-100" y="-100" width="685" height="15"/> <autoresizingMask key="autoresizingMask"/> </scroller> - <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="GfM-TU-Tmr"> + <scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="GfM-TU-Tmr"> <autoresizingMask key="autoresizingMask"/> </scroller> <tableHeaderView key="headerView" id="IiW-3a-Drv"> - <rect key="frame" x="0.0" y="0.0" width="884" height="23"/> + <rect key="frame" x="0.0" y="0.0" width="886" height="23"/> <autoresizingMask key="autoresizingMask"/> </tableHeaderView> </scrollView> @@ -463,29 +461,29 @@ <menuItem title="Add All Tracks" id="S2I-Jd-Lyg"> <attributedString key="attributedTitle"/> <connections> - <action selector="addAll:" target="-2" id="ojh-vi-2gX"/> + <action selector="browseImportExternalFile:" target="-2" id="ojh-vi-2gX"/> </connections> </menuItem> - <menuItem title="Add External SRT…" id="fXD-7h-jMl"> + <menuItem title="Add External Subtitles Track…" id="fXD-7h-jMl"> <connections> - <action selector="browseImportSrtFile:" target="-2" id="tEu-2l-wjN"/> + <action selector="browseImportExternalFile:" target="-2" id="tEu-2l-wjN"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="Pr7-iM-rgd"/> <menuItem title="Remove All Tracks" id="R8a-qg-ASg"> <connections> - <action selector="removeAll:" target="-2" id="8yF-Gu-7bi"/> + <action selector="browseImportExternalFile:" target="-2" id="8yF-Gu-7bi"/> </connections> </menuItem> <menuItem isSeparatorItem="YES" id="eER-z8-aB9"/> <menuItem title="Selection Behavior…" id="pwm-PV-1x4"> <connections> - <action selector="showSettingsSheet:" target="-2" id="aQq-Fi-0Ro"/> + <action selector="browseImportExternalFile:" target="-2" id="aQq-Fi-0Ro"/> </connections> </menuItem> <menuItem title="Reload" id="jcM-HL-QJ6"> <connections> - <action selector="addTracksFromDefaults:" target="-2" id="IQq-bX-u1t"/> + <action selector="browseImportExternalFile:" target="-2" id="IQq-bX-u1t"/> </connections> </menuItem> </items> diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m index 151e2ed8c..c9d01885f 100644 --- a/macosx/HBJob+HBJobConversion.m +++ b/macosx/HBJob+HBJobConversion.m @@ -254,10 +254,11 @@ } else { - // if we are getting the subtitles from an external srt file - if (subTrack.type == SRTSUB) + // if we are getting the subtitles from an external file + if (subTrack.type == IMPORTSRT || subTrack.type == IMPORTSSA) { hb_subtitle_config_t sub_config; + int type = subTrack.type; sub_config.offset = subTrack.offset; @@ -267,18 +268,18 @@ strncpy(sub_config.src_codeset, subTrack.charCode.UTF8String, 39); sub_config.src_codeset[39] = 0; - if (!subTrack.burnedIn && hb_subtitle_can_pass(SRTSUB, job->mux)) + if (!subTrack.burnedIn && hb_subtitle_can_pass(type, job->mux)) { sub_config.dest = PASSTHRUSUB; } - else if (hb_subtitle_can_burn(SRTSUB)) + else if (hb_subtitle_can_burn(type)) { sub_config.dest = RENDERSUB; } sub_config.force = 0; sub_config.default_track = subTrack.def; - hb_srt_add( job, &sub_config, subTrack.isoLanguage.UTF8String); + hb_import_subtitle_add( job, &sub_config, subTrack.isoLanguage.UTF8String, type); } else { diff --git a/macosx/HBSubtitles.h b/macosx/HBSubtitles.h index 562052890..a52e84c36 100644 --- a/macosx/HBSubtitles.h +++ b/macosx/HBSubtitles.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)removeAll; - (void)reloadDefaults; -- (void)addSrtTrackFromURL:(NSURL *)srtURL; +- (void)addExternalTrackFromURL:(NSURL *)fileURL; @property (nonatomic, readonly) NSArray<NSDictionary *> *sourceTracks; @property (nonatomic, readonly) NSMutableArray<HBSubtitlesTrack *> *tracks; diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m index 3193045b7..109351418 100644 --- a/macosx/HBSubtitles.m +++ b/macosx/HBSubtitles.m @@ -24,8 +24,8 @@ extern NSString *keySubTrackName; extern NSString *keySubTrackLanguageIsoCode; extern NSString *keySubTrackType; -extern NSString *keySubTrackSrtFileURL; -extern NSString *keySubTrackSrtFileURLBookmark; +extern NSString *keySubTrackExternalFileURL; +extern NSString *keySubTrackExternalFileURLBookmark; #define NONE_TRACK_INDEX 0 #define FOREIGN_TRACK_INDEX 1 @@ -200,11 +200,13 @@ extern NSString *keySubTrackSrtFileURLBookmark; [self addDefaultTracksFromJobSettings:self.job.jobDict]; } -- (void)addSrtTrackFromURL:(NSURL *)srtURL +- (void)addExternalTrackFromURL:(NSURL *)fileURL { + int type = [fileURL.pathExtension.lowercaseString isEqualToString:@"srt"] ? IMPORTSRT : IMPORTSSA; + #ifdef __SANDBOX_ENABLED__ // Create the security scoped bookmark - NSData *bookmark = [HBUtilities bookmarkFromURL:srtURL + NSData *bookmark = [HBUtilities bookmarkFromURL:fileURL options:NSURLBookmarkCreationWithSecurityScope | NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess]; #endif @@ -212,14 +214,14 @@ extern NSString *keySubTrackSrtFileURLBookmark; // Create a new entry for the subtitle source array so it shows up in our subtitle source list NSMutableArray *sourceTrack = [self.sourceTracks mutableCopy]; #ifdef __SANDBOX_ENABLED__ - [sourceTrack addObject:@{keySubTrackName: srtURL.lastPathComponent, - keySubTrackType: @(SRTSUB), - keySubTrackSrtFileURL: srtURL, - keySubTrackSrtFileURLBookmark: bookmark}]; + [sourceTrack addObject:@{keySubTrackName: fileURL.lastPathComponent, + keySubTrackType: @(type), + keySubTrackExternalFileURL: fileURL, + keySubTrackExternalFileURLBookmark: bookmark}]; #else - [sourceTrack addObject:@{keySubTrackName: srtURL.lastPathComponent, - keySubTrackType: @(SRTSUB), - keySubTrackSrtFileURL: srtURL}]; + [sourceTrack addObject:@{keySubTrackName: fileURL.lastPathComponent, + keySubTrackType: @(type), + keySubTrackExternalFileURL: fileURL}]; #endif self.sourceTracks = [sourceTrack copy]; HBSubtitlesTrack *track = [self trackFromSourceTrackIndex:self.sourceTracksArray.count - 1]; @@ -404,9 +406,9 @@ extern NSString *keySubTrackSrtFileURLBookmark; { for (NSDictionary *sourceTrack in self.sourceTracks) { - if (sourceTrack[keySubTrackSrtFileURLBookmark]) + if (sourceTrack[keySubTrackExternalFileURLBookmark]) { - [self.tokens addObject:[HBSecurityAccessToken tokenWithObject:sourceTrack[keySubTrackSrtFileURL]]]; + [self.tokens addObject:[HBSecurityAccessToken tokenWithObject:sourceTrack[keySubTrackExternalFileURL]]]; } } } @@ -488,13 +490,13 @@ extern NSString *keySubTrackSrtFileURLBookmark; NSMutableArray *sourceTracks = [NSMutableArray array]; for (NSDictionary *sourceTrack in _sourceTracks) { - if (sourceTrack[keySubTrackSrtFileURLBookmark]) + if (sourceTrack[keySubTrackExternalFileURLBookmark]) { NSMutableDictionary<NSString *, id> *copy = [sourceTrack mutableCopy]; - NSURL *srtURL = [HBUtilities URLFromBookmark:sourceTrack[keySubTrackSrtFileURLBookmark]]; + NSURL *srtURL = [HBUtilities URLFromBookmark:sourceTrack[keySubTrackExternalFileURLBookmark]]; if (srtURL) { - copy[keySubTrackSrtFileURL] = srtURL; + copy[keySubTrackExternalFileURL] = srtURL; } [sourceTracks addObject:copy]; } diff --git a/macosx/HBSubtitlesController.m b/macosx/HBSubtitlesController.m index 623f3053a..b9c88e940 100644 --- a/macosx/HBSubtitlesController.m +++ b/macosx/HBSubtitlesController.m @@ -70,14 +70,14 @@ }]; } -#pragma mark - Srt import +#pragma mark - External subtitles import /** - * Imports a srt file. + * Imports a srt/ssa file. * * @param sender */ -- (IBAction)browseImportSrtFile:(id)sender +- (IBAction)browseImportExternalFile:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; panel.allowsMultipleSelection = NO; @@ -85,9 +85,9 @@ panel.canChooseDirectories = NO; NSURL *sourceDirectory; - if ([[NSUserDefaults standardUserDefaults] URLForKey:@"LastSrtImportDirectoryURL"]) + if ([[NSUserDefaults standardUserDefaults] URLForKey:@"LastExternalSubImportDirectoryURL"]) { - sourceDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"LastSrtImportDirectoryURL"]; + sourceDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"LastExternalSubImportDirectoryURL"]; } else { @@ -95,17 +95,17 @@ } panel.directoryURL = sourceDirectory; - panel.allowedFileTypes = @[@"srt"]; + panel.allowedFileTypes = @[@"srt", @"ssa", @"ass"]; [panel beginSheetModalForWindow:self.view.window completionHandler:^(NSInteger result) { if (result == NSModalResponseOK) { - NSURL *importSrtFileURL = panel.URL; - NSURL *importSrtDirectory = importSrtFileURL.URLByDeletingLastPathComponent; - [[NSUserDefaults standardUserDefaults] setURL:importSrtDirectory forKey:@"LastSrtImportDirectoryURL"]; + NSURL *importFileURL = panel.URL; + NSURL *importDirectory = importFileURL.URLByDeletingLastPathComponent; + [[NSUserDefaults standardUserDefaults] setURL:importDirectory forKey:@"LastExternalSubImportDirectoryURL"]; - [self.subtitles addSrtTrackFromURL:importSrtFileURL]; + [self.subtitles addExternalTrackFromURL:importFileURL]; } }]; } diff --git a/macosx/HBSubtitlesTrack.h b/macosx/HBSubtitlesTrack.h index 644c4c112..696ff1c29 100644 --- a/macosx/HBSubtitlesTrack.h +++ b/macosx/HBSubtitlesTrack.h @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN /// A complete list of the possible encodings. - (NSArray<NSString *> *)encodings; -@property (nonatomic, readonly) BOOL isSrt; +@property (nonatomic, readonly) BOOL isExternal; @property (nonatomic, readonly) BOOL isEnabled; @property (nonatomic, readonly) BOOL isForcedSupported; @property (nonatomic, readonly) BOOL canPassthru; diff --git a/macosx/HBSubtitlesTrack.m b/macosx/HBSubtitlesTrack.m index f87a7be5b..412f59840 100644 --- a/macosx/HBSubtitlesTrack.m +++ b/macosx/HBSubtitlesTrack.m @@ -10,7 +10,7 @@ #include "common.h" #include "lang.h" -#define CHAR_CODE_DEFAULT_INDEX 11 +#define CHAR_CODE_DEFAULT_INDEX 28 static NSArray *charEncodingArray = nil; static NSArray *_languagesArray = nil; @@ -18,8 +18,8 @@ static NSArray *_languagesArray = nil; NSString *keySubTrackName = @"keySubTrackName"; NSString *keySubTrackLanguageIsoCode = @"keySubTrackLanguageIsoCode"; NSString *keySubTrackType = @"keySubTrackType"; -NSString *keySubTrackSrtFileURL = @"keySubTrackSrtFileURL"; -NSString *keySubTrackSrtFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; +NSString *keySubTrackExternalFileURL = @"keySubTrackSrtFileURL"; +NSString *keySubTrackExternalFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; @interface HBSubtitlesTrack () @property (nonatomic, readwrite) BOOL validating; @@ -98,9 +98,9 @@ NSString *keySubTrackSrtFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; } // check to see if we are an srt, in which case set our file path and source track type kvp's - if (_type == SRTSUB) + if (_type == IMPORTSRT || _type == IMPORTSSA) { - self.fileURL = [sourceTrack[keySubTrackSrtFileURL] copy]; + self.fileURL = [sourceTrack[keySubTrackExternalFileURL] copy]; self.isoLanguage = @"eng"; self.charCode = charEncodingArray[CHAR_CODE_DEFAULT_INDEX]; } @@ -207,7 +207,7 @@ NSString *keySubTrackSrtFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; } } -#pragma mark - Srt only properties +#pragma mark - External subtitles track only properties - (void)setFileURL:(NSURL *)fileURL { @@ -252,9 +252,9 @@ NSString *keySubTrackSrtFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; return [self.dataSource sourceTracksArray]; } -- (BOOL)isSrt +- (BOOL)isExternal { - return self.type == SRTSUB; + return self.type == IMPORTSRT || self.type == IMPORTSSA; } - (BOOL)isEnabled @@ -288,7 +288,7 @@ NSString *keySubTrackSrtFileURLBookmark = @"keySubTrackSrtFileURLBookmark"; { NSSet *retval = nil; - if ([key isEqualToString: @"isSrt"]) + if ([key isEqualToString: @"isExternal"]) { retval = [NSSet setWithObjects: @"type", nil]; } |