QTfrontend/util/MessageDialog.cpp
branchwebgl
changeset 8833 c13ebed437cb
parent 8805 c0ea47957bdc
child 9080 9b42757d7e71
equal deleted inserted replaced
8450:404ddce27b23 8833:c13ebed437cb
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  */
    17  */
    18 
    18 
    19 #include "MessageDialog.h"
    19 #include "MessageDialog.h"
       
    20 #include "HWApplication.h"
       
    21 
       
    22 int MessageDialog::ShowFatalMessage(const QString & msg, QWidget * parent)
       
    23 {
       
    24     return ShowMessage(QMessageBox::tr("Hedgewars - Error"),
       
    25                        msg,
       
    26                        QMessageBox::Critical,
       
    27                        parent);
       
    28 }
    20 
    29 
    21 int MessageDialog::ShowErrorMessage(const QString & msg, QWidget * parent)
    30 int MessageDialog::ShowErrorMessage(const QString & msg, QWidget * parent)
    22 {
    31 {
    23     return ShowMessage(msg, QMessageBox::tr("Hedgewars - Warning"), QMessageBox::Warning, parent);
    32     return ShowMessage(QMessageBox::tr("Hedgewars - Warning"),
       
    33                        msg,
       
    34                        QMessageBox::Warning,
       
    35                        parent);
    24 }
    36 }
    25 
    37 
    26 int MessageDialog::ShowInfoMessage(const QString & msg, QWidget * parent)
    38 int MessageDialog::ShowInfoMessage(const QString & msg, QWidget * parent)
    27 {
    39 {
    28     return ShowMessage(msg, QMessageBox::tr("Hedgewars - Information"), QMessageBox::Information, parent);
    40     return ShowMessage(QMessageBox::tr("Hedgewars - Information"),
       
    41                        msg,
       
    42                        QMessageBox::Information,
       
    43                        parent);
    29 }
    44 }
    30 
    45 
    31 int MessageDialog::ShowMessage(const QString & msg, const QString & title, QMessageBox::Icon icon, QWidget * parent)
    46 int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent)
    32 {
    47 {
    33     QMessageBox msgMsg(parent);
    48     QMessageBox msgMsg(parent ? parent : HWApplication::activeWindow());
       
    49     msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars");
       
    50     msgMsg.setText(msg);
    34     msgMsg.setIcon(icon);
    51     msgMsg.setIcon(icon);
    35     msgMsg.setWindowTitle(title.isEmpty() ? QMessageBox::tr("Hedgewars") : title);
       
    36     msgMsg.setText(msg);
       
    37     msgMsg.setWindowModality(Qt::WindowModal);
    52     msgMsg.setWindowModality(Qt::WindowModal);
       
    53 
    38     return msgMsg.exec();
    54     return msgMsg.exec();
    39 }
    55 }