Commit beadef9a authored by dt's avatar dt
Browse files

ProgessBar: Distangle finished from progress

That is allow progress to be at 100% and yet unfinished.

Task-Nr: QTCREATORBUG-4858
parent d72bddc7
......@@ -243,11 +243,7 @@ void FutureProgress::setFinished()
{
updateToolTip(d->m_watcher.future().progressText());
// Special case for concurrent jobs that don't use QFutureInterface to report progress
if (d->m_watcher.progressMinimum() == 0 && d->m_watcher.progressMaximum() == 0) {
d->m_progress->setRange(0, 1);
d->m_progress->setValue(1);
}
d->m_progress->setFinished(true);
if (d->m_watcher.future().isCanceled()) {
d->m_progress->setError(true);
......
......@@ -48,7 +48,7 @@ using namespace Core::Internal;
#define CANCELBUTTON_SIZE 15
ProgressBar::ProgressBar(QWidget *parent)
: QWidget(parent), m_error(false), m_minimum(1), m_maximum(100), m_value(1), m_cancelButtonFader(0)
: QWidget(parent), m_error(false), m_minimum(1), m_maximum(100), m_value(1), m_cancelButtonFader(0), m_finished(false)
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
setMouseTracking(true);
......@@ -110,6 +110,14 @@ void ProgressBar::setValue(int value)
update();
}
void ProgressBar::setFinished(bool b)
{
if (b == m_finished)
return;
m_finished = b;
update();
}
QString ProgressBar::title() const
{
return m_title;
......@@ -183,6 +191,9 @@ void ProgressBar::paintEvent(QPaintEvent *)
else if (percent < 0)
percent = 0;
if (finished())
percent = 1;
QPainter p(this);
QFont boldFont(p.font());
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
......@@ -238,7 +249,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
// avoid too small red bar
if (inner.width() < 10)
inner.adjust(0, 0, 10 - inner.width(), 0);
} else if (value() == maximum() && range != 0) {
} else if (m_finished) {
c = QColor(90, 170, 60);
}
......
......@@ -60,9 +60,11 @@ public:
int minimum() const { return m_minimum; }
int maximum() const { return m_maximum; }
int value() const { return m_value; }
bool finished() const { return m_finished; }
void reset();
void setRange(int minimum, int maximum);
void setValue(int value);
void setFinished(bool b);
float cancelButtonFader() { return m_cancelButtonFader; }
void setCancelButtonFader(float value) { update(); m_cancelButtonFader= value;}
bool event(QEvent *);
......@@ -83,6 +85,7 @@ private:
int m_maximum;
int m_value;
float m_cancelButtonFader;
bool m_finished;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment