summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/English.lproj/MainMenu.xib8
-rw-r--r--macosx/English.lproj/Presets.xib69
-rw-r--r--macosx/HBController.h5
-rw-r--r--macosx/HBController.m55
-rw-r--r--macosx/HBPresetsViewController.h5
-rw-r--r--macosx/HBPresetsViewController.m67
6 files changed, 123 insertions, 86 deletions
diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib
index 486f503f0..5b8d5fd83 100644
--- a/macosx/English.lproj/MainMenu.xib
+++ b/macosx/English.lproj/MainMenu.xib
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6724" systemVersion="14C106a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14E17e" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment version="1060" identifier="macosx"/>
<development version="5100" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6724"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@@ -272,13 +272,13 @@
<menuItem title="Import…" tag="-1" id="5192">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
- <action selector="browseImportPresetFile:" target="-1" id="keX-1B-XYZ"/>
+ <action selector="importPreset:" target="-1" id="zab-p5-wEn"/>
</connections>
</menuItem>
<menuItem title="Export…" tag="-1" id="5188">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
- <action selector="browseExportPresetFile:" target="-1" id="kJa-oi-hY2"/>
+ <action selector="exportPreset:" target="-1" id="koR-bb-R5s"/>
</connections>
</menuItem>
<menuItem title="Update Built-in Presets" tag="-1" id="1950">
diff --git a/macosx/English.lproj/Presets.xib b/macosx/English.lproj/Presets.xib
index 38c90619d..9d4573493 100644
--- a/macosx/English.lproj/Presets.xib
+++ b/macosx/English.lproj/Presets.xib
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7528.3" systemVersion="14D127a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7702" systemVersion="14E17e" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
- <deployment identifier="macosx"/>
<development version="5100" identifier="xcode"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7528.3"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7702"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="HBPresetsViewController">
@@ -82,6 +81,32 @@
</scroller>
<accessibility description="Presets"/>
</scrollView>
+ <button toolTip="Create a new preset based on the current settings." verticalHuggingPriority="750" id="kfi-wq-mgV">
+ <rect key="frame" x="3" y="3" width="24" height="23"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" inset="3" id="OJ3-1k-3DY">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="systemBold"/>
+ </buttonCell>
+ <accessibility description="New Preset"/>
+ <connections>
+ <action selector="addNewPreset:" target="-2" id="TYV-vH-8hk"/>
+ <binding destination="-2" name="enabled" keyPath="self.enabled" id="lmV-Y3-JoF"/>
+ </connections>
+ </button>
+ <button toolTip="Delete the current selection" verticalHuggingPriority="750" id="b3V-8w-euU">
+ <rect key="frame" x="26" y="3" width="24" height="23"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="only" alignment="left" borderStyle="border" inset="3" id="Kb1-6u-550">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="systemBold"/>
+ </buttonCell>
+ <accessibility description="Delete"/>
+ <connections>
+ <action selector="deletePreset:" target="-2" id="b6N-h7-25y"/>
+ <binding destination="ohT-Pp-wBT" name="enabled" keyPath="canRemove" id="WNd-yX-UEH"/>
+ </connections>
+ </button>
<popUpButton verticalHuggingPriority="750" id="Ybq-Zt-sta">
<rect key="frame" x="58" y="3" width="35" height="23"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -102,6 +127,17 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="QaO-y0-sMc"/>
+ <menuItem title="Import…" id="LUl-ag-Iu6">
+ <connections>
+ <action selector="importPreset:" target="-2" id="euB-YW-AdI"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Export…" id="xEQ-Un-J0n">
+ <connections>
+ <action selector="exportPreset:" target="-2" id="dDG-rM-14L"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="NEw-wC-h4v"/>
<menuItem title="Update Built-in Presets" id="cm5-Kl-dB3">
<connections>
<action selector="updateBuiltInPresets:" target="-2" id="rND-6g-LMP"/>
@@ -112,33 +148,8 @@
</popUpButtonCell>
<accessibility description="Additional Options"/>
</popUpButton>
- <button toolTip="Create a new preset based on the current settings." verticalHuggingPriority="750" id="kfi-wq-mgV">
- <rect key="frame" x="3" y="3" width="24" height="23"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSAddTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" inset="3" id="OJ3-1k-3DY">
- <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
- <font key="font" metaFont="systemBold"/>
- </buttonCell>
- <accessibility description="New Preset"/>
- <connections>
- <action selector="addNewPreset:" target="-2" id="TYV-vH-8hk"/>
- <binding destination="-2" name="enabled" keyPath="self.enabled" id="lmV-Y3-JoF"/>
- </connections>
- </button>
- <button toolTip="Delete the current selection" verticalHuggingPriority="750" id="b3V-8w-euU">
- <rect key="frame" x="26" y="3" width="24" height="23"/>
- <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
- <buttonCell key="cell" type="smallSquare" bezelStyle="smallSquare" image="NSRemoveTemplate" imagePosition="only" alignment="left" borderStyle="border" inset="3" id="Kb1-6u-550">
- <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
- <font key="font" metaFont="systemBold"/>
- </buttonCell>
- <accessibility description="Delete"/>
- <connections>
- <action selector="deletePreset:" target="-2" id="b6N-h7-25y"/>
- <binding destination="ohT-Pp-wBT" name="enabled" keyPath="canRemove" id="WNd-yX-UEH"/>
- </connections>
- </button>
</subviews>
+ <point key="canvasLocation" x="58" y="345.5"/>
</customView>
<treeController objectClassName="HBPreset" childrenKeyPath="children" leafKeyPath="isLeaf" id="ohT-Pp-wBT">
<declaredKeys>
diff --git a/macosx/HBController.h b/macosx/HBController.h
index 83a47e434..625beb492 100644
--- a/macosx/HBController.h
+++ b/macosx/HBController.h
@@ -107,11 +107,6 @@
- (IBAction)rip:(id)sender;
- (IBAction)pause:(id)sender;
-// Preset Methods
-// Export / Import Presets
-- (IBAction)browseExportPresetFile:(id)sender;
-- (IBAction)browseImportPresetFile:(id)sender;
-
- (IBAction)selectPresetFromMenu:(id)sender;
// Manage User presets
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 -
diff --git a/macosx/HBPresetsViewController.h b/macosx/HBPresetsViewController.h
index 7c7efa15c..7dffd5f73 100644
--- a/macosx/HBPresetsViewController.h
+++ b/macosx/HBPresetsViewController.h
@@ -16,12 +16,15 @@
@end
-@interface HBPresetsViewController : NSViewController
+@interface HBPresetsViewController : NSViewController <NSUserInterfaceValidations>
- (instancetype)initWithPresetManager:(HBPresetsManager *)presetManager;
@property (nonatomic, readwrite, unsafe_unretained) id<HBPresetsViewControllerDelegate> delegate;
+- (IBAction)exportPreset:(id)sender;
+- (IBAction)importPreset:(id)sender;
+
- (void)deselect;
- (void)setSelection:(HBPreset *)preset;
diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m
index 509ae9892..371b0d8d5 100644
--- a/macosx/HBPresetsViewController.m
+++ b/macosx/HBPresetsViewController.m
@@ -63,6 +63,13 @@
{
SEL action = anItem.action;
+ if (action == @selector(exportPreset:))
+ {
+ if (![[self.treeController selectedObjects] firstObject])
+ {
+ return NO;
+ }
+ }
if (action == @selector(setDefault:))
{
if (![[[self.treeController selectedObjects] firstObject] isLeaf])
@@ -71,9 +78,69 @@
}
}
+
return YES;
}
+#pragma mark -
+#pragma mark Import Export Preset(s)
+
+- (IBAction)exportPreset:(id)sender
+{
+ // Find the current selection, it can be a folder too.
+ HBPreset *selectedPreset = [[self.treeController selectedObjects] firstObject];
+
+ // 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", selectedPreset.name];
+
+ [panel beginWithCompletionHandler:^(NSInteger result)
+ {
+ if (result == NSOKButton)
+ {
+ NSURL *presetExportDirectory = [panel.URL URLByDeletingLastPathComponent];
+ [[NSUserDefaults standardUserDefaults] setURL:presetExportDirectory forKey:@"LastPresetExportDirectoryURL"];
+
+ [selectedPreset writeToURL:panel.URL atomically:YES format:HBPresetFormatJson removeRoot:NO];
+ }
+ }];
+}
+
+- (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 beginWithCompletionHandler:^(NSInteger result)
+ {
+ [[NSUserDefaults standardUserDefaults] setURL:panel.directoryURL forKey:@"LastPresetImportDirectoryURL"];
+
+ for (NSURL *url in panel.URLs)
+ {
+ HBPreset *import = [[HBPreset alloc] initWithContentsOfURL:url];
+ for (HBPreset *child in import.children)
+ {
+ [self.presets addPreset:child];
+ }
+ }
+ }];
+}
+
#pragma mark - UI Methods
- (IBAction)clicked:(id)sender