summaryrefslogtreecommitdiffstats
path: root/macosx/HBController.m
diff options
context:
space:
mode:
authorRodeo314 <[email protected]>2018-02-02 04:57:52 -0500
committerBradley Sepos <[email protected]>2018-03-17 17:01:56 -0400
commitd1a3d95ee19797180a88e3013015c9f1696a6429 (patch)
tree4d53d2c8f03f448237f37f9f98cf0b6bd66dbc32 /macosx/HBController.m
parentafc34ed12e616dfc3f86f80c7e5e1ba03fb53e2a (diff)
MacGUI: Add Rename Preset dialog.
@BradleyS thanks @Rodeo314 for his help with this.
Diffstat (limited to 'macosx/HBController.m')
-rw-r--r--macosx/HBController.m41
1 files changed, 40 insertions, 1 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index b48115efa..70ec14bad 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -30,6 +30,7 @@
#import "HBPresetsViewController.h"
#import "HBAddPresetController.h"
+#import "HBRenamePresetController.h"
@import HandBrakeKit;
@@ -549,7 +550,18 @@
}
if (action == @selector(exportPreset:))
{
- return [fPresetsView validateUserInterfaceItem:menuItem];
+ return [fPresetsView validateUserInterfaceItem:menuItem] && self.job != nil;
+ }
+ if (action == @selector(selectDefaultPreset:) ||
+ action == @selector(insertCategory:))
+ {
+ return self.job != nil;
+ }
+ if (action == @selector(renamePreset:) ||
+ action == @selector(deletePreset:) ||
+ action == @selector(setDefaultPreset:))
+ {
+ return self.job != nil && self.edited == NO;//fixme
}
return YES;
@@ -1502,6 +1514,27 @@
return [preset copy];
}
+- (IBAction)showRenamePresetPanel:(id)sender
+{
+ [self.window HB_endEditing];
+
+ HBRenamePresetController *renamePresetController = [[HBRenamePresetController alloc] initWithPreset:self.currentPreset
+ presetManager:presetManager];
+
+ [NSApp beginSheet:renamePresetController.window modalForWindow:self.window modalDelegate:self didEndSelector:@selector(renamePresetSheetDidEnd:returnCode:contextInfo:) contextInfo:(void *)CFBridgingRetain(renamePresetController)];
+}
+
+- (void)renamePresetSheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
+{
+ __unused HBRenamePresetController *renamePresetController = (HBRenamePresetController *)CFBridgingRelease(contextInfo);
+
+ if (returnCode != NSModalResponseCancel)
+ {
+ [self applyPreset:fPresetsView.selectedPreset];
+ [[NSNotificationCenter defaultCenter] postNotificationName:HBPresetsChangedNotification object:nil];
+ }
+}
+
#pragma mark -
#pragma mark Import Export Preset(s)
@@ -1530,6 +1563,12 @@
[fPresetsView setDefault:sender];
}
+- (IBAction)renamePreset:(id)sender
+{
+ fPresetsView.selectedPreset = _currentPreset;
+ [self showRenamePresetPanel:sender];
+}
+
- (IBAction)deletePreset:(id)sender
{
HBPreset *preset = [sender representedObject];