1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-30 02:50:05 +00:00

Added multiple-selection, and the ability to browse for both files and folders to the Juce file chooser dialog classes. This has involved changing a few methods, so if you're using these classes directly, you may need to tweak your code, but it should be very easy to do.

This commit is contained in:
Julian Storer 2009-12-08 16:07:47 +00:00
parent 71a12a140e
commit 1f6d9ec92c
13 changed files with 602 additions and 307 deletions

View file

@ -120,9 +120,11 @@ bool FileChooser::showDialog (const bool selectsDirectories,
&& previewComponent->getHeight() > 10));
#if JUCE_WINDOWS
if (useNativeDialogBox)
#else
if (useNativeDialogBox && ! (selectsFiles && selectsDirectories))
#elif JUCE_MAC
if (useNativeDialogBox && (previewComponent == 0))
#else
if (false)
#endif
{
showPlatformDialog (results, title, startingFile, filters,
@ -133,14 +135,23 @@ bool FileChooser::showDialog (const bool selectsDirectories,
}
else
{
jassert (! selectMultipleFiles); // not yet implemented for juce dialogs!
WildcardFileFilter wildcard (selectsFiles ? filters : String::empty,
selectsDirectories ? "*" : String::empty,
String::empty);
WildcardFileFilter wildcard (filters, String::empty);
int flags = isSave ? FileBrowserComponent::saveMode
: FileBrowserComponent::openMode;
FileBrowserComponent browserComponent (selectsDirectories ? FileBrowserComponent::chooseDirectoryMode
: (isSave ? FileBrowserComponent::saveFileMode
: FileBrowserComponent::loadFileMode),
startingFile, &wildcard, previewComponent);
if (selectsFiles)
flags |= FileBrowserComponent::canSelectFiles;
if (selectsDirectories)
flags |= FileBrowserComponent::canSelectDirectories;
if (selectMultipleFiles)
flags |= FileBrowserComponent::canSelectMultipleItems;
FileBrowserComponent browserComponent (flags, startingFile, &wildcard, previewComponent);
FileChooserDialogBox box (title, String::empty,
browserComponent,
@ -148,7 +159,10 @@ bool FileChooser::showDialog (const bool selectsDirectories,
browserComponent.findColour (AlertWindow::backgroundColourId));
if (box.show())
results.add (new File (browserComponent.getCurrentFile()));
{
for (int i = 0; i < browserComponent.getNumSelectedFiles(); ++i)
results.add (new File (browserComponent.getSelectedFile (i)));
}
}
if (currentlyFocused != 0 && ! currentlyFocusedChecker->hasBeenDeleted())