From c85a007fb90ed59527441be792e1e1cb9033fb91 Mon Sep 17 00:00:00 2001 From: ritsuka Date: Wed, 17 Sep 2014 15:29:53 +0000 Subject: MacGui: hide the “Use advanced options panel” checkbox too when the advanced panel is disabled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6411 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/English.lproj/Video.xib | 21 ++++++------ macosx/HBVideoController.m | 72 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/macosx/English.lproj/Video.xib b/macosx/English.lproj/Video.xib index 3e8888543..f3f5945ff 100644 --- a/macosx/English.lproj/Video.xib +++ b/macosx/English.lproj/Video.xib @@ -1,5 +1,5 @@ - + @@ -10,6 +10,7 @@ + @@ -228,7 +229,7 @@ - + @@ -263,13 +264,6 @@ - - - - - - - @@ -447,7 +441,7 @@ Set this if your device is struggling to play the output (dropped frames). - + @@ -455,6 +449,13 @@ Set this if your device is struggling to play the output (dropped frames). + + + + + + + diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index 8545eb6c3..ab7c0edfe 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -55,6 +55,7 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio NSArray * fPresetNames; NSUInteger fMediumPresetIndex; IBOutlet NSButton * fX264UseAdvancedOptionsCheck; + IBOutlet NSBox * fDividerLine; IBOutlet NSBox * fPresetsBox; IBOutlet NSSlider * fPresetsSlider; IBOutlet NSTextField * fPresetSliderLabel; @@ -127,6 +128,12 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio /* register that we are interested in changes made to the video container */ [center addObserver:self selector: @selector(containerChanged:) name:HBContainerChangedNotification object:nil]; [center addObserver:self selector: @selector(titleChanged:) name:HBTitleChangedNotification object:nil]; + + // Observe the andvanced tab preference. + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self + forKeyPath:@"values.HBShowAdvancedTab" + options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial + context:NULL]; } return self; @@ -277,6 +284,37 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio [fVidRatePopUp selectItemAtIndex: 0]; } +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if (context == NULL) + { + if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"]) + { + [self validateAdvancedOptionsCheckBoxForEncoder:self.codec]; + } + } + else + { + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + } +} + +- (void)validateAdvancedOptionsCheckBoxForEncoder:(int)encoder +{ + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"] && (encoder == HB_VCODEC_X264)) + { + [fX264UseAdvancedOptionsCheck setHidden:NO]; + [fDividerLine setHidden:YES]; + [fEncoderOptionsLabel setStringValue:NSLocalizedString(@"Encoder Options:", @"")]; + } + else + { + [fX264UseAdvancedOptionsCheck setHidden:YES]; + [fDividerLine setHidden:NO]; + [fEncoderOptionsLabel setStringValue:NSLocalizedString(@"Encoder Options", @"")]; + } +} + #pragma mark - apply settings - (void)applyVideoSettingsFromQueue:(NSDictionary *)queueToApply @@ -409,26 +447,37 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio } else { - [self.fAdvancedOptions setOptions: @""]; - [self setOptionExtra:nil]; + [self.fAdvancedOptions setOptions:@""]; + [self setOptionExtra:nil]; } /* preset does not use the x264 preset system, reset the widgets */ [self setPreset: nil]; [self setTune: nil]; [self setProfile:nil]; [self setLevel: nil]; + /* we enable the advanced panel and update the widgets */ - [fX264UseAdvancedOptionsCheck setState:NSOnState]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"]) + { + [fX264UseAdvancedOptionsCheck setState:NSOnState]; + } + else + { + [fX264UseAdvancedOptionsCheck setState:NSOffState]; + } [self updateEncoderOptionsWidgets:nil]; } else { - /* - * x264UseAdvancedOptions is set to 0 (disabled), - * so we use the x264 preset system - */ + // x264UseAdvancedOptions is set to 0 (disabled), + // so we use the new preset system and + // disable the advanced panel + [self.fAdvancedOptions setOptions:@""]; + [fX264UseAdvancedOptionsCheck setState:NSOffState]; + if (preset[@"x264Preset"]) { + // Read the old x264 preset keys [self setPreset: preset[@"x264Preset"]]; [self setTune: preset[@"x264Tune"]]; [self setOptionExtra:preset[@"x264OptionExtra"]]; @@ -437,16 +486,14 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio } else { + // Read the new preset keys (0.10) [self setPreset: preset[@"VideoPreset"]]; [self setTune: preset[@"VideoTune"]]; [self setOptionExtra:preset[@"VideoOptionExtra"]]; [self setProfile: preset[@"VideoProfile"]]; [self setLevel: preset[@"VideoLevel"]]; } - /* preset does not use the advanced panel, reset it */ - [self.fAdvancedOptions setOptions:@""]; - /* we disable the advanced panel and update the widgets */ - [fX264UseAdvancedOptionsCheck setState:NSOffState]; + [self updateEncoderOptionsWidgets:nil]; } } @@ -1016,15 +1063,14 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio - (void) setupPresetsWidgetsForEncoder:(int)encoder { + [self validateAdvancedOptionsCheckBoxForEncoder:(int)encoder]; if (encoder == HB_VCODEC_X264) { - [fX264UseAdvancedOptionsCheck setHidden:NO]; [fFastDecodeCheck setHidden:NO]; } else { - [fX264UseAdvancedOptionsCheck setHidden:YES]; [fFastDecodeCheck setHidden:YES]; } -- cgit v1.2.3