]> granicus.if.org Git - handbrake/commitdiff
MacGui: pass the main window undomanager to the preview window.
authorDamiano Galassi <damiog@gmail.com>
Fri, 15 Jan 2016 18:44:27 +0000 (19:44 +0100)
committerDamiano Galassi <damiog@gmail.com>
Fri, 15 Jan 2016 18:44:27 +0000 (19:44 +0100)
macosx/HBController.m
macosx/HBPictureController.h
macosx/HBPictureController.m
macosx/HBPreviewController.h
macosx/HBPreviewController.m

index 2c6595380b2b4bb2c1c13a463e94cc4dd89b9e9e..53820dbf7c33f9cdf19b1502dd78674758d0d3dc 100644 (file)
 
         // Inits the controllers
         fPreviewController = [[HBPreviewController alloc] init];
+        fPreviewController.documentController = self;
 
         fQueueController = queueController;
         fQueueController.controller = self;
 
 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
 {
-    SEL action = [menuItem action];
+    SEL action = menuItem.action;
 
     if (action == @selector(addToQueue:) || action == @selector(addAllTitlesToQueue:) ||
         action == @selector(addTitlesToQueue:) || action == @selector(showAddPresetPanel:))
index 1901420a50f4cc38700f78bb4c48bdfff8972824..577937dfd550bc2688a21f07d9e14774f248a5a7 100644 (file)
@@ -11,5 +11,6 @@
 @interface HBPictureController : NSWindowController <NSWindowDelegate>
 
 @property (nonatomic, readwrite, strong) HBPicture *picture;
+@property (nonatomic, readwrite, assign) NSWindowController *previewController;
 
 @end
index 8dee131872f01f02aaaa373384a187a5cf91116d..b6fed1f282a67a97cdf7a98c56329f7830638c20 100644 (file)
@@ -72,6 +72,11 @@ static void *HBPictureControllerContext = &HBPictureControllerContext;
     [self adjustSizingDisplay:nil];
 }
 
+- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window
+{
+    return self.previewController.window.undoManager;
+}
+
 #pragma mark - KVO
 
 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
index ccef18cd1cbfd9b8a2c8ba9335f0864923361860..ca0cdefbc6563fe73d8be9561a27f0c48d1042ba 100644 (file)
@@ -8,10 +8,13 @@
 
 @class HBPreviewGenerator;
 @class HBPicture;
+@class HBController;
 
 @interface HBPreviewController : NSWindowController <NSWindowDelegate>
 
 @property (nonatomic, strong) HBPreviewGenerator *generator;
 @property (nonatomic, strong) HBPicture *picture;
 
+@property (nonatomic, assign) HBController *documentController;
+
 @end
index d9c7b055dd8ec3afe2358b102b2fec2b7864225c..974173d523e0777685ad31cb239f6a5936989f61 100644 (file)
@@ -10,6 +10,8 @@
 
 #import "HBPreviewView.h"
 
+#import "HBController.h"
+
 #import <QTKit/QTKit.h>
 #import "QTKit+HBQTMovieExtensions.h"
 
@@ -141,6 +143,33 @@ typedef enum ViewMode : NSUInteger {
     [_generator cancel];
 }
 
+- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
+{
+    SEL action = menuItem.action;
+
+    if (action == @selector(selectPresetFromMenu:))
+    {
+        return [self.documentController validateMenuItem:menuItem];
+    }
+
+    return YES;
+}
+
+- (IBAction)selectDefaultPreset:(id)sender
+{
+    [self.documentController selectDefaultPreset:sender];
+}
+
+- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window
+{
+    return self.documentController.window.undoManager;
+}
+
+- (IBAction)selectPresetFromMenu:(id)sender
+{
+    [self.documentController selectPresetFromMenu:sender];
+}
+
 - (void)setPicture:(HBPicture *)picture
 {
     _picture = picture;
@@ -641,6 +670,7 @@ typedef enum ViewMode : NSUInteger {
     if (self.pictureSettingsWindow == nil)
     {
         self.pictureSettingsWindow = [[HBPictureController alloc] init];
+        self.pictureSettingsWindow.previewController = self;
     }
 
     self.pictureSettingsWindow.picture = self.picture;