summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-30 13:00:30 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-08-06 14:56:36 +0200
commitf74566e08b38d11f2119daa145eda0c19f1d725b (patch)
tree3dc54396acff7e9777b60aeaab3bde62d5b5eb98 /src/widgets/dialogs
parent869a8f51b102566179c12474be0a40042c63aabb (diff)
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>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 4a7ee41090..4a2b5cbea9 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -86,6 +86,7 @@ public:
void retranslateStrings();
void setCancelButtonText(const QString &cancelButtonText);
void adoptChildWidget(QWidget *c);
+ void ensureSizeIsAtLeastSizeHint();
void _q_disconnectOnClose();
QLabel *label;
@@ -386,9 +387,7 @@ void QProgressDialog::setLabelText(const QString &text)
Q_D(QProgressDialog);
if (d->label) {
d->label->setText(text);
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
+ d->ensureSizeIsAtLeastSizeHint();
}
}
@@ -455,9 +454,7 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText
} else {
q->setCancelButton(0);
}
- int w = qMax(q->isVisible() ? q->width() : 0, q->sizeHint().width());
- int h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
- q->resize(w, h);
+ ensureSizeIsAtLeastSizeHint();
}
@@ -495,15 +492,22 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c)
if (c) {
if (c->parentWidget() == q)
- c->hide(); // until we resize
+ c->hide(); // until after ensureSizeIsAtLeastSizeHint()
else
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 h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
q->resize(w, h);
- if (c)
- c->show();
}
@@ -689,9 +693,7 @@ void QProgressDialog::setValue(int progress)
}
}
if (need_show) {
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
+ d->ensureSizeIsAtLeastSizeHint();
show();
d->shown_once = true;
}
@@ -837,9 +839,7 @@ void QProgressDialog::showEvent(QShowEvent *e)
{
Q_D(QProgressDialog);
QDialog::showEvent(e);
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
+ d->ensureSizeIsAtLeastSizeHint();
d->forceTimer->stop();
}