Skip to content

Commit be1c512

Browse files
committed
Merge bitcoin-core#343: Improve the GUI responsiveness when progress dialogs are used
4935ac5 qt: Improve GUI responsiveness (Hennadii Stepanov) 7585010 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 4935ac5. 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 4935ac5. jarolrod: ACK 4935ac5 Tree-SHA512: 2ddd74e7fd87894d341d2439dbaa544d031a350f7f57d4c7e9fbba977dc24080fe60fd7a80a542b1647f1de9091d7fd04a36eab695088d4d75fb836548e99b5f
2 parents 123b401 + 4935ac5 commit be1c512

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/qt/bitcoingui.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
13851385
progressDialog = new QProgressDialog(title, QString(), 0, 100);
13861386
GUIUtil::PolishProgressDialog(progressDialog);
13871387
progressDialog->setWindowModality(Qt::ApplicationModal);
1388-
progressDialog->setMinimumDuration(0);
13891388
progressDialog->setAutoClose(false);
13901389
progressDialog->setValue(0);
13911390
} else if (nProgress == 100) {

src/qt/guiutil.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -853,10 +853,12 @@ void PolishProgressDialog(QProgressDialog* dialog)
853853
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
854854
const int margin = TextWidth(dialog->fontMetrics(), ("X"));
855855
dialog->resize(dialog->width() + 2 * margin, dialog->height());
856-
dialog->show();
857-
#else
858-
Q_UNUSED(dialog);
859856
#endif
857+
// QProgressDialog estimates the time the operation will take (based on time
858+
// for steps), and only shows itself if that estimate is beyond minimumDuration.
859+
// The default minimumDuration value is 4 seconds, and it could make users
860+
// think that the GUI is frozen.
861+
dialog->setMinimumDuration(0);
860862
}
861863

862864
int TextWidth(const QFontMetrics& fm, const QString& text)

src/qt/walletcontroller.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ void WalletControllerActivity::showProgressDialog(const QString& label_text)
207207
m_progress_dialog->setCancelButton(nullptr);
208208
m_progress_dialog->setWindowModality(Qt::ApplicationModal);
209209
GUIUtil::PolishProgressDialog(m_progress_dialog);
210+
// The setValue call forces QProgressDialog to start the internal duration estimation.
211+
// See details in https://bugreports.qt.io/browse/QTBUG-47042.
212+
m_progress_dialog->setValue(0);
210213
}
211214

212215
void WalletControllerActivity::destroyProgressDialog()

src/qt/walletview.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ void WalletView::showProgress(const QString &title, int nProgress)
331331
progressDialog = new QProgressDialog(title, tr("Cancel"), 0, 100);
332332
GUIUtil::PolishProgressDialog(progressDialog);
333333
progressDialog->setWindowModality(Qt::ApplicationModal);
334-
progressDialog->setMinimumDuration(0);
335334
progressDialog->setAutoClose(false);
336335
progressDialog->setValue(0);
337336
} else if (nProgress == 100) {

0 commit comments

Comments
 (0)