Skip to content

Commit 4935ac5

Browse files
committed
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.
1 parent 7585010 commit 4935ac5

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/qt/bitcoingui.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
13751375
progressDialog = new QProgressDialog(title, QString(), 0, 100);
13761376
GUIUtil::PolishProgressDialog(progressDialog);
13771377
progressDialog->setWindowModality(Qt::ApplicationModal);
1378-
progressDialog->setMinimumDuration(0);
13791378
progressDialog->setAutoClose(false);
13801379
progressDialog->setValue(0);
13811380
} else if (nProgress == 100) {

src/qt/guiutil.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,12 @@ void PolishProgressDialog(QProgressDialog* dialog)
818818
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
819819
const int margin = TextWidth(dialog->fontMetrics(), ("X"));
820820
dialog->resize(dialog->width() + 2 * margin, dialog->height());
821-
#else
822-
Q_UNUSED(dialog);
823821
#endif
822+
// QProgressDialog estimates the time the operation will take (based on time
823+
// for steps), and only shows itself if that estimate is beyond minimumDuration.
824+
// The default minimumDuration value is 4 seconds, and it could make users
825+
// think that the GUI is frozen.
826+
dialog->setMinimumDuration(0);
824827
}
825828

826829
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
@@ -330,7 +330,6 @@ void WalletView::showProgress(const QString &title, int nProgress)
330330
progressDialog = new QProgressDialog(title, tr("Cancel"), 0, 100);
331331
GUIUtil::PolishProgressDialog(progressDialog);
332332
progressDialog->setWindowModality(Qt::ApplicationModal);
333-
progressDialog->setMinimumDuration(0);
334333
progressDialog->setAutoClose(false);
335334
progressDialog->setValue(0);
336335
} else if (nProgress == 100) {

0 commit comments

Comments
 (0)