Skip to content

Commit b4a34f3

Browse files
hebastoPastaPastaPasta
authored andcommitted
Merge bitcoin-core/gui#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
1 parent 5181629 commit b4a34f3

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
@@ -1926,7 +1926,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
19261926
progressDialog = new QProgressDialog(title, QString(), 0, 100, this);
19271927
GUIUtil::PolishProgressDialog(progressDialog);
19281928
progressDialog->setWindowModality(Qt::ApplicationModal);
1929-
progressDialog->setMinimumDuration(0);
19301929
progressDialog->setAutoClose(false);
19311930
progressDialog->setValue(0);
19321931
} else if (nProgress == 100) {

src/qt/guiutil.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,10 +1874,12 @@ void PolishProgressDialog(QProgressDialog* dialog)
18741874
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
18751875
const int margin = TextWidth(dialog->fontMetrics(), ("X"));
18761876
dialog->resize(dialog->width() + 2 * margin, dialog->height());
1877-
dialog->show();
1878-
#else
1879-
Q_UNUSED(dialog);
18801877
#endif
1878+
// QProgressDialog estimates the time the operation will take (based on time
1879+
// for steps), and only shows itself if that estimate is beyond minimumDuration.
1880+
// The default minimumDuration value is 4 seconds, and it could make users
1881+
// think that the GUI is frozen.
1882+
dialog->setMinimumDuration(0);
18811883
}
18821884

18831885
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
@@ -178,6 +178,9 @@ void WalletControllerActivity::showProgressDialog(const QString& label_text)
178178
m_progress_dialog->setCancelButton(nullptr);
179179
m_progress_dialog->setWindowModality(Qt::ApplicationModal);
180180
GUIUtil::PolishProgressDialog(m_progress_dialog);
181+
// The setValue call forces QProgressDialog to start the internal duration estimation.
182+
// See details in https://bugreports.qt.io/browse/QTBUG-47042.
183+
m_progress_dialog->setValue(0);
181184
}
182185

183186
void WalletControllerActivity::destroyProgressDialog()

src/qt/walletview.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ void WalletView::showProgress(const QString &title, int nProgress)
462462
progressDialog = new QProgressDialog(title, tr("Cancel"), 0, 100, this);
463463
GUIUtil::PolishProgressDialog(progressDialog);
464464
progressDialog->setWindowModality(Qt::ApplicationModal);
465-
progressDialog->setMinimumDuration(0);
466465
progressDialog->setAutoClose(false);
467466
progressDialog->setValue(0);
468467
} else if (nProgress == 100) {

0 commit comments

Comments
 (0)