author | unc0rr |
Sat, 16 Dec 2017 22:58:28 +0100 | |
changeset 12853 | a9d105dc5c95 |
parent 11046 | 47a8c19ecb60 |
child 14836 | b9437746bffb |
permissions | -rw-r--r-- |
8383 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
8383 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9998
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8383 | 17 |
*/ |
18 |
||
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 |
|
10305 | 22 |
|
23 |
||
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8434
diff
changeset
|
24 |
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
|
25 |
{ |
8805 | 26 |
return ShowMessage(QMessageBox::tr("Hedgewars - Error"), |
27 |
msg, |
|
28 |
QMessageBox::Critical, |
|
29 |
parent); |
|
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8434
diff
changeset
|
30 |
} |
8383 | 31 |
|
32 |
int MessageDialog::ShowErrorMessage(const QString & msg, QWidget * parent) |
|
33 |
{ |
|
8805 | 34 |
return ShowMessage(QMessageBox::tr("Hedgewars - Warning"), |
35 |
msg, |
|
36 |
QMessageBox::Warning, |
|
37 |
parent); |
|
8383 | 38 |
} |
39 |
||
40 |
int MessageDialog::ShowInfoMessage(const QString & msg, QWidget * parent) |
|
41 |
{ |
|
8805 | 42 |
return ShowMessage(QMessageBox::tr("Hedgewars - Information"), |
43 |
msg, |
|
44 |
QMessageBox::Information, |
|
45 |
parent); |
|
8383 | 46 |
} |
47 |
||
8805 | 48 |
int MessageDialog::ShowMessage(const QString & title, const QString & msg, QMessageBox::Icon icon, QWidget * parent) |
8383 | 49 |
{ |
10307
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
50 |
// if no parent try to use active window |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
51 |
parent = parent ? parent : HWApplication::activeWindow(); |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
52 |
|
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
53 |
// didn't work? make child of hwform (e.g. for style and because modal) |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
54 |
if (!parent) |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
55 |
{ |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
56 |
try |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
57 |
{ |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
58 |
HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance()); |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
59 |
if (app->form) |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
60 |
parent = app->form; |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
61 |
} |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
62 |
catch (...) { /* nothing */ } |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
63 |
} |
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
64 |
|
e13d3147f15b
do not get stuck on "in game..." page just because of game crash. output a message instead. could still need some tweaking, but a man gotta sleep. and sheep too...
sheepluva
parents:
10305
diff
changeset
|
65 |
QMessageBox msgMsg(parent); |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8434
diff
changeset
|
66 |
msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars"); |
8383 | 67 |
msgMsg.setText(msg); |
8805 | 68 |
msgMsg.setIcon(icon); |
8383 | 69 |
msgMsg.setWindowModality(Qt::WindowModal); |
8805 | 70 |
|
8383 | 71 |
return msgMsg.exec(); |
8386 | 72 |
} |