make sure all animations have a parent
This commit is contained in:
parent
f04c353dfb
commit
4d40f4554c
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
FlatButtonPrivate::FlatButtonPrivate(FlatButton *q)
|
FlatButtonPrivate::FlatButtonPrivate(FlatButton *q)
|
||||||
: q_ptr(q),
|
: q_ptr(q),
|
||||||
|
ripple(new RippleOverlay),
|
||||||
|
delegate(0),
|
||||||
role(Material::Default),
|
role(Material::Default),
|
||||||
rippleStyle(Material::PositionedRipple),
|
rippleStyle(Material::PositionedRipple),
|
||||||
cornerRadius(3),
|
cornerRadius(3),
|
||||||
|
@ -31,7 +33,7 @@ void FlatButtonPrivate::init()
|
||||||
{
|
{
|
||||||
Q_Q(FlatButton);
|
Q_Q(FlatButton);
|
||||||
|
|
||||||
ripple = new RippleOverlay(q);
|
ripple->setParent(q);
|
||||||
delegate = new FlatButtonDelegate(q);
|
delegate = new FlatButtonDelegate(q);
|
||||||
|
|
||||||
Style &style = Style::instance();
|
Style &style = Style::instance();
|
||||||
|
|
|
@ -21,7 +21,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
FlatButton *const q_ptr;
|
FlatButton *const q_ptr;
|
||||||
RippleOverlay *ripple;
|
RippleOverlay *const ripple;
|
||||||
FlatButtonDelegate *delegate;
|
FlatButtonDelegate *delegate;
|
||||||
Material::Role role;
|
Material::Role role;
|
||||||
Material::RippleStyle rippleStyle;
|
Material::RippleStyle rippleStyle;
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
#include "lib/rippleoverlay.h"
|
#include "lib/rippleoverlay.h"
|
||||||
|
|
||||||
IconButtonPrivate::IconButtonPrivate(IconButton *q)
|
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);
|
Q_Q(IconButton);
|
||||||
|
|
||||||
ripple = new RippleOverlay(q->parentWidget());
|
|
||||||
|
|
||||||
QSizePolicy policy;
|
QSizePolicy policy;
|
||||||
policy.setWidthForHeight(true);
|
policy.setWidthForHeight(true);
|
||||||
q->setSizePolicy(policy);
|
q->setSizePolicy(policy);
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
IconButton *const q_ptr;
|
IconButton *const q_ptr;
|
||||||
RippleOverlay *ripple;
|
RippleOverlay *const ripple;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ICONBUTTON_P_H
|
#endif // ICONBUTTON_P_H
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
ProgressPrivate::ProgressPrivate(Progress *q)
|
ProgressPrivate::ProgressPrivate(Progress *q)
|
||||||
: q_ptr(q),
|
: q_ptr(q),
|
||||||
delegate(0),
|
delegate(new ProgressDelegate(q)),
|
||||||
progressType(Material::IndeterminateProgress),
|
progressType(Material::IndeterminateProgress),
|
||||||
useThemeColors(true)
|
useThemeColors(true)
|
||||||
{
|
{
|
||||||
|
@ -22,8 +22,6 @@ void ProgressPrivate::init()
|
||||||
{
|
{
|
||||||
Q_Q(Progress);
|
Q_Q(Progress);
|
||||||
|
|
||||||
delegate = new ProgressDelegate(q);
|
|
||||||
|
|
||||||
QPropertyAnimation *animation;
|
QPropertyAnimation *animation;
|
||||||
|
|
||||||
animation = new QPropertyAnimation(q);
|
animation = new QPropertyAnimation(q);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
Progress *const q_ptr;
|
Progress *const q_ptr;
|
||||||
ProgressDelegate *delegate;
|
ProgressDelegate *const delegate;
|
||||||
Material::ProgressType progressType;
|
Material::ProgressType progressType;
|
||||||
QColor progressColor;
|
QColor progressColor;
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
|
|
|
@ -46,19 +46,19 @@ void RadioButtonPrivate::init()
|
||||||
|
|
||||||
QPropertyAnimation *animation;
|
QPropertyAnimation *animation;
|
||||||
|
|
||||||
animation = new QPropertyAnimation(checkedIcon, "iconSize");
|
animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
|
||||||
animation->setDuration(250);
|
animation->setDuration(250);
|
||||||
machine->addDefaultAnimation(animation);
|
machine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
animation = new QPropertyAnimation(uncheckedIcon, "iconSize");
|
animation = new QPropertyAnimation(uncheckedIcon, "iconSize", q);
|
||||||
animation->setDuration(250);
|
animation->setDuration(250);
|
||||||
machine->addDefaultAnimation(animation);
|
machine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
animation = new QPropertyAnimation(uncheckedIcon, "opacity");
|
animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
|
||||||
animation->setDuration(250);
|
animation->setDuration(250);
|
||||||
machine->addDefaultAnimation(animation);
|
machine->addDefaultAnimation(animation);
|
||||||
|
|
||||||
animation = new QPropertyAnimation(checkedIcon, "opacity");
|
animation = new QPropertyAnimation(checkedIcon, "opacity", q);
|
||||||
animation->setDuration(250);
|
animation->setDuration(250);
|
||||||
machine->addDefaultAnimation(animation);
|
machine->addDefaultAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,11 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
RaisedButtonPrivate::RaisedButtonPrivate(RaisedButton *q)
|
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);
|
Q_Q(RaisedButton);
|
||||||
|
|
||||||
machine = new QStateMachine(q);
|
machine->setParent(q);
|
||||||
|
|
||||||
q->setTextColor(Qt::white);
|
q->setTextColor(Qt::white);
|
||||||
q->setPeakOpacity(0.25);
|
q->setPeakOpacity(0.25);
|
||||||
|
|
||||||
effect = new QGraphicsDropShadowEffect;
|
|
||||||
effect->setBlurRadius(7);
|
effect->setBlurRadius(7);
|
||||||
effect->setOffset(QPointF(0, 0));
|
effect->setOffset(QPointF(0, 0));
|
||||||
effect->setColor(QColor(0, 0, 0, 60));
|
effect->setColor(QColor(0, 0, 0, 60));
|
||||||
q->setGraphicsEffect(effect);
|
q->setGraphicsEffect(effect);
|
||||||
|
|
||||||
normalState = new QState;
|
|
||||||
pressedState = new QState;
|
|
||||||
|
|
||||||
machine->addState(normalState);
|
machine->addState(normalState);
|
||||||
machine->addState(pressedState);
|
machine->addState(pressedState);
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QStateMachine *machine;
|
QStateMachine *machine;
|
||||||
QState *normalState;
|
QState *const normalState;
|
||||||
QState *pressedState;
|
QState *const pressedState;
|
||||||
QGraphicsDropShadowEffect *effect;
|
QGraphicsDropShadowEffect *const effect;
|
||||||
QColor disabledBackgroundColor;
|
QColor disabledBackgroundColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ AppBarExamples::AppBarExamples(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
Progress *p = new Progress;
|
Progress *p = new Progress;
|
||||||
p->setProgressType(Material::DeterminateProgress);
|
p->setProgressType(Material::IndeterminateProgress);
|
||||||
p->setMinimum(0);
|
p->setMinimum(0);
|
||||||
p->setMaximum(99);
|
p->setMaximum(99);
|
||||||
p->setValue(22);
|
p->setValue(22);
|
||||||
|
@ -25,7 +25,7 @@ AppBarExamples::AppBarExamples(QWidget *parent)
|
||||||
l->addWidget(p);
|
l->addWidget(p);
|
||||||
|
|
||||||
CircularProgress *cp = new CircularProgress;
|
CircularProgress *cp = new CircularProgress;
|
||||||
cp->setProgressType(Material::DeterminateProgress);
|
cp->setProgressType(Material::IndeterminateProgress);
|
||||||
cp->setMinimum(0);
|
cp->setMinimum(0);
|
||||||
cp->setMaximum(99);
|
cp->setMaximum(99);
|
||||||
cp->setValue(90);
|
cp->setValue(90);
|
||||||
|
|
|
@ -11,7 +11,7 @@ IconButtonExamples::IconButtonExamples(QWidget *parent)
|
||||||
QLayout *layout = widget()->layout();
|
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;
|
ExampleView *view = new ExampleView;
|
||||||
view->setWidget(iconButton);
|
view->setWidget(iconButton);
|
||||||
|
|
Loading…
Reference in New Issue