summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qplastiquestyle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/styles/qplastiquestyle.cpp')
-rw-r--r--src/widgets/styles/qplastiquestyle.cpp93
1 files changed, 16 insertions, 77 deletions
diff --git a/src/widgets/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp
index d22f82ff85..449783fb90 100644
--- a/src/widgets/styles/qplastiquestyle.cpp
+++ b/src/widgets/styles/qplastiquestyle.cpp
@@ -79,7 +79,6 @@ static const int blueFrameWidth = 2; // with of line edit focus frame
#include <qsplitter.h>
#include <qstyleoption.h>
#include <qtextedit.h>
-#include <qelapsedtimer.h>
#include <qtoolbar.h>
#include <qtoolbox.h>
#include <qtoolbutton.h>
@@ -89,6 +88,7 @@ static const int blueFrameWidth = 2; // with of line edit focus frame
#include <private/qstylehelper_p.h>
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
+#include <private/qstyleanimation_p.h>
QT_BEGIN_NAMESPACE
@@ -987,12 +987,6 @@ public:
virtual ~QPlastiqueStylePrivate();
void drawPartialFrame(QPainter *painter, const QStyleOptionComplex *option,
const QRect &rect, const QWidget *widget) const;
-
-#ifndef QT_NO_PROGRESSBAR
- QList<QProgressBar *> bars;
- int progressBarAnimateTimer;
- QElapsedTimer timer;
-#endif
};
/*!
@@ -1000,9 +994,6 @@ public:
*/
QPlastiqueStylePrivate::QPlastiqueStylePrivate() :
QWindowsStylePrivate()
-#ifndef QT_NO_PROGRESSBAR
- , progressBarAnimateTimer(0)
-#endif
{
}
@@ -2405,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;
@@ -2575,11 +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 = ((d->animateStep * slideWidth) / ProgressBarFps) % slideWidth;
- if ((((d->animateStep * slideWidth) / ProgressBarFps) % (2 * slideWidth)) >= slideWidth)
- step = slideWidth - step;
+ int step = 0;
+ if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
+ step = animation->progressStep(slideWidth);
+ else
+ d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
progressBar.setRect(rect.left() + 2 + step, rect.top() + 2,
slideWidth / 2, rect.height() - 4);
}
@@ -2732,7 +2726,11 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op
if (!vertical)
progressBar.adjust(0, 1, 0, 1);
if (!indeterminate) {
- int step = (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) ? (d->animateStep % 20) : 0;
+ int step = 0;
+ if (AnimateProgressBar || (indeterminate && AnimateBusyProgressBar)) {
+ if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(widget)))
+ step = animation->animationStep() % 20;
+ }
if (reverse)
painter->drawPixmap(progressBar.left() - 25 + step, progressBar.top(), cache);
else
@@ -2744,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)) {
@@ -4957,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);
}
@@ -5648,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);
@@ -5705,14 +5696,6 @@ void QPlastiqueStyle::unpolish(QWidget *widget)
widget->setBackgroundRole(QPalette::Button);
}
-#ifndef QT_NO_PROGRESSBAR
- if (AnimateBusyProgressBar && qobject_cast<QProgressBar *>(widget)) {
- Q_D(QPlastiqueStyle);
- widget->removeEventFilter(this);
- d->bars.removeAll(static_cast<QProgressBar*>(widget));
- }
-#endif
-
#if defined QPlastique_MaskButtons
if (qobject_cast<QPushButton *>(widget) || qobject_cast<QToolButton *>(widget))
widget->removeEventFilter(this);
@@ -5829,31 +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->bars.append(bar);
- if (d->bars.size() == 1) {
- Q_ASSERT(ProgressBarFps > 0);
- d->timer.start();
- d->progressBarAnimateTimer = startTimer(1000 / ProgressBarFps);
- }
- }
- break;
- case QEvent::Destroy:
- case QEvent::Hide:
- if(!d->bars.isEmpty()) {
- d->bars.removeAll(reinterpret_cast<QProgressBar*>(watched));
- if (d->bars.isEmpty()) {
- killTimer(d->progressBarAnimateTimer);
- d->progressBarAnimateTimer = 0;
- }
- }
- 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);
@@ -5870,35 +5830,14 @@ bool QPlastiqueStyle::eventFilter(QObject *watched, QEvent *event)
widget->setMask(region);
}
break;
-#endif
default:
break;
}
-#endif // QT_NO_PROGRESSBAR
+#endif
return QWindowsStyle::eventFilter(watched, event);
}
-/*!
- \reimp
-*/
-void QPlastiqueStyle::timerEvent(QTimerEvent *event)
-{
-#ifndef QT_NO_PROGRESSBAR
- Q_D(QPlastiqueStyle);
-
- if (event->timerId() == d->progressBarAnimateTimer) {
- Q_ASSERT(ProgressBarFps > 0);
- d->animateStep = d->timer.elapsed() / (1000 / ProgressBarFps);
- foreach (QProgressBar *bar, d->bars) {
- if (AnimateProgressBar || (bar->minimum() == 0 && bar->maximum() == 0))
- bar->update();
- }
- }
-#endif // QT_NO_PROGRESSBAR
- event->ignore();
-}
-
QT_END_NAMESPACE
#endif // !defined(QT_NO_STYLE_PLASTIQUE) || defined(QT_PLUGIN)