44 #ifndef QT_NO_PROGRESSDIALOG 57 #include <private/qdialog_p.h> 60 #if defined(QT_SOFTKEYS_ENABLED) 64 #include <QtGui/qdesktopwidget.h> 88 #ifdef QT_SOFTKEYS_ENABLED
114 #ifndef QT_NO_SHORTCUT 117 #ifdef QT_SOFTKEYS_ENABLED 143 q->setCancelButtonText(cancelText);
152 int mlr =
qMin(q->width() / 10, mtb);
153 const bool centered =
156 int additionalSpacing = 0;
160 additionalSpacing = mlr;
170 for (
int attempt=5; attempt--;) {
172 lh =
qMax(0, q->height() - mtb - bh.
height() - sp - cspc);
174 if (lh < q->height()/4) {
189 centered ? q->width()/2 - cs.
width()/2 : q->width() - mlr - cs.
width(),
190 q->height() - mtb - cs.
height(),
312 d->useDefaultCancelText =
true;
339 const QString &cancelButtonText,
345 d->init(labelText, cancelButtonText, minimum, maximum);
412 return d->label->text();
420 d->label->setText(text);
442 d->cancel = cancelButton;
445 cancelButton->
hide();
450 #ifndef QT_NO_SHORTCUT 454 #ifndef QT_NO_SHORTCUT 455 delete d->escapeShortcut;
456 d->escapeShortcut = 0;
463 #if !defined(QT_SOFTKEYS_ENABLED) 464 cancelButton->
show();
467 d->cancelAction =
new QAction(cancelButton->
text(), cancelButton);
486 d->useDefaultCancelText =
false;
488 if (!cancelButtonText.
isNull()) {
490 d->cancel->setText(cancelButtonText);
491 #ifdef QT_SOFTKEYS_ENABLED 492 d->cancelAction->setText(cancelButtonText);
517 qWarning(
"QProgressDialog::setBar: Cannot set a null progress bar");
522 qWarning(
"QProgressDialog::setBar: Cannot set a new progress bar " 523 "while the old one is active");
544 return d->cancellation_flag;
563 return d->bar->maximum();
569 d->bar->setMaximum(maximum);
587 return d->bar->minimum();
593 d->bar->setMinimum(minimum);
611 d->bar->setRange(minimum, maximum);
631 if (
d->autoClose ||
d->forceHide)
634 d->cancellation_flag =
false;
635 d->shown_once =
false;
636 d->forceTimer->stop();
643 if (
d->receiverToDisconnectOnClose)
658 d->forceHide =
false;
659 d->cancellation_flag =
true;
666 return d->bar->value();
692 if (progress ==
d->bar->value()
693 || (
d->bar->value() == -1 && progress ==
d->bar->maximum()))
696 d->bar->setValue(progress);
703 d->starttime.start();
704 d->forceTimer->start(
d->showTime);
708 int elapsed =
d->starttime.elapsed();
709 if (elapsed >=
d->showTime) {
715 int myprogress = progress -
minimum();
716 if (myprogress == 0) myprogress = 1;
717 if ((totalSteps - myprogress) >=
INT_MAX / elapsed)
718 estimate = (totalSteps - myprogress) / myprogress * elapsed;
720 estimate = elapsed * (totalSteps - myprogress) / myprogress;
721 need_show = estimate >=
d->showTime;
731 d->shown_once =
true;
739 if (progress ==
d->bar->maximum() &&
d->autoReset)
752 QSize sh =
d->label ?
d->label->sizeHint() :
QSize(0, 0);
753 QSize bh =
d->bar->sizeHint();
756 int h = margin * 2 + bh.
height() + sh.
height() + spacing;
758 h +=
d->cancel->sizeHint().height() + spacing;
786 d->retranslateStrings();
812 if (
d->bar->value() == 0) {
813 d->forceTimer->stop();
814 d->forceTimer->start(ms);
894 d->forceTimer->stop();
907 d->forceTimer->stop();
908 if (
d->shown_once ||
d->cancellation_flag)
912 d->shown_once =
true;
931 d->receiverToDisconnectOnClose = receiver;
932 d->memberToDisconnectOnClose = member;
938 #include "moc_qprogressdialog.cpp" 940 #endif // QT_NO_PROGRESSDIALOG
void setLabel(QLabel *label)
Sets the label to label.
The QCursor class provides a mouse cursor with an arbitrary shape.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
static double elapsed(qint64 after, qint64 before)
#define QT_END_NAMESPACE
This macro expands to.
~QProgressDialog()
Destroys the progress dialog.
static const int defaultShowTime
The QDialog class is the base class of dialog windows.
void closeEvent(QCloseEvent *event)
Reimplemented Function
bool useDefaultCancelText
int minimumDuration() const
QByteArray memberToDisconnectOnClose
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
void cancel()
Resets the progress dialog.
The QByteArray class provides an array of bytes.
void forceShow()
Shows the dialog if it is still hidden after the algorithm has been started and minimumDuration milli...
QProgressDialog(QWidget *parent=0, Qt::WindowFlags flags=0)
Constructs a progress dialog.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QSize sizeHint() const
Reimplemented Function
void reset()
Resets the progress dialog.
void changeEvent(QEvent *event)
Reimplemented Function
static const int minWaitTime
QSize sizeHint() const
Returns a size that fits the contents of the progress dialog.
void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
The QProgressBar widget provides a horizontal or vertical progress bar.
The QString class provides a Unicode character string.
void setHeight(int h)
Sets the height to the given height.
The QObject class is the base class of all Qt objects.
The QElapsedTimer class provides a fast way to calculate elapsed times.
void setAutoClose(bool close)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
The QShortcut class is used to create keyboard shortcuts.
int width() const
Returns the width.
void setValue(int progress)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void closeEvent(QCloseEvent *)
Reimplemented Function
The QResizeEvent class contains event parameters for resize events.
Q_CORE_EXPORT void qWarning(const char *,...)
void init(const QString &labelText, const QString &cancelText, int min, int max)
void setBar(QProgressBar *bar)
Sets the progress bar widget to bar.
The QShowEvent class provides an event that is sent when a widget is shown.
void setLabelText(const QString &text)
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
bool isNull() const
Returns true if this string is null; otherwise returns false.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
void setRange(int minimum, int maximum)
Sets the progress bar's minimum and maximum values to minimum and maximum respectively.
#define Q_DECLARE_PUBLIC(Class)
void _q_disconnectOnClose()
QShortcut * escapeShortcut
QPointer< QObject > receiverToDisconnectOnClose
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
void setRange(int minimum, int maximum)
Sets the progress dialog's minimum and maximum values to minimum and maximum, respectively.
The QProgressDialog class provides feedback on the progress of a slow operation.
void setCancelButtonText(const QString &text)
Sets the cancel button's text to cancelButtonText.
QObject * parent() const
Returns a pointer to the parent object.
QString labelText() const
int height() const
Returns the height.
void resizeEvent(QResizeEvent *event)
Reimplemented Function
The QLabel widget provides a text or image display.
void setAutoReset(bool reset)
void setMaximum(int maximum)
void open()
Shows the dialog as a window modal dialog, returning immediately.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QTimer class provides repetitive and single-shot timers.
void showEvent(QShowEvent *event)
Reimplemented Function
void setMinimumDuration(int ms)
void setCancelButton(QPushButton *button)
Sets the cancel button to the push button, cancelButton.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
void retranslateStrings()
void setAlignment(Qt::Alignment)
Without this function, a call to e.
The QCloseEvent class contains parameters that describe a close event.
void canceled()
This signal is emitted when the cancel button is clicked.
void setMinimum(int minimum)
void clear()
Clears the contents of the byte array and makes it empty.
The QAction class provides an abstract user interface action that can be inserted into widgets...
static void flush()
Flushes the platform specific event queues.