mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
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.
This commit is contained in:
parent
75850106ae
commit
4935ac583b
4 changed files with 8 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue