diff options
author | ritsuka <[email protected]> | 2014-08-18 06:22:02 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2014-08-18 06:22:02 +0000 |
commit | 31f0491273b5620bc819bd29cc4157d219bb932d (patch) | |
tree | a2d34edaf2266c26b1950e9d76fb72211611e9c5 /macosx | |
parent | 91e1ce781fdca4a130a842e5843462550977f802 (diff) |
MacGui: general clean up of HBQueueController: removed unused UI elements and code, moved the toolbar to the xib, update the obj-c syntax.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6306 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/English.lproj/Queue.xib | 208 | ||||
-rw-r--r-- | macosx/HBQueueController.h | 103 | ||||
-rw-r--r-- | macosx/HBQueueController.mm | 472 |
3 files changed, 270 insertions, 513 deletions
diff --git a/macosx/English.lproj/Queue.xib b/macosx/English.lproj/Queue.xib index 728ea2eab..116eebee8 100644 --- a/macosx/English.lproj/Queue.xib +++ b/macosx/English.lproj/Queue.xib @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13F7" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13F14" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <dependencies> <deployment version="1060" identifier="macosx"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/> @@ -10,7 +10,6 @@ <outlet property="fOutlineView" destination="2597" id="2601"/> <outlet property="fProgressTextField" destination="2646" id="2648"/> <outlet property="fQueueCountField" destination="2511" id="2564"/> - <outlet property="fQueuePane" destination="2547" id="2561"/> <outlet property="window" destination="2576" id="2645"/> </connections> </customObject> @@ -26,124 +25,74 @@ <rect key="frame" x="0.0" y="0.0" width="574" height="423"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <customView id="2547"> - <rect key="frame" x="0.0" y="0.0" width="574" height="358"/> + <scrollView horizontalLineScroll="19" horizontalPageScroll="0.0" verticalLineScroll="19" verticalPageScroll="0.0" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="2596"> + <rect key="frame" x="20" y="20" width="534" height="338"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <subviews> - <button verticalHuggingPriority="750" id="2622"> - <rect key="frame" x="6" y="-25" width="159" height="16"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <buttonCell key="cell" type="smallSquare" title="quick way to intercept delete key" bezelStyle="smallSquare" alignment="center" controlSize="mini" borderStyle="border" inset="2" id="2642"> - <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> - <font key="font" metaFont="miniSystem"/> - <string key="keyEquivalent"></string> - </buttonCell> - <connections> - <action selector="removeSelectedQueueItem:" target="-2" id="2623"/> - </connections> - </button> - <textField hidden="YES" verticalHuggingPriority="750" id="2615"> - <rect key="frame" x="245" y="1" width="46" height="14"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Spacing" id="2641"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - </textField> - <textField hidden="YES" verticalHuggingPriority="750" id="2614"> - <rect key="frame" x="17" y="0.0" width="38" height="14"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Indent" id="2640"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> - </textFieldCell> - </textField> - <slider hidden="YES" verticalHuggingPriority="750" id="2611"> - <rect key="frame" x="296" y="2" width="80" height="16"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <sliderCell key="cell" controlSize="mini" continuous="YES" alignment="left" maxValue="10" doubleValue="3" tickMarkPosition="above" numberOfTickMarks="11" allowsTickMarkValuesOnly="YES" sliderType="linear" id="2639"> - <font key="font" size="12" name="Helvetica"/> - </sliderCell> - </slider> - <slider hidden="YES" verticalHuggingPriority="750" id="2610"> - <rect key="frame" x="60" y="1" width="180" height="16"/> - <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> - <sliderCell key="cell" controlSize="mini" continuous="YES" alignment="left" maxValue="30" doubleValue="2" tickMarkPosition="above" numberOfTickMarks="31" allowsTickMarkValuesOnly="YES" sliderType="linear" id="2638"> - <font key="font" size="12" name="Helvetica"/> - </sliderCell> - </slider> - <scrollView horizontalLineScroll="19" horizontalPageScroll="0.0" verticalLineScroll="19" verticalPageScroll="0.0" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="2596"> - <rect key="frame" x="20" y="20" width="534" height="338"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <clipView key="contentView" id="B5m-TR-ErO"> - <rect key="frame" x="1" y="1" width="532" height="336"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> - <subviews> - <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="2624" id="2597" customClass="HBQueueOutlineView"> - <rect key="frame" x="0.0" y="0.0" width="532" height="336"/> - <autoresizingMask key="autoresizingMask"/> - <size key="intercellSpacing" width="3" height="2"/> - <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> - <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> - <tableColumns> - <tableColumn identifier="icon" width="38" minWidth="38" maxWidth="38" id="2624"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> - </tableHeaderCell> - <imageCell key="dataCell" refusesFirstResponder="YES" alignment="left" animates="YES" imageAlignment="topRight" imageScaling="proportionallyDown" id="2625"/> - <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> - </tableColumn> - <tableColumn identifier="desc" editable="NO" width="465" minWidth="40" maxWidth="5000" id="2599"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> - </tableHeaderCell> - <textFieldCell key="dataCell" selectable="YES" editable="YES" alignment="left" id="2609" customClass="HBImageAndTextCell"> - <font key="font" metaFont="cellTitle"/> - <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> - <connections> - <outlet property="menu" destination="2649" id="2653"/> - </connections> - </textFieldCell> - <tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/> - </tableColumn> - <tableColumn identifier="action" editable="NO" width="20" minWidth="8" maxWidth="20" id="2604"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="center"> - <font key="font" metaFont="smallSystem"/> - <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> - <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> - </tableHeaderCell> - <buttonCell key="dataCell" type="square" bezelStyle="shadowlessSquare" image="Delete" imagePosition="above" alignment="center" inset="2" id="2605"> - <behavior key="behavior" lightByContents="YES"/> - <font key="font" metaFont="cellTitle"/> - </buttonCell> - </tableColumn> - </tableColumns> - <connections> - <outlet property="dataSource" destination="-2" id="2602"/> - <outlet property="delegate" destination="-2" id="2603"/> - </connections> - </outlineView> - </subviews> - <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> - </clipView> - <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="2644"> - <rect key="frame" x="-100" y="-100" width="282" height="15"/> + <clipView key="contentView" id="B5m-TR-ErO"> + <rect key="frame" x="1" y="1" width="532" height="336"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="2624" id="2597" customClass="HBQueueOutlineView"> + <rect key="frame" x="0.0" y="0.0" width="532" height="336"/> <autoresizingMask key="autoresizingMask"/> - </scroller> - <scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="2643"> - <rect key="frame" x="517" y="1" width="16" height="336"/> - <autoresizingMask key="autoresizingMask"/> - </scroller> - </scrollView> - </subviews> - </customView> + <size key="intercellSpacing" width="3" height="2"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> + <tableColumns> + <tableColumn identifier="icon" width="38" minWidth="38" maxWidth="38" id="2624"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> + </tableHeaderCell> + <imageCell key="dataCell" refusesFirstResponder="YES" alignment="left" animates="YES" imageAlignment="topRight" imageScaling="proportionallyDown" id="2625"/> + <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + </tableColumn> + <tableColumn identifier="desc" editable="NO" width="465" minWidth="40" maxWidth="5000" id="2599"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/> + </tableHeaderCell> + <textFieldCell key="dataCell" selectable="YES" editable="YES" alignment="left" id="2609" customClass="HBImageAndTextCell"> + <font key="font" metaFont="cellTitle"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + <connections> + <outlet property="menu" destination="2649" id="2653"/> + </connections> + </textFieldCell> + <tableColumnResizingMask key="resizingMask" resizeWithTable="YES"/> + </tableColumn> + <tableColumn identifier="action" editable="NO" width="20" minWidth="8" maxWidth="20" id="2604"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="center"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> + </tableHeaderCell> + <buttonCell key="dataCell" type="square" bezelStyle="shadowlessSquare" image="Delete" imagePosition="above" alignment="center" inset="2" id="2605"> + <behavior key="behavior" lightByContents="YES"/> + <font key="font" metaFont="cellTitle"/> + </buttonCell> + </tableColumn> + </tableColumns> + <connections> + <outlet property="dataSource" destination="-2" id="2602"/> + <outlet property="delegate" destination="-2" id="2603"/> + </connections> + </outlineView> + </subviews> + <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> + </clipView> + <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="2644"> + <rect key="frame" x="-100" y="-100" width="282" height="15"/> + <autoresizingMask key="autoresizingMask"/> + </scroller> + <scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="2643"> + <rect key="frame" x="517" y="1" width="16" height="336"/> + <autoresizingMask key="autoresizingMask"/> + </scroller> + </scrollView> <textField verticalHuggingPriority="750" id="2511"> <rect key="frame" x="17" y="399" width="540" height="14"/> <autoresizingMask key="autoresizingMask" flexibleMinY="YES"/> @@ -164,6 +113,27 @@ </textField> </subviews> </view> + <toolbar key="toolbar" implicitIdentifier="0FE76B40-49B7-48AE-B44E-D1B8034BC88A" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="ZVb-ld-0UP"> + <allowedToolbarItems> + <toolbarItem implicitItemIdentifier="609C5CFE-D854-4567-9CC2-70E109CBA332" explicitItemIdentifier="HBQueueStartCancelToolbarIdentifier" label="Start" paletteLabel="Start/Cancel" toolTip="Start Encoding" tag="-1" image="encode" id="SX6-mq-Hck"> + <connections> + <action selector="toggleStartCancel:" target="-2" id="ABS-fA-RwJ"/> + </connections> + </toolbarItem> + <toolbarItem implicitItemIdentifier="7DB01500-5492-42BC-BDEE-55E9EF3765A1" explicitItemIdentifier="HBQueuePauseResumeToolbarIdentifier" label="Pause" paletteLabel="Pause/Resume" toolTip="Pause Encoding" tag="-1" image="pauseencode" id="s7o-pK-heI"> + <connections> + <action selector="togglePauseResume:" target="-2" id="bmr-hx-loD"/> + </connections> + </toolbarItem> + <toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="rHN-a0-oZQ"/> + <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="QuV-M8-cet"/> + </allowedToolbarItems> + <defaultToolbarItems> + <toolbarItem reference="SX6-mq-Hck"/> + <toolbarItem reference="s7o-pK-heI"/> + <toolbarItem reference="QuV-M8-cet"/> + </defaultToolbarItems> + </toolbar> <connections> <outlet property="delegate" destination="-2" id="2579"/> </connections> @@ -193,5 +163,7 @@ </objects> <resources> <image name="Delete" width="16" height="16"/> + <image name="encode" width="24" height="24"/> + <image name="pauseencode" width="24" height="24"/> </resources> </document> diff --git a/macosx/HBQueueController.h b/macosx/HBQueueController.h index 3925eb4e6..19266ed40 100644 --- a/macosx/HBQueueController.h +++ b/macosx/HBQueueController.h @@ -10,12 +10,6 @@ @class HBController; - -#define HB_QUEUE_DRAGGING 0 // <--- NOT COMPLETELY FUNCTIONAL YET -#define HB_OUTLINE_METRIC_CONTROLS 0 // for tweaking the outline cell spacings - - - //------------------------------------------------------------------------------------ // As usual, we need to subclass NSOutlineView to handle a few special cases: // @@ -35,103 +29,18 @@ // drag an image of the queue's icon and desc columns. @interface HBQueueOutlineView : NSOutlineView -{ -BOOL fIsDragging; - -} - -- (BOOL) isDragging; +@property (nonatomic, readonly) BOOL isDragging; @end - - - @interface HBQueueController : NSWindowController <NSToolbarDelegate, NSWindowDelegate> -{ - hb_handle_t *fQueueEncodeLibhb; // reference to libhb - HBController *fHBController; // reference to HBController - NSMutableArray *fJobGroups; // mirror image of the queue array from controller.mm - - int pidNum; // Records the PID number from HBController for this instance - int fEncodingQueueItem; // corresponds to the index of fJobGroups encoding item - int fPendingCount; // Number of various kinds of job groups in fJobGroups. - int fCompletedCount; - int fCanceledCount; - 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 -#if HB_QUEUE_DRAGGING - NSArray *fDraggedNodes; -#endif - NSTimer *fAnimationTimer; // animates the icon of the current job in the queue outline view - int fAnimationIndex; // used to generate name of image used to animate the current job in the queue outline view - - // +------------------window-------------------+ - // |+-------------fCurrentJobPane-------------+| - // || || - // || || - // || || - // |+-----------------------------------------+| - // |+---------------fQueuePane----------------+| - // || || - // || || - // || || - // || || - // || || - // || || - // || || - // |+-----------------------------------------+| - // +-------------------------------------------+ - - // fCurrentJobPane - visible only when processing a job - IBOutlet NSView *fCurrentJobPane; - IBOutlet NSImageView *fJobIconView; - IBOutlet NSTextField *fJobDescTextField; - IBOutlet NSProgressIndicator *fProgressBar; - IBOutlet NSTextField *fProgressTextField; - - // fQueuePane - always visible; fills entire window when fCurrentJobPane is hidden - IBOutlet NSView *fQueuePane; - IBOutlet HBQueueOutlineView *fOutlineView; - IBOutlet NSTextField *fQueueCountField; - NSArray *fDraggedNodes; - BOOL fIsDragging; -#if HB_OUTLINE_METRIC_CONTROLS - IBOutlet NSSlider *fIndentation; // debug - IBOutlet NSSlider *fSpacing; // debug -#endif - - // Text Styles - NSMutableParagraphStyle *ps; - NSDictionary *detailAttr; - NSDictionary *detailBoldAttr; - NSDictionary *titleAttr; - NSDictionary *shortHeightAttr; -} - (void)setPidNum: (int)myPidnum; - (void)setHandle: (hb_handle_t *)handle; - (void)setHBController: (HBController *)controller; -- (void)setupToolbar; - - (void)setQueueArray: (NSMutableArray *)QueueFileArray; -- (id)outlineView:(NSOutlineView *)fOutlineView child:(NSInteger)index ofItem:(id)item; - -- (BOOL)outlineView:(NSOutlineView *)fOutlineView isItemExpandable:(id)item; - -- (BOOL)outlineView:(NSOutlineView *)fOutlineView shouldExpandItem:(id)item; - -- (NSInteger)outlineView:(NSOutlineView *)fOutlineView numberOfChildrenOfItem:(id)item; - -- (id)outlineView:(NSOutlineView *)fOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; - -- (void)outlineView:(NSOutlineView *)fOutlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item; /* Animate the icon for the current encode */ - (void) animateWorkingEncodeIconInQueue; @@ -141,19 +50,9 @@ BOOL fIsDragging; - (IBAction)showQueueWindow: (id)sender; - /* control encodes in the window */ - (IBAction)removeSelectedQueueItem: (id)sender; - (IBAction)revealSelectedQueueItem: (id)sender; - (IBAction)editSelectedQueueItem: (id)sender; -#if HB_OUTLINE_METRIC_CONTROLS -- (IBAction)imageSpacingChanged: (id)sender; -- (IBAction)indentChanged: (id)sender; -#endif - - - - - @end diff --git a/macosx/HBQueueController.mm b/macosx/HBQueueController.mm index e9f08fc66..ef2fb3889 100644 --- a/macosx/HBQueueController.mm +++ b/macosx/HBQueueController.mm @@ -10,13 +10,11 @@ #import "HBUtilities.h" #define HB_ROW_HEIGHT_TITLE_ONLY 17.0 -#define HB_ROW_HEIGHT_FULL_DESCRIPTION 200.0 + // Pasteboard type for or drag operations -#define DragDropSimplePboardType @"MyCustomOutlineViewPboardType" +#define DragDropSimplePboardType @"HBQueueCustomOutlineViewPboardType" -//------------------------------------------------------------------------------------ #pragma mark - -//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ // NSMutableAttributedString (HBAdditions) @@ -29,10 +27,9 @@ @implementation NSMutableAttributedString (HBAdditions) - (void) appendString: (NSString*)aString withAttributes: (NSDictionary *)aDictionary { - NSAttributedString * s = [[[NSAttributedString alloc] - initWithString: aString - attributes: aDictionary] autorelease]; - [self appendAttributedString: s]; + NSAttributedString *s = [[[NSAttributedString alloc] initWithString:aString + attributes:aDictionary] autorelease]; + [self appendAttributedString:s]; } @end @@ -48,44 +45,89 @@ [super viewDidEndLiveResize]; } - - /* This should be for dragging, we take this info from the presets right now */ -- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent*)dragEvent offset:(NSPointPointer)dragImageOffset +- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows + tableColumns:(NSArray *)tableColumns + event:(NSEvent *)dragEvent + offset:(NSPointPointer)dragImageOffset { - fIsDragging = YES; + _isDragging = YES; // By default, NSTableView only drags an image of the first column. Change this to // drag an image of the queue's icon and desc and action columns. - NSArray * cols = [NSArray arrayWithObjects: [self tableColumnWithIdentifier:@"desc"], [self tableColumnWithIdentifier:@"icon"],[self tableColumnWithIdentifier:@"action"], nil]; + NSArray * cols = @[[self tableColumnWithIdentifier:@"desc"], [self tableColumnWithIdentifier:@"icon"],[self tableColumnWithIdentifier:@"action"]]; return [super dragImageForRowsWithIndexes:dragRows tableColumns:cols event:dragEvent offset:dragImageOffset]; } - - -- (void) mouseDown:(NSEvent *)theEvent +- (void)mouseDown:(NSEvent *)theEvent { [super mouseDown:theEvent]; - fIsDragging = NO; + _isDragging = NO; } - - -- (BOOL) isDragging; +- (void)keyDown:(NSEvent *)event { - return fIsDragging; + id delegate = [self delegate]; + + unichar key = [[event charactersIgnoringModifiers] characterAtIndex:0]; + if ((key == NSDeleteCharacter || key == NSDeleteFunctionKey) && + [delegate respondsToSelector:@selector(removeSelectedQueueItem:)]) + { + if ([self selectedRow] == -1) + { + NSBeep(); + } + else + { + [delegate removeSelectedQueueItem:self]; + } + return; + } + else + { + [super keyDown:event]; + } } @end -#pragma mark Toolbar Identifiers -// Toolbar identifiers -static NSString* HBQueueToolbar = @"HBQueueToolbar1"; -static NSString* HBQueueStartCancelToolbarIdentifier = @"HBQueueStartCancelToolbarIdentifier"; -static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseResumeToolbarIdentifier"; - #pragma mark - +@interface HBQueueController () +{ + hb_handle_t *fQueueEncodeLibhb; // reference to libhb + HBController *fHBController; // reference to HBController + NSMutableArray *fJobGroups; // mirror image of the queue array from controller.mm + + int pidNum; // Records the PID number from HBController for this instance + 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 + + NSTimer *fAnimationTimer; // animates the icon of the current job in the queue outline view + int fAnimationIndex; // used to generate name of image used to animate the current job in the queue outline view + + IBOutlet NSTextField *fProgressTextField; + + IBOutlet HBQueueOutlineView *fOutlineView; + IBOutlet NSTextField *fQueueCountField; + NSArray *fDraggedNodes; + + // Text Styles + NSMutableParagraphStyle *ps; + NSDictionary *detailAttr; + NSDictionary *detailBoldAttr; + NSDictionary *titleAttr; + NSDictionary *shortHeightAttr; +} + +@end + @implementation HBQueueController //------------------------------------------------------------------------------------ @@ -103,11 +145,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe [self window]; // Our defaults - [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: - @"NO", @"QueueWindowIsOpen", - @"NO", @"QueueShowsDetail", - @"YES", @"QueueShowsJobsAsGroups", - nil]]; + [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"QueueWindowIsOpen": @"NO"}]; fJobGroups = [[NSMutableArray arrayWithCapacity:0] retain]; @@ -117,21 +155,15 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe return self; } -- (void)setQueueArray: (NSMutableArray *)QueueFileArray +- (void)setQueueArray:(NSMutableArray *)QueueFileArray { [fJobGroups setArray:QueueFileArray]; - fIsDragging = NO; - /* First stop any timer working now */ - //[self stopAnimatingCurrentJobGroupInQueue]; + [fOutlineView reloadData]; - - - + /* lets get the stats on the status of the queue array */ fPendingCount = 0; - fCompletedCount = 0; - fCanceledCount = 0; fWorkingCount = 0; /* We use a number system to set the encode status of the queue item @@ -143,35 +175,27 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe */ int i = 0; NSDictionary *thisQueueDict = nil; - for(id tempObject in fJobGroups) + for (id tempObject in fJobGroups) { thisQueueDict = tempObject; - if ([[thisQueueDict objectForKey:@"Status"] intValue] == 0) // Completed - { - fCompletedCount++; - } - if ([[thisQueueDict objectForKey:@"Status"] intValue] == 1) // being encoded + if ([thisQueueDict[@"Status"] intValue] == 1) // being encoded { fWorkingCount++; /* we have an encoding job so, lets start the animation timer */ - if ([thisQueueDict objectForKey:@"EncodingPID"] && [[thisQueueDict objectForKey:@"EncodingPID"] intValue] == pidNum) + if (thisQueueDict[@"EncodingPID"] && [thisQueueDict[@"EncodingPID"] intValue] == pidNum) { fEncodingQueueItem = i; } } - if ([[thisQueueDict objectForKey:@"Status"] intValue] == 2) // pending + if ([thisQueueDict[@"Status"] intValue] == 2) // pending { fPendingCount++; } - if ([[thisQueueDict objectForKey:@"Status"] intValue] == 3) // cancelled - { - fCanceledCount++; - } i++; } /* Set the queue status field in the queue window */ - NSMutableString * string; + NSMutableString *string; if (fPendingCount == 0) { string = [NSMutableString stringWithFormat: NSLocalizedString( @"No encode pending", @"" )]; @@ -193,11 +217,9 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe * instead of running another timer here polling libhb * for encoding status */ -- (void)setQueueStatusString: (NSString *)statusString +- (void)setQueueStatusString:(NSString *)statusString { - [fProgressTextField setStringValue:statusString]; - } //------------------------------------------------------------------------------------ @@ -259,42 +281,24 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe [self startAnimatingCurrentWorkingEncodeInQueue]; } - - //------------------------------------------------------------------------------------ -// awakeFromNib +// windowDidLoad //------------------------------------------------------------------------------------ -- (void)awakeFromNib +- (void)windowDidLoad { - [self setupToolbar]; - - if( ![[self window] setFrameUsingName:@"Queue"] ) - [[self window] center]; - [self setWindowFrameAutosaveName:@"Queue"]; - /* lets setup our queue list outline view for drag and drop here */ - [fOutlineView registerForDraggedTypes: [NSArray arrayWithObject:DragDropSimplePboardType] ]; + [fOutlineView registerForDraggedTypes: @[DragDropSimplePboardType] ]; [fOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES]; [fOutlineView setVerticalMotionCanBeginDrag: YES]; - // Don't allow autoresizing of main column, else the "delete" column will get // pushed out of view. [fOutlineView setAutoresizesOutlineColumn: NO]; -#if HB_OUTLINE_METRIC_CONTROLS - [fIndentation setHidden: NO]; - [fSpacing setHidden: NO]; - [fIndentation setIntegerValue:[fOutlineView indentationPerLevel]]; // debug - [fSpacing setIntegerValue:3]; // debug -#endif - // Show/hide UI elements fCurrentJobPaneShown = NO; // it's shown in the nib - } - //------------------------------------------------------------------------------------ // windowWillClose //------------------------------------------------------------------------------------ @@ -307,109 +311,6 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe #pragma mark Toolbar //------------------------------------------------------------------------------------ -// setupToolbar -//------------------------------------------------------------------------------------ -- (void)setupToolbar -{ - // Create a new toolbar instance, and attach it to our window - NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: HBQueueToolbar] autorelease]; - - // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults - [toolbar setAllowsUserCustomization: YES]; - [toolbar setAutosavesConfiguration: YES]; - [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel]; - - // We are the delegate - [toolbar setDelegate: self]; - - // Attach the toolbar to our window - [[self window] setToolbar:toolbar]; -} - -//------------------------------------------------------------------------------------ -// toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar: -//------------------------------------------------------------------------------------ -- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar - itemForItemIdentifier:(NSString *)itemIdentifier - willBeInsertedIntoToolbar:(BOOL)flag -{ - // Required delegate method: Given an item identifier, this method returns an item. - // The toolbar will use this method to obtain toolbar items that can be displayed - // in the customization sheet, or in the toolbar itself. - - NSToolbarItem *toolbarItem = nil; - - if ([itemIdentifier isEqual: HBQueueStartCancelToolbarIdentifier]) - { - toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease]; - - // Set the text label to be displayed in the toolbar and customization palette - [toolbarItem setLabel: @"Start"]; - [toolbarItem setPaletteLabel: @"Start/Cancel"]; - - // Set up a reasonable tooltip, and image - [toolbarItem setToolTip: @"Start Encoding"]; - [toolbarItem setImage: [NSImage imageNamed: @"encode"]]; - - // Tell the item what message to send when it is clicked - [toolbarItem setTarget: self]; - [toolbarItem setAction: @selector(toggleStartCancel:)]; - } - - if ([itemIdentifier isEqual: HBQueuePauseResumeToolbarIdentifier]) - { - toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease]; - - // Set the text label to be displayed in the toolbar and customization palette - [toolbarItem setLabel: @"Pause"]; - [toolbarItem setPaletteLabel: @"Pause/Resume"]; - - // Set up a reasonable tooltip, and image - [toolbarItem setToolTip: @"Pause Encoding"]; - [toolbarItem setImage: [NSImage imageNamed: @"pauseencode"]]; - - // Tell the item what message to send when it is clicked - [toolbarItem setTarget: self]; - [toolbarItem setAction: @selector(togglePauseResume:)]; - } - - return toolbarItem; -} - -//------------------------------------------------------------------------------------ -// toolbarDefaultItemIdentifiers: -//------------------------------------------------------------------------------------ -- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar -{ - // Required delegate method: Returns the ordered list of items to be shown in the - // toolbar by default. - - return [NSArray arrayWithObjects: - HBQueueStartCancelToolbarIdentifier, - HBQueuePauseResumeToolbarIdentifier, - nil]; -} - -//------------------------------------------------------------------------------------ -// toolbarAllowedItemIdentifiers: -//------------------------------------------------------------------------------------ -- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar -{ - // Required delegate method: Returns the list of all allowed items by identifier. - // By default, the toolbar does not assume any items are allowed, even the - // separator. So, every allowed item must be explicitly listed. - - return [NSArray arrayWithObjects: - HBQueueStartCancelToolbarIdentifier, - HBQueuePauseResumeToolbarIdentifier, - NSToolbarCustomizeToolbarItemIdentifier, - NSToolbarFlexibleSpaceItemIdentifier, - NSToolbarSpaceItemIdentifier, - NSToolbarSeparatorItemIdentifier, - nil]; -} - -//------------------------------------------------------------------------------------ // validateToolbarItem: //------------------------------------------------------------------------------------ - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem @@ -424,7 +325,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe hb_state_t s; hb_get_state2 (fQueueEncodeLibhb, &s); - if ([[toolbarItem itemIdentifier] isEqual: HBQueueStartCancelToolbarIdentifier]) + if ([[toolbarItem itemIdentifier] isEqualToString:@"HBQueueStartCancelToolbarIdentifier"]) { if ((s.state == HB_STATE_PAUSED) || (s.state == HB_STATE_WORKING) || (s.state == HB_STATE_MUXING)) { @@ -451,7 +352,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe } } - if ([[toolbarItem itemIdentifier] isEqual: HBQueuePauseResumeToolbarIdentifier]) + if ([[toolbarItem itemIdentifier] isEqualToString:@"HBQueuePauseResumeToolbarIdentifier"]) { if (s.state == HB_STATE_PAUSED) { @@ -498,7 +399,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe * to let them decide to cancel it first, then if they do, we can come back and * remove it */ - if ([[[fJobGroups objectAtIndex:row] objectForKey:@"Status"] integerValue] == 1) + if ([fJobGroups[row][@"Status"] integerValue] == 1) { /* We pause the encode here so that it doesn't finish right after and then * screw up the sync while the window is open @@ -565,15 +466,14 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe { while (row != NSNotFound) { - NSMutableDictionary *queueItemToOpen = [fOutlineView itemAtRow: row]; - [[NSWorkspace sharedWorkspace] selectFile:[queueItemToOpen objectForKey:@"DestinationPath"] inFileViewerRootedAtPath:nil]; + NSMutableDictionary *queueItemToOpen = [fOutlineView itemAtRow: row]; + [[NSWorkspace sharedWorkspace] selectFile:queueItemToOpen[@"DestinationPath"] inFileViewerRootedAtPath:nil]; row = [selectedRows indexGreaterThanIndex: row]; } } } - //------------------------------------------------------------------------------------ // Starts or cancels the processing of jobs depending on the current state //------------------------------------------------------------------------------------ @@ -585,7 +485,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe hb_get_state2 (fQueueEncodeLibhb, &s); if ((s.state == HB_STATE_PAUSED) || (s.state == HB_STATE_WORKING) || (s.state == HB_STATE_MUXING)) - [fHBController Cancel: fQueuePane]; // sender == fQueuePane so that warning alert shows up on queue window + [fHBController Cancel: self]; else if (fPendingCount > 0) [fHBController Rip: NULL]; @@ -627,7 +527,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe * to let them decide to cancel it first, then if they do, we can come back and * remove it */ - if ([[[fJobGroups objectAtIndex:row] objectForKey:@"Status"] integerValue] == 1) + if ([fJobGroups[row][@"Status"] integerValue] == 1) { /* We pause the encode here so that it doesn't finish right after and then * screw up the sync while the window is open @@ -652,20 +552,17 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe } else { - /* since we are not a currently encoding item, we can just be cancelled */ - [fHBController rescanQueueItemToMainWindow:[[fJobGroups objectAtIndex:row] objectForKey:@"SourcePath"] - scanTitleNum:[[[fJobGroups objectAtIndex:row] objectForKey:@"TitleNumber"] integerValue] - selectedQueueItem:row]; + /* since we are not a currently encoding item, we can just be cancelled */ + [fHBController rescanQueueItemToMainWindow:fJobGroups[row][@"SourcePath"] + scanTitleNum:[fJobGroups[row][@"TitleNumber"] integerValue] + selectedQueueItem:row]; } } #pragma mark - -#pragma mark Animate Endcoding Item - - - +#pragma mark Animate Encoding Item //------------------------------------------------------------------------------------ // Starts animating the job icon of the currently processing job in the queue outline @@ -744,7 +641,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe insertIndex--; } - id object = [[array objectAtIndex:removeIndex] retain]; + id object = [array[removeIndex] retain]; [array removeObjectAtIndex:removeIndex]; [array insertObject:object atIndex:insertIndex]; [object release]; @@ -761,7 +658,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe - (id)outlineView:(NSOutlineView *)fOutlineView child:(NSInteger)index ofItem:(id)item { if (item == nil) - return [fJobGroups objectAtIndex:index]; + return fJobGroups[index]; // We are only one level deep, so we can't be asked about children NSAssert (NO, @"HBQueueController outlineView:child:ofItem: can't handle nested items."); @@ -779,7 +676,7 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe { // Our outline view has no levels, but we can still expand every item. Doing so // just makes the row taller. See heightOfRowByItem below. -return ![(HBQueueOutlineView*)outlineView isDragging]; + return ![(HBQueueOutlineView *)outlineView isDragging]; } - (NSInteger)outlineView:(NSOutlineView *)fOutlineView numberOfChildrenOfItem:(id)item @@ -794,14 +691,14 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; - (void)outlineViewItemDidCollapse:(NSNotification *)notification { - id item = [[notification userInfo] objectForKey:@"NSObject"]; + id item = [notification userInfo][@"NSObject"]; NSInteger row = [fOutlineView rowForItem:item]; [fOutlineView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(row,1)]]; } - (void)outlineViewItemDidExpand:(NSNotification *)notification { - id item = [[notification userInfo] objectForKey:@"NSObject"]; + id item = [notification userInfo][@"NSObject"]; NSInteger row = [fOutlineView rowForItem:item]; [fOutlineView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(row,1)]]; } @@ -811,7 +708,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; if ([outlineView isItemExpanded: item]) { // It is important to use a constant value when calculating the height. Querying the tableColumn width will not work, since it dynamically changes as the user resizes -- however, we don't get a notification that the user "did resize" it until after the mouse is let go. We use the latter as a hook for telling the table that the heights changed. We must return the same height from this method every time, until we tell the table the heights have changed. Not doing so will quicly cause drawing problems. - NSTableColumn *tableColumnToWrap = (NSTableColumn *) [[outlineView tableColumns] objectAtIndex:1]; + NSTableColumn *tableColumnToWrap = (NSTableColumn *) [outlineView tableColumns][1]; NSInteger columnToWrap = [outlineView.tableColumns indexOfObject:tableColumnToWrap]; // Grab the fully prepared cell with our content filled in. Note that in IB the cell's Layout is set to Wraps. @@ -839,27 +736,19 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; [ps setHeadIndent: 40.0]; [ps setParagraphSpacing: 1.0]; - [ps setTabStops:[NSArray array]]; // clear all tabs + [ps setTabStops:@[]]; // clear all tabs [ps addTabStop: [[[NSTextTab alloc] initWithType: NSLeftTabStopType location: 20.0] autorelease]]; - detailAttr = [[NSDictionary dictionaryWithObjectsAndKeys: - [NSFont systemFontOfSize:10.0], NSFontAttributeName, - ps, NSParagraphStyleAttributeName, - nil] retain]; + detailAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:10.0], + NSParagraphStyleAttributeName: ps} retain]; - detailBoldAttr = [[NSDictionary dictionaryWithObjectsAndKeys: - [NSFont boldSystemFontOfSize:10.0], NSFontAttributeName, - ps, NSParagraphStyleAttributeName, - nil] retain]; + detailBoldAttr = [@{NSFontAttributeName: [NSFont boldSystemFontOfSize:10.0], + NSParagraphStyleAttributeName: ps} retain]; - titleAttr = [[NSDictionary dictionaryWithObjectsAndKeys: - [NSFont systemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName, - ps, NSParagraphStyleAttributeName, - nil] retain]; + titleAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]], + NSParagraphStyleAttributeName: ps} retain]; - shortHeightAttr = [[NSDictionary dictionaryWithObjectsAndKeys: - [NSFont systemFontOfSize:2.0], NSFontAttributeName, - nil] retain]; + shortHeightAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:2.0]} retain]; } - (id)outlineView:(NSOutlineView *)fOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item @@ -873,40 +762,40 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* First line, we should strip the destination path and just show the file name and add the title num and chapters (if any) */ NSString * summaryInfo; - NSString * titleString = [NSString stringWithFormat:@"Title %d", [[item objectForKey:@"TitleNumber"] intValue]]; + NSString * titleString = [NSString stringWithFormat:@"Title %d", [item[@"TitleNumber"] intValue]]; NSString * startStopString = @""; - if ([[item objectForKey:@"fEncodeStartStop"] intValue] == 0) + if ([item[@"fEncodeStartStop"] intValue] == 0) { /* Start Stop is chapters */ - startStopString = ([[item objectForKey:@"ChapterStart"] intValue] == [[item objectForKey:@"ChapterEnd"] intValue]) ? - [NSString stringWithFormat:@"Chapter %d", [[item objectForKey:@"ChapterStart"] intValue]] : - [NSString stringWithFormat:@"Chapters %d through %d", [[item objectForKey:@"ChapterStart"] intValue], [[item objectForKey:@"ChapterEnd"] intValue]]; + startStopString = ([item[@"ChapterStart"] intValue] == [item[@"ChapterEnd"] intValue]) ? + [NSString stringWithFormat:@"Chapter %d", [item[@"ChapterStart"] intValue]] : + [NSString stringWithFormat:@"Chapters %d through %d", [item[@"ChapterStart"] intValue], [item[@"ChapterEnd"] intValue]]; } - else if ([[item objectForKey:@"fEncodeStartStop"] intValue] == 1) + else if ([item[@"fEncodeStartStop"] intValue] == 1) { /* Start Stop is seconds */ - startStopString = [NSString stringWithFormat:@"Seconds %d through %d", [[item objectForKey:@"StartSeconds"] intValue], [[item objectForKey:@"StartSeconds"] intValue] + [[item objectForKey:@"StopSeconds"] intValue]]; + startStopString = [NSString stringWithFormat:@"Seconds %d through %d", [item[@"StartSeconds"] intValue], [item[@"StartSeconds"] intValue] + [item[@"StopSeconds"] intValue]]; } - else if ([[item objectForKey:@"fEncodeStartStop"] intValue] == 2) + else if ([item[@"fEncodeStartStop"] intValue] == 2) { /* Start Stop is Frames */ - startStopString = [NSString stringWithFormat:@"Frames %d through %d", [[item objectForKey:@"StartFrame"] intValue], [[item objectForKey:@"StartFrame"] intValue] + [[item objectForKey:@"StopFrame"] intValue]]; + startStopString = [NSString stringWithFormat:@"Frames %d through %d", [item[@"StartFrame"] intValue], [item[@"StartFrame"] intValue] + [item[@"StopFrame"] intValue]]; } NSString * passesString = @""; /* check to see if our first subtitle track is Foreign Language Search, in which case there is an in depth scan */ - if ([[item objectForKey:@"SubtitleList"] count] && [[[[item objectForKey:@"SubtitleList"] objectAtIndex:0] objectForKey:@"keySubTrackIndex"] intValue] == -1) + if ([item[@"SubtitleList"] count] && [item[@"SubtitleList"][0][@"keySubTrackIndex"] intValue] == -1) { passesString = [passesString stringByAppendingString:@"1 Foreign Language Search Pass - "]; } - if ([[item objectForKey:@"VideoTwoPass"] intValue] == 0) + if ([item[@"VideoTwoPass"] intValue] == 0) { passesString = [passesString stringByAppendingString:@"1 Video Pass"]; } else { - if ([[item objectForKey:@"VideoTurboTwoPass"] intValue] == 1) + if ([item[@"VideoTurboTwoPass"] intValue] == 1) { passesString = [passesString stringByAppendingString:@"2 Video Passes First Turbo"]; } @@ -916,10 +805,10 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } } - [finalString appendString:[NSString stringWithFormat:@"%@", [item objectForKey:@"SourceName"]] withAttributes:titleAttr]; + [finalString appendString:[NSString stringWithFormat:@"%@", item[@"SourceName"]] withAttributes:titleAttr]; /* lets add the output file name to the title string here */ - NSString * outputFilenameString = [[item objectForKey:@"DestinationPath"] lastPathComponent]; + NSString * outputFilenameString = [item[@"DestinationPath"] lastPathComponent]; summaryInfo = [NSString stringWithFormat: @" (%@, %@, %@) -> %@", titleString, startStopString, passesString, outputFilenameString]; @@ -931,7 +820,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* Second Line (Preset Name)*/ [finalString appendString: @"Preset: " withAttributes:detailBoldAttr]; - [finalString appendString:[NSString stringWithFormat:@"%@\n", [item objectForKey:@"PresetName"]] withAttributes:detailAttr]; + [finalString appendString:[NSString stringWithFormat:@"%@\n", item[@"PresetName"]] withAttributes:detailAttr]; /* Third Line (Format Summary) */ NSString * audioCodecSummary = @""; // This seems to be set by the last track we have available... @@ -963,20 +852,20 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } NSString * jobFormatInfo; - if ([[item objectForKey:@"ChapterMarkers"] intValue] == 1) - jobFormatInfo = [NSString stringWithFormat:@"%@ Container, %@ Video %@ Audio, Chapter Markers\n", [item objectForKey:@"FileFormat"], [item objectForKey:@"VideoEncoder"], audioCodecSummary]; + if ([item[@"ChapterMarkers"] intValue] == 1) + jobFormatInfo = [NSString stringWithFormat:@"%@ Container, %@ Video %@ Audio, Chapter Markers\n", item[@"FileFormat"], item[@"VideoEncoder"], audioCodecSummary]; else - jobFormatInfo = [NSString stringWithFormat:@"%@ Container, %@ Video %@ Audio\n", [item objectForKey:@"FileFormat"], [item objectForKey:@"VideoEncoder"], audioCodecSummary]; + jobFormatInfo = [NSString stringWithFormat:@"%@ Container, %@ Video %@ Audio\n", item[@"FileFormat"], item[@"VideoEncoder"], audioCodecSummary]; [finalString appendString: @"Format: " withAttributes:detailBoldAttr]; [finalString appendString: jobFormatInfo withAttributes:detailAttr]; /* Optional String for muxer options */ - if ([[item objectForKey:@"MuxerOptionsSummary"] length]) + if ([item[@"MuxerOptionsSummary"] length]) { NSString *containerOptions = [NSString stringWithFormat:@"%@", - [item objectForKey:@"MuxerOptionsSummary"]]; + item[@"MuxerOptionsSummary"]]; [finalString appendString:@"Container Options: " withAttributes:detailBoldAttr]; [finalString appendString:containerOptions withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; @@ -984,13 +873,13 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* Fourth Line (Destination Path)*/ [finalString appendString: @"Destination: " withAttributes:detailBoldAttr]; - [finalString appendString: [item objectForKey:@"DestinationPath"] withAttributes:detailAttr]; + [finalString appendString: item[@"DestinationPath"] withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; /* Fifth Line Picture Details*/ NSString *pictureInfo = [NSString stringWithFormat:@"%@", - [item objectForKey:@"PictureSettingsSummary"]]; - if ([[item objectForKey:@"PictureKeepRatio"] intValue] == 1) + item[@"PictureSettingsSummary"]]; + if ([item[@"PictureKeepRatio"] intValue] == 1) { pictureInfo = [pictureInfo stringByAppendingString:@" Keep Aspect Ratio"]; } @@ -999,10 +888,10 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; [finalString appendString:@"\n" withAttributes:detailAttr]; /* Optional String for Picture Filters */ - if ([[item objectForKey:@"PictureFiltersSummary"] length]) + if ([item[@"PictureFiltersSummary"] length]) { NSString *pictureFilters = [NSString stringWithFormat:@"%@", - [item objectForKey:@"PictureFiltersSummary"]]; + item[@"PictureFiltersSummary"]]; [finalString appendString:@"Filters: " withAttributes:detailBoldAttr]; [finalString appendString:pictureFilters withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; @@ -1010,12 +899,12 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* Sixth Line Video Details*/ NSString * videoInfo; - videoInfo = [NSString stringWithFormat:@"Encoder: %@", [item objectForKey:@"VideoEncoder"]]; + videoInfo = [NSString stringWithFormat:@"Encoder: %@", item[@"VideoEncoder"]]; /* for framerate look to see if we are using vfr detelecine */ - if ([[item objectForKey:@"JobIndexVideoFramerate"] intValue] == 0) + if ([item[@"JobIndexVideoFramerate"] intValue] == 0) { - if ([[item objectForKey:@"VideoFramerateMode"] isEqualToString:@"vfr"]) + if ([item[@"VideoFramerateMode"] isEqualToString:@"vfr"]) { /* we are using same as source with vfr detelecine */ videoInfo = [NSString stringWithFormat:@"%@ Framerate: Same as source (Variable Frame Rate)", videoInfo]; @@ -1029,44 +918,44 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; else { /* we have a specified, constant framerate */ - if ([[item objectForKey:@"VideoFramerateMode"] isEqualToString:@"pfr"]) + if ([item[@"VideoFramerateMode"] isEqualToString:@"pfr"]) { - videoInfo = [NSString stringWithFormat:@"%@ Framerate: %@ (Peak Frame Rate)", videoInfo ,[item objectForKey:@"VideoFramerate"]]; + videoInfo = [NSString stringWithFormat:@"%@ Framerate: %@ (Peak Frame Rate)", videoInfo ,item[@"VideoFramerate"]]; } else { - videoInfo = [NSString stringWithFormat:@"%@ Framerate: %@ (Constant Frame Rate)", videoInfo ,[item objectForKey:@"VideoFramerate"]]; + videoInfo = [NSString stringWithFormat:@"%@ Framerate: %@ (Constant Frame Rate)", videoInfo ,item[@"VideoFramerate"]]; } } - if ([[item objectForKey:@"VideoQualityType"] intValue] == 0)// Target Size MB + if ([item[@"VideoQualityType"] intValue] == 0)// Target Size MB { - videoInfo = [NSString stringWithFormat:@"%@ Target Size: %@(MB) (%d(kbps) abr)", videoInfo ,[item objectForKey:@"VideoTargetSize"],[[item objectForKey:@"VideoAvgBitrate"] intValue]]; + videoInfo = [NSString stringWithFormat:@"%@ Target Size: %@(MB) (%d(kbps) abr)", videoInfo ,item[@"VideoTargetSize"],[item[@"VideoAvgBitrate"] intValue]]; } - else if ([[item objectForKey:@"VideoQualityType"] intValue] == 1) // ABR + else if ([item[@"VideoQualityType"] intValue] == 1) // ABR { - videoInfo = [NSString stringWithFormat:@"%@ Bitrate: %d(kbps)", videoInfo ,[[item objectForKey:@"VideoAvgBitrate"] intValue]]; + videoInfo = [NSString stringWithFormat:@"%@ Bitrate: %d(kbps)", videoInfo ,[item[@"VideoAvgBitrate"] intValue]]; } else // CRF { - videoInfo = [NSString stringWithFormat:@"%@ Constant Quality: %.2f", videoInfo ,[[item objectForKey:@"VideoQualitySlider"] floatValue]]; + videoInfo = [NSString stringWithFormat:@"%@ Constant Quality: %.2f", videoInfo ,[item[@"VideoQualitySlider"] floatValue]]; } [finalString appendString: @"Video: " withAttributes:detailBoldAttr]; [finalString appendString: videoInfo withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; - if ([[item objectForKey:@"VideoEncoder"] isEqualToString: @"H.264 (x264)"]) + if ([item[@"VideoEncoder"] isEqualToString: @"H.264 (x264)"]) { /* we are using x264 */ NSString *x264Info = @""; - if ([[item objectForKey:@"x264UseAdvancedOptions"] intValue]) + if ([item[@"x264UseAdvancedOptions"] intValue]) { // we are using the old advanced panel - if ([item objectForKey:@"x264Option"] && - [[item objectForKey:@"x264Option"] length]) + if (item[@"x264Option"] && + [item[@"x264Option"] length]) { - x264Info = [x264Info stringByAppendingString: [item objectForKey:@"x264Option"]]; + x264Info = [x264Info stringByAppendingString: item[@"x264Option"]]; } else { @@ -1076,36 +965,36 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; else { // we are using the x264 system - x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@"Preset: %@", [item objectForKey:@"x264Preset"]]]; - if ([[item objectForKey:@"x264Tune"] length]) + x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@"Preset: %@", item[@"x264Preset"]]]; + if ([item[@"x264Tune"] length]) { - x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Tune: %@", [item objectForKey:@"x264Tune"]]]; + x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Tune: %@", item[@"x264Tune"]]]; } - if ([[item objectForKey:@"x264OptionExtra"] length]) + if ([item[@"x264OptionExtra"] length]) { - x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Options: %@", [item objectForKey:@"x264OptionExtra"]]]; + x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Options: %@", item[@"x264OptionExtra"]]]; } - if ([[item objectForKey:@"h264Profile"] length]) + if ([item[@"h264Profile"] length]) { - x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Profile: %@", [item objectForKey:@"h264Profile"]]]; + x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Profile: %@", item[@"h264Profile"]]]; } - if ([[item objectForKey:@"h264Level"] length]) + if ([item[@"h264Level"] length]) { - x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Level: %@", [item objectForKey:@"h264Level"]]]; + x264Info = [x264Info stringByAppendingString: [NSString stringWithFormat:@" - Level: %@", item[@"h264Level"]]]; } } [finalString appendString: @"x264: " withAttributes:detailBoldAttr]; [finalString appendString: x264Info withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; } - else if (![[item objectForKey:@"VideoEncoder"] isEqualToString: @"VP3 (Theora)"]) + else if (![item[@"VideoEncoder"] isEqualToString: @"VP3 (Theora)"]) { /* we are using libavcodec */ NSString *lavcInfo = @""; - if ([item objectForKey:@"lavcOption"] && - [[item objectForKey:@"lavcOption"] length]) + if (item[@"lavcOption"] && + [item[@"lavcOption"] length]) { - lavcInfo = [lavcInfo stringByAppendingString: [item objectForKey:@"lavcOption"]]; + lavcInfo = [lavcInfo stringByAppendingString: item[@"lavcOption"]]; } else { @@ -1137,12 +1026,12 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; if (autoPassthruPresent == YES) { NSString *autoPassthruFallback = @"", *autoPassthruCodecs = @""; - autoPassthruFallback = [autoPassthruFallback stringByAppendingString: [item objectForKey: @"AudioEncoderFallback"]]; - if (0 < [[item objectForKey: @"AudioAllowAACPass"] intValue]) + autoPassthruFallback = [autoPassthruFallback stringByAppendingString: item[@"AudioEncoderFallback"]]; + if (0 < [item[@"AudioAllowAACPass"] intValue]) { autoPassthruCodecs = [autoPassthruCodecs stringByAppendingString: @"AAC"]; } - if (0 < [[item objectForKey: @"AudioAllowAC3Pass"] intValue]) + if (0 < [item[@"AudioAllowAC3Pass"] intValue]) { if (0 < [autoPassthruCodecs length]) { @@ -1150,7 +1039,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } autoPassthruCodecs = [autoPassthruCodecs stringByAppendingString: @"AC3"]; } - if (0 < [[item objectForKey: @"AudioAllowDTSHDPass"] intValue]) + if (0 < [item[@"AudioAllowDTSHDPass"] intValue]) { if (0 < [autoPassthruCodecs length]) { @@ -1158,7 +1047,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } autoPassthruCodecs = [autoPassthruCodecs stringByAppendingString: @"DTS-HD"]; } - if (0 < [[item objectForKey: @"AudioAllowDTSPass"] intValue]) + if (0 < [item[@"AudioAllowDTSPass"] intValue]) { if (0 < [autoPassthruCodecs length]) { @@ -1166,7 +1055,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } autoPassthruCodecs = [autoPassthruCodecs stringByAppendingString: @"DTS"]; } - if (0 < [[item objectForKey: @"AudioAllowMP3Pass"] intValue]) + if (0 < [item[@"AudioAllowMP3Pass"] intValue]) { if (0 < [autoPassthruCodecs length]) { @@ -1192,22 +1081,22 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* Ninth Line Subtitle Details */ int i = 0; - NSEnumerator *enumerator = [[item objectForKey:@"SubtitleList"] objectEnumerator]; + NSEnumerator *enumerator = [item[@"SubtitleList"] objectEnumerator]; id tempObject; while (tempObject = [enumerator nextObject]) { /* remember that index 0 of Subtitles can contain "Foreign Audio Search*/ [finalString appendString: @"Subtitle: " withAttributes:detailBoldAttr]; - [finalString appendString: [tempObject objectForKey:@"keySubTrackName"] withAttributes:detailAttr]; - if ([[tempObject objectForKey:@"keySubTrackForced"] intValue] == 1) + [finalString appendString: tempObject[@"keySubTrackName"] withAttributes:detailAttr]; + if ([tempObject[@"keySubTrackForced"] intValue] == 1) { [finalString appendString: @" - Forced Only" withAttributes:detailAttr]; } - if ([[tempObject objectForKey:@"keySubTrackBurned"] intValue] == 1) + if ([tempObject[@"keySubTrackBurned"] intValue] == 1) { [finalString appendString: @" - Burned In" withAttributes:detailAttr]; } - if ([[tempObject objectForKey:@"keySubTrackDefault"] intValue] == 1) + if ([tempObject[@"keySubTrackDefault"] intValue] == 1) { [finalString appendString: @" - Default" withAttributes:detailAttr]; } @@ -1221,15 +1110,15 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; } else if ([[tableColumn identifier] isEqualToString:@"icon"]) { - if ([[item objectForKey:@"Status"] intValue] == 0) + if ([item[@"Status"] intValue] == 0) { return [NSImage imageNamed:@"EncodeComplete"]; } - else if ([[item objectForKey:@"Status"] intValue] == 1) + else if ([item[@"Status"] intValue] == 1) { return [NSImage imageNamed: [NSString stringWithFormat: @"EncodeWorking%d", fAnimationIndex]]; } - else if ([[item objectForKey:@"Status"] intValue] == 3) + else if ([item[@"Status"] intValue] == 3) { return [NSImage imageNamed:@"EncodeCanceled"]; } @@ -1249,8 +1138,6 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; { if ([[tableColumn identifier] isEqualToString:@"desc"]) { - - // nb: The "desc" column is currently an HBImageAndTextCell. However, we are longer // using the image portion of the cell so we could switch back to a regular NSTextFieldCell. @@ -1262,7 +1149,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; [cell setEnabled: YES]; BOOL highlighted = [outlineView isRowSelected:[outlineView rowForItem: item]] && [[outlineView window] isKeyWindow] && ([[outlineView window] firstResponder] == outlineView); - if ([[item objectForKey:@"Status"] intValue] == 0 || ([[item objectForKey:@"Status"] intValue] == 1 && [[item objectForKey:@"EncodingPID"] intValue] != pidNum)) + if ([item[@"Status"] intValue] == 0 || ([item[@"Status"] intValue] == 1 && [item[@"EncodingPID"] intValue] != pidNum)) { [cell setAction: @selector(revealSelectedQueueItem:)]; if (highlighted) @@ -1310,7 +1197,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { // Dragging is only allowed of the pending items. - if ([[[items objectAtIndex:0] objectForKey:@"Status"] integerValue] != 2) // 2 is pending + if ([items[0][@"Status"] integerValue] != 2) // 2 is pending { return NO; } @@ -1320,7 +1207,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; fDraggedNodes = items; // Provide data for our custom type, and simple NSStrings. - [pboard declareTypes:[NSArray arrayWithObjects: DragDropSimplePboardType, nil] owner:self]; + [pboard declareTypes:@[DragDropSimplePboardType] owner:self]; // the actual data doesn't matter since DragDropSimplePboardType drags aren't recognized by anyone but us!. [pboard setData:[NSData data] forType:DragDropSimplePboardType]; @@ -1375,5 +1262,4 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; return YES; } - @end |