make sure all animations have a parent
This commit is contained in:
parent
f92c66cc0e
commit
7ffad28819
|
@ -7,6 +7,7 @@
|
|||
|
||||
SnackbarPrivate::SnackbarPrivate(Snackbar *q)
|
||||
: q_ptr(q),
|
||||
machine(0),
|
||||
duration(3000),
|
||||
boxWidth(300)
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ SnackbarStateMachine::SnackbarStateMachine(Snackbar *parent)
|
|||
snackbar(parent),
|
||||
_offset(0)
|
||||
{
|
||||
timer.setSingleShot(true);
|
||||
_timer.setSingleShot(true);
|
||||
|
||||
QState *hiddenState = new QState;
|
||||
QState *visibleState = new QState;
|
||||
|
@ -50,7 +50,7 @@ SnackbarStateMachine::SnackbarStateMachine(Snackbar *parent)
|
|||
|
||||
QPropertyAnimation *animation;
|
||||
|
||||
animation = new QPropertyAnimation(this, "offset");
|
||||
animation = new QPropertyAnimation(this, "offset", this);
|
||||
animation->setEasingCurve(QEasingCurve::OutCubic);
|
||||
animation->setDuration(400);
|
||||
addDefaultAnimation(animation);
|
||||
|
@ -59,8 +59,8 @@ SnackbarStateMachine::SnackbarStateMachine(Snackbar *parent)
|
|||
visibleState->assignProperty(this, "offset", 0);
|
||||
finalState->assignProperty(this, "offset", 1);
|
||||
|
||||
connect(&timer, SIGNAL(timeout()), this, SIGNAL(hideSnackbar()));
|
||||
connect(this, SIGNAL(hideSnackbar()), &timer, SLOT(stop()));
|
||||
connect(&_timer, SIGNAL(timeout()), this, SIGNAL(hideSnackbar()));
|
||||
connect(this, SIGNAL(hideSnackbar()), &_timer, SLOT(stop()));
|
||||
}
|
||||
|
||||
SnackbarStateMachine::~SnackbarStateMachine()
|
||||
|
@ -85,5 +85,5 @@ void SnackbarStateMachine::snackbarHidden()
|
|||
|
||||
void SnackbarStateMachine::snackbarShown()
|
||||
{
|
||||
timer.start(snackbar->autoHideDuration());
|
||||
_timer.start(snackbar->autoHideDuration());
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ private:
|
|||
Q_DISABLE_COPY(SnackbarStateMachine)
|
||||
|
||||
Snackbar *const snackbar;
|
||||
QTimer timer;
|
||||
QTimer _timer;
|
||||
qreal _offset;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ public:
|
|||
|
||||
void init();
|
||||
|
||||
Snackbar *const q_ptr;
|
||||
Snackbar *const q_ptr;
|
||||
SnackbarStateMachine *machine;
|
||||
QColor backgroundColor;
|
||||
QColor textColor;
|
||||
QList<QString> messages;
|
||||
int duration;
|
||||
int boxWidth;
|
||||
QColor backgroundColor;
|
||||
QColor textColor;
|
||||
QList<QString> messages;
|
||||
int duration;
|
||||
int boxWidth;
|
||||
};
|
||||
|
||||
#endif // SNACKBAR_P_H
|
||||
|
|
Loading…
Reference in New Issue