diff options
author | ritsuka <[email protected]> | 2015-05-16 07:08:39 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-05-16 07:08:39 +0000 |
commit | 5359f757b672db040780a76eeeea04ed2d3ef89c (patch) | |
tree | fa801e5ba2ede89176826b455a0b055ace4f1635 /macosx/HBController.m | |
parent | 857e9d35752fc2ff1397d7a677a12b9aca82ec7f (diff) |
MacGui: allow exporting a preset folder. Add import/export menu item to the presets drawer too.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7192 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r-- | macosx/HBController.m | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m index c169e0fdc..f15314f4f 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -406,6 +406,10 @@ } return (self.job != nil); } + if (action == @selector(exportPreset:)) + { + return [fPresetsView validateUserInterfaceItem:menuItem]; + } return YES; } @@ -1340,57 +1344,14 @@ #pragma mark - #pragma mark Import Export Preset(s) -- (IBAction)browseExportPresetFile:(id)sender +- (IBAction)exportPreset:(id)sender { - // Open a panel to let the user choose where and how to save the export file - NSSavePanel *panel = [NSSavePanel savePanel]; - // We get the current file name and path from the destination field here - NSURL *defaultExportDirectory = [[NSURL fileURLWithPath:NSHomeDirectory()] URLByAppendingPathComponent:@"Desktop"]; - panel.directoryURL = defaultExportDirectory; - panel.nameFieldStringValue = [NSString stringWithFormat:@"%@.json", fPresetsView.selectedPreset.name]; - - [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) - { - if (result == NSOKButton) - { - NSURL *presetExportDirectory = [panel.URL URLByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setURL:presetExportDirectory forKey:@"LastPresetExportDirectoryURL"]; - - [fPresetsView.selectedPreset writeToURL:panel.URL atomically:YES format:HBPresetFormatJson removeRoot:NO]; - } - }]; + [fPresetsView exportPreset:sender]; } -- (IBAction)browseImportPresetFile:(id)sender +- (IBAction)importPreset:(id)sender { - NSOpenPanel *panel = [NSOpenPanel openPanel]; - panel.allowsMultipleSelection = YES; - panel.canChooseFiles = YES; - panel.canChooseDirectories = NO; - panel.allowedFileTypes = @[@"plist", @"xml", @"json"]; - - if ([[NSUserDefaults standardUserDefaults] URLForKey:@"LastPresetImportDirectoryURL"]) - { - panel.directoryURL = [[NSUserDefaults standardUserDefaults] URLForKey:@"LastPresetImportDirectoryURL"]; - } - else - { - panel.directoryURL = [[NSURL fileURLWithPath:NSHomeDirectory()] URLByAppendingPathComponent:@"Desktop"]; - } - - [panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) - { - [[NSUserDefaults standardUserDefaults] setURL:panel.directoryURL forKey:@"LastPresetImportDirectoryURL"]; - - for (NSURL *url in panel.URLs) - { - HBPreset *import = [[HBPreset alloc] initWithContentsOfURL:url]; - if (import) - { - [presetManager addPreset:import]; - } - } - }]; + [fPresetsView importPreset:sender]; } #pragma mark - |