Improved the options popover.
This commit is contained in:
1 parent
4cacf3aedd
commit
7253a86c8d
7 files changed
+115
-119
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user