Skip to content

Commit 13f6188

Browse files
committed
qt: Add GUIUtil::ShowModalDialogAndDeleteOnClose
1 parent 503194d commit 13f6188

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/qt/guiutil.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <QClipboard>
3737
#include <QDateTime>
3838
#include <QDesktopServices>
39+
#include <QDialog>
3940
#include <QDoubleValidator>
4041
#include <QFileDialog>
4142
#include <QFont>
@@ -958,4 +959,11 @@ void PrintSlotException(
958959
PrintExceptionContinue(exception, description.c_str());
959960
}
960961

962+
void ShowModalDialogAndDeleteOnClose(QDialog* dialog)
963+
{
964+
dialog->setAttribute(Qt::WA_DeleteOnClose);
965+
dialog->setWindowModality(Qt::ApplicationModal);
966+
dialog->show();
967+
}
968+
961969
} // namespace GUIUtil

src/qt/guiutil.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class QAbstractButton;
4141
class QAbstractItemView;
4242
class QAction;
4343
class QDateTime;
44+
class QDialog;
4445
class QFont;
4546
class QKeySequence;
4647
class QLineEdit;
@@ -417,6 +418,11 @@ namespace GUIUtil
417418
type);
418419
}
419420

421+
/**
422+
* Shows a QDialog instance asynchronously, and deletes it on close.
423+
*/
424+
void ShowModalDialogAndDeleteOnClose(QDialog* dialog);
425+
420426
} // namespace GUIUtil
421427

422428
#endif // BITCOIN_QT_GUIUTIL_H

0 commit comments

Comments
 (0)