summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/Base.lproj/HBQueueInfoViewController.xib17
-rw-r--r--macosx/HBController.m4
-rw-r--r--macosx/HBQueue.h12
-rw-r--r--macosx/HBQueue.m121
-rw-r--r--macosx/HBQueueActionItem.h22
-rw-r--r--macosx/HBQueueActionItem.m68
-rw-r--r--macosx/HBQueueController.m37
-rw-r--r--macosx/HBQueueDockTileController.m4
-rw-r--r--macosx/HBQueueInfoViewController.h6
-rw-r--r--macosx/HBQueueInfoViewController.m25
-rw-r--r--macosx/HBQueueItem.h51
-rw-r--r--macosx/HBQueueItemView.h11
-rw-r--r--macosx/HBQueueItemView.m9
-rw-r--r--macosx/HBQueueItemWorkingView.m4
-rw-r--r--macosx/HBQueueJobItem.h54
-rw-r--r--macosx/HBQueueJobItem.m (renamed from macosx/HBQueueItem.m)25
-rw-r--r--macosx/HBQueueTableViewController.h4
-rw-r--r--macosx/HBQueueTableViewController.m47
-rw-r--r--macosx/HBQueueWorker.h6
-rw-r--r--macosx/HBQueueWorker.m8
-rw-r--r--macosx/HandBrake.xcodeproj/project.pbxproj20
21 files changed, 376 insertions, 179 deletions
diff --git a/macosx/Base.lproj/HBQueueInfoViewController.xib b/macosx/Base.lproj/HBQueueInfoViewController.xib
index ee37c5e4c..29bbbbe72 100644
--- a/macosx/Base.lproj/HBQueueInfoViewController.xib
+++ b/macosx/Base.lproj/HBQueueInfoViewController.xib
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17154"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -23,17 +23,18 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Z14-gh-hWn">
- <rect key="frame" x="420" y="3" width="64" height="32"/>
+ <rect key="frame" x="427" y="3" width="58" height="32"/>
<buttonCell key="cell" type="push" title="Edit" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="erY-5X-50l">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="editItem:" target="-2" id="ozj-G7-6d5"/>
+ <binding destination="-2" name="enabled" keyPath="self.canEdit" id="nuW-8z-gyx"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oq4-g0-srt">
- <rect key="frame" x="348" y="3" width="75" height="32"/>
+ <rect key="frame" x="363" y="3" width="69" height="32"/>
<buttonCell key="cell" type="push" title="Reset" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="hgl-N3-x4S">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@@ -44,13 +45,13 @@
</connections>
</button>
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MXt-Cb-20x">
- <rect key="frame" x="0.0" y="39" width="488" height="296"/>
+ <rect key="frame" x="0.0" y="38" width="488" height="297"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="kkx-XF-sYr" customClass="HBFlippedClipView">
- <rect key="frame" x="0.0" y="0.0" width="488" height="296"/>
+ <rect key="frame" x="0.0" y="0.0" width="488" height="297"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view translatesAutoresizingMaskIntoConstraints="NO" id="Akt-r1-6fP">
- <rect key="frame" x="0.0" y="200" width="488" height="96"/>
+ <rect key="frame" x="0.0" y="201" width="488" height="96"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="4" horizontalStackHuggingPriority="250" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VVC-g8-nGU">
<rect key="frame" x="12" y="8" width="464" height="80"/>
@@ -160,7 +161,7 @@
</scroller>
</scrollView>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="gAc-tj-J9f">
- <rect key="frame" x="0.0" y="36" width="488" height="5"/>
+ <rect key="frame" x="0.0" y="35" width="488" height="5"/>
</box>
</subviews>
<constraints>
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 69e125903..2fdd2850d 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -512,8 +512,8 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
- (void)setUpForSingleWorker
{
- HBQueueItem *firstWorkingItem = nil;
- for (HBQueueItem *item in self.queue.items)
+ HBQueueJobItem *firstWorkingItem = nil;
+ for (HBQueueJobItem *item in self.queue.items)
{
if (item.state == HBQueueItemStateWorking)
{
diff --git a/macosx/HBQueue.h b/macosx/HBQueue.h
index 9f86eb22b..dcdcc101d 100644
--- a/macosx/HBQueue.h
+++ b/macosx/HBQueue.h
@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h>
#import "HBQueueItem.h"
+#import "HBQueueJobItem.h"
+#import "HBQueueActionItem.h"
#import "HBQueueWorker.h"
NS_ASSUME_NONNULL_BEGIN
@@ -28,14 +30,14 @@ extern NSString * const HBQueueDidChangeStateNotification;
extern NSString * const HBQueueDidStartItemNotification;
extern NSString * const HBQueueDidCompleteItemNotification;
-extern NSString * const HBQueueItemNotificationItemKey; // HBQueueItem
+extern NSString * const HBQueueItemNotificationItemKey; // HBQueueJobItem
@interface HBQueue : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithURL:(NSURL *)fileURL;
-@property (nonatomic, readonly) NSArray<HBQueueItem *> *items;
+@property (nonatomic, readonly) NSArray<id<HBQueueItem>> *items;
@property (nonatomic, readonly) NSUInteger pendingItemsCount;
@property (nonatomic, readonly) NSUInteger failedItemsCount;
@@ -49,9 +51,9 @@ extern NSString * const HBQueueItemNotificationItemKey; // HBQueueI
- (void)addJob:(HBJob *)job;
- (void)addJobs:(NSArray<HBJob *> *)jobs;
-- (void)addItems:(NSArray<HBQueueItem *> *)items atIndexes:(NSIndexSet *)indexes;
+- (void)addItems:(NSArray<id<HBQueueItem>> *)items atIndexes:(NSIndexSet *)indexes;
- (void)removeItemsAtIndexes:(NSIndexSet *)indexes;
-- (void)moveItems:(NSArray<HBQueueItem *> *)items toIndex:(NSUInteger)index;
+- (void)moveItems:(NSArray<id<HBQueueItem>> *)items toIndex:(NSUInteger)index;
- (BOOL)itemExistAtURL:(NSURL *)url;
@@ -81,7 +83,7 @@ extern NSString * const HBQueueItemNotificationItemKey; // HBQueueI
@property (nonatomic, readonly) BOOL canResume;
- (void)resume;
-- (nullable HBQueueWorker *)workerForItem:(HBQueueItem *)item;
+- (nullable HBQueueWorker *)workerForItem:(HBQueueJobItem *)item;
@end
diff --git a/macosx/HBQueue.m b/macosx/HBQueue.m
index 169ca9649..1e52bfa47 100644
--- a/macosx/HBQueue.m
+++ b/macosx/HBQueue.m
@@ -40,11 +40,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
@property (nonatomic, readonly) NSURL *fileURL;
-@property (nonatomic, readonly) NSMutableArray<HBQueueItem *> *itemsInternal;
+@property (nonatomic, readonly) NSMutableArray<id<HBQueueItem>> *itemsInternal;
@property (nonatomic, readonly) NSArray<HBQueueWorker *> *workers;
@property (nonatomic) IOPMAssertionID assertionID;
-@property (nonatomic) BOOL stop;
@property (nonatomic) NSUInteger pendingItemsCount;
@property (nonatomic) NSUInteger failedItemsCount;
@@ -85,7 +84,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification * _Nonnull note) {
[self updateStats];
- HBQueueItem *item = note.userInfo[HBQueueWorkerItemNotificationItemKey];
+ HBQueueJobItem *item = note.userInfo[HBQueueWorkerItemNotificationItemKey];
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidStartItemNotification object:self userInfo:@{HBQueueItemNotificationItemKey: item}];
}];
@@ -94,7 +93,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification * _Nonnull note) {
[self updateStats];
- HBQueueItem *item = note.userInfo[HBQueueWorkerItemNotificationItemKey];
+ HBQueueJobItem *item = note.userInfo[HBQueueWorkerItemNotificationItemKey];
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidCompleteItemNotification object:self userInfo:@{HBQueueItemNotificationItemKey: item}];
[self completedItem:item];
}];
@@ -149,7 +148,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue];
unarchiver.requiresSecureCoding = YES;
- NSSet *objectClasses = [NSSet setWithObjects:[NSMutableArray class], [HBQueueItem class], nil];
+ NSSet *objectClasses = [NSSet setWithObjects:[NSMutableArray class], [HBQueueJobItem class], [HBQueueActionStopItem class], nil];
NSArray *loadedItems = [unarchiver decodeTopLevelObjectOfClasses:objectClasses
forKey:NSKeyedArchiveRootObjectKey
@@ -175,7 +174,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
#pragma mark - Public methods
-- (NSArray<HBQueueItem *> *)items
+- (NSArray<id<HBQueueItem>> *)items
{
return self.itemsInternal;
}
@@ -196,10 +195,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
NSParameterAssert(jobs);
- NSMutableArray<HBQueueItem *> *itemsToAdd = [NSMutableArray array];
+ NSMutableArray<HBQueueJobItem *> *itemsToAdd = [NSMutableArray array];
for (HBJob *job in jobs)
{
- HBQueueItem *item = [[HBQueueItem alloc] initWithJob:job];
+ HBQueueJobItem *item = [[HBQueueJobItem alloc] initWithJob:job];
[itemsToAdd addObject:item];
}
if (itemsToAdd.count)
@@ -213,9 +212,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
NSParameterAssert(url);
- for (HBQueueItem *item in self.itemsInternal)
+ for (HBQueueJobItem *item in self.itemsInternal)
{
- if ((item.state == HBQueueItemStateReady || item.state == HBQueueItemStateWorking)
+ if ([item isKindOfClass:[HBQueueJobItem class]] &&
+ (item.state == HBQueueItemStateReady || item.state == HBQueueItemStateWorking)
&& [item.completeOutputURL isEqualTo:url])
{
return YES;
@@ -224,7 +224,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
return NO;
}
-- (void)addItems:(NSArray<HBQueueItem *> *)items atIndexes:(NSIndexSet *)indexes
+- (void)addItems:(NSArray<id<HBQueueItem>> *)items atIndexes:(NSIndexSet *)indexes
{
NSParameterAssert(items);
NSParameterAssert(indexes);
@@ -262,7 +262,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)prepareItemForEditingAtIndex:(NSUInteger)index
{
- HBQueueItem *item = self.itemsInternal[index];
+ HBQueueJobItem *item = self.itemsInternal[index];
NSIndexSet *indexes = [NSIndexSet indexSetWithIndex:index];
if (item.state == HBQueueItemStateWorking)
@@ -286,7 +286,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
return;
}
- NSArray<HBQueueItem *> *removeItems = [self.itemsInternal objectsAtIndexes:indexes];
+ NSArray<id<HBQueueItem>> *removeItems = [self.itemsInternal objectsAtIndexes:indexes];
if (self.itemsInternal.count > indexes.lastIndex)
{
@@ -314,7 +314,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
[self save];
}
-- (void)moveItems:(NSArray<HBQueueItem *> *)items toIndex:(NSUInteger)index
+- (void)moveItems:(NSArray<id<HBQueueItem>> *)items toIndex:(NSUInteger)index
{
NSMutableArray<NSNumber *> *source = [NSMutableArray array];
NSMutableArray<NSNumber *> *dest = [NSMutableArray array];
@@ -405,7 +405,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
*/
- (void)removeCompletedAndCancelledItems
{
- NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(id<HBQueueItem> item) {
return (item.state == HBQueueItemStateCompleted || item.state == HBQueueItemStateCanceled);
}];
[self removeItemsAtIndexes:indexes];
@@ -424,7 +424,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)removeNotWorkingItems
{
- NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(id<HBQueueItem> item) {
return (item.state != HBQueueItemStateWorking && item.state != HBQueueItemStateRescanning);
}];
[self removeItemsAtIndexes:indexes];
@@ -432,7 +432,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)removeCompletedItems
{
- NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(id<HBQueueItem> item) {
return (item.state == HBQueueItemStateCompleted);
}];
[self removeItemsAtIndexes:indexes];
@@ -444,10 +444,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
NSUInteger currentIndex = indexes.firstIndex;
while (currentIndex != NSNotFound) {
- HBQueueItem *item = self.itemsInternal[currentIndex];
+ id<HBQueueItem> item = self.itemsInternal[currentIndex];
if (item.state == HBQueueItemStateCanceled || item.state == HBQueueItemStateCompleted ||
- item.state == HBQueueItemStateFailed || item.state ==HBQueueItemStateRescanning)
+ item.state == HBQueueItemStateFailed || item.state == HBQueueItemStateRescanning)
{
item.state = HBQueueItemStateReady;
[updatedIndexes addIndex:currentIndex];
@@ -462,7 +462,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)resetAllItems
{
- NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(id<HBQueueItem> item) {
return (item.state != HBQueueItemStateWorking && item.state != HBQueueItemStateRescanning);
}];
[self resetItemsAtIndexes:indexes];
@@ -470,7 +470,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)resetFailedItems
{
- NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(id<HBQueueItem> item) {
return (item.state == HBQueueItemStateFailed);
}];
[self resetItemsAtIndexes:indexes];
@@ -484,7 +484,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
NSMutableIndexSet *indexes = [NSMutableIndexSet indexSet];
NSUInteger idx = 0;
- for (HBQueueItem *item in self.itemsInternal)
+ for (id<HBQueueItem> item in self.itemsInternal)
{
// We want to keep any queue item that is pending or was previously being encoded
if (item.state == HBQueueItemStateWorking || item.state == HBQueueItemStateRescanning)
@@ -621,23 +621,26 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
NSUInteger pendingCount = 0, failedCount = 0, completedCount = 0, workingCount = 0;
- for (HBQueueItem *item in self.itemsInternal)
+ for (HBQueueJobItem *item in self.itemsInternal)
{
- if (item.state == HBQueueItemStateReady)
- {
- pendingCount++;
- }
- else if (item.state == HBQueueItemStateCompleted)
- {
- completedCount++;
- }
- else if (item.state == HBQueueItemStateFailed)
- {
- failedCount++;
- }
- else if (item.state == HBQueueItemStateWorking)
+ if ([item isKindOfClass:[HBQueueJobItem class]])
{
- workingCount++;
+ if (item.state == HBQueueItemStateReady)
+ {
+ pendingCount++;
+ }
+ else if (item.state == HBQueueItemStateCompleted)
+ {
+ completedCount++;
+ }
+ else if (item.state == HBQueueItemStateFailed)
+ {
+ failedCount++;
+ }
+ else if (item.state == HBQueueItemStateWorking)
+ {
+ workingCount++;
+ }
}
}
@@ -680,9 +683,9 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
/**
* Used to get the next pending queue item and return it if found
*/
-- (HBQueueItem *)nextPendingQueueItem
+- (id<HBQueueItem>)nextPendingQueueItem
{
- for (HBQueueItem *item in self.itemsInternal)
+ for (id<HBQueueItem> item in self.itemsInternal)
{
if (item.state == HBQueueItemStateReady)
{
@@ -704,11 +707,23 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
return nil;
}
+- (void)addStopAction
+{
+
+ id<HBQueueItem> nextItem = self.nextPendingQueueItem;
+ NSUInteger index = nextItem ? [self.itemsInternal indexOfObject:nextItem] : self.itemsInternal.count;
+
+ if ([nextItem isKindOfClass:[HBQueueActionStopItem class]] == NO)
+ {
+ HBQueueActionStopItem *stopItem = [[HBQueueActionStopItem alloc] init];
+ [self addItems:@[stopItem] atIndexes:[NSIndexSet indexSetWithIndex:index]];
+ }
+}
+
- (void)start
{
if (self.canEncode)
{
- self.stop = NO;
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidStartNotification object:self];
[self preventSleep];
[self encodeNextQueueItem];
@@ -720,12 +735,16 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
*/
- (void)encodeNextQueueItem
{
+ id<HBQueueItem> nextItem = self.nextPendingQueueItem;
+
// since we have completed an encode, we go to the next
- if (self.stop)
+ if ([nextItem isKindOfClass:[HBQueueActionStopItem class]])
{
if (self.isEncoding == NO)
{
[HBUtilities writeToActivityLog:"Queue manually stopped"];
+ NSUInteger index = [self.itemsInternal indexOfObject:nextItem];
+ [self removeItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
[self allowSleep];
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidCompleteNotification object:self];
}
@@ -733,10 +752,10 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
else
{
// Check to see if there are any more pending items in the queue
- HBQueueItem *nextItem = self.nextPendingQueueItem;
+ HBQueueJobItem *nextJobItem = self.nextPendingQueueItem;
HBQueueWorker *worker = self.firstAvailableWorker;
- if (nextItem && [self isDiskSpaceLowAtURL:nextItem.outputURL])
+ if (nextJobItem && [self isDiskSpaceLowAtURL:nextJobItem.outputURL])
{
[HBUtilities writeToActivityLog:"Queue Stopped, low space on destination disk"];
[self allowSleep];
@@ -753,9 +772,9 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
[NSNotificationCenter.defaultCenter postNotificationName:HBQueueLowSpaceAlertNotification object:self];
}
// If we still have more pending items in our queue, lets go to the next one
- else if (nextItem && worker && self.countOfEncodings < self.workersCount)
+ else if (nextJobItem && worker && self.countOfEncodings < self.workersCount)
{
- [worker encodeItem:nextItem];
+ [worker encodeItem:nextJobItem];
// Erase undo manager history
[self.undoManager removeAllActions];
@@ -777,7 +796,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
[self save];
}
-- (void)completedItem:(HBQueueItem *)item
+- (void)completedItem:(id<HBQueueItem>)item
{
NSParameterAssert(item);
[self save];
@@ -813,7 +832,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
if (self.isEncoding)
{
- self.stop = YES;
+ [self addStopAction];
[self doCancelAll];
}
}
@@ -825,15 +844,15 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
{
if (self.isEncoding)
{
- self.stop = YES;
+ [self addStopAction];
}
}
- (void)cancelItemsAtIndexes:(NSIndexSet *)indexes
{
- NSArray<HBQueueItem *> *items = [self.items objectsAtIndexes:indexes];
+ NSArray<id<HBQueueItem>> *items = [self.items objectsAtIndexes:indexes];
- for (HBQueueItem *item in items) {
+ for (HBQueueJobItem *item in items) {
for (HBQueueWorker *worker in self.workers) {
if (worker.item == item) {
[worker cancel];
@@ -842,7 +861,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
}
}
-- (nullable HBQueueWorker *)workerForItem:(HBQueueItem *)item
+- (nullable HBQueueWorker *)workerForItem:(HBQueueJobItem *)item
{
for (HBQueueWorker *worker in self.workers)
{
diff --git a/macosx/HBQueueActionItem.h b/macosx/HBQueueActionItem.h
new file mode 100644
index 000000000..6746e624b
--- /dev/null
+++ b/macosx/HBQueueActionItem.h
@@ -0,0 +1,22 @@
+/* HBQueueActionItem.h $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+#import "HBQueueItem.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface HBQueueActionStopItem : NSObject<HBQueueItem>
+
+/// Current state of the item.
+@property (nonatomic) HBQueueItemState state;
+
+/// The title of the item.
+@property (nonatomic, readonly) NSString *title;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBQueueActionItem.m b/macosx/HBQueueActionItem.m
new file mode 100644
index 000000000..41401f271
--- /dev/null
+++ b/macosx/HBQueueActionItem.m
@@ -0,0 +1,68 @@
+/* HBQueueActionItem.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import "HBQueueActionItem.h"
+#import "HBCodingUtilities.h"
+
+@implementation HBQueueActionStopItem
+
+#pragma mark - NSSecureCoding
+
+- (instancetype)init
+{
+ self = [super init];
+ if (self) {
+ _state = HBQueueItemStateReady;
+ }
+ return self;
+}
+
+- (NSString *)title
+{
+ return NSLocalizedString(@"Stop", @"Queue -> Stop action");
+}
+
+- (BOOL)hasFileRepresentation
+{
+ return NO;
+}
+
+- (NSAttributedString *)attributedDescription
+{
+ return [[NSAttributedString alloc] initWithString:NSLocalizedString(@"Stop action.", @"Queue -> Stop action")
+ attributes:@{NSFontAttributeName: [NSFont systemFontOfSize:NSFont.smallSystemFontSize]}];
+}
+
+- (NSImage *)image
+{
+ return [NSImage imageNamed:@"EncodeCanceled"];
+}
+
++ (BOOL)supportsSecureCoding
+{
+ return YES;
+}
+
+static NSString *versionKey = @"HBQueueActionItemVersion";
+
+- (void)encodeWithCoder:(nonnull NSCoder *)coder {
+ [coder encodeInt:1 forKey:versionKey];
+ encodeInteger(_state);
+}
+
+- (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
+ int version = [decoder decodeIntForKey:versionKey];
+
+ if (version == 1 && (self = [super init]))
+ {
+ decodeInteger(_state); if (_state < HBQueueItemStateReady || _state > HBQueueItemStateRescanning) { goto fail; }
+ return self;
+ }
+fail:
+ return nil;
+}
+
+@end
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index d67f11483..00f9f6992 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -68,7 +68,7 @@
[NSNotificationCenter.defaultCenter addObserverForName:HBQueueDidCompleteItemNotification object:_queue queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification * _Nonnull note) {
// Run the per item notification and actions
- HBQueueItem *item = note.userInfo[HBQueueItemNotificationItemKey];
+ HBQueueJobItem *item = note.userInfo[HBQueueItemNotificationItemKey];
if (item.state == HBQueueItemStateCompleted)
{
[self sendToExternalApp:item];
@@ -308,7 +308,7 @@
// if this is a currently encoding job, we need to be sure to alert the user,
// to let them decide to cancel it first, then if they do, we can come back and
// remove it
- NSIndexSet *workingIndexes = [self.queue.items indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
+ NSIndexSet *workingIndexes = [self.queue.items indexesOfObjectsUsingBlock:^BOOL(HBQueueJobItem *item) {
return item.state == HBQueueItemStateWorking;
}];
@@ -349,7 +349,7 @@
}
}
-- (void)doEditQueueItem:(HBQueueItem *)item
+- (void)doEditQueueItem:(HBQueueJobItem *)item
{
[self.queue prepareItemForEditingAtIndex:[self.queue.items indexOfObject:item]];
@@ -371,7 +371,7 @@
/**
* Send the selected queue item back to the main window for rescan and possible edit.
*/
-- (void)editQueueItem:(HBQueueItem *)item
+- (void)editQueueItem:(HBQueueJobItem *)item
{
// if this is a currently encoding item, we need to be sure to alert the user,
// to let them decide to cancel it first, then if they do, we can come back and
@@ -448,7 +448,7 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
*
* @param job the job of the file to send
*/
-- (void)sendToExternalApp:(HBQueueItem *)item
+- (void)sendToExternalApp:(HBQueueJobItem *)item
{
// This end of encode action is called as each encode rolls off of the queue
if ([NSUserDefaults.standardUserDefaults boolForKey:HBSendToAppEnabled] == YES)
@@ -489,7 +489,7 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
/**
* Runs the alert for a single job
*/
-- (void)itemCompletedAlerts:(HBQueueItem *)item
+- (void)itemCompletedAlerts:(HBQueueJobItem *)item
{
NSUserDefaults *ud = NSUserDefaults.standardUserDefaults;
@@ -735,7 +735,7 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
}
else
{
- NSArray<HBQueueItem *> *items = [self.queue.items objectsAtIndexes:indexes];
+ NSArray<id<HBQueueItem>> *items = [self.queue.items objectsAtIndexes:indexes];
self.infoViewController.item = items.firstObject;
[self switchToViewController:self.infoViewController];
}
@@ -760,9 +760,12 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
}
}
-- (void)tableViewEditItem:(HBQueueItem *)item
+- (void)tableViewEditItem:(id<HBQueueItem>)item
{
- [self editQueueItem:item];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ [self editQueueItem:item];
+ }
}
- (void)tableViewRemoveItemsAtIndexes:(nonnull NSIndexSet *)indexes
@@ -774,15 +777,21 @@ NSString * const HBQueueItemNotificationPathKey = @"HBQueueItemNotificationPathK
[self resetQueueItemsAtIndexes:indexes];
}
-- (void)detailsViewEditItem:(nonnull HBQueueItem *)item
+- (void)detailsViewEditItem:(nonnull id<HBQueueItem>)item
{
- [self editQueueItem:item];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ [self editQueueItem:item];
+ }
}
-- (void)detailsViewResetItem:(nonnull HBQueueItem *)item
+- (void)detailsViewResetItem:(nonnull id<HBQueueItem>)item
{
- NSUInteger index = [self.queue.items indexOfObject:item];
- [self resetQueueItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ NSUInteger index = [self.queue.items indexOfObject:item];
+ [self resetQueueItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
+ }
}
- (IBAction)resetAll:(id)sender
diff --git a/macosx/HBQueueDockTileController.m b/macosx/HBQueueDockTileController.m
index 9e9aa8a2e..8e5063334 100644
--- a/macosx/HBQueueDockTileController.m
+++ b/macosx/HBQueueDockTileController.m
@@ -75,8 +75,8 @@
- (void)setUpForSingleWorker
{
self.progress = 0;
- HBQueueItem *firstWorkingItem = nil;
- for (HBQueueItem *item in self.queue.items)
+ HBQueueJobItem *firstWorkingItem = nil;
+ for (HBQueueJobItem *item in self.queue.items)
{
if (item.state == HBQueueItemStateWorking)
{
diff --git a/macosx/HBQueueInfoViewController.h b/macosx/HBQueueInfoViewController.h
index 0fcc747db..9f9362a1d 100644
--- a/macosx/HBQueueInfoViewController.h
+++ b/macosx/HBQueueInfoViewController.h
@@ -11,8 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@protocol HBQueueDetailsViewControllerDelegate
-- (void)detailsViewEditItem:(HBQueueItem *)item;
-- (void)detailsViewResetItem:(HBQueueItem *)item;
+- (void)detailsViewEditItem:(id<HBQueueItem>)item;
+- (void)detailsViewResetItem:(id<HBQueueItem>)item;
@end
@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithDelegate:(id<HBQueueDetailsViewControllerDelegate>)delegate;
-@property (nonatomic) HBQueueItem *item;
+@property (nonatomic) id<HBQueueItem> item;
@end
diff --git a/macosx/HBQueueInfoViewController.m b/macosx/HBQueueInfoViewController.m
index 77bd3f4bc..29b0aeb36 100644
--- a/macosx/HBQueueInfoViewController.m
+++ b/macosx/HBQueueInfoViewController.m
@@ -5,6 +5,7 @@
It may be used under the terms of the GNU General Public License. */
#import "HBQueueInfoViewController.h"
+#import "HBQueueJobItem.h"
static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContext;
@@ -19,6 +20,7 @@ static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContex
@property (nonatomic, weak) id<HBQueueDetailsViewControllerDelegate> delegate;
@property (nonatomic) BOOL canReset;
+@property (nonatomic) BOOL canEdit;
@end
@@ -37,7 +39,7 @@ static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContex
- (void)viewDidLoad
{
[super viewDidLoad];
- [self updateLabels];
+ [self updateUI];
[self addObserver:self forKeyPath:@"item.state" options:0 context:HBQueueInfoViewControllerContext];
}
@@ -67,17 +69,28 @@ static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContex
{
self.canReset = self.item && (self.item.state != HBQueueItemStateWorking &&
self.item.state != HBQueueItemStateRescanning && self.item.state != HBQueueItemStateReady);
+ self.canEdit = self.item && self.item.hasFileRepresentation;
}
- (void)updateLabels
{
if (self.item)
{
- self.statisticsLabel.hidden = self.item.startedDate == nil;
- self.statisticsHeader.hidden = self.item.startedDate == nil;
- self.summaryLabel.hidden = NO;
+ if ([self.item isKindOfClass:[HBQueueJobItem class]])
+ {
+ HBQueueJobItem *jobItem = (HBQueueJobItem *)self.item;
+ self.statisticsLabel.hidden = jobItem.startedDate == nil;
+ self.statisticsHeader.hidden = jobItem.startedDate == nil;
+
+ self.statisticsLabel.attributedStringValue = jobItem.attributedStatistics;
+ }
+ else
+ {
+ self.statisticsLabel.hidden = YES;
+ self.statisticsHeader.hidden = YES;
+ }
- self.statisticsLabel.attributedStringValue = self.item.attributedStatistics;
+ self.summaryLabel.hidden = NO;
self.summaryLabel.attributedStringValue = self.item.attributedDescription;
dispatch_async(dispatch_get_main_queue(), ^{
@@ -103,7 +116,7 @@ static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContex
[self updateDivider];
}
-- (void)setItem:(HBQueueItem *)item
+- (void)setItem:(id<HBQueueItem>)item
{
_item = item;
}
diff --git a/macosx/HBQueueItem.h b/macosx/HBQueueItem.h
index 7f80ee36f..bd883c423 100644
--- a/macosx/HBQueueItem.h
+++ b/macosx/HBQueueItem.h
@@ -1,18 +1,15 @@
-/* HBQueueItem.m $
+/* HBQueueItem.h $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
-#import <Foundation/Foundation.h>
-
-@import HandBrakeKit;
+#import <Cocoa/Cocoa.h>
NS_ASSUME_NONNULL_BEGIN
-/**
- * A flag to indicate the item's state
- */
+
+/// A flag to indicate the item's state
typedef NS_ENUM(NSUInteger, HBQueueItemState) {
HBQueueItemStateReady,
HBQueueItemStateWorking,
@@ -22,43 +19,19 @@ typedef NS_ENUM(NSUInteger, HBQueueItemState) {
HBQueueItemStateRescanning
};
-@interface HBQueueItem : NSObject<NSSecureCoding>
-
-- (instancetype)init NS_UNAVAILABLE;
-- (instancetype)initWithJob:(HBJob *)job;
+@protocol HBQueueItem <NSObject, NSSecureCoding>
-@property (nonatomic, readonly) HBJob *job;
-
-/// Current state of the job.
+/// Current state of the item.
@property (nonatomic) HBQueueItemState state;
-/// The file URL of the source.
-@property (nonatomic, readonly) NSURL *fileURL;
-
-/// The directory URL at which the new file will be created.
-@property (nonatomic, readonly, copy) NSURL *outputURL;
-
-/// The name of the new file that will be created.
-@property (nonatomic, readonly, copy) NSString *outputFileName;
+/// Whether the item has a file representation on disk or not.
+@property (nonatomic, readonly) BOOL hasFileRepresentation;
-/// The file URL at which the new file will be created.
-@property (nonatomic, readonly, copy) NSURL *completeOutputURL;
-
-/// The file URL at which the new file will be created.
-@property (nonatomic, copy, nullable) NSURL *activityLogURL;
-
-@property (nonatomic) NSTimeInterval encodeDuration;
-@property (nonatomic) NSTimeInterval pauseDuration;
-
-@property (nonatomic, nullable) NSDate *startedDate;
-@property (nonatomic, nullable) NSDate *endedDate;
-
-- (void)pausedAtDate:(NSDate *)date;
-- (void)resumedAtDate:(NSDate *)date;
-
-@property (nonatomic, readonly) NSUInteger fileSize;
+/// The title of the item.
+@property (nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) NSAttributedString *attributedDescription;
-@property (nonatomic, readonly, nullable) NSAttributedString *attributedStatistics;
+
+@property (nonatomic, readonly) NSImage *image;
@end
diff --git a/macosx/HBQueueItemView.h b/macosx/HBQueueItemView.h
index 43235e30f..823a5129b 100644
--- a/macosx/HBQueueItemView.h
+++ b/macosx/HBQueueItemView.h
@@ -5,22 +5,21 @@
It may be used under the terms of the GNU General Public License. */
#import <Cocoa/Cocoa.h>
-
-@class HBQueueItem;
+#import "HBQueueItem.h"
NS_ASSUME_NONNULL_BEGIN
@protocol HBQueueItemViewDelegate
-- (void)revealQueueItem:(HBQueueItem *)job;
-- (void)removeQueueItem:(HBQueueItem *)job;
+- (void)revealQueueItem:(id<HBQueueItem>)item;
+- (void)removeQueueItem:(id<HBQueueItem>)item;
@end
@interface HBQueueItemView : NSTableCellView
-@property (nonatomic, weak, nullable) HBQueueItem *item;
-@property (nonatomic, weak, nullable) id <HBQueueItemViewDelegate> delegate;
+@property (nonatomic, weak, nullable) id<HBQueueItem> item;
+@property (nonatomic, weak, nullable) id<HBQueueItemViewDelegate> delegate;
@end
diff --git a/macosx/HBQueueItemView.m b/macosx/HBQueueItemView.m
index 72e585adb..d0d1d54f4 100644
--- a/macosx/HBQueueItemView.m
+++ b/macosx/HBQueueItemView.m
@@ -5,7 +5,6 @@
It may be used under the terms of the GNU General Public License. */
#import "HBQueueItemView.h"
-#import "HBQueueItem.h"
@interface HBQueueItemView ()
@@ -15,7 +14,7 @@
@implementation HBQueueItemView
-- (void)setItem:(HBQueueItem *)item
+- (void)setItem:(id<HBQueueItem>)item
{
_item = item;
[self reload];
@@ -32,7 +31,7 @@
- (void)HB_updateLabel
{
- self.textField.stringValue = _item.outputFileName;
+ self.textField.stringValue = _item.title;
}
- (void)HB_updateState
@@ -61,7 +60,7 @@
label = NSLocalizedString(@"Rescanning for editing", @"HBQueueItemView -> Encode state accessibility label");
break;
default:
- state = [NSImage imageNamed:@"JobSmall"];
+ state = _item.image;
NSLocalizedString(@"Encode ready", @"HBQueueItemView -> Encode state accessibility label");
break;
}
@@ -79,7 +78,7 @@
darkAqua = [self.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameDarkAqua]] == NSAppearanceNameDarkAqua ? YES : NO;
}
- if (_item.state == HBQueueItemStateCompleted)
+ if (_item.state == HBQueueItemStateCompleted && _item.hasFileRepresentation)
{
[_removeButton setAction: @selector(revealQueueItem:)];
if (self.backgroundStyle == NSBackgroundStyleEmphasized)
diff --git a/macosx/HBQueueItemWorkingView.m b/macosx/HBQueueItemWorkingView.m
index 07c5bea66..9bb863a70 100644
--- a/macosx/HBQueueItemWorkingView.m
+++ b/macosx/HBQueueItemWorkingView.m
@@ -6,7 +6,7 @@
#import "HBQueueItemWorkingView.h"
-#import "HBQueueItem.h"
+#import "HBQueueJobItem.h"
#import "HBQueueWorker.h"
#import "HBAttributedStringAdditions.h"
@@ -72,7 +72,7 @@
[self setUpObserversWithWorker:worker];
}
-- (void)setItem:(HBQueueItem *)item
+- (void)setItem:(HBQueueJobItem *)item
{
[self removeObservers];
self.progressField.stringValue = @"";
diff --git a/macosx/HBQueueJobItem.h b/macosx/HBQueueJobItem.h
new file mode 100644
index 000000000..813b197d1
--- /dev/null
+++ b/macosx/HBQueueJobItem.h
@@ -0,0 +1,54 @@
+/* HBQueueJobItem.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
+
+#import <Cocoa/Cocoa.h>
+#import "HBQueueItem.h"
+
+@import HandBrakeKit;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface HBQueueJobItem : NSObject<HBQueueItem>
+
+- (instancetype)init NS_UNAVAILABLE;
+- (instancetype)initWithJob:(HBJob *)job;
+
+@property (nonatomic, readonly) HBJob *job;
+
+/// Current state of the job.
+@property (nonatomic) HBQueueItemState state;
+
+/// The file URL of the source.
+@property (nonatomic, readonly) NSURL *fileURL;
+
+/// The directory URL at which the new file will be created.
+@property (nonatomic, readonly, copy) NSURL *outputURL;
+
+/// The name of the new file that will be created.
+@property (nonatomic, readonly, copy) NSString *outputFileName;
+
+/// The file URL at which the new file will be created.
+@property (nonatomic, readonly, copy) NSURL *completeOutputURL;
+
+/// The file URL at which the new file will be created.
+@property (nonatomic, copy, nullable) NSURL *activityLogURL;
+
+@property (nonatomic) NSTimeInterval encodeDuration;
+@property (nonatomic) NSTimeInterval pauseDuration;
+
+@property (nonatomic, nullable) NSDate *startedDate;
+@property (nonatomic, nullable) NSDate *endedDate;
+
+- (void)pausedAtDate:(NSDate *)date;
+- (void)resumedAtDate:(NSDate *)date;
+
+@property (nonatomic, readonly) NSUInteger fileSize;
+@property (nonatomic, readonly) NSAttributedString *attributedDescription;
+@property (nonatomic, readonly, nullable) NSAttributedString *attributedStatistics;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBQueueItem.m b/macosx/HBQueueJobItem.m
index cd7b097a2..619b60a4f 100644
--- a/macosx/HBQueueItem.m
+++ b/macosx/HBQueueJobItem.m
@@ -1,10 +1,10 @@
-/* HBQueueItem.m $
+/* HBQueueJobItem.m $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
-#import "HBQueueItem.h"
+#import "HBQueueJobItem.h"
#import "HBCodingUtilities.h"
#import "HBAttributedStringAdditions.h"
@@ -16,7 +16,7 @@ static NSDictionary *detailAttr;
static NSDictionary *detailBoldAttr;
static NSDictionary *shortHeightAttr;
-@interface HBQueueItem ()
+@interface HBQueueJobItem ()
@property (nonatomic, nullable) NSDate *pausedDate;
@property (nonatomic, nullable) NSDate *resumedDate;
@@ -27,11 +27,11 @@ static NSDictionary *shortHeightAttr;
@end
-@implementation HBQueueItem
+@implementation HBQueueJobItem
+ (void)initialize
{
- if (self == [HBQueueItem class]) {
+ if (self == [HBQueueJobItem class]) {
_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setDateStyle:NSDateFormatterLongStyle];
[_dateFormatter setTimeStyle:NSDateFormatterLongStyle];
@@ -82,6 +82,21 @@ static NSDictionary *shortHeightAttr;
}
}
+- (NSString *)title
+{
+ return _job.outputFileName;
+}
+
+- (BOOL)hasFileRepresentation
+{
+ return YES;
+}
+
+- (NSImage *)image
+{
+ return [NSImage imageNamed:@"JobSmall"];;
+}
+
- (NSURL *)fileURL
{
return _job.fileURL;
diff --git a/macosx/HBQueueTableViewController.h b/macosx/HBQueueTableViewController.h
index 1bbe36264..6f3b116d2 100644
--- a/macosx/HBQueueTableViewController.h
+++ b/macosx/HBQueueTableViewController.h
@@ -7,14 +7,14 @@
#import <Cocoa/Cocoa.h>
#import "HBQueue.h"
-#import "HBQueueItem.h"
+#import "HBQueueJobItem.h"
NS_ASSUME_NONNULL_BEGIN
@protocol HBQueueTableViewControllerDelegate
- (void)tableViewDidSelectItemsAtIndexes:(NSIndexSet *)indexes;
-- (void)tableViewEditItem:(HBQueueItem *)item;
+- (void)tableViewEditItem:(HBQueueJobItem *)item;
- (void)tableViewResetItemsAtIndexes:(NSIndexSet *)indexes;
- (void)tableViewRemoveItemsAtIndexes:(NSIndexSet *)indexes;
diff --git a/macosx/HBQueueTableViewController.m b/macosx/HBQueueTableViewController.m
index 78aaca7a6..1601000c5 100644
--- a/macosx/HBQueueTableViewController.m
+++ b/macosx/HBQueueTableViewController.m
@@ -17,7 +17,7 @@
@interface HBQueueTableViewController () <NSTableViewDataSource, NSTableViewDelegate, HBQueueItemViewDelegate>
@property (nonatomic, weak, readonly) HBQueue *queue;
-@property (nonatomic) NSArray<HBQueueItem *> *dragNodesArray;
+@property (nonatomic) NSArray<id<HBQueueItem>> *dragNodesArray;
@property (nonatomic, strong) id<HBQueueTableViewControllerDelegate> delegate;
@@ -82,7 +82,7 @@
typedef void (^HBUpdateHeight)(NSNotification *note);
HBUpdateHeight updateHeight = ^void(NSNotification *note) {
- HBQueueItem *item = note.userInfo[HBQueueItemNotificationItemKey];
+ HBQueueJobItem *item = note.userInfo[HBQueueItemNotificationItemKey];
NSUInteger index = [self.queue.items indexOfObject:item];
if (index != NSNotFound)
{
@@ -119,8 +119,12 @@
NSUInteger currentIndex = targetedRows.firstIndex;
while (currentIndex != NSNotFound) {
- NSURL *url = [[self.queue.items objectAtIndex:currentIndex] completeOutputURL];
- [urls addObject:url];
+ id<HBQueueItem> item = [self.queue.items objectAtIndex:currentIndex];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ NSURL *url = [(HBQueueJobItem *)item completeOutputURL];
+ [urls addObject:url];
+ }
currentIndex = [targetedRows indexGreaterThanIndex:currentIndex];
}
@@ -137,8 +141,12 @@
NSUInteger currentIndex = targetedRows.firstIndex;
while (currentIndex != NSNotFound) {
- NSURL *url = [[self.queue.items objectAtIndex:currentIndex] fileURL];
- [urls addObject:url];
+ id<HBQueueItem> item = [self.queue.items objectAtIndex:currentIndex];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ NSURL *url = [(HBQueueJobItem *)item fileURL];
+ [urls addObject:url];
+ }
currentIndex = [targetedRows indexGreaterThanIndex:currentIndex];
}
@@ -155,10 +163,14 @@
NSUInteger currentIndex = targetedRows.firstIndex;
while (currentIndex != NSNotFound) {
- NSURL *url = [[self.queue.items objectAtIndex:currentIndex] activityLogURL];
- if (url)
+ id<HBQueueItem> item = [self.queue.items objectAtIndex:currentIndex];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
{
- [urls addObject:url];
+ NSURL *url = [(HBQueueJobItem *)item activityLogURL];
+ if (url)
+ {
+ [urls addObject:url];
+ }
}
currentIndex = [targetedRows indexGreaterThanIndex:currentIndex];
}
@@ -187,7 +199,7 @@
- (IBAction)editSelectedQueueItem:(id)sender
{
NSInteger row = self.tableView.clickedRow;
- HBQueueItem *item = [self.queue.items objectAtIndex:row];
+ HBQueueJobItem *item = [self.queue.items objectAtIndex:row];
if (item)
{
[self.delegate tableViewEditItem:item];
@@ -248,7 +260,7 @@
row:(NSInteger)row
{
- HBQueueItem *item = self.queue.items[row];
+ id<HBQueueItem> item = self.queue.items[row];
HBQueueItemView *view = nil;
if (item.state == HBQueueItemStateWorking)
@@ -277,21 +289,24 @@
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
- HBQueueItem *item = self.queue.items[row];
+ id<HBQueueItem> item = self.queue.items[row];
return item.state == HBQueueItemStateWorking ? 58 : 22;
}
#pragma mark NSQueueItemView delegate
-- (void)removeQueueItem:(nonnull HBQueueItem *)item
+- (void)removeQueueItem:(nonnull id<HBQueueItem>)item
{
NSUInteger index = [self.queue.items indexOfObject:item];
[self.delegate tableViewRemoveItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
}
-- (void)revealQueueItem:(nonnull HBQueueItem *)item
+- (void)revealQueueItem:(nonnull id<HBQueueItem>)item
{
- [NSWorkspace.sharedWorkspace activateFileViewerSelectingURLs:@[item.completeOutputURL]];
+ if ([item isKindOfClass:[HBQueueJobItem class]])
+ {
+ [NSWorkspace.sharedWorkspace activateFileViewerSelectingURLs:@[[(HBQueueJobItem *)item completeOutputURL]]];
+ }
}
#pragma mark NSTableView delegate
@@ -309,7 +324,7 @@
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
- NSArray<HBQueueItem *> *items = [self.queue.items objectsAtIndexes:rowIndexes];
+ NSArray<id<HBQueueItem>> *items = [self.queue.items objectsAtIndexes:rowIndexes];
// Dragging is only allowed of the pending items.
if (items[0].state != HBQueueItemStateReady)
{
diff --git a/macosx/HBQueueWorker.h b/macosx/HBQueueWorker.h
index 340016fb8..a60e51d47 100644
--- a/macosx/HBQueueWorker.h
+++ b/macosx/HBQueueWorker.h
@@ -6,7 +6,7 @@
#import <Foundation/Foundation.h>
-#import "HBQueueItem.h"
+#import "HBQueueJobItem.h"
NS_ASSUME_NONNULL_BEGIN
@@ -28,9 +28,9 @@ extern NSString * const HBQueueWorkerItemNotificationItemKey; // HB
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithXPCServiceName:(NSString *)serviceName;
-@property (nonatomic, nullable, readonly) HBQueueItem *item;
+@property (nonatomic, nullable, readonly) HBQueueJobItem *item;
-- (void)encodeItem:(HBQueueItem *)item;
+- (void)encodeItem:(HBQueueJobItem *)item;
- (void)cancel;
@property (nonatomic, readonly) BOOL canEncode;
diff --git a/macosx/HBQueueWorker.m b/macosx/HBQueueWorker.m
index 4031bc4b0..d7ddde8ce 100644
--- a/macosx/HBQueueWorker.m
+++ b/macosx/HBQueueWorker.m
@@ -30,7 +30,7 @@ NSString * const HBQueueWorkerItemNotificationItemKey = @"HBQueueWorkerItemNotif
@property (nonatomic, readonly) HBRemoteCore *core;
-@property (nonatomic, nullable) HBQueueItem *item;
+@property (nonatomic, nullable) HBQueueJobItem *item;
@property (nonatomic, nullable) HBJobOutputFileWriter *currentLog;
@end
@@ -115,7 +115,7 @@ NSString * const HBQueueWorkerItemNotificationItemKey = @"HBQueueWorkerItemNotif
[self.core preventSleep];
}
-- (void)completedItem:(HBQueueItem *)item result:(HBCoreResult)result
+- (void)completedItem:(HBQueueJobItem *)item result:(HBCoreResult)result
{
NSParameterAssert(item);
@@ -156,7 +156,7 @@ NSString * const HBQueueWorkerItemNotificationItemKey = @"HBQueueWorkerItemNotif
/**
* Here we actually tell hb_scan to perform the source scan, using the path to source and title number
*/
-- (void)encodeItem:(HBQueueItem *)item
+- (void)encodeItem:(HBQueueJobItem *)item
{
NSParameterAssert(item);
@@ -219,7 +219,7 @@ NSString * const HBQueueWorkerItemNotificationItemKey = @"HBQueueWorkerItemNotif
/**
* This assumes that we have re-scanned and loaded up a new queue item to send to libhb
*/
-- (void)realEncodeItem:(HBQueueItem *)item
+- (void)realEncodeItem:(HBQueueJobItem *)item
{
HBJob *job = item.job;
diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj
index 568d66540..ee74f71df 100644
--- a/macosx/HandBrake.xcodeproj/project.pbxproj
+++ b/macosx/HandBrake.xcodeproj/project.pbxproj
@@ -210,6 +210,7 @@
A939DD8B1FC8826A00135F2A /* HBPresetsMenuBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = A939DD8A1FC8826A00135F2A /* HBPresetsMenuBuilder.m */; };
A93B49221DA3AA6900DD70A3 /* HBToolbarBadgedItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A93B49211DA3AA6900DD70A3 /* HBToolbarBadgedItem.m */; };
A93E0ED31972957000FD67FB /* HBVideoController.m in Sources */ = {isa = PBXBuildFile; fileRef = A93E0ED11972957000FD67FB /* HBVideoController.m */; };
+ A942B66D250BB1FE00049203 /* HBQueueActionItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A942B66C250BB1FE00049203 /* HBQueueActionItem.m */; };
A943874122ED911B005F701B /* HBJob+HBAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = A943874022ED911B005F701B /* HBJob+HBAdditions.m */; };
A9442D2424DAC04E005EDF62 /* org.sparkle-project.Downloader.xpc in Copy Files */ = {isa = PBXBuildFile; fileRef = A9442D1824DAC03A005EDF62 /* org.sparkle-project.Downloader.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
A9442D2524DAC04E005EDF62 /* org.sparkle-project.InstallerConnection.xpc in Copy Files */ = {isa = PBXBuildFile; fileRef = A9442D1424DAC03A005EDF62 /* org.sparkle-project.InstallerConnection.xpc */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
@@ -225,7 +226,7 @@
A957EBCD218DBE5900007988 /* HBAutoNamer.m in Sources */ = {isa = PBXBuildFile; fileRef = A957EBCC218DBE5900007988 /* HBAutoNamer.m */; };
A958EAC222E24D6400D83AF4 /* HBQueueTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A958EAC422E24D6400D83AF4 /* HBQueueTableViewController.xib */; };
A958EAC522E24D6800D83AF4 /* HBQueueInfoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A958EAC722E24D6800D83AF4 /* HBQueueInfoViewController.xib */; };
- A95BA15D220C968500A2F9F9 /* HBQueueItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A95BA15C220C968500A2F9F9 /* HBQueueItem.m */; };
+ A95BA15D220C968500A2F9F9 /* HBQueueJobItem.m in Sources */ = {isa = PBXBuildFile; fileRef = A95BA15C220C968500A2F9F9 /* HBQueueJobItem.m */; };
A95BC1E71CD2548A008D6A33 /* volHighTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = A95BC1E51CD2548A008D6A33 /* volHighTemplate.pdf */; };
A95BC1E81CD2548A008D6A33 /* volLowTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = A95BC1E61CD2548A008D6A33 /* volLowTemplate.pdf */; };
A96127DF22E0994E0086E6DC /* HBQueueInfoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A96127DD22E0994E0086E6DC /* HBQueueInfoViewController.m */; };
@@ -774,6 +775,9 @@
A93FD4731A62ABE800A6AC43 /* HBAudio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBAudio.h; sourceTree = "<group>"; };
A93FD4741A62ABE800A6AC43 /* HBAudio.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBAudio.m; sourceTree = "<group>"; };
A941ACB91CD75B4E0029D06A /* HBHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBHUD.h; sourceTree = "<group>"; };
+ A942B668250BA70400049203 /* HBQueueItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBQueueItem.h; sourceTree = "<group>"; };
+ A942B66B250BB1FE00049203 /* HBQueueActionItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBQueueActionItem.h; sourceTree = "<group>"; };
+ A942B66C250BB1FE00049203 /* HBQueueActionItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBQueueActionItem.m; sourceTree = "<group>"; };
A943873F22ED911B005F701B /* HBJob+HBAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HBJob+HBAdditions.h"; sourceTree = "<group>"; };
A943874022ED911B005F701B /* HBJob+HBAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "HBJob+HBAdditions.m"; sourceTree = "<group>"; };
A9442CDD24DABFED005EDF62 /* Sparkle.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Sparkle.xcodeproj; path = Sparkle/Sparkle.xcodeproj; sourceTree = "<group>"; };
@@ -803,8 +807,8 @@
A958EAC622E24D6800D83AF4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/HBQueueInfoViewController.xib; sourceTree = "<group>"; };
A9597A281A49749D00007771 /* HBRange+UIAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "HBRange+UIAdditions.h"; sourceTree = "<group>"; };
A9597A291A49749D00007771 /* HBRange+UIAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "HBRange+UIAdditions.m"; sourceTree = "<group>"; };
- A95BA15B220C968500A2F9F9 /* HBQueueItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBQueueItem.h; sourceTree = "<group>"; };
- A95BA15C220C968500A2F9F9 /* HBQueueItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBQueueItem.m; sourceTree = "<group>"; };
+ A95BA15B220C968500A2F9F9 /* HBQueueJobItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBQueueJobItem.h; sourceTree = "<group>"; };
+ A95BA15C220C968500A2F9F9 /* HBQueueJobItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBQueueJobItem.m; sourceTree = "<group>"; };
A95BC1E51CD2548A008D6A33 /* volHighTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = volHighTemplate.pdf; sourceTree = "<group>"; };
A95BC1E61CD2548A008D6A33 /* volLowTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = volLowTemplate.pdf; sourceTree = "<group>"; };
A95CB2FB217B6D07001E9F51 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@@ -1491,8 +1495,11 @@
children = (
A97ECB8022E1D85500570935 /* HBQueue.h */,
A97ECB8122E1D85500570935 /* HBQueue.m */,
- A95BA15B220C968500A2F9F9 /* HBQueueItem.h */,
- A95BA15C220C968500A2F9F9 /* HBQueueItem.m */,
+ A942B668250BA70400049203 /* HBQueueItem.h */,
+ A942B66B250BB1FE00049203 /* HBQueueActionItem.h */,
+ A942B66C250BB1FE00049203 /* HBQueueActionItem.m */,
+ A95BA15B220C968500A2F9F9 /* HBQueueJobItem.h */,
+ A95BA15C220C968500A2F9F9 /* HBQueueJobItem.m */,
A9A5F7D3243DD90100C82EC8 /* HBQueueWorker.h */,
A9A5F7D4243DD90100C82EC8 /* HBQueueWorker.m */,
A9AA447C1970726500D7DEFC /* HBQueueController.h */,
@@ -2490,6 +2497,7 @@
A954010322FF397000F83A5F /* HBRedirect.m in Sources */,
A916C99B1C844A0800C7B560 /* HBTableView.m in Sources */,
A916C9991C8449E200C7B560 /* main.m in Sources */,
+ A942B66D250BB1FE00049203 /* HBQueueActionItem.m in Sources */,
A973E10C216E74E900D498EC /* HBThumbnailItemView.m in Sources */,
A916C9981C8449DB00C7B560 /* HBTitleSelectionController.m in Sources */,
A943874122ED911B005F701B /* HBJob+HBAdditions.m in Sources */,
@@ -2531,7 +2539,7 @@
273F20B314ADBE670021BE6D /* HBOutputPanelController.m in Sources */,
A9C61F9E22E31CDB00C28E7C /* HBFlippedClipView.m in Sources */,
273F20B414ADBE670021BE6D /* HBOutputRedirect.m in Sources */,
- A95BA15D220C968500A2F9F9 /* HBQueueItem.m in Sources */,
+ A95BA15D220C968500A2F9F9 /* HBQueueJobItem.m in Sources */,
A964D3A822FDE91B00DFCAEA /* HBRemoteCore.m in Sources */,
A9D0FA771C1C284D0003F2A9 /* HBFocusRingView.m in Sources */,
A91AFD0C1A948827009BECED /* HBOutputFileWriter.m in Sources */,