diff options
author | ritsuka <[email protected]> | 2014-12-28 08:14:32 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2014-12-28 08:14:32 +0000 |
commit | a03845e869297931544d4d8ba5a15678411df155 (patch) | |
tree | 020a76f4d45e2375f5fd61d5f083f51cb0176552 | |
parent | 3acda4f9eb6a6c23f0a9c627aba354433656f70d (diff) |
MacGui: move more things out of HBController.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6664 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/Controller.m | 55 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.xib | 11 | ||||
-rw-r--r-- | macosx/HBAudio.m | 1 | ||||
-rw-r--r-- | macosx/HBJob+UIAdditions.h | 3 | ||||
-rw-r--r-- | macosx/HBJob+UIAdditions.m | 72 | ||||
-rw-r--r-- | macosx/HBPicture+UIAdditions.m | 28 | ||||
-rw-r--r-- | macosx/HBQueueController.mm | 5 | ||||
-rw-r--r-- | macosx/HBRange+UIAdditions.h | 1 | ||||
-rw-r--r-- | macosx/HBRange+UIAdditions.m | 7 | ||||
-rw-r--r-- | macosx/HBRange.m | 20 |
10 files changed, 137 insertions, 66 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 947d9fca3..bc0da2012 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -547,12 +547,6 @@ [fPresetDrawer open:self]; } - /* Setup the start / stop popup */ - [fEncodeStartStopPopUp removeAllItems]; - [fEncodeStartStopPopUp addItemWithTitle: @"Chapters"]; - [fEncodeStartStopPopUp addItemWithTitle: @"Seconds"]; - [fEncodeStartStopPopUp addItemWithTitle: @"Frames"]; - // Align the start / stop widgets with the chapter popups NSPoint startPoint = [fSrcChapterStartPopUp frame].origin; startPoint.y += 2; @@ -565,38 +559,12 @@ [fSrcFrameStartEncodingField setFrameOrigin:startPoint]; [fSrcFrameEndEncodingField setFrameOrigin:endPoint]; - - /* Destination box*/ - NSMenuItem *menuItem; - [fDstFormatPopUp removeAllItems]; - for (const hb_container_t *container = hb_container_get_next(NULL); - container != NULL; - container = hb_container_get_next(container)) - { - NSString *title = nil; - if (container->format & HB_MUX_MASK_MP4) - { - title = @"MP4 File"; - } - else if (container->format & HB_MUX_MASK_MKV) - { - title = @"MKV File"; - } - else - { - title = [NSString stringWithUTF8String:container->name]; - } - menuItem = [[fDstFormatPopUp menu] addItemWithTitle:title - action:nil - keyEquivalent:@""]; - [menuItem setTag:container->format]; - } - /* Bottom */ - [fStatusField setStringValue: @""]; + // Bottom + [fStatusField setStringValue:@""]; - /* Register HBController's Window as a receiver for files/folders drag & drop operations */ - [fWindow registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; + // Register HBController's Window as a receiver for files/folders drag & drop operations + [fWindow registerForDraggedTypes:@[NSFilenamesPboardType]]; // Set up the preset drawer fPresetsView = [[HBPresetsViewController alloc] initWithPresetManager:presetManager]; @@ -1582,10 +1550,8 @@ { // Open a panel to let the user choose and update the text field NSSavePanel *panel = [NSSavePanel savePanel]; - - // We get the current file name and path from the destination field here - [panel setDirectoryURL:self.job.destURL.URLByDeletingLastPathComponent]; - [panel setNameFieldStringValue:self.job.destURL.lastPathComponent]; + panel.directoryURL = self.job.destURL.URLByDeletingLastPathComponent; + panel.nameFieldStringValue = self.job.destURL.lastPathComponent; [panel beginSheetModalForWindow:fWindow completionHandler:^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) @@ -2017,6 +1983,9 @@ static void queueFSEventStreamCallback( // Lets mark our new encode as 1 or "Encoding" queueJob.state = HBJobStateWorking; + + // We are done using the title, remove it from the job + queueJob.title = nil; [self saveQueueFileItem]; } else @@ -2270,12 +2239,6 @@ static void queueFSEventStreamCallback( //------------------------------------------------------------------------------------ - (IBAction)Cancel: (id)sender { - if (!fQueueController) return; - - /* - * No need to allow system sleep here as we'll either call Cancel: - * (which will take care of it) or resume right away - */ [self.queueCore pause]; // Which window to attach the sheet to? diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib index 0b3ce8117..ca054e290 100644 --- a/macosx/English.lproj/MainMenu.xib +++ b/macosx/English.lproj/MainMenu.xib @@ -120,6 +120,7 @@ </popUpButtonCell> <connections> <action selector="encodeStartStopPopUpChanged:" target="240" id="5520"/> + <binding destination="240" name="content" keyPath="self.job.range.types" id="nr8-sN-wpW"/> </connections> </popUpButton> <textField verticalHuggingPriority="750" id="5180"> @@ -213,7 +214,12 @@ </popUpButtonCell> <accessibility description="Format"/> <connections> - <binding destination="240" name="selectedTag" keyPath="self.job.container" id="ful-Gq-2mt"/> + <binding destination="240" name="selectedValue" keyPath="self.job.container" previousBinding="7Po-AA-KsM" id="brh-Ek-It1"> + <dictionary key="options"> + <string key="NSValueTransformerName">HBContainerTransformer</string> + </dictionary> + </binding> + <binding destination="240" name="content" keyPath="self.job.containers" id="7Po-AA-KsM"/> </connections> </popUpButton> <button verticalHuggingPriority="750" id="1562"> @@ -252,8 +258,9 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <binding destination="240" name="value" keyPath="self.job.destURL" id="f8U-7W-7gP"> + <binding destination="240" name="value" keyPath="self.job.destURL" id="Vmi-3b-LD5"> <dictionary key="options"> + <bool key="NSContinuouslyUpdatesValue" value="YES"/> <string key="NSValueTransformerName">HBURLTransformer</string> </dictionary> </binding> diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m index be50a51b3..d4129bde7 100644 --- a/macosx/HBAudio.m +++ b/macosx/HBAudio.m @@ -7,6 +7,7 @@ #import "HBAudio.h" #import "HBAudioController.h" +#import "HBJob.h" #import "NSCodingMacro.h" #import "hb.h" diff --git a/macosx/HBJob+UIAdditions.h b/macosx/HBJob+UIAdditions.h index c7d78ddc8..0d1e315d3 100644 --- a/macosx/HBJob+UIAdditions.h +++ b/macosx/HBJob+UIAdditions.h @@ -14,5 +14,8 @@ @end +@interface HBContainerTransformer : NSValueTransformer +@end + @interface HBURLTransformer : NSValueTransformer @end diff --git a/macosx/HBJob+UIAdditions.m b/macosx/HBJob+UIAdditions.m index 6e5bf030a..509668e17 100644 --- a/macosx/HBJob+UIAdditions.m +++ b/macosx/HBJob+UIAdditions.m @@ -31,8 +31,80 @@ return angles; } +- (NSArray *)containers +{ + NSMutableArray *containers = [NSMutableArray array]; + + for (const hb_container_t *container = hb_container_get_next(NULL); + container != NULL; + container = hb_container_get_next(container)) + { + NSString *title = nil; + if (container->format & HB_MUX_MASK_MP4) + { + title = NSLocalizedString(@"MP4 File", @""); + } + else if (container->format & HB_MUX_MASK_MKV) + { + title = NSLocalizedString(@"MKV File", @""); + } + else + { + title = [NSString stringWithUTF8String:container->name]; + } + [containers addObject:title]; + } + + return [[containers copy] autorelease]; +} + +@end + +@implementation HBContainerTransformer + ++ (Class)transformedValueClass +{ + return [NSString class]; +} + +- (id)transformedValue:(id)value +{ + int container = [value intValue]; + if (container & HB_MUX_MASK_MP4) + { + return NSLocalizedString(@"MP4 File", @""); + } + else if (container & HB_MUX_MASK_MKV) + { + return NSLocalizedString(@"MKV File", @""); + } + else + { + const char *name = hb_container_get_name(container); + if (name) + { + return @(name); + } + else + { + return nil; + } + } +} + ++ (BOOL)allowsReverseTransformation +{ + return YES; +} + +- (id)reverseTransformedValue:(id)value +{ + return @(hb_container_get_from_name([value UTF8String])); +} + @end + @implementation HBURLTransformer + (Class)transformedValueClass diff --git a/macosx/HBPicture+UIAdditions.m b/macosx/HBPicture+UIAdditions.m index e07e30667..60b761588 100644 --- a/macosx/HBPicture+UIAdditions.m +++ b/macosx/HBPicture+UIAdditions.m @@ -50,37 +50,39 @@ - (NSString *)info { - if (!self.title) + NSString *sizeInfo = @""; + + if (self.title) { - return @""; + hb_title_t *title = self.title.hb_title; + sizeInfo = [NSString stringWithFormat: + @"Source: %dx%d, ", + title->geometry.width, title->geometry.height]; } - NSString *sizeInfo; - hb_title_t *title = self.title.hb_title; - if (self.anamorphicMode == HB_ANAMORPHIC_STRICT) // Original PAR Implementation { sizeInfo = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict", - title->geometry.width, title->geometry.height, self.width, self.height, self.displayWidth, self.height]; + @"%@Output: %dx%d, Anamorphic: %dx%d Strict", + sizeInfo, self.width, self.height, self.displayWidth, self.height]; } else if (self.anamorphicMode == HB_ANAMORPHIC_LOOSE) // Loose Anamorphic { sizeInfo = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose", - title->geometry.width, title->geometry.height, self.width, self.height, self.displayWidth, self.height]; + @"%@Output: %dx%d, Anamorphic: %dx%d Loose", + sizeInfo, self.width, self.height, self.displayWidth, self.height]; } else if (self.anamorphicMode == HB_ANAMORPHIC_CUSTOM) // Custom Anamorphic { sizeInfo = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Custom", - title->geometry.width, title->geometry.height, self.width, self.height, self.displayWidth, self.height]; + @"%@Output: %dx%d, Anamorphic: %dx%d Custom", + sizeInfo, self.width, self.height, self.displayWidth, self.height]; } else // No Anamorphic { sizeInfo = [NSString stringWithFormat: - @"Source: %dx%d, Output: %dx%d", - title->geometry.width, title->geometry.height, self.width, self.height]; + @"%@Output: %dx%d", + sizeInfo, self.width, self.height]; } return sizeInfo; diff --git a/macosx/HBQueueController.mm b/macosx/HBQueueController.mm index e566532b7..e92b5bd09 100644 --- a/macosx/HBQueueController.mm +++ b/macosx/HBQueueController.mm @@ -52,9 +52,7 @@ int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item int fPendingCount; // Number of various kinds of job groups in fJobGroups. int fWorkingCount; - BOOL fJobGroupCountsNeedUpdating; - BOOL fCurrentJobPaneShown; // NO when fCurrentJobPane has been shifted out of view (see showCurrentJobPane) NSMutableIndexSet *fSavedExpandedItems; // used by save/restoreOutlineViewState to preserve which items are expanded NSMutableIndexSet *fSavedSelectedItems; // used by save/restoreOutlineViewState to preserve which items are selected @@ -241,9 +239,6 @@ // Don't allow autoresizing of main column, else the "delete" column will get // pushed out of view. [fOutlineView setAutoresizesOutlineColumn: NO]; - - // Show/hide UI elements - fCurrentJobPaneShown = NO; // it's shown in the nib } //------------------------------------------------------------------------------------ diff --git a/macosx/HBRange+UIAdditions.h b/macosx/HBRange+UIAdditions.h index dfac31905..82aacca18 100644 --- a/macosx/HBRange+UIAdditions.h +++ b/macosx/HBRange+UIAdditions.h @@ -10,5 +10,6 @@ @interface HBRange (UIAdditions) @property (nonatomic, readonly) NSArray *chapters; +@property (nonatomic, readonly) NSArray *types; @end diff --git a/macosx/HBRange+UIAdditions.m b/macosx/HBRange+UIAdditions.m index 3bcb31023..27b32081e 100644 --- a/macosx/HBRange+UIAdditions.m +++ b/macosx/HBRange+UIAdditions.m @@ -18,4 +18,11 @@ return chapters; } +- (NSArray *)types +{ + return @[NSLocalizedString(@"Chapters", @""), + NSLocalizedString(@"Seconds", @""), + NSLocalizedString(@"Frames", @"")]; +} + @end diff --git a/macosx/HBRange.m b/macosx/HBRange.m index 83df24b66..b632d4c34 100644 --- a/macosx/HBRange.m +++ b/macosx/HBRange.m @@ -31,6 +31,26 @@ return self; } +- (void)setChapterStart:(int)chapterStart +{ + if (chapterStart > self.chapterStop) + { + self.chapterStop = chapterStart; + } + + _chapterStart = chapterStart; +} + +- (void)setChapterStop:(int)chapterStop +{ + if (chapterStop < self.chapterStart) + { + self.chapterStart = chapterStop; + } + + _chapterStop = chapterStop; +} + - (NSString *)duration { if (self.type == HBRangeTypeChapters) |