Add workaround for QProgressDialog bug on macOS
See: QTBUG-65750, QTBUG-70357.
This commit is contained in:
parent
035f349371
commit
7c572c488d
4 changed files with 32 additions and 23 deletions
|
@ -1237,25 +1237,21 @@ void BitcoinGUI::detectShutdown()
|
|||
|
||||
void BitcoinGUI::showProgress(const QString &title, int nProgress)
|
||||
{
|
||||
if (nProgress == 0)
|
||||
{
|
||||
progressDialog = new QProgressDialog(title, "", 0, 100);
|
||||
if (nProgress == 0) {
|
||||
progressDialog = new QProgressDialog(title, QString(), 0, 100);
|
||||
GUIUtil::PolishProgressDialog(progressDialog);
|
||||
progressDialog->setWindowModality(Qt::ApplicationModal);
|
||||
progressDialog->setMinimumDuration(0);
|
||||
progressDialog->setCancelButton(nullptr);
|
||||
progressDialog->setAutoClose(false);
|
||||
progressDialog->setValue(0);
|
||||
}
|
||||
else if (nProgress == 100)
|
||||
{
|
||||
if (progressDialog)
|
||||
{
|
||||
} else if (nProgress == 100) {
|
||||
if (progressDialog) {
|
||||
progressDialog->close();
|
||||
progressDialog->deleteLater();
|
||||
}
|
||||
}
|
||||
else if (progressDialog)
|
||||
} else if (progressDialog) {
|
||||
progressDialog->setValue(nProgress);
|
||||
}
|
||||
}
|
||||
|
||||
void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
|
||||
|
|
|
@ -48,13 +48,15 @@
|
|||
#include <QFileDialog>
|
||||
#include <QFont>
|
||||
#include <QFontDatabase>
|
||||
#include <QFontMetrics>
|
||||
#include <QKeyEvent>
|
||||
#include <QLineEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QProgressDialog>
|
||||
#include <QSettings>
|
||||
#include <QTextDocument> // for Qt::mightBeRichText
|
||||
#include <QThread>
|
||||
#include <QUrlQuery>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#pragma GCC diagnostic push
|
||||
|
@ -933,4 +935,16 @@ bool ItemDelegate::eventFilter(QObject *object, QEvent *event)
|
|||
return QItemDelegate::eventFilter(object, event);
|
||||
}
|
||||
|
||||
void PolishProgressDialog(QProgressDialog* dialog)
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
|
||||
const int margin = dialog->fontMetrics().width("X");
|
||||
dialog->resize(dialog->width() + 2 * margin, dialog->height());
|
||||
dialog->show();
|
||||
#else
|
||||
Q_UNUSED(dialog);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace GUIUtil
|
||||
|
|
|
@ -31,6 +31,7 @@ class QAbstractItemView;
|
|||
class QDateTime;
|
||||
class QFont;
|
||||
class QLineEdit;
|
||||
class QProgressDialog;
|
||||
class QUrl;
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
@ -248,6 +249,9 @@ namespace GUIUtil
|
|||
private:
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
};
|
||||
|
||||
// Fix known bugs in QProgressDialog class.
|
||||
void PolishProgressDialog(QProgressDialog* dialog);
|
||||
} // namespace GUIUtil
|
||||
|
||||
#endif // BITCOIN_QT_GUIUTIL_H
|
||||
|
|
|
@ -305,24 +305,19 @@ void WalletView::usedReceivingAddresses()
|
|||
|
||||
void WalletView::showProgress(const QString &title, int nProgress)
|
||||
{
|
||||
if (nProgress == 0)
|
||||
{
|
||||
progressDialog = new QProgressDialog(title, "", 0, 100);
|
||||
if (nProgress == 0) {
|
||||
progressDialog = new QProgressDialog(title, tr("Cancel"), 0, 100);
|
||||
GUIUtil::PolishProgressDialog(progressDialog);
|
||||
progressDialog->setWindowModality(Qt::ApplicationModal);
|
||||
progressDialog->setMinimumDuration(0);
|
||||
progressDialog->setAutoClose(false);
|
||||
progressDialog->setValue(0);
|
||||
progressDialog->setCancelButtonText(tr("Cancel"));
|
||||
}
|
||||
else if (nProgress == 100)
|
||||
{
|
||||
if (progressDialog)
|
||||
{
|
||||
} else if (nProgress == 100) {
|
||||
if (progressDialog) {
|
||||
progressDialog->close();
|
||||
progressDialog->deleteLater();
|
||||
}
|
||||
}
|
||||
else if (progressDialog) {
|
||||
} else if (progressDialog) {
|
||||
if (progressDialog->wasCanceled()) {
|
||||
getWalletModel()->wallet().abortRescan();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue