Line data Source code
1 : #ifndef QPROGRESSINDICATOR_H_
2 : #define QPROGRESSINDICATOR_H_
3 :
4 : #include <QColor>
5 : #include <QWidget>
6 :
7 : /*!
8 : \class QProgressIndicator
9 : \brief The QProgressIndicator class lets an application display a progress
10 : indicator to show that a lengthy task is under way.
11 :
12 : Progress indicators are indeterminate and do nothing more than spin to show
13 : that the application is busy.
14 : \sa QProgressBar
15 : */
16 0 : class QProgressIndicator : public QWidget {
17 : Q_OBJECT
18 : /**
19 : * @brief QProgressIndicator::delay in miliseconds.
20 : */
21 : Q_PROPERTY(int delay READ animationDelay WRITE setAnimationDelay)
22 : /**
23 : * @brief QProgressIndicator::displayedWhenStopped render when not spinning.
24 : */
25 : Q_PROPERTY(bool displayedWhenStopped READ isDisplayedWhenStopped WRITE
26 : setDisplayedWhenStopped)
27 : /**
28 : * @brief QProgressIndicator::color of the component..
29 : */
30 : Q_PROPERTY(QColor color READ color WRITE setColor)
31 :
32 : public:
33 : explicit QProgressIndicator(QWidget *parent = 0);
34 :
35 : /*! Returns the delay between animation steps.
36 : \return The number of milliseconds between animation steps. By default,
37 : the animation delay is set to 40 milliseconds.
38 : \sa setAnimationDelay
39 : */
40 0 : int animationDelay() const { return m_delay; }
41 :
42 : /*! Returns a Boolean value indicating whether the component is currently
43 : animated.
44 : \return Animation state.
45 : \sa startAnimation stopAnimation
46 : */
47 : bool isAnimated() const;
48 :
49 : /*! Returns a Boolean value indicating whether the receiver shows itself even
50 : when it is not animating.
51 : \return Return true if the progress indicator shows itself even when it is
52 : not animating. By default, it returns false.
53 : \sa setDisplayedWhenStopped
54 : */
55 : bool isDisplayedWhenStopped() const;
56 :
57 : /*! Returns the color of the component.
58 : \sa setColor
59 : */
60 0 : const QColor &color() const { return m_color; }
61 :
62 : virtual QSize sizeHint() const;
63 : int heightForWidth(int w) const;
64 :
65 : public slots:
66 : /*! Starts the spin animation.
67 : \sa stopAnimation isAnimated
68 : */
69 : void startAnimation();
70 :
71 : /*! Stops the spin animation.
72 : \sa startAnimation isAnimated
73 : */
74 : void stopAnimation();
75 :
76 : /*! Sets the delay between animation steps.
77 : Setting the \a delay to a value larger than 40 slows the animation, while
78 : setting the \a delay to a smaller value speeds it up.
79 : \param delay The delay, in milliseconds.
80 : \sa animationDelay
81 : */
82 : void setAnimationDelay(int delay);
83 :
84 : /*! Sets whether the component hides itself when it is not animating.
85 : \param state The animation state. Set false to hide the progress indicator
86 : when it is not animating; otherwise true.
87 : \sa isDisplayedWhenStopped
88 : */
89 : void setDisplayedWhenStopped(bool state);
90 :
91 : /*! Sets the color of the components to the given color.
92 : \sa color
93 : */
94 : void setColor(const QColor &color);
95 :
96 : protected:
97 : virtual void timerEvent(QTimerEvent *event);
98 : virtual void paintEvent(QPaintEvent *event);
99 :
100 : private:
101 : int m_angle;
102 : int m_timerId;
103 : int m_delay;
104 : bool m_displayedWhenStopped;
105 : QColor m_color;
106 : };
107 :
108 : #endif // QPROGRESSINDICATOR_H_
|