Styles: revise indeterminate progress bar animations
Remove dependencies to QProgressBar where possible. This makes it possible to animate for example QQuickItem based progress bars (read: the desktop components). Change-Id: If208506702365895576238c24191b8d70b90841c Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>bb10
parent
037d1e18e3
commit
a98b943557
|
|
@ -1751,20 +1751,21 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
|
|||
reverse = !reverse;
|
||||
|
||||
QRect progressBar;
|
||||
Q_D(const QCleanlooksStyle);
|
||||
if (!indeterminate) {
|
||||
if (!reverse) {
|
||||
progressBar.setRect(rect.left() + 1, rect.top() + 1, width + 1, rect.height() - 3);
|
||||
} else {
|
||||
progressBar.setRect(rect.right() - 1 - width, rect.top() + 1, width + 1, rect.height() - 3);
|
||||
}
|
||||
d->stopAnimation(option->styleObject);
|
||||
} else {
|
||||
Q_D(const QCleanlooksStyle);
|
||||
int slideWidth = ((rect.width() - 4) * 2) / 3;
|
||||
int step = 0;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
|
||||
step = animation->progressStep(slideWidth);
|
||||
#endif
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
|
||||
progressBar.setRect(rect.left() + 1 + step, rect.top() + 1,
|
||||
slideWidth / 2, rect.height() - 3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1062,22 +1062,19 @@ QStyleAnimation * QCommonStylePrivate::animation(const QObject *target) const
|
|||
}
|
||||
|
||||
/*! \internal */
|
||||
void QCommonStylePrivate::startAnimation(QStyleAnimation *animation)
|
||||
void QCommonStylePrivate::startAnimation(QStyleAnimation *animation) const
|
||||
{
|
||||
#ifndef QT_NO_ANIMATION
|
||||
Q_Q(QCommonStyle);
|
||||
Q_Q(const QCommonStyle);
|
||||
stopAnimation(animation->target());
|
||||
q->connect(animation, SIGNAL(finished()), SLOT(_q_removeAnimation()), Qt::UniqueConnection);
|
||||
q->connect(animation, SIGNAL(destroyed()), SLOT(_q_removeAnimation()), Qt::UniqueConnection);
|
||||
animations.insert(animation->target(), animation);
|
||||
animation->start();
|
||||
#endif // QT_NO_ANIMATION
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
void QCommonStylePrivate::stopAnimation(const QObject *target)
|
||||
void QCommonStylePrivate::stopAnimation(const QObject *target) const
|
||||
{
|
||||
#ifndef QT_NO_ANIMATION
|
||||
QStyleAnimation *animation = animations.value(target);
|
||||
if (animation) {
|
||||
if (animation->state() == QAbstractAnimation::Stopped)
|
||||
|
|
@ -1085,20 +1082,17 @@ void QCommonStylePrivate::stopAnimation(const QObject *target)
|
|||
else
|
||||
animation->stop();
|
||||
}
|
||||
#endif // QT_NO_ANIMATION
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
void QCommonStylePrivate::_q_removeAnimation()
|
||||
{
|
||||
#ifndef QT_NO_ANIMATION
|
||||
Q_Q(QCommonStyle);
|
||||
QObject *animation = q->sender();
|
||||
if (animation) {
|
||||
animations.remove(animation->parent());
|
||||
animation->deleteLater();
|
||||
}
|
||||
#endif // QT_NO_ANIMATION
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ public:
|
|||
|
||||
~QCommonStylePrivate()
|
||||
{
|
||||
#ifndef QT_NO_ANIMATION
|
||||
qDeleteAll(animations);
|
||||
#endif
|
||||
#ifndef QT_NO_ITEMVIEWS
|
||||
delete cachedOption;
|
||||
#endif
|
||||
|
|
@ -120,11 +118,11 @@ public:
|
|||
|
||||
QList<const QObject*> animationTargets() const;
|
||||
QStyleAnimation* animation(const QObject *target) const;
|
||||
void startAnimation(QStyleAnimation *animation);
|
||||
void stopAnimation(const QObject *target);
|
||||
void startAnimation(QStyleAnimation *animation) const;
|
||||
void stopAnimation(const QObject *target) const;
|
||||
|
||||
private:
|
||||
QHash<const QObject*, QStyleAnimation*> animations;
|
||||
mutable QHash<const QObject*, QStyleAnimation*> animations;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -3488,15 +3488,15 @@ void QGtkStyle::drawControl(ControlElement element,
|
|||
progressBar.setRect(rect.left(), rect.top(), width, rect.height());
|
||||
else
|
||||
progressBar.setRect(rect.right() - width, rect.top(), width, rect.height());
|
||||
|
||||
d->stopAnimation(option->styleObject);
|
||||
} else {
|
||||
Q_D(const QGtkStyle);
|
||||
int slideWidth = ((rect.width() - 4) * 2) / 3;
|
||||
int step = 0;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
|
||||
step = animation->progressStep(slideWidth);
|
||||
#endif
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
|
||||
progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1683,15 +1683,15 @@ QMacStylePrivate::QMacStylePrivate()
|
|||
|
||||
}
|
||||
|
||||
bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget *w) const
|
||||
bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QObject *obj) const
|
||||
{
|
||||
if (!w)
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
if (as == AquaPushButton) {
|
||||
QPushButton *pb = const_cast<QPushButton *>(static_cast<const QPushButton *>(w));
|
||||
if (w->window()->isActiveWindow() && pb && !mouseDown) {
|
||||
if (static_cast<const QPushButton *>(w) != defaultButton) {
|
||||
QPushButton *pb = const_cast<QPushButton *>(qobject_cast<const QPushButton *>(obj));
|
||||
if (pb && pb->window()->isActiveWindow() && !mouseDown) {
|
||||
if (pb != defaultButton) {
|
||||
// Changed on its own, update the value.
|
||||
const_cast<QMacStylePrivate *>(this)->stopAnimate(as, defaultButton);
|
||||
const_cast<QMacStylePrivate *>(this)->startAnimate(as, pb);
|
||||
|
|
@ -1699,35 +1699,28 @@ bool QMacStylePrivate::animatable(QMacStylePrivate::Animates as, const QWidget *
|
|||
return true;
|
||||
}
|
||||
}
|
||||
return animation(w);
|
||||
return animation(obj);
|
||||
}
|
||||
|
||||
void QMacStylePrivate::stopAnimate(QMacStylePrivate::Animates as, QWidget *w)
|
||||
void QMacStylePrivate::stopAnimate(QMacStylePrivate::Animates as, QObject *obj)
|
||||
{
|
||||
stopAnimation(w);
|
||||
stopAnimation(obj);
|
||||
if (as == AquaPushButton && defaultButton) {
|
||||
stopAnimation(defaultButton);
|
||||
QPushButton *tmp = defaultButton;
|
||||
defaultButton = 0;
|
||||
tmp->update();
|
||||
} else if (as == AquaScrollBar) {
|
||||
scrollBarInfos.remove(w);
|
||||
scrollBarInfos.remove(qobject_cast<QWidget*>(obj));
|
||||
}
|
||||
}
|
||||
|
||||
void QMacStylePrivate::startAnimate(QMacStylePrivate::Animates as, QWidget *w)
|
||||
void QMacStylePrivate::startAnimate(QMacStylePrivate::Animates as, QObject *obj)
|
||||
{
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (!animation(w))
|
||||
{
|
||||
if (as == AquaProgressBar)
|
||||
startAnimation(new QProgressStyleAnimation(animateSpeed(as), w));
|
||||
else
|
||||
startAnimation(new QStyleAnimation(w));
|
||||
}
|
||||
#endif
|
||||
if (!animation(obj))
|
||||
startAnimation(new QStyleAnimation(obj));
|
||||
if (as == AquaPushButton)
|
||||
defaultButton = static_cast<QPushButton *>(w);
|
||||
defaultButton = qobject_cast<QPushButton *>(obj);
|
||||
}
|
||||
|
||||
bool QMacStylePrivate::addWidget(QWidget *w)
|
||||
|
|
@ -1743,12 +1736,6 @@ bool QMacStylePrivate::addWidget(QWidget *w)
|
|||
startAnimate(AquaPushButton, btn);
|
||||
return true;
|
||||
} else {
|
||||
bool isProgressBar = (qobject_cast<QProgressBar *>(w));
|
||||
if (isProgressBar) {
|
||||
w->installEventFilter(q);
|
||||
startAnimate(AquaProgressBar, w);
|
||||
return true;
|
||||
}
|
||||
bool isScrollBar = (qobject_cast<QScrollBar *>(w));
|
||||
if (isScrollBar) {
|
||||
w->installEventFilter(q);
|
||||
|
|
@ -1768,8 +1755,6 @@ void QMacStylePrivate::removeWidget(QWidget *w)
|
|||
QPushButton *btn = qobject_cast<QPushButton *>(w);
|
||||
if (btn && btn == defaultButton) {
|
||||
stopAnimate(AquaPushButton, btn);
|
||||
} else if (qobject_cast<QProgressBar *>(w)) {
|
||||
stopAnimate(AquaProgressBar, w);
|
||||
} else if (qobject_cast<QScrollBar *>(w)) {
|
||||
stopAnimate(AquaScrollBar, w);
|
||||
}
|
||||
|
|
@ -1797,19 +1782,8 @@ bool QMacStyle::eventFilter(QObject *o, QEvent *e)
|
|||
{
|
||||
//animate
|
||||
Q_D(QMacStyle);
|
||||
if (QProgressBar *pb = qobject_cast<QProgressBar *>(o)) {
|
||||
switch (e->type()) {
|
||||
default:
|
||||
break;
|
||||
case QEvent::Show:
|
||||
d->startAnimate(QMacStylePrivate::AquaProgressBar, pb);
|
||||
break;
|
||||
case QEvent::Destroy:
|
||||
case QEvent::Hide:
|
||||
d->stopAnimate(QMacStylePrivate::AquaProgressBar, pb);
|
||||
}
|
||||
if (QScrollBar *sb = qobject_cast<QScrollBar *>(o)) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
} else if (QScrollBar *sb = qobject_cast<QScrollBar *>(o)) {
|
||||
// take care of fading out overlaying scrollbars (and only those!) when inactive
|
||||
const QAbstractScrollArea *scrollArea = scrollBarsScrollArea(sb);
|
||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 &&
|
||||
|
|
@ -4377,10 +4351,14 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||
tdi.min = pb->minimum;
|
||||
tdi.value = pb->progress;
|
||||
tdi.attributes = vertical ? 0 : kThemeTrackHorizontal;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(w)))
|
||||
tdi.trackInfo.progress.phase = animation->animationStep();
|
||||
#endif
|
||||
if (isIndeterminate) {
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
|
||||
tdi.trackInfo.progress.phase = animation->animationStep();
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animateSpeed(QMacStylePrivate::AquaProgressBar), opt->styleObject));
|
||||
} else {
|
||||
d->stopAnimation(opt->styleObject);
|
||||
}
|
||||
if (!(pb->state & State_Active))
|
||||
tdi.enableState = kThemeTrackInactive;
|
||||
else if (!(pb->state & State_Enabled))
|
||||
|
|
|
|||
|
|
@ -163,9 +163,9 @@ public:
|
|||
void removeWidget(QWidget *);
|
||||
|
||||
enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar };
|
||||
bool animatable(Animates, const QWidget *) const;
|
||||
void stopAnimate(Animates, QWidget *);
|
||||
void startAnimate(Animates, QWidget *);
|
||||
bool animatable(Animates, const QObject *) const;
|
||||
void stopAnimate(Animates, QObject *);
|
||||
void startAnimate(Animates, QObject *);
|
||||
static ThemeDrawState getDrawState(QStyle::State flags);
|
||||
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
|
||||
QStyle::ContentsType ct = QStyle::CT_CustomBase,
|
||||
|
|
|
|||
|
|
@ -2396,7 +2396,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||
}
|
||||
break;
|
||||
#endif // QT_NO_TABBAR
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
|
||||
case CE_ProgressBarGroove:
|
||||
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
QRect rect = bar->rect;
|
||||
|
|
@ -2566,13 +2566,14 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||
} else {
|
||||
progressBar.setRect(rect.right() - 1 - width, rect.top() + 2, width, rect.height() - 4);
|
||||
}
|
||||
d->stopAnimation(option->styleObject);
|
||||
} else {
|
||||
int slideWidth = ((rect.width() - 4) * 2) / 3;
|
||||
int step = 0;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
|
||||
step = animation->progressStep(slideWidth);
|
||||
#endif
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
|
||||
progressBar.setRect(rect.left() + 2 + step, rect.top() + 2,
|
||||
slideWidth / 2, rect.height() - 4);
|
||||
}
|
||||
|
|
@ -2727,10 +2728,8 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||
if (!indeterminate) {
|
||||
int step = 0;
|
||||
if (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) {
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
|
||||
step = animation->animationStep() % 20;
|
||||
#endif
|
||||
}
|
||||
if (reverse)
|
||||
painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache);
|
||||
|
|
@ -2743,7 +2742,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
|
|||
painter->restore();
|
||||
}
|
||||
break;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
|
||||
case CE_HeaderSection:
|
||||
// Draws the header in tables.
|
||||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
||||
|
|
@ -4956,12 +4955,10 @@ QRect QPlastiqueStyle::subElementRect(SubElement element, const QStyleOption *op
|
|||
rect = visualRect(option->direction, option->rect,
|
||||
QWindowsStyle::subElementRect(element, option, widget)).adjusted(0, 0, 1, 1);
|
||||
break;
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
case SE_ProgressBarLabel:
|
||||
case SE_ProgressBarContents:
|
||||
case SE_ProgressBarGroove:
|
||||
return option->rect;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
default:
|
||||
return QWindowsStyle::subElementRect(element, option, widget);
|
||||
}
|
||||
|
|
@ -5647,11 +5644,6 @@ void QPlastiqueStyle::polish(QWidget *widget)
|
|||
widget->setBackgroundRole(QPalette::Window);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget))
|
||||
widget->installEventFilter(this);
|
||||
#endif
|
||||
|
||||
#if defined QPlastique_MaskButtons
|
||||
if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget))
|
||||
widget->installEventFilter(this);
|
||||
|
|
@ -5704,11 +5696,6 @@ void QPlastiqueStyle::unpolish(QWidget *widget)
|
|||
widget->setBackgroundRole(QPalette::Button);
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget))
|
||||
widget->removeEventFilter(this);
|
||||
#endif
|
||||
|
||||
#if defined QPlastique_MaskButtons
|
||||
if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget))
|
||||
widget->removeEventFilter(this);
|
||||
|
|
@ -5825,20 +5812,8 @@ int QPlastiqueStyle::layoutSpacing(QSizePolicy::ControlType control1,
|
|||
*/
|
||||
bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
Q_D(QPlastiqueStyle);
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::Show:
|
||||
if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched))
|
||||
d->startProgressAnimation(this, bar);
|
||||
break;
|
||||
case QEvent::Destroy:
|
||||
case QEvent::Hide:
|
||||
if (QProgressBar *bar = qobject_cast<QProgressBar *>(watched))
|
||||
d->stopProgressAnimation(this, bar);
|
||||
break;
|
||||
#if defined QPlastique_MaskButtons
|
||||
switch (event->type()) {
|
||||
case QEvent::Resize:
|
||||
if (qobject_cast<QPushButton *>(watched) || qobject_cast<QToolButton *>(watched)) {
|
||||
QWidget *widget = qobject_cast<QWidget *>(watched);
|
||||
|
|
@ -5855,11 +5830,10 @@ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event)
|
|||
widget->setMask(region);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
#endif
|
||||
|
||||
return QWindowsStyle::eventFilter(watched, event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
|
||||
QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target),
|
||||
_startTime(QTime::currentTime())
|
||||
{
|
||||
|
|
@ -128,21 +126,13 @@ void QProgressStyleAnimation::setSpeed(int speed)
|
|||
|
||||
bool QProgressStyleAnimation::isUpdateNeeded() const
|
||||
{
|
||||
QProgressBar *pb = qobject_cast<QProgressBar*>(parent());
|
||||
if (pb && pb->minimum() == 0 && pb->maximum() == 0) {
|
||||
int current = animationStep();
|
||||
if (_step == -1 || _step != current)
|
||||
{
|
||||
_step = current;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// the progress bar is no longer indeterminate -> stop
|
||||
const_cast<QProgressStyleAnimation *>(this)->stop();
|
||||
int current = animationStep();
|
||||
if (_step == -1 || _step != current)
|
||||
{
|
||||
_step = current;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // QT_NO_ANIMATION
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#ifndef QT_NO_ANIMATION
|
||||
|
||||
class QStyleAnimation : public QAbstractAnimation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -103,8 +101,6 @@ private:
|
|||
mutable int _step;
|
||||
};
|
||||
|
||||
#endif // QT_NO_ANIMATION
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QSTYLEANIMATION_P_H
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@
|
|||
#include <qcheckbox.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qheaderview.h>
|
||||
#include <qprogressbar.h>
|
||||
#include <private/qwindowsstyle_p.h>
|
||||
#include <private/qstyleanimation_p.h>
|
||||
#include <qtabbar.h>
|
||||
|
|
@ -2726,12 +2725,6 @@ void QStyleSheetStyle::polish(QWidget *w)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (QProgressBar *pb = qobject_cast<QProgressBar *>(w)) {
|
||||
QWindowsStyle::polish(pb);
|
||||
}
|
||||
#endif
|
||||
|
||||
QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any);
|
||||
if (rule.hasDrawable() || rule.hasBox()) {
|
||||
if (w->metaObject() == &QWidget::staticMetaObject
|
||||
|
|
@ -2825,10 +2818,6 @@ void QStyleSheetStyle::unpolish(QWidget *w)
|
|||
QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
||||
sa, SLOT(update()));
|
||||
}
|
||||
#endif
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (QProgressBar *pb = qobject_cast<QProgressBar *>(w))
|
||||
QWindowsStyle::unpolish(pb);
|
||||
#endif
|
||||
baseStyle()->unpolish(w);
|
||||
}
|
||||
|
|
@ -3830,14 +3819,14 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
|||
}
|
||||
|
||||
QRect r = rect;
|
||||
Q_D(const QWindowsStyle);
|
||||
if (pb->minimum == 0 && pb->maximum == 0) {
|
||||
Q_D(const QWindowsStyle);
|
||||
int chunkCount = fillWidth/chunkWidth;
|
||||
int offset = 0;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(w)))
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
|
||||
offset = animation->animationStep() * 8 % rect.width();
|
||||
#endif
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject));
|
||||
int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
|
||||
while (chunkCount > 0) {
|
||||
r.setRect(x, rect.y(), chunkWidth, rect.height());
|
||||
|
|
@ -3868,6 +3857,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
|||
subRule.drawRule(p, r);
|
||||
x += reverse ? -chunkWidth : chunkWidth;
|
||||
}
|
||||
|
||||
d->stopAnimation(opt->styleObject);
|
||||
}
|
||||
|
||||
p->restore();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
#include <private/qmenubar_p.h>
|
||||
#include "qpaintengine.h"
|
||||
#include "qpainter.h"
|
||||
#include "qprogressbar.h"
|
||||
#include "qrubberband.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qtabbar.h"
|
||||
|
|
@ -131,21 +130,6 @@ QWindowsStylePrivate::QWindowsStylePrivate()
|
|||
#endif
|
||||
}
|
||||
|
||||
void QWindowsStylePrivate::startProgressAnimation(QObject *o, QProgressBar *bar)
|
||||
{
|
||||
Q_UNUSED(o);
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (!animation(bar))
|
||||
startAnimation(new QProgressStyleAnimation(animationFps, bar));
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWindowsStylePrivate::stopProgressAnimation(QObject *o, QProgressBar *bar)
|
||||
{
|
||||
Q_UNUSED(o);
|
||||
stopAnimation(bar);
|
||||
}
|
||||
|
||||
// Returns true if the toplevel parent of \a widget has seen the Alt-key
|
||||
bool QWindowsStylePrivate::hasSeenAlt(const QWidget *widget) const
|
||||
{
|
||||
|
|
@ -204,27 +188,6 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
|
|||
d->seenAlt.removeAll(widget);
|
||||
d->seenAlt.removeAll(widget->window());
|
||||
break;
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
case QEvent::StyleChange:
|
||||
case QEvent::Paint:
|
||||
case QEvent::Show:
|
||||
if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
|
||||
// Animation by timer for progress bars that have their min and
|
||||
// max values the same
|
||||
if (bar->minimum() == bar->maximum())
|
||||
d->startProgressAnimation(this, bar);
|
||||
else
|
||||
d->stopProgressAnimation(this, bar);
|
||||
}
|
||||
break;
|
||||
case QEvent::Destroy:
|
||||
case QEvent::Hide:
|
||||
// Do static_cast because there is no type info when getting
|
||||
// the destroy event. We know that it is a QProgressBar, since
|
||||
// we only install a widget event filter for QScrollBars.
|
||||
d->stopProgressAnimation(this, static_cast<QProgressBar *>(o));
|
||||
break;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -315,23 +278,12 @@ void QWindowsStyle::unpolish(QApplication *app)
|
|||
void QWindowsStyle::polish(QWidget *widget)
|
||||
{
|
||||
QCommonStyle::polish(widget);
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (qobject_cast<QProgressBar *>(widget))
|
||||
widget->installEventFilter(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
void QWindowsStyle::unpolish(QWidget *widget)
|
||||
{
|
||||
QCommonStyle::unpolish(widget);
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
if (QProgressBar *bar=qobject_cast<QProgressBar *>(widget)) {
|
||||
Q_D(QWindowsStyle);
|
||||
widget->removeEventFilter(this);
|
||||
d->stopProgressAnimation(this, bar);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -1582,7 +1534,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
|
||||
break;
|
||||
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
case PE_IndicatorProgressChunk:
|
||||
{
|
||||
bool vertical = false, inverted = false;
|
||||
|
|
@ -1616,7 +1567,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
|
||||
case PE_FrameTabWidget: {
|
||||
qDrawWinButton(p, opt->rect, opt->palette, false, 0);
|
||||
|
|
@ -2232,7 +2182,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||
|
||||
|
||||
#endif // QT_NO_TOOLBAR
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
|
||||
case CE_ProgressBarContents:
|
||||
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
|
||||
QRect rect = pb->rect;
|
||||
|
|
@ -2263,8 +2213,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||
if (inverted)
|
||||
reverse = !reverse;
|
||||
int w = rect.width();
|
||||
Q_D(const QWindowsStyle);
|
||||
if (pb->minimum == 0 && pb->maximum == 0) {
|
||||
Q_D(const QWindowsStyle);
|
||||
const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget);
|
||||
QStyleOptionProgressBarV2 pbBits = *pb;
|
||||
Q_ASSERT(unit_width >0);
|
||||
|
|
@ -2274,10 +2224,10 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||
|
||||
int step = 0;
|
||||
int chunkCount = w / unit_width + 1;
|
||||
#ifndef QT_NO_ANIMATION
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
|
||||
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
|
||||
step = (animation->animationStep() / 3) % chunkCount;
|
||||
#endif
|
||||
else
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject));
|
||||
int chunksInRow = 5;
|
||||
int myY = pbBits.rect.y();
|
||||
int myHeight = pbBits.rect.height();
|
||||
|
|
@ -2311,11 +2261,11 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||
p->restore(); //restore state
|
||||
}
|
||||
else {
|
||||
d->stopAnimation(opt->styleObject);
|
||||
QCommonStyle::drawControl(ce, opt, p, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
|
||||
#ifndef QT_NO_DOCKWIDGET
|
||||
case CE_DockWidgetTitle:
|
||||
|
|
|
|||
|
|
@ -63,15 +63,12 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTime;
|
||||
class QProgressBar;
|
||||
|
||||
class QWindowsStylePrivate : public QCommonStylePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QWindowsStyle)
|
||||
public:
|
||||
QWindowsStylePrivate();
|
||||
void startProgressAnimation(QObject *o, QProgressBar *bar);
|
||||
void stopProgressAnimation(QObject *o, QProgressBar *bar);
|
||||
bool hasSeenAlt(const QWidget *widget) const;
|
||||
bool altDown() const { return alt_down; }
|
||||
bool alt_down;
|
||||
|
|
|
|||
|
|
@ -1089,7 +1089,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
return;
|
||||
}
|
||||
break;
|
||||
#ifndef QT_NO_PROGRESSBAR
|
||||
|
||||
case CE_ProgressBarContents:
|
||||
if (const QStyleOptionProgressBar *bar
|
||||
= qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
|
||||
|
|
@ -1101,11 +1101,11 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
inverted = pb2->invertedAppearance;
|
||||
}
|
||||
|
||||
if (const QProgressBar *progressbar = qobject_cast<const QProgressBar *>(widget)) {
|
||||
if (isIndeterminate || (progressbar->value() > 0 && (progressbar->value() < progressbar->maximum()) && d->transitionsEnabled()))
|
||||
d->startProgressAnimation(0, const_cast<QProgressBar *>(progressbar));
|
||||
else
|
||||
d->stopAnimation(progressbar);
|
||||
if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) && d->transitionsEnabled())) {
|
||||
if (!d->animation(option->styleObject))
|
||||
d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
|
||||
} else {
|
||||
d->stopAnimation(option->styleObject);
|
||||
}
|
||||
|
||||
XPThemeData theme(widget, painter,
|
||||
|
|
@ -1116,7 +1116,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
QTime current = QTime::currentTime();
|
||||
|
||||
if (isIndeterminate) {
|
||||
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(widget))) {
|
||||
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(option->styleObject))) {
|
||||
int glowSize = 120;
|
||||
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
|
||||
int animOffset = a->startTime().msecsTo(current) / 4;
|
||||
|
|
@ -1186,7 +1186,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
}
|
||||
d->drawBackground(theme);
|
||||
|
||||
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(widget))) {
|
||||
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(option->styleObject))) {
|
||||
int glowSize = 140;
|
||||
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
|
||||
int animOffset = a->startTime().msecsTo(current) / 4;
|
||||
|
|
@ -1195,8 +1195,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
if (bar->progress < bar->maximum)
|
||||
a->setStartTime(QTime::currentTime());
|
||||
else
|
||||
d->stopAnimation(widget); //we stop the glow motion only after it has
|
||||
//moved out of view
|
||||
d->stopAnimation(option->styleObject); //we stop the glow motion only after it has
|
||||
//moved out of view
|
||||
}
|
||||
painter->save();
|
||||
painter->setClipRect(theme.rect);
|
||||
|
|
@ -1215,7 +1215,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif // QT_NO_PROGRESSBAR
|
||||
|
||||
case CE_MenuBarItem:
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue