28 #ifndef _BIBLIOTEQ_ANIMATED_PUSH_BUTTON_H_
29 #define _BIBLIOTEQ_ANIMATED_PUSH_BUTTON_H_
31 #include <QPropertyAnimation>
32 #include <QPushButton>
37 Q_PROPERTY(QColor color READ color WRITE setColor)
43 SIGNAL(finished(
void)),
45 SLOT(slotAnimationFinished(
void)));
46 m_animator.setPropertyName(
"color");
47 m_animator.setTargetObject(
this);
48 m_negativeColor = QColor(255, 36, 0);
49 m_originalColor = palette().color(QPalette::Window);
50 m_positiveColor = QColor(0, 177, 64);
57 QColor color(
void)
const
59 return QColor(Qt::blue);
62 void animate(
const int milliseconds)
64 animatePositively(milliseconds);
67 void animateNegatively(
const int milliseconds)
69 animation(m_negativeColor, milliseconds);
72 void animatePositively(
const int milliseconds)
74 animation(m_positiveColor, milliseconds);
78 QColor m_negativeColor;
79 QColor m_originalColor;
80 QColor m_positiveColor;
81 QPropertyAnimation m_animator;
83 void animation(
const QColor &color,
const int milliseconds)
92 m_animator.setDuration(milliseconds);
93 m_animator.setEasingCurve(QEasingCurve::OutCubic);
94 m_animator.setEndValue(m_originalColor);
95 m_animator.setLoopCount(1);
96 m_animator.setStartValue(color);
100 void setColor(
const QColor &color)
103 (QString(
"background-color: rgb(%1, %2, %3);").
104 arg(color.red()).arg(color.green()).arg(color.blue()));
108 void slotAnimationFinished(
void)