2024-12-21 14:13:35 +00:00
|
|
|
/*
|
|
|
|
* MessageBox.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "vcmiqt.h"
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2024-12-21 18:58:43 +00:00
|
|
|
namespace MessageBoxCustom
|
2024-12-21 14:13:35 +00:00
|
|
|
{
|
|
|
|
#ifdef VCMI_IOS
|
|
|
|
// iOS can't display modal dialogs when called directly on button press
|
|
|
|
// https://bugreports.qt.io/browse/QTBUG-98651
|
|
|
|
|
|
|
|
template<typename Functor>
|
2024-12-21 18:58:43 +00:00
|
|
|
inline void showDialog(QWidget *parent, const Functor & f)
|
2024-12-21 14:13:35 +00:00
|
|
|
{
|
2024-12-21 18:58:43 +00:00
|
|
|
QTimer::singleShot(0, parent, f);
|
2024-12-21 14:13:35 +00:00
|
|
|
}
|
|
|
|
|
2024-12-21 18:58:43 +00:00
|
|
|
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
|
2024-12-21 14:13:35 +00:00
|
|
|
{
|
2024-12-21 18:58:43 +00:00
|
|
|
QTimer::singleShot(0, parent, [=](){
|
2024-12-21 14:13:35 +00:00
|
|
|
QMessageBox::information(parent, title, text, buttons, defaultButton);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
template<typename Functor>
|
2024-12-21 18:58:43 +00:00
|
|
|
inline void showDialog(QWidget *parent, const Functor & f)
|
2024-12-21 14:13:35 +00:00
|
|
|
{
|
|
|
|
f();
|
|
|
|
}
|
|
|
|
|
2024-12-21 18:58:43 +00:00
|
|
|
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
|
2024-12-21 14:13:35 +00:00
|
|
|
{
|
|
|
|
QMessageBox::information(parent, title, text, buttons, defaultButton);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|