summaryrefslogtreecommitdiff
path: root/plugingui/progressbar.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-04-16 13:33:53 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-04-16 13:33:53 +0200
commit4eb252df04ab237c8638d45bcbf028859dc6a110 (patch)
tree8bffddf62b4271336a6e0121fef8133327654000 /plugingui/progressbar.cc
parentef68248bf70a027595803b08433a7a2c74e20fd0 (diff)
parent35e804b984c28131fe13d229c5a0867762c6e8cf (diff)
Merge branch 'settings'
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..8a382f5 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(std::size_t total)
{
- return _progress;
+ if(this->total != total)
+ {
+ this->total = total;
+ repaintEvent(nullptr);
+ }
}
-void ProgressBar::setProgress(float progress)
+void ProgressBar::setValue(std::size_t 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();