Small improvements in the Queue UI.
This commit is contained in:
1 parent
ac0344b1ea
commit
61fd097463
8 files changed
+85
-15
No files matched your search
@@ -10,6 +10,13 @@
|
||||
|
||||
@class SBQueueItem;
|
||||
|
||||
@protocol SBItemViewDelegate <NSObject>
|
||||
|
||||
- (void)setPopoverSize:(NSSize)size;
|
||||
- (void)editItem:(SBQueueItem *)item;
|
||||
|
||||
@end
|
||||
|
||||
@interface SBItemViewController : NSViewController {
|
||||
@private
|
||||
SBQueueItem *_item;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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)])
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
<outlet property="delegate" destination="-2" id="84"/>
|
||||
</connections>
|
||||
</menu>
|
||||
<window title="Queue Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="zHc-NF-Zeh" userLabel="Window - Detached Options" customClass="NSPanel">
|
||||
<window title="Queue Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="zHc-NF-Zeh" userLabel="Window - Detached Options" customClass="NSPanel">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" utility="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="283" y="305" width="321" height="163"/>
|
||||
|
||||
@@ -50,6 +50,13 @@
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="J6Q-ls-Vzn" name="hidden" keyPath="arrangedObjects.@count" id="lOk-Aa-fIT">
|
||||
<dictionary key="options">
|
||||
<string key="NSValueTransformerName">NSNegateBoolean</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" allowsExpansionToolTips="YES" id="eTa-uz-sjk">
|
||||
<rect key="frame" x="95" y="56" width="277" height="14"/>
|
||||
@@ -100,14 +107,14 @@
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
</progressIndicator>
|
||||
<scrollView borderType="none" autohidesScrollers="YES" horizontalLineScroll="14" horizontalPageScroll="10" verticalLineScroll="14" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="Skr-vw-eHq">
|
||||
<rect key="frame" x="97" y="34" width="273" height="14"/>
|
||||
<rect key="frame" x="97" y="29" width="273" height="19"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="hrx-7s-pPn">
|
||||
<rect key="frame" x="0.0" y="0.0" width="273" height="14"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="273" height="19"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" id="4Xn-YH-LzM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="273" height="14"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="273" height="19"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="0.0"/>
|
||||
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
|
||||
Reference in new issue
Block a user