Fix #15016.
Refs:
- QTBUG-65750: QProgressDialog too small width at larger font size on Mac
- QTBUG-70357: QProgressDialog is too narrow to fit the text of its label
With this PR:

As a workaround this seems to work for the specific case, tried with extra long wallet names.
Thanks for the links btw, out of curiosity I have also tried to apply the same to a different project where Qt's dialog margins are overruled by style sheets - no effect there (this just for info).
Thanks for the fix... But isn't it possible to add a QLayout and have the dialogue autoresize like other windows? However, this seems to work as well.
@jonasschnelli Thank you for your review.
But isn't it possible to add a QLayout and have the dialogue autoresize like other windows?
Yes, it is possible to do something like this:
QLabel* label = new QLabel(title);
progressDialog->setLabel(label);
QProgressBar* bar = new QProgressBar;
progressDialog->setBar(bar);
QPushButton* cancel_button = new QPushButton(tr("Cancel"));
progressDialog->setCancelButton(cancel_button);
QHBoxLayout* h_layout = new QHBoxLayout;
h_layout->addStretch();
h_layout->addWidget(cancel_button);
QVBoxLayout* v_layout = new QVBoxLayout;
v_layout->addWidget(label);
v_layout->addWidget(bar);
v_layout->addLayout(h_layout);
progressDialog->setLayout(v_layout);
But such implementation introduces new issues: e.g., content margins of QLayout are ignored on resize event on Linux.
Is it better to make 3-lines-of-code workaround and just wait when buggy QProgressDialog get fixed by Qt?
utACK 1f7ac92cf88ff7e6b10aaa49e174805a5823bfa2
1242 | @@ -1242,6 +1243,12 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress) 1243 | if (nProgress == 0) 1244 | { 1245 | progressDialog = new QProgressDialog(title, "", 0, 100); 1246 | +#ifdef Q_OS_MAC
Move the implementation to something like:
void GUIUtil::PolishProgressDialog(QProgressDialog* dialog)
{
#ifdef Q_OS_MAC
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
const int margin = (dialog->fontMetrics()).width("X");
progressDialog->resize(dialog->width() + (2 * margin), progressDialog->height());
#else
Q_UNUSED(dialog);
#endif
}
1245 | + if (nProgress == 0) { 1246 | + progressDialog = new QProgressDialog(title, QString(), 0, 100); 1247 | + GUIUtil::PolishProgressDialog(progressDialog); 1248 | progressDialog->setWindowModality(Qt::ApplicationModal); 1249 | progressDialog->setMinimumDuration(0); 1250 | - progressDialog->setCancelButton(0);
Note for reviewers. QProgressDialog::QProgressDialog() docs:
If QString() is passed then no cancel button is shown.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
934 | @@ -933,4 +935,16 @@ bool ItemDelegate::eventFilter(QObject *object, QEvent *event) 935 | return QItemDelegate::eventFilter(object, event); 936 | } 937 | 938 | +void PolishProgressDialog(QProgressDialog* dialog) 939 | +{ 940 | +#ifdef Q_OS_MAC 941 | + // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357. 942 | + const int margin = (dialog->fontMetrics()).width("X");
nit const int margin = dialog->fontMetrics().width("X");
934 | @@ -933,4 +935,16 @@ bool ItemDelegate::eventFilter(QObject *object, QEvent *event) 935 | return QItemDelegate::eventFilter(object, event); 936 | } 937 | 938 | +void PolishProgressDialog(QProgressDialog* dialog) 939 | +{ 940 | +#ifdef Q_OS_MAC 941 | + // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357. 942 | + const int margin = (dialog->fontMetrics()).width("X"); 943 | + dialog->resize(dialog->width() + (2 * margin), dialog->height());
nit, dialog->width() + 2 * margin.
utACK 2b06881, just 2 minor nits.
See: QTBUG-65750, QTBUG-70357.
tACK 7c572c4 on macOS 10.14.2
utACK 7c572c4.
Tested ACK 7c572c488dcf84438d64da4ca920a48810044a72
@HashUnlimited that's probably too much OS-specific customisation. I don't think the benefits of that feature would outweigh the cost of maintaining it. Feel free to make a Github issue with that feature suggestion if you feel strongly about it though.