1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QPROGRESSDIALOG_H |
5 | #define QPROGRESSDIALOG_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | |
9 | #include <QtWidgets/qdialog.h> |
10 | |
11 | QT_REQUIRE_CONFIG(progressdialog); |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QPushButton; |
16 | class QLabel; |
17 | class QProgressBar; |
18 | class QTimer; |
19 | class QProgressDialogPrivate; |
20 | |
21 | class Q_WIDGETS_EXPORT QProgressDialog : public QDialog |
22 | { |
23 | Q_OBJECT |
24 | Q_DECLARE_PRIVATE(QProgressDialog) |
25 | Q_PROPERTY(bool wasCanceled READ wasCanceled) |
26 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) |
27 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) |
28 | Q_PROPERTY(int value READ value WRITE setValue) |
29 | Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset) |
30 | Q_PROPERTY(bool autoClose READ autoClose WRITE setAutoClose) |
31 | Q_PROPERTY(int minimumDuration READ minimumDuration WRITE setMinimumDuration) |
32 | Q_PROPERTY(QString labelText READ labelText WRITE setLabelText) |
33 | |
34 | public: |
35 | explicit QProgressDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); |
36 | QProgressDialog(const QString &labelText, const QString &cancelButtonText, |
37 | int minimum, int maximum, QWidget *parent = nullptr, |
38 | Qt::WindowFlags flags = Qt::WindowFlags()); |
39 | ~QProgressDialog(); |
40 | |
41 | void setLabel(QLabel *label); |
42 | void setCancelButton(QPushButton *button); |
43 | void setBar(QProgressBar *bar); |
44 | |
45 | bool wasCanceled() const; |
46 | |
47 | int minimum() const; |
48 | int maximum() const; |
49 | |
50 | int value() const; |
51 | |
52 | QSize sizeHint() const override; |
53 | |
54 | QString labelText() const; |
55 | int minimumDuration() const; |
56 | |
57 | void setAutoReset(bool reset); |
58 | bool autoReset() const; |
59 | void setAutoClose(bool close); |
60 | bool autoClose() const; |
61 | |
62 | using QDialog::open; |
63 | void open(QObject *receiver, const char *member); |
64 | |
65 | public Q_SLOTS: |
66 | void cancel(); |
67 | void reset(); |
68 | void setMaximum(int maximum); |
69 | void setMinimum(int minimum); |
70 | void setRange(int minimum, int maximum); |
71 | void setValue(int progress); |
72 | void setLabelText(const QString &text); |
73 | void setCancelButtonText(const QString &text); |
74 | void setMinimumDuration(int ms); |
75 | |
76 | Q_SIGNALS: |
77 | void canceled(); |
78 | |
79 | protected: |
80 | void resizeEvent(QResizeEvent *event) override; |
81 | void closeEvent(QCloseEvent *event) override; |
82 | void changeEvent(QEvent *event) override; |
83 | void showEvent(QShowEvent *event) override; |
84 | |
85 | protected Q_SLOTS: |
86 | void forceShow(); |
87 | |
88 | private: |
89 | Q_DISABLE_COPY(QProgressDialog) |
90 | |
91 | Q_PRIVATE_SLOT(d_func(), void _q_disconnectOnClose()) |
92 | }; |
93 | |
94 | QT_END_NAMESPACE |
95 | |
96 | #endif // QPROGRESSDIALOG_H |
97 | |