aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-29 17:12:03 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-29 17:15:21 +0300
commitbe1c512437f7aa8215d2e05eda5cc8b58c3d3937 (patch)
treea7cadc12a74a578c2a7a6d684e3cc4f156925d4a
parent123b401e0acf3b26f149711bdf06d7f6eced1968 (diff)
parent4935ac583bbdc289dd31a1caae3d711edef742b6 (diff)
Merge bitcoin-core/gui#343: Improve the GUI responsiveness when progress dialogs are used
4935ac583bbdc289dd31a1caae3d711edef742b6 qt: Improve GUI responsiveness (Hennadii Stepanov) 75850106aeecfed1d2dc16d8a67ec210c5826a47 qt, macos: Fix GUIUtil::PolishProgressDialog bug (Hennadii Stepanov) Pull request description: [`QProgressDialog`](https://doc.qt.io/qt-5/qprogressdialog.html) estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond [`minimumDuration`](https://doc.qt.io/qt-5/qprogressdialog.html#minimumDuration-prop). The default `minimumDuration` value is [4 seconds](https://doc.qt.io/qt-5/qprogressdialog.html#details), and it could make users think that the GUI is frozen. This PR sets `minimumDuration` to zero for all progress dialogs, that affects ones in the `WalletControllerActivity` class. ACKs for top commit: ryanofsky: Code review ACK 4935ac583bbdc289dd31a1caae3d711edef742b6. I'm not very familiar with this API but all the changes and explanations make sense and are very clear, and this seems like it should be an improvement. promag: Code review ACK 4935ac583bbdc289dd31a1caae3d711edef742b6. jarolrod: ACK 4935ac583bbdc289dd31a1caae3d711edef742b6 Tree-SHA512: 2ddd74e7fd87894d341d2439dbaa544d031a350f7f57d4c7e9fbba977dc24080fe60fd7a80a542b1647f1de9091d7fd04a36eab695088d4d75fb836548e99b5f
-rw-r--r--src/qt/bitcoingui.cpp1
-rw-r--r--src/qt/guiutil.cpp8
-rw-r--r--src/qt/walletcontroller.cpp3
-rw-r--r--src/qt/walletview.cpp1
4 files changed, 8 insertions, 5 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 858010a38c..100022bac1 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1385,7 +1385,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 5ff40ae924..393dca8ccd 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -853,10 +853,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());
- dialog->show();
-#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 c152689f0b..aa26a01541 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 4bae4cab41..cc9e1502f0 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -331,7 +331,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) {