added launcher reload delay while typing filter

This commit is contained in:
thrust26 2020-11-23 09:08:26 +01:00
parent a8d9eab777
commit 106bd3ab91
4 changed files with 28 additions and 2 deletions

View File

@ -88,6 +88,7 @@ class FileListWidget : public StringListWidget
const FilesystemNode& currentDir() const { return _node; }
static void setQuickSelectDelay(uInt64 time) { _QUICK_SELECT_DELAY = time; }
uInt64 getQuickSelectDelay() { return _QUICK_SELECT_DELAY; }
ProgressDialog& progress();
void incProgress();

View File

@ -35,6 +35,7 @@
#include "ProgressDialog.hxx"
#include "MessageBox.hxx"
#include "ToolTip.hxx"
#include "TimerManager.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "FBSurface.hxx"
@ -358,6 +359,16 @@ void LauncherDialog::reload()
{
myMD5List.clear();
myList->reload();
myPendingReload = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void LauncherDialog::tick()
{
if(myPendingReload && myReloadTime < TimerManager::getTicks() / 1000)
reload();
Dialog::tick();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -771,10 +782,19 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
case EditableWidget::kChangedCmd:
{
bool subAllowed = myPattern->getText().length() >= MIN_SUBDIRS_CHARS;
bool subDirs = subAllowed && mySubDirs->getState();
mySubDirs->setEnabled(subAllowed);
myList->setIncludeSubDirs(mySubDirs->getState() && subAllowed);
myList->setIncludeSubDirs(subDirs);
applyFiltering(); // pattern matching taken care of directly in this method
if(subDirs)
{
// delay (potentially slow) subdirectories reloads until user stops typing
myReloadTime = TimerManager::getTicks() / 1000 + myList->getQuickSelectDelay();
myPendingReload = true;
}
else
reload();
break;
}

View File

@ -95,6 +95,8 @@ class LauncherDialog : public Dialog
*/
void reload();
void tick() override;
private:
static constexpr int MIN_LAUNCHER_CHARS = 24;
static constexpr int MIN_ROMINFO_CHARS = 30;
@ -194,6 +196,8 @@ class LauncherDialog : public Dialog
bool myUseMinimalUI{false};
bool myEventHandled{false};
bool myShortCount{false};
bool myPendingReload{false};
uInt64 myReloadTime{0};
enum {
kAllfilesCmd = 'lalf', // show all files (or ROMs only)

View File

@ -49,6 +49,7 @@ WhatsNewDialog::WhatsNewDialog(OSystem& osystem, DialogContainer& parent, const
add(ypos, "enhanced cut/copy/paste for text editing");
add(ypos, "added undo and redo to text editing");
add(ypos, "added wildcard support to launcher dialog filter");
add(ypos, "added option to search subdirectories in launcher");
add(ypos, "added tooltips to many UI items");
add(ypos, "increased sample size for CDFJ+");
add(ypos, ELLIPSIS + " (for a complete list see 'docs/Changes.txt')");