qt-material-widgets/components/qtmaterialcheckbox.cpp

90 lines
2.0 KiB
C++
Raw Normal View History

2017-09-29 06:53:21 +00:00
#include "qtmaterialcheckbox.h"
#include "qtmaterialcheckbox_p.h"
#include <QPropertyAnimation>
#include <QSignalTransition>
#include <QState>
#include "lib/qtmaterialcheckable_internal.h"
2022-02-17 02:10:25 +00:00
namespace md
{
2017-09-29 06:53:21 +00:00
/*!
* \class QtMaterialCheckBoxPrivate
* \internal
*/
/*!
* \internal
*/
2022-02-17 02:10:25 +00:00
CheckBoxPrivate::CheckBoxPrivate(CheckBox *q)
: CheckablePrivate(q)
2017-09-29 06:53:21 +00:00
{
}
/*!
* \internal
*/
2022-02-17 02:10:25 +00:00
CheckBoxPrivate::~CheckBoxPrivate()
2017-09-29 06:53:21 +00:00
{
}
/*!
* \internal
*/
2022-02-17 02:10:25 +00:00
void CheckBoxPrivate::init()
2017-09-29 06:53:21 +00:00
{
2022-02-17 02:10:25 +00:00
Q_Q(CheckBox);
2017-09-29 06:53:21 +00:00
checkedState->assignProperty(checkedIcon, "iconSize", 24);
uncheckedState->assignProperty(checkedIcon, "iconSize", 0);
QPropertyAnimation *animation;
animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
animation->setDuration(300);
uncheckedTransition->addAnimation(animation);
animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
animation->setDuration(1300);
checkedTransition->addAnimation(animation);
animation = new QPropertyAnimation(checkedIcon, "opacity", q);
animation->setDuration(440);
checkedTransition->addAnimation(animation);
animation = new QPropertyAnimation(checkedIcon, "opacity", q);
animation->setDuration(440);
uncheckedTransition->addAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
animation->setDuration(440);
checkedTransition->addAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
animation->setDuration(440);
uncheckedTransition->addAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "color", q);
animation->setDuration(440);
checkedTransition->addAnimation(animation);
animation = new QPropertyAnimation(uncheckedIcon, "color", q);
animation->setDuration(440);
uncheckedTransition->addAnimation(animation);
}
/*!
* \class QtMaterialCheckBox
*/
2022-02-17 02:10:25 +00:00
CheckBox::CheckBox(QWidget *parent)
: Checkable(*new CheckBoxPrivate(this), parent)
2017-09-29 06:53:21 +00:00
{
d_func()->init();
}
2022-02-17 02:10:25 +00:00
CheckBox::~CheckBox()
2017-09-29 06:53:21 +00:00
{
}
2022-02-17 02:10:25 +00:00
}