make sure all animations have a parent

This commit is contained in:
laserpants 2016-06-21 15:09:16 +03:00
parent f04c353dfb
commit 4d40f4554c
13 changed files with 53 additions and 54 deletions

View File

@ -11,6 +11,8 @@
FlatButtonPrivate::FlatButtonPrivate(FlatButton *q)
: q_ptr(q),
ripple(new RippleOverlay),
delegate(0),
role(Material::Default),
rippleStyle(Material::PositionedRipple),
cornerRadius(3),
@ -31,7 +33,7 @@ void FlatButtonPrivate::init()
{
Q_Q(FlatButton);
ripple = new RippleOverlay(q);
ripple->setParent(q);
delegate = new FlatButtonDelegate(q);
Style &style = Style::instance();

View File

@ -21,7 +21,7 @@ public:
void init();
FlatButton *const q_ptr;
RippleOverlay *ripple;
RippleOverlay *const ripple;
FlatButtonDelegate *delegate;
Material::Role role;
Material::RippleStyle rippleStyle;

View File

@ -6,7 +6,8 @@
#include "lib/rippleoverlay.h"
IconButtonPrivate::IconButtonPrivate(IconButton *q)
: q_ptr(q)
: q_ptr(q),
ripple(new RippleOverlay(q->parentWidget()))
{
}
@ -14,8 +15,6 @@ void IconButtonPrivate::init()
{
Q_Q(IconButton);
ripple = new RippleOverlay(q->parentWidget());
QSizePolicy policy;
policy.setWidthForHeight(true);
q->setSizePolicy(policy);

View File

@ -17,7 +17,7 @@ public:
void init();
IconButton *const q_ptr;
RippleOverlay *ripple;
RippleOverlay *const ripple;
};
#endif // ICONBUTTON_P_H

View File

@ -8,7 +8,7 @@
ProgressPrivate::ProgressPrivate(Progress *q)
: q_ptr(q),
delegate(0),
delegate(new ProgressDelegate(q)),
progressType(Material::IndeterminateProgress),
useThemeColors(true)
{
@ -22,8 +22,6 @@ void ProgressPrivate::init()
{
Q_Q(Progress);
delegate = new ProgressDelegate(q);
QPropertyAnimation *animation;
animation = new QPropertyAnimation(q);

View File

@ -19,7 +19,7 @@ public:
void init();
Progress *const q_ptr;
ProgressDelegate *delegate;
ProgressDelegate *const delegate;
Material::ProgressType progressType;
QColor progressColor;
QColor backgroundColor;

View File

@ -46,19 +46,19 @@ void RadioButtonPrivate::init()
QPropertyAnimation *animation;
animation = new QPropertyAnimation(checkedIcon, "iconSize");
animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
animation->setDuration(250);
machine->addDefaultAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "iconSize");
animation = new QPropertyAnimation(uncheckedIcon, "iconSize", q);
animation->setDuration(250);
machine->addDefaultAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "opacity");
animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
animation->setDuration(250);
machine->addDefaultAnimation(animation);
animation = new QPropertyAnimation(checkedIcon, "opacity");
animation = new QPropertyAnimation(checkedIcon, "opacity", q);
animation->setDuration(250);
machine->addDefaultAnimation(animation);
}

View File

@ -11,7 +11,11 @@
#include <QDebug>
RaisedButtonPrivate::RaisedButtonPrivate(RaisedButton *q)
: FlatButtonPrivate(q)
: FlatButtonPrivate(q),
machine(new QStateMachine),
normalState(new QState),
pressedState(new QState),
effect(new QGraphicsDropShadowEffect)
{
}
@ -23,20 +27,16 @@ void RaisedButtonPrivate::init()
{
Q_Q(RaisedButton);
machine = new QStateMachine(q);
machine->setParent(q);
q->setTextColor(Qt::white);
q->setPeakOpacity(0.25);
effect = new QGraphicsDropShadowEffect;
effect->setBlurRadius(7);
effect->setOffset(QPointF(0, 0));
effect->setColor(QColor(0, 0, 0, 60));
q->setGraphicsEffect(effect);
normalState = new QState;
pressedState = new QState;
machine->addState(normalState);
machine->addState(pressedState);

View File

@ -18,9 +18,9 @@ public:
void init();
QStateMachine *machine;
QState *normalState;
QState *pressedState;
QGraphicsDropShadowEffect *effect;
QState *const normalState;
QState *const pressedState;
QGraphicsDropShadowEffect *const effect;
QColor disabledBackgroundColor;
};

View File

@ -11,7 +11,7 @@ AppBarExamples::AppBarExamples(QWidget *parent)
: QWidget(parent)
{
Progress *p = new Progress;
p->setProgressType(Material::DeterminateProgress);
p->setProgressType(Material::IndeterminateProgress);
p->setMinimum(0);
p->setMaximum(99);
p->setValue(22);
@ -25,7 +25,7 @@ AppBarExamples::AppBarExamples(QWidget *parent)
l->addWidget(p);
CircularProgress *cp = new CircularProgress;
cp->setProgressType(Material::DeterminateProgress);
cp->setProgressType(Material::IndeterminateProgress);
cp->setMinimum(0);
cp->setMaximum(99);
cp->setValue(90);

View File

@ -11,7 +11,7 @@ IconButtonExamples::IconButtonExamples(QWidget *parent)
QLayout *layout = widget()->layout();
{
IconButton *iconButton = new IconButton(QIcon("../qt-material-widgets/face.svg"));
IconButton *iconButton = new IconButton(QIcon("../qt-material-widgets/face.svg"), this);
ExampleView *view = new ExampleView;
view->setWidget(iconButton);