2016-03-19 08:32:49 +00:00
|
|
|
#include "checkbox.h"
|
2016-06-19 14:27:21 +00:00
|
|
|
#include "checkbox_p.h"
|
2016-06-13 23:27:37 +00:00
|
|
|
#include <QStateMachine>
|
2016-06-13 11:49:43 +00:00
|
|
|
#include <QEvent>
|
|
|
|
#include <QSignalTransition>
|
2016-06-13 23:27:37 +00:00
|
|
|
#include <QEventTransition>
|
2016-06-13 11:49:43 +00:00
|
|
|
#include <QPropertyAnimation>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QDebug>
|
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
CheckBoxPrivate::CheckBoxPrivate(CheckBox *q)
|
|
|
|
: CheckablePrivate(q)
|
2016-06-13 11:49:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
CheckBoxPrivate::~CheckBoxPrivate()
|
2016-06-13 11:49:43 +00:00
|
|
|
{
|
2016-06-13 23:27:37 +00:00
|
|
|
}
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
void CheckBoxPrivate::init()
|
|
|
|
{
|
2016-06-13 11:49:43 +00:00
|
|
|
QPropertyAnimation *animation;
|
|
|
|
|
|
|
|
animation = new QPropertyAnimation(checkedIcon, "iconSize");
|
2016-06-13 23:27:37 +00:00
|
|
|
animation->setStartValue(0);
|
|
|
|
animation->setEndValue(24);
|
2016-06-13 11:49:43 +00:00
|
|
|
animation->setDuration(250);
|
2016-06-13 23:27:37 +00:00
|
|
|
uncheckedTransition->addAnimation(animation);
|
2016-04-14 13:47:27 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
animation = new QPropertyAnimation(uncheckedIcon, "color");
|
|
|
|
animation->setDuration(250);
|
|
|
|
uncheckedTransition->addAnimation(animation);
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
//
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
animation = new QPropertyAnimation(uncheckedIcon, "color");
|
|
|
|
animation->setDuration(550);
|
|
|
|
checkedTransition->addAnimation(animation);
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
animation = new QPropertyAnimation(checkedIcon, "opacity");
|
|
|
|
animation->setDuration(450);
|
|
|
|
checkedTransition->addAnimation(animation);
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
//
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
checkedState->assignProperty(checkedIcon, "iconSize", 24);
|
|
|
|
checkedState->assignProperty(checkedIcon, "opacity", 1);
|
|
|
|
uncheckedState->assignProperty(checkedIcon, "opacity", 0);
|
|
|
|
disabledCheckedState->assignProperty(checkedIcon, "opacity", 1);
|
|
|
|
disabledUncheckedState->assignProperty(uncheckedIcon, "opacity", 1);
|
2016-06-13 11:49:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
CheckBox::CheckBox(QWidget *parent)
|
|
|
|
: Checkable(*new CheckBoxPrivate(this), parent)
|
2016-06-13 11:49:43 +00:00
|
|
|
{
|
2016-06-13 23:27:37 +00:00
|
|
|
Q_D(CheckBox);
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
d->init();
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
CheckBox::assignProperties();
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
d->machine->start();
|
|
|
|
QCoreApplication::processEvents();
|
2016-04-14 13:47:27 +00:00
|
|
|
}
|
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
CheckBox::~CheckBox()
|
2016-04-14 13:47:27 +00:00
|
|
|
{
|
2016-04-18 08:36:30 +00:00
|
|
|
}
|
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
void CheckBox::assignProperties()
|
2016-04-18 08:36:30 +00:00
|
|
|
{
|
2016-06-13 23:27:37 +00:00
|
|
|
Q_D(CheckBox);
|
2016-06-13 11:49:43 +00:00
|
|
|
|
2016-06-13 23:27:37 +00:00
|
|
|
d->checkedState->assignProperty(d->checkedIcon, "color", checkedColor());
|
2016-06-13 11:49:43 +00:00
|
|
|
d->checkedState->assignProperty(d->uncheckedIcon, "color", checkedColor());
|
2016-06-13 23:27:37 +00:00
|
|
|
d->uncheckedState->assignProperty(d->uncheckedIcon, "color", uncheckedColor());
|
|
|
|
d->uncheckedState->assignProperty(d->uncheckedIcon, "color", uncheckedColor());
|
|
|
|
d->disabledUncheckedState->assignProperty(d->uncheckedIcon, "color", disabledColor());
|
|
|
|
d->disabledCheckedState->assignProperty(d->checkedIcon, "color", disabledColor());
|
2016-04-14 13:47:27 +00:00
|
|
|
}
|