DtkWidget 5.6.0.2
DTK Widget module
dloadingindicator.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DLOADINGINDICATOR_H
6#define DLOADINGINDICATOR_H
7
8#include <QObject>
9#include <QBrush>
10#include <QColor>
11#include <QVariant>
12#include <QSizePolicy>
13#include <QVariantAnimation>
14#include <QGraphicsScene>
15#include <QGraphicsPixmapItem>
16#include <QGraphicsView>
17#include <QEasingCurve>
18#include <QDebug>
19
20#include <dtkwidget_global.h>
21#include <DObject>
22
23DWIDGET_BEGIN_NAMESPACE
24
25class DLoadingIndicatorPrivate;
26class LIBDTKWIDGETSHARED_EXPORT DLoadingIndicator : public QGraphicsView, public DTK_CORE_NAMESPACE::DObject
27{
28 Q_OBJECT
29
30 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor DESIGNABLE true SCRIPTABLE true)
31 Q_PROPERTY(bool loading READ loading WRITE setLoading)
32 Q_PROPERTY(bool smooth READ smooth WRITE setSmooth)
33 Q_PROPERTY(QPixmap imageSource READ imageSource WRITE setImageSource)
34 Q_PROPERTY(QWidget* widgetSource READ widgetSource WRITE setWidgetSource)
35 Q_PROPERTY(int aniDuration READ aniDuration WRITE setAniDuration)
36 Q_PROPERTY(QEasingCurve::Type aniEasingType READ aniEasingType WRITE setAniEasingType)
37 Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
38 Q_PROPERTY(qreal rotate READ rotate WRITE setRotate NOTIFY rotateChanged)
39
40public:
47 Counterclockwise
48 };
49
50 Q_ENUMS(RotationDirection)
51
52 DLoadingIndicator(QWidget * parent = 0);
54
55 QColor backgroundColor() const;
56 bool loading() const;
57 QWidget* widgetSource() const;
58 QPixmap imageSource() const;
59 int aniDuration() const;
60 QEasingCurve::Type aniEasingType() const;
61 QSize sizeHint() const Q_DECL_OVERRIDE;
62 bool smooth() const;
63 RotationDirection direction() const;
64 qreal rotate() const;
65
66public Q_SLOTS:
67 void start();
68 void stop();
69 void setLoading(bool flag);
70 void setAniDuration(int msecs);
71 void setAniEasingCurve(const QEasingCurve & easing);
72 void setBackgroundColor(const QColor &color);
73 void setRotate(QVariant angle);
74 void setWidgetSource(QWidget* widgetSource);
75 void setImageSource(const QPixmap &imageSource);
76 void setAniEasingType(QEasingCurve::Type aniEasingType);
77 void setSmooth(bool smooth);
78 void setDirection(RotationDirection direction);
79
80Q_SIGNALS:
81 void directionChanged(RotationDirection direction);
82 void rotateChanged(qreal rotate);
83
84protected:
85 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
86
87private:
88 D_DECLARE_PRIVATE(DLoadingIndicator)
89};
90
91DWIDGET_END_NAMESPACE
92
93#endif // DLOADINGINDICATOR_H
The DLoadingIndicator class provides a widget that showing loading animation.
Definition: dloadingindicator.h:27
RotationDirection
The RotationDirection enum contains the possible rotation directions of the DLoadingIndicator widget.
Definition: dloadingindicator.h:45
@ Clockwise
Definition: dloadingindicator.h:46