mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-24 01:54:22 +00:00
Add treatFilePackagesAsDirectories flag to native FileChooser
This commit is contained in:
parent
cda1e4f518
commit
9629de32bb
6 changed files with 38 additions and 19 deletions
|
|
@ -25,11 +25,13 @@
|
|||
FileChooser::FileChooser (const String& chooserBoxTitle,
|
||||
const File& currentFileOrDirectory,
|
||||
const String& fileFilters,
|
||||
const bool useNativeBox)
|
||||
const bool useNativeBox,
|
||||
const bool treatFilePackagesAsDirectories)
|
||||
: title (chooserBoxTitle),
|
||||
filters (fileFilters),
|
||||
startingFile (currentFileOrDirectory),
|
||||
useNativeDialogBox (useNativeBox && isPlatformDialogAvailable())
|
||||
useNativeDialogBox (useNativeBox && isPlatformDialogAvailable()),
|
||||
treatFilePackagesAsDirs (treatFilePackagesAsDirectories)
|
||||
{
|
||||
if (! fileFilters.containsNonWhitespaceChars())
|
||||
filters = "*";
|
||||
|
|
@ -106,7 +108,8 @@ bool FileChooser::showDialog (const int flags, FilePreviewComponent* const previ
|
|||
{
|
||||
showPlatformDialog (results, title, startingFile, filters,
|
||||
selectsDirectories, selectsFiles, isSave,
|
||||
warnAboutOverwrite, selectMultiple, previewComp);
|
||||
warnAboutOverwrite, selectMultiple, treatFilePackagesAsDirs,
|
||||
previewComp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,25 +60,32 @@ public:
|
|||
|
||||
After creating one of these, use one of the browseFor... methods to display it.
|
||||
|
||||
@param dialogBoxTitle a text string to display in the dialog box to
|
||||
tell the user what's going on
|
||||
@param initialFileOrDirectory the file or directory that should be selected when
|
||||
the dialog box opens. If this parameter is set to
|
||||
File::nonexistent, a sensible default directory
|
||||
will be used instead.
|
||||
@param filePatternsAllowed a set of file patterns to specify which files can be
|
||||
selected - each pattern should be separated by a
|
||||
comma or semi-colon, e.g. "*" or "*.jpg;*.gif". An
|
||||
empty string means that all files are allowed
|
||||
@param useOSNativeDialogBox if true, then a native dialog box will be used if
|
||||
possible; if false, then a Juce-based browser dialog
|
||||
box will always be used
|
||||
@param dialogBoxTitle a text string to display in the dialog box to
|
||||
tell the user what's going on
|
||||
@param initialFileOrDirectory the file or directory that should be selected
|
||||
when the dialog box opens. If this parameter is
|
||||
set to File::nonexistent, a sensible default
|
||||
directory will be used instead.
|
||||
@param filePatternsAllowed a set of file patterns to specify which files
|
||||
can be selected - each pattern should be
|
||||
separated by a comma or semi-colon, e.g. "*" or
|
||||
"*.jpg;*.gif". An empty string means that all
|
||||
files are allowed
|
||||
@param useOSNativeDialogBox if true, then a native dialog box will be used
|
||||
if possible; if false, then a Juce-based
|
||||
browser dialog box will always be used
|
||||
@param treatFilePackagesAsDirectories if true, then the file chooser will allow the
|
||||
selection of files inside packages when
|
||||
invoked on OS X and when using native dialog
|
||||
boxes.
|
||||
|
||||
@see browseForFileToOpen, browseForFileToSave, browseForDirectory
|
||||
*/
|
||||
FileChooser (const String& dialogBoxTitle,
|
||||
const File& initialFileOrDirectory = File::nonexistent,
|
||||
const String& filePatternsAllowed = String::empty,
|
||||
bool useOSNativeDialogBox = true);
|
||||
bool useOSNativeDialogBox = true,
|
||||
bool treatFilePackagesAsDirectories = false);
|
||||
|
||||
/** Destructor. */
|
||||
~FileChooser();
|
||||
|
|
@ -183,11 +190,12 @@ private:
|
|||
const File startingFile;
|
||||
Array<File> results;
|
||||
const bool useNativeDialogBox;
|
||||
const bool treatFilePackagesAsDirs;
|
||||
|
||||
static void showPlatformDialog (Array<File>& results, const String& title, const File& file,
|
||||
const String& filters, bool selectsDirectories, bool selectsFiles,
|
||||
bool isSave, bool warnAboutOverwritingExistingFiles, bool selectMultipleFiles,
|
||||
FilePreviewComponent* previewComponent);
|
||||
bool treatFilePackagesAsDirs, FilePreviewComponent* previewComponent);
|
||||
static bool isPlatformDialogAvailable();
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileChooser)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ void FileChooser::showPlatformDialog (Array<File>& results,
|
|||
bool isSaveDialogue,
|
||||
bool warnAboutOverwritingExistingFiles,
|
||||
bool selectMultipleFiles,
|
||||
bool /*treatFilePackagesAsDirs*/,
|
||||
FilePreviewComponent* extraInfoComponent)
|
||||
{
|
||||
// TODO
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ void FileChooser::showPlatformDialog (Array<File>& results,
|
|||
const String& title, const File& file, const String& filters,
|
||||
bool isDirectory, bool /* selectsFiles */,
|
||||
bool isSave, bool /* warnAboutOverwritingExistingFiles */,
|
||||
bool /*treatFilePackagesAsDirs*/,
|
||||
bool selectMultipleFiles, FilePreviewComponent*)
|
||||
{
|
||||
const File previousWorkingDirectory (File::getCurrentWorkingDirectory());
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ void FileChooser::showPlatformDialog (Array<File>& results,
|
|||
bool isSaveDialogue,
|
||||
bool /*warnAboutOverwritingExistingFiles*/,
|
||||
bool selectMultipleFiles,
|
||||
bool treatFilePackagesAsDirs,
|
||||
FilePreviewComponent* extraInfoComponent)
|
||||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
|
|
@ -177,6 +178,9 @@ void FileChooser::showPlatformDialog (Array<File>& results,
|
|||
[openPanel setCanChooseFiles: selectsFiles];
|
||||
[openPanel setAllowsMultipleSelection: selectMultipleFiles];
|
||||
[openPanel setResolvesAliases: YES];
|
||||
|
||||
if (treatFilePackagesAsDirs)
|
||||
[openPanel setTreatsFilePackagesAsDirectories: YES];
|
||||
}
|
||||
|
||||
if (extraInfoComponent != nullptr)
|
||||
|
|
@ -260,6 +264,7 @@ void FileChooser::showPlatformDialog (Array<File>&,
|
|||
bool /*isSaveDialogue*/,
|
||||
bool /*warnAboutOverwritingExistingFiles*/,
|
||||
bool /*selectMultipleFiles*/,
|
||||
bool /*treatFilePackagesAsDirs*/,
|
||||
FilePreviewComponent*)
|
||||
{
|
||||
jassertfalse; //there's no such thing in iOS
|
||||
|
|
|
|||
|
|
@ -130,7 +130,8 @@ bool FileChooser::isPlatformDialogAvailable()
|
|||
void FileChooser::showPlatformDialog (Array<File>& results, const String& title_, const File& currentFileOrDirectory,
|
||||
const String& filter, bool selectsDirectory, bool /*selectsFiles*/,
|
||||
bool isSaveDialogue, bool warnAboutOverwritingExistingFiles,
|
||||
bool selectMultipleFiles, FilePreviewComponent* extraInfoComponent)
|
||||
bool selectMultipleFiles, bool /*treatFilePackagesAsDirs*/,
|
||||
FilePreviewComponent* extraInfoComponent)
|
||||
{
|
||||
using namespace FileChooserHelpers;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue