]> granicus.if.org Git - handbrake/commitdiff
MacGui: do not play a sound for notification if alerts are disabled in prefs.
authorDamiano Galassi <damiog@gmail.com>
Wed, 13 Jun 2018 11:04:41 +0000 (13:04 +0200)
committerDamiano Galassi <damiog@gmail.com>
Wed, 13 Jun 2018 11:04:41 +0000 (13:04 +0200)
macosx/HBQueueController.m

index 0c7ad25e36cff35c41e3986a83433773253c8c50..ea915976672a575a4425a42407df2b1c7b63ae26 100644 (file)
     }
 }
 
-- (void)showNotificationWithTitle:(NSString *)title description:(NSString *)description url:(NSURL *)fileURL
+- (void)showNotificationWithTitle:(NSString *)title description:(NSString *)description url:(NSURL *)fileURL playSound:(BOOL)playSound
 {
     NSUserNotification *notification = [[NSUserNotification alloc] init];
     notification.title = title;
     notification.informativeText = description;
-    notification.soundName = NSUserNotificationDefaultSoundName;
+    notification.soundName = playSound ? NSUserNotificationDefaultSoundName : nil;
     notification.hasActionButton = YES;
     notification.actionButtonTitle = NSLocalizedString(@"Show", @"Notification -> Show in Finder");
     notification.userInfo = @{ @"Path": fileURL.path };
         [[NSUserDefaults standardUserDefaults] integerForKey:@"HBAlertWhenDone"] == HBDoneActionAlertAndNotification)
     {
         // If Play System Alert has been selected in Preferences
-        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBAlertWhenDoneSound"] == YES)
-        {
-            NSBeep();
-        }
+        bool playSound = [[NSUserDefaults standardUserDefaults] boolForKey:@"HBAlertWhenDoneSound"];
 
         NSString *title;
         NSString *description;
 
         [self showNotificationWithTitle:title
                             description:description
-                                    url:job.completeOutputURL];
+                                    url:job.completeOutputURL
+                                playSound:playSound];
     }
 }