]> granicus.if.org Git - handbrake/commitdiff
MacGui: "Stop" command modifications
authordynaflash <dynaflashtech@gmail.com>
Thu, 18 Sep 2008 18:54:31 +0000 (18:54 +0000)
committerdynaflash <dynaflashtech@gmail.com>
Thu, 18 Sep 2008 18:54:31 +0000 (18:54 +0000)
- Clicking on the "stop" icon in the toolbar now produces a different alert window with three choices
- " Continue Encoding " default, just dismisses the window and continues on its merry way.
- " Cancel Current and Stop " Cancels the current encode and stops the queue
- " Cancel Current and Continue " Cancels the current encode and moves to the next pending encode (if there is one).

- Also fixed an issue with deleting a canceled encode at the top of the queue list.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1718 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm
macosx/HBQueueController.mm

index 897d833a1b39a571c6bbfaca77ec0d709b1028aa..6f58b7a29a2e1f42a8825d03e9caa2a73d479a4b 100644 (file)
@@ -329,7 +329,7 @@ BOOL                        fIsDragging;
 
 - (IBAction) Cancel: (id) sender;
 - (void)     doCancelCurrentJob;
-
+- (void) doCancelCurrentJobAndStop;
 - (IBAction) Pause: (id) sender;
 
 - (IBAction) calculateBitrate: (id) sender;
index 483dc8523a825e920e1618f6059c70d82bb35c37..a7d1b73c65db781bf2e5c7cc427181581aed6309 100644 (file)
@@ -1536,8 +1536,8 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 - (void) removeQueueFileItem:(int) queueItemToRemove
 {
    
-   // NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
-   if ([[[QueueFileArray objectAtIndex:queueItemToRemove] objectForKey:@"Status"] intValue] == 3) //<-- Find out if the item we are removing is a cancelled item
+   /* Find out if the item we are removing is a cancelled item*/
+   if ([[[QueueFileArray objectAtIndex:queueItemToRemove] objectForKey:@"Status"] intValue] == 3)
     {
     /* Since we are removing a cancelled item, WE need to decrement the currentQueueEncodeIndex
      * by one to keep in sync with the queue array
@@ -2976,8 +2976,8 @@ fWorkingCount = 0;
 {
     if (!fQueueController) return;
     
-  
-    NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Stop encoding ?", nil)];
+  hb_pause( fQueueEncodeLibhb );
+    NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"You are currently encoding. What would you like to do ?", nil)];
    
     // Which window to attach the sheet to?
     NSWindow * docWindow;
@@ -2988,22 +2988,43 @@ fWorkingCount = 0;
         
     NSBeginCriticalAlertSheet(
             alertTitle,
-            NSLocalizedString(@"Keep Encoding", nil),
-            nil,
-            NSLocalizedString(@"Stop Encoding", nil),
+            NSLocalizedString(@"Continue Encoding", nil),
+            NSLocalizedString(@"Cancel Current and Stop", nil),
+            NSLocalizedString(@"Cancel Current and Continue", nil),
             docWindow, self,
-            nil, @selector(didDimissCancelCurrentJob:returnCode:contextInfo:), nil,
-            NSLocalizedString(@"Your movie will be lost if you don't continue encoding.", nil));
+            nil, @selector(didDimissCancel:returnCode:contextInfo:), nil,
+            NSLocalizedString(@"Your encode will be cancelled if you don't continue encoding.", nil));
     
     // didDimissCancelCurrentJob:returnCode:contextInfo: will be called when the dialog is dismissed
 }
 
-- (void) didDimissCancelCurrentJob: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
+- (void) didDimissCancel: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
 {
-    if (returnCode == NSAlertOtherReturn)
+   hb_resume( fQueueEncodeLibhb );
+     if (returnCode == NSAlertOtherReturn)
+    {
         [self doCancelCurrentJob];  // <- this also stops libhb
+    }
+    if (returnCode == NSAlertAlternateReturn)
+    {
+    [self doCancelCurrentJobAndStop];
+    }
 }
 
+- (void) doCancelCurrentJobAndStop
+{
+    hb_stop( fQueueEncodeLibhb );
+    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
+    
+    // now that we've stopped the currently encoding job, lets mark it as cancelled
+    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
+    // and as always, save it in the queue .plist...
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+    // so now lets move to 
+    currentQueueEncodeIndex++ ;
+    [self writeToActivityLog: "cancelling current job and stopping the queue"];
+}
 - (IBAction) Pause: (id) sender
 {
     hb_state_t s;
index cb8be2351512adb9a31d9c108c3fac4b0aae4284..0e14761281fbfdc960b137fc0b3aaca7e59ce925 100644 (file)
@@ -473,7 +473,8 @@ if (fWorkingCount > 0)
     /* if this is a currently encoding job, we need to be sure to alert the user,
      * to let them decide to cancel it first, then if they do, we can come back and
      * remove it */
-    if (row == fEncodingQueueItem)
+    
+    if ([[[fJobGroups objectAtIndex:row] objectForKey:@"Status"] intValue] == 1)
     {
         NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Stop This Encode and Remove It ?", nil)];
         // Which window to attach the sheet to?