diff options
author | ritsuka <[email protected]> | 2015-01-09 07:40:00 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-01-09 07:40:00 +0000 |
commit | 49652651aacc104f48775780532df9ac332dccee (patch) | |
tree | cda754fb5c48e9e1fd1fbf0564f2162a92a03d07 /macosx | |
parent | 8ceebaf185315102a412b0e645200df2992a8185 (diff) |
MacGui: remove some NSString -> NSURL conversions. Added a default size value and folder expanded value for the presets drawer.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6698 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.m | 58 | ||||
-rw-r--r-- | macosx/HBChapterTitlesController.m | 8 | ||||
-rw-r--r-- | macosx/HBPreferencesController.m | 16 |
3 files changed, 39 insertions, 43 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 5676089c9..8306c2eda 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -151,6 +151,13 @@ // Checks for presets updates [self checkBuiltInsForUpdates]; + // Show/Hide the Presets drawer upon launch based + // on user preference DefaultPresetsDrawerShow + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBDefaultPresetsDrawerShow"]) + { + [fPresetDrawer open:self]; + } + /* Init QueueFile .plist */ [self loadQueueFile]; [self initQueueFSEvent]; @@ -550,13 +557,6 @@ [fPresetDrawer setContentSize: drawerSize]; } - /* Show/Dont Show Presets drawer upon launch based - on user preference DefaultPresetsDrawerShow */ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBDefaultPresetsDrawerShow"]) - { - [fPresetDrawer open:self]; - } - // Align the start / stop widgets with the chapter popups NSPoint startPoint = [fSrcChapterStartPopUp frame].origin; startPoint.y += 2; @@ -1263,9 +1263,9 @@ [panel setCanChooseDirectories:YES]; NSURL *sourceDirectory; - if ([[NSUserDefaults standardUserDefaults] URLForKey:@"LastSourceDirectoryURL"]) + if ([[NSUserDefaults standardUserDefaults] URLForKey:@"HBLastSourceDirectoryURL"]) { - sourceDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"LastSourceDirectoryURL"]; + sourceDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"HBLastSourceDirectoryURL"]; } else { @@ -1280,7 +1280,7 @@ { NSURL *scanURL = panel.URL; // we set the last searched source directory in the prefs here - [[NSUserDefaults standardUserDefaults] setURL:scanURL.URLByDeletingLastPathComponent forKey:@"LastSourceDirectoryURL"]; + [[NSUserDefaults standardUserDefaults] setURL:scanURL.URLByDeletingLastPathComponent forKey:@"HBLastSourceDirectoryURL"]; // we order out sheet, which is the browse window as we need to open // the title selection sheet right away @@ -1568,8 +1568,8 @@ self.job.destURL = panel.URL; // Save this path to the prefs so that on next browse destination window it opens there - NSString *destinationDirectory = [panel.URL.path stringByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"]; + [[NSUserDefaults standardUserDefaults] setURL:panel.URL.URLByDeletingLastPathComponent + forKey:@"HBLastDestinationDirectory"]; } }]; } @@ -2191,8 +2191,8 @@ static void queueFSEventStreamCallback( [self doAddToQueue]; } - NSString *destinationDirectory = [self.job.destURL.path stringByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"]; + [[NSUserDefaults standardUserDefaults] setURL:self.job.destURL.URLByDeletingLastPathComponent + forKey:@"HBLastDestinationDirectory"]; currentQueueEncodeIndex = [self getNextPendingQueueIndex]; HBJob *queueJob = QueueFileArray[currentQueueEncodeIndex]; [self performNewQueueScan:queueJob.fileURL.path scanTitleNum:queueJob.titleIdx]; @@ -2446,25 +2446,21 @@ static void queueFSEventStreamCallback( { self.job = [[[HBJob alloc] initWithTitle:title andPreset:self.selectedPreset] autorelease]; - // use the correct extension based on the container - const char *ext = hb_container_get_default_extension(self.job.container); - // Check to see if the last destination has been set,use if so, if not, use Desktop - if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]) + NSURL *destURL = [[NSUserDefaults standardUserDefaults] URLForKey:@"HBLastDestinationDirectory"]; + if (!destURL || ![[NSFileManager defaultManager] fileExistsAtPath:destURL.path]) { - NSURL *fileURL = [NSURL fileURLWithPath:[[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]]; - fileURL = [fileURL URLByAppendingPathComponent:self.browsedSourceDisplayName.stringByDeletingPathExtension]; - fileURL = [fileURL URLByAppendingPathExtension:@(ext)]; - self.job.destURL = fileURL; - } - else - { - self.job.destURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Desktop/%@.%s", - NSHomeDirectory(), - self.browsedSourceDisplayName.stringByDeletingPathExtension, - ext]]; + destURL = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES) firstObject] + isDirectory:YES]; } + destURL = [destURL URLByAppendingPathComponent:title.name]; + // use the correct extension based on the container + const char *ext = hb_container_get_default_extension(self.job.container); + destURL = [destURL URLByAppendingPathExtension:@(ext)]; + + self.job.destURL = destURL; + // set m4v extension if necessary - do not override user-specified .mp4 extension if (self.job.container & HB_MUX_MASK_MP4) { @@ -2475,10 +2471,6 @@ static void queueFSEventStreamCallback( // If we are a stream type and a batch scan, grok the output file name from title->name upon title change if ((title.hb_title->type == HB_STREAM_TYPE || title.hb_title->type == HB_FF_STREAM_TYPE) && self.core.titles.count > 1) { - // we set the default name according to the new title->name - self.job.destURL = [[self.job.destURL URLByDeletingLastPathComponent] URLByAppendingPathComponent: - [NSString stringWithFormat:@"%@.%@", title.name, self.job.destURL.pathExtension]]; - // Change the source to read out the parent folder also fSrcDVD2Field.stringValue = [NSString stringWithFormat:@"%@/%@", self.browsedSourceDisplayName, title.name]; } diff --git a/macosx/HBChapterTitlesController.m b/macosx/HBChapterTitlesController.m index 0ad874a08..ad50d3b86 100644 --- a/macosx/HBChapterTitlesController.m +++ b/macosx/HBChapterTitlesController.m @@ -122,11 +122,11 @@ a timer to avoid interfering with the chain of events that handles the edit. */ - (IBAction) browseForChapterFile: (id) sender { /* We get the current file name and path from the destination field here */ - NSString *sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]; + NSURL *sourceDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"HBLastDestinationDirectory"]; /* Open a panel to let the user choose the file */ NSOpenPanel *panel = [NSOpenPanel openPanel]; - [panel setDirectoryURL:[NSURL fileURLWithPath:sourceDirectory]]; + [panel setDirectoryURL:sourceDirectory]; [panel setAllowedFileTypes:@[@"csv"]]; [panel beginSheetModalForWindow:[[self view] window] completionHandler:^(NSInteger result) { @@ -198,12 +198,12 @@ a timer to avoid interfering with the chain of events that handles the edit. */ - (IBAction) browseForChapterFileSave: (id) sender { - NSString *destinationDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]; + NSURL *destinationDirectory = [[NSUserDefaults standardUserDefaults] URLForKey:@"HBLastDestinationDirectory"]; /* Open a panel to let the user save to a file */ NSSavePanel *panel = [NSSavePanel savePanel]; [panel setAllowedFileTypes:@[@"csv"]]; - [panel setDirectoryURL:[NSURL fileURLWithPath:destinationDirectory]]; + [panel setDirectoryURL:destinationDirectory]; [panel setNameFieldStringValue:self.job.destURL.lastPathComponent.stringByDeletingPathExtension]; [panel beginSheetModalForWindow:[[self view] window] completionHandler:^(NSInteger result) { diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 3e9666e6c..2325eb2c4 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -54,7 +54,8 @@ */ + (void)registerUserDefaults { - NSString *desktopDirectory = [@"~/Desktop" stringByExpandingTildeInPath]; + NSString *desktopDirectory = [NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES) firstObject]; + NSURL *desktopURL = [NSURL fileURLWithPath:desktopDirectory isDirectory:YES]; [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"LaunchSourceBehavior": @"Open Source", @@ -62,8 +63,9 @@ @"DefaultMpegExtension": @"Auto", @"UseDvdNav": @"YES", @"HBDefaultPresetsDrawerShow": @YES, - @"LastDestinationDirectory": desktopDirectory, - @"LastSourceDirectory": desktopDirectory, + // Archive the URL because they aren't supported in plist. + @"HBLastDestinationDirectory": [NSKeyedArchiver archivedDataWithRootObject:desktopURL], + @"HBLastSourceDirectory": [NSKeyedArchiver archivedDataWithRootObject:desktopURL], @"DefaultAutoNaming": @NO, @"AlertWhenDone": @"Alert Window", @"AlertWhenDoneSound": @"YES", @@ -71,12 +73,14 @@ @"EncodeLogLocation": @"NO", @"MinTitleScanSeconds": @"10", @"PreviewsNumber": @"10", - @"Drawer Size": @"", - @"x264CqSliderFractional": @"0.25", + @"x264CqSliderFractional": @"0.50", @"AlertBuiltInPresetUpdate": @"YES", @"SendCompletedEncodeToApp": @"MetaX", @"HBShowAdvancedTab": @NO, - @"HBAutoNamingFormat": @[@"{Source}", @" ", @"{Title}"] + @"HBAutoNamingFormat": @[@"{Source}", @" ", @"{Title}"], + // Hash of the default folders, until there is a better way. + @"HBPreviewViewExpandedStatus": @[@(4097268371718322522), @(3576901712372066251)], + @"HBDrawerSize": NSStringFromSize(NSMakeSize(184, 591)) }]; } |