Implemented a way to update the queue UI with a description of the current action.

This commit is contained in:
Damiano Galassi committed 2014-12-12 13:38:27 +01:00
1 parent a218dc8aae
commit 5219a73a7a
6 files changed
+42 -11

No files matched your search

+6 -1
View File
@@ -249,7 +249,12 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
* sends SBQueueWorkingNotification. * sends SBQueueWorkingNotification.
*/ */
- (void)handleSBStatusWorking:(CGFloat)progress index:(NSInteger)index { - (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]]; NSString *description = self.currentItem.localizedWorkingDescription;
if (!description) {
description = NSLocalizedString(@"Working", @"");
}
NSString *info = [NSString stringWithFormat:@"%@, item %ld of %lu.", description, (long)self.currentIndex + 1, (unsigned long)self.items.count];
[[NSNotificationCenter defaultCenter] postNotificationName:SBQueueWorkingNotification object:self userInfo:@{@"ProgressString": info, [[NSNotificationCenter defaultCenter] postNotificationName:SBQueueWorkingNotification object:self userInfo:@{@"ProgressString": info,
@"Progress": @(progress), @"Progress": @(progress),
@"ItemIndex": @(index)}]; @"ItemIndex": @(index)}];
+1
View File
@@ -17,6 +17,7 @@
*/ */
@protocol SBQueueActionProtocol <NSObject, NSCoding> @protocol SBQueueActionProtocol <NSObject, NSCoding>
- (void)runAction:(SBQueueItem *)item; - (void)runAction:(SBQueueItem *)item;
@property (nonatomic, readonly) NSString *localizedDescription;
@end @end
/** /**
+20 -4
View File
@@ -62,7 +62,11 @@
} }
- (NSString *)description { - (NSString *)description {
return @"Load Subtitles"; return NSLocalizedString(@"Load Subtitles", @"");
}
- (NSString *)localizedDescription {
return NSLocalizedString(@"Loading subtitles", @"");
} }
- (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)initWithCoder:(NSCoder *)coder {
@@ -187,7 +191,11 @@
} }
- (NSString *)description { - (NSString *)description {
return @"Search Metadata"; return NSLocalizedString(@"Search Metadata", @"");
}
- (NSString *)localizedDescription {
return NSLocalizedString(@"Searching metadata", @"");
} }
- (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)initWithCoder:(NSCoder *)coder {
@@ -215,7 +223,11 @@
} }
- (NSString *)description { - (NSString *)description {
return [NSString stringWithFormat:@"Apply %@ Set", _set.presetName]; return [NSString stringWithFormat:NSLocalizedString(@"Apply %@ Set", @""), _set.presetName];
}
- (NSString *)localizedDescription {
return [NSString stringWithFormat:NSLocalizedString(@"Applying %@ set", @""), _set.presetName];
} }
- (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)initWithCoder:(NSCoder *)coder {
@@ -244,7 +256,11 @@
} }
- (NSString *)description { - (NSString *)description {
return @"Organize Groups"; return NSLocalizedString(@"Organize Groups", @"");
}
- (NSString *)localizedDescription {
return NSLocalizedString(@"Organizing groups", @"");
} }
- (instancetype)initWithCoder:(NSCoder *)coder { - (instancetype)initWithCoder:(NSCoder *)coder {
+2
View File
@@ -34,9 +34,11 @@ typedef enum SBQueueItemStatus : NSInteger {
id _delegate; id _delegate;
SBQueueItemStatus _status; SBQueueItemStatus _status;
NSString *_localizedWorkingDescription;
} }
@property (nonatomic, readwrite) SBQueueItemStatus status; @property (nonatomic, readwrite) SBQueueItemStatus status;
@property (nonatomic, readonly) NSString *localizedWorkingDescription;
@property (nonatomic, readonly) MP42File *mp4File; @property (nonatomic, readonly) MP42File *mp4File;
+7
View File
@@ -17,6 +17,8 @@
@interface SBQueueItem () <MP42FileDelegate> @interface SBQueueItem () <MP42FileDelegate>
@property (nonatomic, readwrite) NSString *localizedWorkingDescription;
@property (nonatomic, readwrite, retain) MP42File *mp4File; @property (nonatomic, readwrite, retain) MP42File *mp4File;
@property (nonatomic, readwrite) NSMutableArray *actionsInternal; @property (nonatomic, readwrite) NSMutableArray *actionsInternal;
@property (atomic) BOOL cancelled; @property (atomic) BOOL cancelled;
@@ -26,6 +28,7 @@
@implementation SBQueueItem @implementation SBQueueItem
@synthesize status = _status; @synthesize status = _status;
@synthesize localizedWorkingDescription = _localizedWorkingDescription;
@synthesize attributes = _attributes; @synthesize attributes = _attributes;
@synthesize actionsInternal = _actions; @synthesize actionsInternal = _actions;
@@ -241,9 +244,13 @@
} }
for (id<SBQueueActionProtocol> action in self.actions) { for (id<SBQueueActionProtocol> action in self.actions) {
self.localizedWorkingDescription = action.localizedDescription;
[self progressStatus:0];
[action runAction:self]; [action runAction:self];
} }
self.localizedWorkingDescription = nil;
return YES; return YES;
} }
+6 -6
View File
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C78c" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies> </dependencies>
<objects> <objects>
<customObject id="-2" userLabel="File's Owner" customClass="SBQueueController"> <customObject id="-2" userLabel="File's Owner" customClass="SBQueueController">
@@ -35,7 +35,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" autosaveColumns="NO" id="7" customClass="SBTableView"> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" alternatingRowBackgroundColors="YES" autosaveColumns="NO" id="7" customClass="SBTableView">
<rect key="frame" x="0.0" y="0.0" width="378" height="20"/> <rect key="frame" x="0.0" y="0.0" width="378" height="21"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="4"/> <size key="intercellSpacing" width="3" height="4"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
@@ -100,7 +100,7 @@
</scroller> </scroller>
</scrollView> </scrollView>
<textField verticalHuggingPriority="750" id="12"> <textField verticalHuggingPriority="750" id="12">
<rect key="frame" x="8" y="15" width="185" height="17"/> <rect key="frame" x="8" y="15" width="214" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Queue items" id="13"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Queue items" id="13">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
@@ -109,7 +109,7 @@
</textFieldCell> </textFieldCell>
</textField> </textField>
<progressIndicator maxValue="100" indeterminate="YES" style="bar" id="91"> <progressIndicator maxValue="100" indeterminate="YES" style="bar" id="91">
<rect key="frame" x="199" y="13" width="168.99999973655406" height="20"/> <rect key="frame" x="228" y="13" width="139.99999973655406" height="20"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</progressIndicator> </progressIndicator>
</subviews> </subviews>
@@ -171,7 +171,7 @@
<toolbarItem reference="xBN-FT-Sv0"/> <toolbarItem reference="xBN-FT-Sv0"/>
</defaultToolbarItems> </defaultToolbarItems>
</toolbar> </toolbar>
<point key="canvasLocation" x="171" y="177"/> <point key="canvasLocation" x="169" y="177"/>
</window> </window>
<menu id="78"> <menu id="78">
<items> <items>