QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
qprogressindicator.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2011 Morgan Leborgne
2// SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
3// SPDX-License-Identifier: MIT
8#ifndef SRC_QPROGRESSINDICATOR_H_
9#define SRC_QPROGRESSINDICATOR_H_
10
11#include <QColor>
12#include <QWidget>
13
27class QProgressIndicator : public QWidget {
28 Q_OBJECT
29
30public:
36 explicit QProgressIndicator(QWidget *parent = nullptr);
37
43 [[nodiscard]] auto animationDelay() const -> int { return m_delay; }
44
50 [[nodiscard]] auto isAnimated() const -> bool;
51
57 [[nodiscard]] auto isDisplayedWhenStopped() const -> bool;
58
64 [[nodiscard]] auto color() const -> const QColor & { return m_color; }
65
70 [[nodiscard]] auto sizeHint() const -> QSize override;
71
77 [[nodiscard]] auto heightForWidth(int w) const -> int override;
78
79public slots:
84 void startAnimation();
85
90 void stopAnimation();
91
101 void setAnimationDelay(int delay);
102
108 void setDisplayedWhenStopped(bool state);
109
116 void setColor(const QColor &color);
117
118protected:
123 void timerEvent(QTimerEvent *event) override;
124
129 void paintEvent(QPaintEvent *event) override;
130
131private:
133 int m_angle{0};
135 int m_timerId{-1};
137 int m_delay{40};
141 QColor m_color;
142};
143
144#endif // SRC_QPROGRESSINDICATOR_H_
auto animationDelay() const -> int
Delay between animation steps.
void paintEvent(QPaintEvent *event) override
Draw the twelve capsules, the newest opaque and the rest fading.
QColor m_color
Colour from setColor(); invalid means the palette colour.
int m_angle
Rotation of the first capsule, in degrees.
void stopAnimation()
Stop the spin animation.
QProgressIndicator(QWidget *parent=nullptr)
Create a stopped indicator with a fixed size policy that never takes keyboard focus.
auto isAnimated() const -> bool
Whether the indicator is animating.
void startAnimation()
Start the spin animation from its first position.
auto isDisplayedWhenStopped() const -> bool
Whether the indicator is drawn while it does not animate.
void setColor(const QColor &color)
Set the colour the indicator is drawn in.
void timerEvent(QTimerEvent *event) override
Turn the indicator one step (30 degrees) and repaint.
bool m_displayedWhenStopped
Whether the indicator is drawn while it does not animate.
void setDisplayedWhenStopped(bool state)
Set whether the indicator is drawn while it does not animate.
int m_delay
Milliseconds between two animation steps.
void setAnimationDelay(int delay)
Set the delay between animation steps.
int m_timerId
Id of the animation timer, or -1 while stopped.
auto heightForWidth(int w) const -> int override
Keep the indicator square.
auto sizeHint() const -> QSize override
Preferred size of the indicator.
auto color() const -> const QColor &
Colour set with setColor().