improved progress bar handling for long running file list operations

This commit is contained in:
Thomas Jentzsch 2021-08-24 12:16:30 +02:00
parent 355658bf2e
commit cace55868c
3 changed files with 7 additions and 7 deletions

View File

@ -157,7 +157,6 @@ ProgressDialog& FileListWidget::progress()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FileListWidget::incProgress()
{
if(_includeSubDirs)
progress().incProgress();
}

View File

@ -97,7 +97,8 @@ void ProgressDialog::setRange(int start, int finish, int step)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ProgressDialog::resetProgress()
{
myProgress = myStepProgress = 0;
myLastTick = TimerManager::getTicks();
myProgress = 0;
mySlider->setValue(0);
myIsCancelled = false;
}
@ -105,10 +106,10 @@ void ProgressDialog::resetProgress()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ProgressDialog::setProgress(int progress)
{
// Only increase the progress bar if we have arrived at a new step
if(progress - myStepProgress >= myStep)
// Only increase the progress bar if some time has passed
if(TimerManager::getTicks() - myLastTick > 100000) // update every 1/10th second
{
myStepProgress = progress;
myLastTick = TimerManager::getTicks();
mySlider->setValue(progress % (myFinish - myStart + 1));
// Since this dialog is usually called in a tight loop that doesn't

View File

@ -47,7 +47,7 @@ class ProgressDialog : public Dialog
int myStart{0}, myFinish{0}, myStep{0};
int myProgress{0};
int myStepProgress{0};
uInt64 myLastTick{0};
bool myIsCancelled{false};
private: