Kstars

QProgressIndicator.h
1/*
2
3 This file is part of QProgressIndicator,
4 an open-source recent files menu widget
5
6 SPDX-FileCopyrightText: 2009-2010 Morgan Leborgne
7 SPDX-License-Identifier: LGPL-3.0-or-later
8*/
9
10#pragma once
11
12#include <QWidget>
13#include <QColor>
14
15/**
16 * @class QProgressIndicator
17 * @brief The QProgressIndicator class lets an application display a progress indicator to show that a long task is
18 * under way.
19 * Progress indicators are indeterminate and do nothing more than spin to show that the application is busy.
20 *
21 * @sa QProgressBar
22 */
24{
26 Q_PROPERTY(int delay READ animationDelay WRITE setAnimationDelay)
27 Q_PROPERTY(bool displayedWhenStopped READ isDisplayedWhenStopped WRITE setDisplayedWhenStopped)
28 Q_PROPERTY(QColor color READ color WRITE setColor)
29 public:
30 explicit QProgressIndicator(QWidget *parent = nullptr);
31
32 /**
33 * Returns the delay between animation steps.
34 * @return The number of milliseconds between animation steps. By default, the animation delay is set to
35 * 40 milliseconds.
36 *
37 * @sa setAnimationDelay
38 */
39 int animationDelay() const { return m_delay; }
40
41 /**
42 * Returns a Boolean value indicating whether the component is currently animated.
43 * @return Animation state.
44 * @sa startAnimation stopAnimation
45 */
46 bool isAnimated() const;
47
48 /**
49 * Returns a Boolean value indicating whether the receiver shows itself even when it is not animating.
50 * @return Return true if the progress indicator shows itself even when it is not animating. By default,
51 * it returns false.
52 * @sa setDisplayedWhenStopped
53 */
54 bool isDisplayedWhenStopped() const;
55
56 /**
57 * Returns the color of the component.
58 * @sa setColor
59 */
60 const QColor &color() const { return m_color; }
61
62 QSize sizeHint() const override;
63 int heightForWidth(int w) const override;
64 public slots:
65 /**
66 * Starts the spin animation.
67 * @sa stopAnimation isAnimated
68 */
69 void startAnimation();
70
71 /**
72 * Stops the spin animation.
73 * @sa startAnimation isAnimated
74 */
75 void stopAnimation();
76
77 /**
78 * Sets the delay between animation steps.
79 * Setting the \a delay to a value larger than 40 slows the animation, while setting the @a delay to a
80 * smaller value speeds it up.
81 * @param delay The delay, in milliseconds.
82 * @sa animationDelay
83 */
84 void setAnimationDelay(int delay);
85
86 /**
87 * Sets whether the component hides itself when it is not animating.
88 * @param state The animation state. Set false to hide the progress indicator when it is not animating; otherwise true.
89 * @sa isDisplayedWhenStopped
90 */
91 void setDisplayedWhenStopped(bool state);
92
93 /**
94 * Sets the color of the components to the given color.
95 * @sa color
96 */
97 void setColor(const QColor &color);
98
99 protected:
100 void timerEvent(QTimerEvent *event) override;
101 void paintEvent(QPaintEvent *event) override;
102
103 private:
104 int m_angle { 0 };
105 int m_timerId { -1 };
106 int m_delay { 40 };
107 bool m_displayedWhenStopped { false };
108 QColor m_color { Qt::black };
109};
The QProgressIndicator class lets an application display a progress indicator to show that a long tas...
void stopAnimation()
Stops the spin animation.
bool isDisplayedWhenStopped() const
Returns a Boolean value indicating whether the receiver shows itself even when it is not animating.
void startAnimation()
Starts the spin animation.
void setColor(const QColor &color)
Sets the color of the components to the given color.
int animationDelay() const
Returns the delay between animation steps.
bool isAnimated() const
Returns a Boolean value indicating whether the component is currently animated.
void setDisplayedWhenStopped(bool state)
Sets whether the component hides itself when it is not animating.
void setAnimationDelay(int delay)
Sets the delay between animation steps.
const QColor & color() const
Returns the color of the component.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
QObject * parent() const const
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.