forked from qt-creator/qt-creator
Multiple fixes to the progress bars
* made them a few pixels smaller * they now animate when collapsed * they no longer fade out when an error is reported Reviewed-by: thorbjorn
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QPropertyAnimation>
|
#include <QtCore/QPropertyAnimation>
|
||||||
|
#include <QtCore/QSequentialAnimationGroup>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
@@ -77,7 +78,8 @@ void FadeWidgetHack::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.setOpacity(m_opacity);
|
p.setOpacity(m_opacity);
|
||||||
Utils::StyleHelper::verticalGradient(&p, rect(), rect());
|
if (m_opacity > 0)
|
||||||
|
Utils::StyleHelper::verticalGradient(&p, rect(), rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -237,7 +239,7 @@ void FutureProgress::setFinished()
|
|||||||
if (m_keep) {
|
if (m_keep) {
|
||||||
m_waitingForUserInteraction = true;
|
m_waitingForUserInteraction = true;
|
||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
} else {
|
} else if (!m_progress->hasError()) {
|
||||||
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,11 +305,20 @@ bool FutureProgress::hasError() const
|
|||||||
void FutureProgress::fadeAway()
|
void FutureProgress::fadeAway()
|
||||||
{
|
{
|
||||||
m_faderWidget->raise();
|
m_faderWidget->raise();
|
||||||
|
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(m_faderWidget, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(m_faderWidget, "opacity");
|
||||||
animation->setDuration(600);
|
animation->setDuration(600);
|
||||||
animation->setEndValue(1.0);
|
animation->setEndValue(1.0);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
group->addAnimation(animation);
|
||||||
connect(animation, SIGNAL(finished()), this, SIGNAL(removeMe()));
|
animation = new QPropertyAnimation(this, "maximumHeight");
|
||||||
|
animation->setDuration(120);
|
||||||
|
animation->setEasingCurve(QEasingCurve::InCurve);
|
||||||
|
animation->setStartValue(sizeHint().height());
|
||||||
|
animation->setEndValue(0.0);
|
||||||
|
group->addAnimation(animation);
|
||||||
|
group->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
|
|
||||||
|
connect(group, SIGNAL(finished()), this, SIGNAL(removeMe()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "futureprogress.moc"
|
#include "futureprogress.moc"
|
||||||
|
@@ -41,11 +41,11 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
#define PROGRESSBAR_HEIGHT 13
|
#define PROGRESSBAR_HEIGHT 12
|
||||||
#define CANCELBUTTON_SIZE 15
|
#define CANCELBUTTON_SIZE 15
|
||||||
|
|
||||||
ProgressBar::ProgressBar(QWidget *parent)
|
ProgressBar::ProgressBar(QWidget *parent)
|
||||||
: QWidget(parent), m_error(false), m_minimum(1), m_maximum(100), m_value(1), m_fader(0)
|
: QWidget(parent), m_error(false), m_minimum(1), m_maximum(100), m_value(1), m_cancelButtonFader(0)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@@ -60,7 +60,7 @@ bool ProgressBar::event(QEvent *e)
|
|||||||
switch(e->type()) {
|
switch(e->type()) {
|
||||||
case QEvent::Enter:
|
case QEvent::Enter:
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
QPropertyAnimation *animation = new QPropertyAnimation(this, "cancelButtonFader");
|
||||||
animation->setDuration(125);
|
animation->setDuration(125);
|
||||||
animation->setEndValue(1.0);
|
animation->setEndValue(1.0);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
@@ -68,7 +68,7 @@ bool ProgressBar::event(QEvent *e)
|
|||||||
break;
|
break;
|
||||||
case QEvent::Leave:
|
case QEvent::Leave:
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
QPropertyAnimation *animation = new QPropertyAnimation(this, "m_cancelButtonFader");
|
||||||
animation->setDuration(225);
|
animation->setDuration(225);
|
||||||
animation->setEndValue(0.0);
|
animation->setEndValue(0.0);
|
||||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||||
@@ -133,7 +133,7 @@ QSize ProgressBar::sizeHint() const
|
|||||||
{
|
{
|
||||||
QSize s;
|
QSize s;
|
||||||
s.setWidth(50);
|
s.setWidth(50);
|
||||||
s.setHeight(fontMetrics().height() + PROGRESSBAR_HEIGHT + 9);
|
s.setHeight(fontMetrics().height() + PROGRESSBAR_HEIGHT + 6);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
// elide the text
|
// elide the text
|
||||||
QString elidedtitle = fm.elidedText(m_title, Qt::ElideRight, textSpace);
|
QString elidedtitle = fm.elidedText(m_title, Qt::ElideRight, textSpace);
|
||||||
|
|
||||||
QRect textRect = rect().adjusted(INDENT + 1, 1, -INDENT - 1, 0);
|
QRect textRect = rect().adjusted(3, 1, -3, 0);
|
||||||
textRect.setHeight(h+5);
|
textRect.setHeight(h+5);
|
||||||
|
|
||||||
p.setPen(QColor(0, 0, 0, 120));
|
p.setPen(QColor(0, 0, 0, 120));
|
||||||
@@ -217,7 +217,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
m_progressHeight = PROGRESSBAR_HEIGHT;
|
m_progressHeight = PROGRESSBAR_HEIGHT;
|
||||||
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
|
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
|
||||||
// draw outer rect
|
// draw outer rect
|
||||||
QRect rect(INDENT - 1, h+8, size().width()-2*INDENT + 1, m_progressHeight-1);
|
QRect rect(INDENT - 1, h+6, size().width()-2*INDENT + 1, m_progressHeight-1);
|
||||||
p.setPen(Utils::StyleHelper::panelTextColor());
|
p.setPen(Utils::StyleHelper::panelTextColor());
|
||||||
Utils::StyleHelper::drawCornerImage(bar, &p, rect, 2, 2, 2, 2);
|
Utils::StyleHelper::drawCornerImage(bar, &p, rect, 2, 2, 2, 2);
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
|||||||
p.drawPoint(inner.bottomRight());
|
p.drawPoint(inner.bottomRight());
|
||||||
|
|
||||||
// Draw cancel button
|
// Draw cancel button
|
||||||
p.setOpacity(m_fader);
|
p.setOpacity(m_cancelButtonFader);
|
||||||
|
|
||||||
if (value() < maximum() && !m_error) {
|
if (value() < maximum() && !m_error) {
|
||||||
QRect cancelRect(rect.adjusted(rect.width() - CANCELBUTTON_SIZE, 1, -1, 0));
|
QRect cancelRect(rect.adjusted(rect.width() - CANCELBUTTON_SIZE, 1, -1, 0));
|
||||||
|
@@ -40,7 +40,7 @@ class ProgressBar : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
Q_PROPERTY(float cancelButtonFader READ cancelButtonFader WRITE setCancelButtonFader)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ProgressBar(QWidget *parent = 0);
|
explicit ProgressBar(QWidget *parent = 0);
|
||||||
@@ -60,8 +60,8 @@ public:
|
|||||||
void reset();
|
void reset();
|
||||||
void setRange(int minimum, int maximum);
|
void setRange(int minimum, int maximum);
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
float fader() { return m_fader; }
|
float cancelButtonFader() { return m_cancelButtonFader; }
|
||||||
void setFader(float value) { m_fader = value; update(); }
|
void setCancelButtonFader(float value) { m_cancelButtonFader= value;}
|
||||||
bool event(QEvent *);
|
bool event(QEvent *);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -79,7 +79,7 @@ private:
|
|||||||
int m_minimum;
|
int m_minimum;
|
||||||
int m_maximum;
|
int m_maximum;
|
||||||
int m_value;
|
int m_value;
|
||||||
float m_fader;
|
float m_cancelButtonFader;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -48,16 +48,16 @@ BuildProgress::BuildProgress(TaskWindow *taskWindow)
|
|||||||
m_taskWindow(taskWindow)
|
m_taskWindow(taskWindow)
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
layout->setContentsMargins(8, 4, 0, 4);
|
layout->setContentsMargins(8, 2, 0, 2);
|
||||||
layout->setSpacing(2);
|
layout->setSpacing(2);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
QHBoxLayout *errorLayout = new QHBoxLayout;
|
QHBoxLayout *errorLayout = new QHBoxLayout;
|
||||||
errorLayout->setSpacing(4);
|
errorLayout->setSpacing(2);
|
||||||
layout->addLayout(errorLayout);
|
layout->addLayout(errorLayout);
|
||||||
errorLayout->addWidget(m_errorIcon);
|
errorLayout->addWidget(m_errorIcon);
|
||||||
errorLayout->addWidget(m_errorLabel);
|
errorLayout->addWidget(m_errorLabel);
|
||||||
QHBoxLayout *warningLayout = new QHBoxLayout;
|
QHBoxLayout *warningLayout = new QHBoxLayout;
|
||||||
warningLayout->setSpacing(4);
|
warningLayout->setSpacing(2);
|
||||||
layout->addLayout(warningLayout);
|
layout->addLayout(warningLayout);
|
||||||
warningLayout->addWidget(m_warningIcon);
|
warningLayout->addWidget(m_warningIcon);
|
||||||
warningLayout->addWidget(m_warningLabel);
|
warningLayout->addWidget(m_warningLabel);
|
||||||
|
Reference in New Issue
Block a user