From 98053d85d7aa6ce364a8a9e65fa0895289fdefb5 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 30 Aug 2019 12:03:00 +0200 Subject: [PATCH] MacGui: add a preference to not display preview images in the summary tab. --- .../ColorBars.imageset/Contents.json | 21 +++++ .../ColorBars.imageset/SMPTE_Color_Bars.png | Bin 0 -> 12644 bytes macosx/Base.lproj/Preferences.xib | 80 ++++++++++++------ macosx/HBPreferencesController.m | 3 + macosx/HBPreferencesKeys.h | 1 + macosx/HBPreviewViewController.m | 12 +-- macosx/HBSummaryViewController.m | 12 ++- 7 files changed, 95 insertions(+), 34 deletions(-) create mode 100644 macosx/Assets.xcassets/ColorBars.imageset/Contents.json create mode 100644 macosx/Assets.xcassets/ColorBars.imageset/SMPTE_Color_Bars.png diff --git a/macosx/Assets.xcassets/ColorBars.imageset/Contents.json b/macosx/Assets.xcassets/ColorBars.imageset/Contents.json new file mode 100644 index 000000000..463ea4eab --- /dev/null +++ b/macosx/Assets.xcassets/ColorBars.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "SMPTE_Color_Bars.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/macosx/Assets.xcassets/ColorBars.imageset/SMPTE_Color_Bars.png b/macosx/Assets.xcassets/ColorBars.imageset/SMPTE_Color_Bars.png new file mode 100644 index 0000000000000000000000000000000000000000..b781047bbec052d52898a05dce58f0864afe3698 GIT binary patch literal 12644 zcmeHNdr(tX8ov>1kwykkdD*Vl=(acz^5D@VBt#?#bPUT=f>I9K}l4R1JJhRUSd z1q!{^SFY6Wfqczc1EvQ6q1bGYE7Bnp+ykj$orp2f@C5^el_ExBfRrsYghFX>M2-=P z%ZZ9t z4e(_%f*nAiQK=HdO13Qy##$mq8j2bOELK)lmT#7yuimI;ark^bi_K+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sarfdf?>2pFj1K)^s12dX$w8zq?o6c;EiP+Xw6Kpmi{6D7t1>byXd0_wa#z(AcB z2pFhmBmxGiIFK+rr#R&ISrlt6BRqQBf?xg7!^IU&>2>wak`V6~SX+Yh)-LYb%O~2_ zIa$}VUfXdEKK4N8%&7Q0DYCz+^Um7d(Kn)o28Jy~wLH4m-0cBwU3#VIwDjh4c`7+~ zp*`*KK1G?~kWhe-iNT;U1P9_EMHw6hs)pbwP{rZ#A7}rg;&8AjcPd5K-IelflU=X; zlJ0GPN5^-Es%fL=yH7DMUphPPeDi*O&W~-Ab7MD%?zZkf+75(H*&DKdICW!vR`U!r z?$P2n^XTYzyxHrbWyynW2P(z}8Wf{%Ci}Scjjcl_Xqmm!(?(%IaHj~H;+r3D%NoK9 zy?bwr9`3;Gt(kQ%_kEVT{PV`n`9X8A1yjkG?YJjvXT`a%+~=2h5{UqSq12{I5rWzr za5ntb=8#bSdOP+}Kp6flz<*sn4>rLM&GoW*!IWd_@qtH3V{*-K%H;JEXE=koQ&kpq zOBA0MG4M=JPn}Ru zp1b0Fn`_zc4v%F9O&v;C)ZNqeoa0J+PMm?qJ^s`{$-03L2`ZnoLkJj~VQ zoH50|M5v&kz~}fk7IpGV`Qe2N);XKa#%g-?1+sWJZ2;^@Nn+nZ3V`!6HYsh{2hd50 zG9z%H03p+X$`AqviZTQYRB@n+13+ - + @@ -363,17 +363,17 @@ - + - + - + - + @@ -391,7 +391,7 @@ - + @@ -414,7 +414,7 @@ - + @@ -442,7 +442,7 @@ - + @@ -450,7 +450,7 @@ - + @@ -458,7 +458,7 @@ - + @@ -466,7 +466,7 @@ - + @@ -474,7 +474,7 @@ - + @@ -482,7 +482,7 @@ - + @@ -490,7 +490,7 @@ - + @@ -498,7 +498,7 @@ - + @@ -506,7 +506,7 @@ - + @@ -521,7 +521,7 @@ - + @@ -566,7 +566,7 @@ - + - + @@ -587,7 +587,7 @@ - + @@ -605,7 +605,7 @@ - + @@ -620,7 +620,7 @@ + + + + + + + + + + + + @@ -651,11 +672,13 @@ + + @@ -665,11 +688,11 @@ + - @@ -684,6 +707,7 @@ + @@ -701,7 +725,7 @@ - + diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 41b10c40c..2540f69f0 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -6,6 +6,8 @@ #import "HBPreferencesController.h" NSString * const HBShowOpenPanelAtLaunch = @"HBShowOpenPanelAtLaunch"; +NSString * const HBShowSummaryPreview = @"HBShowSummaryPreview"; + NSString * const HBLastDestinationDirectoryURL = @"HBLastDestinationDirectoryURL"; NSString * const HBLastDestinationDirectoryBookmark = @"HBLastDestinationDirectoryBookmark"; NSString * const HBLastSourceDirectoryURL = @"HBLastSourceDirectoryURL"; @@ -79,6 +81,7 @@ NSString * const HBQueueAutoClearCompletedItems = @"HBQueueAutoClearCompletedIt [[NSUserDefaults standardUserDefaults] registerDefaults:@{ HBShowOpenPanelAtLaunch: @YES, + HBShowSummaryPreview: @YES, HBDefaultMpegExtension: @"Auto", HBUseDvdNav: @YES, HBLastDestinationDirectoryURL: [NSKeyedArchiver archivedDataWithRootObject:moviesURL], diff --git a/macosx/HBPreferencesKeys.h b/macosx/HBPreferencesKeys.h index a3931f0c4..2ab539044 100644 --- a/macosx/HBPreferencesKeys.h +++ b/macosx/HBPreferencesKeys.h @@ -17,6 +17,7 @@ typedef NS_ENUM(NSUInteger, HBDoneAction) { }; extern NSString * const HBShowOpenPanelAtLaunch; +extern NSString * const HBShowSummaryPreview; extern NSString * const HBLastDestinationDirectoryURL; extern NSString * const HBLastDestinationDirectoryBookmark; diff --git a/macosx/HBPreviewViewController.m b/macosx/HBPreviewViewController.m index 2890d3ecd..cd97b33e2 100644 --- a/macosx/HBPreviewViewController.m +++ b/macosx/HBPreviewViewController.m @@ -70,12 +70,8 @@ if (generator) { self.selectedIndex = self.selectedIndex; - [self updatePicture]; - } - else - { - self.previewView.image = nil; } + [self updatePicture]; } - (void)update @@ -190,6 +186,12 @@ self.previewView.image = fPreviewImage; CFRelease(fPreviewImage); } + else + { + NSImage *bars = [NSImage imageNamed:@"ColorBars"]; + CGImageRef image = [bars CGImageForProposedRect:NULL context:nil hints:nil]; + self.previewView.image = image; + } } - (void)scrollWheel:(NSEvent *)theEvent diff --git a/macosx/HBSummaryViewController.m b/macosx/HBSummaryViewController.m index b1cf53eea..a62f9d8e9 100644 --- a/macosx/HBSummaryViewController.m +++ b/macosx/HBSummaryViewController.m @@ -8,6 +8,7 @@ #import "HBPreviewViewController.h" #import "HBPreviewGenerator.h" +#import "HBPreferencesKeys.h" @import HandBrakeKit; @@ -17,6 +18,7 @@ static void *HBSummaryViewControllerPictureContext = &HBSummaryViewControllerPic static void *HBSummaryViewControllerFiltersContext = &HBSummaryViewControllerFiltersContext; static void *HBSummaryViewControllerAudioContext = &HBSummaryViewControllerAudioContext; static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsContext; +static void *HBSummaryViewControllerPreferencesContext = &HBSummaryViewControllerPreferencesContext; @interface HBSummaryViewController () @@ -45,6 +47,9 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo { _labelColor = [NSColor disabledControlTextColor]; _previewViewController = [[HBPreviewViewController alloc] init]; + + [NSUserDefaultsController.sharedUserDefaultsController addObserver:self forKeyPath:@"values.HBShowSummaryPreview" + options:0 context:HBSummaryViewControllerPreferencesContext]; } return self; } @@ -60,7 +65,8 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo - (void)setGenerator:(HBPreviewGenerator *)generator { - self.previewViewController.generator = generator; + _generator = generator; + self.previewViewController.generator = [NSUserDefaults.standardUserDefaults boolForKey:HBShowSummaryPreview] ? generator : nil; } - (void)setJob:(HBJob *)job @@ -124,6 +130,10 @@ static void *HBSummaryViewControllerSubsContext = &HBSummaryViewControllerSubsCo { [self updatePicture:nil]; } + else if (context == HBSummaryViewControllerPreferencesContext) + { + self.generator = self.generator; + } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; -- 2.40.0