summaryrefslogtreecommitdiffstats
path: root/macosx/HBPresetsViewController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-08-09 17:10:45 +0000
committerritsuka <[email protected]>2014-08-09 17:10:45 +0000
commit666e210efe202dc13273dd32de1b1901e194e4ce (patch)
tree95e3c1886f10552e023a517aee569866df806219 /macosx/HBPresetsViewController.m
parentd4e3de96a998ba90f61d31045d5c725428cd030d (diff)
MacGui: added the list of the presets at the bottom of the preset menu and a “New Folder” menu item. Removed the “delete built-in presets” item because it takes just two clicks to remove them manually.
Refactored part of HBPreset to a separate HBTreeNode class. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6278 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPresetsViewController.m')
-rw-r--r--macosx/HBPresetsViewController.m30
1 files changed, 19 insertions, 11 deletions
diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m
index 768dd1aa7..e49586212 100644
--- a/macosx/HBPresetsViewController.m
+++ b/macosx/HBPresetsViewController.m
@@ -1,10 +1,8 @@
-//
-// HBPresetsViewController.m
-// PresetsView
-//
-// Created by Damiano Galassi on 14/07/14.
-// Copyright (c) 2014 Damiano Galassi. All rights reserved.
-//
+/* HBPresetsViewController.m $
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
#import "HBPresetsViewController.h"
#import "HBPresetsManager.h"
@@ -114,6 +112,8 @@
{
if ([self.treeController canRemove])
{
+ // Save the current selection path and apply it again after the deletion
+ NSIndexPath *currentSelection = [self.treeController selectionIndexPath];
/* Alert user before deleting preset */
NSAlert *alert = [NSAlert alertWithMessageText:@"Warning!"
defaultButton:@"OK"
@@ -128,6 +128,7 @@
{
[self.presets deletePresetAtIndexPath:[self.treeController selectionIndexPath]];
}
+ [self.treeController setSelectionIndexPath:currentSelection];
}
}
@@ -136,7 +137,7 @@
NSIndexPath *selectionIndexPath = [self.treeController selectionIndexPath];
if (!selectionIndexPath)
{
- selectionIndexPath = [NSIndexPath indexPathWithIndex:self.presets.contents.count];
+ selectionIndexPath = [NSIndexPath indexPathWithIndex:self.presets.root.children.count];
}
HBPreset *selectedNode = [[self.treeController selectedObjects] firstObject];
@@ -162,9 +163,9 @@
[self.treeController setSelectionIndexPath:nil];
}
-- (void)selectDefaultPreset
+- (void)selectPreset:(HBPreset *)preset
{
- NSIndexPath *idx = [self.presets indexPathOfPreset:self.presets.defaultPreset];
+ NSIndexPath *idx = [self.presets indexPathOfPreset:preset];
if (idx)
{
@@ -338,6 +339,13 @@
for (idx = ([newNodes count] - 1); idx >= 0; idx--)
{
[self.treeController moveNode:newNodes[idx] toIndexPath:indexPath];
+
+ // Call manually this because the NSTreeController doesn't call
+ // the KVC accessors method for the root node.
+ if (indexPath.length == 1)
+ {
+ [self.presets performSelector:@selector(nodeDidChange)];
+ }
}
// keep the moved nodes selected
@@ -375,7 +383,7 @@
{
// drop at the top root level
if (index == -1) // drop area might be ambibuous (not at a particular location)
- indexPath = [NSIndexPath indexPathWithIndex:self.presets.contents.count]; // drop at the end of the top level
+ indexPath = [NSIndexPath indexPathWithIndex:self.presets.root.children.count]; // drop at the end of the top level
else
indexPath = [NSIndexPath indexPathWithIndex:index]; // drop at a particular place at the top level
}