Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt: Add workaround for QProgressDialog bug on macOS #15040

Merged

Conversation

Projects
None yet
8 participants

@fanquake fanquake added the GUI label Dec 26, 2018

@HashUnlimited

This comment has been minimized.

Copy link
Contributor

commented Dec 27, 2018

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).

@jonasschnelli

This comment has been minimized.

Copy link
Member

commented Dec 30, 2018

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.

@donaloconnor
Copy link
Contributor

left a comment

utACK 1f7ac92

@hebasto

This comment has been minimized.

Copy link
Member Author

commented Jan 1, 2019

@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?

@jonasschnelli

This comment has been minimized.

Copy link
Member

commented Jan 3, 2019

utACK 1f7ac92cf88ff7e6b10aaa49e174805a5823bfa2

src/qt/bitcoingui.cpp Outdated
@@ -1242,6 +1243,12 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
if (nProgress == 0)
{
progressDialog = new QProgressDialog(title, "", 0, 100);
#ifdef Q_OS_MAC

This comment has been minimized.

Copy link
@promag

promag Jan 4, 2019

Member

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
}

This comment has been minimized.

Copy link
@hebasto

hebasto Jan 5, 2019

Author Member

Thank you @promag. Will do.

@hebasto hebasto force-pushed the hebasto:20181226-fix-macos-qprogressdialog branch Jan 5, 2019

@hebasto

This comment has been minimized.

Copy link
Member Author

commented Jan 5, 2019

@promag your comment has been addressed.

Also a little of obvious code styling added.

src/qt/bitcoingui.cpp Outdated
progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);

This comment has been minimized.

Copy link
@hebasto

hebasto Jan 5, 2019

Author Member

Note for reviewers. QProgressDialog::QProgressDialog() docs:

If QString() is passed then no cancel button is shown.

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Jan 9, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@hebasto hebasto force-pushed the hebasto:20181226-fix-macos-qprogressdialog branch Jan 14, 2019

@hebasto

This comment has been minimized.

Copy link
Member Author

commented Jan 14, 2019

Rebased.

@promag would you mind re-reviewing?

@DrahtBot DrahtBot removed the Needs rebase label Jan 14, 2019

@promag
Copy link
Member

left a comment

utACK 2b06881, just 2 minor nits.

src/qt/guiutil.cpp Outdated
{
#ifdef Q_OS_MAC
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
const int margin = (dialog->fontMetrics()).width("X");

This comment has been minimized.

Copy link
@promag

promag Jan 14, 2019

Member

nit const int margin = dialog->fontMetrics().width("X");

src/qt/guiutil.cpp Outdated
#ifdef Q_OS_MAC
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
const int margin = (dialog->fontMetrics()).width("X");
dialog->resize(dialog->width() + (2 * margin), dialog->height());

This comment has been minimized.

Copy link
@promag

promag Jan 14, 2019

Member

nit, dialog->width() + 2 * margin.

Add workaround for QProgressDialog bug on macOS
See: QTBUG-65750, QTBUG-70357.

@hebasto hebasto force-pushed the hebasto:20181226-fix-macos-qprogressdialog branch to 7c572c4 Jan 14, 2019

@hebasto

This comment has been minimized.

Copy link
Member Author

commented Jan 14, 2019

@promag all nits are fixed.

@hebasto

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

@Sjors would you mind reviewing this PR?

@Sjors

This comment has been minimized.

Copy link
Member

commented Jan 17, 2019

tACK 7c572c4 on macOS 10.14.2

@promag
Copy link
Member

left a comment

utACK 7c572c4.

@jonasschnelli

This comment has been minimized.

Copy link
Member

commented Jan 17, 2019

Tested ACK 7c572c4

@jonasschnelli jonasschnelli merged commit 7c572c4 into bitcoin:master Jan 17, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

jonasschnelli added a commit that referenced this pull request Jan 17, 2019

Merge #15040: qt: Add workaround for QProgressDialog bug on macOS
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix #15016.

  Refs:
  - [QTBUG-65750: QProgressDialog too small width at larger font size on Mac](https://bugreports.qt.io/browse/QTBUG-65750)
  - [QTBUG-70357: QProgressDialog is too narrow to fit the text of its label](https://bugreports.qt.io/browse/QTBUG-70357)

  With this PR:
  ![screenshot from 2018-12-26 22-01-30](https://user-images.githubusercontent.com/32963518/50456571-1aa35b80-095e-11e9-8442-c285555f2bee.png)

Tree-SHA512: dde668dfa7d2144973c0e868aea7fdb7d90f78584836d024ffefb8df4a709d6842fa3601954759b4462856a80e81df15b861ea39506599230a16928b621d9f8f

@hebasto hebasto deleted the hebasto:20181226-fix-macos-qprogressdialog branch Jan 17, 2019

@Sjors

This comment has been minimized.

Copy link
Member

commented Jan 18, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.