author | sheepluva |
Sat, 14 Jun 2014 23:59:20 +0200 | |
changeset 10305 | 17f3ca06e39a |
parent 10108 | c68cf030eded |
child 10307 | e13d3147f15b |
permissions | -rw-r--r-- |
8383 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
9998 | 3 |
* Copyright (c) 2004-2014 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 |
{ |
8799
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8434
diff
changeset
|
50 |
QMessageBox msgMsg(parent ? parent : HWApplication::activeWindow()); |
44e520374cfc
drop QApplication in favor of HWApplication and minor refactor of MessageDialog
koda
parents:
8434
diff
changeset
|
51 |
msgMsg.setWindowTitle(title != NULL ? title : "Hedgewars"); |
8383 | 52 |
msgMsg.setText(msg); |
8805 | 53 |
msgMsg.setIcon(icon); |
8383 | 54 |
msgMsg.setWindowModality(Qt::WindowModal); |
8805 | 55 |
|
10305 | 56 |
if (!parent) |
57 |
{ |
|
58 |
try |
|
59 |
{ |
|
60 |
/* workaround to make sure style is correct |
|
61 |
* I'd rather assign the stylesheet to qApp directly (in main.cpp), |
|
62 |
* but the current Stylesheet will ruin the look (e.g. map selection) :( |
|
63 |
*/ |
|
64 |
HWApplication * app = dynamic_cast<HWApplication*>(HWApplication::instance()); |
|
65 |
if (app->form) |
|
66 |
msgMsg.setStyleSheet(app->form->styleSheet()); |
|
67 |
} |
|
68 |
catch (...) { /* nothing */ } |
|
69 |
} |
|
70 |
||
8383 | 71 |
return msgMsg.exec(); |
8386 | 72 |
} |