Made ProgressBar destruction behavior configurable

This commit is contained in:
Daniel Wolf 2017-09-09 21:41:50 +02:00
parent 1511f0a9e0
commit f0d3364213
2 changed files with 12 additions and 1 deletions

View File

@ -87,7 +87,9 @@ void ProgressBar::updateLoop() {
std::this_thread::sleep_for(animationInterval); std::this_thread::sleep_for(animationInterval);
} }
updateText(""); if (clearOnDestruction) {
updateText("");
}
} }
void ProgressBar::updateText(const string& text) { void ProgressBar::updateText(const string& text) {

View File

@ -48,6 +48,14 @@ public:
~ProgressBar(); ~ProgressBar();
void reportProgress(double value) override; void reportProgress(double value) override;
bool getClearOnDestruction() const {
return clearOnDestruction;
}
void setClearOnDestruction(bool value) {
clearOnDestruction = value;
}
private: private:
void updateLoop(); void updateLoop();
void updateText(const std::string& text); void updateText(const std::string& text);
@ -59,4 +67,5 @@ private:
std::ostream& stream; std::ostream& stream;
std::string currentText; std::string currentText;
int animationIndex = 0; int animationIndex = 0;
bool clearOnDestruction = true;
}; };