From 34fa5d0cce108c8821312315cc45285cabf03c4b Mon Sep 17 00:00:00 2001 From: Mark Theng Date: Wed, 7 Dec 2022 19:17:30 +0800 Subject: [PATCH] Make file browser respond to search query changes while loading files (#866) --- src/gui/filebrowser/FileBrowserActivity.cpp | 14 +++++++++++++- src/gui/filebrowser/FileBrowserActivity.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index b76cf6f34..b256e08b9 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -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) diff --git a/src/gui/filebrowser/FileBrowserActivity.h b/src/gui/filebrowser/FileBrowserActivity.h index f75619112..603fbf413 100644 --- a/src/gui/filebrowser/FileBrowserActivity.h +++ b/src/gui/filebrowser/FileBrowserActivity.h @@ -30,6 +30,8 @@ class FileBrowserActivity: public TaskListener, public WindowActivity std::vector components; std::vector componentsQueue; ByteString directory; + bool hasQueuedSearch; + ByteString queuedSearch; ui::ProgressBar * progressBar;