From 56680a9b967772ca6eb9112ac6f2a9e9bbe7244b Mon Sep 17 00:00:00 2001 From: ritsuka Date: Tue, 29 Jul 2014 18:38:01 +0000 Subject: MacGui: Implemented a configuration panel similar to the win/lin gui one for the subtitles defaults, and added some more options from the other guis (add all, remove all). The SubtitleAddForeignAudioSubtitle setting will be added later after the automatic audio selection is done. Fixed a bug where HandBrake used 50% of cpu time if the subtitles table view was selected. Refactored a big part of HBSubtitlesController to make it works with the new automatic options and to cleaned the table view data source. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6241 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/HBSubtitlesSettings.m | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 macosx/HBSubtitlesSettings.m (limited to 'macosx/HBSubtitlesSettings.m') diff --git a/macosx/HBSubtitlesSettings.m b/macosx/HBSubtitlesSettings.m new file mode 100644 index 000000000..fd85dcfcb --- /dev/null +++ b/macosx/HBSubtitlesSettings.m @@ -0,0 +1,61 @@ +/* HBSubtitlesSettings.m $ + + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +#import "HBSubtitlesSettings.h" + +@implementation HBSubtitlesSettings + +- (instancetype)init +{ + self = [super init]; + if (self) + { + _trackSelectionLanguages = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)applySettingsFromPreset:(NSDictionary *)preset +{ + if ([preset[@"SubtitleTrackSelectionBehavior"] isEqualToString:@"first"]) + { + self.trackSelectionBehavior = HBSubtitleTrackSelectionBehaviorFirst; + } + else if ([preset[@"SubtitleTrackSelectionBehavior"] isEqualToString:@"all"]) + { + self.trackSelectionBehavior = HBSubtitleTrackSelectionBehaviorAll; + } + else + { + self.trackSelectionBehavior = HBSubtitleTrackSelectionBehaviorNone; + } + self.trackSelectionLanguages = [NSMutableArray arrayWithArray:preset[@"SubtitleLanguageList"]]; + self.addCC = [preset[@"SubtitleAddCC"] boolValue]; + self.addForeignAudioSearch = [preset[@"SubtitleAddForeignAudioSearch"] boolValue]; + self.addForeignAudioSubtitle = [preset[@"SubtitleAddForeignAudioSubtitle"] boolValue]; +} + +- (void)prepareSubtitlesForPreset:(NSMutableDictionary *)preset +{ + if (self.trackSelectionBehavior == HBSubtitleTrackSelectionBehaviorFirst) + { + preset[@"SubtitleTrackSelectionBehavior"] = @"first"; + } + else if (self.trackSelectionBehavior == HBSubtitleTrackSelectionBehaviorAll) + { + preset[@"SubtitleTrackSelectionBehavior"] = @"all"; + } + else + { + preset[@"SubtitleTrackSelectionBehavior"] = @"none"; + } + preset[@"SubtitleLanguageList"] = self.trackSelectionLanguages; + preset[@"SubtitleAddCC"] = @(self.addCC); + preset[@"SubtitleAddForeignAudioSearch"] = @(self.addForeignAudioSearch); + preset[@"SubtitleAddForeignAudioSubtitle"] = @(self.addForeignAudioSubtitle); +} + +@end -- cgit v1.2.3