summaryrefslogtreecommitdiffstats
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
parentafc34ed12e616dfc3f86f80c7e5e1ba03fb53e2a (diff)
MacGUI: Add Rename Preset dialog.
@BradleyS thanks @Rodeo314 for his help with this.
-rw-r--r--macosx/English.lproj/HBRenamePresetController.xib92
-rw-r--r--macosx/English.lproj/MainMenu.xib8
-rw-r--r--macosx/HBController.h2
-rw-r--r--macosx/HBController.m41
-rw-r--r--macosx/HBRenamePresetController.h22
-rw-r--r--macosx/HBRenamePresetController.m85
-rw-r--r--macosx/HandBrake.xcodeproj/project.pbxproj18
7 files changed, 267 insertions, 1 deletions
diff --git a/macosx/English.lproj/HBRenamePresetController.xib b/macosx/English.lproj/HBRenamePresetController.xib
new file mode 100644
index 000000000..fed39b46d
--- /dev/null
+++ b/macosx/English.lproj/HBRenamePresetController.xib
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+ <dependencies>
+ <deployment identifier="macosx"/>
+ <development version="8000" identifier="xcode"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <objects>
+ <customObject id="-2" userLabel="File's Owner" customClass="HBRenamePresetController">
+ <connections>
+ <outlet property="name" destination="UXm-yG-bgW" id="htS-T7-qP0"/>
+ <outlet property="renameButton" destination="WEv-SR-3sw" id="lRz-JT-RDG"/>
+ <outlet property="window" destination="C4G-OG-ksc" id="oNS-V8-CBz"/>
+ </connections>
+ </customObject>
+ <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+ <customObject id="-3" userLabel="Application" customClass="NSObject"/>
+ <window title="Rename Preset" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="C4G-OG-ksc">
+ <windowStyleMask key="styleMask" titled="YES"/>
+ <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+ <rect key="contentRect" x="283" y="305" width="290" height="132"/>
+ <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
+ <view key="contentView" id="3oN-GT-JmW">
+ <rect key="frame" x="0.0" y="0.0" width="290" height="132"/>
+ <autoresizingMask key="autoresizingMask"/>
+ <subviews>
+ <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="A8w-ij-o7q">
+ <rect key="frame" x="18" y="95" width="114" height="17"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="New preset name:" id="Pe0-gr-Yv4">
+ <font key="font" metaFont="system"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UXm-yG-bgW">
+ <rect key="frame" x="20" y="65" width="250" height="22"/>
+ <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="Untitled" drawsBackground="YES" id="NQn-fS-Rbd">
+ <font key="font" metaFont="system"/>
+ <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ <connections>
+ <outlet property="delegate" destination="-2" id="Iwm-TQ-ug8"/>
+ </connections>
+ </textField>
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HkI-lC-Q2A">
+ <rect key="frame" x="106" y="13" width="82" height="32"/>
+ <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="N2f-jz-YyX">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+ </buttonCell>
+ <connections>
+ <action selector="dismiss:" target="-2" id="LVI-0f-38c"/>
+ </connections>
+ </button>
+ <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WEv-SR-3sw" userLabel="Rename Button">
+ <rect key="frame" x="187" y="13" width="89" height="32"/>
+ <buttonCell key="cell" type="push" title="Rename" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Z9M-dc-5Ml">
+ <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+ <font key="font" metaFont="system"/>
+ <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+ </buttonCell>
+ <connections>
+ <action selector="rename:" target="-2" id="BAK-gD-GHH"/>
+ </connections>
+ </button>
+ </subviews>
+ <constraints>
+ <constraint firstItem="UXm-yG-bgW" firstAttribute="trailing" secondItem="WEv-SR-3sw" secondAttribute="trailing" id="FMb-6L-akr"/>
+ <constraint firstItem="HkI-lC-Q2A" firstAttribute="baseline" secondItem="WEv-SR-3sw" secondAttribute="baseline" id="SxI-wa-yJV"/>
+ <constraint firstItem="A8w-ij-o7q" firstAttribute="leading" secondItem="UXm-yG-bgW" secondAttribute="leading" id="TKi-pl-2oX"/>
+ <constraint firstItem="A8w-ij-o7q" firstAttribute="leading" secondItem="3oN-GT-JmW" secondAttribute="leading" constant="20" symbolic="YES" id="Tnf-NN-kbG"/>
+ <constraint firstAttribute="bottom" secondItem="HkI-lC-Q2A" secondAttribute="bottom" constant="20" symbolic="YES" id="UNd-bY-NCa"/>
+ <constraint firstItem="A8w-ij-o7q" firstAttribute="top" secondItem="3oN-GT-JmW" secondAttribute="top" constant="20" symbolic="YES" id="ds6-hB-jKz"/>
+ <constraint firstItem="WEv-SR-3sw" firstAttribute="leading" secondItem="HkI-lC-Q2A" secondAttribute="trailing" constant="11" id="iPl-sl-4rt"/>
+ <constraint firstAttribute="trailing" secondItem="UXm-yG-bgW" secondAttribute="trailing" constant="20" symbolic="YES" id="nUT-Cq-nKu"/>
+ <constraint firstItem="UXm-yG-bgW" firstAttribute="top" secondItem="A8w-ij-o7q" secondAttribute="bottom" constant="8" symbolic="YES" id="y1i-GD-vKr"/>
+ </constraints>
+ </view>
+ <connections>
+ <outlet property="delegate" destination="-2" id="7b1-8k-MIb"/>
+ </connections>
+ <point key="canvasLocation" x="66" y="176"/>
+ </window>
+ </objects>
+</document>
diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib
index be6b5f151..75274b917 100644
--- a/macosx/English.lproj/MainMenu.xib
+++ b/macosx/English.lproj/MainMenu.xib
@@ -345,6 +345,14 @@
<action selector="setDefaultPreset:" target="-1" id="adZ-ic-MKn"/>
</connections>
</menuItem>
+ <menuItem isSeparatorItem="YES" tag="-1" id="2954">
+ <modifierMask key="keyEquivalentModifierMask" command="YES"/>
+ </menuItem>
+ <menuItem title="Rename Preset…" tag="-1" id="1GQ-n3-jfY">
+ <connections>
+ <action selector="renamePreset:" target="-1" id="ts9-w0-2WC"/>
+ </connections>
+ </menuItem>
<menuItem title="Delete Preset" tag="-1" id="CN3-Rh-gVf">
<connections>
<action selector="deletePreset:" target="-1" id="ZGV-Ji-MGc"/>
diff --git a/macosx/HBController.h b/macosx/HBController.h
index b93fefb24..f650a5bf0 100644
--- a/macosx/HBController.h
+++ b/macosx/HBController.h
@@ -38,8 +38,10 @@
// Manage User presets
- (IBAction)showAddPresetPanel:(id)sender;
+- (IBAction)showRenamePresetPanel:(id)sender;
- (IBAction)selectDefaultPreset:(id)sender;
+- (IBAction)renamePreset:(id)sender;
- (IBAction)deletePreset:(id)sender;
- (IBAction)reloadPreset:(id)sender;
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];
diff --git a/macosx/HBRenamePresetController.h b/macosx/HBRenamePresetController.h
new file mode 100644
index 000000000..35b2b914d
--- /dev/null
+++ b/macosx/HBRenamePresetController.h
@@ -0,0 +1,22 @@
+/* HBRenamePresetController.h
+
+ 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 <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class HBPreset;
+@class HBPresetsManager;
+
+@interface HBRenamePresetController : NSWindowController
+
+- (instancetype)initWithPreset:(HBPreset *)preset presetManager:(HBPresetsManager *)manager;
+
+@property (nonatomic, readonly) HBPreset *preset;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/macosx/HBRenamePresetController.m b/macosx/HBRenamePresetController.m
new file mode 100644
index 000000000..be87fe002
--- /dev/null
+++ b/macosx/HBRenamePresetController.m
@@ -0,0 +1,85 @@
+/* HBRenamePresetController.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 "HBRenamePresetController.h"
+
+#import "HBPresetsManager.h"
+#import "HBPreset.h"
+
+@import HandBrakeKit;
+
+@interface HBRenamePresetController () <NSTextFieldDelegate>
+
+@property (nonatomic, strong) IBOutlet NSTextField *name;
+@property (nonatomic, strong) IBOutlet NSButton *renameButton;
+
+@property (nonatomic, strong) HBPreset *preset;
+
+@property (nonatomic, strong) HBPresetsManager *manager;
+
+@end
+
+@implementation HBRenamePresetController
+
+- (instancetype)initWithPreset:(HBPreset *)preset presetManager:(HBPresetsManager *)manager
+{
+ self = [super initWithWindowNibName:@"HBRenamePresetController"];
+ if (self)
+ {
+ NSParameterAssert(preset);
+ NSParameterAssert(manager);
+ _preset = preset;
+ _manager = manager;
+ }
+ return self;
+}
+
+- (void)windowDidLoad
+{
+ [super windowDidLoad];
+
+ self.name.stringValue = self.name.placeholderString = self.preset.name;
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(controlTextDidChange:)
+ name:NSControlTextDidChangeNotification object:nil];
+}
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSControlTextDidChangeNotification object:nil];
+}
+
+- (void)controlTextDidChange:(NSNotification *)obj {
+ self.renameButton.enabled = self.name.stringValue.length > 0 ? YES : NO;
+}
+
+- (IBAction)dismiss:(id)sender
+{
+ [self.window orderOut:nil];
+ [NSApp endSheet:self.window returnCode:NSModalResponseCancel];
+}
+
+- (IBAction)rename:(id)sender
+{
+ if (self.name.stringValue.length == 0)
+ {
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert setMessageText:NSLocalizedString(@"The preset name cannot be empty.", @"")];
+ [alert setInformativeText:NSLocalizedString(@"Please enter a name.", @"")];
+ [alert runModal];
+ }
+ else
+ {
+ [self.preset setName:self.name.stringValue];
+
+ [self.window orderOut:nil];
+ [NSApp endSheet:self.window returnCode:NSModalResponseContinue];
+ }
+}
+
+
+@end
diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj
index 17b667e8d..4dab5ac9f 100644
--- a/macosx/HandBrake.xcodeproj/project.pbxproj
+++ b/macosx/HandBrake.xcodeproj/project.pbxproj
@@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
1C6D76551CD7733300F5B943 /* libharfbuzz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C15C82B1CD7722500368223 /* libharfbuzz.a */; };
1C6D76561CD7733400F5B943 /* libharfbuzz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1C15C82B1CD7722500368223 /* libharfbuzz.a */; };
+ 1C7776A2202300DD001C31EB /* HBRenamePresetController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C7776A0202300DC001C31EB /* HBRenamePresetController.m */; };
+ 1C7776A5202301D5001C31EB /* HBRenamePresetController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C7776A3202301D5001C31EB /* HBRenamePresetController.xib */; };
226268E11572CC7300477B4E /* libavresample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 226268DF1572CC7300477B4E /* libavresample.a */; };
22DD2C4B177B95DA00EF50D3 /* libvpx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22DD2C49177B94DB00EF50D3 /* libvpx.a */; };
273F202314ADB8650021BE6D /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 273F202214ADB8650021BE6D /* IOKit.framework */; };
@@ -316,6 +318,9 @@
/* Begin PBXFileReference section */
1C15C82B1CD7722500368223 /* libharfbuzz.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libharfbuzz.a; path = external/contrib/lib/libharfbuzz.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ 1C7776A0202300DC001C31EB /* HBRenamePresetController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBRenamePresetController.m; sourceTree = "<group>"; };
+ 1C7776A1202300DC001C31EB /* HBRenamePresetController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBRenamePresetController.h; sourceTree = "<group>"; };
+ 1C7776A4202301D5001C31EB /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/HBRenamePresetController.xib; sourceTree = "<group>"; };
226268DF1572CC7300477B4E /* libavresample.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavresample.a; path = external/contrib/lib/libavresample.a; sourceTree = BUILT_PRODUCTS_DIR; };
22CC9E74191EBEA500C69D81 /* libx265.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libx265.a; path = external/contrib/lib/libx265.a; sourceTree = BUILT_PRODUCTS_DIR; };
22DD2C49177B94DB00EF50D3 /* libvpx.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libvpx.a; path = external/contrib/lib/libvpx.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1198,6 +1203,9 @@
273F20A014ADBE670021BE6D /* HBPreferencesController.m */,
A939DD891FC8826A00135F2A /* HBPresetsMenuBuilder.h */,
A939DD8A1FC8826A00135F2A /* HBPresetsMenuBuilder.m */,
+ 1C7776A1202300DC001C31EB /* HBRenamePresetController.h */,
+ 1C7776A0202300DC001C31EB /* HBRenamePresetController.m */,
+ 1C7776A3202301D5001C31EB /* HBRenamePresetController.xib */,
);
name = Controllers;
sourceTree = "<group>";
@@ -1486,6 +1494,7 @@
A9F2EB6F196F12C800066546 /* Audio.xib in Resources */,
A9CF25F11990D62C0023F727 /* Presets.xib in Resources */,
A9C1839D1A716BCC00C897C2 /* HBTitleSelection.xib in Resources */,
+ 1C7776A5202301D5001C31EB /* HBRenamePresetController.xib in Resources */,
273F218A14ADDDA10021BE6D /* AdvancedView.xib in Resources */,
273F218B14ADDDA10021BE6D /* InfoPlist.strings in Resources */,
A932E26C1988334B0047D13E /* AudioDefaults.xib in Resources */,
@@ -1574,6 +1583,7 @@
A99F40CF1B624E7E00750170 /* HBPictureViewController.m in Sources */,
273F20AF14ADBE670021BE6D /* HBAudioController.m in Sources */,
A9DC6C52196F04F6002AE6B4 /* HBSubtitlesController.m in Sources */,
+ 1C7776A2202300DD001C31EB /* HBRenamePresetController.m in Sources */,
A9F472891976B7F30009EC65 /* HBSubtitlesDefaultsController.m in Sources */,
273F20AD14ADBE670021BE6D /* HBAdvancedController.m in Sources */,
A9906B2C1A710920001D82D5 /* HBQueueController.m in Sources */,
@@ -1691,6 +1701,14 @@
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
+ 1C7776A3202301D5001C31EB /* HBRenamePresetController.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 1C7776A4202301D5001C31EB /* English */,
+ );
+ name = HBRenamePresetController.xib;
+ sourceTree = "<group>";
+ };
273F217A14ADDDA10021BE6D /* AdvancedView.xib */ = {
isa = PBXVariantGroup;
children = (