Fixed the optimize checkbox, the tableview not updating and the skeleton for a new action.

This commit is contained in:
Damiano Galassi committed 2014-03-18 20:45:01 +01:00
1 parent 7253a86c8d
commit 60490b4039
8 files changed
+56 -22

No files matched your search

+5 -4
View File
@@ -236,7 +236,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
self.currentIndex = [self.items indexOfObject:self.currentItem];
self.currentItem.status = SBQueueItemStatusWorking;
[self handleSBStatusWorking:self.currentIndex];
[self handleSBStatusWorking:0 index:self.currentIndex];
noErr = [self processItem:self.currentItem optimize:self.optimize error:&outError];
// Check results
@@ -338,17 +338,18 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
}
- (void)progressStatus:(CGFloat)progress {
[self handleSBStatusWorking:progress];
[self handleSBStatusWorking:progress index:-1];
}
/**
* Processes SBQueueStatusWorking state information. Current implementation just
* sends SBQueueWorkingNotification.
*/
- (void)handleSBStatusWorking:(CGFloat)progress {
- (void)handleSBStatusWorking:(CGFloat)progress index:(NSInteger)index {
NSString *info = [NSString stringWithFormat:@"Processing file %ld of %lu.",(long)self.currentIndex + 1, (unsigned long)[self.items count]];
[[NSNotificationCenter defaultCenter] postNotificationName:SBQueueWorkingNotification object:self userInfo:@{@"ProgressString": info,
@"Progress": @(progress)}];
@"Progress": @(progress),
@"ItemIndex": @(index)}];
}
/**
+3
View File
@@ -20,5 +20,8 @@
@interface SBQueueSubtitlesAction : NSObject <SBQueueActionProtocol>
@end
@interface SBQueueSetAction : NSObject <SBQueueActionProtocol>
@end
@interface SBQueueOrganizeGroupsAction : NSObject <SBQueueActionProtocol>
@end
+8 -1
View File
@@ -125,7 +125,7 @@
if (artwork)
[metadata.artworks addObject:artwork];
}
return metadata;
}
@@ -146,6 +146,13 @@
@end
@implementation SBQueueSetAction
- (void)runAction:(SBQueueItem *)item {
}
@end
@implementation SBQueueOrganizeGroupsAction
- (void)runAction:(SBQueueItem *)item {
+27 -5
View File
@@ -86,6 +86,10 @@ static NSString *fileType = @"mp4";
[_countLabel setStringValue:[info valueForKey:@"ProgressString"]];
[_progressIndicator setIndeterminate:NO];
[_progressIndicator setDoubleValue:[[info valueForKey:@"Progress"] doubleValue]];
if ([[info valueForKey:@"ItemIndex"] integerValue] != -1) {
[self updateUI];
}
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SBQueueCompletedNotification object:self.queue queue:mainQueue usingBlock:^(NSNotification *note) {
@@ -110,6 +114,10 @@ static NSString *fileType = @"mp4";
- (void)initOptions {
_options = [[NSMutableDictionary alloc] init];
// Observe the changes to SBQueueOptimize
[self addObserver:self forKeyPath:@"options.SBQueueOptimize" options:0 context:NULL];
[_options setObject:@YES forKey:@"SBQueueOrganize"];
[_options setObject:@YES forKey:@"SBQueueMetadata"];
[_options setObject:@NO forKey:@"SBQueueAutoStart"];
@@ -136,6 +144,14 @@ static NSString *fileType = @"mp4";
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"options.SBQueueOptimize"]) {
self.queue.optimize = [[self.options objectForKey:@"SBQueueOptimize"] boolValue];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
- (SBQueueStatus)status {
return self.queue.status;
}
@@ -154,7 +170,6 @@ static NSString *fileType = @"mp4";
// the popover retains us and we retain the popover,
// we drop the popover whenever it is closed to avoid a cycle
self.popover.contentViewController = [[[SBOptionsViewController alloc] initWithOptions:self.options] autorelease];
self.popover.appearance = NSPopoverAppearanceMinimal;
self.popover.animates = YES;
@@ -179,7 +194,6 @@ static NSString *fileType = @"mp4";
#pragma mark - UI methods
- (void)updateDockTile {
NSUInteger count = [self.queue readyCount];
@@ -383,9 +397,17 @@ static NSString *fileType = @"mp4";
- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem {
SEL action = [anItem action];
if (action == @selector(removeSelectedItems:))
if ([_tableView selectedRow] != -1 || [_tableView clickedRow] != -1)
return YES;
if (action == @selector(removeSelectedItems:)) {
if ([_tableView selectedRow] != -1) {
SBQueueItem *item = [self.queue itemAtIndex:[_tableView selectedRow]];
if ([item status] != SBQueueItemStatusWorking)
return YES;
} else if ([_tableView clickedRow] != -1) {
SBQueueItem *item = [self.queue itemAtIndex:[_tableView clickedRow]];
if ([item status] != SBQueueItemStatusWorking)
return YES;
}
}
if (action == @selector(showInFinder:)) {
if ([_tableView clickedRow] != -1) {
+1 -1
View File
@@ -13,7 +13,7 @@
@class MP42File;
typedef enum SBQueueItemStatus : NSInteger {
SBQueueItemtatusUnknown = 0,
SBQueueItemStatusUnknown = 0,
SBQueueItemStatusReady,
SBQueueItemStatusEditing,
SBQueueItemStatusWorking,
+1
View File
@@ -37,6 +37,7 @@
self = [super init];
if (self) {
_actions = [[NSMutableArray alloc] init];
_status = SBQueueItemStatusReady;
}
return self;
}