Refactor the queue optimise feature to a stand alone action.

This commit is contained in:
Damiano Galassi committed 2018-03-21 18:00:15 +01:00
1 parent 0aaaa6bfd3
commit e3cd4fd77c
6 files changed
+83 -38

No files matched your search

+4 -13
View File
@@ -80,9 +80,6 @@ static void *SBQueueContex = &SBQueueContex;
// Drag & Drop
[self.table registerForDraggedTypes:@[NSFilenamesPboardType, SublerBatchTableViewDataType]];
// Observe the changes to SBQueueOptimize
[self addObserver:self forKeyPath:@"options.SBQueueOptimize" options:NSKeyValueObservingOptionInitial context:SBQueueContex];
// Register to the queue notifications
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
@@ -174,16 +171,6 @@ static void *SBQueueContex = &SBQueueContex;
return YES;
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (context == SBQueueContex) {
if ([keyPath isEqualToString:@"options.SBQueueOptimize"]) {
self.queue.optimize = [(self.options)[SBQueueOptimize] boolValue];
}
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
#pragma mark - Queue methods
/**
@@ -294,6 +281,10 @@ static void *SBQueueContex = &SBQueueContex;
[item addAction:[[SBQueueSetAction alloc] initWithPreset:self.options[SBQueueSet]]];
}
if ([self.options[SBQueueOptimize] boolValue]) {
[item addAction:[[SBQueueOptimizeAction alloc] init]];
}
id type;
[url getResourceValue:&type forKey:NSURLTypeIdentifierKey error:NULL];