| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
|---|
| 4 | ** Contact: https://www.qt.io/licensing/ | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial License Usage | 
|---|
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
|---|
| 11 | ** accordance with the commercial license agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
|---|
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
|---|
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
|---|
| 16 | ** | 
|---|
| 17 | ** GNU Lesser General Public License Usage | 
|---|
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 19 | ** General Public License version 3 as published by the Free Software | 
|---|
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
|---|
| 21 | ** packaging of this file. Please review the following information to | 
|---|
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
|---|
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
|---|
| 24 | ** | 
|---|
| 25 | ** GNU General Public License Usage | 
|---|
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
|---|
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
|---|
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
|---|
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
|---|
| 31 | ** included in the packaging of this file. Please review the following | 
|---|
| 32 | ** information to ensure the GNU General Public License requirements will | 
|---|
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
|---|
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** $QT_END_LICENSE$ | 
|---|
| 37 | ** | 
|---|
| 38 | ****************************************************************************/ | 
|---|
| 39 |  | 
|---|
| 40 | #ifndef QPROGRESSDIALOG_H | 
|---|
| 41 | #define QPROGRESSDIALOG_H | 
|---|
| 42 |  | 
|---|
| 43 | #include <QtWidgets/qtwidgetsglobal.h> | 
|---|
| 44 |  | 
|---|
| 45 | #include <QtWidgets/qdialog.h> | 
|---|
| 46 |  | 
|---|
| 47 | QT_REQUIRE_CONFIG(progressdialog); | 
|---|
| 48 |  | 
|---|
| 49 | QT_BEGIN_NAMESPACE | 
|---|
| 50 |  | 
|---|
| 51 | class QPushButton; | 
|---|
| 52 | class QLabel; | 
|---|
| 53 | class QProgressBar; | 
|---|
| 54 | class QTimer; | 
|---|
| 55 | class QProgressDialogPrivate; | 
|---|
| 56 |  | 
|---|
| 57 | class Q_WIDGETS_EXPORT QProgressDialog : public QDialog | 
|---|
| 58 | { | 
|---|
| 59 | Q_OBJECT | 
|---|
| 60 | Q_DECLARE_PRIVATE(QProgressDialog) | 
|---|
| 61 | Q_PROPERTY(bool wasCanceled READ wasCanceled) | 
|---|
| 62 | Q_PROPERTY(int minimum READ minimum WRITE setMinimum) | 
|---|
| 63 | Q_PROPERTY(int maximum READ maximum WRITE setMaximum) | 
|---|
| 64 | Q_PROPERTY(int value READ value WRITE setValue) | 
|---|
| 65 | Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset) | 
|---|
| 66 | Q_PROPERTY(bool autoClose READ autoClose WRITE setAutoClose) | 
|---|
| 67 | Q_PROPERTY(int minimumDuration READ minimumDuration WRITE setMinimumDuration) | 
|---|
| 68 | Q_PROPERTY(QString labelText READ labelText WRITE setLabelText) | 
|---|
| 69 |  | 
|---|
| 70 | public: | 
|---|
| 71 | explicit QProgressDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); | 
|---|
| 72 | QProgressDialog(const QString &labelText, const QString &cancelButtonText, | 
|---|
| 73 | int minimum, int maximum, QWidget *parent = nullptr, | 
|---|
| 74 | Qt::WindowFlags flags = Qt::WindowFlags()); | 
|---|
| 75 | ~QProgressDialog(); | 
|---|
| 76 |  | 
|---|
| 77 | void setLabel(QLabel *label); | 
|---|
| 78 | void setCancelButton(QPushButton *button); | 
|---|
| 79 | void setBar(QProgressBar *bar); | 
|---|
| 80 |  | 
|---|
| 81 | bool wasCanceled() const; | 
|---|
| 82 |  | 
|---|
| 83 | int minimum() const; | 
|---|
| 84 | int maximum() const; | 
|---|
| 85 |  | 
|---|
| 86 | int value() const; | 
|---|
| 87 |  | 
|---|
| 88 | QSize sizeHint() const override; | 
|---|
| 89 |  | 
|---|
| 90 | QString labelText() const; | 
|---|
| 91 | int minimumDuration() const; | 
|---|
| 92 |  | 
|---|
| 93 | void setAutoReset(bool reset); | 
|---|
| 94 | bool autoReset() const; | 
|---|
| 95 | void setAutoClose(bool close); | 
|---|
| 96 | bool autoClose() const; | 
|---|
| 97 |  | 
|---|
| 98 | using QDialog::open; | 
|---|
| 99 | void open(QObject *receiver, const char *member); | 
|---|
| 100 |  | 
|---|
| 101 | public Q_SLOTS: | 
|---|
| 102 | void cancel(); | 
|---|
| 103 | void reset(); | 
|---|
| 104 | void setMaximum(int maximum); | 
|---|
| 105 | void setMinimum(int minimum); | 
|---|
| 106 | void setRange(int minimum, int maximum); | 
|---|
| 107 | void setValue(int progress); | 
|---|
| 108 | void setLabelText(const QString &text); | 
|---|
| 109 | void setCancelButtonText(const QString &text); | 
|---|
| 110 | void setMinimumDuration(int ms); | 
|---|
| 111 |  | 
|---|
| 112 | Q_SIGNALS: | 
|---|
| 113 | void canceled(); | 
|---|
| 114 |  | 
|---|
| 115 | protected: | 
|---|
| 116 | void resizeEvent(QResizeEvent *event) override; | 
|---|
| 117 | void closeEvent(QCloseEvent *event) override; | 
|---|
| 118 | void changeEvent(QEvent *event) override; | 
|---|
| 119 | void showEvent(QShowEvent *event) override; | 
|---|
| 120 |  | 
|---|
| 121 | protected Q_SLOTS: | 
|---|
| 122 | void forceShow(); | 
|---|
| 123 |  | 
|---|
| 124 | private: | 
|---|
| 125 | Q_DISABLE_COPY(QProgressDialog) | 
|---|
| 126 |  | 
|---|
| 127 | Q_PRIVATE_SLOT(d_func(), void _q_disconnectOnClose()) | 
|---|
| 128 | }; | 
|---|
| 129 |  | 
|---|
| 130 | QT_END_NAMESPACE | 
|---|
| 131 |  | 
|---|
| 132 | #endif // QPROGRESSDIALOG_H | 
|---|
| 133 |  | 
|---|