QTfrontend/util/MessageDialog.cpp
author unc0rr
Mon, 20 Jan 2014 00:25:40 +0400
changeset 10022 eb981a03de90
parent 9998 736015b847e3
child 10108 c68cf030eded
permissions -rw-r--r--
- Make Racer report achievements - Add official racer challenge map #1 - Helper script to detect official challenge maps by land digest
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     1
/*
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9080
diff changeset
     3
 * Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     4
 *
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     8
 *
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    12
 * GNU General Public License for more details.
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    13
 *
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    17
 */
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    18
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    19
#include "MessageDialog.h"
8799
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    20
#include "HWApplication.h"
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    21
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    22
int MessageDialog::ShowFatalMessage(const QString & msg, QWidget * parent)
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    23
{
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    24
    return ShowMessage(QMessageBox::tr("Hedgewars - Error"),
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    25
                       msg,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    26
                       QMessageBox::Critical,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    27
                       parent);
8799
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    28
}
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    29
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    30
int MessageDialog::ShowErrorMessage(const QString & msg, QWidget * parent)
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    31
{
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    32
    return ShowMessage(QMessageBox::tr("Hedgewars - Warning"),
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    33
                       msg,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    34
                       QMessageBox::Warning,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    35
                       parent);
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    36
}
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    37
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    38
int MessageDialog::ShowInfoMessage(const QString & msg, QWidget * parent)
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    39
{
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    40
    return ShowMessage(QMessageBox::tr("Hedgewars - Information"),
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    41
                       msg,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    42
                       QMessageBox::Information,
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    43
                       parent);
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    44
}
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    45
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    46
int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent)
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    47
{
8799
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    48
    QMessageBox msgMsg(parent ? parent : HWApplication::activeWindow());
44e520374cfc drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents: 8434
diff changeset
    49
    msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars");
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    50
    msgMsg.setText(msg);
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    51
    msgMsg.setIcon(icon);
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    52
    msgMsg.setWindowModality(Qt::WindowModal);
8805
c0ea47957bdc minor refactor of MessageDialog
koda
parents: 8799
diff changeset
    53
8383
b557c73a7593 GCI2012: Abstract Hedgewars Dialogs
dag10
parents:
diff changeset
    54
    return msgMsg.exec();
8386
2aaa2995a32e - Fix another ton of bugs and misbehavior
unc0rr
parents: 8383
diff changeset
    55
}