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