1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/*
* 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>
namespace MessageBoxCustom
{
#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>
inline void showDialog(QWidget *parent, const Functor & f)
{
QTimer::singleShot(0, parent, f);
}
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
{
QTimer::singleShot(0, parent, [=](){
QMessageBox::information(parent, title, text, buttons, defaultButton);
});
}
#else
template<typename Functor>
inline void showDialog(QWidget *parent, const Functor & f)
{
f();
}
inline void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton)
{
QMessageBox::information(parent, title, text, buttons, defaultButton);
}
#endif
}
|