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

@hebasto
Copy link
Member

@hebasto hebasto commented Dec 26, 2018

Fix #15016.

Refs:

With this PR:
screenshot from 2018-12-26 22-01-30

@HashUnlimited
Copy link
Contributor

@HashUnlimited HashUnlimited 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
Copy link
Contributor

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

Copy link
Contributor

@donaloconnor donaloconnor left a comment

utACK 1f7ac92

@hebasto
Copy link
Member Author

@hebasto hebasto 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
Copy link
Contributor

@jonasschnelli jonasschnelli commented Jan 3, 2019

utACK 1f7ac92cf88ff7e6b10aaa49e174805a5823bfa2

@@ -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
Copy link
Member

@promag promag Jan 4, 2019

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
}

Copy link
Member Author

@hebasto hebasto Jan 5, 2019

Thank you @promag. Will do.

@hebasto hebasto force-pushed the 20181226-fix-macos-qprogressdialog branch from 1f7ac92 to ce89a5c Jan 5, 2019
@hebasto
Copy link
Member Author

@hebasto hebasto commented Jan 5, 2019

@promag your comment has been addressed.

Also a little of obvious code styling added.

progressDialog->setWindowModality(Qt::ApplicationModal);
progressDialog->setMinimumDuration(0);
progressDialog->setCancelButton(0);
Copy link
Member Author

@hebasto hebasto Jan 5, 2019

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

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

@DrahtBot
Copy link
Contributor

@DrahtBot DrahtBot 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 20181226-fix-macos-qprogressdialog branch from ce89a5c to 2b06881 Jan 14, 2019
@hebasto
Copy link
Member Author

@hebasto hebasto commented Jan 14, 2019

Rebased.

@promag would you mind re-reviewing?

Copy link
Member

@promag promag left a comment

utACK 2b06881, just 2 minor nits.

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

@promag promag Jan 14, 2019

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

#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());
Copy link
Member

@promag promag Jan 14, 2019

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

@hebasto hebasto force-pushed the 20181226-fix-macos-qprogressdialog branch from 2b06881 to 7c572c4 Jan 14, 2019
@hebasto
Copy link
Member Author

@hebasto hebasto commented Jan 14, 2019

@promag all nits are fixed.

@hebasto
Copy link
Member Author

@hebasto hebasto commented Jan 17, 2019

@Sjors would you mind reviewing this PR?

@Sjors
Copy link
Member

@Sjors Sjors commented Jan 17, 2019

tACK 7c572c4 on macOS 10.14.2

Copy link
Member

@promag promag left a comment

utACK 7c572c4.

@jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Jan 17, 2019

Tested ACK 7c572c4

@jonasschnelli jonasschnelli merged commit 7c572c4 into bitcoin:master Jan 17, 2019
2 checks passed
jonasschnelli added a commit that referenced this issue Jan 17, 2019
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 20181226-fix-macos-qprogressdialog branch Jan 17, 2019
@Sjors
Copy link
Member

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

deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Jul 16, 2020
Summary:
See: QTBUG-65750, QTBUG-70357.

---

Backport of Core [[bitcoin/bitcoin#15040 | PR15040]]

This apparently reapplies a nit fixed in D2144. I've chosen to stay close to the Core version for less merge headaches.

Test Plan: unfortunately I do not have a macOS in hand to test this

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D6957
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 21, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 23, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 24, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 24, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 24, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
UdjinM6 added a commit to UdjinM6/dash that referenced this issue Aug 24, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Munkybooty added a commit to Munkybooty/dash that referenced this issue Aug 24, 2021
7c572c4 Add workaround for QProgressDialog bug on macOS (Hennadii Stepanov)

Pull request description:

  Fix bitcoin#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants