tst_Q*AnimationGroup: use QBasicTimer instead of handling raw timer ids
Change-Id: I1392a62e358e8367c24f3db839d53fc0b072483a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7595c21be8
commit
52fd8c716e
@ -8,9 +8,12 @@
|
||||
#include <QSignalSpy>
|
||||
|
||||
#include <QtCore/qanimationgroup.h>
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtCore/qsequentialanimationgroup.h>
|
||||
#include <QtCore/qparallelanimationgroup.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Q_DECLARE_METATYPE(QAbstractAnimation::State)
|
||||
|
||||
class tst_QAnimationGroup : public QObject
|
||||
@ -72,7 +75,7 @@ class UncontrolledAnimation : public QPropertyAnimation
|
||||
Q_OBJECT
|
||||
public:
|
||||
UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr)
|
||||
: QPropertyAnimation(target, propertyName, parent), id(0)
|
||||
: QPropertyAnimation(target, propertyName, parent)
|
||||
{
|
||||
setDuration(250);
|
||||
}
|
||||
@ -82,22 +85,21 @@ public:
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override
|
||||
{
|
||||
if (event->timerId() == id)
|
||||
if (event->id() == timer.id())
|
||||
stop();
|
||||
}
|
||||
|
||||
void updateRunning(bool running)
|
||||
{
|
||||
if (running) {
|
||||
id = startTimer(500);
|
||||
timer.start(500ms, this);
|
||||
} else {
|
||||
killTimer(id);
|
||||
id = 0;
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QBasicTimer timer;
|
||||
};
|
||||
|
||||
void tst_QAnimationGroup::emptyGroup()
|
||||
|
@ -6,9 +6,12 @@
|
||||
#include <QPropertyAnimation>
|
||||
#include <QSignalSpy>
|
||||
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtCore/qparallelanimationgroup.h>
|
||||
#include <QtCore/qscopeguard.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
Q_DECLARE_METATYPE(QAbstractAnimation::State)
|
||||
|
||||
class tst_QParallelAnimationGroup : public QObject
|
||||
@ -107,7 +110,7 @@ class UncontrolledAnimation : public QPropertyAnimation
|
||||
Q_OBJECT
|
||||
public:
|
||||
UncontrolledAnimation(QObject *target, const QByteArray &propertyName, QObject *parent = nullptr)
|
||||
: QPropertyAnimation(target, propertyName, parent), id(0)
|
||||
: QPropertyAnimation(target, propertyName, parent)
|
||||
{
|
||||
setDuration(250);
|
||||
setEndValue(0);
|
||||
@ -118,22 +121,21 @@ public:
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override
|
||||
{
|
||||
if (event->timerId() == id)
|
||||
if (event->id() == timer.id())
|
||||
stop();
|
||||
}
|
||||
|
||||
void updateRunning(bool running)
|
||||
{
|
||||
if (running) {
|
||||
id = startTimer(500);
|
||||
timer.start(500ms, this);
|
||||
} else {
|
||||
killTimer(id);
|
||||
id = 0;
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int id;
|
||||
QBasicTimer timer;
|
||||
};
|
||||
|
||||
void tst_QParallelAnimationGroup::setCurrentTime()
|
||||
|
Loading…
x
Reference in New Issue
Block a user