blob: 0bd719326e36af6d3bef8a3475b9cbcb64ac8228 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <qt/callback.h>
#include <QApplication>
#include <QMessageBox>
#include <QTimer>
#include <QString>
#include <QPushButton>
#include <QWidget>
void ConfirmMessage(QString* text, int msec)
{
QTimer::singleShot(msec, makeCallback([text](Callback* callback) {
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("QMessageBox")) {
QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget);
if (text) *text = messageBox->text();
messageBox->defaultButton()->click();
}
}
delete callback;
}), &Callback::call);
}
|