From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira --- src/widgets/dialogs/qprogressdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/dialogs/qprogressdialog.cpp') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index e1a6bce5b19..189dcd29892 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -492,7 +492,7 @@ void QProgressDialogPrivate::adoptChildWidget(QWidget *c) if (c->parentWidget() == q) c->hide(); // until after ensureSizeIsAtLeastSizeHint() else - c->setParent(q, 0); + c->setParent(q, { }); } ensureSizeIsAtLeastSizeHint(); if (c) -- cgit v1.2.3 From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/widgets/dialogs/qprogressdialog.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/widgets/dialogs/qprogressdialog.cpp') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 189dcd29892..94d3928c8b9 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -65,13 +65,13 @@ class QProgressDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QProgressDialog) public: - QProgressDialogPrivate() : label(0), cancel(0), bar(0), + QProgressDialogPrivate() : label(nullptr), cancel(nullptr), bar(nullptr), shown_once(false), cancellation_flag(false), setValue_called(false), showTime(defaultShowTime), #ifndef QT_NO_SHORTCUT - escapeShortcut(0), + escapeShortcut(nullptr), #endif useDefaultCancelText(false) { @@ -112,7 +112,7 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance label = new QLabel(labelText, q); bar = new QProgressBar(q); bar->setRange(min, max); - int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); + int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, nullptr, q); label->setAlignment(Qt::Alignment(align)); autoClose = true; autoReset = true; @@ -132,12 +132,12 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance void QProgressDialogPrivate::layout() { Q_Q(QProgressDialog); - int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, q); - int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q); - int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q)); - int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q)); + int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, nullptr, q); + int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q); + int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q)); + int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q)); const bool centered = - bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q)); + bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, nullptr, q)); int additionalSpacing = 0; QSize cs = cancel ? cancel->sizeHint() : QSize(0,0); @@ -188,7 +188,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose() if (receiverToDisconnectOnClose) { QObject::disconnect(q, SIGNAL(canceled()), receiverToDisconnectOnClose, memberToDisconnectOnClose); - receiverToDisconnectOnClose = 0; + receiverToDisconnectOnClose = nullptr; } memberToDisconnectOnClose.clear(); } @@ -418,7 +418,7 @@ void QProgressDialog::setCancelButton(QPushButton *cancelButton) } else { #ifndef QT_NO_SHORTCUT delete d->escapeShortcut; - d->escapeShortcut = 0; + d->escapeShortcut = nullptr; #endif } d->adoptChildWidget(cancelButton); @@ -450,7 +450,7 @@ void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText q->setCancelButton(new QPushButton(cancelButtonText, q)); } } else { - q->setCancelButton(0); + q->setCancelButton(nullptr); } ensureSizeIsAtLeastSizeHint(); } -- cgit v1.2.3 From da94625f38692365217b4647dd721fa5ea14c6ff Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 3 Dec 2019 16:11:37 +0100 Subject: Fix sizeHint of QProgressDialog to have enough space for window margins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø (cherry picked from commit 13bbb1d9b9411e6eb65848efa8c0d481109b8868) Reviewed-by: Volker Hilsheimer --- src/widgets/dialogs/qprogressdialog.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/widgets/dialogs/qprogressdialog.cpp') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index e1a6bce5b19..9507053ffec 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -708,14 +708,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 -- cgit v1.2.3