28 #ifndef _BIBLIOTEQ_ANIMATED_TOOL_BUTTON_H_
29 #define _BIBLIOTEQ_ANIMATED_TOOL_BUTTON_H_
31 #include <QPropertyAnimation>
32 #include <QToolButton>
37 Q_PROPERTY(QColor color READ color WRITE setColor)
42 m_animator.setPropertyName(
"color");
43 m_animator.setTargetObject(
this);
44 m_negativeColor = QColor(255, 36, 0);
45 m_originalColor = palette().color(QPalette::Window);
46 m_positiveColor = QColor(0, 177, 64);
53 QColor color(
void)
const
55 return QColor(Qt::blue);
58 void animate(
const int milliseconds)
60 animatePositively(milliseconds);
63 void animateNegatively(
const int milliseconds)
65 animation(m_negativeColor, milliseconds);
68 void animatePositively(
const int milliseconds)
70 animation(m_positiveColor, milliseconds);
74 QColor m_negativeColor;
75 QColor m_originalColor;
76 QColor m_positiveColor;
77 QPropertyAnimation m_animator;
79 void animation(
const QColor &color,
const int milliseconds)
88 m_animator.setDuration(milliseconds);
89 m_animator.setEasingCurve(QEasingCurve::OutCubic);
90 m_animator.setEndValue(m_originalColor);
91 m_animator.setLoopCount(1);
92 m_animator.setStartValue(color);
96 void setColor(
const QColor &color)
99 (QString(
"background-color: rgb(%1, %2, %3); "
102 arg(color.red()).arg(color.green()).arg(color.blue()));