summaryrefslogtreecommitdiffstats
path: root/macosx/HBAppDelegate.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2019-07-19 21:17:27 +0200
committerDamiano Galassi <[email protected]>2019-07-19 21:17:27 +0200
commit97734fff76d15a2da60f7956d82d463ac7ce6ece (patch)
tree11d568970a940eea0bb12dd8594773da39c830a4 /macosx/HBAppDelegate.m
parentf7654c69cb5bad5dcdeaa7375e04327c5178d387 (diff)
MacGui: refactor the queue and implement part of the new queue ui.
Diffstat (limited to 'macosx/HBAppDelegate.m')
-rw-r--r--macosx/HBAppDelegate.m43
1 files changed, 28 insertions, 15 deletions
diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m
index de227e153..d8790fb7c 100644
--- a/macosx/HBAppDelegate.m
+++ b/macosx/HBAppDelegate.m
@@ -6,6 +6,8 @@
#import "HBAppDelegate.h"
+#import "HBQueue.h"
+
#import "HBUtilities.h"
#import "HBPresetsManager.h"
#import "HBPreset.h"
@@ -28,6 +30,8 @@
@property (unsafe_unretained) IBOutlet NSMenu *presetsMenu;
@property (nonatomic, strong) HBPreferencesController *preferencesController;
+
+@property (nonatomic, strong) HBQueue *queue;
@property (nonatomic, strong) HBQueueController *queueController;
@property (nonatomic, strong) HBOutputPanelController *outputPanel;
@@ -59,9 +63,10 @@
_presetsManager = [[HBPresetsManager alloc] initWithURL:[appSupportURL URLByAppendingPathComponent:PRESET_FILE]];
// Queue
- _queueController = [[HBQueueController alloc] initWithURL:[appSupportURL URLByAppendingPathComponent:QUEUE_FILE]];
+ _queue = [[HBQueue alloc] initWithURL:[appSupportURL URLByAppendingPathComponent:QUEUE_FILE]];
+ _queueController = [[HBQueueController alloc] initWithQueue:_queue];
_queueController.delegate = self;
- _mainController = [[HBController alloc] initWithQueue:_queueController presetsManager:_presetsManager];
+ _mainController = [[HBController alloc] initWithDelegate:self queue:_queue presetsManager:_presetsManager];
}
return self;
}
@@ -116,13 +121,13 @@
}
else
{
- [self.queueController setEncodingJobsAsPending];
- [self.queueController removeCompletedJobs];
+ [self.queue setEncodingJobsAsPending];
+ [self.queue removeCompletedAndCancelledItems];
}
// Now we re-check the queue array to see if there are
// any remaining encodes to be done
- if (self.queueController.count)
+ if (self.queue.items.count)
{
[self showMainWindow:self];
[self showQueueWindow:self];
@@ -158,7 +163,7 @@
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)app
{
- if (self.queueController.core.state != HBStateIdle)
+ if (self.queue.isEncoding)
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:NSLocalizedString(@"Are you sure you want to quit HandBrake?", @"Quit Alert -> message")];
@@ -192,6 +197,7 @@
_mainController = nil;
_queueController = nil;
+ _queue = nil;
[HBCore closeGlobal];
}
@@ -206,7 +212,7 @@
{
SEL action = menuItem.action;
- if (action == @selector(rip:) || action == @selector(pause:))
+ if (action == @selector(toggleStartCancel:) || action == @selector(togglePauseResume:))
{
// Delegate the validation to the queue controller
return [self.queueController validateMenuItem:menuItem];
@@ -281,21 +287,28 @@
}
}
+#pragma mark - Rescan job
+
+- (void)openJob:(HBJob *)job completionHandler:(void (^)(BOOL result))handler
+{
+ [self.mainController openJob:job completionHandler:handler];
+}
+
#pragma mark - Menu actions
-- (IBAction)rip:(id)sender
+- (IBAction)toggleStartCancel:(id)sender
{
- [self.queueController rip:self];
+ [self.queueController toggleStartCancel:sender];
}
-- (IBAction)pause:(id)sender
+- (IBAction)togglePauseResume:(id)sender
{
- [self.queueController togglePauseResume:self];
+ [self.queueController togglePauseResume:sender];
}
- (IBAction)browseSources:(id)sender
{
- [self.mainController browseSources:self];
+ [self.mainController browseSources:sender];
}
#pragma mark - Presets Menu actions
@@ -310,7 +323,7 @@
- (IBAction)reloadPreset:(id)sender
{
- [self.mainController reloadPreset:self];
+ [self.mainController reloadPreset:sender];
}
#pragma mark - Show Window Menu Items
@@ -325,7 +338,7 @@
_preferencesController = [[HBPreferencesController alloc] init];
}
- [self.preferencesController showWindow:self];
+ [self.preferencesController showWindow:sender];
}
/**
@@ -346,7 +359,7 @@
- (IBAction)showPreviewWindow:(id)sender
{
- [self.mainController showPreviewWindow:self];
+ [self.mainController showPreviewWindow:sender];
}
/**