'final' progress objects: will prevent child progress objects from showing too.

This commit is contained in:
Matthias Koefferlein 2021-03-13 10:12:53 +01:00
parent 7c4c928632
commit 3378a9a7ce
3 changed files with 28 additions and 2 deletions

View File

@ -322,7 +322,11 @@ ProgressWidget::set_progress (tl::Progress *progress)
double v = progress->value ();
pb->set_value (v, value);
progress = progress->next ();
if (progress->final ()) {
progress = 0;
} else {
progress = progress->next ();
}
} else {
pb->hide ();

View File

@ -131,7 +131,9 @@ ProgressGarbageCollector::~ProgressGarbageCollector ()
static tl::ThreadStorage<ProgressAdaptor **> s_thread_data;
Progress::Progress (const std::string &desc, size_t yield_interval)
: m_desc (desc), m_title (desc),
: m_desc (desc),
m_final (false),
m_title (desc),
m_interval_count (0),
m_yield_interval (yield_interval),
m_last_value (-1.0),

View File

@ -260,6 +260,25 @@ public:
return m_desc;
}
/**
* @brief Sets a value indicating whether the progress is a "final" one
*
* A final progress will prevent child progress objects from showing. It basically summarizes child operations.
* By default, a progress object is not final.
*/
void set_final (bool f)
{
m_final = f;
}
/**
* @brief Gets a value indicating whether the progress is a "final" one
*/
bool final () const
{
return m_final;
}
/**
* @brief Render the title string
*/
@ -297,6 +316,7 @@ private:
friend class ProgressGarbageCollector;
std::string m_desc;
bool m_final;
std::string m_title;
size_t m_interval_count;
size_t m_yield_interval;