File tree Expand file tree Collapse file tree 4 files changed +32
-23
lines changed Expand file tree Collapse file tree 4 files changed +32
-23
lines changed Original file line number Diff line number Diff line change @@ -1245,25 +1245,21 @@ void BitcoinGUI::detectShutdown()
1245
1245
1246
1246
void BitcoinGUI::showProgress (const QString &title, int nProgress)
1247
1247
{
1248
- if (nProgress == 0 )
1249
- {
1250
- progressDialog = new QProgressDialog (title, " " , 0 , 100 );
1248
+ if (nProgress == 0 ) {
1249
+ progressDialog = new QProgressDialog (title, QString (), 0 , 100 );
1250
+ GUIUtil::PolishProgressDialog (progressDialog );
1251
1251
progressDialog->setWindowModality (Qt::ApplicationModal);
1252
1252
progressDialog->setMinimumDuration (0 );
1253
- progressDialog->setCancelButton (nullptr );
1254
1253
progressDialog->setAutoClose (false );
1255
1254
progressDialog->setValue (0 );
1256
- }
1257
- else if (nProgress == 100 )
1258
- {
1259
- if (progressDialog)
1260
- {
1255
+ } else if (nProgress == 100 ) {
1256
+ if (progressDialog) {
1261
1257
progressDialog->close ();
1262
1258
progressDialog->deleteLater ();
1263
1259
}
1264
- }
1265
- else if (progressDialog)
1260
+ } else if (progressDialog) {
1266
1261
progressDialog->setValue (nProgress);
1262
+ }
1267
1263
}
1268
1264
1269
1265
void BitcoinGUI::setTrayIconVisible (bool fHideTrayIcon )
Original file line number Diff line number Diff line change 48
48
#include < QFileDialog>
49
49
#include < QFont>
50
50
#include < QFontDatabase>
51
+ #include < QFontMetrics>
51
52
#include < QKeyEvent>
52
53
#include < QLineEdit>
54
+ #include < QMouseEvent>
55
+ #include < QProgressDialog>
53
56
#include < QSettings>
54
57
#include < QTextDocument> // for Qt::mightBeRichText
55
58
#include < QThread>
56
59
#include < QUrlQuery>
57
- #include < QMouseEvent>
58
60
59
61
#if defined(Q_OS_MAC)
60
62
#pragma GCC diagnostic push
@@ -933,4 +935,16 @@ bool ItemDelegate::eventFilter(QObject *object, QEvent *event)
933
935
return QItemDelegate::eventFilter (object, event);
934
936
}
935
937
938
+ void PolishProgressDialog (QProgressDialog* dialog)
939
+ {
940
+ #ifdef Q_OS_MAC
941
+ // Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
942
+ const int margin = dialog->fontMetrics ().width (" X" );
943
+ dialog->resize (dialog->width () + 2 * margin, dialog->height ());
944
+ dialog->show ();
945
+ #else
946
+ Q_UNUSED (dialog);
947
+ #endif
948
+ }
949
+
936
950
} // namespace GUIUtil
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class QAbstractItemView;
31
31
class QDateTime ;
32
32
class QFont ;
33
33
class QLineEdit ;
34
+ class QProgressDialog ;
34
35
class QUrl ;
35
36
class QWidget ;
36
37
QT_END_NAMESPACE
@@ -248,6 +249,9 @@ namespace GUIUtil
248
249
private:
249
250
bool eventFilter (QObject *object, QEvent *event);
250
251
};
252
+
253
+ // Fix known bugs in QProgressDialog class.
254
+ void PolishProgressDialog (QProgressDialog* dialog);
251
255
} // namespace GUIUtil
252
256
253
257
#endif // BITCOIN_QT_GUIUTIL_H
Original file line number Diff line number Diff line change @@ -305,24 +305,19 @@ void WalletView::usedReceivingAddresses()
305
305
306
306
void WalletView::showProgress (const QString &title, int nProgress)
307
307
{
308
- if (nProgress == 0 )
309
- {
310
- progressDialog = new QProgressDialog (title, " " , 0 , 100 );
308
+ if (nProgress == 0 ) {
309
+ progressDialog = new QProgressDialog (title, tr ( " Cancel " ), 0 , 100 );
310
+ GUIUtil::PolishProgressDialog (progressDialog );
311
311
progressDialog->setWindowModality (Qt::ApplicationModal);
312
312
progressDialog->setMinimumDuration (0 );
313
313
progressDialog->setAutoClose (false );
314
314
progressDialog->setValue (0 );
315
- progressDialog->setCancelButtonText (tr (" Cancel" ));
316
- }
317
- else if (nProgress == 100 )
318
- {
319
- if (progressDialog)
320
- {
315
+ } else if (nProgress == 100 ) {
316
+ if (progressDialog) {
321
317
progressDialog->close ();
322
318
progressDialog->deleteLater ();
323
319
}
324
- }
325
- else if (progressDialog) {
320
+ } else if (progressDialog) {
326
321
if (progressDialog->wasCanceled ()) {
327
322
getWalletModel ()->wallet ().abortRescan ();
328
323
} else {
You can’t perform that action at this time.
0 commit comments