diff options
author | Damiano Galassi <[email protected]> | 2017-02-04 14:04:37 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2017-02-04 14:04:37 +0100 |
commit | 41a737dc5f73013d245d8d64ca2461551adfcf75 (patch) | |
tree | 77ac9fffc021f496c814204caed9ac794b7663ad /macosx | |
parent | 9bd4723096d9c357c7cbf3242fb18537fc1cb66e (diff) |
MacGui: allow to sort by title/name/duration in the title selections sheet.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/English.lproj/HBTitleSelection.xib | 77 | ||||
-rw-r--r-- | macosx/HBController.m | 28 | ||||
-rw-r--r-- | macosx/HBTitleSelectionController.h | 2 | ||||
-rw-r--r-- | macosx/HBTitleSelectionController.m | 12 |
4 files changed, 68 insertions, 51 deletions
diff --git a/macosx/English.lproj/HBTitleSelection.xib b/macosx/English.lproj/HBTitleSelection.xib index 20716688f..47ae7dedc 100644 --- a/macosx/English.lproj/HBTitleSelection.xib +++ b/macosx/English.lproj/HBTitleSelection.xib @@ -1,34 +1,36 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11185.3" systemVersion="16A270f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12100" systemVersion="16E144f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> <deployment identifier="macosx"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11185.3"/> + <development version="7000" identifier="xcode"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12100"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBTitleSelectionController"> <connections> + <outlet property="arrayController" destination="Btd-Nt-z41" id="zGL-0Q-Zf6"/> <outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/> </connections> </customObject> - <arrayController id="Btd-Nt-z41" userLabel="Titles Array Controller"> + <arrayController objectClassName="HBTitleSelection" id="Btd-Nt-z41" userLabel="Titles Array Controller"> <connections> <binding destination="-2" name="contentArray" keyPath="self.titles" id="ujR-MW-HYh"/> </connections> </arrayController> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/> - <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5"> + <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="HBTitleSelectionWindow" animationBehavior="default" id="F0z-JX-Cv5"> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> - <rect key="contentRect" x="196" y="240" width="504" height="250"/> + <rect key="contentRect" x="196" y="240" width="554" height="250"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <value key="minSize" type="size" width="300" height="200"/> <view key="contentView" id="se5-gp-TjO"> - <rect key="frame" x="0.0" y="0.0" width="504" height="250"/> + <rect key="frame" x="0.0" y="0.0" width="554" height="250"/> <autoresizingMask key="autoresizingMask"/> <subviews> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5Jw-On-iU3"> - <rect key="frame" x="18" y="216" width="468" height="14"/> + <rect key="frame" x="18" y="216" width="518" height="14"/> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Select the titles to add to the queue:" id="5tD-fg-g4t"> <font key="font" metaFont="smallSystemBold"/> <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> @@ -43,7 +45,7 @@ </connections> </textField> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="TFh-c7-W2w"> - <rect key="frame" x="427" y="14" width="62" height="28"/> + <rect key="frame" x="477" y="14" width="62" height="28"/> <buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="mOe-XL-tl1"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -56,21 +58,21 @@ DQ </connections> </button> <scrollView autohidesScrollers="YES" horizontalLineScroll="18" horizontalPageScroll="10" verticalLineScroll="18" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="a1K-L9-fU9"> - <rect key="frame" x="20" y="57" width="464" height="151"/> + <rect key="frame" x="20" y="57" width="514" height="151"/> <clipView key="contentView" id="dTc-E7-D15"> - <rect key="frame" x="1" y="1" width="462" height="149"/> + <rect key="frame" x="1" y="0.0" width="512" height="150"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="14" viewBased="YES" id="wM9-Ln-dr0"> - <rect key="frame" x="0.0" y="0.0" width="462" height="149"/> + <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" columnReordering="NO" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" autosaveName="HBTitleSelectionTable" rowHeight="14" headerView="sEp-Wn-EWq" viewBased="YES" floatsGroupRows="NO" id="wM9-Ln-dr0"> + <rect key="frame" x="0.0" y="0.0" width="512" height="127"/> <autoresizingMask key="autoresizingMask"/> <size key="intercellSpacing" width="3" height="4"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <tableViewGridLines key="gridStyleMask" vertical="YES"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> <tableColumns> - <tableColumn identifier="index" width="30" minWidth="30" maxWidth="30" id="4XY-C0-SwE"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="right"> + <tableColumn identifier="index" width="40" minWidth="40" maxWidth="40" id="4XY-C0-SwE"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="right" title="Title"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -83,11 +85,11 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="6H6-2e-RPZ"> - <rect key="frame" x="1" y="2" width="30" height="15"/> + <rect key="frame" x="1" y="2" width="40" height="15"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="gLJ-VQ-3cg"> - <rect key="frame" x="0.0" y="1" width="29" height="14"/> + <rect key="frame" x="1" y="1" width="38" height="14"/> <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" alignment="right" title="0" id="hQc-RA-phB"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> @@ -108,9 +110,16 @@ DQ </connections> </tableCellView> </prototypeCellViews> + <connections> + <binding destination="Btd-Nt-z41" name="value" keyPath="arrangedObjects.title.index" id="BgP-Dm-Jia"> + <dictionary key="options"> + <bool key="NSConditionallySetsEditable" value="NO"/> + </dictionary> + </binding> + </connections> </tableColumn> - <tableColumn identifier="title" width="333" minWidth="40" maxWidth="2000" id="FQY-Ye-g0f"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> + <tableColumn identifier="title" width="373" minWidth="40" maxWidth="2000" id="FQY-Ye-g0f"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Name"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -119,14 +128,15 @@ DQ <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <font key="font" metaFont="smallSystem"/> </buttonCell> + <sortDescriptor key="sortDescriptorPrototype" selector="localizedCaseInsensitiveCompare:" sortKey="title.name"/> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="Sil-eA-Flj"> - <rect key="frame" x="34" y="2" width="333" height="15"/> + <rect key="frame" x="44" y="2" width="373" height="15"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <button translatesAutoresizingMaskIntoConstraints="NO" id="LSj-el-4SZ"> - <rect key="frame" x="0.0" y="-2" width="332" height="20"/> + <rect key="frame" x="0.0" y="-2" width="372" height="20"/> <buttonCell key="cell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="JqJ-5C-Yhw"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <font key="font" metaFont="smallSystem"/> @@ -145,9 +155,12 @@ DQ </constraints> </tableCellView> </prototypeCellViews> + <connections> + <binding destination="Btd-Nt-z41" name="value" keyPath="arrangedObjects.title.name" id="KWr-4Y-Sh8"/> + </connections> </tableColumn> <tableColumn identifier="duration" width="90" minWidth="90" maxWidth="90" id="a6r-ky-REh"> - <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left"> + <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Duration"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> @@ -160,7 +173,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="eNN-Bb-hW0"> - <rect key="frame" x="370" y="2" width="90" height="15"/> + <rect key="frame" x="420" y="2" width="90" height="15"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="dTs-ND-Vgf"> @@ -185,26 +198,38 @@ DQ </connections> </tableCellView> </prototypeCellViews> + <connections> + <binding destination="Btd-Nt-z41" name="value" keyPath="arrangedObjects.title.timeCode" id="12W-yd-RAK"> + <dictionary key="options"> + <bool key="NSConditionallySetsEditable" value="NO"/> + </dictionary> + </binding> + </connections> </tableColumn> </tableColumns> <connections> <binding destination="Btd-Nt-z41" name="content" keyPath="arrangedObjects" id="Yyh-f8-EYR"/> + <binding destination="Btd-Nt-z41" name="sortDescriptors" keyPath="sortDescriptors" previousBinding="Yyh-f8-EYR" id="CCw-mO-9f0"/> <outlet property="menu" destination="vdO-DI-vks" id="Iux-VV-EDo"/> </connections> </tableView> </subviews> </clipView> <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="KUp-wz-bHB"> - <rect key="frame" x="1" y="119" width="223" height="15"/> + <rect key="frame" x="1" y="134" width="502" height="16"/> <autoresizingMask key="autoresizingMask"/> </scroller> - <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="iFv-s2-21F"> + <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="iFv-s2-21F"> <rect key="frame" x="224" y="17" width="15" height="102"/> <autoresizingMask key="autoresizingMask"/> </scroller> + <tableHeaderView key="headerView" id="sEp-Wn-EWq"> + <rect key="frame" x="0.0" y="0.0" width="512" height="23"/> + <autoresizingMask key="autoresizingMask"/> + </tableHeaderView> </scrollView> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="t5w-9e-K60"> - <rect key="frame" x="367" y="14" width="62" height="28"/> + <rect key="frame" x="417" y="14" width="62" height="28"/> <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="jHg-nh-9NJ"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -235,7 +260,7 @@ Gw <connections> <outlet property="delegate" destination="-2" id="0bl-1N-AYu"/> </connections> - <point key="canvasLocation" x="281" y="74"/> + <point key="canvasLocation" x="-41" y="-193"/> </window> <menu id="vdO-DI-vks"> <items> diff --git a/macosx/HBController.m b/macosx/HBController.m index 5b26fc438..602401a2a 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -1161,15 +1161,15 @@ contextInfo:NULL]; } -- (void)didSelectIndexes:(NSIndexSet *)indexes +- (void)didSelectTitles:(NSArray<HBTitle *> *)titles { [self.titlesSelectionController.window orderOut:nil]; [NSApp endSheet:self.titlesSelectionController.window]; - [self doAddTitlesAtIndexesToQueue:indexes]; + [self doAddTitlesToQueue:titles]; } -- (void)doAddTitlesAtIndexesToQueue:(NSIndexSet *)indexes; +- (void)doAddTitlesToQueue:(NSArray<HBTitle *> *)titles; { NSMutableArray<HBJob *> *jobs = [[NSMutableArray alloc] init]; BOOL fileExists = NO; @@ -1178,16 +1178,13 @@ // Get the preset from the loaded job. HBPreset *preset = [self createPresetFromCurrentSettings]; - for (HBTitle *title in self.core.titles) + for (HBTitle *title in titles) { - if ([indexes containsIndex:title.index]) - { - HBJob *job = [[HBJob alloc] initWithTitle:title andPreset:preset]; - job.outputURL = self.currentDestination; - job.outputFileName = [HBUtilities defaultNameForJob:job]; - job.title = nil; - [jobs addObject:job]; - } + HBJob *job = [[HBJob alloc] initWithTitle:title andPreset:preset]; + job.outputURL = self.currentDestination; + job.outputFileName = [HBUtilities defaultNameForJob:job]; + job.title = nil; + [jobs addObject:job]; } NSMutableSet<NSURL *> *destinations = [[NSMutableSet alloc] init]; @@ -1256,12 +1253,7 @@ - (IBAction)addAllTitlesToQueue:(id)sender { - NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; - for (HBTitle *title in self.core.titles) - { - [indexes addIndex:title.index]; - } - [self doAddTitlesAtIndexesToQueue:indexes]; + [self doAddTitlesToQueue:self.core.titles]; } #pragma mark - Picture diff --git a/macosx/HBTitleSelectionController.h b/macosx/HBTitleSelectionController.h index 4999687fa..50ff07078 100644 --- a/macosx/HBTitleSelectionController.h +++ b/macosx/HBTitleSelectionController.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol HBTitleSelectionDelegate <NSObject> -- (void)didSelectIndexes:(NSIndexSet *)indexes; +- (void)didSelectTitles:(NSArray<HBTitle *> *)titles; @end diff --git a/macosx/HBTitleSelectionController.m b/macosx/HBTitleSelectionController.m index 319808a69..7ac625f3c 100644 --- a/macosx/HBTitleSelectionController.m +++ b/macosx/HBTitleSelectionController.m @@ -38,6 +38,7 @@ @interface HBTitleSelectionController () <NSTableViewDataSource, NSTableViewDelegate> +@property (nonatomic, strong) IBOutlet NSArrayController *arrayController; @property (nonatomic, readwrite) NSArray<HBTitleSelection *> *titles; @property (nonatomic, readonly, assign) id<HBTitleSelectionDelegate> delegate; @property (nonatomic, readonly) NSString *message; @@ -75,20 +76,19 @@ - (IBAction)add:(id)sender { - NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet]; - - [self.titles enumerateObjectsUsingBlock:^(HBTitleSelection *obj, NSUInteger idx, BOOL *stop) { + NSMutableArray<HBTitle *> *titles = [NSMutableArray array]; + [self.arrayController.arrangedObjects enumerateObjectsUsingBlock:^(HBTitleSelection *obj, NSUInteger idx, BOOL *stop) { if (obj.selected) { - [indexes addIndex:obj.title.index]; + [titles addObject:obj.title]; } }]; - [self.delegate didSelectIndexes:indexes]; + [self.delegate didSelectTitles:titles]; } - (IBAction)cancel:(id)sender { - [self.delegate didSelectIndexes:[NSIndexSet indexSet]]; + [self.delegate didSelectTitles:@[]]; } @end |