From: Damiano Galassi Date: Sat, 27 Oct 2018 13:46:52 +0000 (+0200) Subject: MacGui: move the advanced x264 panel to the 'Additional options' text field contextua... X-Git-Tag: 1.2.0~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36f5330eb113f7917de31e57a79611c7ad661cc4;p=handbrake MacGui: move the advanced x264 panel to the 'Additional options' text field contextual menu. --- diff --git a/macosx/Base.lproj/AdvancedView.xib b/macosx/Base.lproj/AdvancedView.xib index 17dce4005..8e8cdc445 100644 --- a/macosx/Base.lproj/AdvancedView.xib +++ b/macosx/Base.lproj/AdvancedView.xib @@ -1,17 +1,14 @@ - - + + - - + + - - - @@ -47,22 +44,20 @@ - - + - - + + - + - @@ -71,9 +66,8 @@ - + - @@ -81,9 +75,8 @@ - + - @@ -92,9 +85,8 @@ - + - @@ -102,9 +94,8 @@ - + - @@ -124,9 +114,8 @@ - + - @@ -146,9 +134,8 @@ - + - @@ -165,9 +152,8 @@ - + - @@ -184,9 +170,8 @@ - + - @@ -206,9 +190,8 @@ - + - @@ -225,9 +208,8 @@ - + - @@ -243,20 +225,9 @@ - - - - - - - - - - - + - @@ -273,9 +244,8 @@ - + - @@ -283,9 +253,8 @@ - + - @@ -293,9 +262,8 @@ - + - @@ -303,9 +271,8 @@ - + - @@ -313,9 +280,8 @@ - + - @@ -332,9 +298,8 @@ - + - @@ -342,9 +307,8 @@ - + - @@ -352,9 +316,8 @@ - + - @@ -371,12 +334,11 @@ - + - - + @@ -384,9 +346,8 @@ - + - @@ -394,9 +355,8 @@ - + - @@ -404,9 +364,8 @@ - + - @@ -423,9 +382,8 @@ - + - @@ -442,9 +400,8 @@ - + - @@ -461,9 +418,8 @@ - + - @@ -471,9 +427,8 @@ - + - @@ -481,9 +436,8 @@ - + - @@ -491,9 +445,8 @@ - + - @@ -510,9 +463,8 @@ - + - @@ -532,9 +483,8 @@ - + - @@ -543,9 +493,8 @@ - + - @@ -553,9 +502,8 @@ - + - @@ -572,9 +520,8 @@ - + - @@ -582,9 +529,8 @@ - + - @@ -592,53 +538,53 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - + diff --git a/macosx/Base.lproj/MainWindow.xib b/macosx/Base.lproj/MainWindow.xib index fd577a809..9cff4bca5 100644 --- a/macosx/Base.lproj/MainWindow.xib +++ b/macosx/Base.lproj/MainWindow.xib @@ -1,15 +1,14 @@ - + - + - @@ -54,7 +53,7 @@ - + @@ -94,12 +93,6 @@ - - - - - - @@ -771,7 +764,7 @@ Blu-ray and DVD sources often have multiple titles, the longest of which is typi - + diff --git a/macosx/Base.lproj/Preferences.xib b/macosx/Base.lproj/Preferences.xib index 414513d16..82e504989 100644 --- a/macosx/Base.lproj/Preferences.xib +++ b/macosx/Base.lproj/Preferences.xib @@ -353,11 +353,11 @@ - + - + @@ -378,7 +378,7 @@ - + @@ -401,7 +401,7 @@ - + @@ -429,7 +429,7 @@ - + @@ -437,7 +437,7 @@ - + @@ -461,7 +461,7 @@ - + @@ -469,7 +469,7 @@ - + @@ -477,7 +477,7 @@ - + @@ -485,7 +485,7 @@ - + @@ -493,7 +493,7 @@ - + @@ -508,7 +508,7 @@ - + @@ -562,21 +562,8 @@ - - + @@ -624,10 +611,8 @@ This setting is no longer supported and may be removed in a future version. Use - - @@ -639,8 +624,9 @@ This setting is no longer supported and may be removed in a future version. Use + - + @@ -655,7 +641,6 @@ This setting is no longer supported and may be removed in a future version. Use - @@ -677,7 +662,6 @@ This setting is no longer supported and may be removed in a future version. Use - diff --git a/macosx/Base.lproj/Video.xib b/macosx/Base.lproj/Video.xib index e35a31259..f216a228c 100644 --- a/macosx/Base.lproj/Video.xib +++ b/macosx/Base.lproj/Video.xib @@ -8,8 +8,8 @@ + - @@ -17,7 +17,6 @@ - @@ -548,24 +547,6 @@ Syntax: option-1=foo:opt2=bar,baz - @@ -608,14 +589,15 @@ This setting is no longer supported and may be removed in a future version. Use + - - + + @@ -644,16 +626,13 @@ This setting is no longer supported and may be removed in a future version. Use - - - - + diff --git a/macosx/HBAdvancedController.h b/macosx/HBAdvancedController.h index f2f8714cb..d0714ebd7 100644 --- a/macosx/HBAdvancedController.h +++ b/macosx/HBAdvancedController.h @@ -15,6 +15,4 @@ @property (nonatomic, readwrite, weak) HBVideo *videoSettings; -@property (nonatomic, readwrite, getter=isHidden) BOOL hidden; -@property (nonatomic, readwrite, getter=isEnabled) BOOL enabled; @end diff --git a/macosx/HBAdvancedController.m b/macosx/HBAdvancedController.m index 2bd81b198..1d38a1e00 100644 --- a/macosx/HBAdvancedController.m +++ b/macosx/HBAdvancedController.m @@ -10,14 +10,6 @@ @interface HBAdvancedController () { - /* Advanced Tab for opts fX264optView*/ - IBOutlet NSBox * fOptionsBox; - - IBOutlet NSView * fEmptyView; - - IBOutlet NSView * fX264optView; - IBOutlet NSTextField * fX264optViewTitleLabel; - IBOutlet NSTextField * fDisplayX264OptionsLabel; IBOutlet NSTextField * fDisplayX264Options; IBOutlet NSTextField * fX264optBframesLabel; @@ -59,6 +51,8 @@ IBOutlet NSTextField * fX264optBAdaptLabel; } +@property (nonatomic, readwrite) HBVideo *internalVideoSettings; + - (IBAction) X264AdvancedOptionsAnimate: (id) sender; - (IBAction) X264AdvancedOptionsSet: (id) sender; - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; @@ -73,28 +67,37 @@ @implementation HBAdvancedController -@synthesize enabled = _enabled; - - (instancetype)init { self = [super initWithNibName:@"AdvancedView" bundle:nil]; - if (self) - { - - } - return self; } - (void)viewDidLoad { [super viewDidLoad]; - [self setHidden:NO]; + + fDisplayX264Options.stringValue = _videoSettings.unparseOptions; + [self X264AdvancedOptionsSet:nil]; +} + +- (IBAction)ok:(id)sender +{ + HBVideo *video = self.videoSettings; + video.preset = @"medium"; + video.tune = @""; + video.profile = @"auto"; + video.level = @"auto"; + video.fastDecode = NO; + video.videoOptionExtra = self.internalVideoSettings.videoOptionExtra; + + [self dismissViewController:self]; } - (void)setVideoSettings:(HBVideo *)videoSettings { _videoSettings = videoSettings; + self.internalVideoSettings = [videoSettings copy]; if (_videoSettings) { @@ -107,52 +110,6 @@ [self X264AdvancedOptionsSet:nil]; } -- (void)setHidden:(BOOL)hidden -{ - if (hidden) - { - [fOptionsBox setContentView:fEmptyView]; - } - else - { - [fOptionsBox setContentView:fX264optView]; - } -} - - - (void)setEnabled:(BOOL)flag -{ - _enabled = flag; - - unsigned i; - NSControl * controls[] = - { fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel, - fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp, - fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp, - fX264optTrellisLabel,fX264optTrellisPopUp, fX264optWeightPLabel, fX264optWeightPSwitch, - fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp, - fX264optBPyramidLabel,fX264optBPyramidPopUp, fX264optAqLabel, fX264optAqSlider, - fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel, - fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch, - fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp, fX264optPsyRDSlider, fX264optPsyRDLabel, fX264optPsyTrellisSlider, fX264optPsyTrellisLabel, fX264optBAdaptPopUp, fX264optBAdaptLabel }; - - for( i = 0; i < sizeof( controls ) / sizeof( NSControl * ); i++ ) - { - if( [[controls[i] className] isEqualToString: @"NSTextField"] ) - { - NSTextField * tf = (NSTextField *) controls[i]; - if( ![tf isBezeled] ) - { - [tf setTextColor: flag ? [NSColor controlTextColor] : - [NSColor disabledControlTextColor]]; - continue; - } - } - [controls[i] setEnabled: flag]; - - } -} - - /** * Populates the option widgets */ @@ -462,7 +419,7 @@ /* Change the option string to reflect the new standardized option string */ [fDisplayX264Options setStringValue:changedOptString]; - self.videoSettings.videoOptionExtra = changedOptString; + self.internalVideoSettings.videoOptionExtra = changedOptString; } /** @@ -1401,7 +1358,7 @@ /* We now need to reset the opt widgets since we changed some stuff */ [self X264AdvancedOptionsSet:sender]; - self.videoSettings.videoOptionExtra = fDisplayX264Options.stringValue; + self.internalVideoSettings.videoOptionExtra = fDisplayX264Options.stringValue; } @end diff --git a/macosx/HBController.m b/macosx/HBController.m index dec7906ee..379424e5e 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -22,7 +22,6 @@ #import "HBVideoController.h" #import "HBAudioController.h" #import "HBSubtitlesController.h" -#import "HBAdvancedController.h" #import "HBChapterTitlesController.h" #import "HBPreviewController.h" @@ -34,7 +33,6 @@ @import HandBrakeKit; -static void *HBControllerContext = &HBControllerContext; static void *HBControllerScanCoreContext = &HBControllerScanCoreContext; static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; @@ -66,10 +64,6 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; HBChapterTitlesController * fChapterTitlesController; IBOutlet NSTabViewItem * fChaptersTitlesTab; - // Advanced options tab - HBAdvancedController * fAdvancedOptions; - IBOutlet NSTabViewItem * fAdvancedTab; - // Picture Preview HBPreviewController * fPreviewController; @@ -256,12 +250,8 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; fAudioController = [[HBAudioController alloc] init]; [fAudioTab setView:[fAudioController view]]; - // setup the advanced view controller - fAdvancedOptions = [[HBAdvancedController alloc] init]; - [fAdvancedTab setView:[fAdvancedOptions view]]; - // setup the video view controller - fVideoController = [[HBVideoController alloc] initWithAdvancedController:fAdvancedOptions]; + fVideoController = [[HBVideoController alloc] init]; [fVideoTab setView:[fVideoController view]]; // setup the picture view controller @@ -272,11 +262,6 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; fFiltersViewController = [[HBFiltersViewController alloc] init]; [fFiltersTab setView:[fFiltersViewController view]]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self - forKeyPath:@"values.HBShowAdvancedTab" - options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial - context:HBControllerContext]; - [self.core addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial context:HBControllerScanCoreContext]; @@ -343,18 +328,7 @@ static void *HBControllerQueueCoreContext = &HBControllerQueueCoreContext; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == HBControllerContext && [keyPath isEqualToString:@"values.HBShowAdvancedTab"]) - { - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"] && ![[fMainTabView tabViewItems] containsObject:fAdvancedTab]) - { - [fMainTabView insertTabViewItem:fAdvancedTab atIndex:5]; - } - else - { - [fMainTabView removeTabViewItem:fAdvancedTab]; - } - } - else if (context == HBControllerScanCoreContext) + if (context == HBControllerScanCoreContext) { HBState state = [change[NSKeyValueChangeNewKey] intValue]; [self updateToolbarButtonsStateForScanCore:state]; @@ -1546,16 +1520,17 @@ static NSTouchBarItemIdentifier HBTouchBarAddTitlesToQueue = @"fr.handbrake.addT static NSTouchBarItemIdentifier HBTouchBarRip = @"fr.handbrake.rip"; static NSTouchBarItemIdentifier HBTouchBarPause = @"fr.handbrake.pause"; static NSTouchBarItemIdentifier HBTouchBarPreview = @"fr.handbrake.preview"; +static NSTouchBarItemIdentifier HBTouchBarActivity = @"fr.handbrake.activity"; - (NSTouchBar *)makeTouchBar { NSTouchBar *bar = [[NSTouchBar alloc] init]; bar.delegate = self; - bar.defaultItemIdentifiers = @[HBTouchBarOpen, NSTouchBarItemIdentifierFixedSpaceSmall, HBTouchBarAddToQueue, NSTouchBarItemIdentifierFixedSpaceLarge, HBTouchBarRip, HBTouchBarPause, NSTouchBarItemIdentifierFixedSpaceLarge, HBTouchBarPreview, NSTouchBarItemIdentifierOtherItemsProxy]; + bar.defaultItemIdentifiers = @[HBTouchBarOpen, NSTouchBarItemIdentifierFixedSpaceSmall, HBTouchBarAddToQueue, NSTouchBarItemIdentifierFixedSpaceLarge, HBTouchBarRip, HBTouchBarPause, NSTouchBarItemIdentifierFixedSpaceLarge, HBTouchBarPreview, HBTouchBarActivity, NSTouchBarItemIdentifierOtherItemsProxy]; bar.customizationIdentifier = HBTouchBarMain; - bar.customizationAllowedItemIdentifiers = @[HBTouchBarOpen, HBTouchBarAddToQueue, HBTouchBarAddTitlesToQueue, HBTouchBarRip, HBTouchBarPause, HBTouchBarPreview, NSTouchBarItemIdentifierFixedSpaceSmall, NSTouchBarItemIdentifierFixedSpaceLarge, NSTouchBarItemIdentifierFlexibleSpace]; + bar.customizationAllowedItemIdentifiers = @[HBTouchBarOpen, HBTouchBarAddToQueue, HBTouchBarAddTitlesToQueue, HBTouchBarRip, HBTouchBarPause, HBTouchBarPreview, HBTouchBarActivity, NSTouchBarItemIdentifierFixedSpaceSmall, NSTouchBarItemIdentifierFixedSpaceLarge, NSTouchBarItemIdentifierFlexibleSpace]; return bar; } @@ -1622,6 +1597,16 @@ static NSTouchBarItemIdentifier HBTouchBarPreview = @"fr.handbrake.preview"; item.view = button; return item; } + else if ([identifier isEqualTo:HBTouchBarActivity]) + { + NSCustomTouchBarItem *item = [[NSCustomTouchBarItem alloc] initWithIdentifier:identifier]; + item.customizationLabel = NSLocalizedString(@"Show Activity Window", @"Touch bar"); + + NSButton *button = [NSButton buttonWithImage:[NSImage imageNamed:NSImageNameTouchBarGetInfoTemplate] target:nil action:@selector(showOutputPanel:)]; + + item.view = button; + return item; + } return nil; } diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m index ecef901e0..151e2ed8c 100644 --- a/macosx/HBJob+HBJobConversion.m +++ b/macosx/HBJob+HBJobConversion.m @@ -141,35 +141,26 @@ const char *encoder_options = NULL; const char *encoder_profile = NULL; const char *encoder_level = NULL; - if (self.video.advancedOptions) + + // we are using the x264/x265 preset system + if ([(tmpString = self.video.completeTune) length]) { - // we are using the advanced panel - if ([(tmpString = self.video.videoOptionExtra) length]) - { - encoder_options = tmpString.UTF8String; - } + encoder_tune = [tmpString UTF8String]; } - else + if ([(tmpString = self.video.videoOptionExtra) length]) { - // we are using the x264/x265 preset system - if ([(tmpString = self.video.completeTune) length]) - { - encoder_tune = [tmpString UTF8String]; - } - if ([(tmpString = self.video.videoOptionExtra) length]) - { - encoder_options = [tmpString UTF8String]; - } - if ([(tmpString = self.video.profile) length]) - { - encoder_profile = [tmpString UTF8String]; - } - if ([(tmpString = self.video.level) length]) - { - encoder_level = [tmpString UTF8String]; - } - encoder_preset = self.video.preset.UTF8String; + encoder_options = [tmpString UTF8String]; + } + if ([(tmpString = self.video.profile) length]) + { + encoder_profile = [tmpString UTF8String]; + } + if ([(tmpString = self.video.level) length]) + { + encoder_level = [tmpString UTF8String]; } + encoder_preset = self.video.preset.UTF8String; + hb_job_set_encoder_preset (job, encoder_preset); hb_job_set_encoder_tune (job, encoder_tune); hb_job_set_encoder_options(job, encoder_options); diff --git a/macosx/HBJob+UIAdditions.m b/macosx/HBJob+UIAdditions.m index f8b273804..467b92c51 100644 --- a/macosx/HBJob+UIAdditions.m +++ b/macosx/HBJob+UIAdditions.m @@ -435,53 +435,39 @@ static NSDictionary *shortHeightAttr; { NSMutableString *encoderPresetInfo = [NSMutableString string]; - if (self.video.advancedOptions) + // we are using the x264 system + [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Preset: %@", @"Video description"), self.video.preset]; + + if (self.video.tune.length || self.video.fastDecode) { - // we are using the old advanced panel - if (self.video.videoOptionExtra.length) + [encoderPresetInfo appendString:@", "]; + [encoderPresetInfo appendString:HBKitLocalizedString(@"Tune: ", @"Video description")]; + + if (self.video.tune.length) { - [encoderPresetInfo appendString:self.video.videoOptionExtra]; + [encoderPresetInfo appendString:self.video.tune]; } - else + if (self.video.fastDecode) { - [encoderPresetInfo appendString:HBKitLocalizedString(@"default settings", @"Video description")]; + [encoderPresetInfo appendString:HBKitLocalizedString(@" - fastdecode", @"Video description")]; } } - else + if (self.video.videoOptionExtra.length) { - // we are using the x264 system - [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Preset: %@", @"Video description"), self.video.preset]; - - if (self.video.tune.length || self.video.fastDecode) - { - [encoderPresetInfo appendString:@", "]; - [encoderPresetInfo appendString:HBKitLocalizedString(@"Tune: ", @"Video description")]; - - if (self.video.tune.length) - { - [encoderPresetInfo appendString:self.video.tune]; - } - if (self.video.fastDecode) - { - [encoderPresetInfo appendString:HBKitLocalizedString(@" - fastdecode", @"Video description")]; - } - } - if (self.video.videoOptionExtra.length) - { - [encoderPresetInfo appendString:@", "]; - [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Options: %@", @"Video description"), self.video.videoOptionExtra]; - } - if (self.video.profile.length) - { - [encoderPresetInfo appendString:@", "]; - [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Profile: %@", @"Video description"), self.video.profile]; - } - if (self.video.level.length) - { - [encoderPresetInfo appendString:@", "]; - [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Level: %@", @"Video description"), self.video.level]; - } + [encoderPresetInfo appendString:@", "]; + [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Options: %@", @"Video description"), self.video.videoOptionExtra]; + } + if (self.video.profile.length) + { + [encoderPresetInfo appendString:@", "]; + [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Profile: %@", @"Video description"), self.video.profile]; } + if (self.video.level.length) + { + [encoderPresetInfo appendString:@", "]; + [encoderPresetInfo appendFormat:HBKitLocalizedString(@"Level: %@", @"Video description"), self.video.level]; + } + [attrString appendString:@"\t" withAttributes:detailAttr]; [attrString appendString:HBKitLocalizedString(@"Video Options:", @"Video description") withAttributes:detailBoldAttr]; [attrString appendString:@" \t" withAttributes:detailAttr]; diff --git a/macosx/HBVideo.h b/macosx/HBVideo.h index d259f011c..8f3647123 100644 --- a/macosx/HBVideo.h +++ b/macosx/HBVideo.h @@ -44,7 +44,6 @@ extern NSString * const HBVideoChangedNotification; * Encoder specifics options */ -@property (nonatomic, readwrite) BOOL advancedOptions; @property (nonatomic, readwrite, copy) NSString *preset; @property (nonatomic, readwrite, copy) NSString *tune; @property (nonatomic, readwrite, copy) NSString *profile; diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index 2df476165..15c2f67ae 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -106,7 +106,6 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; if (!(self.undo.isUndoing || self.undo.isRedoing)) { [self validatePresetsSettings]; - [self validateAdvancedOptions]; [self validateVideoOptionExtra:previousEncoder]; } @@ -305,14 +304,6 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; } } -- (void)validateAdvancedOptions -{ - if (self.encoder != HB_VCODEC_H264_MASK) - { - self.advancedOptions = NO; - } -} - - (void)validateVideoOptionExtra:(int)previousEncoder { if (!((previousEncoder & HB_VCODEC_X264_MASK && @@ -445,7 +436,6 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; copy->_twoPass = _twoPass; copy->_turboTwoPass = _turboTwoPass; - copy->_advancedOptions = _advancedOptions; copy->_preset = [_preset copy]; copy->_tune = [_tune copy]; copy->_profile = [_profile copy]; @@ -468,7 +458,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; - (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeInt:1 forKey:@"HBVideoVersion"]; + [coder encodeInt:2 forKey:@"HBVideoVersion"]; encodeInt(_encoder); @@ -485,7 +475,6 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; encodeBool(_twoPass); encodeBool(_turboTwoPass); - encodeBool(_advancedOptions); encodeObject(_preset); encodeObject(_tune); encodeObject(_profile); @@ -515,7 +504,6 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; decodeBool(_twoPass); decodeBool(_turboTwoPass); - decodeBool(_advancedOptions); decodeObjectOrFail(_preset, NSString); decodeObjectOrFail(_tune, NSString); decodeObjectOrFail(_profile, NSString); @@ -591,14 +579,12 @@ fail: self.fastDecode = NO; self.videoOptionExtra = preset[@"VideoOptionExtra"]; - self.advancedOptions = YES; } else { // x264UseAdvancedOptions is set to 0 (disabled), // so we use the new preset system and // disable the advanced panel - self.advancedOptions = NO; self.preset = preset[@"VideoPreset"]; self.tune = preset[@"VideoTune"]; @@ -693,17 +679,7 @@ fail: preset[@"VideoOptionExtra"] = self.videoOptionExtra; preset[@"VideoProfile"] = self.profile; preset[@"VideoLevel"] = self.level; - - // x264 Options, this will either be advanced panel or the video tabs x264 presets panel with modded option string - if (self.advancedOptions) - { - // use the old advanced panel. - preset[@"x264UseAdvancedOptions"] = @YES; - } - else - { - preset[@"x264UseAdvancedOptions"] = @NO; - } + preset[@"x264UseAdvancedOptions"] = @NO; } else { diff --git a/macosx/HBVideoController.h b/macosx/HBVideoController.h index 486b44c48..937563575 100644 --- a/macosx/HBVideoController.h +++ b/macosx/HBVideoController.h @@ -6,7 +6,6 @@ #import -@class HBAdvancedController; @class HBVideo; /** @@ -14,8 +13,6 @@ */ @interface HBVideoController : NSViewController -- (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController; - @property (nonatomic, readwrite, weak) HBVideo *video; @end diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index baca2b0c1..9a99719a5 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -25,8 +25,6 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; IBOutlet NSTextField *fEncoderOptionsLabel; // x264/x265 Presets Box - IBOutlet NSButton *fX264UseAdvancedOptionsCheck; - IBOutlet NSBox *fDividerLine; IBOutlet NSBox *fPresetsBox; IBOutlet NSSlider *fPresetsSlider; @@ -34,26 +32,15 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; IBOutlet NSTextField *fDisplayX264PresetsUnparseTextField; } -@property (nonatomic, strong, readwrite) HBAdvancedController *advancedController; +@property (nonatomic, weak) IBOutlet NSTextField *additionalsOptions; -@property (nonatomic, readwrite) BOOL presetViewEnabled; - -@property (nonatomic, readwrite) NSColor *labelColor; +@property (nonatomic) BOOL presetViewEnabled; +@property (nonatomic) NSColor *labelColor; @end @implementation HBVideoController -- (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController -{ - self = [self init]; - if (self) - { - _advancedController = advancedController; - } - return self; -} - - (instancetype)init { self = [super initWithNibName:@"Video" bundle:nil]; @@ -85,6 +72,51 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; return self; } +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + SEL action = menuItem.action; + + if (action == @selector(showAdvancedX264Panel:)) + { + return [self.video isOldAdvancedPanelSupported:self.video.encoder]; + } + return [self.nextResponder validateMenuItem:menuItem]; +} + +- (void)viewDidAppear +{ + NSText *defaultFieldEditor = [self.view.window fieldEditor:YES forObject:self.additionalsOptions]; + // defaultEditor.delegate = self; didn't help + NSMenu *mu = defaultFieldEditor.menu; + NSMenuItem *separator = [NSMenuItem separatorItem]; + separator.tag = 1; + NSMenuItem *action = [[NSMenuItem alloc] + initWithTitle:NSLocalizedString(@"Show advanced editor", @"Video -> Advanced editor") + action:@selector(showAdvancedX264Panel:) + keyEquivalent:@""]; + action.tag = 2; + action.enabled = YES; + [mu insertItem:separator atIndex:0]; + [mu insertItem:action atIndex:0]; +} + +- (void)viewWillDisappear +{ + NSText *defaultFieldEditor = [self.view.window fieldEditor:YES forObject:self.additionalsOptions]; + NSMenu *mu = defaultFieldEditor.menu; + NSMenuItem *separator = [mu itemWithTag:1]; + NSMenuItem *action = [mu itemWithTag:2]; + if (separator) { [mu removeItem:separator]; } + if (action) { [mu removeItem:action]; } +} + +- (IBAction)showAdvancedX264Panel:(id)sender +{ + HBAdvancedController *controller = [[HBAdvancedController alloc] init]; + controller.videoSettings = self.video; + [self presentViewControllerAsSheet:controller]; +} + - (void)setVideo:(HBVideo *)video { _video = video; @@ -145,27 +177,6 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; fDisplayX264PresetsUnparseTextField.stringValue = @""; } } - else if ([keyPath isEqualToString:@"video.advancedOptions"]) - { - if (self.video.advancedOptions) - { - // Do not enable the advanced panel it isn't visible. - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"]) - { - self.advancedController.videoSettings = self.video.advancedOptions ? self.video : nil; - } - else - { - self.video.advancedOptions = NO; - } - } - // enable/disable, populate and update the various widgets - [self enableEncoderOptionsWidgets:(self.video != nil)]; - - } else if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"]) - { - [self toggleAdvancedOptionsCheckBoxForEncoder:self.video.encoder]; - } else if ([keyPath isEqualToString:@"values.x264CqSliderFractional"]) { [self setupQualitySlider]; @@ -215,19 +226,10 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; */ - (void)switchPresetView { - self.advancedController.hidden = YES; - if ([self.video isPresetSystemSupported:self.video.encoder]) { - [self toggleAdvancedOptionsCheckBoxForEncoder:self.video.encoder]; - fPresetsBox.contentView = fPresetView; [self setupPresetsSlider]; - - if ([self.video isOldAdvancedPanelSupported:self.video.encoder]) - { - self.advancedController.hidden = NO; - } } else if ([self.video isSimpleOptionsPanelSupported:self.video.encoder]) { @@ -244,35 +246,8 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; */ - (void)enableEncoderOptionsWidgets:(BOOL)enable { - // check whether the x264 preset system and the advanced panel should be enabled - BOOL enable_x264_controls = (enable && !self.video.advancedOptions); - BOOL enable_advanced_panel = (enable && self.video.advancedOptions); - // enable/disable the checkbox and advanced panel - self.presetViewEnabled = enable_x264_controls; - self.advancedController.enabled = enable_advanced_panel; -} - -/** - * Shows/Hides the advanced options checkbox - * - * @param encoder the current encoder - */ -- (void)toggleAdvancedOptionsCheckBoxForEncoder:(int)encoder -{ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"] && [self.video isOldAdvancedPanelSupported:self.video.encoder]) - { - fX264UseAdvancedOptionsCheck.hidden = NO; - fDividerLine.hidden = YES; - fEncoderOptionsLabel.stringValue = NSLocalizedString(@"Encoder Options:", @"Video -> Advanced panel checkbox"); - } - else - { - fX264UseAdvancedOptionsCheck.hidden =YES; - fDividerLine.hidden = NO; - fEncoderOptionsLabel.stringValue = NSLocalizedString(@"Encoder Options", @"Video -> Encoder options title"); - self.video.advancedOptions = NO; - } + self.presetViewEnabled = enable; } /**