diff --git a/src/GUI/ProgressStatusBar.cpp b/src/GUI/ProgressStatusBar.cpp index ceb909af8..b3f47f1ed 100644 --- a/src/GUI/ProgressStatusBar.cpp +++ b/src/GUI/ProgressStatusBar.cpp @@ -52,6 +52,18 @@ void ProgressStatusBar::OnSize(wxSizeEvent &e) { e.Skip(); } +void ProgressStatusBar::SetProgress(size_t val) { + if (!this->prog->IsShown()) { + this->ShowProgress(true); + } + if (val == this->prog->GetRange()) { + this->prog->SetValue(0); + this->ShowProgress(false); + } else { + this->prog->SetValue(val); + } +} + void ProgressStatusBar::OnTimer(wxTimerEvent& e) { if (this->prog->IsShown()) this->timer->Stop(); diff --git a/src/GUI/ProgressStatusBar.hpp b/src/GUI/ProgressStatusBar.hpp index dfb792e8b..e295dbd6a 100644 --- a/src/GUI/ProgressStatusBar.hpp +++ b/src/GUI/ProgressStatusBar.hpp @@ -32,21 +32,25 @@ public: cb == nullptr ? this->cancelbutton->Hide() : this->cancelbutton->Show(); } - /// Accessor function for the current value of the progress bar - size_t GetProgress() {return this->prog->GetValue();} - - /// Accessor function for busy state - bool IsBusy() {return this->busy;} - /// Show the progress bar. void ShowProgress(bool show = true) { this->prog->Show(show); this->prog->Pulse(); } + /// Accessor function for the current value of the progress bar + inline size_t GetProgress() {return this->prog->GetValue();} + + /// Accessor set function for the current value of the progress bar + void SetProgress(size_t val); + void SetRange(int range) { if (range != this->prog->GetRange() ) this->prog->SetRange(range);} /// Start the timer. void Run(int rate = 100) { if (this->timer->IsRunning()) this->timer->Start(rate);}; void StartBusy(int rate = 100) { this->busy = true; this->ShowProgress(true); if (!this->timer->IsRunning()) this->timer->Start(rate); } + void StopBusy() { this->timer->Stop(); this->ShowProgress(false); this->prog->SetValue(0); this->busy = false;} + + /// Accessor function for busy state + bool IsBusy() {return this->busy;} private: void OnSize(wxSizeEvent& e);