mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-31 03:00:05 +00:00
Updated FileBrowserComponent to refresh its list if the user switches to another app and then returns.
This commit is contained in:
parent
e2c274840d
commit
6baf778e41
2 changed files with 30 additions and 17 deletions
|
|
@ -32,7 +32,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
|
|||
previewComp (previewComp_),
|
||||
currentPathBox ("path"),
|
||||
fileLabel ("f", TRANS ("file:")),
|
||||
thread ("Juce FileBrowser")
|
||||
thread ("Juce FileBrowser"),
|
||||
wasProcessActive (false)
|
||||
{
|
||||
// You need to specify one or other of the open/save flags..
|
||||
jassert ((flags & (saveMode | openMode)) != 0);
|
||||
|
|
@ -109,6 +110,8 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
|
|||
setRoot (currentRoot);
|
||||
|
||||
thread.startThread (4);
|
||||
|
||||
startTimer (2000);
|
||||
}
|
||||
|
||||
FileBrowserComponent::~FileBrowserComponent()
|
||||
|
|
@ -178,7 +181,7 @@ void FileBrowserComponent::deselectAllFiles()
|
|||
bool FileBrowserComponent::isFileSuitable (const File& file) const
|
||||
{
|
||||
return (flags & canSelectFiles) != 0
|
||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (file));
|
||||
&& (fileFilter == nullptr || fileFilter->isFileSuitable (file));
|
||||
}
|
||||
|
||||
bool FileBrowserComponent::isDirectorySuitable (const File&) const
|
||||
|
|
@ -190,10 +193,10 @@ bool FileBrowserComponent::isFileOrDirSuitable (const File& f) const
|
|||
{
|
||||
if (f.isDirectory())
|
||||
return (flags & canSelectDirectories) != 0
|
||||
&& (fileFilter == nullptr || fileFilter->isDirectorySuitable (f));
|
||||
&& (fileFilter == nullptr || fileFilter->isDirectorySuitable (f));
|
||||
|
||||
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)
|
||||
{
|
||||
(void) key;
|
||||
|
||||
#if JUCE_LINUX || JUCE_WINDOWS
|
||||
if (key.getModifiers().isCommandDown()
|
||||
&& (key.getKeyCode() == 'H' || key.getKeyCode() == 'h'))
|
||||
|
|
@ -413,6 +414,7 @@ bool FileBrowserComponent::keyPressed (const KeyPress& key)
|
|||
}
|
||||
#endif
|
||||
|
||||
ignoreUnused (key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -589,3 +591,16 @@ void FileBrowserComponent::getRoots (StringArray& rootNames, StringArray& rootPa
|
|||
{
|
||||
getDefaultRoots (rootNames, rootPaths);
|
||||
}
|
||||
|
||||
void FileBrowserComponent::timerCallback()
|
||||
{
|
||||
const bool isProcessActive = Process::isForegroundProcess();
|
||||
|
||||
if (wasProcessActive != isProcessActive)
|
||||
{
|
||||
wasProcessActive = isProcessActive;
|
||||
|
||||
if (isProcessActive && fileList != nullptr)
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue