2 ******************************************************************************
4 * @file styleanimator.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup CorePlugin Core Plugin
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <QtCore/QPointer>
33 #include <QtCore/QTime>
34 #include <QtCore/QBasicTimer>
40 * This is a set of helper classes to allow for widget animations in
41 * the style. Its mostly taken from Vista style so it should be fully documented
48 Animation() : m_running(true) {}
49 virtual ~Animation() {}
50 QWidget
*widget() const
58 const QTime
&startTime() const
62 void setRunning(bool val
)
66 void setWidget(QWidget
*widget
)
70 void setStartTime(const QTime
&startTime
)
72 m_startTime
= startTime
;
74 virtual void paint(QPainter
*painter
, const QStyleOption
*option
);
77 void drawBlendedImage(QPainter
*painter
, QRect rect
, float value
);
79 QPointer
<QWidget
> m_widget
;
80 QImage m_primaryImage
;
81 QImage m_secondaryImage
;
86 // Handles state transition animations
87 class Transition
: public Animation
{
89 Transition() : Animation() {}
90 virtual ~Transition() {}
91 void setDuration(int duration
)
93 m_duration
= duration
;
95 void setStartImage(const QImage
&image
)
97 m_primaryImage
= image
;
99 void setEndImage(const QImage
&image
)
101 m_secondaryImage
= image
;
103 virtual void paint(QPainter
*painter
, const QStyleOption
*option
);
108 int m_duration
; // set time in ms to complete a state transition
111 class StyleAnimator
: public QObject
{
115 StyleAnimator(QObject
*parent
= 0) : QObject(parent
) {}
117 void timerEvent(QTimerEvent
*);
118 void startAnimation(Animation
*);
119 void stopAnimation(const QWidget
*);
120 Animation
*widgetAnimation(const QWidget
*) const;
123 QBasicTimer animationTimer
;
124 QList
<Animation
*> animations
;
127 #endif // ANIMATION_H