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
This commit is contained in:
ritsuka 2015-04-07 16:14:30 +00:00
parent 3f537cb972
commit 13d0d1d579
10 changed files with 79 additions and 106 deletions

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14C68k" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14D113c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1060" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
<plugIn identifier="com.apple.QTKitIBPlugin" version="6250"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7528.3"/>
<plugIn identifier="com.apple.QTKitIBPlugin" version="7528.3"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBPreviewController">
@ -27,7 +27,7 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="HandBrake Preview" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="PreviewPanel">
<window title="Preview" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="PreviewPanel">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="221" y="837" width="490" height="360"/>

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C81f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14D113c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1060" identifier="macosx"/>
<development version="5100" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7528.3"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBPictureController">
@ -995,6 +995,11 @@
</tabViewItem>
</tabViewItems>
<connections>
<binding destination="-2" name="hidden" keyPath="self.picture" id="W8S-DU-3XL">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
<outlet property="delegate" destination="-2" id="420"/>
</connections>
</tabView>
@ -1007,14 +1012,35 @@
</buttonCell>
<connections>
<action selector="showPreviewWindow:" target="-2" id="273"/>
<binding destination="-2" name="hidden" keyPath="self.picture" id="zTd-kj-P5U">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNil</string>
</dictionary>
</binding>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="XmO-LR-1DQ">
<rect key="frame" x="258" y="122" width="118" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Nothing to inspect" id="buq-K6-Wvy">
<font key="font" metaFont="system"/>
<color key="textColor" name="highlightColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<binding destination="-2" name="hidden" keyPath="self.picture" id="00s-D3-JmF">
<dictionary key="options">
<string key="NSValueTransformerName">NSIsNotNil</string>
</dictionary>
</binding>
</connections>
</textField>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="hby-dR-NFK"/>
</connections>
<point key="canvasLocation" x="-1.5" y="238"/>
<point key="canvasLocation" x="-807.5" y="98"/>
</window>
<userDefaultsController representsSharedInstance="YES" id="vUw-ux-GVV"/>
</objects>

View File

@ -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;

View File

@ -29,7 +29,7 @@
#import "HBCore.h"
#import "HBJob.h"
@interface HBController () <HBPresetsViewControllerDelegate, HBPreviewControllerDelegate, HBPictureControllerDelegate, HBTitleSelectionDelegate>
@interface HBController () <HBPresetsViewControllerDelegate, HBTitleSelectionDelegate>
@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

View File

@ -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

View File

@ -9,19 +9,11 @@
@class HBFilters;
@class HBPicture;
@protocol HBPictureControllerDelegate <NSObject>
- (IBAction)showPreviewWindow:(id)sender;
@end
@interface HBPictureController : NSWindowController <NSWindowDelegate>
@property (nonatomic, readwrite, strong) HBFilters *filters;
@property (nonatomic, readwrite, strong) HBPicture *picture;
@property (nonatomic, readwrite, unsafe_unretained) id <HBPictureControllerDelegate> delegate;
- (void)showPictureWindow;
@property (nonatomic, readwrite, unsafe_unretained) NSWindowController *previewWindow;
@end

View File

@ -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

View File

@ -8,16 +8,9 @@
@class HBPreviewGenerator;
@protocol HBPreviewControllerDelegate <NSObject>
- (IBAction)showPicturePanel:(id)sender;
@end
@interface HBPreviewController : NSWindowController <NSWindowDelegate>
- (id)initWithDelegate:(id <HBPreviewControllerDelegate>)delegate;
@property (nonatomic, strong) HBPreviewGenerator *generator;
@property (nonatomic, readwrite, unsafe_unretained) NSWindowController *pictureSettingsWindow;
@end

View File

@ -93,8 +93,6 @@ typedef enum ViewMode : NSUInteger {
IBOutlet NSPopUpButton * fPreviewMovieLengthPopUp;
}
@property (nonatomic, unsafe_unretained) id <HBPreviewControllerDelegate> delegate;
@property (nonatomic, strong) CALayer *backLayer;
@property (nonatomic, strong) CALayer *pictureLayer;
@ -130,12 +128,9 @@ typedef enum ViewMode : NSUInteger {
@implementation HBPreviewController
- (id)initWithDelegate:(id <HBPreviewControllerDelegate>)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 -

View File

@ -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