make state machine member pointer type

This commit is contained in:
laserpants 2016-06-13 00:17:46 +03:00
parent 57e77ecc04
commit 309e9eb5a8
4 changed files with 19 additions and 16 deletions

View File

@ -23,6 +23,8 @@ void RaisedButtonPrivate::init()
{
Q_Q(RaisedButton);
machine = new QStateMachine(q);
q->setTextColor(Qt::white);
q->setPeakOpacity(0.25);
@ -35,8 +37,8 @@ void RaisedButtonPrivate::init()
normalState = new QState;
pressedState = new QState;
machine.addState(normalState);
machine.addState(pressedState);
machine->addState(normalState);
machine->addState(pressedState);
normalState->assignProperty(effect, "offset", QPointF(0, 0));
normalState->assignProperty(effect, "blurRadius", 7);
@ -91,8 +93,8 @@ void RaisedButtonPrivate::init()
//
machine.setInitialState(normalState);
machine.start();
machine->setInitialState(normalState);
machine->start();
}
RaisedButton::RaisedButton(QWidget *parent)
@ -140,10 +142,10 @@ bool RaisedButton::event(QEvent *event)
if (QEvent::EnabledChange == event->type()) {
if (isEnabled()) {
d->machine.start();
d->machine->start();
d->effect->setEnabled(true);
} else {
d->machine.stop();
d->machine->stop();
d->effect->setEnabled(false);
}
}

View File

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

View File

@ -27,15 +27,16 @@ void TogglePrivate::init()
Q_Q(Toggle);
ripple = new RippleOverlay(q->parentWidget());
machine = new QStateMachine(q);
q->setCheckable(true);
q->setChecked(false);
q->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
machine.addState(offState);
machine.addState(onState);
machine->addState(offState);
machine->addState(onState);
machine.setInitialState(offState);
machine->setInitialState(offState);
QSignalTransition *transition;
QPropertyAnimation *animation;
@ -101,7 +102,7 @@ void TogglePrivate::init()
QObject::connect(q, SIGNAL(toggled(bool)), q, SLOT(addRipple()));
machine.start();
machine->start();
QCoreApplication::processEvents();
}
@ -290,9 +291,9 @@ bool Toggle::event(QEvent *event)
{
case QEvent::EnabledChange:
if (isEnabled()) {
d->machine.start();
d->machine->start();
} else {
d->machine.stop();
d->machine->stop();
}
break;
case QEvent::ParentChange:

View File

@ -26,7 +26,7 @@ public:
QState *const offState;
QState *const onState;
RippleOverlay *ripple;
QStateMachine machine;
QStateMachine *machine;
Qt::Orientation orientation;
QColor disabledColor;
QColor activeColor;