Small improvements in the Queue UI.

This commit is contained in:
Damiano Galassi committed 2014-03-23 16:58:56 +01:00
1 parent ac0344b1ea
commit 61fd097463
8 files changed
+85 -15

No files matched your search

+7
View File
@@ -10,6 +10,13 @@
@class SBQueueItem;
@protocol SBItemViewDelegate <NSObject>
- (void)setPopoverSize:(NSSize)size;
- (void)editItem:(SBQueueItem *)item;
@end
@interface SBItemViewController : NSViewController {
@private
SBQueueItem *_item;
+13 -5
View File
@@ -9,7 +9,6 @@
#import "SBItemViewController.h"
#import "SBQueueItem.h"
#import "SBQueueController.h"
static void *SBItemViewContex = &SBItemViewContex;
@@ -49,10 +48,16 @@ static void *SBItemViewContex = &SBItemViewContex;
[super loadView];
// Observe the item status
[self addObserver:self forKeyPath:@"item.status" options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew context:SBItemViewContex];
[self addObserver:self
forKeyPath:@"item.status"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:SBItemViewContex];
// Observe the item actions
[self addObserver:self forKeyPath:@"item.actions" options:NSKeyValueObservingOptionInitial context:SBItemViewContex];
[self addObserver:self
forKeyPath:@"item.actions"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
context:SBItemViewContex];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
@@ -67,9 +72,12 @@ static void *SBItemViewContex = &SBItemViewContex;
[self.editButton setEnabled:YES];
}
} else if ([keyPath isEqualToString:@"item.actions"]) {
NSInteger count = [[change objectForKey:NSKeyValueChangeNewKey] count] - [[change objectForKey:NSKeyValueChangeOldKey] count];
NSSize frameSize = self.view.frame.size;
frameSize.height += [self.item.actions count] ? TABLE_ROW_HEIGHT * ([self.item.actions count] - 1) : 0;
[self.view setFrameSize:frameSize];
frameSize.height += TABLE_ROW_HEIGHT * (count >= 0 ? count - 1 : count);
if ([self.delegate respondsToSelector:@selector(setPopoverSize:)]) {
[self.delegate setPopoverSize:frameSize];
}
}
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+3
View File
@@ -11,6 +11,8 @@
#import "SBQueue.h"
@class SBQueueItem;
@class SBOptionsViewController;
@class SBTableView;
@class MP42File;
@@ -26,6 +28,7 @@
NSPopover *_popover;
NSPopover *_itemPopover;
SBOptionsViewController *_windowController;
NSMutableDictionary *_options;
NSImage *_docImg;
+14 -1
View File
@@ -29,6 +29,7 @@ static void *SBQueueContex = &SBQueueContex;
@property (nonatomic, readonly) SBQueue *queue;
@property (nonatomic, retain) NSPopover *popover;
@property (nonatomic, retain) NSPopover *itemPopover;
@property (nonatomic, retain) SBOptionsViewController *windowController;
@property NSMutableDictionary *options;
@@ -62,6 +63,7 @@ static void *SBQueueContex = &SBQueueContex;
@synthesize queue = _queue;
@synthesize popover = _popover;
@synthesize itemPopover = _itemPopover;
@synthesize windowController = _windowController;
@synthesize options = _options;
+ (SBQueueController *)sharedManager {
@@ -393,15 +395,26 @@ static void *SBQueueContex = &SBQueueContex;
}
- (void)setPopoverSize:(NSSize)size {
self.itemPopover.contentSize = size;
}
- (NSWindow *)detachableWindowForPopover:(NSPopover *)popover {
if (popover == self.popover) {
_detachedWindow.contentView = [[SBOptionsViewController alloc] initWithOptions:self.options].view;
if (!self.windowController) {
self.windowController = [[[SBOptionsViewController alloc] initWithOptions:self.options] autorelease];
}
_detachedWindow.contentView = _windowController.view;
_detachedWindow.delegate = self;
return _detachedWindow;
}
return nil;
}
- (void)windowWillClose:(NSNotification *)notification {
self.windowController = nil;
}
- (void)popoverDidClose:(NSNotification *)notification {
NSPopover *closedPopover = [notification object];
if (self.popover == closedPopover) {
+2 -1
View File
@@ -43,7 +43,7 @@ typedef enum SBQueueItemStatus : NSInteger {
@property (nonatomic, readonly) NSURL *URL;
@property (nonatomic, copy) NSURL *destURL;
@property (nonatomic, readonly) NSMutableArray *actions;
@property (nonatomic, readonly) NSArray *actions;
@property (nonatomic, readonly) NSDictionary *attributes;
@property (nonatomic, assign) id delegate;
@@ -54,6 +54,7 @@ typedef enum SBQueueItemStatus : NSInteger {
+ (instancetype)itemWithMP4:(MP42File *)MP4 url:(NSURL *)URL attributes:(NSDictionary *)dict;
- (void)addAction:(id<SBQueueActionProtocol>)action;
- (void)removeAction:(id<SBQueueActionProtocol>)action;
- (BOOL)prepareItem:(NSError **)outError;
- (BOOL)processItem:(BOOL)optimize error:(NSError **)outError;
+35 -4
View File
@@ -18,7 +18,7 @@
@interface SBQueueItem () <MP42FileDelegate>
@property (nonatomic, readwrite, retain) MP42File *mp4File;
@property (nonatomic, readwrite) NSMutableArray *actions;
@property (nonatomic, readwrite) NSMutableArray *actionsInternal;
@property (atomic) BOOL cancelled;
@end
@@ -28,7 +28,7 @@
@synthesize status = _status;
@synthesize attributes = _attributes;
@synthesize actions = _actions;
@synthesize actionsInternal = _actions;
@synthesize cancelled = _cancelled;
@synthesize URL = _fileURL;
@@ -111,6 +111,16 @@
return [[[SBQueueItem alloc] initWithMP4:MP4 url:URL attributes:dict] autorelease];
}
+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)theKey {
BOOL automatic = NO;
if ([theKey isEqualToString:@"actions"]) {
automatic = NO;
} else {
automatic = [super automaticallyNotifiesObserversForKey:theKey];
}
return automatic;
}
#pragma mark Public methods
- (void)setStatus:(SBQueueItemStatus)itemStatus {
@@ -121,7 +131,25 @@
}
- (void)addAction:(id<SBQueueActionProtocol>)action {
[self.actions addObject:action];
if (self.status != SBQueueItemStatusWorking) {
[self willChangeValueForKey:@"actions"];
[self.actionsInternal addObject:action];
[self didChangeValueForKey:@"actions"];
}
}
- (void)removeAction:(id<SBQueueActionProtocol>)action {
if (self.status != SBQueueItemStatusWorking) {
[self willChangeValueForKey:@"actions"];
if ([self.actionsInternal containsObject:action]) {
[self.actionsInternal removeObject:action];
}
[self didChangeValueForKey:@"actions"];
}
}
- (NSArray *)actions {
return [[self.actionsInternal copy] autorelease];
}
#pragma mark Item processing
@@ -233,7 +261,10 @@
bail:
self.mp4File = nil;
[self.actions removeAllObjects];
[self willChangeValueForKey:@"actions"];
[self.actionsInternal removeAllObjects];
[self didChangeValueForKey:@"actions"];
#ifdef SB_SANDBOX
if ([destination respondsToSelector:@selector(stopAccessingSecurityScopedResource)])