summaryrefslogtreecommitdiff
path: root/plugingui/progressbar.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-04-08 00:15:32 +0200
commit057ef1d83ba263fb2adf1aa86f8e281ab0065c43 (patch)
tree31c1f237e3a9df9fc241d87527f7dd4245665d43 /plugingui/progressbar.cc
parentb530ac02af61e320e137a392decef1b3cc5af2c4 (diff)
Refactoring to finally get rid of MessageHandler/Receiver in favor of the new Settings mechanism.
Diffstat (limited to 'plugingui/progressbar.cc')
-rw-r--r--plugingui/progressbar.cc26
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();