qtmaterialcheckbox.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "qtmaterialcheckbox.h"
  2. #include "qtmaterialcheckbox_p.h"
  3. #include <QPropertyAnimation>
  4. #include <QSignalTransition>
  5. #include <QState>
  6. #include "lib/qtmaterialcheckable_internal.h"
  7. /*!
  8. * \class QtMaterialCheckBoxPrivate
  9. * \internal
  10. */
  11. /*!
  12. * \internal
  13. */
  14. QtMaterialCheckBoxPrivate::QtMaterialCheckBoxPrivate(QtMaterialCheckBox *q)
  15. : QtMaterialCheckablePrivate(q)
  16. {
  17. }
  18. /*!
  19. * \internal
  20. */
  21. QtMaterialCheckBoxPrivate::~QtMaterialCheckBoxPrivate()
  22. {
  23. }
  24. /*!
  25. * \internal
  26. */
  27. void QtMaterialCheckBoxPrivate::init()
  28. {
  29. Q_Q(QtMaterialCheckBox);
  30. checkedState->assignProperty(checkedIcon, "iconSize", 24);
  31. uncheckedState->assignProperty(checkedIcon, "iconSize", 0);
  32. QPropertyAnimation *animation;
  33. animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
  34. animation->setDuration(300);
  35. uncheckedTransition->addAnimation(animation);
  36. animation = new QPropertyAnimation(checkedIcon, "iconSize", q);
  37. animation->setDuration(1300);
  38. checkedTransition->addAnimation(animation);
  39. animation = new QPropertyAnimation(checkedIcon, "opacity", q);
  40. animation->setDuration(440);
  41. checkedTransition->addAnimation(animation);
  42. animation = new QPropertyAnimation(checkedIcon, "opacity", q);
  43. animation->setDuration(440);
  44. uncheckedTransition->addAnimation(animation);
  45. animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
  46. animation->setDuration(440);
  47. checkedTransition->addAnimation(animation);
  48. animation = new QPropertyAnimation(uncheckedIcon, "opacity", q);
  49. animation->setDuration(440);
  50. uncheckedTransition->addAnimation(animation);
  51. animation = new QPropertyAnimation(uncheckedIcon, "color", q);
  52. animation->setDuration(440);
  53. checkedTransition->addAnimation(animation);
  54. animation = new QPropertyAnimation(uncheckedIcon, "color", q);
  55. animation->setDuration(440);
  56. uncheckedTransition->addAnimation(animation);
  57. }
  58. /*!
  59. * \class QtMaterialCheckBox
  60. */
  61. QtMaterialCheckBox::QtMaterialCheckBox(QWidget *parent)
  62. : QtMaterialCheckable(*new QtMaterialCheckBoxPrivate(this), parent)
  63. {
  64. d_func()->init();
  65. }
  66. QtMaterialCheckBox::~QtMaterialCheckBox()
  67. {
  68. }