From 371fa07a23b86c7099b838f996896d791e5e01b2 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Wed, 6 Mar 2019 09:32:14 +0100 Subject: [PATCH] MacGui: add options to reset 'When done' action on app launch. --- macosx/Base.lproj/Preferences.xib | 59 +++++++++++++++++++------------ macosx/HBAppDelegate.m | 14 ++++++-- macosx/HBPreferencesController.h | 1 + macosx/HBPreferencesController.m | 1 + 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/macosx/Base.lproj/Preferences.xib b/macosx/Base.lproj/Preferences.xib index 1d17a0ec9..ee5f95348 100644 --- a/macosx/Base.lproj/Preferences.xib +++ b/macosx/Base.lproj/Preferences.xib @@ -1,8 +1,8 @@ - + - + @@ -35,14 +35,14 @@ - + - + - + @@ -73,7 +73,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -146,15 +146,15 @@ - + - - + + @@ -180,7 +180,7 @@ - + @@ -198,7 +198,7 @@ - + @@ -219,7 +219,7 @@ - + @@ -251,7 +251,7 @@ - + @@ -273,7 +273,7 @@ + @@ -289,9 +299,11 @@ + + @@ -322,16 +334,17 @@ - + + @@ -350,7 +363,7 @@ - + diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m index 83e768fd1..de227e153 100644 --- a/macosx/HBAppDelegate.m +++ b/macosx/HBAppDelegate.m @@ -79,6 +79,14 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification { + NSUserDefaults *ud = NSUserDefaults.standardUserDefaults; + + // Reset "When done" action + if ([ud boolForKey:@"HBResetWhenDoneOnLaunch"]) + { + [ud setInteger:HBDoneActionDoNothing forKey:@"HBAlertWhenDone"]; + } + if (@available (macOS 10.12.2, *)) { NSApplication.sharedApplication.automaticCustomizeTouchBarMenuItemEnabled = YES; @@ -94,7 +102,7 @@ NSUInteger instances = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]].count; // Open debug output window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"]) + if ([ud boolForKey:@"OutputPanelIsOpen"]) [self showOutputPanel:nil]; // On Screen Notification @@ -122,7 +130,7 @@ else { // Open queue window now if it was visible when HB was closed - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"]) + if ([ud boolForKey:@"QueueWindowIsOpen"]) [self showQueueWindow:nil]; [self showMainWindow:self]; @@ -131,7 +139,7 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ // Remove encodes logs older than a month - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBClearOldLogs"]) + if ([ud boolForKey:@"HBClearOldLogs"]) { [self cleanEncodeLogs]; } diff --git a/macosx/HBPreferencesController.h b/macosx/HBPreferencesController.h index 9b953998c..48e294a42 100644 --- a/macosx/HBPreferencesController.h +++ b/macosx/HBPreferencesController.h @@ -6,6 +6,7 @@ #import typedef NS_ENUM(NSUInteger, HBDoneAction) { + HBDoneActionDoNothing = 0, HBDoneActionAlert = 1, HBDoneActionNotification = 2, HBDoneActionAlertAndNotification = 3, diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 8c41e7409..4ad596738 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -62,6 +62,7 @@ @"HBLastSourceDirectory": [NSKeyedArchiver archivedDataWithRootObject:desktopURL], @"DefaultAutoNaming": @NO, @"HBAlertWhenDone": @(HBDoneActionNotification), + @"HBResetWhenDoneOnLaunch": @NO, @"HBAlertWhenDoneSound": @YES, @"LoggingLevel": @"1", @"HBClearOldLogs": @YES, -- 2.40.0