@@ -32,7 +32,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
previewComp (previewComp_), | previewComp (previewComp_), | ||||
currentPathBox ("path"), | currentPathBox ("path"), | ||||
fileLabel ("f", TRANS ("file:")), | fileLabel ("f", TRANS ("file:")), | ||||
thread ("Juce FileBrowser") | |||||
thread ("Juce FileBrowser"), | |||||
wasProcessActive (false) | |||||
{ | { | ||||
// You need to specify one or other of the open/save flags.. | // You need to specify one or other of the open/save flags.. | ||||
jassert ((flags & (saveMode | openMode)) != 0); | jassert ((flags & (saveMode | openMode)) != 0); | ||||
@@ -109,6 +110,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_, | |||||
setRoot (currentRoot); | setRoot (currentRoot); | ||||
thread.startThread (4); | thread.startThread (4); | ||||
startTimer (2000); | |||||
} | } | ||||
FileBrowserComponent::~FileBrowserComponent() | FileBrowserComponent::~FileBrowserComponent() | ||||
@@ -178,7 +181,7 @@ void FileBrowserComponent::deselectAllFiles() | |||||
bool FileBrowserComponent::isFileSuitable (const File& file) const | bool FileBrowserComponent::isFileSuitable (const File& file) const | ||||
{ | { | ||||
return (flags & canSelectFiles) != 0 | return (flags & canSelectFiles) != 0 | ||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (file)); | |||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (file)); | |||||
} | } | ||||
bool FileBrowserComponent::isDirectorySuitable (const File&) const | bool FileBrowserComponent::isDirectorySuitable (const File&) const | ||||
@@ -190,10 +193,10 @@ bool FileBrowserComponent::isFileOrDirSuitable (const File& f) const | |||||
{ | { | ||||
if (f.isDirectory()) | if (f.isDirectory()) | ||||
return (flags & canSelectDirectories) != 0 | return (flags & canSelectDirectories) != 0 | ||||
&& (fileFilter == nullptr || fileFilter->isDirectorySuitable (f)); | |||||
&& (fileFilter == nullptr || fileFilter->isDirectorySuitable (f)); | |||||
return (flags & canSelectFiles) != 0 && f.exists() | return (flags & canSelectFiles) != 0 && f.exists() | ||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (f)); | |||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (f)); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
@@ -401,8 +404,6 @@ void FileBrowserComponent::browserRootChanged (const File&) {} | |||||
bool FileBrowserComponent::keyPressed (const KeyPress& key) | bool FileBrowserComponent::keyPressed (const KeyPress& key) | ||||
{ | { | ||||
(void) key; | |||||
#if JUCE_LINUX || JUCE_WINDOWS | #if JUCE_LINUX || JUCE_WINDOWS | ||||
if (key.getModifiers().isCommandDown() | if (key.getModifiers().isCommandDown() | ||||
&& (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) | && (key.getKeyCode() == 'H' || key.getKeyCode() == 'h')) | ||||
@@ -413,6 +414,7 @@ bool FileBrowserComponent::keyPressed (const KeyPress& key) | |||||
} | } | ||||
#endif | #endif | ||||
ignoreUnused (key); | |||||
return false; | return false; | ||||
} | } | ||||
@@ -589,3 +591,16 @@ void FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPa | |||||
{ | { | ||||
getDefaultRoots (rootNames, rootPaths); | getDefaultRoots (rootNames, rootPaths); | ||||
} | } | ||||
void FileBrowserComponent::timerCallback() | |||||
{ | |||||
const bool isProcessActive = Process::isForegroundProcess(); | |||||
if (wasProcessActive != isProcessActive) | |||||
{ | |||||
wasProcessActive = isProcessActive; | |||||
if (isProcessActive && fileList != nullptr) | |||||
refresh(); | |||||
} | |||||
} |
@@ -41,7 +41,8 @@ class JUCE_API FileBrowserComponent : public Component, | |||||
private TextEditorListener, | private TextEditorListener, | ||||
private ButtonListener, | private ButtonListener, | ||||
private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug) | private ComboBoxListener, // (can't use ComboBox::Listener due to idiotic VC2005 bug) | ||||
private FileFilter | |||||
private FileFilter, | |||||
private Timer | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
@@ -103,8 +104,7 @@ public: | |||||
*/ | */ | ||||
File getSelectedFile (int index) const noexcept; | File getSelectedFile (int index) const noexcept; | ||||
/** Deselects any files that are currently selected. | |||||
*/ | |||||
/** Deselects any files that are currently selected. */ | |||||
void deselectAllFiles(); | void deselectAllFiles(); | ||||
/** Returns true if the currently selected file(s) are usable. | /** Returns true if the currently selected file(s) are usable. | ||||
@@ -150,8 +150,7 @@ public: | |||||
*/ | */ | ||||
virtual String getActionVerb() const; | virtual String getActionVerb() const; | ||||
/** Returns true if the saveMode flag was set when this component was created. | |||||
*/ | |||||
/** Returns true if the saveMode flag was set when this component was created. */ | |||||
bool isSaveMode() const noexcept; | bool isSaveMode() const noexcept; | ||||
/** Sets the label that will be displayed next to the filename entry box. | /** Sets the label that will be displayed next to the filename entry box. | ||||
@@ -243,10 +242,8 @@ public: | |||||
bool isFileSuitable (const File&) const override; | bool isFileSuitable (const File&) const override; | ||||
/** @internal */ | /** @internal */ | ||||
bool isDirectorySuitable (const File&) const override; | bool isDirectorySuitable (const File&) const override; | ||||
/** @internal */ | /** @internal */ | ||||
FilePreviewComponent* getPreviewComponent() const noexcept; | FilePreviewComponent* getPreviewComponent() const noexcept; | ||||
/** @internal */ | /** @internal */ | ||||
DirectoryContentsDisplayComponent* getDisplayComponent() const noexcept; | DirectoryContentsDisplayComponent* getDisplayComponent() const noexcept; | ||||
@@ -263,13 +260,13 @@ protected: | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
ScopedPointer <DirectoryContentsList> fileList; | |||||
ScopedPointer<DirectoryContentsList> fileList; | |||||
const FileFilter* fileFilter; | const FileFilter* fileFilter; | ||||
int flags; | int flags; | ||||
File currentRoot; | File currentRoot; | ||||
Array<File> chosenFiles; | Array<File> chosenFiles; | ||||
ListenerList <FileBrowserListener> listeners; | |||||
ListenerList<FileBrowserListener> listeners; | |||||
ScopedPointer<DirectoryContentsDisplayComponent> fileListComponent; | ScopedPointer<DirectoryContentsDisplayComponent> fileListComponent; | ||||
FilePreviewComponent* previewComp; | FilePreviewComponent* previewComp; | ||||
@@ -277,11 +274,12 @@ private: | |||||
TextEditor filenameBox; | TextEditor filenameBox; | ||||
Label fileLabel; | Label fileLabel; | ||||
ScopedPointer<Button> goUpButton; | ScopedPointer<Button> goUpButton; | ||||
TimeSliceThread thread; | TimeSliceThread thread; | ||||
bool wasProcessActive; | |||||
void timerCallback() override; | |||||
void sendListenerChangeMessage(); | void sendListenerChangeMessage(); | ||||
bool isFileOrDirSuitable (const File& f) const; | |||||
bool isFileOrDirSuitable (const File&) const; | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBrowserComponent) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBrowserComponent) | ||||
}; | }; | ||||