summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-12-14 15:15:36 +0100
committerDamiano Galassi <[email protected]>2016-12-14 15:15:36 +0100
commit14c2e61e3a4efe5ec508061b2e6bc702699662cb (patch)
treeefdda1b40038f25b637008b0c10e6be0c205f603
parentf5a7f690c83fa18f3ca4d4f4f196f10db76c3480 (diff)
MacGui: use the languages from the audio preferences for built-in presets, this had been broken when the MacGui started to use hb_preset_job_init().
-rw-r--r--macosx/HBAudioDefaults.m40
-rw-r--r--macosx/HBController.m48
-rw-r--r--macosx/HBUtilities.h1
-rw-r--r--macosx/HBUtilities.m16
4 files changed, 63 insertions, 42 deletions
diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m
index 43e8c858a..127e2a47a 100644
--- a/macosx/HBAudioDefaults.m
+++ b/macosx/HBAudioDefaults.m
@@ -172,22 +172,6 @@
return fallbacks;
}
-- (NSString *)isoCodeForNativeLang:(NSString *)language
-{
- const iso639_lang_t *lang = lang_get_next(NULL);
- for (lang = lang_get_next(lang); lang != NULL; lang = lang_get_next(lang))
- {
- NSString *nativeLanguage = strlen(lang->native_name) ? @(lang->native_name) : @(lang->eng_name);
-
- if ([language isEqualToString:nativeLanguage])
- {
- return @(lang->iso639_2);
- }
- }
-
- return nil;
-}
-
#pragma mark - HBPresetCoding
- (void)applyPreset:(HBPreset *)preset
@@ -212,30 +196,6 @@
}
self.trackSelectionLanguages = [NSMutableArray arrayWithArray:preset[@"AudioLanguageList"]];
- // If the preset is one of the built in, set some additional options
- if ([preset[@"Type"] intValue] == 0)
- {
- if (self.trackSelectionLanguages.count == 0 || [self.trackSelectionLanguages.firstObject isEqualToString:@"und"])
- {
- if ([[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"])
- {
- NSString *lang = [self isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"]];
- if (lang)
- {
- [self.trackSelectionLanguages insertObject:lang atIndex:0];
- }
- }
- if ([[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"])
- {
- NSString *lang = [self isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]];
- if (lang)
- {
- [self.trackSelectionLanguages insertObject:lang atIndex:0];
- }
- }
- }
- }
-
// Auto Passthru settings
// first, disable all encoders
self.allowAACPassthru = NO;
diff --git a/macosx/HBController.m b/macosx/HBController.m
index a223ef54f..8b55d6343 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -135,7 +135,14 @@
fQueueController.controller = self;
presetManager = manager;
- _currentPreset = manager.defaultPreset;
+ if (manager.defaultPreset.isBuiltIn)
+ {
+ _currentPreset = [self presetByAddingDefaultLanguages:manager.defaultPreset];
+ }
+ else
+ {
+ _currentPreset = manager.defaultPreset;
+ }
_scanSpecificTitleIdx = 1;
}
@@ -1252,6 +1259,43 @@
_currentPreset = currentPreset;
}
+
+ if (!(self.undoManager.isUndoing || self.undoManager.isRedoing))
+ {
+ // If the preset is one of the built in, set some additional options
+ if (_currentPreset.isBuiltIn)
+ {
+ _currentPreset = [self presetByAddingDefaultLanguages:_currentPreset];
+ }
+ }
+}
+
+- (HBPreset *)presetByAddingDefaultLanguages:(HBPreset *)preset
+{
+ HBMutablePreset *mutablePreset = [preset mutableCopy];
+ NSMutableArray<NSString *> *languages = [NSMutableArray array];
+
+ if ([[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"])
+ {
+ NSString *lang = [HBUtilities isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"]];
+ if (lang)
+ {
+ [languages insertObject:lang atIndex:0];
+ }
+ }
+
+ if ([[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"])
+ {
+ NSString *lang = [HBUtilities isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]];
+ if (lang)
+ {
+ [languages insertObject:lang atIndex:0];
+ }
+ }
+
+ mutablePreset[@"AudioLanguageList"] = languages;
+
+ return mutablePreset;
}
- (void)setEdited:(BOOL)edited
@@ -1279,7 +1323,7 @@
[self removeJobObservers];
// Apply the preset to the current job
- [self.job applyPreset:preset];
+ [self.job applyPreset:self.currentPreset];
// If Auto Naming is on, update the destination
[self updateFileName];
diff --git a/macosx/HBUtilities.h b/macosx/HBUtilities.h
index fb35b4354..af5538fb9 100644
--- a/macosx/HBUtilities.h
+++ b/macosx/HBUtilities.h
@@ -57,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN
bitrate:(int)bitrate
videoCodec:(uint32_t)codec;
++ (NSString *)isoCodeForNativeLang:(NSString *)language;
+ (NSString *)iso6392CodeFor:(NSString *)language;
+ (NSString *)languageCodeForIso6392Code:(NSString *)language;
diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m
index de3fa6b95..47cb53060 100644
--- a/macosx/HBUtilities.m
+++ b/macosx/HBUtilities.m
@@ -276,6 +276,22 @@
return [name copy];
}
++ (NSString *)isoCodeForNativeLang:(NSString *)language
+{
+ const iso639_lang_t *lang = lang_get_next(NULL);
+ for (lang = lang_get_next(lang); lang != NULL; lang = lang_get_next(lang))
+ {
+ NSString *nativeLanguage = strlen(lang->native_name) ? @(lang->native_name) : @(lang->eng_name);
+
+ if ([language isEqualToString:nativeLanguage])
+ {
+ return @(lang->iso639_2);
+ }
+ }
+
+ return nil;
+}
+
+ (NSString *)iso6392CodeFor:(NSString *)aLanguage
{
iso639_lang_t *lang = lang_for_english(aLanguage.UTF8String);