Fix style animations to stop when the animation target is hidden
QStyleAnimation automatically stopped for hidden QWidgets, but didn't know anything about QQuickItems and kept animating regardless of their visibility. This change ensures that style animations stop as soon as the animation target no longer accepts the animation update eg. it has become hidden or the window was minimized. Task-number: QTBUG-35319 Change-Id: Ie48191fd918c626c0d9afe2e7d2390c495efb071 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
parent
1fc28716e6
commit
ac54abfb07
@ -7634,7 +7634,10 @@ QGraphicsObject::~QGraphicsObject()
|
||||
bool QGraphicsObject::event(QEvent *ev)
|
||||
{
|
||||
if (ev->type() == QEvent::StyleAnimationUpdate) {
|
||||
update();
|
||||
if (isVisible()) {
|
||||
ev->accept();
|
||||
update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QObject::event(ev);
|
||||
|
@ -1409,9 +1409,14 @@ bool QGraphicsWidget::event(QEvent *event)
|
||||
break;
|
||||
case QEvent::WindowActivate:
|
||||
case QEvent::WindowDeactivate:
|
||||
case QEvent::StyleAnimationUpdate:
|
||||
update();
|
||||
break;
|
||||
case QEvent::StyleAnimationUpdate:
|
||||
if (isVisible()) {
|
||||
event->accept();
|
||||
update();
|
||||
}
|
||||
break;
|
||||
// Taken from QWidget::event
|
||||
case QEvent::ActivationChange:
|
||||
case QEvent::EnabledChange:
|
||||
|
@ -8243,7 +8243,10 @@ bool QWidget::event(QEvent *event)
|
||||
update(static_cast<QUpdateLaterEvent*>(event)->region());
|
||||
break;
|
||||
case QEvent::StyleAnimationUpdate:
|
||||
update();
|
||||
if (isVisible() && !window()->isMinimized()) {
|
||||
event->accept();
|
||||
update();
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::WindowBlocked:
|
||||
|
@ -93,7 +93,10 @@ void QStyleAnimation::setStartTime(const QTime &time)
|
||||
void QStyleAnimation::updateTarget()
|
||||
{
|
||||
QEvent event(QEvent::StyleAnimationUpdate);
|
||||
event.setAccepted(false);
|
||||
QCoreApplication::sendEvent(target(), &event);
|
||||
if (!event.isAccepted())
|
||||
stop();
|
||||
}
|
||||
|
||||
bool QStyleAnimation::isUpdateNeeded() const
|
||||
@ -103,16 +106,8 @@ bool QStyleAnimation::isUpdateNeeded() const
|
||||
|
||||
void QStyleAnimation::updateCurrentTime(int)
|
||||
{
|
||||
if (QObject *tgt = target()) {
|
||||
if (tgt->isWidgetType()) {
|
||||
QWidget *widget = static_cast<QWidget *>(tgt);
|
||||
if (!widget->isVisible() || widget->window()->isMinimized())
|
||||
stop();
|
||||
}
|
||||
|
||||
if (isUpdateNeeded())
|
||||
updateTarget();
|
||||
}
|
||||
if (target() && isUpdateNeeded())
|
||||
updateTarget();
|
||||
}
|
||||
|
||||
QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) :
|
||||
|
Loading…
Reference in New Issue
Block a user