diff options
-rw-r--r-- | macosx/HBController.m | 4 | ||||
-rw-r--r-- | macosx/HBPreferencesController.m | 5 | ||||
-rw-r--r-- | macosx/HBUtilities.h | 6 | ||||
-rw-r--r-- | macosx/HBUtilities.m | 5 |
4 files changed, 15 insertions, 5 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m index 021242193..2fdc6eb8f 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -188,11 +188,9 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext; #else _destinationURL = [NSUserDefaults.standardUserDefaults URLForKey:HBLastDestinationDirectoryURL]; #endif - if (!_destinationURL || [NSFileManager.defaultManager fileExistsAtPath:_destinationURL.path isDirectory:nil] == NO) { - _destinationURL = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) firstObject] - isDirectory:YES]; + _destinationURL = HBUtilities.defaultDestinationURL; } #ifdef __SANDBOX_ENABLED__ diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 208121635..6da6a49fe 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -5,6 +5,8 @@ #import "HBPreferencesController.h" +@import HandBrakeKit.HBUtilities; + NSString * const HBShowOpenPanelAtLaunch = @"HBShowOpenPanelAtLaunch"; NSString * const HBShowSummaryPreview = @"HBShowSummaryPreview"; @@ -77,8 +79,7 @@ NSString * const HBQueueWorkerCounts = @"HBQueueWorkerCounts"; */ + (void)registerUserDefaults { - NSString *moviesDirectory = [NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) firstObject]; - NSURL *moviesURL = [NSURL fileURLWithPath:moviesDirectory isDirectory:YES]; + NSURL *moviesURL = HBUtilities.defaultDestinationURL; [[NSUserDefaults standardUserDefaults] registerDefaults:@{ HBShowOpenPanelAtLaunch: @YES, diff --git a/macosx/HBUtilities.h b/macosx/HBUtilities.h index fd4704624..285ee4c00 100644 --- a/macosx/HBUtilities.h +++ b/macosx/HBUtilities.h @@ -25,6 +25,12 @@ NS_ASSUME_NONNULL_BEGIN + (nullable NSURL *)appSupportURL; /** + * Returns the default destination URL + */ ++ (nullable NSURL *)defaultDestinationURL; + + +/** * Returns the url of the current version documentation. */ @property (nonatomic, readonly, class) NSURL *documentationURL; diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m index 218824162..5fabfe77c 100644 --- a/macosx/HBUtilities.m +++ b/macosx/HBUtilities.m @@ -35,6 +35,11 @@ static BOOL hb_resolveBookmarks = YES; return appSupportURL; } ++ (NSURL *)defaultDestinationURL +{ + return [[NSFileManager.defaultManager URLsForDirectory:NSMoviesDirectory inDomains:NSUserDomainMask] firstObject]; +} + + (NSURL *)documentationURL { return [NSURL URLWithString:@"https://handbrake.fr/docs/en/1.3.0/"]; |