Group, cleanup, and consolidate QProgressDialogPrivate member variables
Members grouped and reordered for better alignment, all booleans initialized in the constructor's member initialization list, and snake case names changed to camel case for consistency. Change-Id: Ib59ed770a3d4e307296722270cd991a9a53c72ce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
c82f73666d
commit
041868964d
@ -69,14 +69,17 @@ class QProgressDialogPrivate : public QDialogPrivate
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QProgressDialogPrivate() : label(nullptr), cancel(nullptr), bar(nullptr),
|
QProgressDialogPrivate() : label(nullptr), cancel(nullptr), bar(nullptr),
|
||||||
shown_once(false),
|
#ifndef QT_NO_SHORTCUT
|
||||||
cancellation_flag(false),
|
|
||||||
setValue_called(false),
|
|
||||||
processingEvents(false),
|
|
||||||
showTime(defaultShowTime),
|
|
||||||
#ifndef QT_NO_SHORTCUT
|
|
||||||
escapeShortcut(nullptr),
|
escapeShortcut(nullptr),
|
||||||
#endif
|
#endif
|
||||||
|
showTime(defaultShowTime),
|
||||||
|
processingEvents(false),
|
||||||
|
shownOnce(false),
|
||||||
|
autoClose(true),
|
||||||
|
autoReset(true),
|
||||||
|
forceHide(false),
|
||||||
|
cancellationFlag(false),
|
||||||
|
setValueCalled(false),
|
||||||
useDefaultCancelText(false)
|
useDefaultCancelText(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -93,21 +96,21 @@ public:
|
|||||||
QPushButton *cancel;
|
QPushButton *cancel;
|
||||||
QProgressBar *bar;
|
QProgressBar *bar;
|
||||||
QTimer *forceTimer;
|
QTimer *forceTimer;
|
||||||
bool shown_once;
|
|
||||||
bool cancellation_flag;
|
|
||||||
bool setValue_called;
|
|
||||||
bool processingEvents;
|
|
||||||
QElapsedTimer starttime;
|
|
||||||
int showTime;
|
|
||||||
bool autoClose;
|
|
||||||
bool autoReset;
|
|
||||||
bool forceHide;
|
|
||||||
#ifndef QT_NO_SHORTCUT
|
#ifndef QT_NO_SHORTCUT
|
||||||
QShortcut *escapeShortcut;
|
QShortcut *escapeShortcut;
|
||||||
#endif
|
#endif
|
||||||
bool useDefaultCancelText;
|
|
||||||
QPointer<QObject> receiverToDisconnectOnClose;
|
QPointer<QObject> receiverToDisconnectOnClose;
|
||||||
|
QElapsedTimer starttime;
|
||||||
QByteArray memberToDisconnectOnClose;
|
QByteArray memberToDisconnectOnClose;
|
||||||
|
int showTime;
|
||||||
|
bool processingEvents;
|
||||||
|
bool shownOnce;
|
||||||
|
bool autoClose;
|
||||||
|
bool autoReset;
|
||||||
|
bool forceHide;
|
||||||
|
bool cancellationFlag;
|
||||||
|
bool setValueCalled;
|
||||||
|
bool useDefaultCancelText;
|
||||||
};
|
};
|
||||||
|
|
||||||
void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText,
|
void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText,
|
||||||
@ -119,9 +122,6 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance
|
|||||||
bar->setRange(min, max);
|
bar->setRange(min, max);
|
||||||
int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, nullptr, q);
|
int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, nullptr, q);
|
||||||
label->setAlignment(Qt::Alignment(align));
|
label->setAlignment(Qt::Alignment(align));
|
||||||
autoClose = true;
|
|
||||||
autoReset = true;
|
|
||||||
forceHide = false;
|
|
||||||
QObject::connect(q, SIGNAL(canceled()), q, SLOT(cancel()));
|
QObject::connect(q, SIGNAL(canceled()), q, SLOT(cancel()));
|
||||||
forceTimer = new QTimer(q);
|
forceTimer = new QTimer(q);
|
||||||
QObject::connect(forceTimer, SIGNAL(timeout()), q, SLOT(forceShow()));
|
QObject::connect(forceTimer, SIGNAL(timeout()), q, SLOT(forceShow()));
|
||||||
@ -523,7 +523,7 @@ void QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint()
|
|||||||
bool QProgressDialog::wasCanceled() const
|
bool QProgressDialog::wasCanceled() const
|
||||||
{
|
{
|
||||||
Q_D(const QProgressDialog);
|
Q_D(const QProgressDialog);
|
||||||
return d->cancellation_flag;
|
return d->cancellationFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -601,9 +601,9 @@ void QProgressDialog::reset()
|
|||||||
if (d->autoClose || d->forceHide)
|
if (d->autoClose || d->forceHide)
|
||||||
hide();
|
hide();
|
||||||
d->bar->reset();
|
d->bar->reset();
|
||||||
d->cancellation_flag = false;
|
d->cancellationFlag = false;
|
||||||
d->shown_once = false;
|
d->shownOnce = false;
|
||||||
d->setValue_called = false;
|
d->setValueCalled = false;
|
||||||
d->forceTimer->stop();
|
d->forceTimer->stop();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -627,7 +627,7 @@ void QProgressDialog::cancel()
|
|||||||
d->forceHide = true;
|
d->forceHide = true;
|
||||||
reset();
|
reset();
|
||||||
d->forceHide = false;
|
d->forceHide = false;
|
||||||
d->cancellation_flag = true;
|
d->cancellationFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -657,24 +657,24 @@ int QProgressDialog::value() const
|
|||||||
void QProgressDialog::setValue(int progress)
|
void QProgressDialog::setValue(int progress)
|
||||||
{
|
{
|
||||||
Q_D(QProgressDialog);
|
Q_D(QProgressDialog);
|
||||||
if (d->setValue_called && progress == d->bar->value())
|
if (d->setValueCalled && progress == d->bar->value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
d->bar->setValue(progress);
|
d->bar->setValue(progress);
|
||||||
|
|
||||||
if (d->shown_once) {
|
if (d->shownOnce) {
|
||||||
if (isModal() && !d->processingEvents) {
|
if (isModal() && !d->processingEvents) {
|
||||||
const QScopedValueRollback guard(d->processingEvents, true);
|
const QScopedValueRollback guard(d->processingEvents, true);
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((!d->setValue_called && progress == 0 /* for compat with Qt < 5.4 */) || progress == minimum()) {
|
if ((!d->setValueCalled && progress == 0 /* for compat with Qt < 5.4 */) || progress == minimum()) {
|
||||||
d->starttime.start();
|
d->starttime.start();
|
||||||
d->forceTimer->start(d->showTime);
|
d->forceTimer->start(d->showTime);
|
||||||
d->setValue_called = true;
|
d->setValueCalled = true;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
d->setValue_called = true;
|
d->setValueCalled = true;
|
||||||
bool need_show;
|
bool need_show;
|
||||||
int elapsed = d->starttime.elapsed();
|
int elapsed = d->starttime.elapsed();
|
||||||
if (elapsed >= d->showTime) {
|
if (elapsed >= d->showTime) {
|
||||||
@ -697,7 +697,7 @@ void QProgressDialog::setValue(int progress)
|
|||||||
if (need_show) {
|
if (need_show) {
|
||||||
d->ensureSizeIsAtLeastSizeHint();
|
d->ensureSizeIsAtLeastSizeHint();
|
||||||
show();
|
show();
|
||||||
d->shown_once = true;
|
d->shownOnce = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -856,11 +856,11 @@ void QProgressDialog::forceShow()
|
|||||||
{
|
{
|
||||||
Q_D(QProgressDialog);
|
Q_D(QProgressDialog);
|
||||||
d->forceTimer->stop();
|
d->forceTimer->stop();
|
||||||
if (d->shown_once || d->cancellation_flag)
|
if (d->shownOnce || d->cancellationFlag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
show();
|
show();
|
||||||
d->shown_once = true;
|
d->shownOnce = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user