From 13d0d1d579a7e56ac2e2978994e3f0e74d324bba Mon Sep 17 00:00:00 2001 From: ritsuka Date: Tue, 7 Apr 2015 16:14:30 +0000 Subject: [PATCH] MacGui: changed the Preview Window and Picture Panel behaviour to avoid the hide and show thing when loading a new title, now they can always be opened even if no title is loaded. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7065 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/English.lproj/PicturePreview.xib | 8 +++--- macosx/English.lproj/PictureSettings.xib | 32 +++++++++++++++++++++--- macosx/HBAppDelegate.m | 19 ++++++++------ macosx/HBController.m | 27 ++++++-------------- macosx/HBOutputPanelController.m | 18 ++----------- macosx/HBPictureController.h | 10 +------- macosx/HBPictureController.m | 18 +++++-------- macosx/HBPreviewController.h | 9 +------ macosx/HBPreviewController.m | 26 ++++++++++++------- macosx/HBQueueController.m | 18 ------------- 10 files changed, 79 insertions(+), 106 deletions(-) diff --git a/macosx/English.lproj/PicturePreview.xib b/macosx/English.lproj/PicturePreview.xib index 604172292..f2c07fb41 100644 --- a/macosx/English.lproj/PicturePreview.xib +++ b/macosx/English.lproj/PicturePreview.xib @@ -1,9 +1,9 @@ - + - - + + @@ -27,7 +27,7 @@ - + diff --git a/macosx/English.lproj/PictureSettings.xib b/macosx/English.lproj/PictureSettings.xib index dcfa5fc66..1a9a51b61 100644 --- a/macosx/English.lproj/PictureSettings.xib +++ b/macosx/English.lproj/PictureSettings.xib @@ -1,9 +1,9 @@ - + - + @@ -995,6 +995,11 @@ + + + NSIsNil + + @@ -1007,14 +1012,35 @@ + + + NSIsNil + + + + + + + + + + + + + + NSIsNotNil + + + + - + diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m index 872d61c3e..87bf0f45d 100644 --- a/macosx/HBAppDelegate.m +++ b/macosx/HBAppDelegate.m @@ -84,6 +84,14 @@ // Get the number of HandBrake instances currently running NSUInteger instances = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]].count; + // Open debug output window now if it was visible when HB was closed + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"]) + [self showOutputPanel:nil]; + + // Open queue window now if it was visible when HB was closed + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"]) + [self showQueueWindow:nil]; + [self showMainWindow:self]; // Now we re-check the queue array to see if there are @@ -165,14 +173,6 @@ [self.mainController launchAction]; } - // Open debug output window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"]) - [self showOutputPanel:nil]; - - // Open queue window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"]) - [self showQueueWindow:nil]; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ // Remove encodes logs older than a month if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBClearOldLogs"]) @@ -242,6 +242,9 @@ { [self.presetsManager savePresets]; + [[NSUserDefaults standardUserDefaults] setBool:_queueController.window.isVisible forKey:@"QueueWindowIsOpen"]; + [[NSUserDefaults standardUserDefaults] setBool:_outputPanel.window.isVisible forKey:@"OutputPanelIsOpen"]; + _mainController = nil; _queueController = nil; diff --git a/macosx/HBController.m b/macosx/HBController.m index 29b69da18..9379abf43 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -29,7 +29,7 @@ #import "HBCore.h" #import "HBJob.h" -@interface HBController () +@interface HBController () @property (unsafe_unretained) IBOutlet NSView *openTitleView; @property (nonatomic, readwrite) BOOL scanSpecificTitle; @@ -73,10 +73,10 @@ _core.name = @"ScanCore"; // Inits the controllers + fPreviewController = [[HBPreviewController alloc] init]; fPictureController = [[HBPictureController alloc] init]; - [fPictureController setDelegate:self]; - - fPreviewController = [[HBPreviewController alloc] initWithDelegate:self]; + fPictureController.previewWindow = fPreviewController; + fPreviewController.pictureSettingsWindow = fPictureController; fQueueController = queueController; fQueueController.controller = self; @@ -346,9 +346,7 @@ } } - if (action == @selector(showPicturePanel:) || - action == @selector(showPreviewWindow:) || - action == @selector(addToQueue:)) + if (action == @selector(addToQueue:)) { return (self.job != nil); } @@ -360,9 +358,8 @@ { SEL action = [menuItem action]; - if (action == @selector(addToQueue:) || action == @selector(addAllTitlesToQueue:) || action == @selector(addTitlesToQueue:) || - action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:) || - action == @selector(showPreviewWindow:)) + if (action == @selector(addToQueue:) || action == @selector(addAllTitlesToQueue:) || + action == @selector(addTitlesToQueue:) || action == @selector(showAddPresetPanel:)) { return self.job && self.window.attachedSheet == nil; } @@ -751,14 +748,6 @@ [self titlePopUpChanged:nil]; - // Open preview window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreviewWindowIsOpen"]) - [self showPreviewWindow:nil]; - - // Open picture sizing window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PictureSizeWindowIsOpen"]) - [self showPicturePanel:nil]; - if (self.jobFromQueue) { [fPresetsView deselect]; @@ -1273,7 +1262,7 @@ */ - (IBAction)showPicturePanel:(id)sender { - [fPictureController showPictureWindow]; + [fPictureController showWindow:sender]; } - (IBAction)showPreviewWindow:(id)sender diff --git a/macosx/HBOutputPanelController.m b/macosx/HBOutputPanelController.m index 2fc5f3032..7555afe77 100644 --- a/macosx/HBOutputPanelController.m +++ b/macosx/HBOutputPanelController.m @@ -94,17 +94,8 @@ */ - (IBAction)showWindow:(id)sender { - if ([[self window] isVisible]) - { - [[self window] close]; - } - else - { - [textView scrollToEndOfDocument:self]; - [super showWindow:sender]; - - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"OutputPanelIsOpen"]; - } + [textView scrollToEndOfDocument:self]; + [super showWindow:sender]; } /** @@ -183,9 +174,4 @@ [self.outputFile clear]; } -- (void)windowWillClose:(NSNotification *)aNotification -{ - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"OutputPanelIsOpen"]; -} - @end diff --git a/macosx/HBPictureController.h b/macosx/HBPictureController.h index 6efbcbe5b..1460fa9e2 100644 --- a/macosx/HBPictureController.h +++ b/macosx/HBPictureController.h @@ -9,19 +9,11 @@ @class HBFilters; @class HBPicture; -@protocol HBPictureControllerDelegate - -- (IBAction)showPreviewWindow:(id)sender; - -@end - @interface HBPictureController : NSWindowController @property (nonatomic, readwrite, strong) HBFilters *filters; @property (nonatomic, readwrite, strong) HBPicture *picture; -@property (nonatomic, readwrite, unsafe_unretained) id delegate; - -- (void)showPictureWindow; +@property (nonatomic, readwrite, unsafe_unretained) NSWindowController *previewWindow; @end diff --git a/macosx/HBPictureController.m b/macosx/HBPictureController.m index 73c09f1e2..ba6dc9a24 100644 --- a/macosx/HBPictureController.m +++ b/macosx/HBPictureController.m @@ -315,30 +315,24 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; /** * Displays and brings the picture window to the front */ -- (void)showPictureWindow +- (void)showWindow:(id)sender { - if ([[self window] isVisible]) + if (self.window.isVisible) { - [[self window] close]; + [self.window close]; } else { - [self showWindow:self]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"PictureSizeWindowIsOpen"]; + [super showWindow:self]; } [self resizeInspectorForTab:nil]; [self adjustSizingDisplay:nil]; } -- (IBAction) showPreviewWindow: (id) sender +- (IBAction)showPreviewWindow:(id)sender { - [self.delegate showPreviewWindow:sender]; -} - -- (void) windowWillClose: (NSNotification *)aNotification -{ - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PictureSizeWindowIsOpen"]; + [self.previewWindow showWindow:sender]; } @end diff --git a/macosx/HBPreviewController.h b/macosx/HBPreviewController.h index 9dd2ccf7f..866c2a45d 100644 --- a/macosx/HBPreviewController.h +++ b/macosx/HBPreviewController.h @@ -8,16 +8,9 @@ @class HBPreviewGenerator; -@protocol HBPreviewControllerDelegate - -- (IBAction)showPicturePanel:(id)sender; - -@end - @interface HBPreviewController : NSWindowController -- (id)initWithDelegate:(id )delegate; - @property (nonatomic, strong) HBPreviewGenerator *generator; +@property (nonatomic, readwrite, unsafe_unretained) NSWindowController *pictureSettingsWindow; @end diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 4196819e7..92e779685 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -93,8 +93,6 @@ typedef enum ViewMode : NSUInteger { IBOutlet NSPopUpButton * fPreviewMovieLengthPopUp; } -@property (nonatomic, unsafe_unretained) id delegate; - @property (nonatomic, strong) CALayer *backLayer; @property (nonatomic, strong) CALayer *pictureLayer; @@ -130,12 +128,9 @@ typedef enum ViewMode : NSUInteger { @implementation HBPreviewController -- (id)initWithDelegate:(id )delegate +- (instancetype)init { - if (self = [super initWithWindowNibName:@"PicturePreview"]) - { - _delegate = delegate; - } + self = [super initWithWindowNibName:@"PicturePreview"]; return self; } @@ -211,6 +206,8 @@ typedef enum ViewMode : NSUInteger { [fEncodingControlBox setFrameOrigin:hudControlBoxOrigin]; [fMoviePlaybackControlBox setFrameOrigin:hudControlBoxOrigin]; + [self hideHud]; + /* set the current scale factor */ if( [[self window] respondsToSelector:@selector( backingScaleFactor )] ) self.backingScaleFactor = [[self window] backingScaleFactor]; @@ -239,6 +236,11 @@ typedef enum ViewMode : NSUInteger { [self switchViewToMode:ViewModePicturePreview]; [self displayPreview]; } + else + { + [self.pictureLayer setContents:nil]; + self.window.title = NSLocalizedString(@"Preview", nil); + } } - (void) reloadPreviews @@ -280,7 +282,6 @@ typedef enum ViewMode : NSUInteger { } [self.generator purgeImageCache]; - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PreviewWindowIsOpen"]; } - (void) windowDidChangeBackingProperties: (NSNotification *) notification @@ -613,6 +614,13 @@ typedef enum ViewMode : NSUInteger { } } +- (void)hideHud +{ + [fPictureControlBox setHidden:YES]; + [fMoviePlaybackControlBox setHidden:YES]; + [fEncodingControlBox setHidden:YES]; +} + - (void) startHudTimer { if (self.hudTimer) @@ -795,7 +803,7 @@ typedef enum ViewMode : NSUInteger { - (IBAction) showPictureSettings: (id) sender { - [self.delegate showPicturePanel:self]; + [self.pictureSettingsWindow showWindow:self]; } #pragma mark - diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index c52dd3b68..4d0905dc1 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -88,10 +88,6 @@ - (void)dealloc { - // clear the delegate so that windowWillClose is not attempted - if ([[self window] delegate] == self) - [[self window] setDelegate:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -107,20 +103,6 @@ [self.outlineView setAutoresizesOutlineColumn: NO]; } -- (void)windowWillClose:(NSNotification *)aNotification -{ - [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"QueueWindowIsOpen"]; -} - -/** - * Displays and brings the queue window to the front - */ -- (IBAction)showWindow:(id)sender -{ - [super showWindow:sender]; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"QueueWindowIsOpen"]; -} - #pragma mark Toolbar - (BOOL)validateMenuItem:(NSMenuItem *)menuItem -- 2.40.0