diff options
Diffstat (limited to 'plugingui/progressbar.cc')
-rw-r--r-- | plugingui/progressbar.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/plugingui/progressbar.cc b/plugingui/progressbar.cc index 932f17c..f934664 100644 --- a/plugingui/progressbar.cc +++ b/plugingui/progressbar.cc @@ -26,6 +26,8 @@ */ #include "progressbar.h" +#include <iostream> + namespace GUI { ProgressBar::ProgressBar(Widget *parent) @@ -46,9 +48,6 @@ ProgressBar::ProgressBar(Widget *parent) bar_green.left = new Image(":progress_front_green_l.png"); bar_green.right = new Image(":progress_front_green_r.png"); bar_green.center = new Image(":progress_front_green_c.png"); - - state = ProgressBarState::Blue; - _progress = .5; } ProgressBar::~ProgressBar() @@ -79,22 +78,31 @@ void ProgressBar::setState(ProgressBarState state) } } -float ProgressBar::progress() +void ProgressBar::setTotal(int total) { - return _progress; + if(this->total != total) + { + this->total = total; + repaintEvent(nullptr); + } } -void ProgressBar::setProgress(float progress) +void ProgressBar::setValue(int value) { - _progress = progress; - repaintEvent(nullptr); + if(this->value != value) + { + this->value = value; + repaintEvent(nullptr); + } } void ProgressBar::repaintEvent(RepaintEvent* repaintEvent) { Painter p(*this); - int max = width() * _progress; + float progress = (float)value / (float)total; + + int max = width() * progress; p.clear(); |