1/***************************************************************************
2 * Copyright 2010 Stefan Majewsky <majewsky@gmx.net>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***************************************************************************/
18
19#ifndef UTILS_ANIMATEDITEM_H
20#define UTILS_ANIMATEDITEM_H
21
22#include <QGraphicsObject>
23class QPropertyAnimation;
24
25namespace Utils
26{
27 /**
28 * \class AnimatedItem
29 * This QGraphicsItem has a simple interface for animated opacity changes.
30 */
31 class AnimatedItem : public QGraphicsObject
32 {
33 Q_OBJECT
34 Q_PROPERTY(qreal correct_opacity READ opacity WRITE setOpacity) //I'm talking of AnimatedItem::setOpacity, not QGraphicsItem::setOpacity!
35 public:
36 AnimatedItem(QGraphicsItem* parent = 0);
37
38 ///Returns the duration of opacity animations.
39 int animationTime() const;
40 ///\note This won't have an effect on running animations.
41 void setAnimationTime(int time);
42 ///Returns whether the object's visibility will be set to false when the opacity is reduced to 0.
43 bool hideWhenInvisible() const;
44 void setHideWhenInvisible(bool hideWhenInvisible);
45 void setOpacityAnimated(qreal opacity);
46 ///\warning Always use this instead of QGraphicsItem::setOpacity for direct opacity adjustments.
47 void setOpacity(qreal opacity);
48
49 virtual QRectF boundingRect() const;
50 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
51 private:
52 int m_animationTime;
53 bool m_hideWhenInvisible;
54 QPropertyAnimation* m_animator;
55 };
56}
57
58#endif // KOLF_OVERLAY_P_H
59