From e6bafa0b3890641c5b69c4187828de1e5faaa5fc Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 24 Jul 2022 23:12:11 -0700 Subject: [PATCH] [Playlist Loader] Add option to load more files Add option to load every file in a folder when opening just one or more files in that folder. Signed-off-by: Christopher Snowhill --- Playlist/PlaylistLoader.m | 13 ++++++++++- .../Preferences/Base.lproj/Preferences.xib | 23 ++++++++++++++----- .../Preferences/en.lproj/Preferences.strings | 3 +++ .../Preferences/es.lproj/Preferences.strings | 3 +++ .../Preferences/pl.lproj/Preferences.strings | 2 ++ .../Preferences/ru.lproj/Preferences.strings | 3 +++ 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 7f4ddc922..0c7f236ca 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -62,7 +62,8 @@ extern NSMutableDictionary *kArtworkDictionary; } - (void)initDefaults { - NSDictionary *defaultsDictionary = @{ @"readCueSheetsInFolders": @(YES) }; + NSDictionary *defaultsDictionary = @{ @"readCueSheetsInFolders": @(YES), + @"addOtherFilesInFolders": @(NO) }; [[NSUserDefaults standardUserDefaults] registerDefaults:defaultsDictionary]; } @@ -338,8 +339,11 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc NSMutableArray *containedURLs = [NSMutableArray array]; NSMutableArray *fileURLs = [NSMutableArray array]; NSMutableArray *validURLs = [NSMutableArray array]; + NSMutableArray *folderURLs = [NSMutableArray array]; NSDictionary *xmlData = nil; + BOOL addOtherFilesInFolder = [[NSUserDefaults standardUserDefaults] boolForKey:@"addOtherFilesInFolders"]; + double progress; if(!urls) { @@ -367,6 +371,13 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc // Get subpaths [[SandboxBroker sharedSandboxBroker] addFolderIfMissing:url]; [expandedURLs addObjectsFromArray:[self fileURLsAtPath:[url path]]]; + } else if(addOtherFilesInFolder) { + NSURL *folderUrl = [url URLByDeletingLastPathComponent]; + if(![folderURLs containsObject:folderUrl]) { + [[SandboxBroker sharedSandboxBroker] requestFolderForFile:url]; + [expandedURLs addObjectsFromArray:[self fileURLsAtPath:[folderUrl path]]]; + [folderURLs addObject:folderUrl]; + } } else { [[SandboxBroker sharedSandboxBroker] addFileIfMissing:url]; [expandedURLs addObject:[NSURL fileURLWithPath:[url path]]]; diff --git a/Preferences/Preferences/Base.lproj/Preferences.xib b/Preferences/Preferences/Base.lproj/Preferences.xib index a78d79adc..a02e424dd 100644 --- a/Preferences/Preferences/Base.lproj/Preferences.xib +++ b/Preferences/Preferences/Base.lproj/Preferences.xib @@ -21,11 +21,11 @@ - + - + @@ -45,7 +45,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -97,7 +97,7 @@ - + @@ -117,6 +117,17 @@ + diff --git a/Preferences/Preferences/en.lproj/Preferences.strings b/Preferences/Preferences/en.lproj/Preferences.strings index 54210a310..393690a54 100644 --- a/Preferences/Preferences/en.lproj/Preferences.strings +++ b/Preferences/Preferences/en.lproj/Preferences.strings @@ -235,3 +235,6 @@ /* Class = "NSButtonCell"; title = "Enable FreeSurround stereo to surround upmixing"; ObjectID = "F0i-UK-6Nu"; */ "F0i-UK-6Nu.title" = "Enable FreeSurround stereo to surround upmixing"; + +/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */ +"ws4-en-un8.title" = "Add other files in the same folder when adding a file"; diff --git a/Preferences/Preferences/es.lproj/Preferences.strings b/Preferences/Preferences/es.lproj/Preferences.strings index 8a265a4bf..28ada62bf 100644 --- a/Preferences/Preferences/es.lproj/Preferences.strings +++ b/Preferences/Preferences/es.lproj/Preferences.strings @@ -234,3 +234,6 @@ /* Class = "NSButtonCell"; title = "Enable FreeSurround stereo to surround upmixing"; ObjectID = "F0i-UK-6Nu"; */ "F0i-UK-6Nu.title" = "Activar conversión de sonido estéreo a envolvente"; + +/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */ +"ws4-en-un8.title" = "Add other files in the same folder when adding a file"; diff --git a/Preferences/Preferences/pl.lproj/Preferences.strings b/Preferences/Preferences/pl.lproj/Preferences.strings index 4ca087c9e..cc009df58 100644 --- a/Preferences/Preferences/pl.lproj/Preferences.strings +++ b/Preferences/Preferences/pl.lproj/Preferences.strings @@ -101,3 +101,5 @@ /* Class = "NSMenuItem"; title = "Delete Path"; ObjectID = "nva-pz-xSS"; */ "nva-pz-xSS.title" = "usunąć ścieżkę"; +/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */ +"ws4-en-un8.title" = "Add other files in the same folder when adding a file"; diff --git a/Preferences/Preferences/ru.lproj/Preferences.strings b/Preferences/Preferences/ru.lproj/Preferences.strings index 7015115a4..e9b2e5134 100644 --- a/Preferences/Preferences/ru.lproj/Preferences.strings +++ b/Preferences/Preferences/ru.lproj/Preferences.strings @@ -196,3 +196,6 @@ /* Class = "NSButtonCell"; title = "Enable FreeSurround stereo to surround upmixing"; ObjectID = "F0i-UK-6Nu"; */ "F0i-UK-6Nu.title" = "Включить FreeSurround апмикс стерео в объемный звук"; + +/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */ +"ws4-en-un8.title" = "Add other files in the same folder when adding a file";