-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69eac2f
commit aa77547
Showing
3 changed files
with
97 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 MessageBox | ||
{ | ||
#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> | ||
void showDialog(const Functor & f) | ||
{ | ||
QTimer::singleShot(0, this, f); | ||
} | ||
|
||
void information(QWidget *parent, const QString &title, const QString& text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton) | ||
{ | ||
QTimer::singleShot(0, this, [=](){ | ||
QMessageBox::information(parent, title, text, buttons, defaultButton); | ||
}); | ||
} | ||
|
||
#else | ||
|
||
template<typename Functor> | ||
void showDialog(const Functor & f) | ||
{ | ||
f(); | ||
} | ||
|
||
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 | ||
} |