Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/util.cpp
#include <qt/test/util.h> | #include <qt/test/util.h> | ||||
#include <QApplication> | #include <QApplication> | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
#include <QPushButton> | #include <QPushButton> | ||||
#include <QString> | #include <QString> | ||||
#include <QTimer> | #include <QTimer> | ||||
#include <QWidget> | #include <QWidget> | ||||
void ConfirmMessage(QString *text, int msec) { | void ConfirmMessage(QString *text, int msec) { | ||||
QTimer::singleShot(msec, [text]() { | QTimer::singleShot(msec, [text] { | ||||
for (QWidget *widget : QApplication::topLevelWidgets()) { | for (QWidget *widget : QApplication::topLevelWidgets()) { | ||||
if (widget->inherits("QMessageBox")) { | if (widget->inherits("QMessageBox")) { | ||||
QMessageBox *messageBox = qobject_cast<QMessageBox *>(widget); | QMessageBox *messageBox = qobject_cast<QMessageBox *>(widget); | ||||
if (text) *text = messageBox->text(); | if (text) { | ||||
*text = messageBox->text(); | |||||
} | |||||
messageBox->defaultButton()->click(); | messageBox->defaultButton()->click(); | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
} | } |