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);
}
}
/*! \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)
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
}
/*!
~QCommonStylePrivate()
{
-#ifndef QT_NO_ANIMATION
qDeleteAll(animations);
-#endif
#ifndef QT_NO_ITEMVIEWS
delete cachedOption;
#endif
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
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());
}
}
-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);
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)
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);
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);
}
{
//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 &&
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))
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,
}
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;
} 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);
}
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);
painter->restore();
}
break;
-#endif // QT_NO_PROGRESSBAR
+
case CE_HeaderSection:
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
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);
}
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);
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);
*/
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);
widget->setMask(region);
}
break;
-#endif
default:
break;
}
-#endif // QT_NO_PROGRESSBAR
+#endif
return QWindowsStyle::eventFilter(watched, event);
}
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_ANIMATION
-
QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(target),
_startTime(QTime::currentTime())
{
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
// We mean it.
//
-#ifndef QT_NO_ANIMATION
-
class QStyleAnimation : public QAbstractAnimation
{
Q_OBJECT
mutable int _step;
};
-#endif // QT_NO_ANIMATION
-
QT_END_NAMESPACE
#endif // QSTYLEANIMATION_P_H
#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>
}
#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
sa, SLOT(update()));
}
#endif
-#ifndef QT_NO_PROGRESSBAR
- if (QProgressBar *pb = qobject_cast<QProgressBar *>(w))
- QWindowsStyle::unpolish(pb);
-#endif
baseStyle()->unpolish(w);
}
}
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());
subRule.drawRule(p, r);
x += reverse ? -chunkWidth : chunkWidth;
}
+
+ d->stopAnimation(opt->styleObject);
}
p->restore();
#include <private/qmenubar_p.h>
#include "qpaintengine.h"
#include "qpainter.h"
-#include "qprogressbar.h"
#include "qrubberband.h"
#include "qstyleoption.h"
#include "qtabbar.h"
#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
{
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;
}
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
}
/*!
qDrawShadePanel(p, opt->rect, opt->palette, true, 1, 0);
break;
-#ifndef QT_NO_PROGRESSBAR
case PE_IndicatorProgressChunk:
{
bool vertical = false, inverted = false;
}
}
break;
-#endif // QT_NO_PROGRESSBAR
case PE_FrameTabWidget: {
qDrawWinButton(p, opt->rect, opt->palette, false, 0);
#endif // QT_NO_TOOLBAR
-#ifndef QT_NO_PROGRESSBAR
+
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
QRect rect = pb->rect;
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);
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();
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:
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;
return;
}
break;
-#ifndef QT_NO_PROGRESSBAR
+
case CE_ProgressBarContents:
if (const QStyleOptionProgressBar *bar
= qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
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,
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;
}
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;
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);
}
}
break;
-#endif // QT_NO_PROGRESSBAR
+
case CE_MenuBarItem:
{