summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/HBQueue.h2
-rw-r--r--macosx/HBQueue.m26
-rw-r--r--macosx/HBQueueController.m19
-rw-r--r--macosx/HBQueueInfoViewController.m3
-rw-r--r--macosx/HBQueueItem.h3
-rw-r--r--macosx/HBQueueItem.m2
-rw-r--r--macosx/HBQueueItemView.m4
7 files changed, 37 insertions, 22 deletions
diff --git a/macosx/HBQueue.h b/macosx/HBQueue.h
index ad8e6517a..9f86eb22b 100644
--- a/macosx/HBQueue.h
+++ b/macosx/HBQueue.h
@@ -55,6 +55,8 @@ extern NSString * const HBQueueItemNotificationItemKey; // HBQueueI
- (BOOL)itemExistAtURL:(NSURL *)url;
+- (void)prepareItemForEditingAtIndex:(NSUInteger)index;
+
- (void)removeAllItems;
- (void)removeCompletedAndCancelledItems;
- (void)removeNotWorkingItems;
diff --git a/macosx/HBQueue.m b/macosx/HBQueue.m
index c6b0a882e..169ca9649 100644
--- a/macosx/HBQueue.m
+++ b/macosx/HBQueue.m
@@ -260,6 +260,23 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
[self save];
}
+- (void)prepareItemForEditingAtIndex:(NSUInteger)index
+{
+ HBQueueItem *item = self.itemsInternal[index];
+ NSIndexSet *indexes = [NSIndexSet indexSetWithIndex:index];
+
+ if (item.state == HBQueueItemStateWorking)
+ {
+ [self cancelItemsAtIndexes:indexes];
+ }
+
+ item.state = HBQueueItemStateRescanning;
+ [NSNotificationCenter.defaultCenter postNotificationName:HBQueueDidChangeItemNotification
+ object:self
+ userInfo:@{HBQueueItemNotificationIndexesKey: [NSIndexSet indexSetWithIndex:index]}];
+ [self updateStats];
+}
+
- (void)removeItemsAtIndexes:(NSIndexSet *)indexes
{
NSParameterAssert(indexes);
@@ -408,7 +425,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)removeNotWorkingItems
{
NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
- return (item.state != HBQueueItemStateWorking);
+ return (item.state != HBQueueItemStateWorking && item.state != HBQueueItemStateRescanning);
}];
[self removeItemsAtIndexes:indexes];
}
@@ -429,7 +446,8 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
while (currentIndex != NSNotFound) {
HBQueueItem *item = self.itemsInternal[currentIndex];
- if (item.state == HBQueueItemStateCanceled || item.state == HBQueueItemStateCompleted || item.state == HBQueueItemStateFailed)
+ if (item.state == HBQueueItemStateCanceled || item.state == HBQueueItemStateCompleted ||
+ item.state == HBQueueItemStateFailed || item.state ==HBQueueItemStateRescanning)
{
item.state = HBQueueItemStateReady;
[updatedIndexes addIndex:currentIndex];
@@ -445,7 +463,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
- (void)resetAllItems
{
NSIndexSet *indexes = [self.itemsInternal indexesOfObjectsUsingBlock:^BOOL(HBQueueItem *item) {
- return (item.state != HBQueueItemStateWorking);
+ return (item.state != HBQueueItemStateWorking && item.state != HBQueueItemStateRescanning);
}];
[self resetItemsAtIndexes:indexes];
}
@@ -469,7 +487,7 @@ NSString * const HBQueueItemNotificationItemKey = @"HBQueueItemNotificationItemK
for (HBQueueItem *item in self.itemsInternal)
{
// We want to keep any queue item that is pending or was previously being encoded
- if (item.state == HBQueueItemStateWorking)
+ if (item.state == HBQueueItemStateWorking || item.state == HBQueueItemStateRescanning)
{
item.state = HBQueueItemStateReady;
[indexes addIndex:idx];
diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m
index 02def9878..f182310ab 100644
--- a/macosx/HBQueueController.m
+++ b/macosx/HBQueueController.m
@@ -323,29 +323,18 @@
- (void)doEditQueueItem:(HBQueueItem *)item
{
- NSParameterAssert(item);
-
- if (item.state == HBQueueItemStateWorking)
- {
- NSUInteger index = [self.queue.items indexOfObject:item];
- [self.queue cancelItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
- }
- else
- {
- item.state = HBQueueItemStateWorking;
- }
+ [self.queue prepareItemForEditingAtIndex:[self.queue.items indexOfObject:item]];
[self.delegate openJob:[item.job copy] completionHandler:^(BOOL result) {
+ NSInteger index = [self.queue.items indexOfObject:item];
+ [self.queue resetItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
if (result)
{
// Now that source is loaded and settings applied, delete the queue item from the queue
- NSInteger index = [self.queue.items indexOfObject:item];
- item.state = HBQueueItemStateReady;
[self.queue removeItemsAtIndexes:[NSIndexSet indexSetWithIndex:index]];
}
else
{
- item.state = HBQueueItemStateFailed;
NSBeep();
}
}];
@@ -380,7 +369,7 @@
}
}];
}
- else if (item.state != HBQueueItemStateWorking)
+ else if (item.state != HBQueueItemStateWorking && item.state != HBQueueItemStateRescanning)
{
[self doEditQueueItem:item];
}
diff --git a/macosx/HBQueueInfoViewController.m b/macosx/HBQueueInfoViewController.m
index 27b88b81b..77bd3f4bc 100644
--- a/macosx/HBQueueInfoViewController.m
+++ b/macosx/HBQueueInfoViewController.m
@@ -65,7 +65,8 @@ static void *HBQueueInfoViewControllerContext = &HBQueueInfoViewControllerContex
- (void)updateReset
{
- self.canReset = self.item && (self.item.state != HBQueueItemStateWorking && self.item.state != HBQueueItemStateReady);
+ self.canReset = self.item && (self.item.state != HBQueueItemStateWorking &&
+ self.item.state != HBQueueItemStateRescanning && self.item.state != HBQueueItemStateReady);
}
- (void)updateLabels
diff --git a/macosx/HBQueueItem.h b/macosx/HBQueueItem.h
index e700d12de..7f80ee36f 100644
--- a/macosx/HBQueueItem.h
+++ b/macosx/HBQueueItem.h
@@ -18,7 +18,8 @@ typedef NS_ENUM(NSUInteger, HBQueueItemState) {
HBQueueItemStateWorking,
HBQueueItemStateCompleted,
HBQueueItemStateCanceled,
- HBQueueItemStateFailed
+ HBQueueItemStateFailed,
+ HBQueueItemStateRescanning
};
@interface HBQueueItem : NSObject<NSSecureCoding>
diff --git a/macosx/HBQueueItem.m b/macosx/HBQueueItem.m
index a1d767e51..cd7b097a2 100644
--- a/macosx/HBQueueItem.m
+++ b/macosx/HBQueueItem.m
@@ -247,7 +247,7 @@ static NSString *versionKey = @"HBQueueItemVersion";
if (version == 1 && (self = [super init]))
{
- decodeInteger(_state); if (_state < HBQueueItemStateReady || _state > HBQueueItemStateFailed) { goto fail; }
+ decodeInteger(_state); if (_state < HBQueueItemStateReady || _state > HBQueueItemStateRescanning) { goto fail; }
decodeObjectOrFail(_job, HBJob);
decodeObject(_activityLogURL, NSURL);
diff --git a/macosx/HBQueueItemView.m b/macosx/HBQueueItemView.m
index 5fcf55308..72e585adb 100644
--- a/macosx/HBQueueItemView.m
+++ b/macosx/HBQueueItemView.m
@@ -56,6 +56,10 @@
state = [NSImage imageNamed:@"EncodeFailed"];
label = NSLocalizedString(@"Encode failed", @"HBQueueItemView -> Encode state accessibility label");
break;
+ case HBQueueItemStateRescanning:
+ state = [NSImage imageNamed:@"EncodeWorking0"];
+ label = NSLocalizedString(@"Rescanning for editing", @"HBQueueItemView -> Encode state accessibility label");
+ break;
default:
state = [NSImage imageNamed:@"JobSmall"];
NSLocalizedString(@"Encode ready", @"HBQueueItemView -> Encode state accessibility label");