Improved the options popover.

This commit is contained in:
Damiano Galassi committed 2014-03-18 19:05:53 +01:00
1 parent 4cacf3aedd
commit 7253a86c8d
7 files changed
+115 -119

No files matched your search

-5
View File
@@ -9,11 +9,6 @@
#import <Cocoa/Cocoa.h>
@interface SBOptionsViewController : NSViewController {
IBOutlet NSButton *_optimizeOption;
IBOutlet NSButton *_metadataOption;
IBOutlet NSButton *_organizeGroupsOption;
IBOutlet NSButton *_autoStartOption;
IBOutlet NSPopUpButton *_destButton;
NSMutableDictionary *_options;
+4 -43
View File
@@ -40,40 +40,15 @@
- (void)loadView {
[super loadView];
[self prepareDestPopup];
//[self prepareOptions];
}
- (void)prepareOptions {
if (self.options) {
[_optimizeOption setState:[[self.options objectForKey:@"Optimize"] boolValue]];
[_metadataOption setState:[[self.options objectForKey:@"Metadata"] boolValue]];
[_organizeGroupsOption setState:[[self.options objectForKey:@"Organize"] boolValue]];
[_autoStartOption setState:[[self.options objectForKey:@"AutoStart"] boolValue]];
}
}
- (void)prepareDestPopup {
NSMenuItem *folderItem = nil;
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]) {
_destination = [[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]] retain];
if ([self.options valueForKey:@"SBQueueDestination"]) {
_destination = [[self.options valueForKey:@"SBQueueDestination"] retain];
#ifdef SB_SANDBOX
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestinationBookmark"]) {
BOOL bookmarkDataIsStale;
NSError *error;
NSData *bookmarkData = [[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestinationBookmark"];
[destination release];
destination = [[NSURL
URLByResolvingBookmarkData:bookmarkData
options:NSURLBookmarkResolutionWithSecurityScope
relativeToURL:nil
bookmarkDataIsStale:&bookmarkDataIsStale
error:&error] retain];
}
#endif
if (![[NSFileManager defaultManager] fileExistsAtPath:[_destination path] isDirectory:nil])
if (![[NSFileManager defaultManager] fileExistsAtPath:[_destination path] isDirectory:nil])
_destination = nil;
}
@@ -128,21 +103,7 @@
[_destButton selectItem:folderItem];
_customDestination = YES;
#ifdef SB_SANDBOX
NSData *bookmark = nil;
NSError *error = nil;
bookmark = [[panel URL] bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
includingResourceValuesForKeys:nil
relativeToURL:nil // Make it app-scoped
error:&error];
if (error) {
NSLog(@"Error creating bookmark for URL (%@): %@", [panel URL], error);
[NSApp presentError:error];
}
[[NSUserDefaults standardUserDefaults] setValue:bookmark forKey:@"SBQueueDestinationBookmark"];
#endif
[[NSUserDefaults standardUserDefaults] setValue:[[panel URL] path] forKey:@"SBQueueDestination"];
[self.options setValue:[panel URL] forKey:@"SBQueueDestination"];
[[NSUserDefaults standardUserDefaults] setValue:@"YES" forKey:@"SBQueueDestinationSelected"];
}
else
+3 -3
View File
@@ -227,7 +227,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
[self saveQueueToDisk];
// Get the first item available in the queue
self.currentItem = [[self firstItemInQueue] retain];
self.currentItem = [self firstItemInQueue];
if (!self.currentItem) {
break;
@@ -242,7 +242,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
// Check results
if (self.cancelled) {
self.currentItem.status = SBQueueItemStatusCancelled;
[self.currentItem release];
self.currentItem = nil;
[self handleSBStatusCancelled];
break;
}
@@ -254,7 +254,7 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
[self handleSBStatusFailed:outError];
}
[self.currentItem release];
self.currentItem = nil;
}
if (self.status == SBQueueStatusCancelled) {
+2 -3
View File
@@ -7,7 +7,6 @@
//
#import <Cocoa/Cocoa.h>
#import <IOKit/pwr_mgt/IOPMLib.h>
#import "SBQueue.h"
@@ -25,11 +24,11 @@
IBOutlet NSScrollView *_tableScrollView;
IBOutlet SBTableView *_tableView;
NSMutableDictionary *_options;
IBOutlet NSWindow *_detachedWindow;
NSPopover *_popover;
NSMutableDictionary *_options;
NSImage *_docImg;
NSURL *_destination;
SBQueue *_queue;
}
+48 -36
View File
@@ -110,21 +110,50 @@ static NSString *fileType = @"mp4";
- (void)initOptions {
_options = [[NSMutableDictionary alloc] init];
[_options setObject:@YES forKey:@"Organize"];
[_options setObject:@YES forKey:@"Metadata"];
[_options setObject:@NO forKey:@"AutoStart"];
[_options setObject:@YES forKey:@"Optimize"];
[_options setObject:@YES forKey:@"SBQueueOrganize"];
[_options setObject:@YES forKey:@"SBQueueMetadata"];
[_options setObject:@NO forKey:@"SBQueueAutoStart"];
[_options setObject:@YES forKey:@"SBQueueOptimize"];
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]) {
[_options setObject:[NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]] forKey:@"SBQueueDestination"];
} else {
[_options setObject:nil forKey:@"SBQueueDestination"];
}
}
- (void)createPopover
{
- (NSURL *)queueURL {
NSURL *appSupportURL = nil;
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSUserDomainMask,
YES);
if ([allPaths count]) {
appSupportURL = [NSURL fileURLWithPath:[[[allPaths lastObject] stringByAppendingPathComponent:@"Subler"]
stringByAppendingPathComponent:@"queue.sbqueue"] isDirectory:YES];
return appSupportURL;
} else {
return nil;
}
}
- (SBQueueStatus)status {
return self.queue.status;
}
- (BOOL)saveQueueToDisk {
return [self.queue saveQueueToDisk];
}
#pragma mark - NSPopover delegate
- (void)createPopover {
if (self.popover == nil) {
// create and setup our popover
_popover = [[NSPopover alloc] init];
// 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];
self.popover.contentViewController = [[[SBOptionsViewController alloc] initWithOptions:self.options] autorelease];
self.popover.appearance = NSPopoverAppearanceMinimal;
self.popover.animates = YES;
@@ -139,32 +168,17 @@ static NSString *fileType = @"mp4";
}
- (NSWindow *)detachableWindowForPopover:(NSPopover *)popover {
NSWindow *window = [[NSWindow alloc] init];
window.contentView = popover.contentViewController.view;
_detachedWindow.contentView = [[SBOptionsViewController alloc] initWithOptions:self.options].view;
return window;
return _detachedWindow;
}
- (NSURL *)queueURL {
NSURL *appSupportURL = nil;
NSArray *allPaths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSUserDomainMask,
YES);
if ([allPaths count]) {
appSupportURL = [NSURL fileURLWithPath:[[[allPaths lastObject] stringByAppendingPathComponent:@"Subler"] stringByAppendingPathComponent:@"queue.sbqueue"] isDirectory:YES];
return appSupportURL;
} else {
return nil;
}
- (void)popoverDidClose:(NSNotification *)notification {
self.popover = nil;
}
- (SBQueueStatus)status {
return self.queue.status;
}
#pragma mark - UI methods
- (BOOL)saveQueueToDisk {
return [self.queue saveQueueToDisk];
}
- (void)updateDockTile {
NSUInteger count = [self.queue readyCount];
@@ -247,9 +261,6 @@ static NSString *fileType = @"mp4";
[items release];
[self updateUI];
//if ([_autoStartOption state])
// [self start:self];
}
}];
}
@@ -476,19 +487,20 @@ static NSString *fileType = @"mp4";
- (SBQueueItem *)createItemWithURL:(NSURL *)url {
SBQueueItem *item = [SBQueueItem itemWithURL:url];
if ([[self.options objectForKey:@"Metadata"] boolValue]) {
if ([[self.options objectForKey:@"SBQueueMetadata"] boolValue]) {
[item addAction:[[[SBQueueMetadataAction alloc] init] autorelease]];
[item addAction:[[[SBQueueSubtitlesAction alloc] init] autorelease]];
}
if ([[self.options objectForKey:@"Organize"] boolValue]) {
if ([[self.options objectForKey:@"SBQueueOrganize"] boolValue]) {
[item addAction:[[[SBQueueOrganizeGroupsAction alloc] init] autorelease]];
}
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]) {
_destination = [NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] valueForKey:@"SBQueueDestination"]];
NSURL *destination = [self.options objectForKey:@"SBQueueDestination"];
if (destination) {
destination = [[[destination URLByAppendingPathComponent:[url lastPathComponent]] URLByDeletingPathExtension] URLByAppendingPathExtension:fileType];
}
item.destURL = [[[_destination URLByAppendingPathComponent:[url lastPathComponent]] URLByDeletingPathExtension] URLByAppendingPathExtension:fileType];
item.destURL = destination;
return item;
}
@@ -524,7 +536,7 @@ static NSString *fileType = @"mp4";
if ([undo isUndoing] || [undo isRedoing])
[self updateUI];
if ([[self.options objectForKey:@"Autostart"] boolValue])
if ([[self.options objectForKey:@"SBQueueAutoStart"] boolValue])
[self start:self];
[mutableIndexes release];
+11
View File
@@ -8,6 +8,7 @@
<customObject id="-2" userLabel="File's Owner" customClass="SBQueueController">
<connections>
<outlet property="_countLabel" destination="12" id="BMB-K6-Foo"/>
<outlet property="_detachedWindow" destination="zHc-NF-Zeh" id="Cr1-ha-Wmx"/>
<outlet property="_open" destination="16" id="r2p-1j-93j"/>
<outlet property="_optionsBox" destination="57" id="M8z-YA-4ex"/>
<outlet property="_progressIndicator" destination="91" id="Kds-4b-YzV"/>
@@ -181,6 +182,16 @@
</connections>
</menu>
<userDefaultsController representsSharedInstance="YES" id="46"/>
<window title="Queue Options" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="zHc-NF-Zeh" userLabel="Window - Detached Options">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="283" y="305" width="316" height="133"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<view key="contentView" id="hhb-jZ-DWa">
<rect key="frame" x="0.0" y="0.0" width="316" height="133"/>
<autoresizingMask key="autoresizingMask"/>
</view>
</window>
</objects>
<resources>
<image name="NSActionTemplate" width="14" height="14"/>
+47 -29
View File
@@ -5,31 +5,27 @@
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SBQueueOptViewController">
<customObject id="-2" userLabel="File's Owner" customClass="SBOptionsViewController">
<connections>
<outlet property="_autoStartOption" destination="MGZ-hB-jhx" id="DRb-jB-pzy"/>
<outlet property="_destButton" destination="86l-GG-SpO" id="bE1-31-17X"/>
<outlet property="_metadataOption" destination="9GN-f6-r2j" id="L4N-QR-whD"/>
<outlet property="_optimizeOption" destination="zEH-aV-Tl7" id="Pdd-Ip-hHx"/>
<outlet property="_organizeGroupsOption" destination="ccd-Xn-Dj3" id="NhJ-bJ-y3o"/>
<outlet property="view" destination="UlG-O3-eNc" id="hzl-ex-WZi"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customView id="UlG-O3-eNc" userLabel="OptionsView">
<rect key="frame" x="0.0" y="0.0" width="330" height="172"/>
<rect key="frame" x="0.0" y="0.0" width="316" height="133"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button id="zEH-aV-Tl7">
<rect key="frame" x="100" y="18" width="80" height="18"/>
<rect key="frame" x="119" y="17" width="71" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Optimize" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="nig-pN-efw">
<buttonCell key="cell" type="check" title="Optimize" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="nig-pN-efw">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.options.Optimize" id="8sB-yj-wgn">
<binding destination="-2" name="value" keyPath="self.options.SBQueueOptimize" id="Xni-Sv-Yx7">
<dictionary key="options">
<bool key="NSValidatesImmediately" value="YES"/>
</dictionary>
@@ -37,14 +33,14 @@
</connections>
</button>
<button id="9GN-f6-r2j">
<rect key="frame" x="100" y="95" width="118" height="18"/>
<rect key="frame" x="119" y="74" width="103" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Fetch Metadata" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="QNO-e1-WUJ">
<buttonCell key="cell" type="check" title="Fetch Metadata" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="QNO-e1-WUJ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.options.Metadata" id="QcD-oI-rV4">
<binding destination="-2" name="value" keyPath="self.options.SBQueueMetadata" id="Erf-Bt-RUk">
<dictionary key="options">
<bool key="NSValidatesImmediately" value="YES"/>
</dictionary>
@@ -52,14 +48,14 @@
</connections>
</button>
<button id="MGZ-hB-jhx">
<rect key="frame" x="100" y="38" width="89" height="18"/>
<rect key="frame" x="119" y="35" width="79" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Auto-Start" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="LYO-G0-9jA">
<buttonCell key="cell" type="check" title="Auto-Start" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="LYO-G0-9jA">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.options.Autostart" id="Pw0-L8-WEp">
<binding destination="-2" name="value" keyPath="self.options.SBQueueAutoStart" id="LeC-ZK-MOy">
<dictionary key="options">
<bool key="NSValidatesImmediately" value="YES"/>
</dictionary>
@@ -67,14 +63,14 @@
</connections>
</button>
<button id="ccd-Xn-Dj3">
<rect key="frame" x="100" y="75" width="129" height="18"/>
<rect key="frame" x="119" y="56" width="112" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Organize Groups" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="240-c7-2UW">
<buttonCell key="cell" type="check" title="Organize Groups" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="240-c7-2UW">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<binding destination="-2" name="value" keyPath="self.options.Organize" id="3lj-bb-181">
<binding destination="-2" name="value" keyPath="self.options.SBQueueOrganize" id="udT-og-GPU">
<dictionary key="options">
<bool key="NSValidatesImmediately" value="YES"/>
</dictionary>
@@ -82,14 +78,18 @@
</connections>
</button>
<popUpButton verticalHuggingPriority="750" id="86l-GG-SpO">
<rect key="frame" x="132" y="128" width="180" height="26"/>
<rect key="frame" x="119" y="95" width="180" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Same as file" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="WKY-e5-5Mn" id="8bb-Gy-KAS">
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="8bb-Gy-KAS">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<font key="font" metaFont="smallSystem"/>
<menu key="menu" title="OtherViews" id="BBw-yf-xUC">
<items>
<menuItem title="Same as file" state="on" id="WKY-e5-5Mn"/>
<menuItem title="Same as file" id="WKY-e5-5Mn">
<connections>
<action selector="destination:" target="-2" id="Iz9-zl-XXa"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="DPM-zs-KPu"/>
<menuItem title="Other…" id="veS-S3-uYt">
<connections>
@@ -101,10 +101,28 @@
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" id="vJ5-JB-k1m">
<rect key="frame" x="18" y="134" width="109" height="17"/>
<rect key="frame" x="18" y="100" width="98" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Default location:" id="17e-9u-rVn">
<font key="font" metaFont="system"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Default location:" id="17e-9u-rVn">
<font key="font" metaFont="smallSystemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="Uoo-hZ-D1f">
<rect key="frame" x="26" y="37" width="90" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Global options:" id="NBN-VA-pg2">
<font key="font" metaFont="smallSystemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" id="S7L-mA-j3Y">
<rect key="frame" x="57" y="76" width="59" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Add item:" id="9ls-xq-YGz">
<font key="font" metaFont="smallSystemBold"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>