summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2019-12-03 16:11:37 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2019-12-03 17:05:57 +0100
commit13bbb1d9b9411e6eb65848efa8c0d481109b8868 (patch)
treea184840a0fc479ae1dd43972bc91f8829881a138 /src
parent6cddd0e8cf539fe5efa36d2b7429e6baaffaa809 (diff)
Fix sizeHint of QProgressDialog to have enough space for window margins
Some styles, notably QMacStyle, use different margins for widgets and for windows. For these margins to be returned correctly, we have to tell the style that we want them for a toplevel widget. This was done correctly when laying out the dialog, but not when calculating the sizeHint, leading to a default size of the dialog that was too small to fit the text. As a drive-by, change variable names in the sizeHint method to be a bit more readable. Change-Id: Ib4168c7be176fa816241ebcc5f9235db4a7f982f Fixes: QTBUG-80272 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index e1fb1055ae..38e506a857 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -718,14 +718,17 @@ void QProgressDialog::setValue(int progress)
QSize QProgressDialog::sizeHint() const
{
Q_D(const QProgressDialog);
- QSize sh = d->label ? d->label->sizeHint() : QSize(0, 0);
- QSize bh = d->bar->sizeHint();
- int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
- int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
- int h = margin * 2 + bh.height() + sh.height() + spacing;
+ QSize labelSize = d->label ? d->label->sizeHint() : QSize(0, 0);
+ QSize barSize = d->bar->sizeHint();
+ int marginBottom = style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, this);
+ int spacing = style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, this);
+ int marginLeft = style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, this);
+ int marginRight = style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, this);
+
+ int height = marginBottom * 2 + barSize.height() + labelSize.height() + spacing;
if (d->cancel)
- h += d->cancel->sizeHint().height() + spacing;
- return QSize(qMax(200, sh.width() + 2 * margin), h);
+ height += d->cancel->sizeHint().height() + spacing;
+ return QSize(qMax(200, labelSize.width() + marginLeft + marginRight), height);
}
/*!\reimp