QProgressDialog: Extract Method QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint()
The code was used in five different places, time to centralize. Change-Id: I32338bdae247169a180f59314c50a9b855cae5f0 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
869a8f51b1
commit
f74566e08b
@ -86,6 +86,7 @@ public:
|
|||||||
void retranslateStrings();
|
void retranslateStrings();
|
||||||
void setCancelButtonText(const QString &cancelButtonText);
|
void setCancelButtonText(const QString &cancelButtonText);
|
||||||
void adoptChildWidget(QWidget *c);
|
void adoptChildWidget(QWidget *c);
|
||||||
|
void ensureSizeIsAtLeastSizeHint();
|
||||||
void _q_disconnectOnClose();
|
void _q_disconnectOnClose();
|
||||||
|
|
||||||
QLabel *label;
|
QLabel *label;
|
||||||
@ -386,9 +387,7 @@ void QProgressDialog::setLabelText(const QString &text)
|
|||||||
Q_D(QProgressDialog);
|
Q_D(QProgressDialog);
|
||||||
if (d->label) {
|
if (d->label) {
|
||||||
d->label->setText(text);
|
d->label->setText(text);
|
||||||
int w = qMax(isVisible() ? width() : 0, sizeHint().width());
|
d->ensureSizeIsAtLeastSizeHint();
|
||||||
int h = qMax(isVisible() ? height() : 0, sizeHint().height());
|
|
||||||
resize(w, h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,9 +454,7 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText
|
|||||||
} else {
|
} else {
|
||||||
q->setCancelButton(0);
|
q->setCancelButton(0);
|
||||||
}
|
}
|
||||||
int w = qMax(q->isVisible() ? q->width() : 0, q->sizeHint().width());
|
ensureSizeIsAtLeastSizeHint();
|
||||||
int h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
|
|
||||||
q->resize(w, h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,15 +492,22 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c)
|
|||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
if (c->parentWidget() == q)
|
if (c->parentWidget() == q)
|
||||||
c->hide(); // until we resize
|
c->hide(); // until after ensureSizeIsAtLeastSizeHint()
|
||||||
else
|
else
|
||||||
c->setParent(q, 0);
|
c->setParent(q, 0);
|
||||||
}
|
}
|
||||||
|
ensureSizeIsAtLeastSizeHint();
|
||||||
|
if (c)
|
||||||
|
c->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint()
|
||||||
|
{
|
||||||
|
Q_Q(QProgressDialog);
|
||||||
|
|
||||||
int w = qMax(q->isVisible() ? q->width() : 0, q->sizeHint().width());
|
int w = qMax(q->isVisible() ? q->width() : 0, q->sizeHint().width());
|
||||||
int h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
|
int h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
|
||||||
q->resize(w, h);
|
q->resize(w, h);
|
||||||
if (c)
|
|
||||||
c->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -689,9 +693,7 @@ void QProgressDialog::setValue(int progress)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (need_show) {
|
if (need_show) {
|
||||||
int w = qMax(isVisible() ? width() : 0, sizeHint().width());
|
d->ensureSizeIsAtLeastSizeHint();
|
||||||
int h = qMax(isVisible() ? height() : 0, sizeHint().height());
|
|
||||||
resize(w, h);
|
|
||||||
show();
|
show();
|
||||||
d->shown_once = true;
|
d->shown_once = true;
|
||||||
}
|
}
|
||||||
@ -837,9 +839,7 @@ void QProgressDialog::showEvent(QShowEvent *e)
|
|||||||
{
|
{
|
||||||
Q_D(QProgressDialog);
|
Q_D(QProgressDialog);
|
||||||
QDialog::showEvent(e);
|
QDialog::showEvent(e);
|
||||||
int w = qMax(isVisible() ? width() : 0, sizeHint().width());
|
d->ensureSizeIsAtLeastSizeHint();
|
||||||
int h = qMax(isVisible() ? height() : 0, sizeHint().height());
|
|
||||||
resize(w, h);
|
|
||||||
d->forceTimer->stop();
|
d->forceTimer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user