Make file browser respond to search query changes while loading files (#866)

This commit is contained in:
Mark Theng 2022-12-07 19:17:30 +08:00 committed by GitHub
parent 510424363b
commit 34fa5d0cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -83,6 +83,7 @@ FileBrowserActivity::FileBrowserActivity(ByteString directory, OnSelected onSele
WindowActivity(ui::Point(-1, -1), ui::Point(500, 350)),
onSelected(onSelected_),
directory(directory),
hasQueuedSearch(false),
totalFiles(0)
{
@ -127,7 +128,12 @@ FileBrowserActivity::FileBrowserActivity(ByteString directory, OnSelected onSele
void FileBrowserActivity::DoSearch(ByteString search)
{
if(!loadFiles)
if (loadFiles)
{
hasQueuedSearch = true;
queuedSearch = search;
}
else
{
loadDirectory(directory, search);
}
@ -221,6 +227,12 @@ void FileBrowserActivity::NotifyDone(Task * task)
delete components[i];
}
components.clear();
if (hasQueuedSearch)
{
hasQueuedSearch = false;
loadDirectory(directory, queuedSearch);
}
}
void FileBrowserActivity::OnMouseDown(int x, int y, unsigned button)

View File

@ -30,6 +30,8 @@ class FileBrowserActivity: public TaskListener, public WindowActivity
std::vector<ui::Component*> components;
std::vector<ui::Component*> componentsQueue;
ByteString directory;
bool hasQueuedSearch;
ByteString queuedSearch;
ui::ProgressBar * progressBar;