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/QCoreApplication>
|
||||
#include <QtCore/QPropertyAnimation>
|
||||
#include <QtCore/QSequentialAnimationGroup>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
using namespace Core;
|
||||
@@ -77,7 +78,8 @@ void FadeWidgetHack::paintEvent(QPaintEvent *)
|
||||
|
||||
QPainter p(this);
|
||||
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) {
|
||||
m_waitingForUserInteraction = true;
|
||||
qApp->installEventFilter(this);
|
||||
} else {
|
||||
} else if (!m_progress->hasError()) {
|
||||
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
||||
}
|
||||
}
|
||||
@@ -303,11 +305,20 @@ bool FutureProgress::hasError() const
|
||||
void FutureProgress::fadeAway()
|
||||
{
|
||||
m_faderWidget->raise();
|
||||
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(m_faderWidget, "opacity");
|
||||
animation->setDuration(600);
|
||||
animation->setEndValue(1.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
connect(animation, SIGNAL(finished()), this, SIGNAL(removeMe()));
|
||||
group->addAnimation(animation);
|
||||
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"
|
||||
|
||||
@@ -41,11 +41,11 @@
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
#define PROGRESSBAR_HEIGHT 13
|
||||
#define PROGRESSBAR_HEIGHT 12
|
||||
#define CANCELBUTTON_SIZE 15
|
||||
|
||||
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);
|
||||
setMouseTracking(true);
|
||||
@@ -60,7 +60,7 @@ bool ProgressBar::event(QEvent *e)
|
||||
switch(e->type()) {
|
||||
case QEvent::Enter:
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "cancelButtonFader");
|
||||
animation->setDuration(125);
|
||||
animation->setEndValue(1.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
@@ -68,7 +68,7 @@ bool ProgressBar::event(QEvent *e)
|
||||
break;
|
||||
case QEvent::Leave:
|
||||
{
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
|
||||
QPropertyAnimation *animation = new QPropertyAnimation(this, "m_cancelButtonFader");
|
||||
animation->setDuration(225);
|
||||
animation->setEndValue(0.0);
|
||||
animation->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
@@ -133,7 +133,7 @@ QSize ProgressBar::sizeHint() const
|
||||
{
|
||||
QSize s;
|
||||
s.setWidth(50);
|
||||
s.setHeight(fontMetrics().height() + PROGRESSBAR_HEIGHT + 9);
|
||||
s.setHeight(fontMetrics().height() + PROGRESSBAR_HEIGHT + 6);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
||||
// elide the text
|
||||
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);
|
||||
|
||||
p.setPen(QColor(0, 0, 0, 120));
|
||||
@@ -217,7 +217,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
||||
m_progressHeight = PROGRESSBAR_HEIGHT;
|
||||
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
|
||||
// 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());
|
||||
Utils::StyleHelper::drawCornerImage(bar, &p, rect, 2, 2, 2, 2);
|
||||
|
||||
@@ -262,7 +262,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
||||
p.drawPoint(inner.bottomRight());
|
||||
|
||||
// Draw cancel button
|
||||
p.setOpacity(m_fader);
|
||||
p.setOpacity(m_cancelButtonFader);
|
||||
|
||||
if (value() < maximum() && !m_error) {
|
||||
QRect cancelRect(rect.adjusted(rect.width() - CANCELBUTTON_SIZE, 1, -1, 0));
|
||||
|
||||
@@ -40,7 +40,7 @@ class ProgressBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||
Q_PROPERTY(float cancelButtonFader READ cancelButtonFader WRITE setCancelButtonFader)
|
||||
|
||||
public:
|
||||
explicit ProgressBar(QWidget *parent = 0);
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
void reset();
|
||||
void setRange(int minimum, int maximum);
|
||||
void setValue(int value);
|
||||
float fader() { return m_fader; }
|
||||
void setFader(float value) { m_fader = value; update(); }
|
||||
float cancelButtonFader() { return m_cancelButtonFader; }
|
||||
void setCancelButtonFader(float value) { m_cancelButtonFader= value;}
|
||||
bool event(QEvent *);
|
||||
|
||||
signals:
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
int m_minimum;
|
||||
int m_maximum;
|
||||
int m_value;
|
||||
float m_fader;
|
||||
float m_cancelButtonFader;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -48,16 +48,16 @@ BuildProgress::BuildProgress(TaskWindow *taskWindow)
|
||||
m_taskWindow(taskWindow)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(8, 4, 0, 4);
|
||||
layout->setContentsMargins(8, 2, 0, 2);
|
||||
layout->setSpacing(2);
|
||||
setLayout(layout);
|
||||
QHBoxLayout *errorLayout = new QHBoxLayout;
|
||||
errorLayout->setSpacing(4);
|
||||
errorLayout->setSpacing(2);
|
||||
layout->addLayout(errorLayout);
|
||||
errorLayout->addWidget(m_errorIcon);
|
||||
errorLayout->addWidget(m_errorLabel);
|
||||
QHBoxLayout *warningLayout = new QHBoxLayout;
|
||||
warningLayout->setSpacing(4);
|
||||
warningLayout->setSpacing(2);
|
||||
layout->addLayout(warningLayout);
|
||||
warningLayout->addWidget(m_warningIcon);
|
||||
warningLayout->addWidget(m_warningLabel);
|
||||
|
||||
Reference in New Issue
Block a user