From 75850106aeecfed1d2dc16d8a67ec210c5826a47 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 22 May 2021 21:20:06 +0300 Subject: [PATCH 1/2] qt, macos: Fix GUIUtil::PolishProgressDialog bug QProgressDialog shows itself if the estimated time an operation will take is beyond the minimumDuration value. Direct call show() breaks that behavior on macos. --- src/qt/guiutil.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 4691937380c..d21f9074e78 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -818,7 +818,6 @@ void PolishProgressDialog(QProgressDialog* dialog) // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357. const int margin = TextWidth(dialog->fontMetrics(), ("X")); dialog->resize(dialog->width() + 2 * margin, dialog->height()); - dialog->show(); #else Q_UNUSED(dialog); #endif From 4935ac583bbdc289dd31a1caae3d711edef742b6 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 22 May 2021 21:32:51 +0300 Subject: [PATCH 2/2] qt: Improve GUI responsiveness QProgressDialog estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond minimumDuration. The default minimumDuration value is 4 seconds, and it could make users think that the GUI is frozen. --- src/qt/bitcoingui.cpp | 1 - src/qt/guiutil.cpp | 7 +++++-- src/qt/walletcontroller.cpp | 3 +++ src/qt/walletview.cpp | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 17fffe20877..53a0d400187 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1375,7 +1375,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress) progressDialog = new QProgressDialog(title, QString(), 0, 100); GUIUtil::PolishProgressDialog(progressDialog); progressDialog->setWindowModality(Qt::ApplicationModal); - progressDialog->setMinimumDuration(0); progressDialog->setAutoClose(false); progressDialog->setValue(0); } else if (nProgress == 100) { diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index d21f9074e78..534680ffa53 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -818,9 +818,12 @@ void PolishProgressDialog(QProgressDialog* dialog) // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357. const int margin = TextWidth(dialog->fontMetrics(), ("X")); dialog->resize(dialog->width() + 2 * margin, dialog->height()); -#else - Q_UNUSED(dialog); #endif + // QProgressDialog estimates the time the operation will take (based on time + // for steps), and only shows itself if that estimate is beyond minimumDuration. + // The default minimumDuration value is 4 seconds, and it could make users + // think that the GUI is frozen. + dialog->setMinimumDuration(0); } int TextWidth(const QFontMetrics& fm, const QString& text) diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index c152689f0be..aa26a01541a 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -207,6 +207,9 @@ void WalletControllerActivity::showProgressDialog(const QString& label_text) m_progress_dialog->setCancelButton(nullptr); m_progress_dialog->setWindowModality(Qt::ApplicationModal); GUIUtil::PolishProgressDialog(m_progress_dialog); + // The setValue call forces QProgressDialog to start the internal duration estimation. + // See details in https://bugreports.qt.io/browse/QTBUG-47042. + m_progress_dialog->setValue(0); } void WalletControllerActivity::destroyProgressDialog() diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 67cc42725b5..62bf706adef 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -330,7 +330,6 @@ void WalletView::showProgress(const QString &title, int nProgress) progressDialog = new QProgressDialog(title, tr("Cancel"), 0, 100); GUIUtil::PolishProgressDialog(progressDialog); progressDialog->setWindowModality(Qt::ApplicationModal); - progressDialog->setMinimumDuration(0); progressDialog->setAutoClose(false); progressDialog->setValue(0); } else if (nProgress == 100) {